Пример #1
0
        private void panelcontrol_MouseUp(object sender, MouseEventArgs e)
        {
            End.X = e.X;
            End.Y = e.Y;
            g     = panelcontrol.CreateGraphics();
            DiagramFactory fac  = new DfdFactory();
            ShapeInfo      temp = new ShapeInfo(Start, End);
            DiagramFactory fac2 = new FCFactory();
            CommonGraphics gdi1 = new GdiPlusCommonGraphics(g, panelcontrol);

            //chon graphic
            if (GraphicType == 0)
            {
                gdi = gdi1;
            }
            else
            {
                try
                {
                    Surface s = new Win32Surface(g.GetHdc());
                    Context c = new Context(s);
                    gdi = new CairoCommonGraphics(c);
                }catch (System.DllNotFoundException)
                {
                    GraphicType = 0;
                    MessageBox.Show("DllNotFoundException", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            //chon hinh ve
            switch (ShapeType)
            {
            case 0:
                Shape line = new Line(Start, End);
                line.draw(gdi);

                break;

            case 1:
                Shape rect = new Rect(Start, End);
                rect.draw(gdi);
                break;

            case 2:
                Shape eclip = new Eclip(Start, End);
                eclip.draw(gdi);
                break;

            case 3:

                ABlock startblock = fac.createStartBlock(temp);
                startblock.draw(gdi);
                break;

            case 4:
                ABlock input = fac.createInputBlock(temp);
                input.draw(gdi);
                break;

            case 5:
                ABlock startbl = fac2.createStartBlock(temp);
                startbl.draw(gdi);
                break;

            case 6:
                ABlock inputbl = fac2.createInputBlock(temp);
                inputbl.draw(gdi);
                break;

            case 7:
                Shape star = new Star(Start, End);
                star.draw(gdi);
                break;

            default:
                break;
            }
        }
Пример #2
0
        private void pnCanvas_click(object sender, MouseEventArgs e)
        {
            Point       point = new Point(e.X, e.Y);
            RadioButton checkedButton;
            Shape       shape = null;

            if (pnShape.Enabled)
            {
                checkedButton = pnShape.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);
                switch (checkedButton.Text)
                {
                case "Line":
                    shape = new Line(new ShapeInfo(point, new Point(e.X + LineLength, e.Y)));
                    break;

                case "Rectangle":
                    shape = new Rect(new ShapeInfo(point, RectWidth, RectHeight));
                    break;

                case "Round":
                    shape = new Round(new ShapeInfo(point, RoundRadius, RoundRadius));
                    break;

                case "Star":
                    shape = new Star(new ShapeInfo(point));
                    break;
                }
            }
            else
            {
                checkedButton = pnBlock.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);
                switch (checkedButton.Text)
                {
                case "Start":
                    shape = diagram.factory.createStartBlock(new ShapeInfo(point));
                    break;

                case "Input":
                    shape = diagram.factory.createInputBlock(new ShapeInfo(point));
                    break;
                }
            }

            if (pnShape.Enabled)
            {
                if (cbHighlight.Checked)
                {
                    shape = new HighlightShape(shape);
                }
                if (cbShadow.Checked)
                {
                    shape = new ShadowShape(shape);
                }

                shapes.Add(shape);
            }
            else
            {
                diagram.addBlock((Block)shape);
            }
            isPainting = true;
            pnCanvas.Invalidate();
        }