コード例 #1
0
        public StateContainerEditor()
        {
            InitializeComponent();
            this.modelItemToUIElement = new Dictionary<ModelItem, UIElement>();
            this.shapeLocations = new HashSet<Point>();
            this.listenedTransitionCollections = new HashSet<ModelItem>();
            this.transitionModelItemsAdded = new List<ModelItem>();
            this.transitionModelItemsRemoved = new List<ModelItem>();

            Binding readOnlyBinding = new Binding();
            readOnlyBinding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(DesignerView), 1);
            readOnlyBinding.Path = new PropertyPath(DesignerView.IsReadOnlyProperty);
            readOnlyBinding.Mode = BindingMode.OneWay;
            this.SetBinding(IsReadOnlyProperty, readOnlyBinding);

            this.Loaded += (s, e) =>
            {
                if (this.ShouldInitialize())
                {
                    WorkflowViewElement parent = VisualTreeUtils.FindVisualAncestor<WorkflowViewElement>(this);
                    this.ModelItem = parent.ModelItem;
                    this.StateMachineModelItem = StateContainerEditor.GetStateMachineModelItem(this.ModelItem);
                    this.Context = parent.Context;
                    this.compositeViewEvents = parent;
                    if (this.compositeViewEvents != null)
                    {
                        this.compositeViewEvents.RegisterDefaultCompositeView(this);
                    }
                    if (!this.populated)
                    {
                        this.Populate();
                        Selection.Subscribe(this.Context, this.OnSelectionChangedCallback);
                        this.populated = true;
                    }
                }
            };

            this.Unloaded += (s, e) =>
            {
                if (this.compositeViewEvents != null)
                {
                    (compositeViewEvents).UnregisterDefaultCompositeView(this);
                    this.compositeViewEvents = null;
                }
                if (this.populated)
                {
                    this.Cleanup();
                    Selection.Unsubscribe(this.Context, this.OnSelectionChangedCallback);
                    this.populated = false;
                }

                this.StateMachineModelItem = null;

                this.activeSrcConnectionPoint = null;
                this.activeDestConnectionPointForAutoSplit = null;
                this.activeSrcConnectionPointForAutoSplit = null;

                // selectedConnector is a placeholder for the last connector selected.
                this.selectedConnector = null;

                // Used for connector creation
                this.lastConnectionPointMouseUpElement = null;
                this.activeConnectionPointsAdorner = null;
                this.activeConnectionPoint = null;
                this.initialNode = null;
                // The ModelItem for the initial node
                this.initialModelItem = null;

                BindingOperations.ClearBinding(this, IsReadOnlyProperty);
            };
        }
コード例 #2
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            this.AllowDrop = true;
            this.Content   = containerGrid;
            ICompositeViewEvents containerEvents = null;
            bool isDefault = false;

            this.Loaded += (s, eventArgs) =>
            {
                isDefault = this.IsDefaultContainer;
                DependencyObject parent = VisualTreeHelper.GetParent(this);
                while (null != parent && !typeof(ICompositeViewEvents).IsAssignableFrom(parent.GetType()))
                {
                    parent = VisualTreeHelper.GetParent(parent);
                }
                containerEvents = parent as ICompositeViewEvents;
                if (null != containerEvents)
                {
                    if (isDefault)
                    {
                        containerEvents.RegisterDefaultCompositeView(this);
                    }
                    else
                    {
                        containerEvents.RegisterCompositeView(this);
                    }
                }
                this.shouldSetFocus = true;

                if (this.AutoWrapInSequenceEnabled)
                {
                    // spacer and placer holder
                    this.spacerHelper = new SpacerHelper(this);
                }
            };

            this.Unloaded += (s, eventArgs) =>
            {
                if (null != containerEvents)
                {
                    if (isDefault)
                    {
                        containerEvents.UnregisterDefaultCompositeView(this);
                    }
                    else
                    {
                        containerEvents.UnregisterCompositeView(this);
                    }
                }
                this.shouldSetFocus = false;

                if (this.AutoWrapInSequenceEnabled)
                {
                    if (this.spacerHelper != null)
                    {
                        this.spacerHelper.Unload();
                        this.spacerHelper = null;
                    }
                }
            };
        }
コード例 #3
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            this.AllowDrop = true;
            this.Content   = outerGrid;
            if (this.ItemsPanel != null)
            {
                this.panel.ItemsPanel = this.ItemsPanel;
            }

            ICompositeViewEvents containerEvents = null;
            bool isDefault = false;

            this.Loaded += (s, eventArgs) =>
            {
                isDefault           = this.IsDefaultContainer;
                selectedSpacerIndex = addAtEndMarker;
                DependencyObject parent = VisualTreeHelper.GetParent(this);
                while (null != parent && !typeof(ICompositeViewEvents).IsAssignableFrom(parent.GetType()))
                {
                    parent = VisualTreeHelper.GetParent(parent);
                }
                containerEvents = parent as ICompositeViewEvents;
                if (null != containerEvents)
                {
                    if (isDefault)
                    {
                        containerEvents.RegisterDefaultCompositeView(this);
                    }
                    else
                    {
                        containerEvents.RegisterCompositeView(this);
                    }
                }
                if (this.Items != null)
                {
                    //UnRegistering because of 137896: Inside tab control multiple Loaded events happen without an Unloaded event.
                    this.Items.CollectionChanged -= new NotifyCollectionChangedEventHandler(OnCollectionChanged);
                    this.Items.CollectionChanged += new NotifyCollectionChangedEventHandler(OnCollectionChanged);
                }
                if (populateOnLoad)
                {
                    this.PopulateContent();
                }
            };

            this.Unloaded += (s, eventArgs) =>
            {
                if (null != containerEvents)
                {
                    if (isDefault)
                    {
                        containerEvents.UnregisterDefaultCompositeView(this);
                    }
                    else
                    {
                        containerEvents.UnregisterCompositeView(this);
                    }
                }
                if (this.Items != null)
                {
                    this.Items.CollectionChanged -= new NotifyCollectionChangedEventHandler(OnCollectionChanged);
                }
                populateOnLoad = true;
            };
        }
コード例 #4
0
        public StateContainerEditor()
        {
            InitializeComponent();
            this.DataContext = this;
            this.modelItemToUIElement = new Dictionary<ModelItem, UIElement>();
            this.shapeLocations = new HashSet<Point>();
            this.listenedTransitionCollections = new HashSet<ModelItem>();
            this.transitionModelItemsAdded = new List<ModelItem>();

            Binding readOnlyBinding = new Binding();
            readOnlyBinding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(DesignerView), 1);
            readOnlyBinding.Path = new PropertyPath(DesignerView.IsReadOnlyProperty);
            readOnlyBinding.Mode = BindingMode.OneWay;
            this.SetBinding(IsReadOnlyProperty, readOnlyBinding);

            this.Loaded += (s, e) =>
            {
                if (this.ShouldInitialize())
                {
                    WorkflowViewElement parent = StateContainerEditor.GetVisualAncestor<WorkflowViewElement>(this);
                    this.ModelItem = parent.ModelItem;
                    this.StateMachineModelItem = StateContainerEditor.GetStateMachineModelItem(this.ModelItem);
                    this.Context = parent.Context;
                    this.compositeViewEvents = parent;
                    if (this.compositeViewEvents != null)
                    {
                        this.compositeViewEvents.RegisterDefaultCompositeView(this);
                    }
                    if (!this.populated)
                    {
                        this.Populate();
                        this.populated = true;
                    }
                }
            };

            this.Unloaded += (s, e) =>
            {
                if (this.compositeViewEvents != null)
                {
                    (compositeViewEvents).UnregisterDefaultCompositeView(this);
                    this.compositeViewEvents = null;
                }
                if (this.populated)
                {
                    this.Cleanup();
                    this.populated = false;
                }
            };
        }