public virtual void Deserialize(ElementPropertyBag epb)
        {
            Id = epb.Id;

            if (!String.IsNullOrEmpty(epb.Json))
            {
                Json = JsonConvert.DeserializeObject <Dictionary <string, string> >(epb.Json);
            }

            DisplayRectangle = epb.DisplayRectangle;
            BorderPen.Dispose();
            BorderPen = new Pen(epb.BorderPenColor, epb.BorderPenWidth);
            FillBrush.Dispose();
            FillBrush = new SolidBrush(epb.FillBrushColor);
            Text      = epb.Text;
            TextColor = epb.TextColor;
            // If missing (backwards compatibility) middle-center align.
            TextAlign = epb.TextAlign == 0 ? ContentAlignment.MiddleCenter : epb.TextAlign;
            TextFont.Dispose();
            FontStyle fontStyle = (epb.TextFontUnderline ? FontStyle.Underline : FontStyle.Regular) | (epb.TextFontItalic ? FontStyle.Italic : FontStyle.Regular) | (epb.TextFontStrikeout ? FontStyle.Strikeout : FontStyle.Regular);

            TextFont = new Font(epb.TextFontFamily, epb.TextFontSize, fontStyle);

            HasCornerAnchors    = epb.HasCornerAnchors;
            HasCenterAnchors    = epb.HasCenterAnchors;
            HasLeftRightAnchors = epb.HasLeftRightAnchors;
            HasTopBottomAnchors = epb.HasTopBottomAnchors;

            HasCornerConnections    = epb.HasCornerConnections;
            HasCenterConnections    = epb.HasCenterConnections;
            HasLeftRightConnections = epb.HasLeftRightConnections;
            HasTopBottomConnections = epb.HasTopBottomConnections;
        }
Exemple #2
0
        public virtual void Deserialize(ElementPropertyBag epb)
        {
            Id = epb.Id;
            DisplayRectangle = epb.DisplayRectangle;
            BorderPen.Dispose();
            BorderPen = new Pen(epb.BorderPenColor, epb.BorderPenWidth);
            FillBrush.Dispose();
            FillBrush = new SolidBrush(epb.FillBrushColor);
            Text      = epb.Text;
            TextColor = epb.TextColor;
            TextFont.Dispose();
            FontStyle fontStyle = (epb.TextFontUnderline ? FontStyle.Underline : FontStyle.Regular) | (epb.TextFontItalic ? FontStyle.Italic : FontStyle.Regular) | (epb.TextFontStrikeout ? FontStyle.Strikeout : FontStyle.Regular);

            TextFont = new Font(epb.TextFontFamily, epb.TextFontSize, fontStyle);

            HasCornerAnchors    = epb.HasCornerAnchors;
            HasCenterAnchors    = epb.HasCenterAnchors;
            HasLeftRightAnchors = epb.HasLeftRightAnchors;
            HasTopBottomAnchors = epb.HasTopBottomAnchors;

            HasCornerConnections    = epb.HasCornerConnections;
            HasCenterConnections    = epb.HasCenterConnections;
            HasLeftRightConnections = epb.HasLeftRightConnections;
            HasTopBottomConnections = epb.HasTopBottomConnections;
        }
Exemple #3
0
 void IDisposable.Dispose()
 {
     VeryLargeFont.Dispose();
     VeryLargeFont.Dispose();
     LargeFont.Dispose();
     MediumFont.Dispose();
     SmallFont.Dispose();
     VerySmallFont.Dispose();
     FillBrush.Dispose();
     AccentBrush.Dispose();
     DefaultBrush.Dispose();
 }
Exemple #4
0
        void DrawBackground(Graphics g)
        {
            Brush FillBrush;

            if (RTLMenu)
            {
                FillBrush = new LinearGradientBrush(m_BackRect, m_ItemColors.GradientEndColor, m_ItemColors.GradientStartColor, LinearGradientMode.Horizontal);
            }
            else
            {
                FillBrush = new LinearGradientBrush(m_BackRect, m_ItemColors.GradientStartColor, m_ItemColors.GradientEndColor, LinearGradientMode.Horizontal);
            }
            g.FillRectangle(FillBrush, m_BackRect);
            FillBrush.Dispose();
        }
Exemple #5
0
        // Clean up managed resources.
        public void Dispose()
        {
            Console.WriteLine("Disposing the Managed Resources");
            // If we've already run Dispose, do nothing.

            if (IsDisposed)
            {
                return;
            }
            // Dispose of FillBrush and OutlinePen.
            FillBrush.Dispose();
            OutlinePen.Dispose();
            // Remember that we ran Dispose.
            IsDisposed = true;
        }
Exemple #6
0
        // Clean up managed resources.
        public void Dispose()
        {
            // If we've already run Dispose, do nothing.
            if (IsDisposed)
            {
                return;
            }

            // Dispose of FillBrush and OutlinePen.
            FillBrush.Dispose();
            OutlinePen.Dispose();

            // Remember that we ran Dispose.
            IsDisposed = true;
        }
Exemple #7
0
        protected override Rectangle CalculateBounds()
        {
            Rectangle bounds = base.CalculateBounds();

            bounds.Y--;
            bounds.Height++;
            bounds.Width--;
            // update brush
            if (FillBrush != null)
            {
                FillBrush.Dispose();
            }
            FillBrush = new LinearGradientBrush(bounds, Color.FromArgb(64, Color.LightBlue),
                                                Color.FromArgb(64, Color.DodgerBlue), LinearGradientMode.Vertical);
            return(bounds);
        }
Exemple #8
0
        public virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                disposed = true;

                if (disposing)
                {
                    BorderPen.Dispose();
                    FillBrush.Dispose();
                    background?.Dispose();
                    selectionPen.Dispose();
                    altSelectionPen.Dispose();
                    anchorPen.Dispose();
                    anchorBrush.Dispose();
                    TextFont.Dispose();
                    connectionPointPen.Dispose();
                }
            }
        }
 public virtual void Dispose()
 {
     if (!disposed)
     {
         if (FillBrush != null)
         {
             FillBrush.Dispose();
             FillBrush = null;
         }
         if (PenBrush != null)
         {
             PenBrush.Dispose();
             PenBrush = null;
         }
         if (StrokeStyle != null)
         {
             StrokeStyle.Dispose();
             StrokeStyle = null;
         }
     }
 }
Exemple #10
0
        /// <summary>
        /// Do the actual work of drawing the filled border
        /// </summary>
        /// <param name="g"></param>
        /// <param name="bounds"></param>
        protected void DrawFilledBorder(Graphics g, Rectangle bounds)
        {
            bounds.Inflate(BoundsPadding);
            GraphicsPath path = GetRoundedRect(bounds, CornerRounding);

            if (FillGradientFrom != null && FillGradientTo != null)
            {
                if (FillBrush != null)
                {
                    FillBrush.Dispose();
                }
                FillBrush = new LinearGradientBrush(bounds, FillGradientFrom.Value, FillGradientTo.Value,
                                                    FillGradientMode);
            }
            if (FillBrush != null)
            {
                g.FillPath(FillBrush, path);
            }
            if (BorderPen != null)
            {
                g.DrawPath(BorderPen, path);
            }
        }
        /// <summary>
        /// Draw rectangles for notes
        /// </summary>
        /// <param name="e"></param>
        /// <param name="noteNumber"></param>
        /// <param name="startTime"></param>
        /// <param name="duration"></param>
        /// <param name="channel"></param>
        private void MakeNoteRectangle(Graphics g, int noteNumber, long startTime, int duration, int channel)
        {
            Rectangle  rect = new Rectangle();
            SolidBrush FillBrush;
            Pen        StrokePen;
            int        PH = pnlCanvas.Height;

            int X = (int)((noteNumber - lowNoteID) * xscale);        // X = notenumber - 23 (graves à gauche aigues à droite)
            int Y = (int)(PH - (startTime + duration) * yscale);     // hauteur - starttime

            int W = (int)xscale;
            int H = (int)(duration * yscale);

            Rectangle rectn = new Rectangle(X, Y, W, H);

            if (channel == 9)  // Drums are green
            {
                StrokePen = new Pen(Color.DarkGreen, 2);
                FillBrush = new SolidBrush(Color.LightGreen);
                duration  = sequence1.Time.Quarter / 4;
            }
            else
            {
                // Other
                #region colors per channel
                switch (channel)
                {
                case 0:
                    StrokePen = new Pen(Color.DarkGreen, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.LightGreen);
                    break;

                case 1:
                    StrokePen = new Pen(Color.DarkBlue, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.CornflowerBlue);
                    break;

                case 2:
                    StrokePen = new Pen(Color.DarkGoldenrod, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.LightGoldenrodYellow);
                    break;

                case 3:
                    StrokePen = new Pen(Color.DarkGreen, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.SlateBlue);
                    break;

                case 4:
                    StrokePen = new Pen(Color.Pink, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.LightPink);
                    break;

                case 5:
                    StrokePen = new Pen(Color.Salmon, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.LightSalmon);
                    break;

                case 6:
                    StrokePen = new Pen(Color.SeaGreen, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.LightSeaGreen);
                    break;

                case 7:
                    StrokePen = new Pen(Color.SlateBlue, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.LightSteelBlue);
                    break;

                case 8:
                    StrokePen = new Pen(Color.BlueViolet, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.Plum);
                    break;

                case 10:
                    StrokePen = new Pen(Color.DarkGray, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.Maroon);
                    break;

                case 11:
                    StrokePen = new Pen(Color.DarkGray, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.Red);
                    break;

                case 12:
                    StrokePen = new Pen(Color.DarkGray, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.Chocolate);
                    break;

                case 13:
                    StrokePen = new Pen(Color.DarkGray, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.NavajoWhite);
                    break;

                case 14:
                    StrokePen = new Pen(Color.DarkGray, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.Green);
                    break;

                default:
                    StrokePen = new Pen(Color.DarkGray, 2);
                    FillBrush = new SolidBrush(System.Drawing.Color.LightGray);
                    break;
                }
                #endregion colors per channel
            }

            rect = new Rectangle(X, Y, W, H);

            //g.DrawRectangle(StrokePen, X, Y, W, H);
            //g.FillRectangle(FillBrush, rect);
            // Draw rectangles with rounded corners
            RectRoutines.DrawRoundedRectangle(g, StrokePen, rect, 5);
            RectRoutines.FillRoundedRectangle(g, FillBrush, rect, 5);


            FillBrush.Dispose();
            StrokePen.Dispose();
        }