Пример #1
0
        public ControlWrapper GetCandy()
        {
            ControlWrapper cw = new ControlWrapper();

            cw.Protect(new BoardLabel());
            return(cw);
        }
Пример #2
0
 /// <summary>Initializes a new instance of the <see cref="PluginModel" /> class.</summary>
 /// <param name="pluginType">The plug-in type.</param>
 /// <param name="instanceAllowance">The instance allowance.</param>
 /// <param name="pluginName">Name of the plug-in.</param>
 /// <param name="controlWrapper">The control wrapper.</param>
 public PluginModel(Type pluginType, InstanceAllowance instanceAllowance, string pluginName, ControlWrapper controlWrapper)
 {
     PluginType = pluginType;
     PluginInstanceAllowance = instanceAllowance;
     PluginName           = pluginName;
     PluginControlWrapper = controlWrapper;
 }
Пример #3
0
        public ControlWrapper GetCandy()
        {
            ControlWrapper cw    = new ControlWrapper();
            BoardImage     image = new BoardImage();

            cw.Protect(image);
            return(cw);
        }
Пример #4
0
        public ControlWrapper GetCandy()
        {
            ControlWrapper   cw = new ControlWrapper();
            BoardMediaPlayer p  = new BoardMediaPlayer();

            cw.Protect(p);
            return(cw);
        }
Пример #5
0
        public ControlWrapper GetCandy()
        {
            ControlWrapper cw    = new ControlWrapper();
            DesignerChart  dc    = new DesignerChart();
            BoardChart     chart = new BoardChart(dc);

            cw.Protect(chart);
            return(cw);
        }
Пример #6
0
 /// <summary>Gets the collection of plug-ins of a specified type.</summary>
 /// <param name="view">The type of plug-ins to return.</param>
 /// <returns>A collection of plug-ins.</returns>
 public IEnumerable <T> this[ControlWrapper view]
 {
     get
     {
         return(view == ControlWrapper.LayoutAnchorable
             ? Items.Where(p => GetPluginControlWrapper(p) == ControlWrapper.LayoutAnchorable).ToList()
             : Items.Where(p => GetPluginControlWrapper(p) == ControlWrapper.LayoutDocument).ToList());
     }
 }
Пример #7
0
        private void AddControl(Control ctrl, Control parent)
        {
            if (parent is PropertyGrid)
            {
                return;
            }
            ControlWrapper wrap = new ControlWrapper();

            m_ctrls[ctrl] = wrap;
            wrap.ctrl     = ctrl;
            wrap.varname  = "ctrl" + m_ctrls.Count.ToString();
            wrap.parent   = parent;
            string parexpr = null;

            if (parent == m_rootWindow)
            {
                parexpr = "root";
            }
            else if (parent is Form && m_openedWindows.ContainsKey((Form)parent))
            {
                parexpr = m_openedWindows[(Form)parent];
            }
            else
            {
                parexpr = m_ctrls[parent].varname;
            }
            bool processed = false;

            if (parent is SplitContainer)
            {
                if (ctrl == ((SplitContainer)parent).Panel1)
                {
                    wrap.vardef = String.Format("    {0} = {1}.Panel1\n", wrap.varname, parexpr);
                }
                else
                {
                    wrap.vardef = String.Format("    {0} = {1}.Panel2\n", wrap.varname, parexpr);
                }
                processed = true;
            }
            if (parent is TabControl && ctrl is TabPage)
            {
                TabPage    page = (TabPage)ctrl;
                TabControl tabs = (TabControl)parent;
                if (String.IsNullOrEmpty(page.Name))
                {
                    wrap.vardef = String.Format("    {0} = {1}.TabPages[{2}]\n", wrap.varname, parexpr, tabs.TabPages.IndexOf(page));
                    processed   = true;
                }
            }
            if (!processed)
            {
                wrap.vardef = String.Format("    {0} = {1}.Controls['{2}']\n", wrap.varname, parexpr, ctrl.Name);
            }
            RegisterControlHooks(ctrl);
        }
Пример #8
0
    public void SetControl <TControl>(TControl control)
        where TControl : System.Windows.Forms.Control
    {
        ControlWrapper prevLink = Link;

        if (prevLink != null)
        {
            prevLink.Dispose();
        }
        _link = new ControlWrapper <TControl>(this, control);
    }
        /// <summary>
        /// Checks if the object is of type window
        /// If not it creates a wrapper window
        /// </summary>
        /// <param name="instance">The instance of the object to check</param>
        /// <returns>Returns a window instance</returns>
        public static Window VerifyObjectType(object instance)
        {
            Window returnValue = instance as Window;
            //return the value if it is alread a window
            if (returnValue != null)
                return returnValue;

            //wrap the control in a window and return it
            ControlWrapper wrapper = new ControlWrapper(instance);
            return wrapper;
        }
Пример #10
0
        public ControlWrapper GetCandy()
        {
            ControlWrapper cw = new ControlWrapper();
            DesignerTable  tb = new DesignerTable();

            tb.Size.Width  = 400;
            tb.Size.Height = 300;
            BoardDataGrid bf = new BoardDataGrid(tb);

            cw.Protect(bf);
            return(cw);
        }
Пример #11
0
    { public ControlWrapper GetCandy()
      {
          ControlWrapper     cw = new ControlWrapper();
          DesignerProcessbar pb = new DesignerProcessbar();

          pb.Size.Width  = 200;
          pb.Size.Height = 50;
          BoardProcessbar bf = new BoardProcessbar(pb);

          cw.Protect(bf);
          return(cw);
      }
Пример #12
0
 private void WantControlVar(ControlWrapper wrap)
 {
     if (!wrap.isvar)
     {
         bool isform = wrap.parent is Form && m_openedWindows.ContainsKey((Form)wrap.parent);
         if (wrap.parent != m_rootWindow && !isform)
         {
             WantControlVar(m_ctrls[wrap.parent]);
         }
         AddCommand(wrap.vardef);
         wrap.isvar = true;
     }
 }
Пример #13
0
        public ControlWrapper GetCandy()
        {
            ControlWrapper       cw = new ControlWrapper();
            DesignerDynamicLabel dg = new DesignerDynamicLabel();

            dg.Size.Width  = 150;
            dg.Size.Height = 50;
            dg.Text        = "动态文本";
            BoardDynamicLabel bf = new BoardDynamicLabel(dg);

            cw.Protect(bf);
            return(cw);
        }
Пример #14
0
        public ControlWrapper GetCandy()
        {
            ControlWrapper cw    = new ControlWrapper();
            DesignerClock  clock = new DesignerClock();

            clock.Size.Width  = 200;
            clock.Size.Height = 50;

            BoardClock bf = new BoardClock(clock);

            cw.Protect(bf);
            return(cw);
        }
        /// <summary>Gets the <see cref="IEnumerable{FrameworkElementPluginViewModel}"/> with the specified control wrapper.</summary>
        /// <param name="controlWrapper">The control wrapper.</param>
        /// <returns>A collection of plug-in view models that have the specified control wrapper.</returns>
        public IEnumerable <FrameworkElementPluginViewModel> this[ControlWrapper controlWrapper]
        {
            get
            {
                List <FrameworkElementPluginViewModel> frameworkElementPluginViewModels =
                    Items
                    .Where(viewModel => viewModel.Model.PluginControlWrapper == controlWrapper)
                    .ToList();

                // return both types of view models that have the appropriate control wrapper type
                return(frameworkElementPluginViewModels);
            }
        }
Пример #16
0
        public ControlWrapper GetCandy()
        {
            ControlWrapper cw = new ControlWrapper();
            DesignerGif    dg = new DesignerGif();

            dg.Size.Width     = 200;
            dg.Size.Height    = 200;
            dg.GIFImageSource = "GifDemo.gif";
            dg.AutoPlay       = true;

            BoardGif bf = new BoardGif(dg);

            cw.Protect(bf);
            return(cw);
        }
Пример #17
0
        /// <summary>
        /// Checks if the object is of type window
        /// If not it creates a wrapper window
        /// </summary>
        /// <param name="instance">The instance of the object to check</param>
        /// <returns>Returns a window instance</returns>
        public static Window VerifyObjectType(object instance)
        {
            Window returnValue = instance as Window;

            //return the value if it is alread a window
            if (returnValue != null)
            {
                return(returnValue);
            }

            //wrap the control in a window and return it
            ControlWrapper wrapper = new ControlWrapper(instance);

            return(wrapper);
        }
Пример #18
0
        private void PopulateContentTypeDD(SPWeb web)
        {
            cbContentTypes.Items.Clear();

            SPContentTypeCollection types = web.ContentTypes;

            foreach (SPContentType ct in types)
            {
                ctDD = new ControlWrapper <SPContentType>(ct.Name, ct);
                cbContentTypes.Items.Add(ctDD);
            }
            if (types.Count > 0)
            {
                cbContentTypes.SelectedIndex = 0;
            }
        }
Пример #19
0
        private void PopulateSCDD(SPWeb web)
        {
            cbSiteCols.Items.Clear();

            SPFieldCollection scs = web.Fields;

            foreach (SPField sc in scs)
            {
                scDD = new ControlWrapper <SPField>(sc.Title, sc);
                cbSiteCols.Items.Add(scDD);
            }

            if (scs.Count > 0)
            {
                cbSiteCols.SelectedIndex = 0;
            }
        }
Пример #20
0
        private string GetControlExpression(Control ctrl, bool wantVar)
        {
            if (ctrl == m_rootWindow)
            {
                return("root");
            }
            if (ctrl is Form && m_openedWindows.ContainsKey((Form)ctrl))
            {
                return(m_openedWindows[(Form)ctrl]);
            }
            ControlWrapper wrap = m_ctrls[ctrl];

            if (wantVar)
            {
                WantControlVar(wrap);
            }
            return(wrap.varname);
        }
Пример #21
0
    static void Main()
    {
        var model = new ControlWrapper {
            Controls =
            {
                new ControlDto {
                    Type      = ControlType.LinkLabel,
                    Caption   = "This is LinkLabel's text",
                    LocationX = 170, LocationY = 40
                }, new  ControlDto{
                    Type      = ControlType.Label,
                    Caption   = "This is Label's text",
                    LocationX = 170, LocationY = 50
                }
            }
        };
        var ser = new XmlSerializer(typeof(ControlWrapper));

        ser.Serialize(Console.Out, model);
    }
Пример #22
0
        public bool RemoveChild(PropertiesNode child, bool ignoreInspector)
        {
            if (OnRemoveChild != null)
            {
                var resultRemove = OnRemoveChild(child.GetControl());
                if (!resultRemove)
                {
                    MessageBox.Show("CantRemoveItemFromParent", "FailToRemoveParent",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            if (child.ControlWrapper != null)
            {
                child.ControlWrapper.Parent = null;

                if (ControlWrapper != null)
                {
                    ControlWrapper.AlignControls();
                }
                else
                {
                    var alignmentProvider = _control as IAlignment;
                    if (alignmentProvider != null)
                    {
                        alignmentProvider.AlignControls();
                    }
                }
                return(true);
            }
            if (!ignoreInspector)
            {
                MessageBox.Show("Element can't be removed from inspector tree itself", "Can't delete element",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return(false);
            }
            return(true);
        }
Пример #23
0
        /// <summary>Loads the plug-ins.</summary>
        /// <returns>A collection of the PluginModel's describing each plug-in.</returns>
        /// <exception cref="PluginException">An error occurred attempting to retrieve the plug-in assembly names.</exception>
        /// <exception cref="PluginException">An error occurred attempting to load the plug-in assembly types.</exception>
        /// <exception cref="PluginException">An error occurred attempting to build a plug-in model for type [type].</exception>
        public PluginModelCollection LoadPlugins()
        {
            IReadOnlyList <PluginLocation> plugins = PluginReader.ReadPluginDirectory();
            PluginTypeCollection           pluginTypeCollection = PluginReader.LoadPluginAssemblyTypes(plugins);

            PluginModelCollection pluginModelCollection = new PluginModelCollection();

            if (pluginTypeCollection == null || pluginTypeCollection.Count == 0)
            {
                return(pluginModelCollection);
            }

            foreach (Type type in pluginTypeCollection)
            {
                try
                {
                    PluginInstanceAllowanceAttribute pluginInstanceAllowanceAttribute = type.GetCustomAttribute <PluginInstanceAllowanceAttribute>();
                    PluginNameAttribute     pluginNameAttribute           = type.GetCustomAttribute <PluginNameAttribute>();
                    ControlWrapperAttribute pluginControlWrapperAttribute = type.GetCustomAttribute <ControlWrapperAttribute>();

                    ControlWrapper    pluginControlWrapper    = pluginControlWrapperAttribute?.ControlWrapper ?? ControlWrapper.LayoutAnchorable;
                    InstanceAllowance pluginInstanceAllowance = pluginInstanceAllowanceAttribute?.InstanceAllowance ?? InstanceAllowance.Single;
                    string            pluginName = pluginNameAttribute?.PluginName ?? type.Name;

                    // double check to make sure the PluginName wasn't set to "" or string.Empty
                    if (string.IsNullOrWhiteSpace(pluginName))
                    {
                        pluginName = type.Name;
                    }

                    pluginModelCollection.Add(new PluginModel(type, pluginInstanceAllowance, pluginName, pluginControlWrapper));
                }
                catch (Exception ex)
                {
                    throw new PluginException(FormattableString.Invariant($"An error occurred attempting to build a plug-in model for type {type}."), ex);
                }
            }

            return(pluginModelCollection);
        }
Пример #24
0
        protected override void OnDrop(DragEventArgs e)
        {
            base.OnDrop(e);
            string controlName = e.Data.GetData("NewItem") as string;

            if (!String.IsNullOrEmpty(controlName))
            {
                try
                {
                    ControlWrapper wrapper = BoardControlFactory.CreateCandyByName(controlName);
                    object         candy   = wrapper.Tear();
                    if (candy != null)
                    {
                        Point location = e.GetPosition(this);
                        AddDesignerItem(candy, location);
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message); }


                e.Handled = true;
            }
        }
 /// <summary>Initializes a new instance of the <see cref="ControlWrapperAttribute"/> class.</summary>
 /// <param name="controlWrapper">The control wrapper.</param>
 public ControlWrapperAttribute(ControlWrapper controlWrapper)
 {
     ControlWrapper = controlWrapper;
 }
Пример #26
0
        private void AddToolStripItem(ToolStripItem item, string childsCollection, MenuWrapper parent, ControlWrapper cparent)
        {
            MenuWrapper wrap = new MenuWrapper();

            m_menus[item] = wrap;
            wrap.varname  = "menu" + m_menus.Count.ToString();
            wrap.item     = item;
            wrap.parent   = parent;
            wrap.cparent  = cparent;
            wrap.vardef   = String.Format("    {0} = {1}['{2}']\n", wrap.varname, childsCollection, item.Name);

            int childCount = 0;

            if (item is ToolStripMenuItem)
            {
                ToolStripMenuItem obj = (ToolStripMenuItem)item;
                foreach (ToolStripItem child in obj.DropDownItems)
                {
                    childCount++;
                    AddToolStripItem(child, wrap.varname + ".DropDownItems", wrap, null);
                }
            }
            if (childCount == 0)
            {
                wrap.hasevent = true;
                item.Click   += new EventHandler(ToolStripItem_Click);
            }
        }