Esempio n. 1
0
 /// <summary>
 /// Get the total value of a Matrix attribute of this gear after children and Overclocker
 /// </summary>
 public static int GetTotalMatrixAttribute(this IHasMatrixAttributes objThis, string strAttributeName)
 {
     if (objThis == null)
     {
         return(0);
     }
     return(objThis.GetBaseMatrixAttribute(strAttributeName) + objThis.GetBonusMatrixAttribute(strAttributeName));
 }
Esempio n. 2
0
        /// <summary>
        /// Refreshes a set of ComboBoxes corresponding to Matrix attributes
        /// </summary>
        public static void RefreshMatrixAttributeCBOs(this IHasMatrixAttributes objThis, ComboBox cboAttack, ComboBox cboSleaze, ComboBox cboDP, ComboBox cboFirewall)
        {
            if (objThis == null)
            {
                return;
            }
            if (cboAttack == null)
            {
                throw new ArgumentNullException(nameof(cboAttack));
            }
            if (cboSleaze == null)
            {
                throw new ArgumentNullException(nameof(cboSleaze));
            }
            if (cboDP == null)
            {
                throw new ArgumentNullException(nameof(cboDP));
            }
            if (cboFirewall == null)
            {
                throw new ArgumentNullException(nameof(cboFirewall));
            }

            int intBaseAttack    = objThis.GetBaseMatrixAttribute("Attack");
            int intBaseSleaze    = objThis.GetBaseMatrixAttribute("Sleaze");
            int intBaseDP        = objThis.GetBaseMatrixAttribute("Data Processing");
            int intBaseFirewall  = objThis.GetBaseMatrixAttribute("Firewall");
            int intBonusAttack   = objThis.GetBonusMatrixAttribute("Attack");
            int intBonusSleaze   = objThis.GetBonusMatrixAttribute("Sleaze");
            int intBonusDP       = objThis.GetBonusMatrixAttribute("Data Processing");
            int intBonusFirewall = objThis.GetBonusMatrixAttribute("Firewall");

            cboAttack.SuspendLayout();
            cboSleaze.SuspendLayout();
            cboDP.SuspendLayout();
            cboFirewall.SuspendLayout();
            cboAttack.BeginUpdate();
            cboSleaze.BeginUpdate();
            cboDP.BeginUpdate();
            cboFirewall.BeginUpdate();

            cboAttack.Enabled        = false;
            cboAttack.BindingContext = new BindingContext();
            cboAttack.DataSource     = new List <string>(4)
            {
                (intBaseAttack + intBonusAttack).ToString(GlobalOptions.InvariantCultureInfo), (intBaseSleaze + intBonusAttack).ToString(GlobalOptions.InvariantCultureInfo), (intBaseDP + intBonusAttack).ToString(GlobalOptions.InvariantCultureInfo), (intBaseFirewall + intBonusAttack).ToString(GlobalOptions.InvariantCultureInfo)
            };
            cboAttack.SelectedIndex = 0;
            cboAttack.Visible       = true;
            cboAttack.Enabled       = objThis.CanSwapAttributes;

            cboSleaze.Enabled        = false;
            cboSleaze.BindingContext = new BindingContext();
            cboSleaze.DataSource     = new List <string>(4)
            {
                (intBaseAttack + intBonusSleaze).ToString(GlobalOptions.InvariantCultureInfo), (intBaseSleaze + intBonusSleaze).ToString(GlobalOptions.InvariantCultureInfo), (intBaseDP + intBonusSleaze).ToString(GlobalOptions.InvariantCultureInfo), (intBaseFirewall + intBonusSleaze).ToString(GlobalOptions.InvariantCultureInfo)
            };
            cboSleaze.SelectedIndex = 1;
            cboSleaze.Visible       = true;
            cboSleaze.Enabled       = objThis.CanSwapAttributes;

            cboDP.Enabled        = false;
            cboDP.BindingContext = new BindingContext();
            cboDP.DataSource     = new List <string>(4)
            {
                (intBaseAttack + intBonusDP).ToString(GlobalOptions.InvariantCultureInfo), (intBaseSleaze + intBonusDP).ToString(GlobalOptions.InvariantCultureInfo), (intBaseDP + intBonusDP).ToString(GlobalOptions.InvariantCultureInfo), (intBaseFirewall + intBonusDP).ToString(GlobalOptions.InvariantCultureInfo)
            };
            cboDP.SelectedIndex = 2;
            cboDP.Visible       = true;
            cboDP.Enabled       = objThis.CanSwapAttributes;

            cboFirewall.Enabled        = false;
            cboFirewall.BindingContext = new BindingContext();
            cboFirewall.DataSource     = new List <string>(4)
            {
                (intBaseAttack + intBonusFirewall).ToString(GlobalOptions.InvariantCultureInfo), (intBaseSleaze + intBonusFirewall).ToString(GlobalOptions.InvariantCultureInfo), (intBaseDP + intBonusFirewall).ToString(GlobalOptions.InvariantCultureInfo), (intBaseFirewall + intBonusFirewall).ToString(GlobalOptions.InvariantCultureInfo)
            };
            cboFirewall.SelectedIndex = 3;
            cboFirewall.Visible       = true;
            cboFirewall.Enabled       = objThis.CanSwapAttributes;

            cboAttack.EndUpdate();
            cboSleaze.EndUpdate();
            cboDP.EndUpdate();
            cboFirewall.EndUpdate();
            cboAttack.ResumeLayout();
            cboSleaze.ResumeLayout();
            cboDP.ResumeLayout();
            cboFirewall.ResumeLayout();
        }
Esempio n. 3
0
        /// <summary>
        /// Refreshes a set of ComboBoxes corresponding to Matrix attributes
        /// </summary>
        public static void RefreshMatrixAttributeCBOs(this IHasMatrixAttributes objThis, ComboBox cboAttack, ComboBox cboSleaze, ComboBox cboDP, ComboBox cboFirewall)
        {
            if (objThis == null)
            {
                return;
            }

            int intBaseAttack    = objThis.GetBaseMatrixAttribute("Attack");
            int intBaseSleaze    = objThis.GetBaseMatrixAttribute("Sleaze");
            int intBaseDP        = objThis.GetBaseMatrixAttribute("Data Processing");
            int intBaseFirewall  = objThis.GetBaseMatrixAttribute("Firewall");
            int intBonusAttack   = objThis.GetBonusMatrixAttribute("Attack");
            int intBonusSleaze   = objThis.GetBonusMatrixAttribute("Sleaze");
            int intBonusDP       = objThis.GetBonusMatrixAttribute("Data Processing");
            int intBonusFirewall = objThis.GetBonusMatrixAttribute("Firewall");

            cboAttack.BeginUpdate();
            cboSleaze.BeginUpdate();
            cboDP.BeginUpdate();
            cboFirewall.BeginUpdate();

            cboAttack.Enabled        = false;
            cboAttack.BindingContext = new BindingContext();
            cboAttack.ValueMember    = "Value";
            cboAttack.DisplayMember  = "Name";
            cboAttack.DataSource     = new List <string>()
            {
                (intBaseAttack + intBonusAttack).ToString(), (intBaseSleaze + intBonusAttack).ToString(), (intBaseDP + intBonusAttack).ToString(), (intBaseFirewall + intBonusAttack).ToString()
            };
            cboAttack.SelectedIndex = 0;
            cboAttack.Visible       = true;
            cboAttack.Enabled       = objThis.CanSwapAttributes;

            cboSleaze.Enabled        = false;
            cboSleaze.BindingContext = new BindingContext();
            cboSleaze.ValueMember    = "Value";
            cboSleaze.DisplayMember  = "Name";
            cboSleaze.DataSource     = new List <string>()
            {
                (intBaseAttack + intBonusSleaze).ToString(), (intBaseSleaze + intBonusSleaze).ToString(), (intBaseDP + intBonusSleaze).ToString(), (intBaseFirewall + intBonusSleaze).ToString()
            };
            cboSleaze.SelectedIndex = 1;
            cboSleaze.Visible       = true;
            cboSleaze.Enabled       = objThis.CanSwapAttributes;

            cboDP.Enabled        = false;
            cboDP.BindingContext = new BindingContext();
            cboDP.ValueMember    = "Value";
            cboDP.DisplayMember  = "Name";
            cboDP.DataSource     = new List <string>()
            {
                (intBaseAttack + intBonusDP).ToString(), (intBaseSleaze + intBonusDP).ToString(), (intBaseDP + intBonusDP).ToString(), (intBaseFirewall + intBonusDP).ToString()
            };
            cboDP.SelectedIndex = 2;
            cboDP.Visible       = true;
            cboDP.Enabled       = objThis.CanSwapAttributes;

            cboFirewall.Enabled        = false;
            cboFirewall.BindingContext = new BindingContext();
            cboFirewall.ValueMember    = "Value";
            cboFirewall.DisplayMember  = "Name";
            cboFirewall.DataSource     = new List <string>()
            {
                (intBaseAttack + intBonusFirewall).ToString(), (intBaseSleaze + intBonusFirewall).ToString(), (intBaseDP + intBonusFirewall).ToString(), (intBaseFirewall + intBonusFirewall).ToString()
            };
            cboFirewall.SelectedIndex = 3;
            cboFirewall.Visible       = true;
            cboFirewall.Enabled       = objThis.CanSwapAttributes;

            cboAttack.EndUpdate();
            cboSleaze.EndUpdate();
            cboDP.EndUpdate();
            cboFirewall.EndUpdate();
        }
        /// <summary>
        /// Refreshes a set of ComboBoxes corresponding to Matrix attributes
        /// </summary>
        public static async Task RefreshMatrixAttributeComboBoxesAsync(this IHasMatrixAttributes objThis, ComboBox cboAttack, ComboBox cboSleaze, ComboBox cboDataProcessing, ComboBox cboFirewall)
        {
            if (objThis == null)
            {
                return;
            }
            if (cboAttack == null)
            {
                throw new ArgumentNullException(nameof(cboAttack));
            }
            if (cboSleaze == null)
            {
                throw new ArgumentNullException(nameof(cboSleaze));
            }
            if (cboDataProcessing == null)
            {
                throw new ArgumentNullException(nameof(cboDataProcessing));
            }
            if (cboFirewall == null)
            {
                throw new ArgumentNullException(nameof(cboFirewall));
            }

            int intBaseAttack          = objThis.GetBaseMatrixAttribute("Attack");
            int intBaseSleaze          = objThis.GetBaseMatrixAttribute("Sleaze");
            int intBaseDataProcessing  = objThis.GetBaseMatrixAttribute("Data Processing");
            int intBaseFirewall        = objThis.GetBaseMatrixAttribute("Firewall");
            int intBonusAttack         = objThis.GetBonusMatrixAttribute("Attack");
            int intBonusSleaze         = objThis.GetBonusMatrixAttribute("Sleaze");
            int intBonusDataProcessing = objThis.GetBonusMatrixAttribute("Data Processing");
            int intBonusFirewall       = objThis.GetBonusMatrixAttribute("Firewall");

            await cboAttack.DoThreadSafeAsync(x =>
            {
                x.SuspendLayout();
                x.BeginUpdate();
            });

            await cboSleaze.DoThreadSafeAsync(x =>
            {
                x.SuspendLayout();
                x.BeginUpdate();
            });

            await cboDataProcessing.DoThreadSafeAsync(x =>
            {
                x.SuspendLayout();
                x.BeginUpdate();
            });

            await cboFirewall.DoThreadSafeAsync(x =>
            {
                x.SuspendLayout();
                x.BeginUpdate();
            });

            try
            {
                await cboAttack.DoThreadSafeAsync(x =>
                {
                    x.Enabled        = false;
                    x.BindingContext = new BindingContext();
                    x.DataSource     = new List <string>(4)
                    {
                        (intBaseAttack + intBonusAttack).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseSleaze + intBonusAttack).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseDataProcessing + intBonusAttack).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseFirewall + intBonusAttack).ToString(GlobalSettings.InvariantCultureInfo)
                    };
                    x.SelectedIndex = 0;
                    x.Visible       = true;
                    x.Enabled       = objThis.CanSwapAttributes;
                });

                await cboSleaze.DoThreadSafeAsync(x =>
                {
                    x.Enabled        = false;
                    x.BindingContext = new BindingContext();
                    x.DataSource     = new List <string>(4)
                    {
                        (intBaseAttack + intBonusSleaze).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseSleaze + intBonusSleaze).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseDataProcessing + intBonusSleaze).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseFirewall + intBonusSleaze).ToString(GlobalSettings.InvariantCultureInfo)
                    };
                    x.SelectedIndex = 1;
                    x.Visible       = true;
                    x.Enabled       = objThis.CanSwapAttributes;
                });

                await cboDataProcessing.DoThreadSafeAsync(x =>
                {
                    x.Enabled        = false;
                    x.BindingContext = new BindingContext();
                    x.DataSource     = new List <string>(4)
                    {
                        (intBaseAttack + intBonusDataProcessing).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseSleaze + intBonusDataProcessing).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseDataProcessing + intBonusDataProcessing).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseFirewall + intBonusDataProcessing).ToString(GlobalSettings.InvariantCultureInfo)
                    };
                    x.SelectedIndex = 2;
                    x.Visible       = true;
                    x.Enabled       = objThis.CanSwapAttributes;
                });

                await cboFirewall.DoThreadSafeAsync(x =>
                {
                    x.Enabled        = false;
                    x.BindingContext = new BindingContext();
                    x.DataSource     = new List <string>(4)
                    {
                        (intBaseAttack + intBonusFirewall).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseSleaze + intBonusFirewall).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseDataProcessing + intBonusFirewall).ToString(GlobalSettings.InvariantCultureInfo),
                        (intBaseFirewall + intBonusFirewall).ToString(GlobalSettings.InvariantCultureInfo)
                    };
                    x.SelectedIndex = 3;
                    x.Visible       = true;
                    x.Enabled       = objThis.CanSwapAttributes;
                });
            }
            finally
            {
                await cboAttack.DoThreadSafeAsync(x =>
                {
                    x.EndUpdate();
                    x.ResumeLayout();
                });

                await cboSleaze.DoThreadSafeAsync(x =>
                {
                    x.EndUpdate();
                    x.ResumeLayout();
                });

                await cboDataProcessing.DoThreadSafeAsync(x =>
                {
                    x.EndUpdate();
                    x.ResumeLayout();
                });

                await cboFirewall.DoThreadSafeAsync(x =>
                {
                    x.EndUpdate();
                    x.ResumeLayout();
                });
            }
        }