private void CreateNewNode(Repo.IElement element, Point position, string modelName) { var model = this.repo.Model(modelName); var newNode = model.CreateElement(element) as Repo.INode; this.CreateNode(newNode, position); }
public void NewNode(Repo.IElement element, string modelName) { var model = this.Repo.Model(modelName); var newNode = model.CreateElement(element) as Repo.INode; this.RaiseNewVertexInRepo(newNode); }
/// <summary> /// Creates a new instance of <see cref="CreateEdgeCommand"/> class. /// </summary> /// <param name="model">Model to which a new edge shall be added.</param> /// <param name="type">Type of a new edge (element from metamodel).</param> /// <param name="source">Source node for an edge.</param> /// <param name="destination">Destination node for an edge.</param> public CreateEdgeCommand(IModel model, Repo.IElement type, Repo.IElement source, Repo.IElement destination) { this.model = model; this.type = type; this.source = source; this.destination = destination; }
public void RemoveElement(Repo.IElement element) { foreach (var modelExplorerElement in this.Elements.ToArray()) { if (modelExplorerElement.Element == element) { this.Elements.Remove(modelExplorerElement); } } }
private void VertexSelectedAction(object sender, VertexSelectedEventArgs args) { this.ctrlVer = args.VertexControl; if (this.currentElement != null && this.currentElement.InstanceMetatype == Repo.Metatype.Edge) { if (this.prevVer == null) { this.editorManager.CreateVirtualEdge(this.ctrlVer, this.ctrlVer.GetPosition()); this.prevVer = this.ctrlVer; } else { this.CreateEdge(this.currentElement as Repo.IEdge); this.prevVer = null; this.editorManager.DestroyVirtualEdge(); this.currentElement = null; } } this.attributesView.DataContext = this.ctrlVer.GetDataVertex <DataVertex>(); this.g_Area.GetAllVertexControls().ToList().ForEach(x => x.GetDataVertex <DataVertex>().Color = Brushes.Green); this.ctrlVer.GetDataVertex <DataVertex>().Color = Brushes.LightBlue; if (this.prevVer != null) { this.prevVer.GetDataVertex <DataVertex>().Color = Brushes.Yellow; } if (args.MouseArgs.RightButton == MouseButtonState.Pressed) { args.VertexControl.ContextMenu = new ContextMenu(); var mi = new MenuItem { Header = "Delete item", Tag = args.VertexControl }; mi.Click += this.MenuItemClickVert; args.VertexControl.ContextMenu.Items.Add(mi); args.VertexControl.ContextMenu.IsOpen = true; } }
private void ZoomCtrl_MouseDown(object sender, MouseButtonEventArgs e, string modelName) { if (e.LeftButton == MouseButtonState.Pressed) { var pos = this.g_zoomctrl.TranslatePoint(e.GetPosition(this.g_zoomctrl), this.g_Area); if (this.currentElement != null && this.currentElement.InstanceMetatype == Repo.Metatype.Node) { this.CreateNewNode(this.currentElement, pos, modelName); this.currentElement = null; } if (this.currentElement != null && this.currentElement.InstanceMetatype == Repo.Metatype.Edge) { if (this.prevVer != null) { this.prevVer = null; this.editorManager.DestroyVirtualEdge(); this.currentElement = null; } } } }
private void OnElementChecked(object sender, RoutedEventArgs e) { var selectedElement = ((sender as ToggleButton)?.DataContext as PaletteElement)?.Element; this.paletteViewModel.SelectedElement = selectedElement; }
/// <summary> /// Clears selected element on a palette. /// </summary> public void ClearSelection() => this.paletteViewModel.SelectedElement = null;
private void CreateNewNode(Repo.IElement element) { var command = new CreateNodeCommand(this.model, element); this.controller.Execute(command); }
public void NewElement(Repo.IElement element) => this.Elements.Add(element.Metatype == Repo.Metatype.Node ? (ModelExplorerElement) new ModelExplorerNode(element) : new ModelExplorerEdge(element));
public void NewEdge(Repo.IElement edge, VertexControl prevVer, VertexControl ctrlVer) { this.model.NewEdge(edge as Repo.IEdge, prevVer?.Vertex as NodeViewModel, ctrlVer?.Vertex as NodeViewModel); }
public void NewNode(Repo.IElement node, string modelName) { this.model.NewNode(node, modelName); }
/// <summary> /// Initializes a new instance of a <see cref="CreateNodeCommand"/> class. /// </summary> /// <param name="model">Model to which a new node shall be added.</param> /// <param name="type">Type of a new node (element from metamodel).</param> public CreateNodeCommand(IModel model, Repo.IElement type) { this.model = model; this.type = type; }
public ModelExplorerEdge(Repo.IElement element) : base(element) { }
private void InitPalette(string metamodelName) { var model = this.repo.Model(metamodelName).Metamodel; if (model == null) { return; } foreach (var type in model.Elements) { if (type.IsAbstract) { continue; } StackPanel sp = new StackPanel() { Orientation = Orientation.Horizontal }; sp.HorizontalAlignment = HorizontalAlignment.Left; Label l = new Label() { Content = type.Name }; Image img = new Image() { Source = type.Shape != string.Empty ? new BitmapImage(new Uri("pack://application:,,,/" + type.Shape)) : new BitmapImage(new Uri("pack://application:,,,/Pictures/Vertex.png")) }; img.LayoutTransform = new ScaleTransform(0.3, 0.3); img.HorizontalAlignment = HorizontalAlignment.Left; l.VerticalAlignment = VerticalAlignment.Center; l.HorizontalAlignment = HorizontalAlignment.Left; sp.Children.Add(img); sp.Children.Add(l); var button = new ToggleButton { Content = sp }; button.HorizontalContentAlignment = HorizontalAlignment.Left; RoutedEventHandler createNode = (sender, args) => this.PaletteButton_Checked(type); RoutedEventHandler createEdge = (sender, args) => { }; button.Click += (sender, args) => this.currentElement = type; if (type.InstanceMetatype == Repo.Metatype.Edge) { this.g_Area.VertexSelected += (sender, args) => button.IsChecked = false; } else { this.g_zoomctrl.MouseDown += (sender, args) => button.IsChecked = false; } // TODO: Bind it to XAML, do not do GUI work in C#. this.paletteGrid.RowDefinitions.Add(new RowDefinition()); this.paletteGrid.Children.Add(button); Grid.SetRow(button, this.paletteGrid.RowDefinitions.Count - 1); } }
private void OnElementUnchecked(object sender, RoutedEventArgs e) { this.paletteViewModel.SelectedElement = null; }
private void PaletteButton_Checked(Repo.IElement element) { this.currentElement = element; }
/// <summary> /// Initializes a new instance of <see cref="RemoveEdgeCommand"/> class. /// </summary> /// <param name="model">Model from which an edge shall be removed.</param> /// <param name="edge">Edge that shall be removed.</param> public RemoveEdgeCommand(IModel model, Repo.IElement edge) { this.model = model; this.edge = edge; }
private void CreateNewNode(Repo.IElement element) { this.controller.NewNode(element, this.model.ModelName); }
/// <summary> /// Initializes a new instance of <see cref="RemoveNodeCommand"/> class. /// </summary> /// <param name="model">Model from which a node shall be removed.</param> /// <param name="node">Node that shall be removed.</param> public RemoveNodeCommand(IModel model, Repo.IElement node) { this.model = model; this.node = node; }
protected ModelExplorerElement(Repo.IElement element) => this.Element = element;