public FormPickComponent(string title, IEnumerable <IShipComponentType> components1, string group2Title = null, IEnumerable <IShipComponentType> components2 = null) : this() { this.Text = title; this.Choice = null; populateWhith(components1); if (components1.Any() && components2 != null && components2.Any()) { this.componentPanel.SetFlowBreak(this.componentPanel.Controls[this.componentPanel.Controls.Count - 1], true); var groupTitle = new Label(); var dummy = new Label(); this.componentPanel.Controls.Add(groupTitle); this.componentPanel.Controls.Add(dummy); groupTitle.AutoSize = true; this.componentPanel.SetFlowBreak(groupTitle, true); groupTitle.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6); groupTitle.Name = "groupTitle"; groupTitle.Size = new System.Drawing.Size(149, 13); groupTitle.Text = group2Title; dummy.Margin = new System.Windows.Forms.Padding(0); dummy.Name = "dummy"; dummy.Size = new System.Drawing.Size(0, 0); } if (components2 != null) { populateWhith(components2); } this.Font = SettingsWinforms.Get.FormFont; }
private void actionButton_Click(object sender, EventArgs e) { var context = LocalizationManifest.Get.CurrentLanguage["FormDesign"]; Action <DesignInfo> disbandDesign = x => this.controller.DisbandDesign(this.data); Action <DesignInfo> keepDesign = x => this.controller.KeepDesign(this.data); Action <DesignInfo> refitDesign = x => this.controller.RefitDesign(this.data, x); var formatter = new ThousandsFormatter(); var refitOptions = new IShipComponentType[] { new ShipComponentType <DesignInfo>(context["disbandDesign"].Text(), global::Stareater.Properties.Resources.cancel, null, disbandDesign), new ShipComponentType <DesignInfo>(context["keepDesign"].Text(), global::Stareater.Properties.Resources.start, null, keepDesign) }.Concat( this.controller.RefitCandidates(this.data).Where(x => x.Constructable).Select(x => new ShipComponentType <DesignInfo>( x.Name + Environment.NewLine + context["refitCost"].Text() + ": " + formatter.Format(this.controller.RefitCost(this.data, x)), ImageCache.Get[x.ImagePath], x, refitDesign ))); using (var form = new FormPickComponent(context["refitTitle"].Text(), refitOptions)) form.ShowDialog(); this.makeNameText(); }
private void pickShieldAction_Click(object sender, EventArgs e) { Action <ShieldInfo> selectShield = x => this.controller.Shield = x; var shields = new IShipComponentType[] { new ShipComponentType <ShieldInfo>(this.context["unselectComponent"].Text(), null, null, selectShield) }.Concat( this.controller.Shields().Select(x => new ShipComponentType <ShieldInfo>( x.Name, ImageCache.Get[x.ImagePath], x, selectShield ))); using (var form = new FormPickComponent(this.context["shieldPickTitle"].Text(), shields)) form.ShowDialog(); if (this.controller.Shield != null) { this.pickShieldAction.Text = this.controller.Shield.Name; this.shieldImage.Visible = true; this.shieldImage.Image = ImageCache.Get[this.controller.Shield.ImagePath]; } else { this.pickShieldAction.Text = this.context["noShield"].Text(); this.shieldImage.Visible = false; this.shieldImage.Image = null; } updateInfos(); }