public void Clone(object value)
        {
            // Writes a deep (value-wise) copy onto the object from value
            SubsystemIcon copy = (SubsystemIcon)value;

            Location = new Point(copy.Location.X, copy.Location.Y);
        }
        private void DrawingCanvas_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            // If drawing canvas intercepts double-click, nothing exists here; create a new subsystem
            // Ask for subsystem name
            TextboxDialog dialog = new TextboxDialog("Create new subsystem", "New subsystem name");

            dialog.ShowDialog();
            if (dialog.Cancelled)
            {
                return;
            }

            // Create new element
            SubsystemElement newSubsystem = new SubsystemElement();

            newSubsystem.Name = dialog.StringValue;

            // Create new icon
            SubsystemIcon newIcon = new SubsystemIcon();

            newIcon.MouseDown += new MouseEventHandler(SubsystemClicked);
            newIcon.MouseMove += new MouseEventHandler(newIcon_MouseMove);
            newIcon.subsystem  = newSubsystem;
            newIcon.Location   = new Point(e.X, e.Y);
            newIcon.Parent     = this;
            SubsystemIcons.Add(newIcon);
            RefreshConnections();
        }
        public object Clone()
        {
            // Returns a deep (value-wise) copy of the object's relevant values
            SubsystemIcon copy = new SubsystemIcon();

            copy.Location = new Point(Location.X, Location.Y);
            return(copy);
        }
 public DependencyConnection()
 {
     DependentIcon   = null;
     IndependentIcon = null;
     OpenPoint       = new Point(0, 0);
     shade           = Color.Black;
     BackColor       = Color.Transparent;
     Thickness       = 2;
     InitializeComponent();
 }
        public void SubsystemClicked(object sender, MouseEventArgs e)
        {
            try
            {
                SubsystemIcon icon = (SubsystemIcon)sender;
                if (floater != null)
                {
                    // Connect other end
                    if (floater.IndependentIcon == null)
                    {
                        floater.IndependentIcon = icon;
                    }
                    else
                    {
                        floater.DependentIcon = icon;
                    }

                    // Add to list and reset floater reference
                    Connections.Add(floater);
                    floater = null;
                    RefreshConnections();
                    return;
                }
                if (icon.IsOverLeft)
                {
                    // Create floating dependency from left side
                    floater               = new DependencyConnection();
                    floater.Parent        = this;
                    floater.Location      = new Point(0, 0);
                    floater.Height        = Height;
                    floater.Width         = Width;
                    floater.DependentIcon = icon;
                    floater.OpenPoint     = e.Location;
                    floater.Refresh();
                }
                if (icon.IsOverRight)
                {
                    // Create floating (in)dependency from right side
                    floater                 = new DependencyConnection();
                    floater.Parent          = this;
                    floater.Location        = new Point(0, 0);
                    floater.Height          = Height;
                    floater.Width           = Width;
                    floater.IndependentIcon = icon;
                    floater.OpenPoint       = e.Location;
                    floater.Refresh();
                }
            }
            catch (InvalidCastException)
            {
                // Subsystem click not sent by subsystem
                MessageBox.Show("Subsystem click not sent by subsystem");
            }
        }
 public void newIcon_MouseMove(object sender, MouseEventArgs e)
 {
     // Update connections and canvas if icon moved
     try
     {
         SubsystemIcon ico = (SubsystemIcon)sender;
         if (ico.IsMoving)
         {
             RefreshConnections();
         }
     }
     catch (InvalidCastException)
     {
         // Sender wasn't a subsystem icon
     }
 }