private void AddChildCommandExecute(object param) { var selectednode = ((this.SelectedItems as SelectorViewModel).Nodes as ObservableCollection <object>)[0] as OrganizationChartNodeVM; OrganizationChartNodeVM node = new OrganizationChartNodeVM() { ContentTemplate = selectednode.ContentTemplate as DataTemplate, CustomContentTemplate = selectednode.CustomContentTemplate, CustomContent = new CustomContent() { Image = "/syncfusion.diagrambuilder.wpf;component/Resources/male.png", ImageVisibility = 100 }, ID = id.ToString(), ParentID = selectednode.ID.ToString(), UnitWidth = 200, UnitHeight = 120, Annotations = new List <IAnnotation>() { new LabelVM() { Content = "Name", FontSize = 12, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = ((selectednode.Annotations as List <IAnnotation>)[0] as LabelVM).TextHorizontalAlignment, TextVerticalAlignment = ((selectednode.Annotations as List <IAnnotation>)[0] as LabelVM).TextVerticalAlignment, Offset = ((selectednode.Annotations as List <IAnnotation>)[0] as LabelVM).Offset, LabelWidth = ((selectednode.Annotations as List <IAnnotation>)[0] as LabelVM).LabelWidth, }, new LabelVM() { FontSize = 12, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).TextHorizontalAlignment, TextVerticalAlignment = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).TextVerticalAlignment, HorizontalAlignment = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).HorizontalAlignment, VerticalAlignment = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).VerticalAlignment, Offset = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).Offset, LabelWidth = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).LabelWidth, }, } }; foreach (string labels in RoleAnnotation as List <string> ) { LabelVM anno = (node.Annotations as List <IAnnotation>)[1] as LabelVM; if (anno.Content != null) { anno.Content = anno.Content.ToString() + "\n" + labels; } else { anno.Content = labels; } } id++; (OrgNodeCollection as NodeVMCollection).Add(node); ((this.SelectedItems as SelectorViewModel).Nodes as ObservableCollection <object>).Clear(); node.IsSelected = true; this.LayoutManager.Layout.UpdateLayout(); }
private void EditCommandExecute(object param) { List <string> contents = new List <string>(); OrganizationChartNodeVM firstnode = (NodeCollection as ObservableCollection <OrganizationChartNodeVM>).First(); LabelVM firstlabel = (firstnode.Annotations as List <IAnnotation>)[0] as LabelVM; foreach (string labels in RoleAnnotation as List <string> ) { contents.Add(labels); } AdditionalInformationWindow window = new AdditionalInformationWindow(); window.Annotations = contents; window.Annotation = firstlabel.Content.ToString(); window.ShowDialog(); List <String> Annotations = window.Annotations; string Annotation = window.Annotation; foreach (OrganizationChartNodeVM node in NodeCollection as ObservableCollection <OrganizationChartNodeVM> ) { LabelVM label = (node.Annotations as List <IAnnotation>).ElementAt(0) as LabelVM; label.Content = Annotation.ToString(); } if (Annotations.Count > 0) { RoleAnnotation = Annotations; foreach (OrganizationChartNodeVM node in NodeCollection as ObservableCollection <OrganizationChartNodeVM> ) { LabelVM label = (node.Annotations as List <IAnnotation>).ElementAt(1) as LabelVM; label.Content = null; foreach (string labels in Annotations as List <string> ) { if (label.Content != null) { label.Content = label.Content.ToString() + "\n" + labels; } else { label.Content = labels; } } } } else { foreach (OrganizationChartNodeVM node in NodeCollection as ObservableCollection <OrganizationChartNodeVM> ) { LabelVM label = (node.Annotations as List <IAnnotation>).ElementAt(1) as LabelVM; label.Content = null; label.ReadOnly = false; } } this.LayoutManager.Layout.UpdateLayout(); }
private void DeleteCommandExecute(object param) { for (int i = 0; i < ((this.SelectedItems as SelectorViewModel).Nodes as ObservableCollection <object>).Count();) { OrganizationChartNodeVM selectedNode = ((this.SelectedItems as SelectorViewModel).Nodes as ObservableCollection <object>)[i] as OrganizationChartNodeVM; if (selectedNode.Type != "root") { DeleteNode(selectedNode); } } this.LayoutManager.Layout.UpdateLayout(); }
private OrganizationChartNodeVM AddRootNode() { ResourceDictionary resourceDictionary = new ResourceDictionary() { Source = new Uri(@"/syncfusion.diagrambuilder.Wpf;component/OrganizationChart/Theme/OrganizationChartUI.xaml", UriKind.RelativeOrAbsolute) }; OrganizationChartNodeVM n = new OrganizationChartNodeVM(); n.ContentTemplate = resourceDictionary["Belt"] as DataTemplate; n.CustomContentTemplate = "Belt"; n.CustomContent = new CustomContent() { Image = "/syncfusion.diagrambuilder.wpf;component/Resources/male.png", }; n.ID = id.ToString(); n.ParentID = ""; n.UnitWidth = 200; n.UnitHeight = 120; n.Type = "root"; id++; n.Annotations = new List <IAnnotation>() { new LabelVM() { Content = "Name", FontSize = 12, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = TextAlignment.Center, TextVerticalAlignment = VerticalAlignment.Center, Offset = new Point(0.5, 0.8), LabelWidth = 180, }, new LabelVM() { Content = "Role", FontSize = 12, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = TextAlignment.Left, TextVerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Offset = new Point(0.5, 0.65), LabelWidth = 85, }, }; (OrgNodeCollection as NodeVMCollection).Add(n); return(n); }
private void ExpandCollapseExecute(object obj) { OrganizationChartNodeVM node = ((this.SelectedItems as SelectorVM).Nodes as IEnumerable <object>).FirstOrDefault() as OrganizationChartNodeVM; if (node != null && (node.Info as INodeInfo) != null && (node.Info as INodeInfo).OutConnectors != null && (node.Info as INodeInfo).OutConnectors.Count() > 0) { ExpandCollapseParameter parameter = new ExpandCollapseParameter() { Node = node, }; (this.Info as IGraphInfo).Commands.ExpandCollapse.Execute(parameter); } }
private void InsertPictureExecute(object obj) { OrganizationChartNodeVM node = ((this.SelectedItems as SelectorVM).Nodes as IEnumerable <object>).FirstOrDefault() as OrganizationChartNodeVM; if (node != null) { OpenFileDialog openDialogBox = new OpenFileDialog(); openDialogBox.Title = "File Open"; if (openDialogBox.ShowDialog() == true) { (node.CustomContent as CustomContent).Image = openDialogBox.FileName.ToString(); } } }
private void ItemSelectedCommandExecute(object param) { DiagramEventArgs args = param as DiagramEventArgs; if (args.Item is OrganizationChartNodeVM) { OrganizationChartNodeVM node = args.Item as OrganizationChartNodeVM; UpdateQuickCommandsVisibility(); } if (args.Item is OrganizationChartNodeVM && (args.Item as OrganizationChartNodeVM).Type == "root") { this.Quickcommands_Delete.VisibilityMode = VisibilityMode.Connector; } }
private OrganizationChartNodeVM AddRootNode() { OrganizationChartNodeVM n = new OrganizationChartNodeVM(); n.ContentTemplate = App.Current.FindResource("Belt") as DataTemplate; n.CustomContentTemplate = "Belt"; n.CustomContent = new CustomContent() { Image = "/Resources/male.png", }; n.ID = id.ToString(); n.ParentID = ""; n.UnitWidth = 200; n.UnitHeight = 120; n.Type = "root"; id++; n.Annotations = new List <IAnnotation>() { new LabelVM() { Content = "Name", FontSize = 12, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = TextAlignment.Center, TextVerticalAlignment = VerticalAlignment.Center, Offset = new Point(0.5, 0.8), LabelWidth = 180, }, new LabelVM() { Content = "Role", FontSize = 12, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = TextAlignment.Left, TextVerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Offset = new Point(0.5, 0.65), LabelWidth = 85, }, }; (OrgNodeCollection as NodeVMCollection).Add(n); return(n); }
private void DeleteNode(OrganizationChartNodeVM SelectedNode) { if ((SelectedNode.Info as INodeInfo).OutNeighbors != null && (SelectedNode.Info as INodeInfo).OutNeighbors.Count() > 0) { for (int i = (SelectedNode.Info as INodeInfo).OutNeighbors.Count() - 1; (SelectedNode.Info as INodeInfo).OutNeighbors.Count() - 1 >= i && i >= 0; i--) { OrganizationChartNodeVM c = (SelectedNode.Info as INodeInfo).OutNeighbors.ElementAt(i) as OrganizationChartNodeVM; DeleteNode(c); } } if ((SelectedNode.Info as INodeInfo).InOutConnectors != null && (SelectedNode.Info as INodeInfo).OutNeighbors.Count() > 0) { for (int i = (SelectedNode.Info as INodeInfo).InOutConnectors.Count() - 1; (SelectedNode.Info as INodeInfo).InOutConnectors.Count() - 1 >= i && i >= 0; i--) { OrganizationChartNodeVM con = (SelectedNode.Info as INodeInfo).InOutConnectors.ElementAt(i) as OrganizationChartNodeVM; (this.Connectors as ObservableCollection <OrganizationChartNodeVM>).Remove(con); } } (OrgNodeCollection as NodeVMCollection).Remove(SelectedNode); }