コード例 #1
0
ファイル: RollingCounter.cs プロジェクト: ssor/csharpDemos
        internal void Draw(Graphics e)
        {
            if (_scrollEffect == false)
            {
                _scrollY = (int)_count * Height;
            }
            int diff1, diff2;

            diff1 = 10 * Height - _scrollY;
            diff2 = Height - diff1;
            if (diff1 <= Height && diff1 >= 0)
            {
                //    Console.WriteLine(" XXscrollY = " + _scrollY + " diff1=" + diff1 + " diff2=" + diff2 + " Height=" + Height);

                e.DrawImage(_map, new Rectangle(_x, _y, _width, diff1), new Rectangle(0, _scrollY, _width, diff1), GraphicsUnit.Pixel);
                e.DrawImage(_map, new Rectangle(_x, diff1 + _y, _width, diff2), new Rectangle(0, 0, _width, diff2), GraphicsUnit.Pixel);
            }
            else
            {
                //    Console.WriteLine("YYscrollY = " + _scrollY + " diff1=" + diff1 + " diff2=" + diff2 + " Height=" + Height);

                e.DrawImage(_map, new Rectangle(_x, _y, _width, _height), new Rectangle(0, _scrollY, _width, _height), GraphicsUnit.Pixel);
            }

            Border.Border b        = new Border.Inner3D();
            Rectangle     drawRect = RectangleHelper.Shrink(new Rectangle(_x, _y, _width, _height), 3);

            b.DrawBorder(e, new GRectangle(drawRect).GetGraphicsPath());
        }
コード例 #2
0
ファイル: MeterPanel.cs プロジェクト: ssor/csharpDemos
        public void Draw(Graphics e)
        {
            e.SmoothingMode = SmoothingMode.HighQuality;
            Rectangle ori = new Rectangle(_clientRect.X, _clientRect.Y, _clientRect.Width, _clientRect.Width);

            _center = new PointF(ori.X + ori.Width / 2, ori.Top + ori.Height / 2);
            Rectangle    r  = Helper.RectangleHelper.Shrink(ori, 1);
            GraphicsPath gp = new GraphicsPath();

            gp.AddEllipse(r);
            if (_border)
            {
                Border.Border border = new Border.Inner3D();
                border.DrawBorder(e, gp);
            }
            Rectangle    r2  = Helper.RectangleHelper.Shrink(r, 15);
            Pen          p   = new Pen(_outlineColor);
            GraphicsPath gp2 = new GraphicsPath();

            gp2.AddArc(r2, _startGapAngle + _sweepAngle, 360 - _sweepAngle);
            gp2.Reverse();
            Rectangle r3   = Helper.RectangleHelper.Shrink(r2, 5);
            PointF    out1 = Helper.AlgorithmHelper.LocationToCenter(_center, r2.Width / 2, _startGapAngle);
            PointF    in1  = Helper.AlgorithmHelper.LocationToCenter(_center, r3.Width / 2, _startGapAngle);
            PointF    out2 = Helper.AlgorithmHelper.LocationToCenter(_center, r2.Width / 2, _startGapAngle + _sweepAngle);
            PointF    in2  = Helper.AlgorithmHelper.LocationToCenter(_center, r3.Width / 2, _startGapAngle + _sweepAngle);

            gp2.AddLine(out2, in2);
            gp2.AddArc(r3, _startGapAngle + _sweepAngle, 360 - _sweepAngle);
            gp2.AddLine(in1, out1);
            gp2.CloseAllFigures();

            DrawMarking(e, r3, r2);
            PointF point = Helper.AlgorithmHelper.LocationToCenter(_center, 50, _curAngle);

            e.DrawLine(new Pen(_pointerColor, 2), _center, point);
            Rectangle           r4 = Helper.RectangleHelper.Shrink(r3, 30);
            LinearGradientBrush lb = new LinearGradientBrush(r4, _pointerHandleColor, Color.LightGray, 45f);

            e.FillEllipse(lb, r4);
            e.DrawPath(p, gp2);
            //Draw the pointer
            //Rectangle ptr = Helper.RectangleHelper.Shrink(r4, 20);
            //e.DrawEllipse(new Pen(Color.Black), ptr);
        }