Exemple #1
0
        public void Initialize()
        {
            Text          = _language.Title;
            okButton.Text = _languageGeneral.OK;
            string[] versionInfo       = Utilities.AssemblyVersion.Split('.');
            string   minorMinorVersion = string.Empty;

            if (versionInfo.Length >= 3 && versionInfo[2] != "0")
            {
                minorMinorVersion = "." + versionInfo[2];
            }
            labelProduct.Text                      = String.Format("{0} {1}.{2}{3}, build", _languageGeneral.Title, versionInfo[0], versionInfo[1], minorMinorVersion);
            linkLabelGitBuildHash.Left             = labelProduct.Left + labelProduct.Width - 5;
            linkLabelGitBuildHash.LinkColor        = Color.FromArgb(0, 102, 204);
            linkLabelGitBuildHash.VisitedLinkColor = Color.FromArgb(0, 102, 204);

            string revisionNumber = "0";

            if (versionInfo.Length >= 4)
            {
                revisionNumber = versionInfo[3];
            }
            linkLabelGitBuildHash.Text = revisionNumber;
            var toolTip1 = new ToolTip();

            toolTip1.SetToolTip(linkLabelGitBuildHash, GetGitHubHashLink());

            richTextBoxAbout1.Text = _language.AboutText1.TrimEnd() + Environment.NewLine +
                                     Environment.NewLine +
                                     _languageGeneral.TranslatedBy.Trim();
            double height = TextDraw.MeasureTextHeight(richTextBoxAbout1.Font, richTextBoxAbout1.Text, false) * 1.4 + 80;

            richTextBoxAbout1.Height = (int)height;
            Height = richTextBoxAbout1.Top + richTextBoxAbout1.Height + 90;
        }
Exemple #2
0
        public void Initialize()
        {
            Text          = _language.Title + " - " + (IntPtr.Size * 8) + "-bit";
            okButton.Text = _languageGeneral.Ok;
            string[] versionInfo    = Utilities.AssemblyVersion.Split('.');
            string   revisionNumber = "0";

            if (versionInfo.Length >= 4)
            {
                revisionNumber = versionInfo[3];
            }
            if (revisionNumber == "0")
            {
                labelProduct.Text = String.Format("{0} {1}.{2}.{3}, ", _languageGeneral.Title, versionInfo[0], versionInfo[1], versionInfo[2]);
                revisionNumber    = Utilities.AssemblyDescription.Substring(0, 7);
            }
            else
            {
                labelProduct.Text = String.Format("{0} {1}.{2}.{3}, build", _languageGeneral.Title, versionInfo[0], versionInfo[1], versionInfo[2]);
            }
            linkLabelGitBuildHash.Left             = labelProduct.Left + labelProduct.Width - 5;
            linkLabelGitBuildHash.LinkColor        = Color.FromArgb(0, 102, 204);
            linkLabelGitBuildHash.VisitedLinkColor = Color.FromArgb(0, 102, 204);
            linkLabelGitBuildHash.Text             = revisionNumber;
            var toolTip1 = new ToolTip();

            toolTip1.SetToolTip(linkLabelGitBuildHash, GetGitHubHashLink());

            string aboutText = _language.AboutText1.TrimEnd() + Environment.NewLine +
                               Environment.NewLine +
                               _languageGeneral.TranslatedBy.Trim();

            while (aboutText.Contains("\n ") || aboutText.Contains("\n\t"))
            {
                aboutText = aboutText.Replace("\n ", "\n");
                aboutText = aboutText.Replace("\n\t", "\n");
            }
            richTextBoxAbout1.Text = aboutText;

            double height = TextDraw.MeasureTextHeight(richTextBoxAbout1.Font, richTextBoxAbout1.Text, false) * 1.4 + 80;

            richTextBoxAbout1.Height = (int)height;
            Height = richTextBoxAbout1.Top + richTextBoxAbout1.Height + 90;
        }
Exemple #3
0
        public void Initialize()
        {
            Text          = _language.Title;
            okButton.Text = _languageGeneral.OK;
            string[] versionInfo       = Utilities.AssemblyVersion.Split('.');
            string   minorMinorVersion = string.Empty;

            if (versionInfo.Length >= 3 && versionInfo[2] != "0")
            {
                minorMinorVersion = "." + versionInfo[2];
            }
            labelProduct.Text      = String.Format("{0} {1}.{2}{3} rev.{4}", _languageGeneral.Title, versionInfo[0], versionInfo[1], minorMinorVersion, versionInfo[3]);
            richTextBoxAbout1.Text = _language.AboutText1.TrimEnd() + Environment.NewLine +
                                     Environment.NewLine +
                                     _languageGeneral.TranslatedBy.Trim();
            var height = TextDraw.MeasureTextHeight(richTextBoxAbout1.Font, richTextBoxAbout1.Text, false) * 1.4 + 80;

            richTextBoxAbout1.Height = (int)height;
            Height = richTextBoxAbout1.Top + richTextBoxAbout1.Height + 90;
        }
        private void GeneratePreviewReal()
        {
            if (listViewStyles.SelectedItems.Count != 1)
            {
                return;
            }

            if (pictureBoxPreview.Image != null)
            {
                pictureBoxPreview.Image.Dispose();
            }
            var bmp = new Bitmap(pictureBoxPreview.Width, pictureBoxPreview.Height);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                // Draw background
                const int rectangleSize = 9;
                for (int y = 0; y < bmp.Height; y += rectangleSize)
                {
                    for (int x = 0; x < bmp.Width; x += rectangleSize)
                    {
                        Color c = Color.DarkGray;
                        if (y % (rectangleSize * 2) == 0)
                        {
                            if (x % (rectangleSize * 2) == 0)
                            {
                                c = Color.LightGray;
                            }
                        }
                        else
                        {
                            if (x % (rectangleSize * 2) != 0)
                            {
                                c = Color.LightGray;
                            }
                        }
                        g.FillRectangle(new SolidBrush(c), x, y, rectangleSize, rectangleSize);
                    }
                }

                // Draw text
                Font font;
                try
                {
                    double fontSize = 20;
                    if (Utilities.IsInteger(textBoxFontSize.Text.Replace("px", string.Empty)))
                    {
                        fontSize = Convert.ToInt32(textBoxFontSize.Text.Replace("px", string.Empty));
                    }
                    else if (textBoxFontSize.Text.EndsWith('%'))
                    {
                        int num;
                        if (int.TryParse(textBoxFontSize.Text.TrimEnd('%'), out num))
                        {
                            fontSize = fontSize * num / 100.0;
                        }
                    }
                    font = new Font(comboBoxFontName.Text, (float)fontSize);
                }
                catch
                {
                    font = new Font(Font, FontStyle.Regular);
                }
                g.TextRenderingHint = TextRenderingHint.AntiAlias;
                g.SmoothingMode     = SmoothingMode.AntiAlias;
                var sf = new StringFormat {
                    Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near
                };
                var path = new GraphicsPath();

                bool newLine = false;
                var  sb      = new StringBuilder();
                sb.Append("This is a test!");

                var measuredWidth  = TextDraw.MeasureTextWidth(font, sb.ToString(), comboBoxFontWeight.Text == "bold") + 1;
                var measuredHeight = TextDraw.MeasureTextHeight(font, sb.ToString(), comboBoxFontWeight.Text == "bold") + 1;

                float left = 5;
                //if (radioButtonTopLeft.Checked || radioButtonMiddleLeft.Checked || radioButtonBottomLeft.Checked)
                //    left = (float)numericUpDownMarginLeft.Value;
                //else if (radioButtonTopRight.Checked || radioButtonMiddleRight.Checked || radioButtonBottomRight.Checked)
                //    left = bmp.Width - (measuredWidth + ((float)numericUpDownMarginRight.Value));
                //else
                //    left = ((float)(bmp.Width - measuredWidth * 0.8 + 15) / 2);

                float top = 2;
                //if (radioButtonTopLeft.Checked || radioButtonTopCenter.Checked || radioButtonTopRight.Checked)
                //    top = (float)numericUpDownMarginVertical.Value;
                //else if (radioButtonMiddleLeft.Checked || radioButtonMiddleCenter.Checked || radioButtonMiddleRight.Checked)
                //    top = (bmp.Height - measuredHeight) / 2;
                //else
                //    top = bmp.Height - measuredHeight - ((int)numericUpDownMarginVertical.Value);

                int leftMargin      = 0;
                int pathPointsStart = -1;

                //if (radioButtonOpaqueBox.Checked)
                //{
                //    if (_isSubStationAlpha)
                //        g.FillRectangle(new SolidBrush(panelBackColor.BackColor), left, top, measuredWidth + 3, measuredHeight + 3);
                //    else
                //        g.FillRectangle(new SolidBrush(panelOutlineColor.BackColor), left, top, measuredWidth + 3, measuredHeight + 3);
                //}

                TextDraw.DrawText(font, sf, path, sb, comboBoxFontStyle.Text == "italic", comboBoxFontWeight.Text == "bold", false, left, top, ref newLine, leftMargin, ref pathPointsStart);

                int outline = 0; // (int)numericUpDownOutline.Value;

                if (outline > 0)
                {
                    Color outlineColor = Color.White;
                    g.DrawPath(new Pen(outlineColor, outline), path);
                }
                g.FillPath(new SolidBrush(panelFontColor.BackColor), path);
            }
            pictureBoxPreview.Image = bmp;
        }
        protected override void GeneratePreviewReal()
        {
            pictureBoxPreview.Image?.Dispose();

            var bmp = new Bitmap(pictureBoxPreview.Width, pictureBoxPreview.Height);

            using (var g = Graphics.FromImage(bmp))
            {
                // Draw background
                const int rectangleSize = 9;
                for (int y = 0; y < bmp.Height; y += rectangleSize)
                {
                    for (int x = 0; x < bmp.Width; x += rectangleSize)
                    {
                        var c = Color.WhiteSmoke;
                        if (y % (rectangleSize * 2) == 0)
                        {
                            if (x % (rectangleSize * 2) == 0)
                            {
                                c = Color.LightGray;
                            }
                        }
                        else
                        {
                            if (x % (rectangleSize * 2) != 0)
                            {
                                c = Color.LightGray;
                            }
                        }

                        using (var brush = new SolidBrush(c))
                        {
                            g.FillRectangle(brush, x, y, rectangleSize, rectangleSize);
                        }
                    }
                }

                // Draw text
                Font font;
                try
                {
                    font = new Font(comboBoxFontName.Text, (float)numericUpDownFontSize.Value);
                }
                catch
                {
                    font = new Font(Font, FontStyle.Regular);
                }
                g.TextRenderingHint = TextRenderingHint.AntiAlias;
                g.SmoothingMode     = SmoothingMode.AntiAlias;
                var sf = new StringFormat {
                    Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near
                };
                var path = new GraphicsPath();

                bool newLine = false;
                var  sb      = new StringBuilder();
                sb.Append(Configuration.Settings.General.PreviewAssaText);

                var measuredWidth  = TextDraw.MeasureTextWidth(font, sb.ToString(), checkBoxFontBold.Checked) + 1;
                var measuredHeight = TextDraw.MeasureTextHeight(font, sb.ToString(), checkBoxFontBold.Checked) + 1;

                float left;
                if (radioButtonTopLeft.Checked || radioButtonMiddleLeft.Checked || radioButtonBottomLeft.Checked)
                {
                    left = (float)numericUpDownMarginLeft.Value;
                }
                else if (radioButtonTopRight.Checked || radioButtonMiddleRight.Checked || radioButtonBottomRight.Checked)
                {
                    left = bmp.Width - (measuredWidth + ((float)numericUpDownMarginRight.Value));
                }
                else
                {
                    left = (bmp.Width - measuredWidth) / 2;
                }

                float top;
                if (radioButtonTopLeft.Checked || radioButtonTopCenter.Checked || radioButtonTopRight.Checked)
                {
                    top = (float)numericUpDownMarginVertical.Value;
                }
                else if (radioButtonMiddleLeft.Checked || radioButtonMiddleCenter.Checked || radioButtonMiddleRight.Checked)
                {
                    top = (bmp.Height - measuredHeight) / 2;
                }
                else
                {
                    top = bmp.Height - measuredHeight - ((int)numericUpDownMarginVertical.Value);
                }

                top -= (int)numericUpDownShadowWidth.Value;
                if (radioButtonTopCenter.Checked || radioButtonMiddleCenter.Checked || radioButtonBottomCenter.Checked)
                {
                    left -= (int)(numericUpDownShadowWidth.Value / 2);
                }

                const int leftMargin      = 0;
                int       pathPointsStart = -1;

                if (radioButtonOpaqueBox.Checked)
                {
                    using (var brush = new SolidBrush(_isSubStationAlpha ? panelBackColor.BackColor : panelOutlineColor.BackColor))
                    {
                        g.FillRectangle(brush, left, top, measuredWidth + 3, measuredHeight + 3);
                    }
                }

                TextDraw.DrawText(font, sf, path, sb, checkBoxFontItalic.Checked, checkBoxFontBold.Checked, checkBoxFontUnderline.Checked, left, top, ref newLine, leftMargin, ref pathPointsStart);

                int outline = (int)numericUpDownOutline.Value;

                // draw shadow
                if (numericUpDownShadowWidth.Value > 0 && radioButtonOutline.Checked)
                {
                    using (var shadowPath = (GraphicsPath)path.Clone())
                        using (var p1 = new Pen(Color.FromArgb(250, panelBackColor.BackColor), outline))
                        {
                            for (int i = 0; i < (int)numericUpDownShadowWidth.Value; i++)
                            {
                                var translateMatrix = new Matrix();
                                translateMatrix.Translate(1, 1);
                                shadowPath.Transform(translateMatrix);
                                g.DrawPath(p1, shadowPath);
                            }
                        }
                }

                if (outline > 0 && radioButtonOutline.Checked)
                {
                    using (var pen = new Pen(_isSubStationAlpha ? panelBackColor.BackColor : panelOutlineColor.BackColor))
                    {
                        g.DrawPath(pen, path);
                    }
                }

                using (var brush = new SolidBrush(panelPrimaryColor.BackColor))
                {
                    g.FillPath(brush, path);
                }

                font.Dispose();
            }
            pictureBoxPreview.Image = bmp;
        }
Exemple #6
0
        private void DrawText(string text, Graphics g, Bitmap bmp, ComboBox comboboxfontName, decimal fontSize, CheckBox checkBoxFontBold, RadioButton radioButtonAlignTop, CheckBox checkBoxFontItalic, CheckBox checkBoxFontUnderline, Color fontColor, Color backColor)
        {
            Font font;

            try
            {
                font = new Font(comboboxfontName.Text, (float)fontSize);
            }
            catch
            {
                font = new Font(Font, FontStyle.Regular);
            }
            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            g.SmoothingMode     = SmoothingMode.AntiAlias;
            var sf = new StringFormat {
                Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near
            };
            var path = new GraphicsPath();

            bool newLine = false;
            var  sb      = new StringBuilder();

            sb.Append(text);

            var measuredWidth  = TextDraw.MeasureTextWidth(font, sb.ToString(), checkBoxFontBold.Checked) + 1;
            var measuredHeight = TextDraw.MeasureTextHeight(font, sb.ToString(), checkBoxFontBold.Checked) + 1;

            //if (radioButtonTopLeft.Checked || radioButtonMiddleLeft.Checked || radioButtonBottomLeft.Checked)
            //    left = (float)numericUpDownMarginLeft.Value;
            //else if (radioButtonTopRight.Checked || radioButtonMiddleRight.Checked || radioButtonBottomRight.Checked)
            //    left = bmp.Width - (measuredWidth + ((float)numericUpDownMarginRight.Value));
            //else
            float left = ((float)(bmp.Width - measuredWidth * 0.8 + 15) / 2);

            float top;

            if (radioButtonAlignTop.Checked)
            {
                top = 10;
            }
            //else if (radioButtonMiddleLeft.Checked || radioButtonMiddleCenter.Checked || radioButtonMiddleRight.Checked)
            //    top = (bmp.Height - measuredHeight) / 2;
            else
            {
                top = bmp.Height - measuredHeight - 10;
            }
            //top -= (int)numericUpDownShadowWidth.Value;
            //if (radioButtonTopCenter.Checked || radioButtonMiddleCenter.Checked || radioButtonBottomCenter.Checked)
            //    left -= (int)(numericUpDownShadowWidth.Value / 2);

            const int leftMargin      = 0;
            int       pathPointsStart = -1;

            //if (false) //radioButtonOpaqueBox.Checked)
            //{
            //    g.FillRectangle(new SolidBrush(backColor), left, top, measuredWidth + 3, measuredHeight + 3);
            //}

            TextDraw.DrawText(font, sf, path, sb, checkBoxFontItalic.Checked, checkBoxFontBold.Checked, checkBoxFontUnderline.Checked, left, top, ref newLine, leftMargin, ref pathPointsStart);

            var outline = (int)numericUpDownOutline1.Value;

            // draw shadow
            if (numericUpDownShadowWidth1.Value > 0) // && radioButtonOutline1.Checked)
            {
                var shadowPath = (GraphicsPath)path.Clone();
                for (int i = 0; i < (int)numericUpDownShadowWidth1.Value; i++)
                {
                    var translateMatrix = new Matrix();
                    translateMatrix.Translate(1, 1);
                    shadowPath.Transform(translateMatrix);

                    using (var p1 = new Pen(Color.FromArgb(250, Color.Black), outline)) //(()) panelBackColor.BackColor), outline);
                        g.DrawPath(p1, shadowPath);
                }
            }

            if (outline > 0)
            {
                g.DrawPath(new Pen(backColor, outline), path);
            }
            g.FillPath(new SolidBrush(fontColor), path);
        }