/// <summary>
        /// Deserialization constructor
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected Connector(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            this.mName = info.GetString("mName");

            this.mAllowMultipleConnections = info.GetBoolean("mAllowMultipleConnections");

            this.ConnectorLocation = (ConnectorLocation)info.GetValue("mConnectorLocation", typeof(ConnectorLocation));

            this.mConnectionShift = info.GetSingle("mConnectionShift");

            try
            {
                this.mAllowNewConnectionsFrom = info.GetBoolean("mAllowNewConnectionsFrom");
            }
            catch
            {
                this.mAllowNewConnectionsFrom = true;
            }
            try
            {
                this.mAllowNewConnectionsTo = info.GetBoolean("mAllowNewConnectionsTo");
            }
            catch
            {
                this.mAllowNewConnectionsTo = true;
            }

            mConnections = new ConnectionCollection();
            mSendList    = new ArrayList();
            mReceiveList = new ArrayList();
        }
示例#2
0
 //-------------------------------------------------------------------------------------------//
 //--- Add a new connector location list control to the list view as well as the data list ---//
 //-------------------------------------------------------------------------------------------//
 public void AddConnectorLocation(ConnectorLocation connectorLocation)
 {
     if (!HasConnectorLocation(connectorLocation))
     {
         AddListViewItem(connectorLocation);
     }
 }
 private void ControlsToData()
 {
     if (connectorLocation == null)
     {
         connectorLocation = new ConnectorLocation();
     }
     connectorLocation = connectorLocationPinControl.ConnectorLocationPin;
 }
 private void DataToControls()
 {
     if (connectorLocation == null)
     {
         connectorLocation = new ConnectorLocation();
     }
     connectorLocationPinControl.ConnectorLocationPin = connectorLocation;
 }
示例#5
0
 private void ControlsToData()
 {
     if (connectorLocationPin == null)
     {
         connectorLocationPin = new ConnectorLocation();
     }
     connectorLocationPin.connectorID = edtConnectorId.Text;
     connectorLocationPin.pinID       = edtConnectorPinId.Text;
 }
示例#6
0
        private bool HasConnectorLocation(ConnectorLocation connectorLocation)
        {
            bool hasConnectorLocation = false;

            foreach (ListViewItem selectedItem in SelectedItems)
            {
                ConnectorLocation item = selectedItem.Tag as ConnectorLocation;
                if (item != null && item.connectorID.Equals(connectorLocation.connectorID) &&
                    item.pinID.Equals(connectorLocation.pinID))
                {
                    hasConnectorLocation = true;
                    break;
                }
            }
            return(hasConnectorLocation);
        }
示例#7
0
        //-------------------------------------------------------------//
        //--- Add a connector location pin to the list view control ---//
        //-------------------------------------------------------------//
        private int AddListViewItem(ConnectorLocation connectorLocation)
        {
            if (connectorLocation == null)
            {
                connectorLocation = new ConnectorLocation();
            }
            var item = new ListViewItem(connectorLocation.connectorID);

            item.SubItems.Add(connectorLocation.pinID);
            item.Tag = connectorLocation;
            if (lvList.Columns.Count >= 2)
            {
                lvList.Columns[0].Width = -2;
                lvList.Columns[1].Width = -2;
            }
            return(lvList.Items.Add(item).Index);
        }
示例#8
0
        //----------------------------------------//
        //--- Add a new connector location pin ---//
        //----------------------------------------//
        protected override void btnAdd_Click(object sender, EventArgs e)
        {
            var form = new ConnectorLocationPinForm(_connectors);
            //--------------------------------------------------------------------------------------------------------------//
            //--- If there already locations in the list, then lets grab the last connector id and set it on the new pin ---//
            //--------------------------------------------------------------------------------------------------------------//
            var locationPin = new ConnectorLocation();

            if (lvList.Items.Count > 0)
            {
                locationPin.connectorID = ((ConnectorLocation)lvList.Items[lvList.Items.Count - 1].Tag).connectorID;
            }
            form.ConnectorLocation = locationPin;
            if (DialogResult.OK == form.ShowDialog())
            {
                AddConnectorLocation(form.ConnectorLocation);
            }
        }
示例#9
0
        /// <summary>
        /// Binds the given connection to the shape at the specified connector location.
        /// </summary>
        /// <param name="con">The connection.</param>
        /// <param name="property">The property of the connection to bind to.</param>
        /// <param name="location">The location (Right, 
        /// Left, Top or Bottom).</param>
        public void BindConnection(Connection con, DependencyProperty property, ConnectorLocation location)
        {
            //A multibinding is like a many-to-one function which returns a value for a dependency property 
            //in terms of multiple values.
            //The WidthConverter is the class that does the actual conversion of data to one Point-value.
            //MultiBinding mb = new MultiBinding();
            Binding bb = new Binding("Who");
            bb.Source = this;
            bb.Converter = new ConnectorConverter2();
            bb.NotifyOnSourceUpdated = true;
            bb.Mode = BindingMode.OneWay;
            bb.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            //mb.Converter = new ConnectorConverter();
            //this is nasty hack, don't like it but the connection will not be visible if the
            //converter does not return because width and/or height is NaN. Argh.
            //if (double.IsNaN(this.Width))
            //    this.Width = this.DesiredSize.Width;
            //if (double.IsNaN(this.Height))
            //    this.Height = this.DesiredSize.Height;

            //mb.Mode = BindingMode.TwoWay;
            //mb.NotifyOnSourceUpdated = true;

            //Because of the multiple locations we have to switch between the various possibilities.
            switch (location)
            {
                case ConnectorLocation.Top:
                    bb.ConverterParameter = "Top";
                    break;
                case ConnectorLocation.Right:
                    bb.ConverterParameter = "Right";
                    break;
                case ConnectorLocation.Bottom:
                    bb.ConverterParameter = "Bottom";
                    break;
                case ConnectorLocation.Left:
                    bb.ConverterParameter = "Left";
                    break;
                default:
                    break;
            }

            //Binding bx = new Binding("(Canvas.Left)");
            //bx.Source = this;
            //bx.Mode = BindingMode.TwoWay;
            //bx.NotifyOnSourceUpdated = true;
            //mb.Bindings.Add(bx);

            //Binding by = new Binding("(Canvas.Top)");
            //by.Source = this;
            ////bwh.Mode = BindingMode.TwoWay;
            //mb.Bindings.Add(by);

            //Binding bw = new Binding("Width");            
            //bw.Source = this;
            ////bww.Mode = BindingMode.TwoWay;
            //mb.Bindings.Add(bw);

            //Binding bh = new Binding("Height");
            //bh.Source = this;
            ////bww.Mode = BindingMode.TwoWay;
            //mb.Bindings.Add(bh);

            con.SetBinding(property, bb);
           
            this.mConnections.Add(con);
        }
示例#10
0
        /// <summary>
        /// Binds the given connection to the shape at the specified connector location.
        /// </summary>
        /// <param name="con">The connection.</param>
        /// <param name="property">The property of the connection to bind to.</param>
        /// <param name="location">The location (Right,
        /// Left, Top or Bottom).</param>
        public void BindConnection(Connection con, DependencyProperty property, ConnectorLocation location)
        {
            //A multibinding is like a many-to-one function which returns a value for a dependency property
            //in terms of multiple values.
            //The WidthConverter is the class that does the actual conversion of data to one Point-value.
            //MultiBinding mb = new MultiBinding();
            Binding bb = new Binding("Who");

            bb.Source                = this;
            bb.Converter             = new ConnectorConverter2();
            bb.NotifyOnSourceUpdated = true;
            bb.Mode = BindingMode.OneWay;
            bb.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            //mb.Converter = new ConnectorConverter();
            //this is nasty hack, don't like it but the connection will not be visible if the
            //converter does not return because width and/or height is NaN. Argh.
            //if (double.IsNaN(this.Width))
            //    this.Width = this.DesiredSize.Width;
            //if (double.IsNaN(this.Height))
            //    this.Height = this.DesiredSize.Height;

            //mb.Mode = BindingMode.TwoWay;
            //mb.NotifyOnSourceUpdated = true;

            //Because of the multiple locations we have to switch between the various possibilities.
            switch (location)
            {
            case ConnectorLocation.Top:
                bb.ConverterParameter = "Top";
                break;

            case ConnectorLocation.Right:
                bb.ConverterParameter = "Right";
                break;

            case ConnectorLocation.Bottom:
                bb.ConverterParameter = "Bottom";
                break;

            case ConnectorLocation.Left:
                bb.ConverterParameter = "Left";
                break;

            default:
                break;
            }

            //Binding bx = new Binding("(Canvas.Left)");
            //bx.Source = this;
            //bx.Mode = BindingMode.TwoWay;
            //bx.NotifyOnSourceUpdated = true;
            //mb.Bindings.Add(bx);

            //Binding by = new Binding("(Canvas.Top)");
            //by.Source = this;
            ////bwh.Mode = BindingMode.TwoWay;
            //mb.Bindings.Add(by);

            //Binding bw = new Binding("Width");
            //bw.Source = this;
            ////bww.Mode = BindingMode.TwoWay;
            //mb.Bindings.Add(bw);

            //Binding bh = new Binding("Height");
            //bh.Source = this;
            ////bww.Mode = BindingMode.TwoWay;
            //mb.Bindings.Add(bh);

            con.SetBinding(property, bb);

            this.mConnections.Add(con);
        }