コード例 #1
0
        /// <summary>
        /// Shows the planting info window for varities that already have been added to a planting.
        /// </summary>
        /// <param name="plantingInfo">Planting info.</param>
        /// <param name="action">Action.</param>
        /// <param name="planting">Planting.</param>
        /// <param name="varietyName">Variety name.</param>
        public static void ShowPlantingInfoWindow(PlantingInfo plantingInfo, System.Action <PlantingInfo> action, Planting planting, string varietyName)
        {
            EditPlantingInfoWindow window = new EditPlantingInfoWindow(plantingInfo, action);

            window.Title = $"Add {varietyName} to {planting.Name}";
            window.ShowAll();
        }
コード例 #2
0
        private void SetUpVarieties(Planting planting)
        {
            string[] labels = new string[Varieties.Count];
            keys = new VarietyKeySeq[Varieties.Count];
            var en = Varieties.Keys.GetEnumerator();

            for (int i = 0; en.MoveNext() && i < Varieties.Count; i++)
            {
                keys[i]   = en.Current;
                labels[i] = GardenData.LoadedData.GetVariety(en.Current).Name + " x " + Varieties[en.Current].Count;
            }
            VarityBox = new ComboBoxEntry(labels);


            VarityBox.Changed += (object sender, EventArgs e) =>
            {
                VarietyRemoveButton.Sensitive = VarityBox.Active >= 0;
                VarietyEditButton.Sensitive   = VarityBox.Active >= 0;
            };


            if (VarietiesLabeledHBox != null)
            {
                VarietiesInnerHBox.Remove(VarietyRemoveButton);
                VarietiesInnerHBox.Remove(VarietyEditButton);
                RemoveLabeledEntry(VarietiesLabeledHBox);
            }

            VarietyRemoveButton           = new Button("Remove");
            VarietyRemoveButton.Sensitive = false;

            VarietyRemoveButton.Clicked += (object sender, EventArgs e) =>
            {
                Varieties.Remove(keys[VarityBox.Active]);
                SetUpVarieties(planting);
            };

            VarietyEditButton           = new Button("Edit");
            VarietyEditButton.Sensitive = false;
            VarietyEditButton.Clicked  += (sender, e) =>
            {
                EditPlantingInfoWindow.ShowPlantingInfoWindow(Varieties[keys[VarityBox.Active]], (plantingInfo) =>
                {
                    GardenDrawingArea area = GardenDrawingArea.ActiveInstance;
                    area.Draw();
                    MainWindow.GetInstance().ShowAreaSelectionInfo(area.SelectedArea);
                }, planting, GardenData.LoadedData.GetVariety(keys[VarityBox.Active]).Name);
            };

            VarietiesInnerHBox = new HBox();
            VarietiesInnerHBox.Add(VarityBox);

            VarietiesInnerHBox.Add(VarietyEditButton);
            VarietiesInnerHBox.Add(VarietyRemoveButton);
            VarietiesLabeledHBox = AddLabeledEntry("Varieties", VarietiesInnerHBox);
            ShowAll();
        }