コード例 #1
0
ファイル: Label.cs プロジェクト: Givemebuff/WPFBoardDesigner
        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
ファイル: Image.cs プロジェクト: Givemebuff/WPFBoardDesigner
        public ControlWrapper GetCandy()
        {
            ControlWrapper cw    = new ControlWrapper();
            BoardImage     image = new BoardImage();

            cw.Protect(image);
            return(cw);
        }
コード例 #4
0
ファイル: Video.cs プロジェクト: Givemebuff/WPFBoardDesigner
        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
ファイル: MacroRecorder.cs プロジェクト: janproch/datadmin
        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);
    }
コード例 #9
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;
        }
コード例 #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
ファイル: MacroRecorder.cs プロジェクト: janproch/datadmin
 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
ファイル: Clock.cs プロジェクト: Givemebuff/WPFBoardDesigner
        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);
        }
コード例 #15
0
        /// <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
ファイル: MacroRecorder.cs プロジェクト: janproch/datadmin
        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;
            }
        }
コード例 #25
0
 /// <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
ファイル: MacroRecorder.cs プロジェクト: janproch/datadmin
        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);
            }
        }