Esempio n. 1
0
        /// <summary>
        /// Consructor
        /// </summary>
        /// <param name="desktop">Desktop</param>
        public FormOrder(PanelDesktop desktop)
        {
            InitializeComponent();
            this.LoadControlResources(ControlUtilites.Resources);
            this.desktop = desktop;
            IList <IObjectLabel> objs;
            IList <IArrowLabel>  arrs;

            desktop.GetSelected(out objs, out arrs);
            if (objs.Count != 0 | arrs.Count != 0)
            {
                if (objs.Count == 0)
                {
                    return;
                }
                else
                {
                    label = objs[0] as INamedComponent;
                }
            }
            else
            {
                label = objs[0] as INamedComponent;
            }
            labelObject.Text = label.Name;
            foreach (Control c in desktop.Controls)
            {
                if (!(c is INamedComponent))
                {
                    continue;
                }
                INamedComponent nc = c as INamedComponent;
                listBoxComponents.Items.Add(nc.Name);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Shows error
        /// </summary>
        /// <param name="form">Parent form</param>
        /// <param name="e">Exception</param>
        /// <param name="helpstring">Help string</param>
        /// <param name="r">Resources</param>
        public static void ShowError(this Form form, Exception e, string helpstring, Dictionary <string, string> r)
        {
            IErrorHandler eh = Diagram.UI.StaticExtensionDiagramUI.ErrorHandler;

            if (eh != null)
            {
                e.ShowError(0);
                return;
            }
            string message = e.Message;

            if (r != null)
            {
                string rMessage = r[message];
                if (rMessage != null)
                {
                    message = rMessage;
                }
                else
                {
                    message = r["System error : "] + message + r[" contact developer"];
                }
            }
            WindowsExtensions.ControlExtensions.ShowMessageBoxModal(form, message, PanelDesktop.GetResourceString("Error", r), MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Esempio n. 3
0
 internal DragDropStream(string name, PanelDesktop desktop)
 {
     this.name          = name;
     desktop.DragEnter += dragEnter;
     desktop.DragDrop  += dragDrop;
     this.desktop       = desktop;
 }
Esempio n. 4
0
        /// <summary>
        /// The on mouse down event handler
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The event arguments</param>
        private void onMouseDownMoveEventHandler(object sender, MouseEventArgs e)
        {
            if (!e.IsArrowClick())
            {
                return;
            }
            IObjectLabel lab = Label;

            if (lab == null)
            {
                return;
            }
            PanelDesktop  desktop = Parent as PanelDesktop;
            PaletteButton active  = desktop.Tools.Active;

            if (active != null)
            {
                if (active.IsArrow & !(active.ReflectionType == null))
                {
                    try
                    {
                        ICategoryArrow arrow = desktop.Tools.Factory.CreateArrow(active);
                        arrow.Source              = lab.Object;
                        desktop.ActiveArrow       = arrow;
                        desktop.ActiveObjectLabel = lab;
                        return;
                    }
                    catch (Exception ex)
                    {
                        ex.ShowError(10);
                    }
                }
            }
        }
Esempio n. 5
0
 internal DragDropConverter(ICategoryObjectConverter converter, PanelDesktop desktop)
 {
     this.converter     = converter;
     this.desktop       = desktop;
     desktop.AllowDrop  = true;
     desktop.DragEnter += dragEnter;
     desktop.DragDrop  += dragDrop;
 }
Esempio n. 6
0
 void IDragDrop.Set(ICategoryObjectConverter converter, PanelDesktop desktop)
 {
     this.converter     = converter;
     this.desktop       = desktop;
     desktop.AllowDrop  = true;
     desktop.DragEnter += DragEnter;
     desktop.DragDrop  += DragDrop;
 }
 internal static void SetDragDrop(this PanelDesktop desktop)
 {
     foreach (IDragDrop dd in dragDrop)
     {
         IDragDrop d = dd.New;
         d.Set(null, desktop);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Start
 /// </summary>
 /// <param name="startTime">Start time</param>
 /// <param name="pause">Pause</param>
 /// <param name="step">Step</param>
 /// <param name="stepCount">Step Count</param>
 /// <param name="desktop">Desktop</param>
 public void Start(double startTime, double step, int stepCount, int pause, int timeIndicator, IDesktop desktop)
 {
     this.startTime = startTime;
     this.pause = pause;
     this.step = step;
     this.stepCount = stepCount;
     this.timeIndicator = timeIndicator; 
     this.desktop = desktop as PanelDesktop;
     StartWorker();
 }
Esempio n. 9
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            IFieldConsumer c = consumer;

            c.Consume();
            IDesktop r = label.Root.Desktop;

            if (r is PanelDesktop)
            {
                PanelDesktop d = r as PanelDesktop;
                d.Refresh();
            }
        }
Esempio n. 10
0
        /// <summary>
        /// The on mouse move event handler
        /// Draws correspond arrows
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The event arguments</param>
        protected void onMouseMoveArrow(object sender, MouseEventArgs e)
        {
            PanelDesktop desktop = Parent as PanelDesktop;

            if (!e.IsArrowClick())
            {
                return;
            }
            if (desktop.ActiveArrow == null)
            {
                return;
            }
            desktop.DrawArrow(this, e);
        }
Esempio n. 11
0
        internal void remove()
        {
            RemoveForm();
            PanelDesktop desktop = Parent as PanelDesktop;

            if (desktop != null)
            {
                desktop.remove(this);
            }
            if (nc != null)
            {
                nc.Remove();
            }
        }
Esempio n. 12
0
        private void paintC(object c, PaintEventArgs e)
        {
            INamedComponent nc = this;
            PanelDesktop    d  = nc.Desktop as PanelDesktop;

            if (d.IsMoved)
            {
                return;
            }
            if (bmp == null)
            {
                return;
            }
            e.Graphics.DrawImage(bmp, 0, 0);
        }
Esempio n. 13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="tools">Tools</param>
 /// <param name="ext">Extension of files</param>
 public FormDesktop(ToolsDiagram tools, string ext)
     : this()
 {
     Text = ResourceService.Resources.GetControlResource("Desktop", ControlUtilites.Resources) + " " + nDesktop;
     ++nDesktop;
     desktop = new PanelDesktop(tools);
     StaticExtensionDiagramUI.CurrentDeskop = desktop;
     desktop.Extension  = ext;
     desktop.AutoScroll = true;
     desktop.Dock       = DockStyle.Fill;
     panelCenter.Controls.Add(desktop);
     desktop.ResizeImage();
     ToolBox.EditorReceiver.AddEditorDrag(desktop);
     ToolBox.PictureReceiver.AddImageDrag(desktop);
 }
Esempio n. 14
0
        /// <summary>
        /// Shows form
        /// </summary>
        public void ShowForm()
        {
            PanelDesktop desktop = Parent as PanelDesktop;
            bool         init    = false;

            try
            {
                if (form == null)
                {
                    form = desktop.Tools.Factory.CreateForm(nc) as Form;
                    init = true;
                }
                if (form != null)
                {
                    if (form.IsDisposed)
                    {
                        form = desktop.Tools.Factory.CreateForm(nc) as Form;
                        init = true;
                    }
                    if (init)
                    {
                        form.FormClosing += (object sender, FormClosingEventArgs e) =>
                        {
                            form.Prepare();
                        };
                        if (form is IUpdatableForm)
                        {
                            (form as IUpdatableForm).UpdateFormUI();
                        }
                        Action <Form> act = StaticExtensionDiagramUIForms.PostFormLoad;
                        if (act != null)
                        {
                            act(form);
                        }
                    }
                    form.Show();
                    form.BringToFront();
                    form.Activate();
                    form.Focus();
                    form.Show();
                }
            }
            catch (Exception ex)
            {
                ex.ShowError(10);
            }
        }
Esempio n. 15
0
        private void MovedBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (!moved)
            {
                return;
            }
            int dx = e.X - mouseX;
            int dy = e.Y - mouseY;

            Left    += dx;
            Top     += dy;
            label.X += dx;
            label.Y += dy;
            PanelDesktop d = label.Desktop as PanelDesktop;

            d.Redraw();
        }
Esempio n. 16
0
        private void ResizeBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (!moved)
            {
                return;
            }
            int dx = e.X - mouseX;
            int dy = e.Y - mouseY;

            Left += dx;
            Top  += dy;
            Control c = label as Control;

            c.Width  += dx;
            c.Height += dy;
            PanelDesktop d = label.Desktop as PanelDesktop;

            d.Redraw();
        }
Esempio n. 17
0
        private void MMouseMove(object sender, MouseEventArgs e)
        {
            Control caption = sender as Control;

            if (!pDesktop.Tools.IsMoved)
            {
                return;
            }
            if (!IsMoved)
            {
                return;
            }
            Control c  = caption;
            int     dx = e.X - mouseX;
            int     dy = e.Y - mouseY;

            //c.Left += dx;
            //c.Top += dy;
            label.X += dx;
            label.Y += dy;
            PanelDesktop d = label.Desktop as PanelDesktop;

            if (label.Selected)
            {
                foreach (Control control in pDesktop.Controls)
                {
                    if (control is IObjectLabelUI)
                    {
                        IObjectLabelUI olui = control as IObjectLabelUI;
                        if (olui.Selected)
                        {
                            if (olui != label)
                            {
                                olui.X += dx;
                                olui.Y += dy;
                            }
                        }
                    }
                }
            }
            d.Redraw();
        }
Esempio n. 18
0
 /// <summary>
 /// Test buffer with UI
 /// </summary>
 /// <param name="buffer">Byte buffer that contains scenario</param>
 /// <param name="binder">Serialization binder</param>
 /// <param name="pan">Desktop</param>
 /// <param name="ext">Extension</param>
 /// <param name="extd">Required extension</param>
 /// <returns>Test exception</returns>
 public Exception TestBuffer(byte[] buffer, SerializationBinder binder, PanelDesktop pan, string ext, string extd)
 {
     try
     {
         MemoryStream ms = new MemoryStream(buffer);
         pan.LoadFromStream(ms, binder, ext, extd);
         foreach (object o in pan.Controls)
         {
             if (o is IShowForm)
             {
                 IShowForm sf = o as IShowForm;
                 sf.ShowForm();
             }
         }
         pan.TempDelete();
     }
     catch (Exception e)
     {
         e.ShowError(10);
         return(TestException.GetRoot(e));
     }
     return(null);
 }
Esempio n. 19
0
        /// <summary>
        /// Test database with UI
        /// </summary>
        /// <param name="data">Database</param>
        /// <param name="binder">Serialization binder</param>
        /// <param name="pan">Desktop</param>
        /// <param name="ext">Extension</param>
        /// <param name="extd">Required extension</param>
        /// <param name="logWriter">Log writer</param>
        public void TestData(DatabaseInterface data, SerializationBinder binder, PanelDesktop pan, string ext,
                             string extd, TextWriter logWriter)
        {
            IDictionary <object, object> t = data.GetItems(ext);

            foreach (object o in t.Keys)
            {
                string e      = ext + "";
                object id     = o;
                byte[] buffer = data.GetData(o + "", ref e);
                object ob     = t[o];
                if (ob is object[])
                {
                    ob = ((object[])ob)[0];
                }
                string s = ob + "";
                if (logWriter != null)
                {
                    logWriter.WriteLine("+++++++++++");
                    logWriter.WriteLine(s);
                    logWriter.WriteLine("+++++++++++");
                }
                Exception ex = TestBuffer(buffer, binder, pan, ext, extd);
                if (ex != null)
                {
                    TestException te = new TestException(s, id, ex);
                    write(te);
                    if (StopAtFirstError)
                    {
                        return;
                    }
                }
                buffer = null;
                GC.Collect();
            }
        }
Esempio n. 20
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();
        }
Esempio n. 21
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();
        }
Esempio n. 22
0
        /// <summary>
        /// Creates Form
        /// </summary>
        public override void CreateForm()
        {
            PanelDesktop d = StaticExtensionDiagramUI.CurrentDeskop as PanelDesktop;

            form = d.Tools.Factory.CreateForm(this) as Form;
        }
Esempio n. 23
0
        /// <summary>
        /// Gets component button
        /// </summary>
        /// <param name="component">Component</param>
        /// <returns>The component button</returns>
        public static IPaletteButton GetButton(INamedComponent component)
        {
            PanelDesktop desktop = GetDesktop(component);

            return(desktop.Tools.FindButton(component));
        }
Esempio n. 24
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();
        }