private void bt_SaveShape_Click(object sender, RoutedEventArgs e) { try { byte r = Byte.Parse(tb_RedValue.Text); byte g = Byte.Parse(tb_GreenValue.Text); byte b = Byte.Parse(tb_BlueValue.Text); int w = Int32.Parse(tb_Width.Text); int h = Int32.Parse(tb_Height.Text); Shape shape = sm.CreateNewShape(); string name = sm.SetFinalShapeName(shape, w, h); sm.WriteShapeToDB(name, r, g, b, w, h); lb_ShapeTemplates.Items.Clear(); lb_ColourTemplates.Items.Clear(); clrm.LoadColors(); sm.LoadShapes(); } catch (FormatException) { MessageBox.Show("Error occured - Please provide correct values before choosing the shape."); } catch (OverflowException) { MessageBox.Show("Error occured - The value of a color is incorrect. Value must be between 0 and 255"); } catch (Exception ex) { MessageBox.Show("Error occured - " + ex.Message); } }
public MainWindow() { InitializeComponent(); sm = new ShapeManager(this); cm = new CanvasManager(this); clrm = new ColorManager(this); cb_Shapes.ItemsSource = new ShapeManager(this).ListShapes; clrm.LoadColors(); sm.LoadShapes(); cm.LoadCanvasses(); }