Exemplo n.º 1
0
        private void GraffitiForm_Paint(object sender, PaintEventArgs e)
        {
            drawRulers();
            if (this.pQueue.Count == 0)
            {
                return;
            }
            object pfirst = this.pQueue.Peek();

            foreach (object p in this.pQueue)
            {
                if (p is Point)
                {
                    if (pfirst is Point)
                    {
                        DrawLine(this.lineColor, (Point)pfirst, (Point)p);
                    }
                    pfirst = p;
                }
                if (p is Rectangle)
                {
                    Rectangle rect = (Rectangle)p;
                    DrawRectangle(this.lineColor, new Point(rect.X, rect.Y), rect.Size);
                }
                if (p is Model.PointImage)
                {
                    Model.PointImage pi = (Model.PointImage)p;
                    drawImage(pi.Pic, pi.Rect);
                }
            }
        }
Exemplo n.º 2
0
        private void insertPicbutton_Click(object sender, EventArgs e)
        {
            OpenFileDialog openImageDialog = new OpenFileDialog();

            openImageDialog.Filter = "图片|*.jpg";
            if (openImageDialog.ShowDialog() == DialogResult.OK)
            {
                Image     img  = Image.FromFile(openImageDialog.FileName);
                Graphics  gr   = CreateGraphics();
                Rectangle rect = Rectangle.Ceiling(gr.VisibleClipBounds);
                foreach (object p in this.pQueue)
                {
                    if (p is Rectangle)
                    {
                        rect = (Rectangle)p;
                    }
                }
                gr.DrawImage(img, rect);
                Model.PointImage pi = new Model.PointImage();
                pi.Pic  = img;
                pi.Rect = rect;
                pQueue.Enqueue(pi);
            }
        }