public mPlayground() { screen = new mScreen(width, height); layers = new List <mCanvas>(); layers.Add(new mCanvas(width, height)); commandHandler = new CommandHandler(); shapeTool = new ShapeDrawTool(this); tempFont = ContentHandler.Instance.Content.Load <SpriteFont>("TempFont"); //UI drawButton = new UIButton(5, 675, 80, 40); drawButton.Text = "Draw"; drawButton.Color = Color.LightBlue; drawButton.BorderColor = Color.LightGreen; drawButton.Border = true; drawButton.OnPress = () => { shapeTool.Reset(); shapeTool = new ShapeDrawTool(this); drawButton.Border = true; selectButton.Border = false; moveButton.Border = false; transformButton.Border = false; }; selectButton = new UIButton(90, 675, 80, 40); selectButton.Text = "Select"; selectButton.Color = Color.LightBlue; selectButton.BorderColor = Color.LightGreen; selectButton.OnPress = () => { shapeTool.Reset(); shapeTool = new ShapeSelectTool(this); drawButton.Border = false; selectButton.Border = true; moveButton.Border = false; transformButton.Border = false; }; moveButton = new UIButton(175, 675, 80, 40); moveButton.Text = "Move"; moveButton.Color = Color.LightBlue; moveButton.BorderColor = Color.LightGreen; moveButton.OnPress = () => { shapeTool.Reset(); shapeTool = new ShapeMoveTool(this); drawButton.Border = false; selectButton.Border = false; moveButton.Border = true; transformButton.Border = false; }; transformButton = new UIButton(260, 675, 80, 40); transformButton.Text = "Resize"; transformButton.Color = Color.LightBlue; transformButton.BorderColor = Color.LightGreen; transformButton.OnPress = () => { shapeTool.Reset(); shapeTool = new ShapeTransformTool(this); drawButton.Border = false; selectButton.Border = false; moveButton.Border = false; transformButton.Border = true; }; saveButton = new UIButton(1195, 675, 80, 40); saveButton.Text = "Save"; saveButton.Color = Color.LightBlue; saveButton.BorderColor = Color.LightGreen; saveButton.OnPress = savePlayground; openButton = new UIButton(1110, 675, 80, 40); openButton.Text = "Open"; openButton.Color = Color.LightBlue; openButton.BorderColor = Color.LightGreen; openButton.OnPress = loadPlayground; }
private void canvas1_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { grid1.ReleaseMouseCapture(); if (selectedTool != null && selectedTool.Start != null && selectedTool.Segments != null) { Environment.Instance.Segments.AddRange(selectedTool.Segments); snapshot.Clear(); selectedTool.finalize(); selectedTool = (IShapeTool)Activator.CreateInstance(selectedTool.GetType()); } }
private void button5_Click(object sender, RoutedEventArgs e) { selectedTool = new EllipseTool(); }
private void button4_Click(object sender, RoutedEventArgs e) { selectedTool = new RectangleTool(); }
private void button3_Click(object sender, RoutedEventArgs e) { selectedTool = new LineTool(); }