/** * Selection of location for ornament in relation to the selected figures */ private void OrnamentTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { switch (OrnamentLocation) { case "Top": decorator = new OrnamentDecTop(); break; case "Bot": decorator = new OrnamentDecBot(); break; case "Left": decorator = new OrnamentDecLeft(); break; case "Right": decorator = new OrnamentDecRight(); break; default: break; } Invoke_Pat.AddOrnament(ref FigsSel, OrnamentTextBox.Text, decorator); Invoke_Pat.ExecuteCommands(); OrnamentTextBox.Visibility = Visibility.Hidden; OrnamentLocationBox.Visibility = Visibility.Hidden; } }
/** * Add Ornament on a Figure */ public void AddOrnament(ref List <Component> FS, string Or, IDec Dec) { foreach (Figure F in FS) { DrwOrnament AddOr = new DrwOrnament(F, Or, Dec); if (Counter <= ComI.Count()) { ComI.Insert(Counter, AddOr); } else { ComI.Add(AddOr); } Counter++; } }
public DecDecoratorFirst(IDec dec) { _dec = dec; }
public DecDecoratorTwo(IDec dec) { _dec = dec; }
/* * Ornament consist out of a Txt, Figure and Decorator */ public DrwOrnament(Figure F, string T, IDec D) { Fig = F; Txt = T; Dec = D; }
private Component LoadFig(string[] result) { int[] Pos = new int[4]; Regex regex = new Regex(""); MatchCollection matches; int GroupSize = 0; List <string[]> OrList = new List <string[]>(); List <Component> templist = new List <Component>(); while (RL < result.Count()) { regex = new Regex("ComponentList:(\\d*)"); matches = regex.Matches(result[RL]); foreach (Match M in matches) { GroupSize = Convert.ToInt16(M.Groups[1].ToString()); RL++; } while (result[RL].Contains("Ornament")) { regex = new Regex("Ornament\\s(\\w*)\\s(.*)"); matches = regex.Matches(result[RL]); foreach (Match M in matches) { string loc = M.Groups[1].ToString(); string or = M.Groups[2].ToString(); string[] Ornament = { loc, or }; OrList.Add(Ornament); RL++; } } regex = new Regex("(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)"); //Point P = new Point(); if (result.Count() > RL + 1 && regex.IsMatch(result[RL + 1])) { matches = regex.Matches(result[RL + 1]); Pos[0] = Convert.ToInt16(matches[0].Groups[1].Value); Pos[1] = Convert.ToInt16(matches[0].Groups[2].Value); Pos[2] = Convert.ToInt16(matches[0].Groups[3].Value); Pos[3] = Convert.ToInt16(matches[0].Groups[4].Value); } switch (result[RL]) { case "Rectangle": Point P = new Point(); P.X = Pos[2] - Pos[0]; P.Y = Pos[3] - Pos[1]; Rectangle newRectangle = new Rectangle() { Stroke = Brushes.DarkGray, Fill = Brushes.Blue, StrokeThickness = 4, Width = P.X, Height = P.Y, }; Component RecFig = new Figure(newRectangle, "Rectangle", DepPat); RecFig.SetPosition(P); templist = new List <Component> { RecFig }; foreach (string[] str in OrList) { switch (str[0]) { case "Top": Dec = new OrnamentDecTop(); break; case "Bot": Dec = new OrnamentDecBot(); break; case "Left": Dec = new OrnamentDecLeft(); break; case "Right": Dec = new OrnamentDecRight(); break; default: break; } ComI.AddOrnament(ref templist, str[1], Dec); } ComI.ExecuteCommands(); for (int c = 0; c < GroupSize; c++) { RL += 2; Component child = LoadFig(result); //int childgroupsize = 0; //if (child != null) //{ // RecFig.addGroup(child); // childgroupsize = child.getGroupS(); //} } Figs_All.Add(RecFig); return(RecFig); case "Ellipse": Point p = new Point(); p.X = Pos[2] - Pos[0]; p.Y = Pos[3] - Pos[1]; Ellipse NewElipse = new Ellipse() { Stroke = Brushes.DarkGray, Fill = Brushes.Blue, StrokeThickness = 4, Width = p.X, Height = p.Y, }; Component EllFigs = new Figure(NewElipse, "Ellipse", DepPat); EllFigs.SetPosition(p); templist = new List <Component> { EllFigs }; foreach (string[] str in OrList) { switch (str[0]) { case "Top": Dec = new OrnamentDecTop(); break; case "Bot": Dec = new OrnamentDecBot(); break; case "Left": Dec = new OrnamentDecLeft(); break; case "Right": Dec = new OrnamentDecRight(); break; default: break; } ComI.AddOrnament(ref templist, str[1], Dec); } ComI.ExecuteCommands(); for (int c = 0; c < GroupSize; c++) { RL += 2; Component child = LoadFig(result); //int childgroupsize = 0; //if (child != null) //{ // EllFigs.Add(child); // childgroupsize = child.getGroupS(); //} } Figs_All.Add(EllFigs); return(EllFigs); default: RL++; break; } } return(null); }
public Load(List <Component> FA, Canvas C, IDec D) { Figs_All = FA; DepPat = C; Dec = D; }