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 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", Background = HostCanvas.FindResource("CommentBackgroundBrushError") as Brush, ExpandSide = CommentExpandSides.Top }; BottomComment = new Comment(this) { Text = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", 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); }
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(); //Adding a title to nodes. A new subgrid holds the title an the node panel //TODO : Clean up // ---------------------------------------------------------------------------------------------------------------------- // Container Panel // ---------------------------------------------------------------------------------------------------------------------- Grid container = new Grid { ShowGridLines = false, Background = Brushes.Transparent }; container.RowDefinitions.Insert(0, new RowDefinition()); container.RowDefinitions.Insert(1, new RowDefinition()); Children.Add(container); NodeTitle = new Grid { ShowGridLines = false, Background = Brushes.Transparent }; Title(container, new Label { Content = this.GetType().Name, Foreground = Brushes.White, HorizontalContentAlignment = HorizontalAlignment.Center, FontSize = 13, Padding = new Thickness(0) }); container.Children.Add(ContentGrid = new Grid { ShowGridLines = false, Background = Brushes.Transparent }); SetColumn(ContentGrid, 0); SetRow(ContentGrid, 1); 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 = "", Background = HostCanvas.FindResource("CommentBackgroundBrushError") as Brush, ExpandSide = CommentExpandSides.Top }; BottomComment = new Comment(this) { Text = "", 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); }