//private DrawingPage _page = null;

        public DrawingItemDesignerGlyph(
            BehaviorService behaviorService,
            IComponentChangeService changeService,
            ISelectionService selectionService,
            IDesigner relatedDesigner,
            Adorner anchorAdorner)
            : base(new DrawingItemBehavior(relatedDesigner))
        {
            // Cache references for convenience.

            this.behaviorService  = behaviorService;
            this.changeService    = changeService;
            this.selectionService = selectionService;
            this.relatedDesigner  = relatedDesigner;
            this.anchorAdorner    = anchorAdorner;

            // Cache a reference to the control being designed.
            this.drawingItem =
                this.relatedDesigner.Component as DrawingItem;
            //
            // Hook the SelectionChanged event.
            this.selectionService.SelectionChanged +=
                new EventHandler(selectionService_SelectionChanged);

            // Hook the ComponentChanged event so the anchor glyphs
            // can correctly track the control's bounds.
            this.changeService.ComponentChanged +=
                new ComponentChangedEventHandler(changeService_ComponentChanged);
            //
            computeBounds();
        }
Esempio n. 2
0
        public void ClearMarks()
        {
            if (selectedDrawing != null)
            {
                selectedDrawing.IsSelected = false;
                if (selectedDrawing.Container != null)
                {
                    selectedDrawing.Container.IsSelected = false;
                }
            }
            bool b = true;

            while (b)
            {
                b = false;
                for (int i = 0; i < Controls.Count; i++)
                {
                    if (Controls[i] is DrawingMark)
                    {
                        b = true;
                        Controls.RemoveAt(i);
                        break;
                    }
                }
            }
            selectedDrawing = null;
            designer        = null;
        }
 public virtual DrawingItem HitTestChild(Control owner, int x, int y)
 {
     if (_items != null)
     {
         int x0 = x - this.Left;
         int y0 = y - this.Top;
         if (this.RotateAngle != 0)
         {
             PointF pf = DrawRect.ConvertPoint(this.RectF, this.RotateAngle, new PointF((float)x, (float)y));
             x0 = (int)pf.X;
             y0 = (int)pf.Y;
         }
         for (int i = _items.Count - 1; i >= 0; i--)
         {
             DrawingItem  obj = _items[i];
             DrawGroupBox dgb = obj as DrawGroupBox;
             if (dgb != null)
             {
                 DrawingItem o = dgb.HitTestChild(owner, x0, y0);
                 if (o != null)
                 {
                     return(o);
                 }
             }
             if (obj.HitTest(owner, x0, y0))
             {
                 return(obj);
             }
         }
     }
     return(null);
 }
 public static CodeExpression GetDrawItemExpression(DrawingControl dc)
 {
     if (dc != null)
     {
         DrawingItem di = dc.Item as DrawingItem;
         if (di != null)
         {
             DrawDataRepeater ddp = di.Container as DrawDataRepeater;
             if (ddp != null)
             {
                 //((item type)<repeater name>[<drawing item name>])
                 TypeMappingAttribute tma = null;
                 object[]             vs  = dc.GetType().GetCustomAttributes(typeof(TypeMappingAttribute), true);
                 if (vs != null && vs.Length > 0)
                 {
                     tma = vs[0] as TypeMappingAttribute;
                 }
                 if (tma != null)
                 {
                     CodeFieldReferenceExpression repeater = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), ddp.Name);
                     CodeIndexerExpression        cie      = new CodeIndexerExpression(repeater, new CodePrimitiveExpression(dc.Name));
                     CodeCastExpression           cce      = new CodeCastExpression(tma.MappedType, cie);
                     return(cce);
                 }
             }
         }
     }
     return(null);
 }
 public override void OnDraw(Graphics g)
 {
     base.OnDraw(g);             //draw rectangle
     DrawImage.DrawImageOnRect(g, getBackImage());
     if (_items != null)
     {
         DrawingPage.VerifyDrawingOrder(_items, false);
         GraphicsState gs = g.Save();
         if (RotateAngle != 0)
         {
             double    angle = (RotateAngle / 180) * Math.PI;
             Rectangle rc    = this.Rectangle;
             g.TranslateTransform(
                 (rc.Width + (float)(rc.Height * Math.Sin(angle)) - (float)(rc.Width * Math.Cos(angle))) / 2 + rc.X,
                 (rc.Height - (float)(rc.Height * Math.Cos(angle)) - (float)(rc.Width * Math.Sin(angle))) / 2 + rc.Y);
             g.RotateTransform((float)RotateAngle);
         }
         else
         {
             g.TranslateTransform((float)(this.Left), (float)(this.Top));
         }
         for (int i = 0; i < _items.Count; i++)
         {
             DrawingItem item = _items[i];
             if (item.Visible)
             {
                 item.OnDraw(g);
             }
         }
         g.Restore(gs);
     }
 }
        public override void Copy(DrawingItem obj)
        {
            base.Copy(obj);
            DrawClosedCurve v = obj as DrawClosedCurve;

            if (v != null)
            {
                this.width     = v.width;
                this.fill      = v.fill;
                this.tension   = v.tension;
                this.fillColor = v.fillColor;
                int n = v.PointCount;
                if (n > 0)
                {
                    pts = new Point[n];
                    Point pt;
                    for (int i = 0; i < n; i++)
                    {
                        pt     = v.GetPoint(i);
                        pts[i] = new Point(pt.X, pt.Y);
                    }
                    ArrayToPointList();
                    calculateBrounds();
                }
                else
                {
                    pts = null;
                }
            }
        }
 private void addType(Type tp, bool bHotspotsOnly)
 {
     if (DrawingItem.IsForHotspot(tp) || (!bHotspotsOnly))
     {
         listBox1.Items.Add(tp);
     }
 }
Esempio n. 8
0
 public void SetNewName(DrawingItem item)
 {
     if (item != null)
     {
         item.Name = CreateNewDrawingItemName(item.GetType().Name);
     }
 }
 private void listBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     if (e.Index >= 0 && e.Index < listBox1.Items.Count)
     {
         System.Drawing.Rectangle rc = e.Bounds;
         rc.X = e.Bounds.Left + 2;
         rc.Y = e.Bounds.Top + 2;
         Type  tp  = (Type)listBox1.Items[e.Index];
         Image img = DrawingItem.GetTypeIcon(tp);
         if ((e.State & DrawItemState.Selected) != 0)
         {
             //fill background
             e.Graphics.FillRectangle(m_brushBKSelected, e.Bounds);
             //draw image
             e.Graphics.DrawImage(img, rc.Left, rc.Top);
             //write name
             rc.X = rc.Left + img.Width + 2;
             e.Graphics.DrawString(tp.Name, m_font, m_brushWhite, rc);
         }
         else
         {
             //fill name background
             e.Graphics.FillRectangle(m_brushWhite, e.Bounds);
             //draw image
             e.Graphics.DrawImage(img, rc.Left, rc.Top);
             //write name
             rc.X = rc.Left + img.Width + 2;
             e.Graphics.DrawString(tp.Name, m_font, m_brushBlack, rc);
         }
         //draw name box
         e.Graphics.DrawRectangle(m_penLine, e.Bounds);
     }
 }
Esempio n. 10
0
 public void RemoveDrawing(DrawingItem draw)
 {
     foreach (DrawingLayer l in this)
     {
         l.DeleteDrawingByID(draw.DrawingId);
     }
 }
 public override DrawingItem HitTestChild(Control owner, int x, int y)
 {
     if (_drawItems != null)
     {
         for (int r = 0; r < _drawItems.Length; r++)
         {
             for (int c = 0; c < _drawItems[r].Length; c++)
             {
                 DrawGroupBox dgb = _drawItems[r][c] as DrawGroupBox;
                 if (dgb != null)
                 {
                     DrawingItem di = dgb.HitTestChild(owner, x, y);
                     if (di != null)
                     {
                         return(di);
                     }
                 }
                 if (_drawItems[r][c].HitTest(owner, x, y))
                 {
                     return(_drawItems[r][c]);
                 }
             }
         }
     }
     return(null);
 }
Esempio n. 12
0
 public void DeleteSelectedItem()
 {
     if (selectedDrawing != null)
     {
         DeleteDrawing(selectedDrawing);
         selectedDrawing = null;
     }
 }
 public static dynamic GetTSObject(DrawingItem dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
        public override void Copy(DrawingItem obj)
        {
            base.Copy(obj);
            DrawRect v = obj as DrawRect;

            if (v != null)
            {
            }
        }
Esempio n. 15
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     try
     {
         if (curDrawing != null)
         {
             if (curDrawing.UseMouseMove())
             {
                 if (sHelp.Length > 0)
                 {
                     xH = e.X;
                     yH = e.Y;
                     System.Drawing.Graphics g = this.CreateGraphics();
                     g.DrawString(sHelp, ftHelp, System.Drawing.Brushes.LightGreen, e.X, e.Y);
                     g.Dispose();
                 }
                 float x1, y1;
                 systemToCustomerXY(e.X, e.Y, out x1, out y1);
                 MouseEventArgs e1 = new MouseEventArgs(e.Button, e.Clicks, (int)x1, (int)y1, e.Delta);
                 if (curDrawing.dlgDrawingsMouseMove(this, e1, ref nStep, this))
                 {
                     this.Invalidate();
                 }
             }
             else
             {
                 OnMouseDown(e);
             }
         }
         else
         {
             if (e.Button == System.Windows.Forms.MouseButtons.None)
             {
                 DrawingItem v = HitTest(new Point(e.X, e.Y));
                 if (v != null)
                 {
                     this.Cursor = System.Windows.Forms.Cursors.Hand;
                 }
                 else
                 {
                     this.Cursor = System.Windows.Forms.Cursors.Default;
                 }
             }
             else if ((e.Button & MouseButtons.Left) == System.Windows.Forms.MouseButtons.Left)
             {
                 if (_newObj != null)
                 {
                 }
             }
         }
     }
     catch
     {
     }
 }
Esempio n. 16
0
        public void SelectDrawing(Guid id)
        {
            DrawingItem obj = GetDrawingItemById(id);

            if (obj != null)
            {
                selectedDrawing = obj;
                designer        = selectedDrawing.CreateDesigner();
            }
        }
 private void btOK_Click(object sender, System.EventArgs e)
 {
     if (listBox1.SelectedIndex >= 0)
     {
         Type tp = (Type)listBox1.Items[listBox1.SelectedIndex];
         objRet = (DrawingItem)Activator.CreateInstance(tp);
         objRet.ResetDefaultProperties();
         Close();
     }
 }
        void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            _page.Refresh();
            DrawingItem item = propertyGrid1.SelectedObject as DrawingItem;

            if (item != null)
            {
                item.Refresh();
            }
        }
        void propertyGrid2_SelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e)
        {
            DrawingItem item = e.NewSelection.Value as DrawingItem;

            if (item != null)
            {
                SelectItem(item);
                _page.SetItemSelection(item);
            }
        }
        public override void Copy(DrawingItem obj)
        {
            base.Copy(obj);
            DrawDataRepeater ddp = obj as DrawDataRepeater;

            this.Columns = ddp.Columns;
            this.Rows    = ddp.Rows;
            _gapx        = ddp._gapx;
            _gapy        = ddp._gapy;
        }
Esempio n. 21
0
 public bool ReplaceDrawingItem(DrawingItem item)
 {
     foreach (DrawingLayer l in this)
     {
         if (l.ReplaceDrawingItem(item))
         {
             return(true);
         }
     }
     return(false);
 }
 private void setupDataBind(DrawingItem newDi, DrawingItem di)
 {
     newDi.DataBindings.Clear();
     if (di.DataBindings != null)
     {
         foreach (Binding bd in di.DataBindings)
         {
             newDi.DataBindings.Add(bd.PropertyName, _tbl, bd.BindingMemberInfo.BindingMember, true);
         }
     }
 }
Esempio n. 23
0
 public DrawingItem GetDrawingItemById(Guid id)
 {
     foreach (DrawingLayer l in this)
     {
         DrawingItem item = l.FindDrawingByID(id);
         if (item != null)
         {
             return(item);
         }
     }
     return(null);
 }
Esempio n. 24
0
 public DrawingItem HitTest(Control owner, int x, int y)
 {
     for (int i = this.Count - 1; i >= 0; i--)
     {
         DrawingItem item = this[i].HitTest(owner, x, y);
         if (item != null)
         {
             return(item);
         }
     }
     return(null);
 }
Esempio n. 25
0
 private void lstDrawings_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (frmParent != null)
     {
         if (lstDrawings.SelectedIndex >= 0)
         {
             DrawingItem obj = (DrawingItem)lstDrawings.Items[lstDrawings.SelectedIndex];
             frmParent.SelectDrawing(obj.DrawingId);
             ShowProperties(obj);
         }
     }
 }
Esempio n. 26
0
 public void SetItemSelection(DrawingItem item)
 {
     ClearMarks();
     selectedDrawing            = item;
     selectedDrawing.IsSelected = true;
     if (selectedDrawing.Container != null)
     {
         selectedDrawing.Container.IsSelected = true;
     }
     designer = selectedDrawing.CreateDesigner();
     editor.SelectItem(selectedDrawing);
 }
        /// <summary>
        /// Called when any mouse-move message enters the adorner window of the BehaviorService.
        /// The OnMouseDoubleClick{?} method is called when any mouse-move message enters the WndProc
        /// of the adorner window of the BehaviorService. The message is first passed here,
        /// to the top-most Behavior in the behavior stack. Returning true from this method signifies
        /// that the message was handled by the Behavior and should not continue to be processed.
        /// From here, the message is sent to the appropriate behavior.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="button"></param>
        /// <param name="mouseLoc"></param>
        /// <returns></returns>
        public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc)
        {
            Point p = _behaviorService.AdornerWindowPointToScreen(new Point(mouseLoc.X, mouseLoc.Y));

            p = _page.PointToClient(p);
            _itemUnderMouse = _page.HitTest(p);
            if (_itemUnderMouse != null)
            {
                _page.Cursor = System.Windows.Forms.Cursors.Hand;
            }
            return(false);
        }
        public override void OnLoadedFromXmlFile(DrawingItem obj, IDesignPane designPane, IDrawDesignControl designControl)
        {
            Point p0 = this.Location;

            this.Copy(obj);             //contained objects are cloned in _items
            if (this.Page != null && this.Page.InDesignMode)
            {
                DrawGroupBox dgb = obj as DrawGroupBox;
                if (dgb != null)
                {
                    IList <DrawingItem> lst = dgb.Items;                    //cloned in _items
                    if (lst != null && designPane != null && designControl != null)
                    {
                        //for each object, create a designer control and assign it to the control
                        Control ctrl = designControl as Control;                         //control corresponding to this object
                        foreach (DrawingItem di in lst)
                        {
                            Type     t  = di.GetType();
                            object[] vs = t.GetCustomAttributes(typeof(TypeMappingAttribute), true);
                            if (vs != null && vs.Length > 0)
                            {
                                TypeMappingAttribute tm = vs[0] as TypeMappingAttribute;
                                if (tm != null)
                                {
                                    //create designer control
                                    IComponent         ic  = designPane.CreateComponent(tm.MappedType, di.Name);
                                    IDrawDesignControl idc = ic as IDrawDesignControl;
                                    Control            c   = ic as Control;
                                    DrawingItem        d0  = idc.Item;                             //auto-created object, should be deleted
                                    ctrl.Controls.Add(c);
                                    idc.Item   = GetItemByID(di.DrawingId);                        //use cloned object for the new control
                                    c.Location = di.Location;
                                    if (_items != null)
                                    {
                                        //remove auto-created object d0
                                        for (int i = 0; i < _items.Count; i++)
                                        {
                                            if (d0 == _items[i] || d0.DrawingId == _items[i].DrawingId)
                                            {
                                                _items.RemoveAt(i);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            this.Location = p0;
        }
Esempio n. 29
0
 public void SelectItem(Guid id)
 {
     for (int i = 0; i < lstDrawings.Items.Count; i++)
     {
         DrawingItem obj = (DrawingItem)lstDrawings.Items[i];
         if (obj.DrawingId == id)
         {
             lstDrawings.SelectedIndex = i;
             ShowProperties(obj);
             break;
         }
     }
 }
 public void SelectItem(DrawingItem item)
 {
     propertyGrid1.SelectedObject = item;
     VPLUtil.AdjustImagePropertyAttribute(item);
     if (item != null)
     {
         Text = "Drawing item: " + item.Name;
     }
     else
     {
         Text = "Drawing item:";
     }
     propertyGrid1.Refresh();
 }