/// <summary>
        /// Initializes a new instance of the <see cref="WizardControl"/> class.
        /// </summary>
        public WizardControl()
        {
            pageHistory = new Stack <WizardPage>();

            Pages              = new WizardPageCollection(this);
            Pages.ItemAdded   += Pages_AddItem;
            Pages.ItemDeleted += Pages_RemoveItem;
            Pages.Reset       += Pages_Reset;

            InitializeComponent();
            backButton.CompatibleImageStrip = Properties.Resources.BackBtnStrip;

            if (!Application.RenderWithVisualStyles)
            {
                titleBar.BackColor = System.Drawing.SystemColors.Control;
            }
            titleBar.SetTheme(VisualStyleElementEx.AeroWizard.TitleBar.Active);
            header.SetTheme(VisualStyleElementEx.AeroWizard.HeaderArea.Normal);
            contentArea.SetTheme(VisualStyleElementEx.AeroWizard.ContentArea.Normal);
            commandArea.SetTheme(VisualStyleElementEx.AeroWizard.CommandArea.Normal);

            // Get localized defaults for button text
            ResetBackButtonToolTipText();
            ResetCancelButtonText();
            ResetFinishButtonText();
            ResetNextButtonText();
            ResetTitle();
            ResetTitleIcon();
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WizardPageContainer"/> class.
        /// </summary>
        public WizardPageContainer()
        {
            pageHistory = new Stack <WizardPage>();

            Pages              = new WizardPageCollection(this);
            Pages.ItemAdded   += Pages_AddItem;
            Pages.ItemDeleted += Pages_RemoveItem;
            Pages.Reset       += Pages_Reset;

            OnRightToLeftChanged(EventArgs.Empty);

            // Get localized defaults for button text
            ResetBackButtonText();
            ResetCancelButtonText();
            ResetFinishButtonText();
            ResetNextButtonText();
        }
示例#3
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (myParent == null)
            {
                return;
            }
            int y = Padding.Top;
            WizardPageCollection pages = myParent.Pages;
            bool hit = false;

            for (int i = 0; i < pages.Count; i++)
            {
                var curPage = pages[i];
                if (!curPage.Suppress)
                {
                    Size itemSize = new Size(Width - Padding.Horizontal, defItemHeight);
                    if (OwnerDraw)
                    {
                        var meArg = new MeasureStepListItemEventArgs(e.Graphics, Font, curPage, new Size(Width, defItemHeight));
                        OnMeasureItem(meArg);
                        itemSize = meArg.ItemSize;
                    }
                    if (y + itemSize.Height > (Height - Padding.Bottom))
                    {
                        break;
                    }
                    bool isSelected = myParent.SelectedPage == curPage;
                    if (isSelected)
                    {
                        hit = true;
                    }
                    var eArg = new DrawStepListItemEventArgs(e.Graphics, Font, new Rectangle(new Point(Padding.Left, y), itemSize), curPage, isSelected, hit);
                    if (OwnerDraw)
                    {
                        OnDrawItem(eArg);
                    }
                    else
                    {
                        DefaultDrawItem(eArg);
                    }
                    y += itemSize.Height;
                }
            }
        }
示例#4
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (myParent == null)
            {
                return;
            }

            using (Font ptrFont = new Font("宋体", 9), boldFont = new Font("宋体", 9, FontStyle.Bold))
            {
                int                  itemHeight = (int)Math.Ceiling(TextRenderer.MeasureText(e.Graphics, "Wg", this.Font).Height * 2.0);
                int                  lPad       = 0;// TextRenderer.MeasureText(e.Graphics, "1", ptrFont, new Size(0, itemHeight), TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter | TextFormatFlags.NoPadding).Width;
                const int            rPad       = 0;
                Rectangle            rect       = new Rectangle(lPad, 0, this.Width, itemHeight);
                Rectangle            prect      = new Rectangle(0, 0, lPad, itemHeight);
                WizardPageCollection pages      = myParent.Pages;
                bool                 hit        = false;
                for (int i = 0; i < pages.Count && rect.Y < (this.Height - itemHeight); i++)
                {
                    if (!pages[i].Suppress)
                    {
                        Color fc = this.ForeColor, bc = this.BackColor;
                        bool  isSelected = myParent.SelectedPage == pages[i];
                        int   level      = GetStepTextIndentLevel(pages[i]);
                        prect.X = lPad * level;
                        rect.X  = lPad * (level + 1);
                        if (isSelected)
                        {
                            hit = true;
                            //fc = SystemColors.HighlightText;
                            //bc = SystemColors.Highlight;
                        }
                        else if (!hit)
                        {
                            fc = SystemColors.GrayText;
                        }
                        using (Brush br = new SolidBrush(bc))
                            e.Graphics.FillRectangle(br, Rectangle.Union(rect, prect));
                        //TextRenderer.DrawText(e.Graphics, hit ? "4" : "a", ptrFont, prect, fc, TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter | TextFormatFlags.NoPadding);
                        TextRenderer.DrawText(e.Graphics, GetStepText(pages[i]), isSelected ? boldFont : this.Font, rect, fc, TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);
                        prect.Y = rect.Y += itemHeight;
                    }
                }
            }
        }
示例#5
0
 private void SetupControl(WizardControl p)
 {
     if (myParent != null)
     {
         WizardPageCollection pages = myParent.Pages;
         pages.ItemAdded   -= pages_Changed;
         pages.ItemChanged -= pages_Changed;
         pages.ItemDeleted -= pages_Changed;
     }
     myParent = p;
     if (myParent != null)
     {
         WizardPageCollection pages = myParent.Pages;
         pages.ItemAdded   += pages_Changed;
         pages.ItemChanged += pages_Changed;
         pages.ItemDeleted += pages_Changed;
     }
     Refresh();
 }