Example #1
0
        public object Clone()
        {
            DrawingLayerCollection lc = new DrawingLayerCollection();

            lc._defaultLayerId = _defaultLayerId;
            foreach (DrawingLayer l in this)
            {
                lc.Add((DrawingLayer)l.Clone());
            }
            return(lc);
        }
Example #2
0
        protected override object CreateInstance(Type itemType)
        {
            dlgNewDrawing dlg = new dlgNewDrawing();

            dlg.LoadData(false);
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DrawingLayerCollection ls = this.Context.Instance as DrawingLayerCollection;
                if (ls != null)
                {
                    ls.SetNewName(dlg.objRet);
                    dlg.objRet.Page = (DrawingPage)ls.Page;
                }
                return(dlg.objRet);
            }
            return(null);
        }
Example #3
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            object                 v     = base.EditValue(context, provider, value);
            DrawingLayer           layer = value as DrawingLayer;
            DrawingLayerCollection ls    = context.Instance as DrawingLayerCollection;

            if (layer != null && ls != null)
            {
                foreach (DrawingItem item in layer)
                {
                    item.LayerId = layer.LayerId;
                }
                IDrawingOwnerPointer iw = ls.Page.DesignerPointer;
                if (iw != null)
                {
                    iw.OnDrawingCollectionChanged(layer);
                }
            }
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    Type         t    = edSvc.GetType();
                    PropertyInfo pif0 = t.GetProperty("OwnerGrid");
                    if (pif0 != null)
                    {
                        object       g  = pif0.GetValue(edSvc, null);
                        PropertyGrid pg = g as PropertyGrid;
                        if (pg != null)
                        {
                            pg.Refresh();
                        }
                    }
                }
            }
            return(v);
        }
Example #4
0
 public void LoadData(DrawingLayerCollection layers)
 {
     drawPage.LoadData(layers, true);
 }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (service != null)
                {
                    dlgDrawingBoard dlg = new dlgDrawingBoard();
                    DrawingLayer    lst = value as DrawingLayer;

                    Hotspots     hs   = null;
                    IDrawingPage page = null;
                    hs = context.Instance as Hotspots;
                    if (hs == null)
                    {
                        page = context.Instance as IDrawingPage;
                        if (page != null)
                        {
                            dlg.Attrs = page.PageAttributes;
                        }
                        Control cOwner = context.Instance as Control;
                        if (cOwner != null)
                        {
                            dlg.ImgBK = cOwner.BackgroundImage;
                        }
                        DrawingLayerCollection ls = value as DrawingLayerCollection;
                        dlg.LoadData(ls);
                    }
                    else
                    {
                        lst = (DrawingLayer)hs.Drawings.Clone();
                        dlg.LoadData(hs);
                        hs.clearBK();
                    }

                    try
                    {
                        if (service.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                        {
                            if (hs != null)
                            {
                                value = dlg.lstShapes;
                                hs.InitBK();
                            }
                            else
                            {
                                value = dlg.DrawingLayers;
                                if (page != null)
                                {
                                    page.PageAttributes = dlg.Attrs;
                                }
                            }
                        }
                        else
                        {
                            if (hs != null)
                            {
                                hs.SetDrawings(lst);
                                hs.InitBK();
                            }
                        }
                    }
                    catch (Exception err)
                    {
                        DrawingItem.ShowMessage(err.Message);
                    }
                }
            }
            return(value);
        }