public void AddParent(Figuren F) { if (Parent == null) { Parent = F; } }
private void LoadButton_Click(object sender, RoutedEventArgs e) { ResetCanvas(); Figuren tempfiguur = new Figuren(new Rectangle(), "Temp", MyCanvas); tempfiguur.Accept(new Load(AllFiguren, MyCanvas, decorator)); }
public void Visit(Figuren F) { StreamWriter sw = new StreamWriter(@"C:/GrafischeEditor/Save.txt"); int RecusionLevel = 1; foreach (Figuren f in AllFiguren) { if (f.Isingroup == false) { sw.WriteLine("Groep:" + f.GetGroep().Count().ToString()); foreach (Ornament OR in f.GetOrnament()) { sw.WriteLine("ornament " + OR.GetLocation() + " " + OR.GetText() + " "); } sw.WriteLine(f.type); int Left = Convert.ToInt16(Canvas.GetLeft(f.GetShape())); int Top = Convert.ToInt16(Canvas.GetTop(f.GetShape())); int Right = Convert.ToInt16(Canvas.GetRight(f.GetShape())); int Bot = Convert.ToInt16(Canvas.GetBottom(f.GetShape())); sw.WriteLine(Left + " " + Top + " " + Right + " " + Bot); SaveChild(f, sw, RecusionLevel); } } sw.Close(); }
//Voeg nieuw figuur toe aan groep van dit figuur public void Add(Figuren F) { if (this != F && F.Isingroup != true) { Groep.Add(F); F.AddParent(this); F.Isingroup = true; } }
public void Visit(Figuren F) { double moveX = end.X - start.X; double moveY = end.Y - start.Y; if (!SelectedFiguren.Contains(F.Parent)) { F.Move(moveX, moveY); } }
public void Execute() { Ellipse newEllipse = new Ellipse() { Stroke = Brushes.Green, Fill = Brushes.Red, StrokeThickness = 4, Height = 10, Width = 10 }; if (end.X >= start.X) { newEllipse.SetValue(Canvas.LeftProperty, start.X); newEllipse.SetValue(Canvas.RightProperty, end.X); newEllipse.Width = end.X - start.X; } else { newEllipse.SetValue(Canvas.LeftProperty, end.X); newEllipse.SetValue(Canvas.RightProperty, start.X); newEllipse.Width = start.X - end.X; } if (end.Y >= start.Y) { newEllipse.SetValue(Canvas.TopProperty, start.Y); newEllipse.SetValue(Canvas.BottomProperty, end.Y); newEllipse.Height = end.Y - start.Y; } else { newEllipse.SetValue(Canvas.TopProperty, end.Y); newEllipse.SetValue(Canvas.BottomProperty, start.Y); newEllipse.Height = start.Y - end.Y; } Figuren ELlipsenFiguren = new Figuren(newEllipse, "Ellipse", MyCanvas); Allfiguren.Add(ELlipsenFiguren); //MyCanvas.Children.Add(newEllipse); }
public void RemoveFromGroep(Figuren F) { List <Figuren> RemoveFiguren = new List <Figuren>(); foreach (Figuren figuren in Groep) { if (figuren == F) { RemoveFiguren.Add(F); } } foreach (Figuren figuren in RemoveFiguren) { figuren.Parent = null; Groep.Remove(figuren); F.Isingroup = false; } }
public void Visit(Figuren F) { StreamReader sr = new StreamReader(@"C:/GrafischeEditor/Save.txt"); List <string> read = new List <string>(); string line; while ((line = sr.ReadLine()) != null) { line = line.Replace("-", string.Empty); read.Add(line); } string[] result = read.ToArray(); for (readline = 0; readline < result.Length; readline++) { Figuren child = LoadFig(result); } sr.Close(); }
public void Execute() { Rectangle newRectangle = new Rectangle() { Stroke = Brushes.Green, Fill = Brushes.Red, StrokeThickness = 4, }; if (end.X >= start.X) { newRectangle.SetValue(Canvas.LeftProperty, start.X); newRectangle.SetValue(Canvas.RightProperty, end.X); newRectangle.Width = end.X - start.X; } else { newRectangle.SetValue(Canvas.LeftProperty, end.X); newRectangle.SetValue(Canvas.RightProperty, start.X); newRectangle.Width = start.X - end.X; } if (end.Y >= start.Y) { newRectangle.SetValue(Canvas.TopProperty, start.Y); newRectangle.SetValue(Canvas.BottomProperty, end.Y); newRectangle.Height = end.Y - start.Y; } else { newRectangle.SetValue(Canvas.TopProperty, end.Y); newRectangle.SetValue(Canvas.BottomProperty, start.Y); newRectangle.Height = start.Y - end.Y; } Figuren RectangleFiguren = new Figuren(newRectangle, "Rechthoek", MyCanvas); Allfiguren.Add(RectangleFiguren); //MyCanvas.Children.Add(newRectangle); }
private void SaveChild(Figuren F, StreamWriter sw, int Reclvl) { foreach (Figuren fig in F.GetGroep()) { for (int i = 0; i < Reclvl; i++) { sw.Write("-"); } sw.WriteLine("Groep:" + fig.GetGroep().Count().ToString() + " "); for (int i = 0; i < Reclvl; i++) { sw.Write("-"); } foreach (Ornament OR in fig.GetOrnament()) { sw.WriteLine("ornament " + OR.GetLocation() + " " + OR.GetText() + ""); } for (int i = 0; i < Reclvl; i++) { sw.Write("-"); } sw.WriteLine(fig.type); for (int i = 0; i < Reclvl; i++) { sw.Write("-"); } int Left = Convert.ToInt16(Canvas.GetLeft(fig.GetShape())); int Top = Convert.ToInt16(Canvas.GetTop(fig.GetShape())); int Right = Convert.ToInt16(Canvas.GetRight(fig.GetShape())); int Bot = Convert.ToInt16(Canvas.GetBottom(fig.GetShape())); sw.WriteLine(Left + " " + Top + " " + Right + " " + Bot); if (fig.GetGroep().Count != 0) { Reclvl++; } SaveChild(fig, sw, Reclvl); } }
public void Decorate(Figuren F, string text) { Ornament Or = new Ornament(F.Mycanvas, text, "Left", F.MyFigure); F.Ornamenten.Add(Or); }
private Figuren LoadFig(string[] result) { int[] position = new int[4]; Regex regex = new Regex(""); MatchCollection matches; int groupsize = 0; List <string[]> ornamentsloaded = new List <string[]>(); List <Figuren> templist = new List <Figuren>(); while (readline < result.Count()) { regex = new Regex("Groep:(\\d*)"); matches = regex.Matches(result[readline]); foreach (Match M in matches) { groupsize = Convert.ToInt16(M.Groups[1].ToString()); readline++; } while (result[readline].Contains("ornament")) { regex = new Regex("ornament\\s(\\w*)\\s(.*)"); matches = regex.Matches(result[readline]); foreach (Match M in matches) { string loc = M.Groups[1].ToString(); string or = M.Groups[2].ToString(); string[] ornament = { loc, or }; ornamentsloaded.Add(ornament); readline++; } } regex = new Regex("(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)"); if (result.Count() > readline + 1 && regex.IsMatch(result[readline + 1])) { matches = regex.Matches(result[readline + 1]); position[0] = Convert.ToInt16(matches[0].Groups[1].Value); position[1] = Convert.ToInt16(matches[0].Groups[2].Value); position[2] = Convert.ToInt16(matches[0].Groups[3].Value); position[3] = Convert.ToInt16(matches[0].Groups[4].Value); } switch (result[readline]) { case "Rechthoek": Rectangle newRectangle = new Rectangle() { Stroke = Brushes.Green, Fill = Brushes.Red, StrokeThickness = 4, Width = position[2] - position[0], Height = position[3] - position[1], }; //MyCanvas.Children.Add(newRectangle); Figuren RectangleFiguren = new Figuren(newRectangle, "Rechthoek", MyCanvas); RectangleFiguren.SetPosition(position[0], position[1], position[2], position[3]); templist = new List <Figuren> { RectangleFiguren }; foreach (string[] str in ornamentsloaded) { switch (str[0]) { case "Top": decorator = new TopOrnamentDecorator(); break; case "Bot": decorator = new BotOrnamentDecorator(); break; case "Left": decorator = new LeftOrnamentDecorator(); break; case "Right": decorator = new RightOrnamentDecorator(); break; default: break; } commandinvoker.AddOrnament(ref templist, str[1], decorator); } commandinvoker.ExecuteCommands(); for (int c = 0; c < groupsize; c++) { readline += 2; Figuren child = LoadFig(result); int childgroupsize = 0; if (child != null) { RectangleFiguren.Add(child); childgroupsize = child.GetGroupSize(); } } AllFiguren.Add(RectangleFiguren); return(RectangleFiguren); case "Ellipse": Ellipse NewElipse = new Ellipse() { Stroke = Brushes.Green, Fill = Brushes.Red, StrokeThickness = 4, Width = position[2] - position[0], Height = position[3] - position[1], }; //MyCanvas.Children.Add(NewElipse); Figuren ElipseFiguren = new Figuren(NewElipse, "Ellipse", MyCanvas); ElipseFiguren.SetPosition(position[0], position[1], position[2], position[3]); templist = new List <Figuren> { ElipseFiguren }; foreach (string[] str in ornamentsloaded) { switch (str[0]) { case "Top": decorator = new TopOrnamentDecorator(); break; case "Bot": decorator = new BotOrnamentDecorator(); break; case "Left": decorator = new LeftOrnamentDecorator(); break; case "Right": decorator = new RightOrnamentDecorator(); break; default: break; } commandinvoker.AddOrnament(ref templist, str[1], decorator); } commandinvoker.ExecuteCommands(); for (int c = 0; c < groupsize; c++) { readline += 2; Figuren child = LoadFig(result); int childgroupsize = 0; if (child != null) { ElipseFiguren.Add(child); childgroupsize = child.GetGroupSize(); } } AllFiguren.Add(ElipseFiguren); return(ElipseFiguren); default: readline++; break; } } return(null); }
public AddOrnament(Figuren F, string T, IDecorator D) { text = T; Fig = F; decorator = D; }
public void Visit(Figuren F) { F.Resize(start, end); }