public bool IsValidConnection(Point location, ParamIOGate self)
        {
            foreach (UIElement ele in ParamCanvas.GetElementsInCanvasCoordinates(location))
            {
                if (ele is ParamIOGate)
                    if ((ele as ParamIOGate) != self)
                        return true;
            }

            return false;
        }
        public void UpdateInboundParam(Point inboundLocation, ParamIOGate paramGate)
        {
            ParameterConnection line = paramGate.ConnectionLine;

            try
            {
                Point outboundLocation = new Point(line.Connection.X1, line.Connection.Y1);
                ParamInputModel inboundModel = GetParamModelByCoord(inboundLocation) as ParamInputModel;

                if (inboundModel.Value != null)
                {
                    UndoLineDrawing(paramGate);

                    throw new Exception
                        ("This parameter has already got a data source. You can only have one data source," +
                            "try removing its data source before connecting again.");

                }

                ParameterModel outboundModel = GetParamModelByCoord(outboundLocation) as ParameterModel;

                inboundModel.Value = new ParamBinder(outboundModel.ParentName, outboundModel.Name);
                source = inboundModel; //keep a copy of the source for easy alteration of value
                line.LineDeletionEvent += new ParameterConnection.ParamConnectionEventHandler(line_LineDeletionEvent);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void UndoLineDrawing(ParamIOGate paramGate)
        {
            paramGate.ConnectionLine.DeleteLine();
            paramGate.ConnectionLine = null;

            DestroyOutputLine();//destroy any previous drawn lines
        }