Esempio n. 1
0
        /// <summary>
        /// Opent een afbeelding
        /// </summary>
        private void Import(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title  = "Kies een bestand om te openen";
            ofd.Filter = "PNG|*.png|JPEG|*.jpg|Bitmap Image|*.bmp|GIF|*.gif";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                SchetsWin s = new SchetsWin();
                s.MdiParent = this;
                ImageTool i = new ImageTool();
                i.DrawImage(s.schetscontrol, ofd.FileName);

                s.Show();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Leest een XML en maakt er een tekening van
        /// </summary>
        /// <param name="path">De opgeslagen locatie van de XML</param>
        /// <param name="sw">Het window waar de tekening in komt</param>
        public void ReadXML(string path, SchetsWin sw)
        {
            XDocument   xml = XDocument.Load(path);
            ISchetsTool current;

            sw.schetscontrol.Schets.background = new SolidBrush(Color.FromArgb(int.Parse(xml.Descendants("Background").First().Value)));
            sw.schetscontrol.Schets.Schoon();
            sw.schetscontrol.RebuildBitmap(this, new EventArgs());
            foreach (XElement o in xml.Descendants("Object"))
            {
                switch (o.Element("Elements").Element("Type").Value)
                {
                case "SchetsEditor.FullRectangle":
                    current = (ISchetsTool)(new TwoDimensionalTool <FullRectangle>());
                    break;

                case "SchetsEditor.LineRectangle":
                    current = (ISchetsTool)(new TwoDimensionalTool <LineRectangle>());
                    break;

                case "SchetsEditor.Line":
                    current = (ISchetsTool)(new TwoDimensionalTool <Line>());
                    break;

                case "SchetsEditor.LineCircle":
                    current = (ISchetsTool)(new TwoDimensionalTool <LineCircle>());
                    break;

                case "SchetsEditor.FullCircle":
                    current = (ISchetsTool)(new TwoDimensionalTool <FullCircle>());
                    break;

                default:
                    current = current = (ISchetsTool)(new TwoDimensionalTool <Line>());
                    break;
                }
                sw.schetscontrol.penkleur  = Color.FromArgb(int.Parse(o.Element("Color").Value));
                sw.schetscontrol.lijnDikte = int.Parse(o.Element("Elements").Element("Thickness").Value);
                if (o.Descendants("Elements").Count() > 1)
                {
                    current = (ISchetsTool) new PencilTool();
                }

                current.MuisVast(sw.schetscontrol, XElementToPoint(o.Element("Elements"), "PointA"));
                foreach (XElement el in o.Descendants("Elements"))
                {
                    current.MuisDrag(sw.schetscontrol, XElementToPoint(el, "PointB"));
                }
                current.MuisLos(sw.schetscontrol, XElementToPoint(o.Descendants("Elements").Last(), "PointB"));
            }

            //Tekst wordt anders opgeslagen dan de andere tools, dus het wordt ook anders gelezen
            ISchetsTool text;

            foreach (XElement to in xml.Descendants("TextObject"))
            {
                text = new TekstTool();
                sw.schetscontrol.penkleur = Color.FromArgb(int.Parse(to.Element("Color").Value));
                text.MuisVast(sw.schetscontrol, XElementToPoint(to, "PointA"));
                text.MuisLos(sw.schetscontrol, XElementToPoint(to, "PointB"));

                foreach (var x in to.Elements("Text"))
                {
                    text.Letter(sw.schetscontrol, x.Value.ToCharArray()[0]);
                }

                text.Finalize(sw.schetscontrol);
            }

            //Geïmporteerde afbeeldingen worden ook anders opgeslagen dan andere tools
            ImageTool imagetool;

            foreach (XElement i in xml.Descendants("Image"))
            {
                imagetool = new ImageTool();
                imagetool.MuisVast(sw.schetscontrol, XElementToPoint(i, "PointA"));
                imagetool.MuisLos(sw.schetscontrol, XElementToPoint(i, "PointB"));
                imagetool.DrawImage(sw.schetscontrol, i.Element("Path").Value);
            }
        }