コード例 #1
0
        private void RemovePage(object sender, EventArgs ea)
        {
            IDesignerHost _dh = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (_dh != null)
            {
                DesignerTransaction _dt = _dh.CreateTransaction("Removed page");

                MultiPanelPage _page = m_mpanel.SelectedPage;

                if (_page != null)
                {
                    MultiPanelPage _ytp = m_mpanel.SelectedPage;
                    m_mpanel.Controls.Remove(_ytp);
                    _dh.DestroyComponent(_ytp);

                    if (m_mpanel.Controls.Count > 0)
                    {
                        m_mpanel.SelectedPage = (MultiPanelPage)m_mpanel.Controls[0];
                    }
                    else
                    {
                        m_mpanel.SelectedPage = null;
                    }

                    RaiseComponentChanging(TypeDescriptor.GetProperties(Control)["SelectedPage"]);
                    RaiseComponentChanged(TypeDescriptor.GetProperties(Control)["SelectedPage"], _ytp, m_mpanel.SelectedPage);
                }

                _dt.Commit();
            }
        }
コード例 #2
0
 /// <summary>
 /// Overridden. Inherited from <see cref="ControlDesigner.Initialize( IComponent )"/>.
 /// </summary>
 /// <param name="component">
 /// The <see cref="IComponent"/> hosted by the designer.
 /// </param>
 public override void Initialize(IComponent component)
 {
     _page = component as MultiPanelPage;
     if (_page == null)
         DisplayError(new Exception("You attempted to use a MultiPanelPageDesigner with a class that does not inherit from MultiPanelPage."));
     base.Initialize(component);
 }
コード例 #3
0
        /// <summary>
        /// Event handler for the "Remove Tab" verb.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="ea">
        /// Some <see cref="EventArgs"/>.
        /// </param>
        private void RemovePage()
        {
            IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (dh != null)
            {
                DesignerTransaction dt = dh.CreateTransaction("Removed page");

                MultiPanelPage page = multiPanel.SelectedPage;
                if (page != null)
                {
                    MultiPanelPage ytp = multiPanel.SelectedPage;
                    multiPanel.Controls.Remove(ytp);
                    dh.DestroyComponent(ytp);

                    if (multiPanel.Controls.Count > 0)
                    {
                        multiPanel.SelectedPage = (MultiPanelPage)multiPanel.Controls[0];
                    }
                    else
                    {
                        multiPanel.SelectedPage = null;
                    }

                    //RaiseComponentChanging(TypeDescriptor.GetProperties(Control)["SelectedPage"]);
                    //RaiseComponentChanged(TypeDescriptor.GetProperties(Control)["SelectedPage"], ytp, multiPanel.SelectedPage);
                }

                dt.Commit();
            }
        }
コード例 #4
0
        /// <summary>
        /// Event handler for the "Remove Tab" verb.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// Some <see cref="EventArgs"/>.
        /// </param>
        private void RemovePage(object sender, EventArgs e)
        {
            IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (dh != null)
            {
                DesignerTransaction dt   = dh.CreateTransaction("Removed page");
                MultiPanelPage      page = _mpanel.SelectedPage;
                if (page != null)
                {
                    MultiPanelPage multiPanelPage = _mpanel.SelectedPage;
                    _mpanel.Controls.Remove(multiPanelPage);
                    dh.DestroyComponent(multiPanelPage);
                    if (_mpanel.Controls.Count > 0)
                    {
                        _mpanel.SelectedPage = (MultiPanelPage)_mpanel.Controls[0];
                    }
                    else
                    {
                        _mpanel.SelectedPage = null;
                    }
                    RaiseComponentChanging(TypeDescriptor.GetProperties(Control)["SelectedPage"]);
                    RaiseComponentChanged(TypeDescriptor.GetProperties(Control)["SelectedPage"], multiPanelPage, _mpanel.SelectedPage);
                }
                dt.Commit();
            }
        }
コード例 #5
0
        /// <summary>
        /// Event handler for the "Select X page" handler.
        /// </summary>
        /// <param name="panel"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        private static void SelectPage(IDesignerHost dh, MultiPanel panel, MultiPanelPage page)
        {
            DesignerTransaction dt = dh.CreateTransaction("Selected page");
            MultiPanelPage oldSelectedPage = panel.SelectedPage;

            panel.SelectedPage = page;
            dt.Commit();
        }
コード例 #6
0
        /// <summary>
        /// Event handler for the "Select X page" handler.
        /// </summary>
        /// <param name="panel"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        private static void SelectPage(IDesignerHost dh, MultiPanel panel, MultiPanelPage page)
        {
            DesignerTransaction dt = dh.CreateTransaction("Selected page");
            MultiPanelPage      oldSelectedPage = panel.SelectedPage;

            panel.SelectedPage = page;
            dt.Commit();
        }
コード例 #7
0
        public override void Initialize(IComponent component)
        {
            m_page = component as MultiPanelPage;

            if (m_page == null)
            {
                DisplayError(new Exception("You attempted to use a MultiPanelPageDesigner with a class that does not inherit from MultiPanelPage."));
            }

            base.Initialize(component);
        }
コード例 #8
0
        /// <summary>
        /// Overridden. Initializes the component.
        /// </summary>
        /// <param name="component">The <see cref="IComponent"/> hosted by the designer.</param>
        public override void Initialize(IComponent component)
        {
            // Should not happen.
            m_page = component as MultiPanelPage;
            if (m_page == null)
            {
                DisplayError(
                    new InvalidOperationException(
                        "You attempted to use a MultiPanelPageDesigner with a class that does not inherit from MultiPanelPage."));
            }

            base.Initialize(component);
        }
コード例 #9
0
        /// <summary>
        /// </summary>
        public ControlCollection(Control owner)
            : base(owner)
        {
            if (owner == null || owner.GetType() != typeof(MultiPanelPage))
            {
                throw new ArgumentNullException("owner", "Tried to create a MultiPanelPage.ControlCollection with a null owner.");
            }
            MultiPanelPage c = owner as MultiPanelPage;

            if (c == null)
            {
                throw new ArgumentException("Tried to create a MultiPanelPage.ControlCollection with a non-MultiPanelPage owner.", "owner");
            }
        }
コード例 #10
0
        /// <summary>
        /// </summary>
        public override void Add(Control value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value", "Tried to add a null value to the MultiPanelPage.ControlCollection.");
            }
            MultiPanelPage p = value as MultiPanelPage;

            if (p != null)
            {
                throw new ArgumentException("Tried to add a MultiPanelPage control to the MultiPanelPage.ControlCollection.", "value");
            }
            base.Add(value);
        }
コード例 #11
0
    public override void Add(Control value)
    {
        if (value == null)
        {
            throw new ArgumentNullException("value", "Tried to add a null value to the MultiPanelPagesCollection.");
        }
        MultiPanelPage p = value as MultiPanelPage;

        if (p == null)
        {
            throw new ArgumentException("Tried to add a non-MultiPanelPage control to the MultiPanelPagesCollection", "value");
        }
        p.SendToBack();
        base.Add(p);
    }
コード例 #12
0
        private string FormatColumnValue(string colName)
        {
            colName = SQLiteParser.Utils.QuoteIfNeeded(colName);

            MultiPanelPage page = pnlValues.SelectedPage;

            if (page == pnlBlobValue)
            {
                return(colName + " = x'" + txtBlob.Text.Trim() + "'");
            }
            else if (page == pnlBooleanValue)
            {
                return(colName + " = " + (rbtnTrue.Checked ? "1" : "0"));
            }
            else if (page == pnlDateTimeValue)
            {
                DateTime dt = new DateTime(dtpDate.Value.Year, dtpDate.Value.Month, dtpDate.Value.Day);
                return("DATE(" + colName + ") = DATE('" + SQLiteParser.Utils.GetDateTimeLiteralString(dt, false) + "')");
            }
            else if (page == pnlFloatingPoint)
            {
                string colname          = (string)cboColumnName.SelectedItem;
                SQLiteColumnStatement c = Utils.GetColumnByName(_columns, colname);
                if (Utils.GetDbType(c.ColumnType) == DbType.Double)
                {
                    double dval = (double)numFloatingPoint.Value;
                    return(colName + " = " + dval.ToString());
                }
                else
                {
                    float fval = (float)numFloatingPoint.Value;
                    return(colName + " = " + fval.ToString());
                }
            }
            else if (page == pnlGuidValue)
            {
                return(colName + " = " + "X'" + txtGuid.Text.Replace("-", string.Empty) + "'");
            }
            else if (page == pnlIntegerValue)
            {
                return(colName + " = " + numIntValue.Value.ToString());
            }
            else if (page == pnlTextValue)
            {
                return(colName + " = " + SQLiteParser.Utils.QuoteLiteralString(txtFieldValue.Text));
            }
            throw new InvalidOperationException();
        }
コード例 #13
0
ファイル: MultiPanelDesigner.cs プロジェクト: henrikja/EVEMon
        /// <summary>
        /// Occurs when the service's selection changes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnServiceSelectionChanged(object sender, EventArgs e)
        {
            ISelectionService service = (ISelectionService)GetService(typeof(ISelectionService));

            if (service?.PrimarySelection == null)
            {
                return;
            }

            MultiPanelPage page = GetMultiPanelPage((Control)service.PrimarySelection);

            if (page != null)
            {
                m_panel.SelectedPage = page;
            }
        }
コード例 #14
0
        /// <summary>
        /// Gets the collection of verbs displayed in the top right menu of the designer.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="panel"></param>
        /// <returns></returns>
        public static DesignerVerbCollection GetDesignerVerbs(IDesignerHost host, MultiPanel panel)
        {
            DesignerVerbCollection verbs = new DesignerVerbCollection
            {
                new DesignerVerb("Add Page", (sender, args) => AddPage(host, panel)),
                new DesignerVerb("Remove Page", (sender, args) => RemovePage(host, panel))
            };

            foreach (MultiPanelPage page in panel.Controls)
            {
                MultiPanelPage pageCopy = page;
                verbs.Add(new DesignerVerb("Select \"" + page.Text + "\"", (sender, args) => SelectPage(host, panel, pageCopy)));
            }

            return(verbs);
        }
コード例 #15
0
        private void s_SelectionChanged(object sender, EventArgs e)
        {
            ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService));

            if (s != null)
            {
                if (s.PrimarySelection != null)
                {
                    MultiPanelPage page = GetMultiPanelPage((Control)s.PrimarySelection);
                    if (page != null)
                    {
                        _mpanel.SelectedPage = page;
                    }
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// Event handler for the "Remove Tab" verb.
        /// </summary>
        /// <param name="dh"></param>
        /// <param name="panel"></param>
        private static void RemovePage(IDesignerHost dh, MultiPanel panel)
        {
            MultiPanelPage page = panel.SelectedPage;

            if (page == null)
            {
                return;
            }

            DesignerTransaction dt = dh.CreateTransaction("Removed page");

            panel.Controls.Remove(page);
            dh.DestroyComponent(page);

            panel.SelectedPage = panel.Controls.Count > 0 ? (MultiPanelPage)panel.Controls[0] : null;

            dt.Commit();
        }
コード例 #17
0
        /// <summary>
        /// Event handler for the "Add Page" verb.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// Some <see cref="EventArgs"/>.
        /// </param>
        private void AddPage(object sender, EventArgs e)
        {
            IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (dh != null)
            {
                DesignerTransaction dt        = dh.CreateTransaction("Added new page");
                MultiPanelPage      before    = _mpanel.SelectedPage;
                string         name           = GetNewPageName();
                MultiPanelPage multiPanelPage = dh.CreateComponent(typeof(MultiPanelPage), name) as MultiPanelPage;
                multiPanelPage.Text = name;
                _mpanel.Controls.Add(multiPanelPage);
                _mpanel.SelectedPage = multiPanelPage;
                RaiseComponentChanging(TypeDescriptor.GetProperties(Control)["SelectedPage"]);
                RaiseComponentChanged(TypeDescriptor.GetProperties(Control)["SelectedPage"], before, multiPanelPage);
                dt.Commit();
            }
        }
コード例 #18
0
        /// <summary>
        /// When we switch panels, we update the "next", "previous" and "cancel" buttons.
        /// </summary>
        /// <param name="newPage">The page selected.</param>
        private void UpdateButtons(MultiPanelPage newPage)
        {
            bool nextPrev = false;

            if (newPage == CredentialsPage)
            {
                StartServer();
            }
            else
            {
                nextPrev        = true;
                ButtonNext.Text = m_updateMode ? "&Update" : "&Import";
                ButtonNext.Focus();
            }
            ButtonPrevious.Visible = nextPrev;
            ButtonPrevious.Enabled = nextPrev;
            ButtonNext.Visible     = nextPrev;
            ButtonNext.Enabled     = nextPrev;
            Throbber.State         = ThrobberState.Stopped;
            Throbber.Visible       = false;
        }
コード例 #19
0
ファイル: MultiPanelDesigner.cs プロジェクト: henrikja/EVEMon
        /// <summary>
        /// Return the page hosting the provided control, or the control itself it it is a page. If the matching page is not bound to this represented panel, returns null.
        /// </summary>
        /// <param name="ctrl"></param>
        /// <returns></returns>
        private MultiPanelPage GetMultiPanelPage(Control ctrl)
        {
            while (true)
            {
                // If the control is a page, return it if the parent is the represented panel, null otherwise.
                MultiPanelPage page = ctrl as MultiPanelPage;

                if (page != null)
                {
                    return(ReferenceEquals(m_panel, page.Parent) ? page : null);
                }

                // If the control has a parent, browser its ancestry
                if (ctrl.Parent == null)
                {
                    return(null);
                }

                ctrl = ctrl.Parent;
            }
        }
コード例 #20
0
        /// <summary>
        /// Return the page hosting the provided control, or the control itself it it is a page. If the matching page is not bound to this represented panel, returns null.
        /// </summary>
        /// <param name="ctrl"></param>
        /// <returns></returns>
        private MultiPanelPage GetMultiPanelPage(Control ctrl)
        {
            // If the control is a page, return it if the parent is the represented panel, null otherwise.
            if (ctrl is MultiPanelPage)
            {
                MultiPanelPage page = (MultiPanelPage)ctrl;
                if (Object.ReferenceEquals(m_panel, page.Parent))
                {
                    return(page);
                }
                return(null);
            }

            // If the control has a parent, browser its ancestry
            if (ctrl.Parent != null)
            {
                return(GetMultiPanelPage(ctrl.Parent));
            }

            return(null);
        }
コード例 #21
0
 private MultiPanelPage GetMultiPanelPage(Control ctrl)
 {
     if (ctrl is MultiPanelPage)
     {
         MultiPanelPage p = (MultiPanelPage)ctrl;
         if (object.ReferenceEquals(_mpanel, p.Parent))
         {
             return(p);
         }
         else
         {
             return(null);
         }
     }
     else if (ctrl.Parent != null)
     {
         return(GetMultiPanelPage(ctrl.Parent));
     }
     else
     {
         return(null);
     }
 }
コード例 #22
0
        private void AddPage(object sender, EventArgs ea)
        {
            IDesignerHost _dh = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (_dh != null)
            {
                DesignerTransaction _dt = _dh.CreateTransaction("Added new page");

                MultiPanelPage _before = m_mpanel.SelectedPage;

                string         _name = GetNewPageName();
                MultiPanelPage _ytp  = _dh.CreateComponent(typeof(MultiPanelPage), _name) as MultiPanelPage;
                _ytp.Text = _name;

                m_mpanel.Controls.Add(_ytp);
                m_mpanel.SelectedPage = _ytp;

                RaiseComponentChanging(TypeDescriptor.GetProperties(Control)["SelectedPage"]);
                RaiseComponentChanged(TypeDescriptor.GetProperties(Control)["SelectedPage"], _before, _ytp);

                _dt.Commit();
            }
        }
コード例 #23
0
        private MultiPanelPage GetMultiPanelPage(Control ctrl)
        {
            if (ctrl is MultiPanelPage)
            {
                MultiPanelPage _p = (MultiPanelPage)ctrl;

                if (ReferenceEquals(m_mpanel, _p.Parent))
                {
                    return(_p);
                }
                else
                {
                    return(null);
                }
            }
            else if (ctrl.Parent != null)
            {
                return(GetMultiPanelPage(ctrl.Parent));
            }
            else
            {
                return(null);
            }
        }