void Diagram_Loaded(object sender, RoutedEventArgs e) { if (this.DataContext is DiagramVM) { (this.DataContext as DiagramVM).ScrollSettings = this.ScrollSettings; } //if (this.DataContext != null && (this.DataContext as DiagramVM)._isValidXml) //{ // IGraphInfo graph = (sender as SfDiagram).Info as IGraphInfo; // PageVM page = (this.DataContext as DiagramVM).PageSettings as PageVM; // graph.Commands.Zoom.Execute( // new ZoomPositionParamenter() // { // ZoomTo = page.Scale // }); // if (graph.ScrollInfo != null) // { // graph.ScrollInfo.PanTo(new Point(page.HOffset, page.VOffset)); // } //} (this.SelectedItems as SelectorViewModel).Commands = new QuickCommandCollection(); QuickCommandViewModel Quickcommands_Delete = AddQuickCommand(new Thickness(0, 50, 0, 0), new Point(.5, 1), "Delete", (this.Info as IGraphInfo).Commands.Delete); QuickCommandViewModel Quickcommands_Draw = AddQuickCommand(new Thickness(50, 0, 0, 0), new Point(1, 0.5), "Draw", (this.Info as IGraphInfo).Commands.Draw); QuickCommandViewModel Quickcommands_Duplicate = AddQuickCommand(new Thickness(50, 50, 0, 0), new Point(1, 1), "Duplicate", (this.Info as IGraphInfo).Commands.Duplicate); }
private void UpdateQuickCommands() { var fillColor = (System.Windows.Media.SolidColorBrush) new BrushConverter().ConvertFromString("White"); var strokeColor = (System.Windows.Media.SolidColorBrush) new BrushConverter().ConvertFromString("#444444"); var resource = new System.Windows.ResourceDictionary() { Source = new Uri(@"/syncfusion.floorplanner.wpf;component/Template/FloorPlanDictionary.xaml", UriKind.RelativeOrAbsolute) }; var quickCommandStyle = new Style() { TargetType = typeof(System.Windows.Shapes.Path) }; quickCommandStyle.Setters.Add(new Setter() { Property = System.Windows.Shapes.Path.StretchProperty, Value = Stretch.Fill }); quickCommandStyle.Setters.Add(new Setter() { Property = System.Windows.Shapes.Path.FillProperty, Value = fillColor }); quickCommandStyle.Setters.Add(new Setter() { Property = System.Windows.Shapes.Path.StrokeProperty, Value = strokeColor }); splitQuickCommand = new QuickCommandViewModel() { Shape = new EllipseGeometry() { RadiusX = 28, RadiusY = 28 }, ShapeStyle = quickCommandStyle, Length = 1, Margin = new Thickness(0, -25, 0, 0), VisibilityMode = VisibilityMode.Connector, Command = this.SplitCommand, ContentTemplate = resource["SplitCommandIcon"] as DataTemplate }; strokeQuickCommand = new QuickCommandViewModel() { Shape = new EllipseGeometry() { RadiusX = 28, RadiusY = 28 }, ShapeStyle = quickCommandStyle, Length = 0, Margin = new Thickness(0, -25, 0, 0), VisibilityMode = VisibilityMode.Connector, Command = this.StrokeChangeCommand, ContentTemplate = resource["StrokeCommandIcon"] as DataTemplate, }; var quickCommandCollection = (this.SelectedItems as SelectorViewModel).Commands as QuickCommandCollection; quickCommandCollection.Add(splitQuickCommand); quickCommandCollection.Add(strokeQuickCommand); }
public MainWindow() { InitializeComponent(); (diagramcontrol.Info as IGraphInfo).ItemUnSelectedEvent += Diagram_ItemUnSelectedEvent; (diagramcontrol.Info as IGraphInfo).ItemSelectedEvent += Diagram_ItemSelectedEvent; EnableOptionsCommand = new Command(c => EnableOptionsCommandClick()); quick1 = AddQuickCommand(); (diagramcontrol.SelectedItems as SelectorViewModel).Commands = new ObservableCollection <QuickCommandViewModel>() { quick1, }; }
/// <summary> /// Method to change the Content value of QuickCommand /// </summary> /// <param name="content"></param> private void OnQuickCommandContentChanged(object content) { QuickCommandViewModel quickCommand = ((this.SelectedItems as SelectorViewModel).Commands as QuickCommandCollection)[0]; if (content.ToString().Equals("Duplicate")) { quickCommand.Command = DuplicateCommand; quickCommand.Content = "M0,2.4879999 L0.986,2.4879999 0.986,9.0139999 6.9950027,9.0139999 6.9950027,10 0.986,10 C0.70400238,10 0.47000122,9.9060001 0.28100207,9.7180004 0.09400177,9.5300007 0,9.2959995 0,9.0139999 z M3.0050011,0 L9.0140038,0 C9.2960014,0 9.5300026,0.093999863 9.7190018,0.28199956 9.906002,0.47000027 10,0.70399952 10,0.986 L10,6.9949989 C10,7.2770004 9.906002,7.5160007 9.7190018,7.7110004 9.5300026,7.9069996 9.2960014,8.0049992 9.0140038,8.0049992 L3.0050011,8.0049992 C2.7070007,8.0049992 2.4650002,7.9069996 2.2770004,7.7110004 2.0890007,7.5160007 1.9950027,7.2770004 1.9950027,6.9949989 L1.9950027,0.986 C1.9950027,0.70399952 2.0890007,0.47000027 2.2770004,0.28199956 2.4650002,0.093999863 2.7070007,0 3.0050011,0 z"; } else if (content.ToString().Equals("Delete")) { quickCommand.Command = DeleteCommand; quickCommand.Content = "M0.54700077,2.2130003 L7.2129992,2.2130003 7.2129992,8.8800011 C7.2129992,9.1920013 7.1049975,9.4570007 6.8879985,9.6739998 6.6709994,9.8910007 6.406,10 6.0939997,10 L1.6659999,10 C1.3539997,10 1.0890004,9.8910007 0.87200136,9.6739998 0.65500242,9.4570007 0.54700071,9.1920013 0.54700077,8.8800011 z M2.4999992,0 L5.2600006,0 5.8329986,0.54600048 7.7599996,0.54600048 7.7599996,1.6660004 0,1.6660004 0,0.54600048 1.9270014,0.54600048 z"; } }
private QuickCommandViewModel AddQuickCommand(Thickness margin, Point offset, string content, ICommand command) { QuickCommandViewModel quickCommand = new QuickCommandViewModel() { Margin = margin, OffsetX = offset.X, OffsetY = offset.Y, Command = command, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, VisibilityMode = VisibilityMode.Node, Content = GetTemplate(content), Shape = "F1M23.467,11.733C23.467,18.213 18.214,23.466 11.734,23.466 5.253,23.466 0,18.213 0,11.733 0,5.253 5.253,0 11.734,0 18.214,0 23.467,5.253 23.467,11.733", ShapeStyle = this.Resources["QuickCommandstyle"] as Style, }; if (content == "Bringtofront") { quickCommand.ShapeStyle = this.Resources["BringToFrontQuickCommandstyle"] as Style; } if (content == "SendToBack") { quickCommand.ShapeStyle = this.Resources["SendToBackQuickCommandstyle"] as Style; } if (content == "Draw" || content == "Draw1" || content == "Duplicate") { DrawParameter drawParameter = new DrawParameter(DrawingTool.Connector, null, null, null, null, NullSourceTarget.SelectionAsSource | NullSourceTarget.CloneSourceAsTarget); DupilicateParameter duplicateParameter = new DupilicateParameter() { DragClone = true }; quickCommand.DragCommand = command; if (content == "Duplicate") { quickCommand.CommandParameter = duplicateParameter; } else { quickCommand.CommandParameter = drawParameter; } } ((DiagramControl.SelectedItems as SelectorViewModel).Commands as QuickCommandCollection).Add(quickCommand); return(quickCommand); }
private QuickCommandViewModel AddQuickCommand() { QuickCommandViewModel quick = new QuickCommandViewModel(); quick.Shape = "F1M23.467,11.733C23.467,18.213 18.214,23.466 11.734,23.466 5.253,23.466 0,18.213 0,11.733 0,5.253 5.253,0 11.734,0 18.214,0 23.467,5.253 23.467,11.733"; quick.ContentTemplate = this.Resources["Template"] as DataTemplate; quick.Command = EnableOptionsCommand; quick.ShapeStyle = App.Current.Resources["QuickCommandShapestyle"] as Style; quick.OffsetX = 1; quick.OffsetY = 1; quick.HorizontalAlignment = HorizontalAlignment.Left; quick.VerticalAlignment = VerticalAlignment.Top; quick.Margin = new Thickness(10); quick.CommandParameter = null; quick.VisibilityMode = VisibilityMode.Node | VisibilityMode.Connector; ((diagramcontrol.SelectedItems as SelectorViewModel).Commands as QuickCommandCollection).Add(quick); return(quick); }
private QuickCommandViewModel AddQuickCommand(Thickness margin, Point offset, string content, ICommand command) { QuickCommandViewModel quickCommand = new QuickCommandViewModel() { Margin = margin, OffsetX = offset.X, OffsetY = offset.Y, Command = command, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, VisibilityMode = VisibilityMode.Node, Content = GetTemplate(content), Shape = "F1M23.467,11.733C23.467,18.213 18.214,23.466 11.734,23.466 5.253,23.466 0,18.213 0,11.733 0,5.253 5.253,0 11.734,0 18.214,0 23.467,5.253 23.467,11.733", ShapeStyle = GetQuickCommandShapeStyle(), ContentTemplate = GetQuickCommandContentTemplate() }; ((this.SelectedItems as SelectorViewModel).Commands as QuickCommandCollection).Add(quickCommand); return(quickCommand); }
//Get style private void Style1_Checked(object sender, RoutedEventArgs e) { RadioButton send = sender as RadioButton; switch (send.Name) { case "Style1": ChangeResizer("OldSelector"); break; case "Style2": Style3.IsChecked = false; Style4.IsChecked = false; (diagramControl.SelectedItems as SelectorViewModel).Commands = null; ChangeResizer("VisioSelector"); break; case "Style3": Style4.IsChecked = false; Style2.IsChecked = false; (diagramControl.SelectedItems as SelectorViewModel).Commands = new QuickCommandCollection(); QuickCommandViewModel senddtoback = AddQuickCommand(new Thickness(-60, -60, 0, 0), new Point(0, 0), "SendToBack", (diagramControl.Info as IGraphInfo).Commands.SendToBack); QuickCommandViewModel bringtofront = AddQuickCommand(new Thickness(0, -60, 0, 0), new Point(0.5, 0), "Bringtofront", (diagramControl.Info as IGraphInfo).Commands.BringToFront); QuickCommandViewModel delete = AddQuickCommand(new Thickness(60, -60, 0, 0), new Point(1, 0), "Delete", (diagramControl.Info as IGraphInfo).Commands.Delete); QuickCommandViewModel draw = AddQuickCommand(new Thickness(60, 0, 0, 0), new Point(1, 0.5), "Draw", (diagramControl.Info as IGraphInfo).Commands.Draw); ChangeResizer("CustomSelector"); break; case "Style4": Style3.IsChecked = false; Style2.IsChecked = false; (diagramControl.SelectedItems as SelectorViewModel).Commands = new QuickCommandCollection(); QuickCommandViewModel Quickcommands_Delete = AddQuickCommand(new Thickness(0, 50, 0, 0), new Point(.5, 1), "Delete", (diagramControl.Info as IGraphInfo).Commands.Delete); QuickCommandViewModel Quickcommands_Draw = AddQuickCommand(new Thickness(50, 0, 0, 0), new Point(1, 0.5), "Draw1", (diagramControl.Info as IGraphInfo).Commands.Draw); QuickCommandViewModel Quickcommands_Duplicate = AddQuickCommand(new Thickness(50, 50, 0, 0), new Point(1, 1), "Duplicate", (diagramControl.Info as IGraphInfo).Commands.Duplicate); diagramControl.SFSelector.ClearValue(Selector.StyleProperty); break; } }
private void MindMapDiagram_Loaded(object sender, RoutedEventArgs e) { this.CommandManager.View = this; this.SetBinding(SnapSettingsProperty, new Binding() { Path = new PropertyPath("SnapSettings"), Mode = BindingMode.TwoWay }); this.SetBinding(CommandManagerProperty, new Binding() { Path = new PropertyPath("CommandManager"), Mode = BindingMode.TwoWay }); this.SetBinding(ConstraintsProperty, new Binding() { Path = new PropertyPath("Constraints"), Mode = BindingMode.TwoWay }); //this.SetBinding(ExportSettingsProperty, //new Binding() //{ // Path = new PropertyPath("ExportSettings"), // Mode = BindingMode.TwoWay //}); ((SelectedItems as SelectorViewModel).Commands as QuickCommandCollection).Clear(); ViewModel.Quickcommands_Left = Quickcommands_Left = AddQuickCommand(new Thickness(-18, 0, 0, 0), new Point(0, 0.5), "Left", ViewModel.AddLeftChildCommand); ViewModel.Quickcommands_Right = Quickcommands_Right = AddQuickCommand(new Thickness(18, 0, 0, 0), new Point(1, 0.5), "Right", ViewModel.AddRightChildCommand); ViewModel.Quickcommands_Delete = Quickcommands_Delete = AddQuickCommand(new Thickness(22, 0, 0, 0), new Point(1, 0.5), "Delete", ViewModel.DeleteChildCommand); Quickcommands_Delete.VisibilityMode = VisibilityMode.Connector; //FitToPageParameter fitToPage = new FitToPageParameter() { FitToPage = FitToPage.FitToPage, Region = Region.PageSettings }; //(this.Info as IGraphInfo).Commands.FitToPage.Execute(fitToPage); this.Loaded -= MindMapDiagram_Loaded; }
/// <summary> /// Method to change the Shape of the QuickCommand /// </summary> /// <param name="shape"></param> private void OnQuickCommandShapeChanged(object shape) { QuickCommandViewModel quickCommand = ((this.SelectedItems as SelectorViewModel).Commands as QuickCommandCollection)[0]; quickCommand.Shape = App.Current.Resources[shape.ToString()]; }
/// <summary> /// This method is used to notify when the diagram is loaded. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void Diagram_Loaded(object sender, RoutedEventArgs e) { (sender as SfDiagram).Constraints = (sender as SfDiagram).Constraints | GraphConstraints.Undoable; this.CommandManager.View = this; if ((this.DataContext as IDiagramViewModel).FirstLoad != null) { (this.DataContext as IDiagramViewModel).FirstLoad.Execute(null); } this.SetBinding( SnapSettingsProperty, new Binding { Path = new PropertyPath("SnapSettings"), Mode = BindingMode.TwoWay }); if (this.DataContext is BrainstormingVM) { this.SetBinding( CommandManagerProperty, new Binding { Path = new PropertyPath("CommandManager"), Mode = BindingMode.TwoWay }); } this.SetBinding( ConstraintsProperty, new Binding { Path = new PropertyPath("Constraints"), Mode = BindingMode.TwoWay }); if (this.DataContext is BrainstormingVM) { BrainstormingVM dataContext = this.DataContext as BrainstormingVM; ((this.SelectedItems as SelectorViewModel).Commands as QuickCommandCollection).Clear(); dataContext.QuickCommands_Left = this.QuickCommands_Left = this.AddQuickCommand( new Thickness(-18, 0, 0, 0), new Point(0, 0.5), "Left", dataContext.AddLeftChildCommand); dataContext.QuickCommands_Right = this.QuickCommands_Right = this.AddQuickCommand( new Thickness(18, 0, 0, 0), new Point(1, 0.5), "Right", dataContext.AddRightChildCommand); dataContext.QuickCommands_Delete = this.QuickCommands_Delete = this.AddQuickCommand( new Thickness(22, 0, 0, 0), new Point(1, 0.5), "Delete", dataContext.DeleteChildCommand); this.QuickCommands_Delete.VisibilityMode = VisibilityMode.Connector; (this.SelectedItems as SelectorViewModel).SelectorConstraints &= ~SelectorConstraints.Rotator; if (dataContext.Rootnode != null) { dataContext.Rootnode.Constraints.Remove(NodeConstraints.ExcludeFromLayout); dataContext.Updatebowtielayout("left"); dataContext.Updatebowtielayout("right"); dataContext.Rootnode.IsSelected = true; } } else if (DataContext is OrganizationChartDiagramVM) { OrganizationChartDiagramVM dataContext = (DataContext as OrganizationChartDiagramVM); ((SelectedItems as SelectorViewModel).Commands as QuickCommandCollection).Clear(); dataContext.Quickcommands_Add = Quickcommands_Add = AddQuickCommand(new Thickness(20, 0, 0, 0), new Point(1, 0), "Add", dataContext.AddChildCommand); dataContext.Quickcommands_Delete = QuickCommands_Delete = AddQuickCommand(new Thickness(20, 20, 0, 0), new Point(1, 1), "Delete", dataContext.DeleteCommand); (SelectedItems as SelectorViewModel).SelectorConstraints &= ~SelectorConstraints.Rotator; } foreach (Window win in Application.Current.Windows) { if (win.DataContext is DiagramBuilderVM) { (win.DataContext as DiagramBuilderVM).IsLoaded = true; } } }