public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu) { var buttonHolder = widgetViewModel as TicketExplorerViewModel; var ret = new TicketExplorerView { DataContext = buttonHolder, ContextMenu = contextMenu }; var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var radiusBinding = new Binding("CornerRadius") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var buttonColorBinding = new Binding("ButtonColor") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var enabledBinding = new Binding("IsEnabled") { Source = buttonHolder, Mode = BindingMode.OneWay }; var transformBinding = new Binding("RenderTransform") { Source = buttonHolder, Mode = BindingMode.OneWay }; ret.SetBinding(InkCanvas.LeftProperty, xBinding); ret.SetBinding(InkCanvas.TopProperty, yBinding); ret.SetBinding(FrameworkElement.HeightProperty, heightBinding); ret.SetBinding(FrameworkElement.WidthProperty, widthBinding); //ret.SetBinding(FlexButton.FlexButton.CornerRadiusProperty, radiusBinding); //ret.SetBinding(FlexButton.FlexButton.ButtonColorProperty, buttonColorBinding); //ret.SetBinding(UIElement.RenderTransformProperty, transformBinding); //ret.SetBinding(UIElement.IsEnabledProperty, enabledBinding); return ret; }
public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu) { var buttonHolder = widgetViewModel as EntityButtonWidgetViewModel; var ret = new FlexButton.FlexButton { DataContext = buttonHolder, ContextMenu = contextMenu, CommandParameter = buttonHolder }; var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var captionBinding = new Binding("Settings.Caption") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var radiusBinding = new Binding("CornerRadius") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var buttonColorBinding = new Binding("ButtonColor") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var commandBinding = new Binding("ItemClickedCommand") { Source = buttonHolder, Mode = BindingMode.OneWay }; var enabledBinding = new Binding("IsEnabled") { Source = buttonHolder, Mode = BindingMode.OneWay }; var rotateTransform = new Binding("RotateTransform") { Source = buttonHolder, Mode = BindingMode.OneWay }; ret.SetBinding(InkCanvas.LeftProperty, xBinding); ret.SetBinding(InkCanvas.TopProperty, yBinding); ret.SetBinding(FrameworkElement.HeightProperty, heightBinding); ret.SetBinding(FrameworkElement.WidthProperty, widthBinding); ret.SetBinding(ContentControl.ContentProperty, captionBinding); ret.SetBinding(FlexButton.FlexButton.CornerRadiusProperty, radiusBinding); ret.SetBinding(FlexButton.FlexButton.ButtonColorProperty, buttonColorBinding); ret.SetBinding(ButtonBase.CommandProperty, commandBinding); ret.SetBinding(FrameworkElement.LayoutTransformProperty, rotateTransform); //ret.SetBinding(UIElement.IsEnabledProperty, enabledBinding); return ret; }
public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu) { var viewModel = widgetViewModel as TicketExplorerWidgetViewModel; Debug.Assert(viewModel != null); var ret = new TicketExplorerView { DataContext = viewModel.TicketExplorerViewModel, ContextMenu = contextMenu, Tag = viewModel }; var heightBinding = new Binding("Height") { Source = viewModel, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = viewModel, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = viewModel, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = viewModel, Mode = BindingMode.TwoWay }; ret.SetBinding(InkCanvas.LeftProperty, xBinding); ret.SetBinding(InkCanvas.TopProperty, yBinding); ret.SetBinding(FrameworkElement.HeightProperty, heightBinding); ret.SetBinding(FrameworkElement.WidthProperty, widthBinding); return(ret); }
public override void SetReference(IDocument document) { if (diagram != null) { diagram.SelectionChanged -= new EventHandler(diagram_SelectionChanged); } if (document == null) { diagram = null; } else { // TODO do this in a sane way diagram = document as ClassDiagram; if (diagram == null) { throw new Exception("This is not a class diagram"); } diagram.SelectionChanged += new EventHandler(diagram_SelectionChanged); mnuNewStructure.Visible = ((ClassDiagram)diagram).Language.SupportsStructures; mnuNewDelegate.Visible = ((ClassDiagram)diagram).Language.SupportsDelegates; toolNewStructure.Visible = ((ClassDiagram)diagram).Language.SupportsStructures; toolNewDelegate.Visible = ((ClassDiagram)diagram).Language.SupportsDelegates; toolDelete.Enabled = diagram.HasSelectedElement; } }
public DiagramViewModel( [NotNull] IModelEventSource modelEventSource, [NotNull] IDiagramEventSource diagramEventSource, [NotNull] IDiagramViewportUi diagramViewportUi, [NotNull] IRelatedNodeItemViewModelFactory relatedNodeItemViewModelFactory, [NotNull] IComparer <IModelNode> modelNodeComparer) : base(modelEventSource, diagramEventSource) { _relatedNodeItemViewModelFactory = relatedNodeItemViewModelFactory; _modelNodeComparer = modelNodeComparer; DiagramViewportViewModel = (DiagramViewportViewModel)diagramViewportUi; RelatedNodeListBoxViewModel = new RelatedNodeListBoxViewModel(ModelEventSource, DiagramEventSource); RelatedNodeListBoxViewModel.ItemSelected += OnRelatedNodeSelected; RelatedNodeListBoxViewModel.Items.CollectionChanged += OnRelatedNodeCollectionChanged; PopupTextViewModel = new AutoHidePopupTextViewModel(); PreviewMouseDownCommand = new DelegateCommand(OnAnyMouseDownEvent); MouseDownCommand = new DelegateCommand(OnUnhandledMouseDownEvent); DiagramEventSource.DiagramChanged += OnDiagramChanged; SubscribeToViewportEvents(); _lastDiagram = DiagramEventSource.LatestDiagram; }
public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu) { var buttonHolder = widgetViewModel as DefaultWidgetViewModel; var brd = new Border { DataContext = buttonHolder, ContextMenu = contextMenu, BorderBrush = System.Windows.Media.Brushes.Gray, Background = System.Windows.Media.Brushes.White }; var ret = new Button { DataContext = buttonHolder, ContextMenu = contextMenu, Content = "New Widget" }; brd.Child = ret; var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var transformBinding = new Binding("RenderTransform") { Source = buttonHolder, Mode = BindingMode.OneWay }; brd.SetBinding(InkCanvas.LeftProperty, xBinding); brd.SetBinding(InkCanvas.TopProperty, yBinding); brd.SetBinding(FrameworkElement.HeightProperty, heightBinding); brd.SetBinding(FrameworkElement.WidthProperty, widthBinding); brd.SetBinding(UIElement.RenderTransformProperty, transformBinding); return brd; }
private IEnumerable <DiagramEventBase> UpdateModelCore([NotNull] IModel model) { LatestDiagram = LatestDiagram.WithModel(model); yield return(new DiagramModelUpdatedEvent(LatestDiagram)); // TODO: remove those shapes whose model item no longer exists }
public DiagramViewModel( IModelService modelService, IDiagramService diagramService, IDiagramShapeUiFactory diagramShapeUiFactory, double minZoom, double maxZoom, double initialZoom) : base(modelService, diagramService) { DiagramShapeUiFactory = diagramShapeUiFactory; DiagramViewportViewModel = new DiagramViewportViewModel( ModelService, DiagramService, diagramShapeUiFactory, minZoom, maxZoom, initialZoom); RelatedNodeListBoxViewModel = new RelatedNodeListBoxViewModel(ModelService, DiagramService); RelatedNodeListBoxViewModel.ItemSelected += OnRelatedNodeSelected; RelatedNodeListBoxViewModel.Items.CollectionChanged += OnRelatedNodeCollectionChanged; PopupTextViewModel = new AutoHidePopupTextViewModel(); PreviewMouseDownCommand = new DelegateCommand(OnAnyMouseDownEvent); MouseDownCommand = new DelegateCommand(OnUnhandledMouseDownEvent); DiagramService.DiagramChanged += OnDiagramChanged; SubscribeToViewportEvents(); _lastDiagram = DiagramService.LatestDiagram; }
public FrameworkElement CreateWidgetControl(IDiagram widget, ContextMenu contextMenu) { var viewModel = widget as EntityGridWidgetViewModel; Debug.Assert(viewModel != null); if (widget.DesignMode) { viewModel.RefreshSync(); foreach (var entityScreenItemViewModel in viewModel.ResourceSelectorViewModel.EntityScreenItems) { entityScreenItemViewModel.IsEnabled = false; } } var ret = new EntitySelectorView(viewModel.ResourceSelectorViewModel) { DataContext = viewModel.ResourceSelectorViewModel, ContextMenu = contextMenu, Tag = widget }; var heightBinding = new Binding("Height") { Source = viewModel, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = viewModel, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = viewModel, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = viewModel, Mode = BindingMode.TwoWay }; ret.SetBinding(InkCanvas.LeftProperty, xBinding); ret.SetBinding(InkCanvas.TopProperty, yBinding); ret.SetBinding(FrameworkElement.HeightProperty, heightBinding); ret.SetBinding(FrameworkElement.WidthProperty, widthBinding); return ret; }
protected override bool CloneEntity(IDiagram diagram) { if (diagram.DiagramType != DiagramType.ClassDiagram) return false; return ((ClassDiagram)diagram).InsertComment(Comment.Clone()); }
protected static void AddControl(IDiagram buttonHolder, InkCanvas parentControl) { var ret = new FlexButton.FlexButton { DataContext = buttonHolder, ContextMenu = ButtonContextMenu }; ret.CommandParameter = buttonHolder; parentControl.Children.Add(ret); var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var captionBinding = new Binding("Caption") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var radiusBinding = new Binding("CornerRadius") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var buttonColorBinding = new Binding("ButtonColor") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var commandBinding = new Binding("Command") { Source = buttonHolder, Mode = BindingMode.OneWay }; var enabledBinding = new Binding("IsEnabled") { Source = buttonHolder, Mode = BindingMode.OneWay }; var transformBinding = new Binding("RenderTransform") { Source = buttonHolder, Mode = BindingMode.OneWay }; ret.SetBinding(LeftProperty, xBinding); ret.SetBinding(TopProperty, yBinding); ret.SetBinding(HeightProperty, heightBinding); ret.SetBinding(WidthProperty, widthBinding); ret.SetBinding(ContentControl.ContentProperty, captionBinding); ret.SetBinding(FlexButton.FlexButton.CornerRadiusProperty, radiusBinding); ret.SetBinding(FlexButton.FlexButton.ButtonColorProperty, buttonColorBinding); ret.SetBinding(ButtonBase.CommandProperty, commandBinding); ret.SetBinding(RenderTransformProperty, transformBinding); ret.SetBinding(IsEnabledProperty, enabledBinding); }
// XML generator diagrams public void xg(int indnt, StreamWriter writer, IDiagram node, string msg) { indent(indnt, writer); if (msg != "") { writer.WriteLine(msg); } writer.Write("<IDiagram NodeId=\"" + node.UniqueId + "\" ParentId=\"" + node.ParentNode.UniqueId + "\" DiagramIndex=\"" + node.Index + "\">\n"); // A diagram contains a collection of nodes // Only XML generator those who are direct children of this diagram (the method // GetAllNodes() returns all nodes inside the diagram, not just direct children foreach (var n in node.GetAllNodes()) { INode tmp = n.ParentNode; if (tmp != null && tmp == node) { xg(indnt + 1, writer, (dynamic)n, ""); } } indent(indnt, writer); writer.Write("</IDiagram>\n"); }
private void HandleIncomingDataFlow(IEntity target, IThreatModel model, IDiagram diagram, ReplacementStrategy strategy, IDataFlow flow, IDataFlow existing) { if (existing != null) { switch (strategy) { case ReplacementStrategy.Stop: // This should not happen! throw new InvalidOperationException("Replacement Strategy is Stop."); case ReplacementStrategy.Replace: model.RemoveDataFlow(existing.Id); MoveIncomingDataFlow(target, model, diagram, flow); break; case ReplacementStrategy.Skip: break; default: throw new ArgumentOutOfRangeException(nameof(strategy), strategy, null); } } else { MoveIncomingDataFlow(target, model, diagram, flow); } }
private void AddProjectItemNode(IProjectItem projectItem) { ModelNode node = null; if (projectItem is IDiagram) { IDiagram diagram = (IDiagram)projectItem; node = new DiagramNode(diagram); if (TreeView != null) { ModelView.OnDocumentOpening(new DocumentEventArgs(diagram)); } } // More kind of items might be possible later... if (node != null) { Nodes.Add(node); if (TreeView != null) { node.AfterInitialized(); TreeView.SelectedNode = node; } if (projectItem.IsUntitled) { node.EditLabel(); } } }
private string ImageKeyForDiagram(IDiagram diagram) { switch (diagram.DiagramType) { case DiagramType.ClassDiagram: var doc = (ClassDiagram)diagram; if (doc.Language == CSharpLanguage.Instance) { return("csharp"); } else if (doc.Language == JavaLanguage.Instance) { return("java"); } break; case DiagramType.UseCaseDiagram: return("usecase"); default: return("diagram"); } return("diagram"); }
public TaskViewModel(Task model, IDiagram widget, IMessagingService messagingService) { _widget = widget; _messagingService = messagingService; Model = model; ToggleCompletedCommand = new CaptionCommand <string>("¨", OnToggleCompleted); }
/// <exception cref="ArgumentNullException"> /// <paramref name="document"/> is null. /// </exception> public static void Paste(IDiagram document) { if (document == null) throw new ArgumentNullException("document"); item.Paste(document); }
public override void ValidateMenuItems(IDiagram diagram) { base.ValidateMenuItems(diagram); GeneralContextMenu.Default.ValidateMenuItems(diagram); //TODO: ez kellene: mnuProperties.Enabled = diagram.SingleSelection; mnuProperties.Enabled = false; }
private void UpdateSelection() { IDiagram vm = (designerCanvas.DataContext as IDiagram); Rect rubberBand = new Rect(startPoint.Value, endPoint.Value); ItemsControl itemsControl = GetParent <ItemsControl>(typeof(ItemsControl), designerCanvas); foreach (VisualElement item in vm.Items) { if (item is VisualElement) { DependencyObject container = itemsControl.ItemContainerGenerator.ContainerFromItem(item); Rect itemRect = VisualTreeHelper.GetDescendantBounds((Visual)container); Rect itemBounds = ((Visual)container).TransformToAncestor(designerCanvas).TransformBounds(itemRect); if (rubberBand.Contains(itemBounds)) { item.IsSelected = true; } else { if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { item.IsSelected = false; } } } } }
public TaskViewModel(Task model, IDiagram widget, IMessagingService messagingService) { _widget = widget; _messagingService = messagingService; Model = model; ToggleCompletedCommand = new CaptionCommand<string>("¨", OnToggleCompleted); }
protected override bool CloneEntity(IDiagram diagram) { if (diagram.DiagramType != DiagramType.ClassDiagram) return false; return ((ClassDiagram)diagram).InsertInterface(InterfaceType.Clone()); }
void IClipboardItem.Paste(IDocument document) { IDiagram diagram = (IDiagram)document; if (diagram == null) { return; } bool success = false; currentOffset += BaseOffset; Size offset = new Size( (int)((diagram.Offset.X + currentOffset) / diagram.Zoom), (int)((diagram.Offset.Y + currentOffset) / diagram.Zoom)); foreach (Shape shape in shapes) { Shape pasted = shape.Paste(diagram, offset); pastedShapes[shape] = pasted; success |= (pasted != null); } foreach (var shape in shapes) { if (shape.ParentShape == null) { continue; } if (!pastedShapes.ContainsKey(shape.ParentShape) || !pastedShapes.ContainsKey(shape)) { continue; } var parentShape = (ShapeContainer)pastedShapes[shape.ParentShape]; var childShape = pastedShapes[shape]; parentShape.AttachShapes(new List <Shape> { childShape }); } foreach (var connection in connections) { Shape first = GetShape(connection.Relationship.First); Shape second = GetShape(connection.Relationship.Second); if (first != null && pastedShapes[first] != null && second != null && pastedShapes[second] != null) { var pasted = connection.Paste( diagram, offset, pastedShapes[first], pastedShapes[second]); success |= (pasted != null); } } if (success) { Clipboard.Clear(); } }
private static DiagramSpec CreateDiagramSpec([NotNull] IDiagram diagram) { return(new DiagramSpec { Nodes = diagram.Nodes.Select(ToNodeSpec).ToArray(), Connector = diagram.Connectors.Select(ToConnectorSpec).ToArray() }); }
protected DesignerElement(int id, IDiagram parent, double left, double top, double itemWidth, double itemHeight) : base(id, parent) { this._left = left; this._top = top; this._itemWidth = itemWidth; this._itemHeight = itemHeight; Init(); }
public NetworkBuilder(IDiagram diagram, INeuronFactory factory, ISettingsProvider settings, ILogAggregator logAggregator) { _diagram = diagram; _factory = factory; _settings = settings; _logAggregator = logAggregator; }
/// <summary> /// "defines" the diagram so that it isn't written into the output multiple times. /// This allows technologies like SVG, for instance, to more effectively decrease their over-all size. /// /// A diagram that's already defined can't be geometrically translated, scaled, or rotated, /// and will rely more heavilly on the renderer's ability to handle these processes. /// </summary> /// <param name="diagram"></param> /// <returns></returns> public static IDiagram Defined(this IDiagram diagram) { if (diagram is DefinedDiagram alreadyDefined) { return(alreadyDefined); } return(new DefinedDiagram(diagram)); }
public static IDiagram Scale(this IDiagram diagram, decimal x = 1, decimal y = 1) { return((diagram, x, y) switch { (_, 1, 1) => diagram, (IScalable scalable, decimal scaleX, decimal scaleY) => scalable.PerformScaling(scaleX, scaleY), _ => diagram.WithScale(x, y) });
public DeleteElementsCommand(List <Shape> shapes, List <AbstractConnection> connections, IDiagram diagram) { this.diagram = diagram; this.shapes = shapes; this.connections = connections; }
public DiagramLayoutInfo Calculate(IDiagram diagram) { var layoutStructure = new DiagramLayoutStructure(diagram); var rootLayoutAlgorithm = _layoutAlgorithmSelectionStrategy.GetForRoot(); var rootLayoutInfo = LayoutRecursive(layoutStructure, layoutStructure.RootLayoutGroup, rootLayoutAlgorithm); return(new DiagramLayoutInfo(rootLayoutInfo.Nodes, rootLayoutInfo.Connectors)); }
public void ClearDiagram() { lock (_diagramUpdateLockObject) { Diagram = Diagram.Clear(); DiagramChanged?.Invoke(new DiagramClearedEvent(Diagram)); } }
private void ApplyChanges(IDictionary <ModelNodeId, Rect2D> changedRects, IDiagram diagram) { foreach (var rect in changedRects) { var diagramNode = diagram.GetNode(rect.Key); DiagramService.UpdateDiagramNodeCenter(diagramNode, rect.Value.Center); } }
private void OnDiagramAssociated(IEntity entity, IDiagram diagram) { if (entity != null && _entity != null && entity.Id == _entity.Id) { _visible = true; Visible = (MarkerStatusTrigger.CurrentStatus == MarkerStatus.Full); } }
public static DiagramEvent Create([NotNull] IDiagram diagram, DiagramShapeEventBase shapeEvent = null) { var shapeEvents = shapeEvent == null ? Enumerable.Empty <DiagramShapeEventBase>() : new[] { shapeEvent }; return(new DiagramEvent(diagram, shapeEvents)); }
/// <exception cref="ArgumentNullException"> /// <paramref name="document"/> is null. /// </exception> public static void SaveAsImage(IDiagram document, bool selectedOnly) { if (document == null) throw new ArgumentNullException("document"); using (SaveFileDialog saveAsImageDialog = new SaveFileDialog()) { saveAsImageDialog.DefaultExt = "png"; if (Settings.Default.UseClearTypeForImages) saveAsImageDialog.Filter = DialogFilterWithoutTransparentPNG; else saveAsImageDialog.Filter = DialogFilter; saveAsImageDialog.FilterIndex = 4; saveAsImageDialog.FileName = document.GetSelectedElementName() ?? ((IDocumentItem)document).Name; if (initDir == null && document.ProjectInfo != null) saveAsImageDialog.InitialDirectory = document.ProjectInfo.GetProjectDirectory(); else saveAsImageDialog.InitialDirectory = initDir; if (saveAsImageDialog.ShowDialog() == DialogResult.OK) { initDir = Path.GetDirectoryName(saveAsImageDialog.FileName); string extension = System.IO.Path.GetExtension(saveAsImageDialog.FileName); ImageFormat format; switch (extension.ToLower()) { case ".bmp": format = ImageFormat.Bmp; break; case ".gif": format = ImageFormat.Gif; break; case ".jpg": case ".jpeg": format = ImageFormat.Jpeg; break; case ".emf": format = ImageFormat.Emf; break; case ".png": default: format = ImageFormat.Png; break; } bool transparent = (saveAsImageDialog.FilterIndex == 5 && !Settings.Default.UseClearTypeForImages); SaveAsImage(document, saveAsImageDialog.FileName, format, selectedOnly, transparent); } } }
public void OnWidgetRemoved(EventArgs e, IDiagram widgetViewModel) { var handler = WidgetRemoved; if (handler != null) { handler(widgetViewModel, e); } }
protected override bool CloneEntity(IDiagram diagram) { if (!(diagram is UseCaseDiagram useCaseDiagram)) { return(false); } return(((UseCaseDiagram)diagram).InsertUseCase(useCase.Clone())); }
protected static void AddControl(IDiagram buttonHolder, InkCanvas parentControl) { var result = WidgetCreatorRegistry.CreateWidgetControl(buttonHolder, ButtonContextMenu); if (result != null) { parentControl.Children.Add(result); } }
protected override bool CloneEntity(IDiagram diagram) { if (diagram.DiagramType != DiagramType.ClassDiagram) { return(false); } return(((ClassDiagram)diagram).InsertInterface(InterfaceType.Clone())); }
protected override bool CloneEntity(IDiagram diagram) { if (diagram.DiagramType != DiagramType.ClassDiagram) { return(false); } return(((ClassDiagram)diagram).InsertComment(Comment.Clone())); }
public DiagramConnectorRouteChangedEvent( [NotNull] IDiagram newDiagram, [NotNull] IDiagramConnector oldConnector, [NotNull] IDiagramConnector newConnector) : base(newDiagram) { OldConnector = oldConnector; NewConnector = newConnector; }
public void RemoveWidget(IDiagram viewModel) { if (viewModel != null && InteractionService.UserIntraction.AskQuestion("Delete Widget?")) { Widgets.Remove(viewModel); _entityService.RemoveWidget(viewModel.GetWidget()); RaisePropertyChanged(() => Widgets); SaveTrackableEntityScreenItems(); LoadTrackableEntityScreenItems(); } }
public void SetReference(IDiagram _diagram) { if (_diagram == null) diagram = null; else { diagram = _diagram as Diagram; mnuNewStructure.Visible = diagram.Language.SupportsStructures; mnuNewDelegate.Visible = diagram.Language.SupportsDelegates; } }
/// <exception cref="ArgumentNullException"> /// <paramref name="diagram"/> is null. /// </exception> public DiagramNode(IDiagram diagram) { if (diagram == null) throw new ArgumentNullException("diagram"); this.diagram = diagram; this.Text = diagram.Name; this.ImageKey = "diagram"; this.SelectedImageKey = "diagram"; diagram.Renamed += new EventHandler(diagram_Renamed); }
public void PerformLayout(IDiagram diagram) { if (diagram.DiagramItems == null || diagram.DiagramItems.Count == 0) { return; } diagram.Padding = new Thickness(); var endpointLayout = new EndpointItemLayout(diagram); var handlerLayout = new HandlerLayout(diagram); var endpointTimelineLayout = new EndpointTimelineLayout(diagram); var arrowLayout = new ArrowLayout(diagram, endpointLayout); var processRouteLayout = new ProcessRouteLayout(diagram); foreach (var item in diagram.DiagramItems) { var endpoint = item as EndpointItem; if (endpoint != null) { endpointLayout.Position(endpoint); continue; } var handler = item as Handler; if (handler != null) { handlerLayout.Position(handler); continue; } var timeline = item as EndpointTimeline; if (timeline != null) { endpointTimelineLayout.Position(timeline); continue; } var arrow = item as Arrow; if (arrow != null) { arrowLayout.Position(arrow); } var route = item as MessageProcessingRoute; if (route != null) { processRouteLayout.Position(route); } } }
protected override bool CloneRelationship(IDiagram diagram, Shape first, Shape second) { if(diagram.DiagramType != DiagramType.ClassDiagram) return false; Comment comment = first.Entity as Comment; if (comment != null) { CommentRelationship clone = relationship.Clone(comment, second.Entity); return ((ClassDiagram)diagram).InsertCommentRelationship(clone); } else { return false; } }
public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu) { var buttonHolder = widgetViewModel as TaskEditorViewModel; var ret = new TaskEditorView { DataContext = buttonHolder, ContextMenu = contextMenu }; var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var transformBinding = new Binding("ScaleTransform") { Source = buttonHolder, Mode = BindingMode.OneWay }; ret.SetBinding(InkCanvas.LeftProperty, xBinding); ret.SetBinding(InkCanvas.TopProperty, yBinding); ret.SetBinding(FrameworkElement.HeightProperty, heightBinding); ret.SetBinding(FrameworkElement.WidthProperty, widthBinding); ret.Border.SetBinding(FrameworkElement.LayoutTransformProperty, transformBinding); return ret; }
protected override bool CloneRelationship(IDiagram diagram, Shape first, Shape second) { if (diagram.DiagramType != DiagramType.ClassDiagram) return false; CompositeType firstType = first.Entity as CompositeType; CompositeType secondType = second.Entity as CompositeType; if (firstType != null && secondType != null) { GeneralizationRelationship clone = generalization.Clone(firstType, secondType); return ((ClassDiagram)diagram).InsertGeneralization(clone); } else { return false; } }
protected override bool CloneRelationship(IDiagram diagram, Shape first, Shape second) { if (diagram.DiagramType != DiagramType.ClassDiagram) return false; TypeBase firstType = first.Entity as TypeBase; TypeBase secondType = second.Entity as TypeBase; if (firstType != null && secondType != null) { DependencyRelationship clone = dependency.Clone(firstType, secondType); return ((ClassDiagram)diagram).InsertDependency(clone); } else { return false; } }
protected override bool CloneRelationship(IDiagram diagram, Shape first, Shape second) { if (diagram.DiagramType != DiagramType.ClassDiagram) return false; CompositeType firstType = first.Entity as CompositeType; TypeBase secondType = second.Entity as TypeBase; if (firstType != null && secondType != null) { NestingRelationship clone = nesting.Clone(firstType, secondType); return ((ClassDiagram)diagram).InsertNesting(clone); } else { return false; } }
public static string Save(string outputDirectory, IDiagram diagram, IRunnerRecorder recorder) { var generator = diagram.CreateGenerator(); var filePath = Path.Combine(outputDirectory, "{0}.nplant".FormatWith(diagram.Name.ReplaceIllegalPathCharacters('_'))); if (File.Exists(filePath)) File.Delete(filePath); using (var file = File.CreateText(filePath)) { file.Write(generator.Generate()); recorder.Log("Diagram '{0}' written...".FormatWith(diagram.GetType().FullName)); recorder.Record(filePath); } return filePath; }
public override void ValidateMenuItems(IDiagram diagram) { base.ValidateMenuItems(diagram); GeneralContextMenu.Default.ValidateMenuItems(diagram); bool multiSelection = (diagram.SelectedElementCount >= 2); mnuAlign.Enabled = multiSelection; mnuAlignTop.Enabled = multiSelection; mnuAlignLeft.Enabled = multiSelection; mnuAlignBottom.Enabled = multiSelection; mnuAlignRight.Enabled = multiSelection; mnuAlignHorizontal.Enabled = multiSelection; mnuAlignVertical.Enabled = multiSelection; mnuMakeSameSize.Enabled = multiSelection; mnuSameWidth.Enabled = multiSelection; mnuSameHeight.Enabled = multiSelection; mnuSameSize.Enabled = multiSelection; }
public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu) { var buttonHolder = widgetViewModel as TicketExplorerViewModel; var ret = new TicketExplorerView { DataContext = buttonHolder, ContextMenu = contextMenu }; var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay }; ret.SetBinding(InkCanvas.LeftProperty, xBinding); ret.SetBinding(InkCanvas.TopProperty, yBinding); ret.SetBinding(FrameworkElement.HeightProperty, heightBinding); ret.SetBinding(FrameworkElement.WidthProperty, widthBinding); return ret; }
protected override bool CloneRelationship(IDiagram diagram, Shape first, Shape second) { if (diagram.DiagramType != DiagramType.ClassDiagram) return false; TypeBase firstType = first.Entity as TypeBase; InterfaceType secondType = second.Entity as InterfaceType; if (firstType != null && secondType != null) { RealizationRelationship clone = realization.Clone(firstType, secondType); return ((ClassDiagram)diagram).InsertRealization(clone); } else { return false; } }
private static void CreateHtmlViewer(IDiagram buttonHolder, InkCanvas parentControl) { if (!BrowserCache.ContainsKey(buttonHolder.Caption + buttonHolder.HtmlContent)) { var brws = new BrowserControl { DataContext = buttonHolder, ContextMenu = ButtonContextMenu, MinHeight = 10, MinWidth = 10 }; BrowserCache.Add(buttonHolder.Caption + buttonHolder.HtmlContent, brws); } var ret = BrowserCache[buttonHolder.Caption + buttonHolder.HtmlContent]; ret.DataContext = buttonHolder; ret.ContextMenu = ButtonContextMenu; ret.IsToolbarVisible = false; parentControl.Children.Add(ret); ret.AutoRefresh = buttonHolder.AutoRefresh; BindingOperations.ClearAllBindings(ret); var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay }; var enabledBinding = new Binding("IsEnabled") { Source = buttonHolder, Mode = BindingMode.OneWay }; var transformBinding = new Binding("RenderTransform") { Source = buttonHolder, Mode = BindingMode.OneWay }; var urlBinding = new Binding("HtmlContent") { Source = buttonHolder, Mode = BindingMode.OneWay }; var detailsVisibilityBinding = new Binding("IsDetailsVisible") { Source = buttonHolder, Mode = BindingMode.TwoWay }; ret.SetBinding(LeftProperty, xBinding); ret.SetBinding(TopProperty, yBinding); ret.SetBinding(HeightProperty, heightBinding); ret.SetBinding(WidthProperty, widthBinding); ret.SetBinding(RenderTransformProperty, transformBinding); ret.SetBinding(IsEnabledProperty, enabledBinding); ret.SetBinding(BrowserControl.IsToolbarVisibleProperty, detailsVisibilityBinding); ret.SetBinding(BrowserControl.ActiveUrlProperty, urlBinding); }
public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu) { var viewModel = widgetViewModel as TicketExplorerWidgetViewModel; Debug.Assert(viewModel != null); var ret = new TicketExplorerView { DataContext = viewModel.TicketExplorerViewModel, ContextMenu = contextMenu, Tag = viewModel }; var heightBinding = new Binding("Height") { Source = viewModel, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = viewModel, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = viewModel, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = viewModel, Mode = BindingMode.TwoWay }; ret.SetBinding(InkCanvas.LeftProperty, xBinding); ret.SetBinding(InkCanvas.TopProperty, yBinding); ret.SetBinding(FrameworkElement.HeightProperty, heightBinding); ret.SetBinding(FrameworkElement.WidthProperty, widthBinding); return ret; }
private void Load(IDiagram diagram) { string notation = diagram.CreateGenerator().Generate(); var stringReader = new StringReader(notation); Queue<string> lines = stringReader.ReadAllLines(); while (lines.Count > 0) { string line = lines.Dequeue(); if (line.StartsWith("class") && line.EndsWith("{")) { ClassElement @class = this.AddClass(line); @class.Load(DequeueTo("}", lines)); } } }
public DiagramDocument(IDiagram document, IDockForm dockForm) { InitializeComponent(); DockForm = dockForm; canvas.Diagram = document; Text = canvas.Diagram.Name; TabText = Text; canvas.Diagram.Renamed += new EventHandler(diagram_StateChanged); Style.CurrentStyleChanged += new EventHandler(Style_CurrentStyleChanged); canvas.Diagram.StateChanged += new EventHandler(diagram_StateChanged); canvas.Diagram.SelectionChanged += new EventHandler(Diagram_SelectionChanged); Handler.ZoomHandler = canvas; Handler.PrintHandler = canvas.Diagram; Handler.EditHandler = canvas.Diagram; Handler.VisualizerHandler = canvas; Handler.LayoutHandler = canvas.Diagram; Handler.GenerateCode += new EventHandler(Handler_GenerateCode); UpdateTexts(); Load += DiagramDocument_Load; }
public override void ValidateMenuItems(IDiagram diagram) { if (diagram.DiagramType != DiagramType.ClassDiagram) { // TODO do this in a sane way throw new Exception("This is not a class diagram"); } var classDiagram = (ClassDiagram) diagram; base.ValidateMenuItems(diagram); mnuPaste.Enabled = diagram.CanPasteFromClipboard; mnuNewStructure.Visible = classDiagram.Language.SupportsStructures; mnuNewDelegate.Visible = classDiagram.Language.SupportsDelegates; mnuShowType.Checked = DiagramEditor.Settings.Default.ShowType; mnuShowParameters.Checked = DiagramEditor.Settings.Default.ShowParameters; mnuShowParameterNames.Checked = DiagramEditor.Settings.Default.ShowParameterNames; mnuShowInitialValue.Checked = DiagramEditor.Settings.Default.ShowInitialValue; mnuSaveAsImage.Enabled = !diagram.IsEmpty; }
public FrameworkElement CreateWidgetControl(IDiagram widget, ContextMenu contextMenu) { var viewModel = widget as EntitySearchWidgetViewModel; Debug.Assert(viewModel != null); var ret = new EntitySearchView(viewModel.EntitySearchViewModel) { DataContext = viewModel.EntitySearchViewModel, ContextMenu = contextMenu, Tag = widget }; var heightBinding = new Binding("Height") { Source = viewModel, Mode = BindingMode.TwoWay }; var widthBinding = new Binding("Width") { Source = viewModel, Mode = BindingMode.TwoWay }; var xBinding = new Binding("X") { Source = viewModel, Mode = BindingMode.TwoWay }; var yBinding = new Binding("Y") { Source = viewModel, Mode = BindingMode.TwoWay }; var transformBinding = new Binding("ScaleTransform") { Source = viewModel, Mode = BindingMode.OneWay }; ret.SetBinding(InkCanvas.LeftProperty, xBinding); ret.SetBinding(InkCanvas.TopProperty, yBinding); ret.SetBinding(FrameworkElement.HeightProperty, heightBinding); ret.SetBinding(FrameworkElement.WidthProperty, widthBinding); ret.MainGrid.SetBinding(FrameworkElement.LayoutTransformProperty, transformBinding); return ret; }