Ejemplo n.º 1
0
        /// <summary>
        ///     Raises the <see cref="E:Paint" /> event.
        /// </summary>
        /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
        protected override void OnPaint(LCDPaintEventArgs e)
        {
            if (Width == 1)
            {
                for (var y = 0; y < Height; y++)
                {
                    e.Bitmap[0, y] = true;
                }
            }
            else
            {
                var top = Start.X < End.X ? (Start.Y < End.Y) : (End.Y < Start.Y);

                for (var x = 0; x < Width; x++)
                {
                    var ry  = (int)(((float)Height / Width) * x);
                    var nry = Math.Max(ry, (int)(((float)Height / Width) * (x + 1)) - 1);
                    var sy  = top ? ry : Height - ry - 1;
                    var ey  = top ? nry : Height - nry - 1;
                    for (var y = sy; y <= ey; y++)
                    {
                        e.Bitmap[x, y] = true;
                    }
                }
            }
            base.OnPaint(e);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Raises the <see cref="E:Paint" /> event.
        /// </summary>
        /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
        protected override void OnPaint(LCDPaintEventArgs e)
        {
            if (_bitmap != null)
            {
                e.Bitmap.Merge(_bitmap, new Point(0, 0), MergeMethods.Override);
            }

            base.OnPaint(e);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Raises the <see cref="E:Paint" /> event.
        /// </summary>
        /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
        protected override void OnPaint(LCDPaintEventArgs e)
        {
            SelectedTab?.PerformLayout();
            e.Bitmap.MergeOverride(SelectedTab?.Bitmap, new Point(0, 0));

            if (Menu.Visible)
            {
                Menu.PerformLayout();
                e.Bitmap.MergeOverride(Menu.Bitmap, new Point(0, Height - Menu.Height));
            }
            base.OnPaint(e);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Raises the <see cref="E:Paint" /> event.
        /// </summary>
        /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
        protected override void OnPaint(LCDPaintEventArgs e)
        {
            if (Controls == null)
            {
                return;
            }

            foreach (var control in Controls.ToArray())
            {
                control.PerformLayout();
                e.Bitmap.Merge(control.Bitmap, control.Location, control.MergeMethod ?? MergeMethods.Override);
            }
            base.OnPaint(e);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Raises the <see cref="E:Paint" /> event.
        /// </summary>
        /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
        protected override void OnPaint(LCDPaintEventArgs e)
        {
            int graphX, graphY, graphWidth, graphHeight;

            switch (Style)
            {
            case BorderStyle.Border:
                graphX      = 1;
                graphY      = 1;
                graphWidth  = Width - 2;
                graphHeight = Height - 2;
                break;

            case BorderStyle.BorderWithPadding:
                graphX      = 2;
                graphY      = 2;
                graphWidth  = Width - 4;
                graphHeight = Height - 4;
                break;

            case BorderStyle.None:
            default:
                graphX      = 0;
                graphY      = 0;
                graphWidth  = Width;
                graphHeight = Height;
                break;
            }

            if (Style == BorderStyle.Border || Style == BorderStyle.BorderWithPadding)
            {
                for (var x = 1; x < Width - 1; x++)
                {
                    e.Bitmap[x, 0]          = true;
                    e.Bitmap[x, Height - 1] = true;
                }
                for (var y = 0; y < Height; y++)
                {
                    e.Bitmap[0, y]         = true;
                    e.Bitmap[Width - 1, y] = true;
                }
            }

            if (graphWidth <= 0 || graphHeight <= 0 || !_values.Any())
            {
                base.OnPaint(e);
                return;
            }

            var cx = graphX + MaxEntries - _values.Count;

            foreach (
                var height in
                _values.Select(value => (float)(value - Minimum) / (Maximum - Minimum))
                .Select(value => Math.Min(1f, Math.Max(0f, value)))
                .Select(value => (int)(value * graphHeight)))
            {
                for (var y = 0; y < height; y++)
                {
                    e.Bitmap[cx, graphY + graphHeight - y] = true;
                }

                cx++;
            }

            base.OnPaint(e);
        }
Ejemplo n.º 6
0
 /// <summary>
 ///     Raises the <see cref="E:Paint" /> event.
 /// </summary>
 /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
 protected override void OnPaint(LCDPaintEventArgs e)
 {
     base.OnPaint(e);
     Push(e.Bitmap);
 }
Ejemplo n.º 7
0
        /// <summary>
        ///     Raises the <see cref="E:Paint" /> event.
        /// </summary>
        /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
        protected override void OnPaint(LCDPaintEventArgs e)
        {
            if (Font != null && Text != null)
            {
                using (var bitmap = new Bitmap(Width, Height))
                    using (var graphics = Graphics.FromImage(bitmap))
                    {
                        graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;

                        if (AutoSize)
                        {
                            graphics.DrawString(Text, Font, Brushes.Black, new Point(0, 0));
                        }
                        else
                        {
                            Size size;
                            switch (TextAlign)
                            {
                            default:
                            case ContentAlignment.TopLeft:
                                graphics.DrawString(Text, Font, Brushes.Black, new Point(0, 0));
                                break;

                            case ContentAlignment.TopCenter:
                                size = MeasureText();
                                graphics.DrawString(Text, Font, Brushes.Black, new Point((Width - size.Width) / 2, 0));
                                break;

                            case ContentAlignment.TopRight:
                                size = MeasureText();
                                graphics.DrawString(Text, Font, Brushes.Black, new Point(Width - size.Width, 0));
                                break;

                            case ContentAlignment.MiddleLeft:
                                size = MeasureText();
                                graphics.DrawString(Text, Font, Brushes.Black, new Point(0, (Height - size.Height) / 2));
                                break;

                            case ContentAlignment.MiddleCenter:
                                size = MeasureText();
                                graphics.DrawString(Text, Font, Brushes.Black,
                                                    new Point((Width - size.Width) / 2, (Height - size.Height) / 2));
                                break;

                            case ContentAlignment.MiddleRight:
                                size = MeasureText();
                                graphics.DrawString(Text, Font, Brushes.Black,
                                                    new Point(Width - size.Width, (Height - size.Height) / 2));
                                break;

                            case ContentAlignment.BottomLeft:
                                size = MeasureText();
                                graphics.DrawString(Text, Font, Brushes.Black, new Point(0, Height - size.Height));
                                break;

                            case ContentAlignment.BottomCenter:
                                size = MeasureText();
                                graphics.DrawString(Text, Font, Brushes.Black,
                                                    new Point((Width - size.Width) / 2, Height - size.Height));
                                break;

                            case ContentAlignment.BottomRight:
                                size = MeasureText();
                                graphics.DrawString(Text, Font, Brushes.Black,
                                                    new Point(Width - size.Width, Height - size.Height));
                                break;
                            }
                        }

                        e.Bitmap.Merge(new MonochromeBitmap(bitmap), new Point(), MergeMethods.Override);
                    }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 ///     Raises the <see cref="E:Paint" /> event.
 /// </summary>
 /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
 protected override void OnPaint(LCDPaintEventArgs e)
 {
     _container.PerformLayout();
     e.Bitmap.MergeOverride(_container.Bitmap, new Point(0, 0));
     base.OnPaint(e);
 }
Ejemplo n.º 9
0
 /// <summary>
 ///     Raises the <see cref="E:Paint" /> event.
 /// </summary>
 /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
 protected override void OnPaint(LCDPaintEventArgs e)
 {
     _label.PerformLayout();
     e.Bitmap.MergeOverride(_label.Bitmap, new Point(-_steps, 0));
     base.OnPaint(e);
 }
Ejemplo n.º 10
0
 /// <summary>
 ///     Raises the <see cref="E:Paint" /> event.
 /// </summary>
 /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param>
 protected virtual void OnPaint(LCDPaintEventArgs e)
 {
     Paint?.Invoke(this, e);
 }