///<summary> Add environment sub-panel, including tooltips </summary> private static void AddSubPanelEnvironment(Panel p) { string flux_tooltip = Lib.BuildString ( "<align=left />" + String.Format("<b>{0,-14}\t{1,-15}\t{2}</b>\n", "Source", "Flux", "Temp"), String.Format("{0,-14}\t{1,-15}\t{2}\n", "solar", env_analyzer.solar_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.solar_flux) : "none", Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.solar_flux))), String.Format("{0,-14}\t{1,-15}\t{2}\n", "albedo", env_analyzer.albedo_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.albedo_flux) : "none", Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.albedo_flux))), String.Format("{0,-14}\t{1,-15}\t{2}\n", "body", env_analyzer.body_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.body_flux) : "none", Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.body_flux))), String.Format("{0,-14}\t{1,-15}\t{2}\n", "background", Lib.HumanReadableFlux(Sim.BackgroundFlux()), Lib.HumanReadableTemp(Sim.BlackBodyTemperature(Sim.BackgroundFlux()))), String.Format("{0,-14}\t\t{1,-15}\t{2}", "total", Lib.HumanReadableFlux(env_analyzer.total_flux), Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.total_flux))) ); string atmosphere_tooltip = Lib.BuildString ( "<align=left />", String.Format("{0,-14}\t<b>{1}</b>\n", "breathable", Sim.Breathable(env_analyzer.body) ? "yes" : "no"), String.Format("{0,-14}\t<b>{1}</b>\n", "pressure", Lib.HumanReadablePressure(env_analyzer.body.atmospherePressureSeaLevel)), String.Format("{0,-14}\t<b>{1}</b>\n", "light absorption", Lib.HumanReadablePerc(1.0 - env_analyzer.atmo_factor)), String.Format("{0,-14}\t<b>{1}</b>", "gamma absorption", Lib.HumanReadablePerc(1.0 - Sim.GammaTransparency(env_analyzer.body, 0.0))) ); string shadowtime_str = Lib.HumanReadableDuration(env_analyzer.shadow_period) + " (" + (env_analyzer.shadow_time * 100.0).ToString("F0") + "%)"; p.AddSection("ENVIRONMENT", string.Empty, () => { p.Prev(ref environment_index, panel_environment.Count); update = true; }, () => { p.Next(ref environment_index, panel_environment.Count); update = true; }); p.AddContent("temperature", Lib.HumanReadableTemp(env_analyzer.temperature), env_analyzer.body.atmosphere && env_analyzer.landed ? "atmospheric" : flux_tooltip); p.AddContent("difference", Lib.HumanReadableTemp(env_analyzer.temp_diff), "difference between external and survival temperature"); p.AddContent("atmosphere", env_analyzer.body.atmosphere ? "yes" : "no", atmosphere_tooltip); p.AddContent("shadow time", shadowtime_str, "the time in shadow\nduring the orbit"); }
///<summary> Add environment sub-panel, including tooltips </summary> private static void AddSubPanelEnvironment(Panel p) { string flux_tooltip = Lib.BuildString ( "<align=left />" + String.Format("<b>{0,-14}\t{1,-15}\t{2}</b>\n", Local.Planner_Source, Local.Planner_Flux, Local.Planner_Temp), //"Source""Flux""Temp" String.Format("{0,-14}\t{1,-15}\t{2}\n", Local.Planner_solar, env_analyzer.solar_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.solar_flux) : Local.Generic_NONE, Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.solar_flux))), //"solar""none" String.Format("{0,-14}\t{1,-15}\t{2}\n", Local.Planner_albedo, env_analyzer.albedo_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.albedo_flux) : Local.Generic_NONE, Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.albedo_flux))), //"albedo""none" String.Format("{0,-14}\t{1,-15}\t{2}\n", Local.Planner_body, env_analyzer.body_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.body_flux) : Local.Generic_NONE, Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.body_flux))), //"body""none" String.Format("{0,-14}\t{1,-15}\t{2}\n", Local.Planner_background, Lib.HumanReadableFlux(Sim.BackgroundFlux()), Lib.HumanReadableTemp(Sim.BlackBodyTemperature(Sim.BackgroundFlux()))), //"background" String.Format("{0,-14}\t\t{1,-15}\t{2}", Local.Planner_total, Lib.HumanReadableFlux(env_analyzer.total_flux), Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.total_flux))) //"total" ); string atmosphere_tooltip = Lib.BuildString ( "<align=left />", String.Format("{0,-14}\t<b>{1}</b>\n", Local.BodyInfo_breathable, Sim.Breathable(env_analyzer.body) ? Local.BodyInfo_breathable_yes : Local.BodyInfo_breathable_no), //"breathable""yes""no" String.Format("{0,-14}\t<b>{1}</b>\n", Local.Planner_pressure, Lib.HumanReadablePressure(env_analyzer.body.atmospherePressureSeaLevel)), //"pressure" String.Format("{0,-14}\t<b>{1}</b>\n", Local.BodyInfo_lightabsorption, Lib.HumanReadablePerc(1.0 - env_analyzer.atmo_factor)), //"light absorption" String.Format("{0,-14}\t<b>{1}</b>", Local.BodyInfo_gammaabsorption, Lib.HumanReadablePerc(1.0 - Sim.GammaTransparency(env_analyzer.body, 0.0))) //"gamma absorption" ); string shadowtime_str = Lib.HumanReadableDuration(env_analyzer.shadow_period) + " (" + (env_analyzer.shadow_time * 100.0).ToString("F0") + "%)"; p.AddSection(Local.TELEMETRY_ENVIRONMENT, string.Empty, //"ENVIRONMENT" () => { p.Prev(ref environment_index, panel_environment.Count); enforceUpdate = true; }, () => { p.Next(ref environment_index, panel_environment.Count); enforceUpdate = true; }); p.AddContent(Local.Planner_temperature, Lib.HumanReadableTemp(env_analyzer.temperature), env_analyzer.body.atmosphere && env_analyzer.landed ? Local.Planner_atmospheric : flux_tooltip); //"temperature""atmospheric" p.AddContent(Local.Planner_difference, Lib.HumanReadableTemp(env_analyzer.temp_diff), Local.Planner_difference_desc); //"difference""difference between external and survival temperature" p.AddContent(Local.Planner_atmosphere, env_analyzer.body.atmosphere ? Local.Planner_atmosphere_yes : Local.Planner_atmosphere_no, atmosphere_tooltip); //"atmosphere""yes""no" p.AddContent(Local.Planner_shadowtime, shadowtime_str, Local.Planner_shadowtime_desc); //"shadow time""the time in shadow\nduring the orbit" }
/// <summary> /// Shows the Network status, ControlPath, Signal strength /// </summary> public static void ConnMan(this Panel p, Vessel v) { // avoid corner-case when this is called in a lambda after scene changes v = FlightGlobals.FindVessel(v.id); // if vessel doesn't exist anymore, leave the panel empty if (v == null) { return; } // get info from the cache Vessel_info vi = Cache.VesselInfo(v); // if not a valid vessel, leave the panel empty if (!vi.is_valid) { return; } // set metadata p.Title(Lib.BuildString(Lib.Ellipsis(v.vesselName, Styles.ScaleStringLength(40)), " <color=#cccccc>CONNECTION MANAGER</color>")); p.Width(Styles.ScaleWidthFloat(365.0f)); p.paneltype = Panel.PanelType.connection; // time-out simulation if (p.Timeout(vi)) { return; } // draw ControlPath section p.AddSection("CONTROL PATH"); if (vi.connection.linked) { if (vi.connection.control_path != null) { foreach (string[] hop in vi.connection.control_path) { if (hop == null || hop.Length < 1) { continue; } string name = hop[0]; string value = hop.Length >= 2 ? hop[1] : ""; string tooltip = hop.Length >= 3 ? ("\n" + hop[2]) : ""; p.AddContent(name, value, tooltip); } } } else { p.AddContent("<i>no connection</i>", string.Empty); } }
///<summary> Add habitat sub-panel, including tooltips </summary> private static void AddSubPanelHabitat(Panel p) { SimulatedResource atmo_res = resource_sim.Resource("Atmosphere"); SimulatedResource waste_res = resource_sim.Resource("WasteAtmosphere"); SimulatedResource moist_res = resource_sim.Resource("MoistAtmosphere"); // generate tooltips string atmo_tooltip = atmo_res.Tooltip(); string waste_tooltip = waste_res.Tooltip(true); string moist_tooltip = moist_res.Tooltip(true); // generate status string for scrubbing string waste_status = !Features.Poisoning //< feature disabled ? "n/a" : waste_res.produced <= double.Epsilon //< unnecessary ? "not required" : waste_res.consumed <= double.Epsilon //< no scrubbing ? "<color=#ffff00>none</color>" : waste_res.produced > waste_res.consumed * 1.001 //< insufficient scrubbing ? "<color=#ffff00>inadequate</color>" : "good"; //< sufficient scrubbing // generate status string for humidity string moist_status = !Features.Humidity //< feature disabled ? "n/a" : moist_res.produced <= double.Epsilon //< unnecessary ? "not required" : moist_res.consumed <= double.Epsilon //< no humidity control ? "<color=#ffff00>none</color>" : moist_res.produced > moist_res.consumed * 1.001 //< insufficient humidity control ? "<color=#ffff00>inadequate</color>" : "good"; //< sufficient humidity control // generate status string for pressurization string atmo_status = !Features.Pressure //< feature disabled ? "n/a" : atmo_res.consumed <= double.Epsilon //< unnecessary ? "not required" : atmo_res.produced <= double.Epsilon //< no pressure control ? "<color=#ffff00>none</color>" : atmo_res.consumed > atmo_res.produced * 1.001 //< insufficient pressure control ? "<color=#ffff00>inadequate</color>" : "good"; //< sufficient pressure control p.AddSection("HABITAT", string.Empty, () => { p.Prev(ref environment_index, panel_environment.Count); update = true; }, () => { p.Next(ref environment_index, panel_environment.Count); update = true; }); p.AddContent("volume", Lib.HumanReadableVolume(vessel_analyzer.volume), "volume of enabled habitats"); p.AddContent("surface", Lib.HumanReadableSurface(vessel_analyzer.surface), "surface of enabled habitats"); p.AddContent("scrubbing", waste_status, waste_tooltip); p.AddContent("humidity", moist_status, moist_tooltip); p.AddContent("pressurization", atmo_status, atmo_tooltip); }
///<summary> Add electric charge sub-panel, including tooltips </summary> private static void AddSubPanelEC(Panel p) { // get simulated resource SimulatedResource res = resource_sim.Resource("ElectricCharge"); // create tooltip string tooltip = res.Tooltip(); // render the panel section p.AddSection(Local.Planner_ELECTRICCHARGE); //"ELECTRIC CHARGE" p.AddContent(Local.Planner_storage, Lib.HumanReadableAmount(res.storage), tooltip); //"storage" p.AddContent(Local.Planner_consumed, Lib.HumanReadableRate(res.consumed), tooltip); //"consumed" p.AddContent(Local.Planner_produced, Lib.HumanReadableRate(res.produced), tooltip); //"produced" p.AddContent(Local.Planner_duration, Lib.HumanReadableDuration(res.Lifetime())); //"duration" }
///<summary> Add supply resource sub-panel, including tooltips </summary> ///<remarks> /// does not include electric charge /// does not include special resources like waste atmosphere /// restricted to resources that are configured explicitly in the profile as supplies ///</remarks> private static void AddSubPanelResource(Panel p, string res_name) { // get simulated resource SimulatedResource res = resource_sim.Resource(res_name); // create tooltip string tooltip = res.Tooltip(); // render the panel section p.AddSection(Lib.SpacesOnCaps(res_name).ToUpper(), string.Empty, () => { p.Prev(ref resource_index, panel_resource.Count); update = true; }, () => { p.Next(ref resource_index, panel_resource.Count); update = true; }); p.AddContent("storage", Lib.HumanReadableAmount(res.storage), tooltip); p.AddContent("consumed", Lib.HumanReadableRate(res.consumed), tooltip); p.AddContent("produced", Lib.HumanReadableRate(res.produced), tooltip); p.AddContent("duration", Lib.HumanReadableDuration(res.Lifetime())); }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); var lb1 = new Label { WordWrap = true, Text = "GroupBox is a control that displays a frame around a control with an optional caption. It has only one child, but you can used any components for macking rich user interfaces", }; grid.AddContent(lb1, 0, 0, 2); targetPanel = new GroupBox() { Background = Color.DarkMagenta, Text = "Header", }; var contentPanel = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; contentPanel.AddContent(new Label("Content") { Background = Color.Magenta, Foreground = Color.White, }); targetPanel.AddContent(contentPanel); grid.AddContent(targetPanel, 0, 1); descriptionLabel = new Label("Let's check how to work TextAlignment, BorderThickness, BorderColor and BorderChars properties") { Margin = new Thickness(1, 0, 0, 0), WordWrap = true, }; grid.AddContent(descriptionLabel, 1, 1); }
///<summary> Add supply resource sub-panel, including tooltips </summary> ///<remarks> /// does not include electric charge /// does not include special resources like waste atmosphere /// restricted to resources that are configured explicitly in the profile as supplies ///</remarks> private static void AddSubPanelResource(Panel p, string res_name) { // get simulated resource SimulatedResource res = resource_sim.Resource(res_name); // create tooltip string tooltip = res.Tooltip(); var resource = PartResourceLibrary.Instance.resourceDefinitions[res_name]; // render the panel section p.AddSection(Lib.SpacesOnCaps(resource.displayName).ToUpper(), string.Empty, () => { p.Prev(ref resource_index, panel_resource.Count); enforceUpdate = true; }, () => { p.Next(ref resource_index, panel_resource.Count); enforceUpdate = true; }); p.AddContent(Local.Planner_storage, Lib.HumanReadableAmount(res.storage), tooltip); //"storage" p.AddContent(Local.Planner_consumed, Lib.HumanReadableRate(res.consumed), tooltip); //"consumed" p.AddContent(Local.Planner_produced, Lib.HumanReadableRate(res.produced), tooltip); //"produced" p.AddContent(Local.Planner_duration, Lib.HumanReadableDuration(res.Lifetime())); //"duration" }
///<summary> Add habitat sub-panel, including tooltips </summary> private static void AddSubPanelHabitat(Panel p) { SimulatedResource atmo_res = resource_sim.Resource("Atmosphere"); SimulatedResource waste_res = resource_sim.Resource("WasteAtmosphere"); // generate tooltips string atmo_tooltip = atmo_res.Tooltip(); string waste_tooltip = waste_res.Tooltip(true); // generate status string for scrubbing string waste_status = !Features.Poisoning //< feature disabled ? "n/a" : waste_res.produced <= double.Epsilon //< unnecessary ? Local.Planner_scrubbingunnecessary //"not required" : waste_res.consumed <= double.Epsilon //< no scrubbing ? Lib.Color(Local.Planner_noscrubbing, Lib.Kolor.Orange) //"none" : waste_res.produced > waste_res.consumed * 1.001 //< insufficient scrubbing ? Lib.Color(Local.Planner_insufficientscrubbing, Lib.Kolor.Yellow) //"inadequate" : Lib.Color(Local.Planner_sufficientscrubbing, Lib.Kolor.Green); //"good" //< sufficient scrubbing // generate status string for pressurization string atmo_status = !Features.Pressure //< feature disabled ? "n/a" : atmo_res.consumed <= double.Epsilon //< unnecessary ? Local.Planner_pressurizationunnecessary //"not required" : atmo_res.produced <= double.Epsilon //< no pressure control ? Lib.Color(Local.Planner_nopressurecontrol, Lib.Kolor.Orange) //"none" : atmo_res.consumed > atmo_res.produced * 1.001 //< insufficient pressure control ? Lib.Color(Local.Planner_insufficientpressurecontrol, Lib.Kolor.Yellow) //"inadequate" : Lib.Color(Local.Planner_sufficientpressurecontrol, Lib.Kolor.Green); //"good" //< sufficient pressure control p.AddSection(Local.Planner_HABITAT, string.Empty, //"HABITAT" () => { p.Prev(ref environment_index, panel_environment.Count); enforceUpdate = true; }, () => { p.Next(ref environment_index, panel_environment.Count); enforceUpdate = true; }); p.AddContent(Local.Planner_volume, Lib.HumanReadableVolume(vessel_analyzer.volume), Local.Planner_volume_tip); //"volume""volume of enabled habitats" p.AddContent(Local.Planner_habitatssurface, Lib.HumanReadableSurface(vessel_analyzer.surface), Local.Planner_habitatssurface_tip); //"surface""surface of enabled habitats" p.AddContent(Local.Planner_scrubbing, waste_status, waste_tooltip); //"scrubbing" p.AddContent(Local.Planner_pressurization, atmo_status, atmo_tooltip); //"pressurization" }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); var lb1 = new Label { WordWrap = true, Text = "Panel is a simple control using to group collections of controls. It has only one child, but you can used any components for macking rich user interfaces", }; grid.AddContent(lb1, 0, 0, 2); targetPanel = new Panel() { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, Background = Color.DarkMagenta, }; targetPanel.AddContent(new Label("Content") { Background = Color.Magenta, Foreground = Color.White, }); grid.AddContent(targetPanel, 0, 1); descriptionLabel = new Label("Let's check how to work VerticalContentAlignment and HorizontalContentAlignment properties") { Margin = new Thickness(1, 0, 0, 0), WordWrap = true, }; grid.AddContent(descriptionLabel, 1, 1); }
private void InitializeComponent() { panel1 = new Panel() { HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, AutoSize = false, }; canvas1 = new Canvas() { Width = 45, Height = 15, }; canvas1.OnPaint += CanvasPaint; panel1.AddContent(canvas1); AddContent(panel1); }
///<summary> Add stress sub-panel, including tooltips </summary> private static void AddSubPanelStress(Panel p) { // get first living space rule // - guaranteed to exist, as this panel is not rendered if it doesn't // - even without crew, it is safe to evaluate the modifiers that use it Rule rule = Profile.rules.Find(k => k.modifiers.Contains("living_space")); // render title p.AddSection(Local.Planner_STRESS, string.Empty, //"STRESS" () => { p.Prev(ref special_index, panel_special.Count); enforceUpdate = true; }, () => { p.Next(ref special_index, panel_special.Count); enforceUpdate = true; }); // render living space data // generate details tooltips string living_space_tooltip = Lib.BuildString ( Local.Planner_volumepercapita, "<b>\t", Lib.HumanReadableVolume(vessel_analyzer.volume / Math.Max(vessel_analyzer.crew_count, 1)), "</b>\n", //"volume per-capita: Local.Planner_ideallivingspace, "<b>\t", Lib.HumanReadableVolume(PreferencesComfort.Instance.livingSpace), "</b>" //"ideal living space: ); p.AddContent(Local.Planner_livingspace, Habitat.Living_space_to_string(vessel_analyzer.living_space), living_space_tooltip); //"living space" // render comfort data if (rule.modifiers.Contains("comfort")) { p.AddContent(Local.Planner_comfort, vessel_analyzer.comforts.Summary(), vessel_analyzer.comforts.Tooltip()); //"comfort" } else { p.AddContent(Local.Planner_comfort, "n/a"); //"comfort" } // render pressure data if (rule.modifiers.Contains("pressure")) { string pressure_tooltip = vessel_analyzer.pressurized ? Local.Planner_analyzerpressurized1 //"Free roaming in a pressurized environment is\nvastly superior to living in a suit." : Local.Planner_analyzerpressurized2; //"Being forced inside a suit all the time greatly\nreduces the crews quality of life.\nThe worst part is the diaper." p.AddContent(Local.Planner_pressurized, vessel_analyzer.pressurized ? Local.Planner_pressurized_yes : Local.Planner_pressurized_no, pressure_tooltip); //"pressurized""yes""no" } else { p.AddContent(Local.Planner_pressurized, "n/a"); //"pressurized" } // render life estimate double mod = Modifiers.Evaluate(env_analyzer, vessel_analyzer, resource_sim, rule.modifiers); p.AddContent(Local.Planner_lifeestimate, Lib.HumanReadableDuration(rule.fatal_threshold / (rule.degeneration * mod))); //"duration" }
private void InitializeComponent() { panel1 = new Panel() { HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, AutoSize = false, }; tilePanel = new TilePanel() { Width = 45, Height = 15, Background = Color.Black, Foreground = Color.Magenta, Tile = '░', }; tilePanel.OnPaint += CanvasPaint; panel1.AddContent(tilePanel); AddContent(panel1); }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1, 0, 0), }; grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 20)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 80)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 4)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 4)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); var lb1 = new Label { WordWrap = true, Text = "MessageBox displays a message window, also known as a dialog box, which presents a message to the user. It is a modal window, blocking other actions in the application until the user closes it.", }; grid.AddContent(lb1, 0, 0, 2); grid.AddContent(new Label("Caption") { Foreground = Color.DarkMagenta }, 0, 1); grid.AddContent(new Label("The text to display in the title bar of the message box") { WordWrap = true }, 1, 1); grid.AddContent(new Label("Message") { Foreground = Color.DarkMagenta }, 0, 2); grid.AddContent(new Label("The text to display in the message box") { WordWrap = true }, 1, 2); grid.AddContent(new Label("MessageIcon") { Foreground = Color.DarkMagenta }, 0, 3); grid.AddContent(new Label("One of the values that specifies which icon to display in the message box [None, Error, Question, Warning, Information]") { WordWrap = true }, 1, 3); grid.AddContent(new Label("Buttons") { Foreground = Color.DarkMagenta }, 0, 4); grid.AddContent(new Label("One of the values that specifies which buttons to display in the message box [OK, OKCancel, AbortRetryIgnore, YesNoCancel, YesNo, RetryCancel]") { WordWrap = true }, 1, 4); var buttonsPanel = new Panel() { HorizontalContentAlignment = HorizontalAlignment.Center, }; var stackPanel = new StackPanel(Orientation.Horizontal); var btn1 = new Button("Simple") { Margin = new Thickness(0, 0, 1, 0) }; btn1.OnClick += SimpleClick; stackPanel.AddContent(btn1); var btn2 = new Button("With caption") { Margin = new Thickness(0, 0, 1, 0) }; btn2.OnClick += CaptionClick; stackPanel.AddContent(btn2); var btn3 = new Button("Caption & icon") { Margin = new Thickness(0, 0, 1, 0) }; btn3.OnClick += CaptionIconClick; stackPanel.AddContent(btn3); var btn4 = new Button("Full variant") { Margin = new Thickness(0, 0, 1, 0) }; btn4.OnClick += FullClick; stackPanel.AddContent(btn4); buttonsPanel.AddContent(stackPanel); grid.AddContent(buttonsPanel, 0, 5, 2); }
private void InitializeComponent() { panel1 = new Panel() { HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, AutoSize = false, }; stackPanel1 = new StackPanel(Orientation.Vertical) { Width = 40, }; groupBox1 = new GroupBox() { Background = Color.Green, BorderColor = Color.DarkGreen, }; stackPanel2 = new StackPanel(Orientation.Vertical) { Margin = new Thickness(5, 0), }; label1 = new Label("Congratulations!!!") { Foreground = Color.DarkGreen, TextAlignment = TextAlignment.Center, }; stackPanel2.AddContent(label1); labelMapName = new Label() { Foreground = Color.DarkGreen, TextAlignment = TextAlignment.Center, WordWrap = true, }; stackPanel2.AddContent(labelMapName); groupBox1.AddContent(stackPanel2); groupBox2 = new GroupBox() { Background = Color.Gray, BorderColor = Color.DarkGray, Margin = new Thickness(0, 1, 0, 0), }; stackPanel3 = new StackPanel(Orientation.Vertical); stackPanel3.AddContent(new Label("Your achievements:") { TextAlignment = TextAlignment.Center, Margin = new Thickness(0, 0, 0, 1), }); grid1 = new Grid(); grid1.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Absolute, 20)); grid1.ColumnDefinitions.Add(new ColumnDefinition()); grid1.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); grid1.AddContent(new Label("Steps taken"), 0, 0); labelSteps = new Label(); grid1.AddContent(labelSteps, 1, 0); grid1.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); grid1.AddContent(new Label("Coins collected"), 0, 1); labelCoins = new Label(); grid1.AddContent(labelCoins, 1, 1); stackPanel3.AddContent(grid1); groupBox2.AddContent(stackPanel3); stackPanel1.AddContent(groupBox1); stackPanel1.AddContent(groupBox2); panel1.AddContent(stackPanel1); AddContent(panel1); }
///<summary> Add reliability sub-panel, including tooltips </summary> private static void AddSubPanelReliability(Panel p) { // evaluate redundancy metric // - 0: no redundancy // - 0.5: all groups have 2 elements // - 1.0: all groups have 3 or more elements double redundancy_metric = 0.0; foreach (KeyValuePair <string, int> pair in vessel_analyzer.redundancy) { switch (pair.Value) { case 1: break; case 2: redundancy_metric += 0.5 / vessel_analyzer.redundancy.Count; break; default: redundancy_metric += 1.0 / vessel_analyzer.redundancy.Count; break; } } // traduce the redundancy metric to string string redundancy_str = string.Empty; if (redundancy_metric <= 0.1) { redundancy_str = "none"; } else if (redundancy_metric <= 0.33) { redundancy_str = "poor"; } else if (redundancy_metric <= 0.66) { redundancy_str = "okay"; } else { redundancy_str = "great"; } // generate redundancy tooltip string redundancy_tooltip = string.Empty; if (vessel_analyzer.redundancy.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, int> pair in vessel_analyzer.redundancy) { if (sb.Length > 0) { sb.Append("\n"); } sb.Append("<b>"); switch (pair.Value) { case 1: sb.Append("<color=red>"); break; case 2: sb.Append("<color=yellow>"); break; default: sb.Append("<color=green>"); break; } sb.Append(pair.Value.ToString()); sb.Append("</color></b>\t"); sb.Append(pair.Key); } redundancy_tooltip = Lib.BuildString("<align=left />", sb.ToString()); } // generate repair string and tooltip string repair_str = "none"; string repair_tooltip = string.Empty; if (vessel_analyzer.crew_engineer) { repair_str = "engineer"; repair_tooltip = "The engineer on board should\nbe able to handle all repairs"; } else if (vessel_analyzer.crew_capacity == 0) { repair_str = "safemode"; repair_tooltip = "We have a chance of repairing\nsome of the malfunctions remotely"; } // render panel p.AddSection("RELIABILITY", string.Empty, () => { p.Prev(ref special_index, panel_special.Count); update = true; }, () => { p.Next(ref special_index, panel_special.Count); update = true; }); p.AddContent("malfunctions", Lib.HumanReadableAmount(vessel_analyzer.failure_year, "/y"), "average case estimate\nfor the whole vessel"); p.AddContent("high quality", Lib.HumanReadablePerc(vessel_analyzer.high_quality), "percentage of high quality components"); p.AddContent("redundancy", redundancy_str, redundancy_tooltip); p.AddContent("repair", repair_str, repair_tooltip); }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); var lb1 = new Label { WordWrap = true, Text = "Button is a common button control. It inherited from ButtonBase and has Background as Application.SystemColors.ButtonFace and Foreground as Application.SystemColors.ButtonText", }; grid.AddContent(lb1, 0, 0, 2); var targetPanel = new Panel() { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var stackPanel = new StackPanel(Orientation.Vertical) { AutoSize = true, Padding = new Thickness(1), }; for (int i = 1; i <= 4; i++) { var btn = new Button($"Button{i}") { Margin = new Thickness(0, 0, 0, i < 4 ? 1 : 0), IsDisabled = i == 2, }; btn.OnClick += BtnClick; stackPanel.AddContent(btn); } targetPanel.AddContent(stackPanel); grid.AddContent(targetPanel, 0, 1); var descriptionLabel = new Label("Use [Tab]\\[Shift+Tab] for change focused button. [Space] or [Enter] to clik. If you want to disable button selection, set the IsDisabled property. DialogResult gets or sets a value that is returned to the parent form when the button is clicked") { Margin = new Thickness(1, 1, 0, 0), WordWrap = true, }; grid.AddContent(descriptionLabel, 1, 1); }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); var lb1 = new Label { WordWrap = true, Text = "CheckBox represents a control to give the user an option, such as true/false or yes/no. CheckBox controls let the user pick a combination of options", }; grid.AddContent(lb1, 0, 0, 2); var targetPanel = new Panel() { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var stackPanel = new StackPanel(Orientation.Vertical) { AutoSize = true, Padding = new Thickness(1), }; var cb1 = new CheckBox("CheckBox1") { Margin = new Thickness(0, 0, 0, 1), }; cb1.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb1); var cb2 = new CheckBox("CheckBox2") { Checked = true, Margin = new Thickness(0, 0, 0, 1), }; cb2.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb2); var cb3 = new CheckBox("CheckBox3") { IsDisabled = true, Margin = new Thickness(0, 0, 0, 1), }; cb3.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb3); var cb4 = new CheckBox("CheckBox4") { IsDisabled = true, Checked = true, Margin = new Thickness(0, 0, 0, 1), }; cb4.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb4); var cb5 = new CheckBox("CheckBox5") { ThreeState = true, }; cb5.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb5); targetPanel.AddContent(stackPanel); grid.AddContent(targetPanel, 0, 1); var propertyPanel = new StackPanel(Orientation.Vertical); propertyPanel.AddContent( new Label( "Use [Tab]\\[Shift+Tab] for change focused checkbox. [Space] or [Enter] to change the state. The ThreeState property determines whether the control supports two or three states") { Margin = new Thickness(1, 1, 0, 0), WordWrap = true, }); propertyChangedLabel = new Label("Click on any available checkbox…") { Margin = new Thickness(1, 1, 0, 0), WordWrap = true, }; propertyPanel.AddContent(propertyChangedLabel); grid.AddContent(propertyPanel, 1, 1); }
///<summary> Add reliability sub-panel, including tooltips </summary> private static void AddSubPanelReliability(Panel p) { // evaluate redundancy metric // - 0: no redundancy // - 0.5: all groups have 2 elements // - 1.0: all groups have 3 or more elements double redundancy_metric = 0.0; foreach (KeyValuePair <string, int> pair in vessel_analyzer.redundancy) { switch (pair.Value) { case 1: break; case 2: redundancy_metric += 0.5 / vessel_analyzer.redundancy.Count; break; default: redundancy_metric += 1.0 / vessel_analyzer.redundancy.Count; break; } } // traduce the redundancy metric to string string redundancy_str = string.Empty; if (redundancy_metric <= 0.1) { redundancy_str = Local.Planner_none; //"none" } else if (redundancy_metric <= 0.33) { redundancy_str = Local.Planner_poor; //"poor" } else if (redundancy_metric <= 0.66) { redundancy_str = Local.Planner_okay; //"okay" } else { redundancy_str = Local.Planner_great; //"great" } // generate redundancy tooltip string redundancy_tooltip = string.Empty; if (vessel_analyzer.redundancy.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, int> pair in vessel_analyzer.redundancy) { if (sb.Length > 0) { sb.Append("\n"); } sb.Append(Lib.Color(pair.Value.ToString(), pair.Value == 1 ? Lib.Kolor.Red : pair.Value == 2 ? Lib.Kolor.Yellow : Lib.Kolor.Green, true)); sb.Append("\t"); sb.Append(pair.Key); } redundancy_tooltip = Lib.BuildString("<align=left />", sb.ToString()); } // generate repair string and tooltip string repair_str = Local.Planner_none; //"none" string repair_tooltip = string.Empty; if (vessel_analyzer.crew_engineer) { repair_str = "engineer"; repair_tooltip = Local.Planner_engineer_tip; //"The engineer on board should\nbe able to handle all repairs" } else if (vessel_analyzer.crew_capacity == 0) { repair_str = "safemode"; repair_tooltip = Local.Planner_safemode_tip; //"We have a chance of repairing\nsome of the malfunctions remotely" } // render panel p.AddSection(Local.Planner_RELIABILITY, string.Empty, //"RELIABILITY" () => { p.Prev(ref special_index, panel_special.Count); enforceUpdate = true; }, () => { p.Next(ref special_index, panel_special.Count); enforceUpdate = true; }); p.AddContent(Local.Planner_malfunctions, Lib.HumanReadableAmount(vessel_analyzer.failure_year, "/y"), Local.Planner_malfunctions_tip); //"malfunctions""average case estimate\nfor the whole vessel" p.AddContent(Local.Planner_highquality, Lib.HumanReadablePerc(vessel_analyzer.high_quality), Local.Planner_highquality_tip); //"high quality""percentage of high quality components" p.AddContent(Local.Planner_redundancy, redundancy_str, redundancy_tooltip); //"redundancy" p.AddContent(Local.Planner_repair, repair_str, repair_tooltip); //"repair" }
///<summary> Add radiation sub-panel, including tooltips </summary> private static void AddSubPanelRadiation(Panel p) { // get first radiation rule // - guaranteed to exist, as this panel is not rendered if it doesn't // - even without crew, it is safe to evaluate the modifiers that use it Rule rule = Profile.rules.Find(k => k.modifiers.Contains("radiation")); // detect if it use shielding bool use_shielding = rule.modifiers.Contains("shielding"); // calculate various radiation levels double[] levels = new[] { Math.Max(Radiation.Nominal, (env_analyzer.surface_rad + vessel_analyzer.emitted)), // surface Math.Max(Radiation.Nominal, (env_analyzer.magnetopause_rad + vessel_analyzer.emitted)), // inside magnetopause Math.Max(Radiation.Nominal, (env_analyzer.inner_rad + vessel_analyzer.emitted)), // inside inner belt Math.Max(Radiation.Nominal, (env_analyzer.outer_rad + vessel_analyzer.emitted)), // inside outer belt Math.Max(Radiation.Nominal, (env_analyzer.heliopause_rad + vessel_analyzer.emitted)), // interplanetary Math.Max(Radiation.Nominal, (env_analyzer.extern_rad + vessel_analyzer.emitted)), // interstellar Math.Max(Radiation.Nominal, (env_analyzer.storm_rad + vessel_analyzer.emitted)) // storm }; // evaluate modifiers (except radiation) List <string> modifiers_except_radiation = new List <string>(); foreach (string s in rule.modifiers) { if (s != "radiation") { modifiers_except_radiation.Add(s); } } double mod = Modifiers.Evaluate(env_analyzer, vessel_analyzer, resource_sim, modifiers_except_radiation); // calculate life expectancy at various radiation levels double[] estimates = new double[7]; for (int i = 0; i < 7; ++i) { estimates[i] = rule.fatal_threshold / (rule.degeneration * mod * levels[i]); } // generate tooltip RadiationModel mf = Radiation.Info(env_analyzer.body).model; string tooltip = Lib.BuildString ( "<align=left />", String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_surface, Lib.HumanReadableDuration(estimates[0])), //"surface" mf.has_pause ? String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_magnetopause, Lib.HumanReadableDuration(estimates[1])) : "", //"magnetopause" mf.has_inner ? String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_innerbelt, Lib.HumanReadableDuration(estimates[2])) : "", //"inner belt" mf.has_outer ? String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_outerbelt, Lib.HumanReadableDuration(estimates[3])) : "", //"outer belt" String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_interplanetary, Lib.HumanReadableDuration(estimates[4])), //"interplanetary" String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_interstellar, Lib.HumanReadableDuration(estimates[5])), //"interstellar" String.Format("{0,-20}\t<b>{1}</b>", Local.Planner_storm, Lib.HumanReadableDuration(estimates[6])) //"storm" ); // render the panel p.AddSection(Local.Planner_RADIATION, string.Empty, //"RADIATION" () => { p.Prev(ref special_index, panel_special.Count); enforceUpdate = true; }, () => { p.Next(ref special_index, panel_special.Count); enforceUpdate = true; }); p.AddContent(Local.Planner_surface, Lib.HumanReadableRadiation(env_analyzer.surface_rad + vessel_analyzer.emitted), tooltip); //"surface" p.AddContent(Local.Planner_orbit, Lib.HumanReadableRadiation(env_analyzer.magnetopause_rad), tooltip); //"orbit" if (vessel_analyzer.emitted >= 0.0) { p.AddContent(Local.Planner_emission, Lib.HumanReadableRadiation(vessel_analyzer.emitted), tooltip); //"emission" } else { p.AddContent(Local.Planner_activeshielding, Lib.HumanReadableRadiation(-vessel_analyzer.emitted), tooltip); //"active shielding" } p.AddContent(Local.Planner_shielding, rule.modifiers.Contains("shielding") ? Habitat.Shielding_to_string(vessel_analyzer.shielding) : "N/A", tooltip); //"shielding" }
private void InitializeComponent() { WindowState = ControlState.Maximized; Background = Color.Black; mainMenu1 = new MainMenu(); fileMenuItem = new MenuItem("File"); newMenuItem = new MenuItem("&New"); newMenuItem.OnClick += NewMenuItemClick; fileMenuItem.Items.Add(newMenuItem); openMenuItem = new MenuItem("&Open…"); openMenuItem.OnClick += OpenMenuItemClick; fileMenuItem.Items.Add(openMenuItem); fileMenuItem.Items.Add(new SeparatorMenuItem()); saveMenuItem = new MenuItem("&Save", null, enabled: false); saveMenuItem.OnClick += SaveMenuItemClick; fileMenuItem.Items.Add(saveMenuItem); saveAsMenuItem = new MenuItem("Save &as…", null, enabled: false); saveAsMenuItem.OnClick += SaveAsMenuItemClick; fileMenuItem.Items.Add(saveAsMenuItem); fileMenuItem.Items.Add(new SeparatorMenuItem()); exitMenuItem = new MenuItem("E&xit"); exitMenuItem.OnClick += ExitMenuItemClick; fileMenuItem.Items.Add(exitMenuItem); mainMenu1.Items.Add(fileMenuItem); editMenuItem = new MenuItem("Edit"); wallMenuItem = new MenuItem("Wall", new Shortcut(ConsoleKey.D1), enabled: false); wallMenuItem.OnClick += MazeItemClick; wallMenuItem.Tag = MapItem.Wall; editMenuItem.Items.Add(wallMenuItem); startMenuItem = new MenuItem("Start point", new Shortcut(ConsoleKey.D2), enabled: false); startMenuItem.OnClick += MazeItemClick; startMenuItem.Tag = MapItem.StartPoint; editMenuItem.Items.Add(startMenuItem); endMenuItem = new MenuItem("End point", new Shortcut(ConsoleKey.D3), enabled: false); endMenuItem.OnClick += MazeItemClick; endMenuItem.Tag = MapItem.EndPoint; editMenuItem.Items.Add(endMenuItem); doorMenuItem = new MenuItem("Door", new Shortcut(ConsoleKey.D4), enabled: false); doorMenuItem.OnClick += MazeItemClick; doorMenuItem.Tag = MapItem.Door; editMenuItem.Items.Add(doorMenuItem); keyMenuItem = new MenuItem("Key", new Shortcut(ConsoleKey.D5), enabled: false); keyMenuItem.OnClick += MazeItemClick; keyMenuItem.Tag = MapItem.Key; editMenuItem.Items.Add(keyMenuItem); tenCoinsMenuItem = new MenuItem("10 coins", new Shortcut(ConsoleKey.D6), enabled: false); tenCoinsMenuItem.OnClick += MazeItemClick; tenCoinsMenuItem.Tag = MapItem.TenCoins; editMenuItem.Items.Add(tenCoinsMenuItem); twentyCoinsMenuItem = new MenuItem("20 coins", new Shortcut(ConsoleKey.D7), enabled: false); twentyCoinsMenuItem.OnClick += MazeItemClick; twentyCoinsMenuItem.Tag = MapItem.TwentyCoins; editMenuItem.Items.Add(twentyCoinsMenuItem); editMenuItem.Items.Add(new SeparatorMenuItem()); generateMenuItem = new MenuItem("Generate", new Shortcut(ConsoleKey.G, false, true, false), enabled: false); generateMenuItem.OnClick += GenerateClick; editMenuItem.Items.Add(generateMenuItem); editMenuItem.Items.Add(new SeparatorMenuItem()); clearMazeMenuItem = new MenuItem("Clear maze", null, enabled: false); clearMazeMenuItem.OnClick += ClearMazeClick; editMenuItem.Items.Add(clearMazeMenuItem); editMenuItem.Items.Add(new SeparatorMenuItem()); checkPathMenuItem = new MenuItem("Check path", new Shortcut(ConsoleKey.P, false, true, false), enabled: false); checkPathMenuItem.OnClick += CheckPathClick; editMenuItem.Items.Add(checkPathMenuItem); mainMenu1.Items.Add(editMenuItem); MainMenu = mainMenu1; statusBar1 = new StatusBar(); statusBar1.AddHelpButton(); StatusBar = statusBar1; panel1 = new Panel() { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; label1 = new Label( "Welcome to the maze map editor. Use main menu (Alt+F1) for create new (Alt-N) maze map or open (Alt-O) exist file of map") { Foreground = Color.DarkGray, Width = Math.Min(65, Application.Environment.WindowWidth - 4), WordWrap = true, TextAlignment = TextAlignment.Center, }; panel1.AddContent(label1); statusPositionLabel = new Label(); statusDimensionLabel = new Label(); statusMazeItemLabel = new Label(); statusSaveLabel = new Label("●"); AddContent(panel1); }