Example #1
0
 /// <summary>
 /// Removes associated object
 /// </summary>
 public virtual void RemoveObject()
 {
     if (child != null)
     {
         if (child is IRemovableObject)
         {
             IRemovableObject ro = child as IRemovableObject;
             ro.RemoveObject();
         }
         if (child is IDisposable)
         {
             IDisposable d = child as IDisposable;
             d.Dispose();
         }
     }
 }
Example #2
0
        /// <summary>
        /// Removes itself
        /// </summary>
        public void Remove()
        {
            foreach (IArrowLabelUI label in arrows)
            {
                label.RemoveFromComponent();
                label.RemoveForm();

                // label.RemoveFromComponent();
                //	label.RemoveForm();
                desktop.Tools.RemoveArrowNode(label);
                if (label.Arrow is IRemovableObject)
                {
                    IRemovableObject rem = label.Arrow as IRemovableObject;
                    rem.RemoveObject();
                }
            }
            arrows = null;
            desktop.Remove(this);
            GC.Collect();
        }
Example #3
0
 /// <summary>
 /// Removes itself
 /// </summary>
 /// <param name="removeForm">The "should remove properties editor" flag</param>
 public void Remove(bool removeForm)
 {
     if (Desktop == null)
     {
         return;
     }
     Desktop.Tools.RemoveArrowNode(this);
     RemoveFromComponent();
     pair.Remove(this);
     pair.Refresh();
     if (removeForm)
     {
         RemoveForm();
     }
     if (Arrow is IRemovableObject)
     {
         IRemovableObject obj = Arrow as IRemovableObject;
         obj.RemoveObject();
     }
     arrow = null;
     GC.Collect();
 }
 private void ActionIsBeingRemovedHandler(IRemovableObject item)
 {
     Remove();
 }
Example #5
0
        /// <summary>
        /// Removes itself
        /// </summary>
        /// <param name="removeForm">The "remove form" sign</param>
        public void Remove(bool removeForm)
        {
            Control cp = Parent;

            if (cp != null)
            {
                if (cp.Controls.Contains(rbox))
                {
                    cp.Controls.Remove(rbox);
                }
            }
            if (removeForm)
            {
                if (label is IShowForm)
                {
                    IShowForm sf   = label as IShowForm;
                    Form      form = sf.Form as Form;
                    if (form is IRemovableObject)
                    {
                        IRemovableObject r = form as IRemovableObject;
                        r.RemoveObject();
                    }
                    sf.RemoveForm();
                    sf = null;
                }
            }
            if (isRemoved)
            {
                return;
            }
            isRemoved = true;
            if (label is IRemovableObject)
            {
                IRemovableObject r = label as IRemovableObject;
                r.RemoveObject();
            }
            Control cont = label as Control;
            Control c    = Parent;

            if (c != null)
            {
                PanelDesktop d = pDesktop;
                if (c.Controls.Contains(cont))
                {
                    d.Remove(label);
                    if (c.Controls.Contains(cont))
                    {
                        c.Controls.Remove(cont);
                    }
                }
            }
            if (label.Object is IRemovableObject)
            {
                IRemovableObject obj = label.Object as IRemovableObject;
                obj.RemoveObject();
                obj = null;
            }
            cont.Dispose();
            label = null;
            cont  = null;
            GC.Collect();
        }
Example #6
0
        private void MouseUp(object sender, MouseEventArgs e)
        {
            Control caption = sender as Control;

            IsMoved = false;
            pDesktop.SetBlocking(false);
            PanelDesktop   Desktop = pDesktop;
            ICategoryArrow arrow   = Desktop.ActiveArrow;

            if (!StaticExtensionDiagramUIForms.IsArrowClick(e))
            {
                return;
            }
            try
            {
                if (arrow == null)
                {
                    pDesktop.Redraw();
                    return;
                }
                int x = this.label.X + caption.Left + e.X;
                int y = this.label.Y + caption.Top + e.Y;
                for (int i = 0; i < Desktop.Controls.Count; i++)
                {
                    if (!(Desktop.Controls[i] is IChildObjectLabel) & !(Desktop.Controls[i] is IObjectLabelUI))
                    {
                        continue;
                    }
                    Control c = Desktop.Controls[i];
                    bool    hor = x <c.Left | x> c.Left + c.Width;
                    bool    vert = y <c.Top | y> c.Top + c.Height;
                    if (hor | vert)
                    {
                        continue;
                    }
                    IObjectLabel label = null;
                    if (Desktop.Controls[i] is IObjectLabelUI)
                    {
                        label = Desktop.Controls[i] as IObjectLabel;
                    }
                    else
                    {
                        IChildObjectLabel child = Desktop.Controls[i] as IChildObjectLabel;
                        label = child.Label;
                    }

                    arrow.Target = label.Object;
                    IArrowLabel lab = Desktop.Tools.Factory.CreateArrowLabel(Desktop.Tools.Active, arrow, this.label, label);
                    lab.Arrow.SetAssociatedObject(lab);
                    Desktop.AddArrowLabel(lab);
                    break;
                }
            }
            catch (Exception ex)
            {
                ex.ShowError(10);
                if (arrow != null)
                {
                    if (arrow is IRemovableObject)
                    {
                        IRemovableObject rem = arrow as IRemovableObject;
                        rem.RemoveObject();
                    }
                }
                ex.ShowError(1);
            }
            Desktop.ActiveArrow = null;
            Desktop.Redraw();
        }
Example #7
0
        /// <summary>
        /// The on mouse up event handler
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The event arguments</param>
        protected void onMouseUpArrow(object sender, MouseEventArgs e)
        {
            //isMoved = false;
            PanelDesktop   desktop = Parent as PanelDesktop;
            ICategoryArrow arrow   = desktop.ActiveArrow;

            if (!StaticExtensionDiagramUIForms.IsArrowClick(e))
            {
                return;
            }
            if (!(nc is IObjectLabel))
            {
                return;
            }
            IObjectLabel    ol  = nc as IObjectLabel;
            ICategoryObject obj = ol.Object;

            try
            {
                if (arrow == null)
                {
                    return;
                }
                int x = Left + e.X;
                int y = Top + e.Y;
                for (int i = 0; i < desktop.Controls.Count; i++)
                {
                    if (!(desktop.Controls[i] is ChildObjectLabel) & !(desktop.Controls[i] is ObjectLabel))
                    {
                        continue;
                    }
                    Control c = desktop.Controls[i];
                    bool    hor = x <c.Left | x> c.Left + c.Width;
                    bool    vert = y <c.Top | y> c.Top + c.Height;
                    if (hor | vert)
                    {
                        continue;
                    }
                    IObjectLabel label = null;
                    if (desktop.Controls[i] is IObjectLabel)
                    {
                        label = desktop.Controls[i] as IObjectLabel;
                    }
                    else
                    {
                        ChildObjectLabel child = desktop.Controls[i] as ChildObjectLabel;
                        label = child.Label;
                    }
                    arrow.Target = label.Object;
                    ArrowLabel lab =
                        desktop.Tools.Factory.CreateArrowLabel(desktop.Tools.Active,
                                                               arrow, ol, label) as ArrowLabel;
                    lab.Arrow.Object = lab;
                    desktop.AddArrowLabel(lab);
                    break;
                }
            }
            catch (Exception ex)
            {
                ex.ShowError(10);
                if (arrow != null)
                {
                    if (arrow is IRemovableObject)
                    {
                        IRemovableObject rem = arrow as IRemovableObject;
                        rem.RemoveObject();
                    }
                }
                ex.ShowError(1);
            }
            desktop.ActiveArrow = null;
            desktop.Redraw();
        }
Example #8
0
        /// <summary>
        /// The on mouse up event handler
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The event arguments</param>
        protected void onMouseUpMoveEventHandler(object sender, MouseEventArgs e)
        {
            isMoved         = false;
            Desktop.IsMoved = false;
            Desktop.SetBlocking(false);
            ICategoryArrow arrow = Desktop.ActiveArrow;

            if (!e.IsArrowClick())
            {
                return;
            }
            try
            {
                if (arrow == null)
                {
                    Desktop.Redraw();
                    return;
                }
                int x = Left + e.X;
                int y = Top + e.Y;
                for (int i = 0; i < Desktop.Controls.Count; i++)
                {
                    if (!(Desktop.Controls[i] is IChildObjectLabel) & !(Desktop.Controls[i] is IObjectLabel))
                    {
                        continue;
                    }
                    Control c = Desktop.Controls[i];
                    bool    hor = x <c.Left | x> c.Left + c.Width;
                    bool    vert = y <c.Top | y> c.Top + c.Height;
                    if (hor | vert)
                    {
                        continue;
                    }
                    IObjectLabel label = null;
                    if (Desktop.Controls[i] is IObjectLabel)
                    {
                        label = Desktop.Controls[i] as IObjectLabel;
                    }
                    else
                    {
                        IChildObjectLabel child = Desktop.Controls[i] as IChildObjectLabel;
                        label = child.Label;
                    }

                    arrow.Target = label.Object;
                    IArrowLabel lab = Desktop.Tools.Factory.CreateArrowLabel(Desktop.Tools.Active, arrow, this, label);
                    lab.Arrow.SetAssociatedObject(lab);
                    Desktop.AddArrowLabel(lab);
                    break;
                }
            }
            catch (Exception ex)
            {
                ex.ShowError(10);
                if (arrow != null)
                {
                    if (arrow is IRemovableObject)
                    {
                        IRemovableObject rem = arrow as IRemovableObject;
                        rem.RemoveObject();
                    }
                }
                ex.ShowError(1);;
            }
            Desktop.ActiveArrow = null;
            Desktop.Redraw();
        }