public static void ShowGardenCreationDialog(List <GardenPoint> points, Action <Garden.Garden> action) { GardenCreationDialog dialog = new GardenCreationDialog(); dialog.CreateButton.Clicked += (object sender, System.EventArgs e) => { Garden.Garden area = new Garden.Garden(dialog.NameEntry.Text, dialog.DescrEntry.Text); dialog.SetValuesForCreation(area, points); action(area); GardenDrawingArea.ActiveInstance?.Draw(); dialog.Destroy(); }; }
public static GardenData TestData() { GardenData Data = new GardenData("testdata"); var zwiebelgewaechse = new PlantFamily("Zwiebelgewaechse", ""); Data.AddFamily("zwiebelgewaechse", zwiebelgewaechse); var knoblauch = new Plant("Knoblauch", ""); knoblauch.FeederType = FeederType.Medium; knoblauch.ScientificName = "allium sativum"; zwiebelgewaechse.AddPlant("knoblauch", knoblauch); var morado = new PlantVariety("Morado", "rotviolett, aus Spanien, geeignet für Herbstpflanzung, bildet Brutzwiebeln"); morado.SetColor(new Cairo.Color(0.9, 0.9, 0.9)); knoblauch.AddVariety("morado", morado); var vallelado = new PlantVariety("Vallelado", "bla"); vallelado.SetColor(new Cairo.Color(0.9, 0.9, 0.9)); knoblauch.AddVariety("vallelado", vallelado); var nachtschattengew = new PlantFamily("Nachtschattengewächse", ""); Data.AddFamily("nachtschattengewaechse", nachtschattengew); var kartoffeln = new Plant("Kartoffel", ""); kartoffeln.SetColor(new Cairo.Color(0.2, 0.8, 0.8)); nachtschattengew.AddPlant("kartoffel", kartoffeln); var bed1 = new Garden.Garden("Omas Garten", "Alte Garten von Oma", 2000, 1, 2000, 1); var bed2 = new Garden.Garden("Hauptstraßengarten", "Alte Garten von Oma", 2000, 1, 2000, 1); Data.AddGarden("oma_garten", bed1); Data.AddGarden("hptstr_garten", bed2); bed1.Shape.AddPoint(new GardenPoint(0, 0)); bed1.Shape.AddPoint(new GardenPoint(0, 200)); bed1.Shape.AddPoint(new GardenPoint(300, 200)); bed1.Shape.AddPoint(new GardenPoint(300, 0)); bed1.Shape.FinishPoints(); var compostArea = new GardenArea("Kompost", "hier wurde Kompost angewendet", 2000, 1, 2010, 6); compostArea.Shape.AddPoint(new GardenPoint(100, 100)); compostArea.Shape.AddPoint(new GardenPoint(300, 100)); compostArea.Shape.AddPoint(new GardenPoint(300, 200)); compostArea.Shape.AddPoint(new GardenPoint(100, 200)); compostArea.Shape.FinishPoints(); bed1.AddMethodArea("compost", compostArea); var plantingArea = new Planting("Planting", "hier wurde was gepflanzt", 2000, 1, 2010, 6); plantingArea.Shape.AddPoint(new GardenPoint(400, 400)); plantingArea.Shape.AddPoint(new GardenPoint(500, 400)); plantingArea.Shape.AddPoint(new GardenPoint(500, 500)); plantingArea.Shape.AddPoint(new GardenPoint(400, 500)); plantingArea.Shape.FinishPoints(); bed1.AddPlanting("planting", plantingArea); plantingArea.AddVariety(morado, new PlantingInfo() { Count = 3 }); plantingArea.AddVariety(vallelado, new PlantingInfo() { Count = 2 }); //string s = Newtonsoft.Json.JsonConvert.SerializeObject(Data, Newtonsoft.Json.Formatting.Indented); return(Data); }
public GardenDrawingArea(Garden.Garden garden, SpinButton zoomButton, int width = 800, int height = 600) { this.Garden = garden; this.SetSizeRequest(width, height); this.AddEvents((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask | Gdk.EventMask.AllEventsMask)); this.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { if (args.Event.Button == 1) { if (MainWindow.GetInstance().AreaNewButton.Active) { UndoSelection(); GardenPoint gridPoint = SnapToGrid((int)(args.Event.X), (int)(args.Event.Y)); NewPoints.Add(gridPoint); Draw(); } else if (CheckAreaClick((int)args.Event.X, (int)args.Event.Y)) { MakeSelection(); } else { UndoSelection(); } } else if (args.Event.Button == 3 || args.Event.Button == 2) { if (CheckAreaClick((int)args.Event.X, (int)args.Event.Y) && SelectedArea != null) { MakeSelection(); MenuItem item1 = new MenuItem("Set created date"); item1.Activated += (sender, e) => DateInputWindow.ShowWindow("Set created date", (int y, int m) => { SelectedArea.SetCreated(y, m); }); MenuItem item2 = new MenuItem("Set removed date"); item2.Activated += (sender, e) => DateInputWindow.ShowWindow("Set removed date", (int y, int m) => { SelectedArea.SetRemoved(y, m); }); MenuItem item3 = new MenuItem("Edit area"); item3.Activated += (sender, e) => MainWindow.GetInstance().AreaEditButton.Activate(); MenuItem item4 = new MenuItem("Remove area"); item4.Activated += (sender, e) => MainWindow.GetInstance().AreaDeleteButton.Activate(); MenuItem item5 = new MenuItem("Edit point"); item5.Sensitive = SelectedPoint != null; item5.Activated += (sender, e) => PointInputWindow.ShowWindow("Set new point", Math.Min(SelectedPoint.X, SelectedPoint.Y) - 100, Math.Max(SelectedPoint.X, SelectedPoint.Y) + 100, SelectedPoint.X, SelectedPoint.Y, (int x, int y) => { SelectedArea.Shape.ModPoint(SelectedPoint, new GardenPoint(x, y), true); SelectedPoint = null; Draw(); }); Menu menu = new Menu() { item1, item2, item3, item4, item5 }; menu.AttachToWidget(this, null); menu.ShowAll(); menu.Popup(); } } }; zoomButton.ValueChanged += (object sender, System.EventArgs e) => { Zoom = zoomButton.Value; if (IsDrawable) { Draw(); } }; this.QueryTooltip += (object o, QueryTooltipArgs args) => { System.Console.WriteLine("tooltip drawing area"); }; zoomButton.QueryTooltip += (object o, QueryTooltipArgs args) => { System.Console.WriteLine("tooltip zoom button"); }; }
public void AddGarden(string key, Garden garden) { Gardens.Add(key, garden); garden.ID = key; }