Exemplo n.º 1
0
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            if (COG == null)
            {
                foreach (PointF pt in pts.ToArray())
                   g.FillRectangle(Brushes.Black, new RectangleF(pt.X - 2, pt.Y - 2, 4, 4));
            }
            else
            {
                System.Drawing.Drawing2D.GraphicsPath Path = new System.Drawing.Drawing2D.GraphicsPath();
                Path.AddClosedCurve((PointF[])pts.ToArray(),float.Parse(text_objTension.Text));
                g.DrawPath(Pens.Black, Path);

                g.FillEllipse(Brushes.Red, new RectangleF(COG.Value.X - 2, COG.Value.Y - 2, 4, 4));
                g.FillEllipse(Brushes.Blue, new RectangleF(Desc.Centroid.X - 2, Desc.Centroid.Y - 2, 4, 4));
            }
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // GraphicsPathの作成
            System.Drawing.Drawing2D.GraphicsPath path =
                new System.Drawing.Drawing2D.GraphicsPath();
            //円を描く(ホームボタン)
            path.AddEllipse(new Rectangle(3, 3, 57, 57));
            hombtn.Region = new Region(path);  //コントロールの形を変更

            //ボタンを描くための座標を指定
            Point[] points =
            {
                new Point(9,   3),
                new Point(3,  10),
                new Point(3,  49),
                new Point(10, 55),
                new Point(49, 55),
                new Point(55, 49),
                new Point(55, 10),
                new Point(49, 3)
            };

            //GraphicsPathの作成
            System.Drawing.Drawing2D.GraphicsPath path1 =
                new System.Drawing.Drawing2D.GraphicsPath();

            //point内の各点を曲線で結ぶ
            path1.AddClosedCurve(points, 0.2F);

            //各ボタンコントロールの形を変更
            btn1.Region  = new Region(path1);
            btn2.Region  = new Region(path1);
            btn3.Region  = new Region(path1);
            btn4.Region  = new Region(path1);
            btn5.Region  = new Region(path1);
            btn6.Region  = new Region(path1);
            btn7.Region  = new Region(path1);
            btn8.Region  = new Region(path1);
            btn9.Region  = new Region(path1);
            btn10.Region = new Region(path1);
            btn11.Region = new Region(path1);
            btn12.Region = new Region(path1);

            //各Labelの親コントロールをPictureBox1とする
            pictureBox1.Controls.Add(label1);
            pictureBox1.Controls.Add(label2);
            pictureBox1.Controls.Add(label3);
            pictureBox1.Controls.Add(label4);
            pictureBox1.Controls.Add(label5);
            pictureBox1.Controls.Add(label6);
            pictureBox1.Controls.Add(label7);
            pictureBox1.Controls.Add(label8);
            pictureBox1.Controls.Add(label9);
            pictureBox1.Controls.Add(label10);
            pictureBox1.Controls.Add(label11);
            pictureBox1.Controls.Add(label12);

            //各ボタンの親コントロールをPictureBox1とする
            pictureBox1.Controls.Add(btn1);
            pictureBox1.Controls.Add(btn2);
            pictureBox1.Controls.Add(btn3);
            pictureBox1.Controls.Add(btn4);
            pictureBox1.Controls.Add(btn5);
            pictureBox1.Controls.Add(btn6);
            pictureBox1.Controls.Add(btn7);
            pictureBox1.Controls.Add(btn8);
            pictureBox1.Controls.Add(btn9);
            pictureBox1.Controls.Add(btn10);
            pictureBox1.Controls.Add(btn11);
            pictureBox1.Controls.Add(btn12);
        }
Exemplo n.º 3
0
        void mInkPicture_NewPackets(object sender, InkCollectorNewPacketsEventArgs e)
        {
            //Console.WriteLine("mInkPicture_NewPackets PacketCount={0}", e.PacketCount);
            //if (this.DialogResult != System.Windows.Forms.DialogResult.None) return;
            if (dlgRes != System.Windows.Forms.DialogResult.None) return;

            float[] intersections = e.Stroke.SelfIntersections;
            if (intersections.Length > 0)
            {
                String msg = "SelfIntersections=";
                foreach (float f in intersections)
                {
                    msg += f + " ";
                }
                Console.WriteLine(msg);

                try
                {
                    int ipt1 = (int)Math.Round(intersections[0], 0);
                    int ipt2 = (int)Math.Round(intersections[intersections.Length - 1], 0);
                    int count = ipt2 - ipt1;
                    Point[] pts = e.Stroke.GetPoints();
                    Point[] ptPath = new Point[count];
                    //Graphics g = Graphics.FromImage(mBgBmp);
                    Graphics g = mInkPicture.CreateGraphics();
                    mInkPicture.Renderer.InkSpaceToPixel(g, ref pts);
                    Array.Copy(pts, ipt1, ptPath, 0, count);
                    Pen p = new Pen(Color.Red);
                    g.DrawPolygon(p, ptPath);

                    dlgRes = MessageBox.Show("Clip and Copy this region?", "Selection", MessageBoxButtons.YesNoCancel);
                    if (dlgRes == System.Windows.Forms.DialogResult.Yes)
                    {
                        System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                        path.AddClosedCurve(ptPath);
                        if (mSelRegion != null) mSelRegion.Dispose();
                        mSelRegion = new Region(path);
                        mRegionPath = ptPath;
                    }
                    g.Dispose();

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }
            }
        }