Example #1
0
 void renderSegment(Renderer.BaseRenderer g, LPoint p1, LPoint p2, float quality, float border)
 {
     if (p1.Outside && p2.Outside)
     {
         return;
     }
     if (Spline != null)
     {
         int   n  = (int)(p1.Dist(p2) * quality);
         float dx = (p2.X - p1.X) / n;
         float dy = (p2.Y - p1.Y) / n;
         float dr = (p2.Rad - p1.Rad) / n;
         for (int i = 0; i < n; i++)
         {
             double x, y;
             Spline.GetPoint(p1.Index + i / (float)n, out x, out y);
             LPoint p = new LPoint((float)x, (float)y, p1.Rad + dr * i);
             renderPoint(g, p, border);
         }
     }
     else
     {
         int   n  = (int)(p1.Dist(p2) * quality);
         float dx = (p2.X - p1.X) / n;
         float dy = (p2.Y - p1.Y) / n;
         float dr = (p2.Rad - p1.Rad) / n;
         for (int i = 0; i < n; i++)
         {
             LPoint p = new LPoint(p1.X + dx * i, p1.Y + dy * i, p1.Rad + dr * i);
             renderPoint(g, p, border);
         }
     }
 }
Example #2
0
 public virtual void Render(Renderer.BaseRenderer g, float quality = 1, int start = 0, bool simple = false)
 {
     if (g.RenderSpecial && Selected)
     {
         renderFull(g, PBrush.CreateSolid(Color.Black), 4, quality, start, simple);
         renderFull(g, PBrush.CreateSolid(Color.White), 2, quality, start, simple);
     }
     renderFull(g, Brush, 0, quality, start, simple);
 }
Example #3
0
 public void DrawBackground(Renderer.BaseRenderer r)
 {
     for (int i = 0; i < lines.Count; i++)
     {
         if (lines[i] is Forms.IBackground)
         {
             lines[i].Render(r);
         }
     }
 }
Example #4
0
        public InkControl()
        {
            pm             = new PointerManager(this);
            timer          = new System.Windows.Forms.Timer();
            timer.Interval = 10;
            timer.Start();
            timer.Tick          += timer_tick;
            this.Paint          += this_paint;
            this.SizeChanged    += InkControl_SizeChanged;
            this.VisibleChanged += InkControl_VisibleChanged;
            //SizeMode = PictureBoxSizeMode.StretchImage;
            renderer    = new Renderer.GdiRenderer(CreateGraphics());
            gpuRenderer = Renderer.GPURenderer.Create(this, RenderMode.Software);

            this.MouseWheel += InkControl_MouseWheel;
            this.MouseMove  += InkControl_MouseMove;
            this.MouseDown  += InkControl_MouseDown;
            this.MouseUp    += InkControl_MouseUp;

            recreateBufferFull();
            renderThread  = new Thread(renderLoop);
            renderThread2 = new Thread(renderLoop2);

            /*MenuItem[] contextMenu = new MenuItem[]
             * {
             *  new MenuItem("Copy"),
             *  new MenuItem("Paste")
             * };
             * this.ContextMenu = new ContextMenu(contextMenu);*/

            if (Process.GetCurrentProcess().ProcessName == "devenv")
            {
                active = false;
            }

            Stream stream = ResManager.GetStream("img/blank.cur");

            if (stream != null)
            {
                blankCursor = new Cursor(stream);
            }
            else
            {
                blankCursor = Cursors.Default;
            }
        }
Example #5
0
        void renderLoop2()
        {
            Graphics g = this.CreateGraphics();

            Renderer.BaseRenderer r = g.GetRenderer();
            while (running)
            {
                try
                {
                    //g.Transform = transform.CreateGdiMatrix();
                    //line?.Render(r);
                    //g.Dispose();
                }
                catch (Exception) { }
                Thread.Sleep(10);
            }
        }
Example #6
0
 void renderFull(Renderer.BaseRenderer g, PBrush brush, float border, float quality, int start, bool simple)
 {
     if (Points.Count == 1)
     {
         g.BeginCircles(brush);
         LPoint pt = Points[0];
         renderPoint(g, pt, border);
         g.EndCircle();
     }
     else if (Points.Count > 1 && !simple)
     {
         g.BeginCircles(brush);
         renderPoint(g, Points[0], border);
         if (start < 1)
         {
             start = 1;
         }
         for (int i = start; i < Points.Count; i++)
         {
             if (Points[i] == null)
             {
                 continue;
             }
             renderPoint(g, Points[i], border);
             renderSegment(g, Points[i - 1], Points[i], quality,
                           border);
             PointF p1 = new PointF(Points[i].X - Points[i].dX * 16,
                                    Points[i].Y - Points[i].dY * 16);
             PointF p2 = new PointF(Points[i].X + Points[i].dX * 16,
                                    Points[i].Y + Points[i].dY * 16);
             //g.DrawLine(Color.Lime, 1, p1, p2, false, true);
         }
         RenderPos = Points.Count - 1;
         g.EndCircle();
     }
     else if (Points.Count > 1)
     {
         for (int i = start + 1; i < Points.Count; i++)
         {
             g.DrawLine(Color.Black, 1, Points[i - 1].ToPointF(), Points[i].ToPointF());
         }
     }
 }
Example #7
0
        public void Draw(Renderer.BaseRenderer r)
        {
            lock (this)
            {
                SizeF pSize = Format.GetPixelSize();

                if (Background != null)
                {
                    Background.Draw(r, Format, Border,
                                    Util.ApplyFilter(BackgroundColor1, this.Filter), Util.ApplyFilter(BackgroundColor2, this.Filter));
                }

                if (ShowDate)
                {
                    r.DrawText(CreationTime.ToLongDateString() + " " + CreationTime.ToShortTimeString(),
                               PBrush.CreateSolid(Util.ApplyFilter(BackgroundColor1, this.Filter)),
                               new RectangleF(Border + 1, Border - 5, 300, 50), 2);
                }

                for (int i = 0; i < lines.Count; i++)
                {
                    if (lines[i] is Forms.TransformableForm)
                    {
                        ((Forms.TransformableForm)lines[i]).RenderTransformed(r);
                    }
                    else if (!(lines[i] is Forms.IBackground))
                    {
                        lines[i].Render(r);
                        if (Configuration.ShowLineBoundingBoxes)
                        {
                            r.DrawRect(Color.Green, 1, lines[i].Bounds);
                        }
                    }
                }
            }
        }
Example #8
0
 void renderPoint(Renderer.BaseRenderer g, LPoint pt, float border)
 {
     g.Circle(pt.X, pt.Y, pt.Rad + border);
 }