Esempio n. 1
0
 /// <summary>
 /// Updates arrows forms
 /// </summary>
 public void UpdateForms()
 {
     for (int i = 0; i < arrows.Count; i++)
     {
         IArrowLabelUI lab = arrows[i] as IArrowLabelUI;
         lab.UpdateForm();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Draws all arrows of this pair
        /// </summary>
        /// <param name="g">The graphics to draw</param>
        public void SetArrows(Graphics g)
        {
            object[] arrs = arrows.ToArray();
            int      n    = arrs.Length;
            int      xs   = 0;
            int      ys   = 0;
            int      xt   = 0;
            int      yt   = 0;
            Control  p    = null;

            if (objects[0] is Panel | objects[0] is UserControl)
            {
                p = objects[0] as Control;
            }
            else
            {
                p = ContainerPerformer.GetPanel(objects[0]) as Control;
            }
            xs = p.Left + p.Width / 2;
            ys = p.Top + p.Height / 2;
            if (objects[1] is Panel | objects[1] is UserControl)
            {
                p = objects[1] as Control;
            }
            else
            {
                p = ContainerPerformer.GetPanel(objects[1]) as Control;
            }
            if (p == null)
            {
                return;
            }
            xt = p.Left + p.Width / 2;
            yt = p.Top + p.Height / 2;
            int    xc   = (xt + xs) / 2;
            int    yc   = (yt + ys) / 2;
            int    dx   = (xt - xs) / 2;
            int    dy   = (yt - ys) / 2;
            double d    = Math.Sqrt((double)(dx * dx + dy * dy));
            double px   = -DISTANCE * ((double)dy) / d;
            double py   = DISTANCE * ((double)dx) / d;
            int    posX = xc - (int)((n - 1) * px / 2);
            int    posY = yc - (int)((n - 1) * py / 2);

            for (int i = 0; i < n; i++)
            {
                IArrowLabelUI lab     = arrs[i] as IArrowLabelUI;
                Control       control = lab.Control as Control;
                lab.X = posX + i * (int)px - control.Width / 2;
                lab.Y = posY + i * (int)py - control.Height / 2;
                if (g == null)
                {
                    continue;
                }
                lab.Draw(g);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Removes label from pair
 /// </summary>
 /// <param name="label">The label to remove</param>
 public void Remove(IArrowLabelUI label)
 {
     arrows.Remove(label);
     try
     {
         desktop.Tools.RemoveArrowNode(label);
     }
     catch (Exception ex)
     {
         ex.ShowError(10);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Crerates arrow label from arrow
 /// </summary>
 /// <param name="arr">The arrow</param>
 /// <returns>The label</returns>
 public virtual IArrowLabelUI CreateLabel(ICategoryArrow arr)
 {
     foreach (IUIFactory f in factories)
     {
         IArrowLabelUI a = f.CreateLabel(arr);
         if (a != null)
         {
             return(a);
         }
     }
     return(null);
 }
Esempio n. 5
0
 /// <summary>
 /// Removes arrow node
 /// </summary>
 /// <param name="label">The arrow label</param>
 public void RemoveArrowNode(IArrowLabelUI label)
 {
     if (tree == null)
     {
         return;
     }
     try
     {
         TreeNode n = label.Node as TreeNode;
         arrowsNode.Nodes.Remove(n);
     }
     catch (Exception ex)
     {
         ex.ShowError(10);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Creates arrow label
 /// </summary>
 /// <param name="button">Corresponding button</param>
 /// <param name="arrow">Corresponding arrow</param>
 /// <param name="source">Soource label</param>
 /// <param name="target">Target label</param>
 /// <returns>The arrow label</returns>
 public virtual IArrowLabelUI CreateArrowLabel(IPaletteButton button, ICategoryArrow arrow, IObjectLabel source, IObjectLabel target)
 {
     foreach (IUIFactory f in factories)
     {
         IArrowLabelUI a = f.CreateArrowLabel(button, arrow, source, target);
         if (a != null)
         {
             return(a);
         }
     }
     if (defaultValue)
     {
         return(factory.CreateArrowLabel(button, arrow, source, target));
     }
     return(null);
 }
Esempio n. 7
0
        /// <summary>
        /// Adds arrow node
        /// </summary>
        /// <param name="label"></param>
        public void AddArrowNode(IArrowLabelUI label)
        {
            if (tree == null)
            {
                return;
            }
            NamedNode node = new NamedNode(label, false);

            label.Node = node;
            arrowsNode.Nodes.Add(node);
            NamedNode ns = new NamedNode(label.Source, true);

            node.Nodes.Add(ns);
            NamedNode nt = new NamedNode(label.Target, true);

            node.Nodes.Add(nt);
        }
Esempio n. 8
0
 /// <summary>
 /// Sets new name
 /// </summary>
 /// <param name="name">The name</param>
 public void SetName(string name)
 {
     if (component is NamedComponent)
     {
         NamedComponent comp = component as NamedComponent;
         comp.SetName(name);
     }
     else if (component is IObjectLabelUI)
     {
         IObjectLabelUI olui = component as IObjectLabelUI;
         olui.ComponentName = name;
     }
     else if (component is IArrowLabelUI)
     {
         IArrowLabelUI alui = component as IArrowLabelUI;
         alui.ComponentName = name;
     }
 }
Esempio n. 9
0
        private void buttonOK_Click(object sender, System.EventArgs e)
        {
            int ord = label.Ord;

            try
            {
                int n = listBoxComponents.SelectedIndex;
                if (label is IObjectLabelUI)
                {
                    IObjectLabelUI l = label as IObjectLabelUI;
                    l.Ord = n;
                }
                if (label is IArrowLabelUI)
                {
                    IArrowLabelUI l = label as IArrowLabelUI;
                    l.Ord = n;
                }
                desktop.CheckOrder();
                Dispose();
            }
            catch (Exception ex)
            {
                ex.ShowError(10);
                if (label is IObjectLabelUI)
                {
                    IObjectLabelUI l = label as IObjectLabelUI;
                    l.Ord = ord;
                }
                if (label is IArrowLabelUI)
                {
                    IArrowLabelUI l = label as IArrowLabelUI;
                    l.Ord = ord;
                }
                this.ShowError(ex, Diagram.UI.Utils.ControlUtilites.Resources);
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Adds arrow to this pair
 /// </summary>
 /// <param name="label">The label of arrow to add</param>
 public void Add(IArrowLabelUI label)
 {
     label.Pair = this;
     arrows.Add(label);
 }