Beispiel #1
0
 protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e)
 {
     if (e.HasPropertyChanged(() => SelectedColumn))
     {
         SetColorPickers();
     }
     else if (e.HasPropertyChanged(() => Grid))
     {
         SetColorPickers();
     }
     else if (e.HasPropertyChanged(() => ForeColor))
     {
         if (Columns.FirstOrDefault(x => x.Name == SelectedColumn.Name) != null)
         {
             var column = Columns.First(x => x.Name == SelectedColumn.Name);
             column.IsChangedColor = !ForeColor.Equals(column.ForeColor);
             column.ForeColor      = ForeColor;
         }
         SelectedColumn.ForeColor = ForeColor;
     }
     else if (e.HasPropertyChanged(() => BackColor))
     {
         if (Columns.FirstOrDefault(x => x.Name == SelectedColumn.Name) != null)
         {
             var column = Columns.First(x => x.Name == SelectedColumn.Name);
             column.IsChangedColor = !BackColor.Equals(column.BackColor);
             column.BackColor      = BackColor;
         }
         SelectedColumn.BackColor = BackColor;
     }
     base.OnPropertyChanged(e);
 }
        protected override void OnForeColorChanged(EventArgs e)
        {
            String colorName = String.Empty, rgb, tooltip;

            if (ForeColor.ToKnownColor() != 0)
            {
                colorName = ForeColor.ToKnownColor().ToString();
            }
            else if (ForeColor.IsNamedColor)
            {
                colorName = ForeColor.ToString();
            }

            rgb = String.Format("R={0}; G={1}; B={2}", ForeColor.R, ForeColor.G, ForeColor.B);

            if (colorName.Length > 0)
            {
                tooltip = String.Format("{0} ({1})", colorName, rgb);
            }
            else
            {
                tooltip = rgb;
            }

            _toolTip.SetToolTip(this, tooltip);

            base.OnForeColorChanged(e);
        }
        public void DrawGrid(Graphics g, PointF translation, float scale)
        {
            Settings set = Settings.Get <Settings>();
            float    r   = (float)(set.Read(Settings.TABLE, Settings.DIAMETER, 20f) * scale);

            Color color = ForeColor.GetStepColor(BackColor, 0.5);

            using (Pen p = new Pen(color, 2))
            {
                g.DrawLine(p, new PointF(translation.X, translation.Y - r), new PointF(translation.X, translation.Y + r));
                g.DrawLine(p, new PointF(translation.X - r, translation.Y), new PointF(translation.X + r, translation.Y));
            }

            using (Pen p = new Pen(color, 1))
            {
                for (float x = 10 * scale; x < r; x += 10 * scale)
                {
                    g.DrawLine(p, new PointF(translation.X - x, translation.Y - r), new PointF(translation.X - x, translation.Y + r));
                    g.DrawLine(p, new PointF(translation.X + x, translation.Y - r), new PointF(translation.X + x, translation.Y + r));

                    g.DrawLine(p, new PointF(translation.X - r, translation.Y - x), new PointF(translation.X + r, translation.Y - x));
                    g.DrawLine(p, new PointF(translation.X - r, translation.Y + x), new PointF(translation.X + r, translation.Y + x));
                }
            }
        }
Beispiel #4
0
        protected override void PreRendering(Graphics targetGraphics)
        {
            base.PreRendering(targetGraphics);
            float angle  = (ValueAsFloat - 1 / 4f) * (float)Math.PI * 2,
                  width  = Width,
                  height = Height,
                  size   = Math.Min(Width, Height),
                  cx     = width / 2,
                  cy     = height / 2,
                  pw     = size * .08f,
                  pw2    = pw / 2f;

            targetGraphics.DrawLine(new Pen(new SolidBrush(ForeColor.Blend(Color.Black, .6)), size * .06f), new PointF(cx, cy), new PointF(cx + (float)Math.Cos(-angle) * cx, cy - (float)Math.Sin(-angle) * cy));

            var pen = new Pen(Color.FromArgb(51, 0, 0, 0), pw);

            pen.EndCap = LineCap.Round;
            targetGraphics.DrawLine(pen, new PointF(cx, cy), new PointF(cx + pw / 4f, cy + pw / 4f));
            pen.Color = Color.FromArgb(151, 0, 0, 0);
            targetGraphics.DrawLine(pen, new PointF(cx, cy), new PointF(cx - pw2, cy + pw2));

            var rect  = new RectangleF(cx - pw2, cy - pw2, pw, pw);
            var lgrad = new LinearGradientBrush(rect, Color.DimGray, Color.Gainsboro, -45f);

            targetGraphics.FillEllipse(lgrad, rect);

            var rgrad = CustomControlShapes.GetRadialGradientBrush(rect, new Color[] { Color.FromArgb(71, 0, 0, 0) }, Color.White);

            targetGraphics.FillEllipse(rgrad, rect);
        }
Beispiel #5
0
        private void UseFormattedText(RenderCallback renderCallback)
        {
            Brush           textBrush       = new SolidColorBrush(ForeColor.ToWpfColor());
            FontDescription fontDescription = Font.GetFontDescription();
            var             formattedText   = new FormattedText(
                Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
                fontDescription.Typeface, fontDescription.Size, textBrush);

            formattedText.SetTextDecorations(fontDescription.TextDecorations);
            if (Width != null)
            {
                formattedText.MaxTextWidth = Width.Value;
            }
            if (Height != null)
            {
                formattedText.MaxTextHeight = Height.Value;
            }
            if (!Multiline)
            {
                formattedText.MaxLineCount = 1;
            }
            formattedText.Trimming = TextTrimming.None;
            //formattedText.TextAlignment = HorizontalTextAlignment;

            renderCallback(formattedText);
        }
Beispiel #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Accelerators.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ (BackColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ForeColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ Items.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ ListIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (MouseIcon?.Length.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ MousePointer.GetHashCode();
         hashCode = (hashCode * 397) ^ PropMask.GetHashCode();
         hashCode = (hashCode * 397) ^ Remainder.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ Size.GetHashCode();
         hashCode = (hashCode * 397) ^ TabData.GetHashCode();
         hashCode = (hashCode * 397) ^ TabFixedHeight.GetHashCode();
         hashCode = (hashCode * 397) ^ TabFixedWidth.GetHashCode();
         hashCode = (hashCode * 397) ^ TabNames.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ TabOrientation.GetHashCode();
         hashCode = (hashCode * 397) ^ TabsAllocated.GetHashCode();
         hashCode = (hashCode * 397) ^ TabStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ Tags.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ TextProps.GetHashCode();
         hashCode = (hashCode * 397) ^ TipStrings.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ VariousPropertyBits.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #7
0
        //----------------------------------------
        protected override CResultAErreur MySerialize(sc2i.common.C2iSerializer serializer)
        {
            int            nVersion = GetNumVersion();
            CResultAErreur result   = serializer.TraiteVersion(ref nVersion);

            if (!result)
            {
                return(result);
            }
            result = base.MySerialize(serializer);
            if (!result)
            {
                return(result);
            }

            int nCol = BackColor.ToArgb();

            serializer.TraiteInt(ref nCol);
            m_backColor = Color.FromArgb(nCol);

            nCol = ForeColor.ToArgb();
            serializer.TraiteInt(ref nCol);
            m_foreColor = Color.FromArgb(nCol);

            int nBorder = (int)BorderStyle;

            serializer.TraiteInt(ref nBorder);
            BorderStyle = (EBorderStyle)nBorder;

            result = serializer.TraiteListe <I2iObjetGraphique>(m_listeChilds);

            return(result);
        }
        public string GetSerializableFmt()
        {
            Dictionary <string, object> serial = new Dictionary <string, object>();

            serial.Add("MaxWidth", MaximumSize.Width);
            serial.Add("MaxHeight", MaximumSize.Height);
            serial.Add("MinWidth", MinimumSize.Width);
            serial.Add("MinHeight", MinimumSize.Height);
            serial.Add("SizeWidth", Size.Width);
            serial.Add("SizeHeight", Size.Height);

            serial.Add("BackColor", BackColor.ToArgb());
            //serial.Add("BackColor2", BackColor2.ToArgb());
            serial.Add("BorderStyle", BorderStyle);
            //serial.Add("GradientMode", GradientMode);
            serial.Add("DesignEventSerialFmt", DesignEventSerialFmt);

            serial.Add("CustomDesignFmt", CustomDesignFmt);
            serial.Add("RClickMenuDesignFmt", RClickMenuDesignFmt);
            serial.Add("ForeColor", ForeColor.ToArgb());
            serial.Add("ImeMode", ImeMode);

            serial.Add("TabIndex", TabIndex);

            return(DictionaryJsonHelper.SerializeDictionaryToJsonString <string, object>(serial));
        }
Beispiel #9
0
        /// <summary>
        /// Begin compact serialization MobiusDataType
        /// </summary>
        /// <returns></returns>

        public StringBuilder BeginSerialize(string type)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<");
            sb.Append(type);
            sb.Append(",");
            if (BackColor != DefaultBackColor)
            {
                sb.Append(BackColor.ToArgb().ToString());
            }
            sb.Append(",");

            if (ForeColor != DefaultAttrValues.ForeColor)
            {
                sb.Append(ForeColor.ToArgb().ToString());
            }
            sb.Append(",");

            if (!Lex.IsNullOrEmpty(DbLink))
            {
                sb.Append(NormalizeForSerialize(DbLink));
            }
            sb.Append(",");

            if (!Lex.IsNullOrEmpty(Hyperlink))
            {
                sb.Append(NormalizeForSerialize(Hyperlink));
            }
            sb.Append(",");

            return(sb);
        }
Beispiel #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (PropMask?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (BackColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ForeColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (FontTextProps?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)NextAvailableId;
         hashCode = (hashCode * 397) ^ (BooleanProperties?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)BorderStyle;
         hashCode = (hashCode * 397) ^ (int)MousePointer;
         hashCode = (hashCode * 397) ^ (ScrollBars?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ GroupCount;
         hashCode = (hashCode * 397) ^ (int)Cycle;
         hashCode = (hashCode * 397) ^ (int)SpecialEffect;
         hashCode = (hashCode * 397) ^ (BorderColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)Zoom;
         hashCode = (hashCode * 397) ^ (int)PictureAlignment;
         hashCode = (hashCode * 397) ^ (int)PictureSizeMode;
         hashCode = (hashCode * 397) ^ (int)ShapeCookie;
         hashCode = (hashCode * 397) ^ (int)DrawBuffer;
         hashCode = (hashCode * 397) ^ (DisplayedSize?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (LogicalSize?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ScrollPosition?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Caption?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ FontIsStdFont.GetHashCode();
         hashCode = (hashCode * 397) ^ (FontStdFont?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Beispiel #11
0
        protected override CResultAErreur MySerialize(C2iSerializer serializer)
        {
            //return CResultAErreur.True;
            int            nVersion = GetNumVersion();
            CResultAErreur result   = serializer.TraiteVersion(ref nVersion);

            if (!result)
            {
                return(result);
            }

            result = base.MySerialize(serializer);
            if (!result)
            {
                return(result);
            }

            int nColor = BackColor.ToArgb();

            serializer.TraiteInt(ref nColor);
            BackColor = Color.FromArgb(nColor);

            nColor = ForeColor.ToArgb();
            serializer.TraiteInt(ref nColor);
            ForeColor = Color.FromArgb(nColor);
            return(result);
        }
 protected override void OnForeColorChanged(EventArgs e)
 {
     base.OnForeColorChanged(e);
     if (textbox_ctrl != null)
     {
         textbox_ctrl.TextColor = ForeColor.ToNSColor();
     }
 }
Beispiel #13
0
 protected override void DrawForeGround(IRenderer gc)
 {
     if (ForeColor.A == 0 || StrokeWidth == 0)
     {
         return;
     }
     gc.drawEllipse(rect.X, rect.Y, rect.Width, rect.Height, ForeColor.ToArgb(), StrokeWidth);
 }
Beispiel #14
0
 /// <summary>
 /// Called from the setter of the UserInputEnabled property. Makes the
 /// Captionview readonly and grays-out the text.
 /// </summary>
 private void DisableUserInput()
 {
     Console.WriteLine("Forecolor: {0}", ForeColor.ToString());
     ReadOnly  = true;
     ForeColor = SystemColors.GrayText;
     ColumnHeadersDefaultCellStyle.ForeColor = SystemColors.GrayText;
     EnableHeadersVisualStyles = false;
 }
Beispiel #15
0
        /// <summary>
        /// Synchronizes current Console position and color attributes.
        /// </summary>
        ///
        private bool SyncConsolePositionAndAttributes()
        {
            string c1 = "-", c2 = "-", c3 = "-";

            // Update Console cursor position, if different
            //
            if (CursorTop != Y || CursorLeft != X)
            {
                Console.SetCursorPosition(CursorLeft = X, CursorTop = Y);

                #region [ Trace ]
                Debug.IfTracing(TraceFlag.Updates, delegate
                {
                    c1 = string.Format("{0,4} {1,4} {2,6}", Y, X, Y * Width + X);
                });
                #endregion
            }

            // Update current Console background color, if different
            //
            if (BackColor != Buffer.Area[Y, X].BackColor)
            {
                Console.BackgroundColor = Map(
                    BackColor           = Buffer.Area[Y, X].BackColor);

                #region [ Trace ]
                Debug.IfTracing(TraceFlag.Updates, delegate
                {
                    c2 = BackColor.ToString();
                });
                #endregion
            }

            // Update current Console foreground color, if different
            //
            if (ForeColor != Buffer.Area[Y, X].ForeColor)
            {
                Console.ForegroundColor = Map(
                    ForeColor           = Buffer.Area[Y, X].ForeColor);

                #region [ Trace ]
                Debug.IfTracing(TraceFlag.Updates, delegate
                {
                    c3 = ForeColor.ToString();
                });
                #endregion
            }

            #region [ Trace ]
            Debug.IfTracing(TraceFlag.Updates, delegate
            {
                Debug.TraceTimeStamp();
                Debug.Trace("{0,16}{1,12}{2,12} ", c1, c2, c3);
            });
            #endregion

            return(true);
        }
Beispiel #16
0
 private void colorSelectionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     colorPicker.Color = ForeColor;
     colorPicker.ShowDialog();
     if (!ForeColor.Equals(colorPicker.Color))
     {
         ForeColor = colorPicker.Color;
     }
 }
Beispiel #17
0
        /// <summary>
        /// Get custom css inline style
        /// </summary>
        /// <param name="autoFit">
        /// A value indicating whether the control's html width and height should be calculated by browser.
        /// </param>
        /// <returns>Custom css inline style</returns>
        protected virtual string GetCustomStyle(bool autoFit = false)
        {
            string widthString  = autoFit ? "auto" : string.Format("{0}pt", Width);
            string heightString = autoFit ? "auto" : string.Format("{0}pt", Height);

            string style = string.Format(StyleFormat, ForeColor.ToString("RGB"), BackColor.ToString("RGB"),
                                         TextAlign.ToString().ToLower(), Font.ToString("W"), heightString, widthString);

            return(style);
        }
Beispiel #18
0
        public override string ToString()
        {
            string result = "Line " + ForeColor.ToString();

            if (Width > 1)
            {
                result += " Width=" + Width.ToString();
            }
            return(result);
        }
 public string ToInternallyFormattedSystemString()
 {
     return
         (("&" + ForeColor.GetSimpleColor().ColorCode) +
          (IsBold ? "&l" : "") +
          (IsItallic ? "&o" : "") +
          (IsUnderlined ? "&n" : "") +
          (IsStrikeout ? "&m" : "") +
          (IsObfuscated ? "&k" : "") +
          Message);
 }
Beispiel #20
0
        protected override void CreateImage()
        {
            // If width and height are not set, we need to measure the string.
            int  calculatedWidth, calculatedHeight;
            Size measuredSize = MeasureString();

            if (Width == null || Height == null)
            {
                double width  = Width ?? measuredSize.Width;
                double height = Height ?? measuredSize.Height;
                calculatedWidth  = (int)width;
                calculatedHeight = (int)height;
            }
            else             // otherwise just create the image at the desired size
            {
                calculatedWidth  = Width.Value;
                calculatedHeight = Height.Value;
            }

            #region Draw text

            DrawingVisual  dv = new DrawingVisual();
            DrawingContext dc = dv.RenderOpen();

            //RenderOptions.SetClearTypeHint(dv, ClearTypeHint.Auto);
            TextOptions.SetTextRenderingMode(dv, TextRenderingMode.Auto);
            //TextOptions.SetTextFormattingMode(dv, TextFormattingMode.Ideal)

            UseFormattedText(ft =>
            {
                Pen pen = null;
                if (StrokeWidth > 0 && StrokeColor != null)
                {
                    pen = new Pen(new SolidColorBrush(StrokeColor.Value.ToWpfColor()), StrokeWidth);
                }

                // Calculate position to draw text at, based on vertical text alignment.
                int x = CalculateHorizontalPosition((int)measuredSize.Width);
                int y = CalculateVerticalPosition((int)measuredSize.Height);

                dc.DrawGeometry(new SolidColorBrush(ForeColor.ToWpfColor()), pen,
                                ft.BuildGeometry(new Point(x, y)));
            });

            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(calculatedWidth, calculatedHeight);
            rtb.Render(dv);

            #endregion

            Bitmap = new FastBitmap(rtb);
        }
Beispiel #21
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + ForeColor.GetHashCode();
         hash = hash * 23 + BackColor.GetHashCode();
         hash = hash * 23 + AdornmentColor.GetHashCode();
         hash = hash * 23 + Adornment.GetHashCode();
         hash = hash * 23 + FontStyle.GetHashCode();
         return(hash);
     }
 }
Beispiel #22
0
        protected virtual void formMain_ForeColorChanged(object sender, EventArgs e)
        {
            List <Control> listCtrlDoChangeForeColor;

            ForeColor = (sender as Form).ForeColor;

            listCtrlDoChangeForeColor = getTypedControls(this, new List <Type> ()
            {
                typeof(DataGridView), typeof(ZedGraph.ZedGraphControl)
            }).ToList();

            listCtrlDoChangeForeColor.ForEach(ctrl => ctrl.ForeColor = ForeColor.Equals(SystemColors.ControlText) == false ? ForeColor : SystemColors.ControlText);
        }
Beispiel #23
0
        public override void Initialize(ContentManager content, GraphicsDevice graphics)
        {
            texture = content.Load <Texture2D>(textureName);

            srcRect[0] = new Rectangle(0, 0, texture.Width - 1, texture.Height);
            srcRect[1] = new Rectangle(texture.Width - 1, 0, 1, texture.Height);
            srcRect[2] = new Rectangle(texture.Width - 1, 0, -texture.Width + 1, texture.Height);

            if (Text != string.Empty)
            {
                textSize = Font.MeasureString(Text);
            }

            if (textureName == @"textures\controls\button\default")
            {
                if (Size.X < Font.MeasureString(Text).X + 20f)
                {
                    Size = new Vector2(Font.MeasureString(Text).X + 20f, Size.Y);
                }
                if (Size.Y < texture.Height)
                {
                    Size = new Vector2(Size.X, texture.Height);
                }
                if (Size.Y < Font.MeasureString(Text).Y + 5f)
                {
                    Size = new Vector2(Size.X, Font.MeasureString(Text).Y + 5f);
                }
            }
            else
            {
                srcRect[0].Width += 1;
                Size              = new Vector2(texture.Width * scale, texture.Height * scale);
            }

            area.Width  = (int)Size.X;
            area.Height = (int)Size.Y;

            Vector4 colorVect = BackColor.ToVector4();

            highlight = BackColor;
            BackColor = new Color(new Vector4(colorVect.X * 0.95f, colorVect.Y * 0.95f, colorVect.Z * 0.95f, colorVect.W));
            dimColor  = new Color(new Vector4(colorVect.X * 0.85f, colorVect.Y * 0.85f, colorVect.Z * 0.85f, colorVect.W));

            colorVect     = ForeColor.ToVector4();
            texthighlight = ForeColor;
            ForeColor     = new Color(new Vector4(colorVect.X * 0.95f, colorVect.Y * 0.5f, colorVect.Z * 0.95f, colorVect.W));
            textdim       = new Color(new Vector4(colorVect.X * 0.9f, colorVect.Y * 0.9f, colorVect.Z * 0.9f, colorVect.W));

            base.Initialize(content, graphics);
        }
Beispiel #24
0
 public override int GetHashCode()
 {
     unchecked
     {
         //I shouldn't disable this, but I am in order to facilitate easier testing.
         //Should we ever need to put these in a set, this will need to be fixed.
         // ReSharper disable NonReadonlyMemberInGetHashCode
         int hashCode = Level.GetHashCode();
         hashCode = (hashCode * 397) ^ ForeColor.GetHashCode();
         hashCode = (hashCode * 397) ^ BackColor.GetHashCode();
         // ReSharper restore NonReadonlyMemberInGetHashCode
         return(hashCode);
     }
 }
        private void Save(object obj)
        {
            Settings.Default.CharacterInterval = CharacterInterval;
            Settings.Default.CharacterMargin   = CharacterMargin;
            Settings.Default.FontSize          = FontSize;
            Settings.Default.TimeFontSize      = TimeFontSize;
            Settings.Default.BackColor         = BackColor.ToString();
            Settings.Default.ForeColor         = ForeColor.ToString();
            Settings.Default.DisplayTime       = DisplayTime;
            Settings.Default.UseAllScreens     = UseAllScreens;
            Settings.Default.TimeFormat        = TimeFormat;

            Settings.Default.Save();
            parentWindow.Close();
        }
Beispiel #26
0
 private void ApplyStyle(SyntaxDescriptor sd, Capture c)
 {
     Select(c.Index, c.Length);
     if (SelectionColor.ToArgb() == ForeColor.ToArgb() &&
         SameFont(SelectionFont, Font))
     {
         if (sd.Color != ForeColor)
         {
             SelectionColor = sd.Color;
         }
         if (sd.Font != null)
         {
             SelectionFont = sd.Font;
         }
     }
 }
        private void CreateRenderTarget()
        {
            // This doesn't work in the Designer, because the Designer doesn't
            // pick up the skialib dll.
            var typeFace = SKTypeface.FromFamilyName(Font.Name,
                                                     SKFontStyleWeight.Normal,
                                                     SKFontStyleWidth.Normal,
                                                     SKFontStyleSlant.Upright);

            _renderTargetControl = new SkiaMonospaceRenderTarget(typeFace, Font.Size,
                                                                 ForeColor.ToSKColor(), BackColor.ToSKColor(),
                                                                 WidthInCharacters, HeightInCharacters);
            _renderTargetControlIsInstanciated = true;

            Controls.Add(_renderTargetControl);
        }
Beispiel #28
0
        /// <summary>
        /// Serialize base of Mobius Data Type
        /// </summary>
        /// <param name="br"></param>

        public virtual void SerializeBinary(BinaryWriter bw)
        {
            if (IsNonExistant)             // write nonexistant if nonexistant value is set
            {
                bw.Write(NonExistantValueFlag);
            }

            if (BackColor != DefaultBackColor)
            {
                bw.Write(true);
                bw.Write(BackColor.ToArgb());
            }
            else
            {
                bw.Write(false);
            }

            if (ForeColor != DefaultAttrValues.ForeColor)
            {
                bw.Write(true);
                bw.Write(ForeColor.ToArgb());
            }
            else
            {
                bw.Write(false);
            }

            if (DbLink != "")
            {
                bw.Write(true);
                bw.Write(Lex.S(DbLink));
            }
            else
            {
                bw.Write(false);
            }

            if (Hyperlink != "")
            {
                bw.Write(true);
                bw.Write(Lex.S(Hyperlink));
            }
            else
            {
                bw.Write(false);
            }
        }
Beispiel #29
0
 private void Separator_Paint(object sender, PaintEventArgs e)
 {
     if (orientation == Orientation.Horizontal)
     {
         e.Graphics.DrawLine(BackColor.ToPen(), 0, 0, this.Width, 0);
         e.Graphics.DrawLine(ForeColor.ToPen(), 0, 1, this.Width, 1);
     }
     else if (orientation == Orientation.Vertical)
     {
         e.Graphics.DrawLine(BackColor.ToPen(), 0, 0, 0, this.Height);
         e.Graphics.DrawLine(ForeColor.ToPen(), 1, 0, 1, this.Height);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.DrawBorder(Graphics, Color, float)"/>
        protected override void DrawBorder(Graphics gr, Color bc, float bw)      // normal override, you can overdraw border if required.
        {
            int       topoffset = this.Text.HasChars() ? (Margin.Top * 3 / 8) : GBMargins;
            Rectangle rectarea  = new Rectangle(Margin.Left,
                                                topoffset,
                                                Width - Margin.TotalWidth - 1,
                                                Height - Margin.Bottom - topoffset - 1);

            //System.Diagnostics.Debug.WriteLine("Bounds {0} rectarea {1}", bounds, rectarea);

            using (var fmt = ControlHelpersStaticFunc.StringFormatFromContentAlignment(TextAlign))
            {
                // work out the area of the text box, given the text width, and the textalign
                var       size       = this.Text.HasChars() ? gr.MeasureString(this.Text, this.Font, 10000, fmt) : new SizeF(0, 0);
                int       twidth     = (int)(size.Width + 0.99f);
                bool      alignright = TextAlign == ContentAlignment.MiddleRight || TextAlign == ContentAlignment.TopRight || TextAlign == ContentAlignment.BottomRight;
                Rectangle titlearea  = new Rectangle(alignright ? rectarea.Right - twidth - GBXoffset : GBXoffset, 0, twidth, GroupBoxTextHeight);

                using (var p = new Pen(bc, bw))
                {
                    if (this.Text.HasChars())
                    {
                        gr.DrawLine(p, titlearea.Left - GBXpad, rectarea.Top, rectarea.Left, rectarea.Top); // draw around text
                        gr.DrawLine(p, rectarea.Right, rectarea.Top, titlearea.Right + GBXpad, rectarea.Top);
                    }
                    else
                    {
                        gr.DrawLine(p, rectarea.Left, rectarea.Top, rectarea.Right, rectarea.Top);
                    }

                    gr.DrawLine(p, rectarea.Left, rectarea.Top, rectarea.Left, rectarea.Bottom - 1);
                    gr.DrawLine(p, rectarea.Left, rectarea.Bottom - 1, rectarea.Right, rectarea.Bottom - 1);
                    gr.DrawLine(p, rectarea.Right, rectarea.Bottom - 1, rectarea.Right, rectarea.Top);
                    gr.DrawLine(p, rectarea.Right, rectarea.Bottom - 1, rectarea.Right, rectarea.Top);
                }

                if (this.Text.HasChars())
                {
                    using (Brush textb = new SolidBrush((Enabled) ? this.ForeColor : ForeColor.Multiply(ForeDisabledScaling)))
                    {
                        gr.DrawString(this.Text, this.Font, textb, titlearea, fmt);
                    }
                }
            }
        }