/// <summary> /// Delegate called when the control is initialized. /// </summary> /// <param name="pEventArgs">The event arguments.</param> protected override void OnInitialized(EventArgs pEventArgs) { PortViewModel lPortViewModel = this.DataContext as PortViewModel; if (lPortViewModel == null) { return; } PortContainer lParentContainer = this.FindVisualParent <PortContainer>(); if (lParentContainer == null) { return; } PortView lPortView = lParentContainer.GetContainerForViewModel(lPortViewModel); if (lPortView != null) { AdornerLayeredCanvas lCanvas = this.FindVisualParent <AdornerLayeredCanvas>(); if (lCanvas != null) { // Creating the adorner layer. AdornerLayer lLayer = lCanvas.AdornerLayer; // Creating the adorner and propagating this control background. this.mAdorner = new ConnectorAdorner(lPortView); this.UpdateConnectorsBackground(); // Adding the adorner to the layer. lLayer.Add(this.mAdorner); } } }
/// <summary> /// Delegate called when the background brush changed. /// </summary> /// <param name="pObject">The modified control.</param> /// <param name="pEventArgs">The event arguments.</param> private static void OnBackgroundChanged(DependencyObject pObject, DependencyPropertyChangedEventArgs pEventArgs) { PortContainer lContainer = pObject as PortContainer; if (lContainer != null) { lContainer.UpdateItemsBackground(); } }
/// <summary> /// Method called when the control template is applied. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); // Getting the parts of the control. this.mInnerPortContainer = this.GetTemplateChild(PART_PORT_CONTAINER) as PortContainer; if (this.mInnerPortContainer == null) { throw new Exception("NodeView control template not correctly defined."); } // Binding the Ports property. Binding lNodesBinding = new Binding("Ports"); lNodesBinding.Source = this.Content; lNodesBinding.Mode = BindingMode.OneWay; this.mInnerPortContainer.SetBinding(ItemsControl.ItemsSourceProperty, lNodesBinding); }
/// <summary> /// Initializes an instance of the <see cref="NodeView"/> class. /// </summary> public NodeView() { this.mInnerPortContainer = null; this.mBackgroundBackup = null; this.mIsBackgroundBackupUpdateLocked = false; }
/// <summary> /// Initializes an instance of the <see cref="NodeView"/> class. /// </summary> public NodeView() { this.mInnerPortContainer = null; }