public Port(string name, PortTypes portType, Type type, VplControl hostCanvas) { DataType = type; PortType = portType; Name = name; this.hostCanvas = hostCanvas; if (portType == PortTypes.Input) { Style = this.hostCanvas.FindResource("VplPortStyleLeft") as Style; } else { Style = this.hostCanvas.FindResource("VplPortStyleRight") as Style; } MouseDown += Port_MouseDown; // ParentNode.SizeChanged += ParentNode_SizeChanged; // ParentNode.PropertyChanged += ParentNode_PropertyChanged; ConnectedConnectors = new List <Connector>(); Origin = new BindingPoint(0, 0); }
public ConnectorPort(VplControl hostCanvas) { this.hostCanvas = hostCanvas; Style = hostCanvas.FindResource("VplConnectorPortStyle") as Style; hostCanvas.Children.Add(this); }
public SelectionNode(VplControl hostCanvas) : base(hostCanvas) { searchTextBox = new SearchTextBox(); searchTextBox.OnSearch += searchTextBox_OnSearch; var tempTypeList = new List <Type>(); AddControlToNode(searchTextBox); listBox.DisplayMemberPath = "Name"; listBox.MaxHeight = 140; listBox.MinHeight = 80; AddControlToNode(listBox); switch (hostCanvas.NodeTypeMode) { case NodeTypeModes.OnlyInternalTypes: tempTypeList.AddRange( Utilities.Utilities.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "DatoUI.VPL.Nodes") .ToList()); break; case NodeTypeModes.OnlyExternalTypes: tempTypeList.AddRange(hostCanvas.ExternalNodeTypes); break; case NodeTypeModes.All: tempTypeList.AddRange( Utilities.Utilities.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "DatoUI.VPL.Nodes") .ToList()); tempTypeList.AddRange(hostCanvas.ExternalNodeTypes); break; } tempTypeList = tempTypeList.OrderBy(x => x.Name).ToList(); foreach (var type in tempTypeList.Where(type => !type.IsAbstract && !type.Name.Contains("<>"))) { typeList.Add(type); } listBox.ItemsSource = typeList; searchTextBox.PreviewKeyDown += searchTextBox_KeyDown; listBox.PreviewMouseLeftButtonUp += listBox_PreviewMouseLeftButtonUp; listBox.SelectionMode = SelectionMode.Single; Border.MouseLeave += SelectionNode_MouseLeave; MouseEnter += SelectionNode_MouseEnter; }
public NodeGroup(VplControl hostCanvas) : base(hostCanvas) { Id = Interlocked.Increment(ref counter); Border.MouseDown += HitTestBorder_MouseDown; Border.MouseUp += Border_MouseUp; Border.Visibility = Visibility.Visible; Border.Style = FindResource("VplGroupBorderStyle") as Style; HostCanvas.NodeGroupCollection.Add(this); SetZIndex(this, 1); SetZIndex(Border, 1); }
/// <summary> /// Initializes a new instance of VplElement class. /// </summary> /// <param name="hostCanvas">The host VplControl in which the VplElement will be rendered.</param> protected VplElement(VplControl hostCanvas) { HostCanvas = hostCanvas; // ---------------------------------------------------------------------------------------------------------------------- // Border // ---------------------------------------------------------------------------------------------------------------------- Border = new Border { Child = this, Style = FindResource("VplElementBorderStyle") as Style, Visibility = Visibility.Collapsed }; DependencyPropertyDescriptor.FromProperty(IsSelectedProperty, typeof(VplElement)) .AddValueChanged(this, OnSelectionChanged); HostCanvas.AddChildren(Border); // ---------------------------------------------------------------------------------------------------------------------- // HitTestBorder // ---------------------------------------------------------------------------------------------------------------------- HitTestBorder = new Border { Style = FindResource("HitTestBorderStyle") as Style }; HitTestBorder.MouseEnter += HitTestBorder_MouseEnter; HitTestBorder.MouseLeave += HitTestBorder_MouseLeave; HitTestGrid = new Grid(); HitTestGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(30) }); HitTestGrid.ColumnDefinitions.Add(new ColumnDefinition()); HitTestGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(30) }); HitTestGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(30) }); HitTestGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(30) }); HitTestBorder.Child = HitTestGrid; HostCanvas.AddChildren(HitTestBorder); // ---------------------------------------------------------------------------------------------------------------------- // Buttons // ---------------------------------------------------------------------------------------------------------------------- if (GetType() == typeof(SelectionNode)) { return; } CaptionLabel = new NodeCaptionLabel(this); QuestButton = new NodeQuestionButton(this); ResizeButton = new NodePinButton(this); BinButton = new NodeBinButton(this); AutoCheckBox = new NodeAutoCheckBox(this); BinButton.Click += binButton_Click; BinButton.Visibility = Visibility.Collapsed; QuestButton.Visibility = Visibility.Collapsed; ResizeButton.Visibility = Visibility.Collapsed; AutoCheckBox.Visibility = Visibility.Collapsed; }
public Connector(VplControl hostCanvas, Port startPort, Port endPort) { HostCanvas = hostCanvas; Path = new Path(); StartEllipse = new ConnectorPort(hostCanvas); EndEllipse = new ConnectorPort(hostCanvas); Panel.SetZIndex(Path, 2); if (startPort.ParentNode != null) { Panel.SetZIndex(StartEllipse, startPort.ParentNode.Id + 1); } if (endPort.ParentNode != null) { Panel.SetZIndex(EndEllipse, endPort.ParentNode.Id + 1); } Path.Style = HostCanvas.FindResource("VplConnectorStyle") as Style; StartPort = startPort; EndPort = endPort; Canvas.SetLeft(StartEllipse, StartPort.Origin.X - StartEllipse.ActualWidth / 2); Canvas.SetTop(StartEllipse, StartPort.Origin.Y - StartEllipse.ActualHeight / 2); Canvas.SetLeft(EndEllipse, EndPort.Origin.X - EndEllipse.ActualWidth / 2); Canvas.SetTop(EndEllipse, EndPort.Origin.Y - EndEllipse.ActualHeight / 2); StartBezierPoint = new BindingPoint(StartPort.Origin.X, StartPort.Origin.Y); EndBezierPoint = new BindingPoint(EndPort.Origin.X, EndPort.Origin.Y); startPort.DataChanged += endPort.StartPort_DataChanged; StartPort.Origin.PropertyChanged += Origin_PropertyChanged; EndPort.Origin.PropertyChanged += Origin_PropertyChanged; if (startPort.ParentNode != null) { StartPort.ParentNode.PropertyChanged += Origin_PropertyChanged; ObserveNode(StartPort.ParentNode); } if (endPort.ParentNode != null) { EndPort.ParentNode.PropertyChanged += Origin_PropertyChanged; ObserveNode(EndPort.ParentNode); } startPort.ConnectedConnectors.Add(this); endPort.ConnectedConnectors.Add(this); endPort.CalculateData(startPort.Data); DefinePath(); HostCanvas.Children.Add(Path); Path.MouseDown += Path_MouseDown; Path.MouseUp += PathOnMouseUp; }
protected Node(VplControl hostCanvas) : base(hostCanvas) { Guid = Guid.NewGuid(); id = Interlocked.Increment(ref id); id = Interlocked.Increment(ref id); Id = id; InputPorts = new List <Port>(); OutputPorts = new List <Port>(); ControlElements = new List <UIElement>(); IsHitTestVisible = true; HasError = false; SpaceCanvas = new Canvas(); Children.Add(ContentGrid = new Grid { ShowGridLines = false, Background = Brushes.Transparent }); if (hostCanvas.GraphFlowDirection == GraphFlowDirections.Horizontal) { // ---------------------------------------------------------------------------------------------------------------------- // Content Panels // ---------------------------------------------------------------------------------------------------------------------- InputPortPanel = new StackPanel { VerticalAlignment = VerticalAlignment.Center }; SetColumn(InputPortPanel, 0); SetRow(InputPortPanel, 1); ContentGrid.Children.Add(InputPortPanel); OutputPortPanel = new StackPanel { VerticalAlignment = VerticalAlignment.Center }; SetColumn(OutputPortPanel, 2); SetRow(OutputPortPanel, 1); ContentGrid.Children.Add(OutputPortPanel); } else { // ---------------------------------------------------------------------------------------------------------------------- // Content Panels // ---------------------------------------------------------------------------------------------------------------------- InputPortPanel = new DockPanel { HorizontalAlignment = HorizontalAlignment.Center }; SetRow(InputPortPanel, 0); SetColumn(InputPortPanel, 1); ContentGrid.Children.Add(InputPortPanel); OutputPortPanel = new DockPanel { HorizontalAlignment = HorizontalAlignment.Center }; SetColumn(OutputPortPanel, 1); SetRow(OutputPortPanel, 2); ContentGrid.Children.Add(OutputPortPanel); } // ---------------------------------------------------------------------------------------------------------------------- // Content grid row and column definitions // ---------------------------------------------------------------------------------------------------------------------- ContentGrid.ColumnDefinitions.Insert(0, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); // Input ContentGrid.ColumnDefinitions.Insert(0, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); // Content ContentGrid.ColumnDefinitions.Insert(0, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); // Output ContentGrid.RowDefinitions.Insert(0, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); // Header ContentGrid.RowDefinitions.Insert(1, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); // Content ContentGrid.RowDefinitions.Insert(1, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); // Footer ContentGrid.RowDefinitions.Insert(1, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); // Risize area ContentGrid.SizeChanged += ContentGridOnSizeChanged; ContentGrid.VerticalAlignment = VerticalAlignment.Center; // ---------------------------------------------------------------------------------------------------------------------- // Main content grid // ---------------------------------------------------------------------------------------------------------------------- MainContentGrid = new Grid { ShowGridLines = false, Style = FindResource("MainContentGridStyle") as Style }; SetColumn(MainContentGrid, 1); SetRow(MainContentGrid, 1); ContentGrid.Children.Add(MainContentGrid); // ---------------------------------------------------------------------------------------------------------------------- // Event delagates // ---------------------------------------------------------------------------------------------------------------------- Border.MouseDown += Node_MouseDown; Loaded += Node_Loaded; KeyUp += Node_KeyUp; KeyDown += Node_KeyDown; // ---------------------------------------------------------------------------------------------------------------------- // Comments // ---------------------------------------------------------------------------------------------------------------------- TopComment = new Comment(this) { Text = "Top Comment", Background = HostCanvas.FindResource("CommentBackgroundBrushError") as Brush, ExpandSide = CommentExpandSides.Top }; BottomComment = new Comment(this) { Text = "Help Information: [No content]", Background = HostCanvas.FindResource("CommentBackgroundBrush") as Brush, ExpandSide = CommentExpandSides.Bottom }; TopComment.Visibility = Visibility.Collapsed; BottomComment.Visibility = Visibility.Collapsed; ShowHelpOnMouseOver = false; if (QuestButton != null) { if (QuestButton != null) { QuestButton.Click += QuestButton_Click; } } SetZIndex(this, Id); SetZIndex(Border, Id); if (HitTestBorder != null) { SetZIndex(HitTestBorder, Id); } if (BinButton != null) { SetZIndex(BinButton, Id); } if (ResizeButton != null) { SetZIndex(ResizeButton, Id); } if (QuestButton != null) { SetZIndex(QuestButton, Id); } if (CaptionLabel != null) { SetZIndex(CaptionLabel, Id); } if (AutoCheckBox != null) { SetZIndex(AutoCheckBox, Id); } SetZIndex(TopComment, Id); SetZIndex(BottomComment, Id); if (GetType() == typeof(SelectionNode)) { return; } HostCanvas.NodeCollection.Add(this); }