protected GardenAreaCreationDialog(string title) : base(title) { TransientFor = MainWindow.GetInstance(); Modal = true; AddLabeledEntry("Name", NameEntry); AddLabeledEntry("Description", DescrEntry); AddEntry(CreatedDateBox); AddEntry(RemovedDateBox); AddControlButton(CancelButton); AddControlButton(CreateButton); GardenDrawingArea.ActiveInstance?.Draw(); CancelButton.Clicked += (object sender, System.EventArgs e) => { Dialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.OkCancel, "Are you sure to discard the changes made?", new { }); int response = dialog.Run(); if (response == (int)ResponseType.Cancel) { } else if (response == (int)ResponseType.Ok) { GardenDrawingArea.ActiveInstance?.NewPoints.Clear(); GardenDrawingArea.ActiveInstance?.Draw(); this.Destroy(); } dialog.Destroy(); }; System.DateTime defaultDate = new System.DateTime(MainWindow.GetInstance().GetYear(), MainWindow.GetInstance().GetMonth(), 1); CreatedDateBox.SetDate(defaultDate); RemovedDateBox.SetDate(defaultDate); ShowAll(); }
public EditPlantingInfoWindow(PlantingInfo plantingInfo, System.Action <PlantingInfo> okAction) : base("Edit planting information") { GardenPlannerSettings settings = GardenPlannerSettings.GetSettings(); AddControlButton("cancel", () => { this.Destroy(); }); AddControlButton("ok", () => { plantingInfo.Count = numberPlantsSpinButton.ValueAsInt; plantingInfo.PlannedPlantingDate = plannedDateBox.GetDate(); plantingInfo.AlreadyPlanted = alreadyPlantedButton.Active; plantingInfo.PlantingDate = actualDateBox.GetDate(); this.Destroy(); okAction.Invoke(plantingInfo); }); numberPlantsSpinButton = new SpinButton(1, settings.MaxPlantingCount, 1); numberPlantsSpinButton.Value = plantingInfo.Count; AddLabeledEntry("Number of plants", numberPlantsSpinButton); plannedDateBox = new DateEntryBox("planned planting date", DateEntryType.MiddleMonthDateEntry); plannedDateBox.SetDate(plantingInfo.PlannedPlantingDate); AddEntry(plannedDateBox); alreadyPlantedButton = new CheckButton("already planted") { Active = plantingInfo.AlreadyPlanted }; alreadyPlantedButton.Clicked += (sender, e) => { actualDateBox.Sensitive = alreadyPlantedButton.Active; }; AddEntry(alreadyPlantedButton); actualDateBox = new DateEntryBox("planted on", DateEntryType.DayDateEntry) { Sensitive = alreadyPlantedButton.Active }; actualDateBox.SetDate(plantingInfo.PlantingDate); AddEntry(actualDateBox); }