diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/App.config b/Samples/Stencil/CollapseVisibility/CollapseVisibility/App.config new file mode 100644 index 0000000..7b30518 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/App.config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/App.xaml b/Samples/Stencil/CollapseVisibility/CollapseVisibility/App.xaml new file mode 100644 index 0000000..4a591ab --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/App.xaml.cs b/Samples/Stencil/CollapseVisibility/CollapseVisibility/App.xaml.cs new file mode 100644 index 0000000..1246511 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/App.xaml.cs @@ -0,0 +1,11 @@ +using System.Windows; + +namespace StencilDiagramElements +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_462.csproj b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_462.csproj new file mode 100644 index 0000000..2f97a94 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_462.csproj @@ -0,0 +1,101 @@ + + + + + Debug + AnyCPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE} + WinExe + StencilDiagramElements + StencilDiagramElements + v4.6.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + \ No newline at end of file diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_462.sln b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_462.sln new file mode 100644 index 0000000..8e5e72d --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_462.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35209.166 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CollapseVisibility_462", "CollapseVisibility_462.csproj", "{E15DB11B-274C-4738-89B9-D2D15A51B8FE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5E712F1A-8FC2-479C-B0F1-918FAA8313B2} + EndGlobalSection +EndGlobal diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_60.csproj b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_60.csproj new file mode 100644 index 0000000..4f44304 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_60.csproj @@ -0,0 +1,113 @@ + + + WinExe + net6.0-windows + true + true + False + false + false + StencilDiagramElements + StencilDiagramElements + + + TRACE;NET50 + + + TRACE;NET50 + + + TRACE;NET50 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + + + \ No newline at end of file diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_60.sln b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_60.sln new file mode 100644 index 0000000..9660c1c --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_60.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31410.414 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CollapseVisibility_60", "CollapseVisibility_60.csproj", "{E15DB11B-274C-4738-89B9-D2D15A51B8FE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5E712F1A-8FC2-479C-B0F1-918FAA8313B2} + EndGlobalSection +EndGlobal diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_80.csproj b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_80.csproj new file mode 100644 index 0000000..cc85067 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_80.csproj @@ -0,0 +1,111 @@ + + + WinExe + net8.0-windows + true + true + False + false + false + StencilDiagramElements + StencilDiagramElements + + + TRACE;NET50 + + + TRACE;NET50 + + + TRACE;NET50 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + + + + + + \ No newline at end of file diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_80.sln b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_80.sln new file mode 100644 index 0000000..b218233 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/CollapseVisibility_80.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.226.21692 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CollapseVisibility_80", "CollapseVisibility_80.csproj", "{E15DB11B-274C-4738-89B9-D2D15A51B8FE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E15DB11B-274C-4738-89B9-D2D15A51B8FE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5E712F1A-8FC2-479C-B0F1-918FAA8313B2} + EndGlobalSection +EndGlobal diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/MainWindow.xaml b/Samples/Stencil/CollapseVisibility/CollapseVisibility/MainWindow.xaml new file mode 100644 index 0000000..0af7dd7 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/MainWindow.xaml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/MainWindow.xaml.cs b/Samples/Stencil/CollapseVisibility/CollapseVisibility/MainWindow.xaml.cs new file mode 100644 index 0000000..e66a39a --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/MainWindow.xaml.cs @@ -0,0 +1,150 @@ +using Syncfusion.UI.Xaml.Diagram; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows; + +namespace StencilDiagramElements +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + private int nodeIndex = 0; + private int connectorIndex = 0; + List segmentPoints; + public MainWindow() + { + InitializeComponent(); + + diagram.Constraints |= GraphConstraints.Bridging; + diagram.Loaded += OnDiagramLoaded; + + + (diagram.Info as IGraphInfo).ItemAdding += OnItemAdding; + + (diagram.Info as IGraphInfo).ItemDropEvent += MainWindow_ItemDropEvent; + (diagram.Info as IGraphInfo).NodeChangedEvent += MainWindow_NodeChangedEvent; + } + + + //Method to update relative position of parent node to child node. + private void MainWindow_NodeChangedEvent(object sender, ChangeEventArgs args) + { + if (args.NewValue.InteractionState == NodeChangedInteractionState.Dragged) + { + var parentnode = args.Item as CustomNodeViewModel; + if (parentnode.ChildNodes != null && parentnode.ChildNodes.Count > 0) + { + foreach(CustomNodeViewModel childNode in parentnode.ChildNodes as IEnumerable) + { + childNode.OffsetX = parentnode.OffsetX; + childNode.OffsetY = parentnode.OffsetY; + } + } + } + } + + //Method to add dropped node as child as intersected node. + private void MainWindow_ItemDropEvent(object sender, ItemDropEventArgs args) + { + if (args.Source is CustomNodeViewModel && !(args.Target is SfDiagram)) + { + var childNode = args.Source as CustomNodeViewModel; + foreach (var node in args.Target as IEnumerable) + { + if (node is CustomNodeViewModel) + { + var parentNode = node as CustomNodeViewModel; + //Add dropped node as child of intersected node + parentNode.ChildNodes.Add(childNode as CustomNodeViewModel); + //Enable selection for parnet and disable selection for child which is collapsed. + childNode.NodeVisibility = Visibility.Collapsed; + childNode.IsSelected = false; + parentNode.IsSelected = true; + } + } + } + } + + private void OnDiagramLoaded(object sender, RoutedEventArgs e) + { + (diagram.SelectedItems as ISelector).SelectorConstraints = SelectorConstraints.Default & ~(SelectorConstraints.Resizer | SelectorConstraints.Rotator | SelectorConstraints.QuickCommands); + } + + private void OnItemAdding(object sender, ItemAddingEventArgs args) + { + if (args.Item is CustomNodeViewModel node) + { + nodeIndex++; + node.Constraints &= ~NodeConstraints.Connectable; + node.UnitWidth = 100; + node.UnitHeight = 100; + node.Shape = App.Current.MainWindow.Resources["Rectangle"]; + + node.Annotations = new AnnotationCollection() + { + new AnnotationEditorViewModel() { + Content = "Node" + nodeIndex, + Offset= new Point(0.5, 0), + VerticalAlignment=VerticalAlignment.Top, + Margin= new Thickness(0,15,0,0) + } + }; + node.ContentTemplate = null; + node.Content = null; + } + } + + + } + + public class CustomNodeViewModel: NodeViewModel + { + private Visibility nodeVisibility = Visibility.Visible; + public Visibility NodeVisibility + { + get + { + return nodeVisibility; + } + + set + { + if (nodeVisibility != value) + { + nodeVisibility = value; + OnPropertyChanged("NodeVisibility"); + } + } + } + + public List ChildNodes = new List(); + public CustomNodeViewModel() + { + this.Constraints |= NodeConstraints.AllowDrop; + } + } + + public class CustomNodeCollection : ObservableCollection + { + + } + + public class CustomConnectorViewModel : ConnectorViewModel + { + public ConnectorModel Connector { get; set; } + } + + public class CustomConnectorCollection: ObservableCollection + { + + } + + public class ConnectorModel + { + public int Text { get; set; } + } +} diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/AssemblyInfo.cs b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9f8bf2b --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("StencilDiagramElements")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("StencilDiagramElements")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Resources.Designer.cs b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Resources.Designer.cs new file mode 100644 index 0000000..181bbb2 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace StencilDiagramElements.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StencilDiagramElements.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Resources.resx b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Settings.Designer.cs b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Settings.Designer.cs new file mode 100644 index 0000000..a806602 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace StencilDiagramElements.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Settings.settings b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/CollapseVisibility/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Samples/Stencil/CollapseVisibility/README.md b/Samples/Stencil/CollapseVisibility/README.md new file mode 100644 index 0000000..2ff3b83 --- /dev/null +++ b/Samples/Stencil/CollapseVisibility/README.md @@ -0,0 +1,16 @@ +# Collapse visibility sample + +This repository contains sample which shows how to manage the visibility of the node when it is drag and drop over the another node + +__*Documentation*__: https://help.syncfusion.com/wpf/diagram/stencil#preserving-node-template-while-drag-and-drop + +## Project pre-requisites + +To run this application, you need to have the below two in your system + +* [Visual Studio 2019](https://www.visualstudio.com/wpf-vs) +* [Syncfusion.SfDiagram.WPF](https://www.nuget.org/packages/Syncfusion.SfDiagram.WPF/) nuget package. To install the package using NuGet Package Manager, refer this [link](https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio#nuget-package-manager). + +## Deploying and running the sample + +* To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging.