Exemplo n.º 1
0
        public HistoryControl()
        {
            UI.InitScaling(this);
            this.itemHeight = UI.ScaleHeight(16);

            SetStyle(ControlStyles.StandardDoubleClick, false);

            InitializeComponent();
        }
Exemplo n.º 2
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            int ulX = (this.ClientRectangle.Width - UI.ScaleWidth(this.DefaultSize.Width)) / 2;
            int ulY = (this.ClientRectangle.Height - UI.ScaleHeight(this.DefaultSize.Height)) / 2;

            this.primaryColorRectangle.Location   = new System.Drawing.Point(UI.ScaleWidth(ulX + 2), UI.ScaleHeight(ulY + 2));
            this.secondaryColorRectangle.Location = new System.Drawing.Point(UI.ScaleWidth(ulX + 18), UI.ScaleHeight(ulY + 18));
            this.swapIconBox.Location             = new System.Drawing.Point(UI.ScaleWidth(ulX + 30), UI.ScaleHeight(ulY + 2));
            this.blackAndWhiteIconBox.Location    = new System.Drawing.Point(UI.ScaleWidth(ulX + 2), UI.ScaleHeight(ulY + 31));

            base.OnLayout(levent);
        }
Exemplo n.º 3
0
        public ImageListMenu()
        {
            UI.InitScaling(this);
            InitializeComponent();

            this.imageXInset     = UI.ScaleWidth(2);
            this.imageYInset     = UI.ScaleHeight(4);
            this.textLeftMargin  = UI.ScaleWidth(4);
            this.textRightMargin = UI.ScaleWidth(16);
            this.textVMargin     = UI.ScaleHeight(2);

            this.stringFormat = (StringFormat)StringFormat.GenericTypographic.Clone();
        }
Exemplo n.º 4
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            int leftMargin                     = UI.ScaleWidth(8);
            int rightMargin                    = UI.ScaleWidth(8);
            int topMargin                      = UI.ScaleHeight(8);
            int bottomMargin                   = UI.ScaleHeight(8);
            int afterInfoLabelVMargin          = UI.ScaleHeight(8);
            int afterDocumentListHeaderVMargin = UI.ScaleHeight(8);
            int afterDocumentListVMargin       = UI.ScaleHeight(8);
            int commandLinkVMargin             = UI.ScaleHeight(8);
            int insetWidth                     = ClientSize.Width - leftMargin - rightMargin;

            int y = topMargin;

            this.infoLabel.Location = new Point(leftMargin, y);
            this.infoLabel.Width    = insetWidth;
            this.infoLabel.Height   = this.infoLabel.GetPreferredSize(new Size(this.infoLabel.Width, 0)).Height;
            y += this.infoLabel.Height + afterInfoLabelVMargin;

            this.documentListHeader.Location = new Point(leftMargin, y);
            this.documentListHeader.Width    = insetWidth;
            y += this.documentListHeader.Height + afterDocumentListHeaderVMargin;

            this.documentStrip.Location = new Point(leftMargin, y);
            this.documentStrip.Size     = new Size(insetWidth, UI.ScaleHeight(72));
            this.hScrollBar.Location    = new Point(leftMargin, this.documentStrip.Bottom);
            this.hScrollBar.Width       = insetWidth;
            y += this.documentStrip.Height + hScrollBar.Height + afterDocumentListVMargin;

            this.saveButton.Location = new Point(leftMargin, y);
            this.saveButton.Width    = insetWidth;
            this.saveButton.PerformLayout();
            y += this.saveButton.Height + commandLinkVMargin;

            this.dontSaveButton.Location = new Point(leftMargin, y);
            this.dontSaveButton.Width    = insetWidth;
            this.dontSaveButton.PerformLayout();
            y += this.dontSaveButton.Height + commandLinkVMargin;

            this.cancelButton.Location = new Point(leftMargin, y);
            this.cancelButton.Width    = insetWidth;
            this.cancelButton.PerformLayout();
            y += this.cancelButton.Height + commandLinkVMargin;

            this.ClientSize = new Size(ClientSize.Width, y);
            base.OnLayout(levent);
        }
Exemplo n.º 5
0
        private RectangleF GetOurRectangle()
        {
            PointF[] ptFs = new PointF[1] {
                this.Location
            };
            this.transform.TransformPoints(ptFs);
            float ratio = (float)Math.Ceiling(1.0 / OwnerList.ScaleFactor.Ratio);

            float ourWidth  = UI.ScaleWidth(this.Size.Width);
            float ourHeight = UI.ScaleHeight(this.Size.Height);

            if (!Single.IsNaN(ratio))
            {
                RectangleF rectF = new RectangleF(ptFs[0], new SizeF(0, 0));
                rectF.Inflate(ratio * ourWidth, ratio * ourHeight);
                return(rectF);
            }
            else
            {
                return(RectangleF.Empty);
            }
        }
Exemplo n.º 6
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            int leftMargin            = UI.ScaleWidth(8);
            int rightMargin           = UI.ScaleWidth(8);
            int topMargin             = UI.ScaleHeight(8);
            int bottomMargin          = UI.ScaleHeight(8);
            int buttonHMargin         = UI.ScaleWidth(7);
            int afterIntroTextVMargin = UI.ScaleHeight(16);
            int afterHeaderVMargin    = UI.ScaleHeight(3);
            int hMargin    = UI.ScaleWidth(7);
            int vMargin    = UI.ScaleHeight(7);
            int insetWidth = ClientSize.Width - leftMargin - rightMargin;

            this.introText.Location = new Point(leftMargin, topMargin);
            this.introText.Width    = insetWidth;
            this.introText.Height   = this.introText.GetPreferredSize(this.introText.Size).Height;

            this.defaultToolText.Location = new Point(
                leftMargin,
                this.introText.Bottom + afterIntroTextVMargin);

            this.toolChooserStrip.Location = new Point(
                this.defaultToolText.Right + hMargin,
                this.defaultToolText.Top + (this.defaultToolText.Height - this.toolChooserStrip.Height) / 2);

            int y             = vMargin + Math.Max(this.defaultToolText.Bottom, this.toolChooserStrip.Bottom);
            int maxInsetWidth = insetWidth;

            foreach (ToolConfigRow toolConfigRow in this.toolConfigRows)
            {
                if (!string.IsNullOrEmpty(toolConfigRow.HeaderLabel.Text))
                {
                    toolConfigRow.HeaderLabel.Location = new Point(leftMargin, y);
                    toolConfigRow.HeaderLabel.Width    = insetWidth;
                    y = toolConfigRow.HeaderLabel.Bottom + afterHeaderVMargin;
                }

                toolConfigRow.ToolConfigStrip.Location = new Point(leftMargin + 3, y);
                Size preferredSize = toolConfigRow.ToolConfigStrip.GetPreferredSize(
                    new Size(maxInsetWidth, 1));

                toolConfigRow.ToolConfigStrip.Size = preferredSize;

                maxInsetWidth = Math.Max(maxInsetWidth, toolConfigRow.ToolConfigStrip.Width);

                y = toolConfigRow.ToolConfigStrip.Bottom + vMargin;
            }

            y += vMargin;

            this.bottomSeparator.Location = new Point(leftMargin, y);
            this.bottomSeparator.Width    = insetWidth;
            this.bottomSeparator.Visible  = false;

            y += this.bottomSeparator.Height;

            this.cancelButton.Location = new Point(ClientSize.Width - rightMargin - this.cancelButton.Width, y);

            this.saveButton.Location = new Point(
                this.cancelButton.Left - buttonHMargin - this.saveButton.Width,
                this.cancelButton.Top);

            this.resetButton.Location = new Point(leftMargin, this.saveButton.Top);

            this.loadFromToolBarButton.Location = new Point(this.resetButton.Right + buttonHMargin, this.resetButton.Top);

            y = this.resetButton.Bottom + bottomMargin;

            this.ClientSize = new Size(leftMargin + maxInsetWidth + rightMargin, y);

            if (IsHandleCreated && maxInsetWidth > insetWidth)
            {
                BeginInvoke(new Procedure(PerformLayout), null);
            }

            base.OnLayout(levent);
        }
Exemplo n.º 7
0
            protected override void OnLayout(LayoutEventArgs levent)
            {
                int leftMargin                 = UI.ScaleWidth(8);
                int rightMargin                = UI.ScaleWidth(8);
                int topMargin                  = UI.ScaleHeight(8);
                int bottomMargin               = UI.ScaleHeight(8);
                int imageToIntroHMargin        = UI.ScaleWidth(8);
                int topSectionToLinksVMargin   = UI.ScaleHeight(8);
                int commandButtonVMargin       = UI.ScaleHeight(0);
                int afterCommandButtonsVMargin = UI.ScaleHeight(8);
                int insetWidth                 = ClientSize.Width - leftMargin - rightMargin;

                if (this.taskImagePB.Image == null)
                {
                    this.taskImagePB.Location = new Point(0, topMargin);
                    this.taskImagePB.Size     = new Size(0, 0);
                    this.taskImagePB.Visible  = false;
                }
                else
                {
                    this.taskImagePB.Location = new Point(leftMargin, topMargin);

                    if (this.scaleTaskImageWithDpi)
                    {
                        this.taskImagePB.Size = UI.ScaleSize(this.taskImagePB.Image.Size);
                    }
                    else
                    {
                        this.taskImagePB.Size = this.taskImagePB.Image.Size;
                    }

                    this.taskImagePB.Visible = true;
                }

                this.introTextLabel.Location = new Point(this.taskImagePB.Right + imageToIntroHMargin, this.taskImagePB.Top);
                this.introTextLabel.Width    = ClientSize.Width - this.introTextLabel.Left - rightMargin;
                this.introTextLabel.Height   = this.introTextLabel.GetPreferredSize(new Size(this.introTextLabel.Width, 1)).Height;

                int y = Math.Max(this.taskImagePB.Bottom, this.introTextLabel.Bottom);

                y += topSectionToLinksVMargin;

                if (!string.IsNullOrEmpty(this.auxButton.Text))
                {
                    this.auxButton.Visible  = true;
                    this.auxButton.Location = new Point(leftMargin, y);
                    this.auxButton.PerformLayout();
                    y += this.auxButton.Height;
                    y += topSectionToLinksVMargin;
                }
                else
                {
                    this.auxButton.Visible = false;
                }

                if (this.commandButtons != null)
                {
                    this.separator.Location = new Point(leftMargin, y);
                    this.separator.Width    = insetWidth;
                    y += this.separator.Height;

                    for (int i = 0; i < this.commandButtons.Length; ++i)
                    {
                        this.commandButtons[i].Location = new Point(leftMargin, y);
                        this.commandButtons[i].Width    = insetWidth;
                        this.commandButtons[i].PerformLayout();
                        y += this.commandButtons[i].Height + commandButtonVMargin;
                    }

                    y += afterCommandButtonsVMargin;
                }

                this.ClientSize = new Size(ClientSize.Width, y);
                base.OnLayout(levent);
            }
Exemplo n.º 8
0
        private Size MeasureAndDraw(Graphics g, bool enableDrawing, PushButtonState state, bool drawFocusCues, bool drawKeyboardCues)
        {
            if (enableDrawing)
            {
                g.PixelOffsetMode   = PixelOffsetMode.Half;
                g.CompositingMode   = CompositingMode.SourceOver;
                g.InterpolationMode = InterpolationMode.Bilinear;
            }

            int marginX       = UI.ScaleWidth(9);
            int marginYTop    = UI.ScaleHeight(8);
            int marginYBottom = UI.ScaleHeight(9);
            int paddingX      = UI.ScaleWidth(8);
            int paddingY      = UI.ScaleHeight(3);
            int offsetX       = 0;
            int offsetY       = 0;

            bool drawAsDefault = (state == PushButtonState.Default);

            if (enableDrawing)
            {
                using (Brush backBrush = new SolidBrush(this.BackColor))
                {
                    CompositingMode oldCM = g.CompositingMode;
                    g.CompositingMode = CompositingMode.SourceCopy;
                    g.FillRectangle(backBrush, ClientRectangle);
                    g.CompositingMode = oldCM;
                }

                Rectangle ourRect = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);

                if (state == PushButtonState.Pressed)
                {
                    offsetX = 1;
                    offsetY = 1;
                }

                UI.DrawCommandButton(g, state, ourRect, BackColor, this);
            }

            Rectangle actionImageRect;

            Brush textBrush = new SolidBrush(SystemColors.WindowText);

            if (this.actionImage == null)
            {
                actionImageRect = new Rectangle(offsetX, offsetY + marginYTop, 0, 0);
            }
            else
            {
                actionImageRect = new Rectangle(offsetX + marginX, offsetY + marginYTop,
                                                UI.ScaleWidth(this.actionImage.Width), UI.ScaleHeight(this.actionImage.Height));

                Rectangle srcRect = new Rectangle(0, 0, this.actionImage.Width, this.actionImage.Height);

                if (enableDrawing)
                {
                    Image drawMe = Enabled ? this.actionImage : this.actionImageDisabled;

                    if (Enabled)
                    {
                        actionImageRect.Y += 3;
                        actionImageRect.X += 1;
                        g.DrawImage(this.actionImageDisabled, actionImageRect, srcRect, GraphicsUnit.Pixel);
                        actionImageRect.X -= 1;
                        actionImageRect.Y -= 3;
                    }

                    actionImageRect.Y += 2;
                    g.DrawImage(drawMe, actionImageRect, srcRect, GraphicsUnit.Pixel);
                    actionImageRect.Y -= 2;
                }
            }

            int actionTextX     = actionImageRect.Right + paddingX;
            int actionTextY     = actionImageRect.Top;
            int actionTextWidth = ClientSize.Width - actionTextX - marginX + offsetX;

            StringFormat stringFormat = (StringFormat)StringFormat.GenericTypographic.Clone();

            stringFormat.HotkeyPrefix = drawKeyboardCues ? HotkeyPrefix.Show : HotkeyPrefix.Hide;

            SizeF actionTextSize = g.MeasureString(this.actionText, this.actionTextFont, actionTextWidth, stringFormat);

            Rectangle actionTextRect = new Rectangle(actionTextX, actionTextY,
                                                     actionTextWidth, (int)Math.Ceiling(actionTextSize.Height));

            if (enableDrawing)
            {
                if (state == PushButtonState.Disabled)
                {
                    ControlPaint.DrawStringDisabled(g, this.actionText, this.actionTextFont, this.BackColor, actionTextRect, stringFormat);
                }
                else
                {
                    g.DrawString(this.actionText, this.actionTextFont, textBrush, actionTextRect, stringFormat);
                }
            }

            int descriptionTextX     = actionTextX;
            int descriptionTextY     = actionTextRect.Bottom + paddingY;
            int descriptionTextWidth = actionTextWidth;

            SizeF descriptionTextSize = g.MeasureString(this.explanationText, this.explanationTextFont,
                                                        descriptionTextWidth, stringFormat);

            Rectangle descriptionTextRect = new Rectangle(descriptionTextX, descriptionTextY,
                                                          descriptionTextWidth, (int)Math.Ceiling(descriptionTextSize.Height));

            if (enableDrawing)
            {
                if (state == PushButtonState.Disabled)
                {
                    ControlPaint.DrawStringDisabled(g, this.explanationText, this.explanationTextFont, this.BackColor, descriptionTextRect, stringFormat);
                }
                else
                {
                    g.DrawString(this.explanationText, this.explanationTextFont, textBrush, descriptionTextRect, stringFormat);
                }
            }

            if (enableDrawing)
            {
                if (drawFocusCues)
                {
                    ControlPaint.DrawFocusRectangle(g, new Rectangle(3, 3, ClientSize.Width - 5, ClientSize.Height - 5));
                }
            }

            if (textBrush != null)
            {
                textBrush.Dispose();
            }

            stringFormat.Dispose();
            Size layoutSize = new Size(ClientSize.Width, descriptionTextRect.Bottom + marginYBottom);

            return(layoutSize);
        }
Exemplo n.º 9
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            // Bottom-right Buttons
            int buttonsBottomMargin = UI.ScaleHeight(8);
            int buttonsRightMargin  = UI.ScaleWidth(8);
            int buttonsHMargin      = UI.ScaleWidth(8);

            this.baseCancelButton.Location = new Point(
                ClientSize.Width - this.baseOkButton.Width - buttonsRightMargin,
                ClientSize.Height - buttonsBottomMargin - this.baseCancelButton.Height);

            this.baseOkButton.Location = new Point(
                this.baseCancelButton.Left - buttonsHMargin - this.baseOkButton.Width,
                ClientSize.Height - buttonsBottomMargin - this.baseOkButton.Height);

            int previewBottomMargin = UI.ScaleHeight(8);

            // Set up layout properties
            int topMargin               = UI.ScaleHeight(6);
            int leftMargin              = UI.ScaleWidth(8);
            int leftColumWidth          = UI.ScaleWidth(200);
            int columHMargin            = UI.ScaleWidth(8);
            int rightMargin             = UI.ScaleWidth(8);
            int vMargin                 = UI.ScaleHeight(4);
            int rightColumnX            = leftMargin + leftColumWidth + columHMargin;
            int rightColumnWidth        = ClientSize.Width - rightColumnX - rightMargin;
            int defaultsButtonTopMargin = UI.ScaleHeight(12);
            int headerXAdjustment       = -3;

            // Left column
            this.settingsHeader.Location = new Point(leftMargin + headerXAdjustment, topMargin);
            this.settingsHeader.Width    = leftColumWidth - headerXAdjustment;
            this.settingsHeader.PerformLayout();

            this.saveConfigPanel.Location = new Point(leftMargin, this.settingsHeader.Bottom + vMargin);
            this.saveConfigPanel.Width    = leftColumWidth;
            this.saveConfigPanel.PerformLayout();

            //this.saveConfigWidget.Location = new Point(0, 0);
            this.saveConfigWidget.Width = this.saveConfigPanel.Width - SystemInformation.VerticalScrollBarWidth;

            // Right column
            this.previewHeader.Location = new Point(rightColumnX + headerXAdjustment, topMargin);
            this.previewHeader.Width    = rightColumnWidth - headerXAdjustment;
            this.previewHeader.PerformLayout();

            this.documentView.Location = new Point(rightColumnX, this.previewHeader.Bottom + vMargin);
            this.documentView.Size     = new Size(
                rightColumnWidth,
                this.baseCancelButton.Top - previewBottomMargin - this.documentView.Top);

            // Finish up setting the height on the left side
            this.saveConfigPanel.Height = this.documentView.Bottom - this.saveConfigPanel.Top -
                                          this.defaultsButton.Height - defaultsButtonTopMargin;

            this.saveConfigWidget.PerformLayout();

            int saveConfigHeight = Math.Min(this.saveConfigPanel.Height, this.saveConfigWidget.Height);

            this.defaultsButton.PerformLayout();

            this.defaultsButton.Location = new Point(
                leftMargin + (leftColumWidth - this.defaultsButton.Width) / 2,
                this.saveConfigPanel.Top + saveConfigHeight + defaultsButtonTopMargin);

            MinimumSize = UI.ScaleSize(unscaledMinSize);

            base.OnLayout(levent);
        }