//private ModelEnergyProperties ModelEnergyProperties { get; set; } public Dialog_IdealAirLoad(ref HoneybeeSchema.ModelEnergyProperties libSource, IdealAirSystemAbridged hvac = default, bool lockedMode = false) { var sys = hvac ?? new IdealAirSystemAbridged($"IdealAirSystem_{Guid.NewGuid().ToString().Substring(0, 8)}"); var vm = new IdealAirLoadViewModel(libSource, sys, this); //Padding = new Padding(4); Title = $"Ideal Air Load - {DialogHelper.PluginName}"; WindowStyle = WindowStyle.Default; Width = 450; this.Icon = DialogHelper.HoneybeeIcon; var layout = new DynamicLayout() { DataContext = vm }; layout.DefaultSpacing = new Size(4, 4); layout.Padding = new Padding(10); // string displayName = null, // EconomizerType economizerType = EconomizerType.DifferentialDryBulb, // bool demandControlledVentilation = false, // double sensibleHeatRecovery = 0, // double latentHeatRecovery = 0, // double heatingAirTemperature = 50, // double coolingAirTemperature = 13, // AnyOf<Autosize, NoLimit, double> heatingLimit = null, // AnyOf<Autosize, NoLimit, double> coolingLimit = null, // string heatingAvailability = null, // string coolingAvailability var nameText = new TextBox(); var economizer = new DropDown(); var DCV = new CheckBox() { Text = "Demand Controlled Ventilation" }; var sensible = new NumericStepper() { MinValue = 0, MaxValue = 1, MaximumDecimalPlaces = 2, Increment = 0.1 }; var latent = new NumericStepper() { MinValue = 0, MaxValue = 1, MaximumDecimalPlaces = 2, Increment = 0.1 }; var heatingAirT = new NumericStepper() { MinValue = -50, MaxValue = 100, MaximumDecimalPlaces = 2 }; var coolingAirT = new NumericStepper() { MinValue = -50, MaxValue = 100, MaximumDecimalPlaces = 2 }; var heatingLimitAuto = new RadioButton() { Text = "Autosize" }; var heatingLimitNoLimit = new RadioButton() { Text = "No Limit" }; var heatingLimitNumber = new RadioButton(); var heatingLimit = new NumericStepper(); var coolingLimitAuto = new RadioButton() { Text = "Autosize" }; var coolingLimitNoLimit = new RadioButton() { Text = "No Limit" }; var coolingLimitNumber = new RadioButton(); var coolingLimit = new NumericStepper(); var heatingAvailability = new OptionalButton(); heatingAvailability.TextBinding.Bind(vm, _ => _.HeatingAvaliabilitySchedule.BtnName); heatingAvailability.Bind(_ => _.Command, vm, _ => _.HeatingAvaliabilityCommand); heatingAvailability.Bind(_ => _.RemoveCommand, vm, _ => _.RemoveHeatingAvaliabilityCommand); heatingAvailability.Bind(_ => _.IsRemoveVisable, vm, _ => _.HeatingAvaliabilitySchedule.IsRemoveVisable); var coolingAvailability = new OptionalButton(); coolingAvailability.TextBinding.Bind(vm, _ => _.CoolingAvaliabilitySchedule.BtnName); coolingAvailability.Bind(_ => _.Command, vm, _ => _.CoolingAvaliabilityCommand); coolingAvailability.Bind(_ => _.RemoveCommand, vm, _ => _.RemoveCoolingAvaliabilityCommand); coolingAvailability.Bind(_ => _.IsRemoveVisable, vm, _ => _.CoolingAvaliabilitySchedule.IsRemoveVisable); nameText.TextBinding.BindDataContext((IdealAirLoadViewModel m) => m.Name); economizer.BindDataContext(c => c.DataStore, (IdealAirLoadViewModel m) => m.Economizers); economizer.SelectedKeyBinding.BindDataContext((IdealAirLoadViewModel m) => m.Economizer); DCV.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.DCV); sensible.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.SensibleHR); latent.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.LatentHR); heatingAirT.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.HeatingAirTemperature); coolingAirT.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.CoolingAirTemperature); heatingLimitAuto.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.HeatingLimitAutosized); heatingLimitNoLimit.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.HeatingLimitNoLimit); heatingLimitNumber.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.HeatingLimitNumber); heatingLimit.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.HeatingLimit); heatingLimit.BindDataContext(c => c.Enabled, (IdealAirLoadViewModel m) => m.HeatingLimitNumber); coolingLimitAuto.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.CoolingLimitAutosized); coolingLimitNoLimit.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.CoolingLimitNoLimit); coolingLimitNumber.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.CoolingLimitNumber); coolingLimit.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.CoolingLimit); coolingLimit.BindDataContext(c => c.Enabled, (IdealAirLoadViewModel m) => m.CoolingLimitNumber); layout.AddRow("Name:"); layout.AddRow(nameText); layout.AddRow("Economizer:"); layout.AddRow(economizer); layout.AddSeparateRow(DCV); layout.AddRow("Sensible Heat Recovery: [0-1]"); layout.AddRow(sensible); layout.AddRow("Latent Heat Recovery: [0-1]"); layout.AddRow(latent); layout.AddRow("Heating Supply Air Temperature: [C]"); layout.AddRow(heatingAirT); layout.AddRow("Cooling Supply Air Temperature: [C]"); layout.AddRow(coolingAirT); layout.AddRow("Heating Capacity Limit: [Watts]"); layout.AddRow(heatingLimitAuto); layout.AddRow(heatingLimitNoLimit); layout.AddSeparateRow(heatingLimitNumber, heatingLimit); layout.AddRow("Cooling Capacity Limit: [Watts]"); layout.AddRow(coolingLimitAuto); layout.AddRow(coolingLimitNoLimit); layout.AddSeparateRow(coolingLimitNumber, coolingLimit); layout.AddRow("Heating Availability"); layout.AddRow(heatingAvailability); layout.AddRow("Cooling Availability"); layout.AddRow(coolingAvailability); var locked = new CheckBox() { Text = "Locked", Enabled = false }; locked.Checked = lockedMode; var OKButton = new Button { Text = "OK", Enabled = !lockedMode }; OKButton.Click += (sender, e) => OkCommand.Execute(vm.GreateHvac(hvac)); AbortButton = new Button { Text = "Cancel" }; AbortButton.Click += (sender, e) => Close(); var hbData = new Button { Text = "Schema Data" }; hbData.Click += (sender, e) => Dialog_Message.Show(this, vm.GreateHvac(hvac).ToJson(true), "Schema Data"); layout.AddSeparateRow(locked, null, OKButton, this.AbortButton, null, hbData); layout.AddRow(null); Content = layout; }
//private ModelEnergyProperties ModelEnergyProperties { get; set; } public Dialog_OpsHVACs(ref HoneybeeSchema.ModelEnergyProperties libSource, HoneybeeSchema.Energy.IHvac hvac = default, bool lockedMode = false) { this.Padding = new Padding(10); Title = $"From OpenStudio HVAC library - {DialogHelper.PluginName}"; WindowStyle = WindowStyle.Default; Width = 450; this.Icon = DialogHelper.HoneybeeIcon; if (hvac == null) // add a new system { _vm = new OpsHVACsViewModel(libSource, this); } else // edit existing system { _vm = new OpsHVACsViewModel(libSource, hvac, this); } var layout = new DynamicLayout() { DataContext = _vm }; layout.DefaultSpacing = new Size(5, 5); layout.DefaultPadding = new Padding(5); // add a new system from lib if (hvac == null) { // UI for system groups var hvacGroups = new DropDown(); var hvacTypes = new DropDown(); var hvacEquipments = new DropDown(); hvacGroups.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.HvacGroups); hvacGroups.SelectedKeyBinding.BindDataContext((OpsHVACsViewModel m) => m.HvacGroup); hvacTypes.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.HvacTypes); hvacTypes.ItemTextBinding = Binding.Delegate <Type, string>(t => _vm.HVACTypesDic[t]); hvacTypes.SelectedValueBinding.BindDataContext((OpsHVACsViewModel m) => m.HvacType); hvacEquipments.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.HvacEquipmentTypes); hvacEquipments.ItemTextBinding = Binding.Delegate <string, string>(t => _vm.HVACsDic[t]); hvacEquipments.SelectedKeyBinding.BindDataContext((OpsHVACsViewModel m) => m.HvacEquipmentType); layout.AddRow("HVAC Groups:"); layout.AddRow(hvacGroups); layout.AddRow("HVAC Types:"); layout.AddRow(hvacTypes); layout.AddRow("HVAC Equipment Types:"); layout.AddRow(hvacEquipments); layout.AddRow(null); } var year = new DropDown(); var nameText = new TextBox(); var economizer = new DropDown(); var sensible = new NumericStepper() { MinValue = 0, MaxValue = 1, MaximumDecimalPlaces = 2, Increment = 0.1 }; var latent = new NumericStepper() { MinValue = 0, MaxValue = 1, MaximumDecimalPlaces = 2, Increment = 0.1 }; nameText.TextBinding.BindDataContext((OpsHVACsViewModel m) => m.Name); year.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.Vintages); year.SelectedKeyBinding.BindDataContext((OpsHVACsViewModel m) => m.Vintage); var economizerTitle = new Label() { Text = "Economizer:" }; economizer.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.Economizers); economizer.SelectedKeyBinding.BindDataContext((OpsHVACsViewModel m) => m.Economizer); economizer.BindDataContext(c => c.Enabled, (OpsHVACsViewModel m) => m.EconomizerVisable); economizer.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.EconomizerVisable); economizerTitle.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.EconomizerVisable); var sensibleTitle = new Label() { Text = "Sensible Heat Recovery:" }; sensible.BindDataContext(c => c.Value, (OpsHVACsViewModel m) => m.SensibleHR); sensible.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.SensibleHRVisable); sensibleTitle.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.SensibleHRVisable); var latentTitle = new Label() { Text = "Latent Heat Recovery:" }; latent.BindDataContext(c => c.Value, (OpsHVACsViewModel m) => m.LatentHR); latent.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.LatentHRVisable); latentTitle.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.LatentHRVisable); var dcv = new CheckBox() { Text = "Demand Control Ventilation" }; dcv.Bind(_ => _.Checked, _vm, _ => _.DcvChecked); dcv.Bind(c => c.Visible, _vm, _ => _.DcvVisable); var availabilityTitle = new Label() { Text = "DOAS Availability Schedule:" }; availabilityTitle.Bind(c => c.Visible, _vm, _ => _.AvaliabilityVisable); var availability = new OptionalButton(); availability.Bind(c => c.Visible, _vm, _ => _.AvaliabilityVisable); availability.TextBinding.Bind(_vm, _ => _.AvaliabilitySchedule.BtnName); availability.Bind(_ => _.Command, _vm, _ => _.AvaliabilityCommand); availability.Bind(_ => _.RemoveCommand, _vm, _ => _.RemoveAvaliabilityCommand); availability.Bind(_ => _.IsRemoveVisable, _vm, _ => _.AvaliabilitySchedule.IsRemoveVisable); var radSettings = GenRadSettingsPanel(); var gp = new GroupBox() { Text = "HVAC System settings" }; var gpLayout = new DynamicLayout(); gpLayout.DefaultPadding = new Padding(5); // fix the height of layout in case of creating a new system, otherwise, autosize height if (hvac == null) { gpLayout.Height = 250; gpLayout.BeginScrollable(BorderType.None); } var gpGeneralLayout = new DynamicLayout(); //gpLayout.BeginGroup("HVAC System settings", new Padding(5), new Size(5, 0)); gpGeneralLayout.Spacing = new Size(5, 2); gpGeneralLayout.AddRow("Name:"); gpGeneralLayout.AddRow(nameText); gpGeneralLayout.AddRow("Vintage:"); gpGeneralLayout.AddRow(year); gpGeneralLayout.AddRow(economizerTitle); gpGeneralLayout.AddRow(economizer); gpGeneralLayout.AddRow(sensibleTitle); gpGeneralLayout.AddRow(sensible); gpGeneralLayout.AddRow(latentTitle); gpGeneralLayout.AddRow(latent); gpGeneralLayout.AddRow(availabilityTitle); gpGeneralLayout.AddRow(availability); gpGeneralLayout.AddRow(dcv); gpLayout.AddRow(gpGeneralLayout); gpLayout.AddRow(radSettings); //gpLayout.EndGroup(); gp.Content = gpLayout; layout.AddRow(gp); var locked = new CheckBox() { Text = "Locked", Enabled = false }; locked.Checked = lockedMode; var OKButton = new Button { Text = "OK", Enabled = !lockedMode }; OKButton.Click += (sender, e) => { var obj = _vm.GreateHvac(hvac); OkCommand.Execute(obj); }; AbortButton = new Button { Text = "Cancel" }; AbortButton.Click += (sender, e) => Close(); layout.AddSeparateRow(locked, null, OKButton, this.AbortButton, null, null); //layout.AddRow(null); Content = layout; }
public static Control GetView(Bivouac bivouac) { ComboBox typeDropDown = new ComboBox(); typeDropDown.DataContext = bivouac; typeDropDown.DataStore = ConstantManager.Instance.BivouacTypes; typeDropDown.BindDataContext(c => c.SelectedKey, (Bivouac m) => m.Type); typeDropDown.Tag = "Type"; ComboBox noteDropDown = new ComboBox(); noteDropDown.DataContext = bivouac; noteDropDown.DataStore = ConstantManager.Instance.Notes; noteDropDown.BindDataContext(c => c.SelectedKey, (Bivouac m) => m.Note); noteDropDown.TextColor = Colors.Gold; noteDropDown.Tag = "Note"; TextBox addressTextBox = new TextBox(); addressTextBox.DataContext = bivouac; addressTextBox.BindDataContext(c => c.Text, (Bivouac m) => m.Address); addressTextBox.Tag = "Address"; TextBox cityTextBox = new TextBox(); cityTextBox.DataContext = bivouac; cityTextBox.BindDataContext(c => c.Text, (Bivouac m) => m.City); cityTextBox.Tag = "City"; ComboBox countryDropDown = new ComboBox(); countryDropDown.DataContext = bivouac; countryDropDown.DataStore = ConstantManager.Instance.Countries; countryDropDown.BindDataContext(c => c.SelectedKey, (Bivouac m) => m.Country); countryDropDown.Tag = "Country"; TextBox coordinatesTextBox = new TextBox(); coordinatesTextBox.DataContext = bivouac; coordinatesTextBox.BindDataContext(c => c.Text, (Bivouac m) => m.Coordinates); coordinatesTextBox.Tag = "Lat, Long"; NumericStepper elevationNumericUpDown = new NumericStepper(); elevationNumericUpDown.DataContext = bivouac; elevationNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.Elevation); elevationNumericUpDown.Tag = "Height (m)"; NumericStepper distanceNumericUpDown = new NumericStepper(); distanceNumericUpDown.DataContext = bivouac; distanceNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.Distance); distanceNumericUpDown.Tag = "Total (km)"; NumericStepper distanceTrackNumericUpDown = new NumericStepper(); distanceTrackNumericUpDown.DataContext = bivouac; distanceTrackNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.DistanceTrack); distanceTrackNumericUpDown.Tag = "Track (km)"; NumericStepper walkNumericUpDown = new NumericStepper(); walkNumericUpDown.DataContext = bivouac; walkNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.Walk); walkNumericUpDown.Tag = "Walk (m)"; NumericStepper wakeUpTemperatureNumericUpDown = new NumericStepper(); wakeUpTemperatureNumericUpDown.DataContext = bivouac; wakeUpTemperatureNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.WakeUpTemperature); wakeUpTemperatureNumericUpDown.Tag = "Wake T (C°)"; CheckBox photoCheckBox = new CheckBox(); photoCheckBox.DataContext = bivouac; photoCheckBox.BindDataContext(c => c.Checked, (Bivouac m) => m.Photo); photoCheckBox.Tag = "Photo"; photoCheckBox.Width = 14; CheckBox fromiOverLanderCheckBox = new CheckBox(); fromiOverLanderCheckBox.DataContext = bivouac; fromiOverLanderCheckBox.BindDataContext(c => c.Checked, (Bivouac m) => m.FromIOverLander); fromiOverLanderCheckBox.Tag = "iOverLander"; fromiOverLanderCheckBox.Width = 14; CheckBox toiOverLanderCheckBox = new CheckBox(); toiOverLanderCheckBox.DataContext = bivouac; toiOverLanderCheckBox.BindDataContext(c => c.Checked, (Bivouac m) => m.ToIOverLander); toiOverLanderCheckBox.Tag = "Shared"; toiOverLanderCheckBox.Width = 14; TextArea commentTextArea = new TextArea(); commentTextArea.DataContext = bivouac; commentTextArea.BindDataContext(c => c.Text, (Bivouac m) => m.Comments); GridView tagsGrid = new GridView(); tagsGrid.DataStore = bivouac.GetBivouacTags(); tagsGrid.ShowHeader = false; tagsGrid.Width = 170; tagsGrid.Columns.Add(new GridColumn { DataCell = new CheckBoxCell { Binding = Binding.Property <Tag, bool?>(r => r.IsChecked) }, Editable = true }); tagsGrid.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property <Tag, string>(r => r.Name) }, Editable = false }); var infoColumn = ViewHelper.AppendV( ViewHelper.AppendH(ViewHelper.Labelize(typeDropDown), ViewHelper.Labelize(addressTextBox)), ViewHelper.AppendH(ViewHelper.Labelize(noteDropDown), ViewHelper.Labelize(cityTextBox), ViewHelper.Labelize(elevationNumericUpDown)), ViewHelper.AppendH(ViewHelper.Labelize(wakeUpTemperatureNumericUpDown), ViewHelper.Labelize(countryDropDown)), ViewHelper.AppendH(ViewHelper.Labelize(distanceNumericUpDown), ViewHelper.Labelize(coordinatesTextBox)), ViewHelper.AppendH(ViewHelper.Labelize(distanceTrackNumericUpDown), ViewHelper.Labelize(elevationNumericUpDown)), ViewHelper.AppendH(ViewHelper.Labelize(walkNumericUpDown), ViewHelper.Labelize(photoCheckBox, 42), ViewHelper.Labelize(fromiOverLanderCheckBox, 79), ViewHelper.Labelize(toiOverLanderCheckBox, 49)) ); return(new GroupBox() { Padding = 5, Content = ViewHelper.AppendH(infoColumn, tagsGrid, new Label() { Width = 20 }, commentTextArea), Text = "Bivouac" }); }