Exemple #1
0
        public void drawShape(int x, int y, string className)
        {
            if (className != "")
            {
                unselectAll(cont);
                paintAction();
                // and after creating some shape, it stand selected
                Shape shape = factory.createShape(x, y, className);
                if (shape != null)
                {
                    cont.Add(shape);

                    cont.Last().draw(gr);
                    toolStripMenuItemCounter.Text = cont.Count() + "";  // счетчик фигур на форме, отображается слева вверху
                }
            }
        }
Exemple #2
0
        public override void load(StreamReader sr)
        {
            string[] data = sr.ReadLine().Split();
            int      n    = Int32.Parse(data[0]);

            brush.setColor(System.Drawing.ColorTranslator.FromHtml(data[1]));
            brush.setBrushW(Int32.Parse(data[2]));
            x     = Int32.Parse(data[3]);
            y     = Int32.Parse(data[4]);
            R     = Double.Parse(data[5]);
            angle = float.Parse(data[6]);


            FactoryShape factory   = new FactoryShape();
            string       className = "";
            char         ch        = (char)sr.Read();

            for (int i = 0; i < n; i++)
            {
                while (ch != ' ')
                {
                    className += ch;
                    ch         = (char)sr.Read();
                }

                Shape shape = factory.createShape(className);
                shape.load(sr);
                if (shape.brush.isSelect())
                {
                    shape.brush.select();
                }
                calcWH((VShape)shape);
                className = "";
                if (i < n - 1)
                {
                    ch = (char)sr.Read();
                }
                children.Add(shape);
            }
        }
Exemple #3
0
        public void loadShapes(Iterator <Shape> it)
        {
            StreamReader sr = new StreamReader(Form1.mainPath, System.Text.Encoding.Default);

            try {
                int n = Int32.Parse(sr.ReadLine());
                if (n > 0)
                {
                    Clear();
                    FactoryShape factory   = new FactoryShape();
                    string       className = "";
                    char         ch        = (char)sr.Read();
                    for (int i = 0; i < n; i++)
                    {
                        while (ch != ' ')
                        {
                            className += ch;
                            ch         = (char)sr.Read();
                        }
                        Shape shape = factory.createShape(className);

                        if (shape != null)
                        {
                            shape.load(sr);
                            className = "";
                            ch        = (char)sr.Read();
                            it.addNext(shape);
                        }
                    }
                }
                sr.Close();
            } catch (Exception e) {
                //
            } finally {
                sr.Dispose();
            }

            notifyAll();
        }