Пример #1
0
        /// <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);
                }
            }
        }
Пример #2
0
        /// <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();
            }
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
 /// <summary>
 /// Initializes an instance of the <see cref="NodeView"/> class.
 /// </summary>
 public NodeView()
 {
     this.mInnerPortContainer = null;
     this.mBackgroundBackup = null;
     this.mIsBackgroundBackupUpdateLocked = false;
 }
Пример #5
0
        /// <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);
        }
Пример #6
0
 /// <summary>
 /// Initializes an instance of the <see cref="NodeView"/> class.
 /// </summary>
 public NodeView()
 {
     this.mInnerPortContainer = null;
 }