Exemple #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 PointImage)
                {
                    PointImage pi = (PointImage)p;
                    drawImage(pi.Pic, pi.Rect);
                }
            }
        }
Exemple #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);
                PointImage pi = new PointImage();
                pi.Pic  = img;
                pi.Rect = rect;
                pQueue.Enqueue(pi);
            }
        }