示例#1
0
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            if (HitConnector != null)
            {
                if (this.sourceConnector.Orientation.ToString() != "Top" && this.HitConnector.Orientation.ToString() == "Top" &&
                    this.sourceConnector.Connections.Count == 0)
                {
                    ModelChildStateObject  SinkconnObj   = new ModelChildStateObject();
                    ModelParentStateObject SourceConnObj = new ModelParentStateObject();

                    DockPanel          Sourcepnl      = (DockPanel)this.sourceConnector.ParentDesignerItem.Content;
                    DockPanel          Sinkpnl        = (DockPanel)this.HitConnector.ParentDesignerItem.Content;
                    ModelConnectorInfo SourceConnInfo = this.sourceConnector.GetInfo();


                    //Bağlanılan state'in Child'ına atanır
                    SinkconnObj.SourcePoint = this.sourceConnector.Position;
                    SinkconnObj.SinkPoint   = this.HitConnector.Position;
                    SinkconnObj.ChildId     = Sinkpnl.Uid;
                    SinkconnObj.ChildType   = Sinkpnl.Tag.ToString();

                    //bağlanan state'in Parent'ına atanır
                    SourceConnObj.SourcePoint  = this.sourceConnector.Position;
                    SourceConnObj.SinkPoint    = this.HitConnector.Position;
                    SourceConnObj.ParentId     = Sourcepnl.Uid;
                    SourceConnObj.ParentType   = Sourcepnl.Tag.ToString();
                    SourceConnObj.PropertyName = SourceConnInfo.ToolTip;

                    //
                    if (ArrangeProperties(SinkconnObj, SourceConnObj, Sourcepnl, Sinkpnl))
                    {
                        ViewModelConnector sourceConnector = this.sourceConnector;
                        ViewModelConnector sinkConnector   = this.HitConnector;
                        sourceConnector.DesignerItemName = Sourcepnl.Tag.ToString();
                        sourceConnector.Name             = SourceConnInfo.ToolTip.ToString();

                        sinkConnector.DesignerItemName = Sinkpnl.Tag.ToString();
                        sinkConnector.Name             = "Top";

                        ViewModelConnection newConnection = new ViewModelConnection(sourceConnector, sinkConnector);
                        newConnection.SourceToolTip        = SourceConnObj.PropertyName;
                        newConnection.SourceDesignerItemId = Sourcepnl.Name;
                        newConnection.SinkDesignerItemId   = Sinkpnl.Name;

                        Canvas.SetZIndex(newConnection, designerCanvas.Children.Count);
                        this.designerCanvas.Children.Add(newConnection);
                    }
                }
                else
                {
                    MessageBox.Show("Bağlantıyı doğru şekilde yapınız.!");
                }
            }
            if (HitDesignerItem != null)
            {
                this.HitDesignerItem.IsDragConnectionOver = false;
            }

            if (this.IsMouseCaptured)
            {
                this.ReleaseMouseCapture();
            }

            AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.designerCanvas);

            if (adornerLayer != null)
            {
                adornerLayer.Remove(this);
            }
        }
示例#2
0
        private bool ArrangeProperties(ModelChildStateObject SinkconnObj, ModelParentStateObject SourceConnObj, DockPanel Sourcepnl, DockPanel Sinkpnl)
        {
            bool Retval = false;

            List <ModelCanvasStateObject> TransactionList = new List <ModelCanvasStateObject>();

            TransactionList = this.designerCanvas.TransactionList;
            Type ClassType = Type.GetType("ATMDesigner.UI.States.State" + Sourcepnl.Tag.ToString());

            if (!TransactionList.FindAll(x => x.Id == Sourcepnl.Uid).Exists(x => x.TransactionName == designerCanvas.CurrentTransactionName))
            {
                MessageBox.Show("Bağlantıyı doğru şekilde yapınız.!");
                Retval = false;
                return(Retval);
            }

            PropertyGrid SelectedPgrid = TransactionList.FindAll(x => x.Id == Sourcepnl.Uid).Find(x => x.TransactionName == designerCanvas.CurrentTransactionName).PropertyGrid;
            Object       PSelectedObj  = SelectedPgrid.SelectedObject;
            PropertyInfo Property      = ClassType.GetProperty(SourceConnObj.PropertyName.ToString());
            object       PropertyValue = Property.GetValue(PSelectedObj);

            if (Property.GetValue(PSelectedObj).ToString() != "255")
            {
                MessageBox.Show("Bağlantıyı doğru şekilde yapınız.!");
                Retval = false;
                return(Retval);
            }

            Property.SetValue(PSelectedObj, Sinkpnl.Uid, null);
            this.designerCanvas.TransactionList.FindAll(x => x.Id == Sourcepnl.Uid).Find(x => x.TransactionName == designerCanvas.CurrentTransactionName).PropertyGrid.SelectedObject = PSelectedObj;


            //
            //Pointer state bağlanılan stateler için(Transaction arası geçiş)
            //
            if (Sinkpnl.Tag.ToString() == "P")
            {
                //yeni
                PointerStateElements elements = new PointerStateElements();
                StateP pointerstate           = new StateP();
                elements.SourceStateNumber  = Sourcepnl.Uid.ToString();
                elements.SourceStateType    = Sourcepnl.Tag.ToString();
                elements.SourcePropertyName = SourceConnObj.PropertyName;
                if (!TransactionList.FindAll(x => x.Id == Sinkpnl.Uid).Exists(x => x.TransactionName == designerCanvas.CurrentTransactionName))
                {
                    MessageBox.Show("Bağlantıyı doğru şekilde yapınız.!");
                    Retval = false;
                    return(Retval);
                }

                Object PointerObj = TransactionList.FindAll(x => x.Id == Sinkpnl.Uid).Find(x => x.TransactionName == designerCanvas.CurrentTransactionName).PropertyGrid.SelectedObject;
                pointerstate = (StateP)PointerObj;

                Property.SetValue(PSelectedObj, pointerstate.NextStateNumber, null);
                this.designerCanvas.TransactionList.FindAll(x => x.Id == Sourcepnl.Uid).Find(x => x.TransactionName == designerCanvas.CurrentTransactionName).PropertyGrid.SelectedObject = PSelectedObj;


                pointerstate.SourceStatesList.Add(elements);

                this.designerCanvas.TransactionList.FindAll(x => x.Id == Sinkpnl.Uid).Find(x => x.TransactionName == designerCanvas.CurrentTransactionName).PropertyGrid.SelectedObject = pointerstate;
            }

            foreach (var item in TransactionList)
            {
                if (item.Id == SourceConnObj.ParentId)
                {
                    item.ChildStateList.Add(SinkconnObj);
                }
                else if (item.Id == SinkconnObj.ChildId)
                {
                    item.ParentStateList.Add(SourceConnObj);
                }
            }
            this.designerCanvas.TransactionList = TransactionList;
            Retval = true;

            return(Retval);
        }