예제 #1
0
 public void MergeWith(ModelRadianceProperties other)
 {
     if (other == null)
     {
         return;
     }
     this.AddModifiers(other.ModifierList);
     this.AddModifierSets(other.ModifierSetList);
 }
예제 #2
0
        public ModifierSetManagerViewModel(HB.ModelRadianceProperties libSource, Control control = default) : base(control)
        {
            _modelRadianceProperties = libSource;

            this._userData   = libSource.ModifierSetList.OfType <ModifierSetAbridged>().Select(_ => new ModifierSetViewData(_)).ToList();
            this._systemData = SystemRadianceLib.ModifierSetList.OfType <ModifierSetAbridged>().Select(_ => new ModifierSetViewData(_)).ToList();
            this._allData    = _userData.Concat(_systemData).Distinct(_viewDataComparer).ToList();

            ResetDataCollection();
        }
 public static void AddModifierSets(this ModelRadianceProperties modelRadianceCollection, List <IDdRadianceBaseModel> modifierSets)
 {
     if (modifierSets == null)
     {
         return;
     }
     foreach (var item in modifierSets)
     {
         modelRadianceCollection.AddModifierSet(item);
     }
 }
 public static void AddModifiers(this ModelRadianceProperties modelRadianceCollection, List <ModifierBase> modifiers)
 {
     if (modifiers == null)
     {
         return;
     }
     foreach (var item in modifiers)
     {
         modelRadianceCollection.AddModifier(item);
     }
 }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ModelProperties" /> class.
        /// </summary>
        /// <param name="energy">energy.</param>
        /// <param name="radiance">radiance.</param>
        public ModelProperties
        (
            // Required parameters
            ModelEnergyProperties energy = default, ModelRadianceProperties radiance = default // Optional parameters
        ) : base()                                                                             // BaseClass
        {
            this.Energy   = energy;
            this.Radiance = radiance;

            // Set non-required readonly properties with defaultValue
            this.Type = "ModelProperties";
        }
예제 #6
0
        internal HB.ModelRadianceProperties CheckResources(HB.ModelRadianceProperties libSource)
        {
            var eng = new ModelRadianceProperties();

            eng.AddModifierSet(this.ModifierSet);


            var names = this.ModifierSet.GetAllModifiers();
            var mods  = names.Select(_ => libSource.ModifierList.FirstOrDefault(c => c.Identifier == _)).Where(_ => _ != null);

            eng.AddModifiers(mods);

            return(eng.DuplicateModelRadianceProperties());
        }
        public static void AddModifier(this ModelRadianceProperties modelRadianceCollection, ModifierBase modifier)
        {
            modelRadianceCollection.Modifiers = modelRadianceCollection.Modifiers ?? new List <AnyOf <Plastic, Glass, BSDF, Glow, Light, Trans, Metal, Void, Mirror> >();
            var exist = modelRadianceCollection.Modifiers.OfType <ModifierBase>().Any(_ => _.Identifier == modifier.Identifier);

            if (exist)
            {
                return;
            }
            switch (modifier)
            {
            case Plastic obj:
                modelRadianceCollection.Modifiers.Add(obj);
                break;

            case Glass obj:
                modelRadianceCollection.Modifiers.Add(obj);
                break;

            case Trans obj:
                modelRadianceCollection.Modifiers.Add(obj);
                break;

            case Metal obj:
                modelRadianceCollection.Modifiers.Add(obj);
                break;

            case Mirror obj:
                modelRadianceCollection.Modifiers.Add(obj);
                break;

            case Glow obj:
                modelRadianceCollection.Modifiers.Add(obj);
                break;

            case Light obj:
                modelRadianceCollection.Modifiers.Add(obj);
                break;

            case BSDF obj:
                modelRadianceCollection.Modifiers.Add(obj);
                break;

            default:
                throw new ArgumentException($"{modifier.GetType()}({modifier.Identifier}) is not added to model");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ModelProperties" /> class.
        /// </summary>
        /// <param name="energy">energy.</param>
        /// <param name="radiance">radiance.</param>
        public ModelProperties
        (
            // Required parameters
            ModelEnergyProperties energy = default, ModelRadianceProperties radiance = default // Optional parameters
        ) : base()                                                                             // BaseClass
        {
            this.Energy   = energy;
            this.Radiance = radiance;

            // Set non-required readonly properties with defaultValue
            this.Type = "ModelProperties";

            // check if object is valid, only check for inherited class
            if (this.GetType() == typeof(ModelProperties))
            {
                this.IsValid(throwException: true);
            }
        }
        public static void AddModifierSet(this ModelRadianceProperties modelRadianceCollection, IDdRadianceBaseModel modifierSet)
        {
            modelRadianceCollection.ModifierSets = modelRadianceCollection.ModifierSets ?? new List <AnyOf <ModifierSet, ModifierSetAbridged> >();
            var exist = modelRadianceCollection.ModifierSets.OfType <IDdRadianceBaseModel>().Any(_ => _.Identifier == modifierSet.Identifier);

            if (exist)
            {
                return;
            }
            switch (modifierSet)
            {
            case ModifierSet em:
                modelRadianceCollection.ModifierSets.Add(em);
                break;

            case ModifierSetAbridged em:
                modelRadianceCollection.ModifierSets.Add(em);
                break;

            default:
                throw new ArgumentException($"{modifierSet.GetType()}({modifierSet.Identifier}) is not added to model");
            }
        }
        public Dialog_ModifierSet_Interior(ref HB.ModelRadianceProperties libSource, InteriorSet ModifierSet, bool lockedMode = false)
        {
            try
            {
                _vm = new ModifierSetViewModel_Interior(this, ref libSource, ModifierSet);

                Padding     = new Padding(5);
                Resizable   = true;
                Title       = $"Interior Modifier Set - {DialogHelper.PluginName}";
                WindowStyle = WindowStyle.Default;
                Width       = 450;
                this.Icon   = DialogHelper.HoneybeeIcon;


                var interiorGroup = GenInteriorSetPanel(lockedMode);

                //Left panel
                var panelLeft = new DynamicLayout();
                panelLeft.DefaultSpacing = new Size(0, 5);

                panelLeft.AddRow(interiorGroup);


                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.GetHBObject();
                    this.Close(obj);
                };

                AbortButton = new Button {
                    Text = "Cancel"
                };
                AbortButton.Click += (sender, e) => Close();

                var buttons = new TableLayout
                {
                    Padding = new Padding(5, 10, 5, 5),
                    Spacing = new Size(10, 10),
                    Rows    = { new TableRow(locked, null, OkButton, this.AbortButton, null) }
                };


                //Create layout
                Content = new TableLayout()
                {
                    Padding = new Padding(10),
                    Spacing = new Size(5, 5),
                    Rows    =
                    {
                        panelLeft,
                        new TableRow(buttons),
                        null
                    }
                };
            }
            catch (Exception e)
            {
                Dialog_Message.Show(e.ToString());
                //throw e;
            }
        }
예제 #11
0
        public Dialog_ModifierSet(ref HB.ModelRadianceProperties libSource, HB.ModifierSetAbridged ModifierSet, bool lockedMode = false)
        {
            try
            {
                _vm = new ModifierSetViewModel(this, ref libSource, ModifierSet);

                Padding     = new Padding(5);
                Resizable   = true;
                Title       = $"Modifier Set - {DialogHelper.PluginName}";
                WindowStyle = WindowStyle.Default;
                MinimumSize = new Size(450, 600);
                this.Icon   = DialogHelper.HoneybeeIcon;


                var nameTbx = new TextBox()
                {
                    Enabled = !lockedMode
                };
                nameTbx.TextBinding.Bind(_vm, _ => _.Name);

                var wallGroup     = GenWallSetPanel(lockedMode);
                var floorGroup    = GenFloorSetPanel(lockedMode);
                var roofGroup     = GenRoofSetPanel(lockedMode);
                var apertureGroup = GenApertureSetPanel(lockedMode);
                var doorGroup     = GenDoorSetPanel(lockedMode);
                var shadeGroup    = GenShadeSetPanel(lockedMode);
                var airBdGroup    = GenAirBoundarySetPanel(lockedMode);


                //Left panel
                var panelLeft = new DynamicLayout();
                panelLeft.DefaultSpacing = new Size(0, 5);

                panelLeft.BeginScrollable(BorderType.None);
                panelLeft.Height = 600;


                panelLeft.AddRow("Name");
                panelLeft.AddRow(nameTbx);
                panelLeft.AddRow(wallGroup);
                panelLeft.AddRow(floorGroup);
                panelLeft.AddRow(roofGroup);
                panelLeft.AddRow(apertureGroup);
                panelLeft.AddRow(doorGroup);
                panelLeft.AddRow(shadeGroup);
                panelLeft.AddRow(airBdGroup);

                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.GetHBObject();
                    OkCommand.Execute(obj);
                };

                AbortButton = new Button {
                    Text = "Cancel"
                };
                AbortButton.Click += (sender, e) => Close();

                var hbData = new Button {
                    Text = "Schema Data"
                };
                hbData.Command = _vm.HBDataBtnClick;

                var buttons = new TableLayout
                {
                    Padding = new Padding(5, 10, 5, 5),
                    Spacing = new Size(10, 10),
                    Rows    = { new TableRow(locked, null, OkButton, this.AbortButton, null, hbData) }
                };


                //Create layout
                Content = new TableLayout()
                {
                    Padding = new Padding(10),
                    Spacing = new Size(5, 5),
                    Rows    =
                    {
                        panelLeft,
                        new TableRow(buttons),
                        null
                    }
                };
            }
            catch (Exception e)
            {
                Dialog_Message.Show(e.ToString());
                //throw e;
            }
        }