Example #1
0
        public SkillControl2(Skill objSkill)
        {
            if (objSkill == null)
            {
                return;
            }
            _objGraphics        = CreateGraphics();
            _objSkill           = objSkill;
            _objAttributeActive = objSkill.AttributeObject;
            InitializeComponent();
            SkillControl2_DpiChangedAfterParent(null, EventArgs.Empty);
            this.UpdateLightDarkMode();
            this.TranslateWinForm();

            foreach (ToolStripItem tssItem in cmsSkillLabel.Items)
            {
                tssItem.UpdateLightDarkMode();
                tssItem.TranslateToolStripItemsRecursively();
            }

            SuspendLayout();

            //Display
            _fntNormalName = lblName.Font;
            _fntItalicName = new Font(_fntNormalName, FontStyle.Italic);
            _fntNormal     = btnAttribute.Font;
            _fntItalic     = new Font(_fntNormal, FontStyle.Italic);

            if (!_objSkill.Default)
            {
                lblName.Font = _fntItalicName;
            }
            lblName.DoOneWayDataBinding("Text", objSkill, nameof(Skill.CurrentDisplayName));
            lblName.DoOneWayDataBinding("ForeColor", objSkill, nameof(Skill.PreferredColor));
            lblName.DoOneWayDataBinding("ToolTipText", objSkill, nameof(Skill.HtmlSkillToolTip));

            btnAttribute.DoOneWayDataBinding("Text", objSkill, nameof(Skill.DisplayAttribute));

            lblModifiedRating.Text        = objSkill.DisplayOtherAttribute(_objAttributeActive.Abbrev);
            lblModifiedRating.ToolTipText = objSkill.CompileDicepoolTooltip(_objAttributeActive.Abbrev);

            // Creating controls outside of the designer saves on handles if the controls would be invisible anyway
            if (objSkill.AllowDelete) // For active skills, can only change by going from Create to Career mode, so no databinding necessary
            {
                cmdDelete = new Button
                {
                    AutoSize                = true,
                    AutoSizeMode            = AutoSizeMode.GrowAndShrink,
                    Dock                    = DockStyle.Fill,
                    Margin                  = new Padding(3, 0, 3, 0),
                    Name                    = "cmdDelete",
                    Tag                     = "String_Delete",
                    Text                    = "Delete",
                    UseVisualStyleBackColor = true
                };
                cmdDelete.Click += cmdDelete_Click;
                cmdDelete.UpdateLightDarkMode();
                cmdDelete.TranslateWinForm();
                tlpRight.Controls.Add(cmdDelete, 4, 0);
            }

            if (objSkill.CharacterObject.Created)
            {
                lblCareerRating = new Label
                {
                    Anchor      = AnchorStyles.Right,
                    AutoSize    = true,
                    MinimumSize = new Size((int)(25 * _objGraphics.DpiX / 96.0f), 0),
                    Name        = "lblCareerRating",
                    Text        = "00",
                    TextAlign   = ContentAlignment.MiddleRight
                };
                btnCareerIncrease = new ButtonWithToolTip
                {
                    Anchor                  = AnchorStyles.Right,
                    AutoSize                = true,
                    AutoSizeMode            = AutoSizeMode.GrowAndShrink,
                    Image                   = Resources.add,
                    Margin                  = new Padding(3, 0, 3, 0),
                    Name                    = "btnCareerIncrease",
                    Padding                 = new Padding(1),
                    UseVisualStyleBackColor = true
                };
                btnCareerIncrease.Click += btnCareerIncrease_Click;

                lblCareerRating.DoOneWayDataBinding("Text", objSkill, nameof(Skill.Rating));
                btnCareerIncrease.DoOneWayDataBinding("Enabled", objSkill, nameof(Skill.CanUpgradeCareer));
                btnCareerIncrease.DoOneWayDataBinding("ToolTipText", objSkill, nameof(Skill.UpgradeToolTip));

                lblCareerRating.UpdateLightDarkMode();
                lblCareerRating.TranslateWinForm();
                btnCareerIncrease.UpdateLightDarkMode();
                btnCareerIncrease.TranslateWinForm();
                tlpMain.Controls.Add(lblCareerRating, 2, 0);
                tlpMain.Controls.Add(btnCareerIncrease, 3, 0);

                btnAddSpec = new ButtonWithToolTip
                {
                    Anchor                  = AnchorStyles.Right,
                    AutoSize                = true,
                    AutoSizeMode            = AutoSizeMode.GrowAndShrink,
                    Image                   = Resources.add,
                    Margin                  = new Padding(3, 0, 3, 0),
                    Name                    = "btnAddSpec",
                    Padding                 = new Padding(1),
                    UseVisualStyleBackColor = true
                };
                btnAddSpec.Click += btnAddSpec_Click;
                lblCareerSpec     = new Label
                {
                    Anchor    = AnchorStyles.Left,
                    AutoSize  = true,
                    Name      = "lblCareerSpec",
                    Text      = "[Specializations]",
                    TextAlign = ContentAlignment.MiddleLeft
                };
                lblCareerSpec.DoOneWayDataBinding("Text", objSkill, nameof(Skill.CurrentDisplaySpecialization));
                btnAddSpec.DoOneWayDataBinding("Enabled", objSkill, nameof(Skill.CanAffordSpecialization));
                btnAddSpec.DoOneWayDataBinding("Visible", objSkill, nameof(Skill.CanHaveSpecs));
                btnAddSpec.DoOneWayDataBinding("ToolTipText", objSkill, nameof(Skill.AddSpecToolTip));

                lblCareerSpec.UpdateLightDarkMode();
                lblCareerSpec.TranslateWinForm();
                btnAddSpec.UpdateLightDarkMode();
                btnAddSpec.TranslateWinForm();
                tlpRight.Controls.Add(lblCareerSpec, 0, 0);
                tlpRight.Controls.Add(btnAddSpec, 1, 0);

                List <ListItem> lstAttributeItems = new List <ListItem>(AttributeSection.AttributeStrings.Count);
                foreach (string strLoopAttribute in AttributeSection.AttributeStrings)
                {
                    if (strLoopAttribute == "MAGAdept")
                    {
                        if (!objSkill.CharacterObject.Options.MysAdeptSecondMAGAttribute)
                        {
                            continue;
                        }
                        lstAttributeItems.Add(new ListItem(strLoopAttribute, LanguageManager.MAGAdeptString()));
                    }
                    else
                    {
                        string strAttributeShort = LanguageManager.GetString("String_Attribute" + strLoopAttribute + "Short", GlobalOptions.Language, false);
                        lstAttributeItems.Add(new ListItem(strLoopAttribute, !string.IsNullOrEmpty(strAttributeShort) ? strAttributeShort : strLoopAttribute));
                    }
                }

                cboSelectAttribute = new ElasticComboBox
                {
                    Anchor            = AnchorStyles.Left | AnchorStyles.Right,
                    DropDownStyle     = ComboBoxStyle.DropDownList,
                    FormattingEnabled = true,
                    Margin            = new Padding(3, 0, 3, 0),
                    Name = "cboSelectAttribute"
                };
                cboSelectAttribute.DropDownClosed += cboSelectAttribute_Closed;
                cboSelectAttribute.BeginUpdate();
                cboSelectAttribute.DataSource    = null;
                cboSelectAttribute.DisplayMember = nameof(ListItem.Name);
                cboSelectAttribute.ValueMember   = nameof(ListItem.Value);
                cboSelectAttribute.DataSource    = lstAttributeItems;
                cboSelectAttribute.SelectedValue = _objSkill.AttributeObject.Abbrev;
                cboSelectAttribute.EndUpdate();
                cboSelectAttribute.UpdateLightDarkMode();
                cboSelectAttribute.TranslateWinForm();
                pnlAttributes.Controls.Add(cboSelectAttribute);
            }
            else
            {
                nudSkill = new NumericUpDownEx
                {
                    Anchor              = AnchorStyles.Right,
                    AutoSize            = true,
                    InterceptMouseWheel = NumericUpDownEx.InterceptMouseWheelMode.WhenMouseOver,
                    Margin              = new Padding(3, 2, 3, 2),
                    Maximum             = new decimal(new[] { 99, 0, 0, 0 }),
                    Name = "nudSkill"
                };
                nudKarma = new NumericUpDownEx
                {
                    Anchor              = AnchorStyles.Right,
                    AutoSize            = true,
                    InterceptMouseWheel = NumericUpDownEx.InterceptMouseWheelMode.WhenMouseOver,
                    Margin              = new Padding(3, 2, 3, 2),
                    Maximum             = new decimal(new[] { 99, 0, 0, 0 }),
                    Name = "nudKarma"
                };

                // Trick to make it seem like the button is a label (+ onclick method not doing anything in Create mode)
                btnAttribute.FlatAppearance.MouseDownBackColor = Color.Transparent;
                btnAttribute.FlatAppearance.MouseOverBackColor = Color.Transparent;

                nudSkill.DoOneWayDataBinding("Visible", objSkill.CharacterObject, nameof(objSkill.CharacterObject.BuildMethodHasSkillPoints));
                nudSkill.DoDatabinding("Value", objSkill, nameof(Skill.Base));
                nudSkill.DoOneWayDataBinding("Enabled", objSkill, nameof(Skill.BaseUnlocked));
                nudSkill.DoOneWayDataBinding("InterceptMouseWheel", objSkill.CharacterObject.Options, nameof(CharacterOptions.InterceptMode));
                nudKarma.DoDatabinding("Value", objSkill, nameof(Skill.Karma));
                nudKarma.DoOneWayDataBinding("Enabled", objSkill, nameof(Skill.KarmaUnlocked));
                nudKarma.DoOneWayDataBinding("InterceptMouseWheel", objSkill.CharacterObject.Options, nameof(CharacterOptions.InterceptMode));

                nudSkill.UpdateLightDarkMode();
                nudSkill.TranslateWinForm();
                nudKarma.UpdateLightDarkMode();
                nudKarma.TranslateWinForm();
                tlpMain.Controls.Add(nudSkill, 2, 0);
                tlpMain.Controls.Add(nudKarma, 3, 0);

                if (objSkill.IsExoticSkill)
                {
                    lblCareerSpec = new Label
                    {
                        Anchor    = AnchorStyles.Left,
                        AutoSize  = true,
                        Name      = "lblCareerSpec",
                        Text      = "[Specializations]",
                        TextAlign = ContentAlignment.MiddleLeft
                    };
                    lblCareerSpec.DoOneWayDataBinding("Text", objSkill, nameof(Skill.CurrentDisplaySpecialization));
                    lblCareerSpec.UpdateLightDarkMode();
                    lblCareerSpec.TranslateWinForm();
                    tlpRight.Controls.Add(lblCareerSpec, 0, 0);
                }
                else
                {
                    cboSpec = new ElasticComboBox
                    {
                        Anchor            = AnchorStyles.Left | AnchorStyles.Right,
                        AutoCompleteMode  = AutoCompleteMode.Suggest,
                        FormattingEnabled = true,
                        Margin            = new Padding(3, 0, 3, 0),
                        Name    = "cboSpec",
                        Sorted  = true,
                        TabStop = false
                    };
                    cboSpec.BeginUpdate();
                    cboSpec.DataSource    = null;
                    cboSpec.DisplayMember = nameof(ListItem.Name);
                    cboSpec.ValueMember   = nameof(ListItem.Value);
                    cboSpec.DataSource    = objSkill.CGLSpecializations;
                    cboSpec.SelectedIndex = -1;
                    cboSpec.DoDatabinding("Text", objSkill, nameof(Skill.Specialization));
                    cboSpec.DoOneWayDataBinding("Enabled", objSkill, nameof(Skill.CanHaveSpecs));
                    cboSpec.EndUpdate();
                    cboSpec.UpdateLightDarkMode();
                    cboSpec.TranslateWinForm();
                    chkKarma = new ColorableCheckBox(components)
                    {
                        Anchor             = AnchorStyles.Left,
                        AutoSize           = true,
                        DefaultColorScheme = true,
                        Margin             = new Padding(3, 0, 3, 0),
                        Name = "chkKarma",
                        UseVisualStyleBackColor = true
                    };
                    chkKarma.DoOneWayDataBinding("Visible", objSkill.CharacterObject, nameof(objSkill.CharacterObject.BuildMethodHasSkillPoints));
                    chkKarma.DoDatabinding("Checked", objSkill, nameof(Skill.BuyWithKarma));
                    chkKarma.DoOneWayDataBinding("Enabled", objSkill, nameof(Skill.CanHaveSpecs));
                    chkKarma.UpdateLightDarkMode();
                    chkKarma.TranslateWinForm();
                    tlpRight.Controls.Add(cboSpec, 0, 0);
                    tlpRight.Controls.Add(chkKarma, 1, 0);
                }
            }

            this.DoOneWayDataBinding("Enabled", objSkill, nameof(Skill.Enabled));
            this.DoOneWayDataBinding("BackColor", objSkill, nameof(Skill.PreferredControlColor));

            ResumeLayout(true);

            _blnLoading = false;

            _objSkill.PropertyChanged += Skill_PropertyChanged;
        }
Example #2
0
        public AttributeControl(CharacterAttrib attribute)
        {
            if (attribute == null)
            {
                return;
            }
            _objAttribute = attribute;
            _objCharacter = attribute.CharacterObject;

            InitializeComponent();
            this.UpdateLightDarkMode();
            this.TranslateWinForm();

            SuspendLayout();
            _dataSource = _objCharacter.AttributeSection.GetAttributeBindingByName(AttributeName);
            _objCharacter.AttributeSection.PropertyChanged += AttributePropertyChanged;
            //Display
            lblName.DoOneWayDataBinding("Text", _dataSource, nameof(CharacterAttrib.DisplayNameFormatted));
            lblValue.DoOneWayDataBinding("Text", _dataSource, nameof(CharacterAttrib.DisplayValue));
            lblLimits.DoOneWayDataBinding("Text", _dataSource, nameof(CharacterAttrib.AugmentedMetatypeLimits));
            lblValue.DoOneWayDataBinding("ToolTipText", _dataSource, nameof(CharacterAttrib.ToolTip));
            if (_objCharacter.Created)
            {
                cmdImproveATT = new ButtonWithToolTip
                {
                    Anchor                  = AnchorStyles.Right,
                    AutoSize                = true,
                    AutoSizeMode            = AutoSizeMode.GrowAndShrink,
                    Image                   = Resources.add,
                    Margin                  = new Padding(3, 0, 3, 0),
                    MinimumSize             = new Size(24, 24),
                    Name                    = "cmdImproveATT",
                    UseVisualStyleBackColor = true
                };
                cmdImproveATT.Click += cmdImproveATT_Click;
                cmdImproveATT.DoOneWayDataBinding("ToolTipText", _dataSource, nameof(CharacterAttrib.UpgradeToolTip));
                cmdImproveATT.DoOneWayDataBinding("Enabled", _dataSource, nameof(CharacterAttrib.CanUpgradeCareer));
                cmdImproveATT.UpdateLightDarkMode();
                cmdImproveATT.TranslateWinForm();
                flpRight.Controls.Add(cmdImproveATT);
                if (AttributeName == "EDG")
                {
                    cmdBurnEdge = new ButtonWithToolTip
                    {
                        Anchor                  = AnchorStyles.Right,
                        AutoSize                = true,
                        AutoSizeMode            = AutoSizeMode.GrowAndShrink,
                        Image                   = Resources.fire,
                        Margin                  = new Padding(3, 0, 3, 0),
                        MinimumSize             = new Size(24, 24),
                        Name                    = "cmdBurnEdge",
                        ToolTipText             = LanguageManager.GetString("Tip_CommonBurnEdge"),
                        UseVisualStyleBackColor = true
                    };
                    cmdBurnEdge.Click += cmdBurnEdge_Click;
                    cmdBurnEdge.UpdateLightDarkMode();
                    cmdBurnEdge.TranslateWinForm();
                    flpRight.Controls.Add(cmdBurnEdge);
                }
            }
            else
            {
                while (_objAttribute.KarmaMaximum < 0 && _objAttribute.Base > 0)
                {
                    _objAttribute.Base -= 1;
                }
                // Very rough fix for when Karma values somehow exceed KarmaMaximum after loading in. This shouldn't happen in the first place, but this ad-hoc patch will help fix crashes.
                if (_objAttribute.Karma > _objAttribute.KarmaMaximum)
                {
                    _objAttribute.Karma = _objAttribute.KarmaMaximum;
                }

                nudKarma = new NumericUpDownEx
                {
                    Anchor              = AnchorStyles.Right,
                    AutoSize            = true,
                    InterceptMouseWheel = NumericUpDownEx.InterceptMouseWheelMode.WhenMouseOver,
                    Margin              = new Padding(3, 0, 3, 0),
                    Maximum             = new decimal(new[] { 99, 0, 0, 0 }),
                    MinimumSize         = new Size(35, 0),
                    Name = "nudKarma"
                };
                nudKarma.BeforeValueIncrement += nudKarma_BeforeValueIncrement;
                nudKarma.ValueChanged         += nudKarma_ValueChanged;
                nudBase = new NumericUpDownEx
                {
                    Anchor              = AnchorStyles.Right,
                    AutoSize            = true,
                    InterceptMouseWheel = NumericUpDownEx.InterceptMouseWheelMode.WhenMouseOver,
                    Margin              = new Padding(3, 0, 3, 0),
                    Maximum             = new decimal(new[] { 99, 0, 0, 0 }),
                    MinimumSize         = new Size(35, 0),
                    Name = "nudBase"
                };
                nudBase.BeforeValueIncrement += nudBase_BeforeValueIncrement;
                nudBase.ValueChanged         += nudBase_ValueChanged;

                nudBase.DoDatabinding("Visible", _objCharacter, nameof(Character.EffectiveBuildMethodUsesPriorityTables));
                nudBase.DoOneWayDataBinding("Maximum", _dataSource, nameof(CharacterAttrib.PriorityMaximum));
                nudBase.DoDatabinding("Value", _dataSource, nameof(CharacterAttrib.Base));
                nudBase.DoOneWayDataBinding("Enabled", _dataSource, nameof(CharacterAttrib.BaseUnlocked));
                nudBase.InterceptMouseWheel = GlobalOptions.InterceptMode;

                nudKarma.DoOneWayDataBinding("Maximum", _dataSource, nameof(CharacterAttrib.KarmaMaximum));
                nudKarma.DoDatabinding("Value", _dataSource, nameof(CharacterAttrib.Karma));
                nudKarma.InterceptMouseWheel = GlobalOptions.InterceptMode;

                nudBase.UpdateLightDarkMode();
                nudBase.TranslateWinForm();
                nudKarma.UpdateLightDarkMode();
                nudKarma.TranslateWinForm();

                flpRight.Controls.Add(nudKarma);
                flpRight.Controls.Add(nudBase);
            }

            ResumeLayout();
        }
        public KnowledgeSkillControl(KnowledgeSkill skill)
        {
            if (skill == null)
            {
                return;
            }
            _objGraphics        = CreateGraphics();
            _skill              = skill;
            _tmrNameChangeTimer = new Timer {
                Interval = 1000
            };
            _tmrNameChangeTimer.Tick += NameChangeTimer_Tick;
            InitializeComponent();
            KnowledgeSkillControl_DpiChangedAfterParent(null, EventArgs.Empty);
            this.UpdateLightDarkMode();
            this.TranslateWinForm();

            SuspendLayout();

            lblModifiedRating.DoOneWayDataBinding("Text", _skill, nameof(KnowledgeSkill.DisplayPool));
            lblModifiedRating.DoOneWayDataBinding("ToolTipText", _skill, nameof(KnowledgeSkill.PoolToolTip));

            cmdDelete.DoOneWayDataBinding("Visible", _skill, nameof(Skill.AllowDelete));

            cboType.BeginUpdate();
            cboType.DataSource    = null;
            cboType.DisplayMember = nameof(ListItem.Name);
            cboType.ValueMember   = nameof(ListItem.Value);
            cboType.DataSource    = KnowledgeSkill.KnowledgeTypes;
            cboType.DoDatabinding("SelectedValue", _skill, nameof(KnowledgeSkill.Type));
            cboType.DoOneWayDataBinding("Enabled", _skill, nameof(Skill.AllowTypeChange));
            cboType.EndUpdate();

            lblName.DoOneWayNegatableDatabinding("Visible", _skill, nameof(Skill.AllowNameChange));
            lblName.DoOneWayDataBinding("Text", _skill, nameof(KnowledgeSkill.WriteableName));
            lblName.DoOneWayDataBinding("ForeColor", _skill, nameof(Skill.PreferredColor));

            cboName.BeginUpdate();
            cboName.DoOneWayDataBinding("Visible", _skill, nameof(Skill.AllowNameChange));
            cboName.DataSource    = null;
            cboName.DisplayMember = nameof(ListItem.Name);
            cboName.ValueMember   = nameof(ListItem.Value);
            cboName.DataSource    = KnowledgeSkill.DefaultKnowledgeSkills;
            cboName.SelectedIndex = -1;
            cboName.Text          = _skill.WriteableName;
            cboName.EndUpdate();
            _blnUpdatingName = false;

            if (_skill.CharacterObject.Created)
            {
                lblRating = new Label
                {
                    Anchor      = AnchorStyles.Right,
                    AutoSize    = true,
                    MinimumSize = new Size((int)(25 * _objGraphics.DpiX / 96.0f), 0),
                    Name        = "lblRating",
                    Text        = "00",
                    TextAlign   = ContentAlignment.MiddleCenter
                };
                btnCareerIncrease = new ButtonWithToolTip
                {
                    Anchor                  = AnchorStyles.Right,
                    AutoSize                = true,
                    AutoSizeMode            = AutoSizeMode.GrowAndShrink,
                    Image                   = Resources.add,
                    Margin                  = new Padding(3, 0, 3, 0),
                    Name                    = "btnCareerIncrease",
                    Padding                 = new Padding(1),
                    UseVisualStyleBackColor = true
                };
                btnCareerIncrease.Click += btnCareerIncrease_Click;

                lblRating.DoOneWayNegatableDatabinding("Visible", _skill, nameof(KnowledgeSkill.IsNativeLanguage));
                lblRating.DoOneWayDataBinding("Text", _skill, nameof(Skill.Rating));

                btnCareerIncrease.DoOneWayDataBinding("Visible", _skill, nameof(KnowledgeSkill.AllowUpgrade));
                btnCareerIncrease.DoOneWayDataBinding("Enabled", _skill, nameof(Skill.CanUpgradeCareer));
                btnCareerIncrease.DoOneWayDataBinding("ToolTipText", _skill, nameof(Skill.UpgradeToolTip));

                lblRating.UpdateLightDarkMode();
                lblRating.TranslateWinForm();
                btnCareerIncrease.UpdateLightDarkMode();
                btnCareerIncrease.TranslateWinForm();
                tlpMain.Controls.Add(lblRating, 1, 0);
                tlpMain.Controls.Add(btnCareerIncrease, 2, 0);

                lblSpec = new Label
                {
                    Anchor    = AnchorStyles.Left,
                    AutoSize  = true,
                    Name      = "lblSpec",
                    Text      = "[SPEC]",
                    TextAlign = ContentAlignment.MiddleLeft
                };
                btnAddSpec = new ButtonWithToolTip
                {
                    Anchor                  = AnchorStyles.Right,
                    AutoSize                = true,
                    AutoSizeMode            = AutoSizeMode.GrowAndShrink,
                    Image                   = Resources.add,
                    Margin                  = new Padding(3, 0, 3, 0),
                    Name                    = "btnAddSpec",
                    Padding                 = new Padding(1),
                    UseVisualStyleBackColor = true
                };
                btnAddSpec.Click += btnAddSpec_Click;

                lblSpec.DoOneWayNegatableDatabinding("Visible", _skill, nameof(KnowledgeSkill.IsNativeLanguage));
                lblSpec.DoOneWayDataBinding("Text", _skill, nameof(Skill.CurrentDisplaySpecialization));

                btnAddSpec.DoOneWayDataBinding("Visible", _skill, nameof(Skill.CanHaveSpecs));
                btnAddSpec.DoOneWayDataBinding("Enabled", _skill, nameof(Skill.CanAffordSpecialization));
                btnAddSpec.DoOneWayDataBinding("ToolTipText", _skill, nameof(Skill.AddSpecToolTip));

                lblSpec.UpdateLightDarkMode();
                lblSpec.TranslateWinForm();
                btnAddSpec.UpdateLightDarkMode();
                btnAddSpec.TranslateWinForm();
                tlpMiddle.SetColumnSpan(lblSpec, 2);
                tlpMiddle.Controls.Add(lblSpec, 1, 0);
                tlpMiddle.Controls.Add(btnAddSpec, 3, 0);
            }
            else
            {
                nudSkill = new NumericUpDownEx
                {
                    Anchor              = AnchorStyles.Right,
                    AutoSize            = true,
                    InterceptMouseWheel = NumericUpDownEx.InterceptMouseWheelMode.WhenMouseOver,
                    Margin              = new Padding(3, 2, 3, 2),
                    Maximum             = new decimal(new[] { 99, 0, 0, 0 }),
                    Name = "nudSkill"
                };
                nudKarma = new NumericUpDownEx
                {
                    Anchor              = AnchorStyles.Right,
                    AutoSize            = true,
                    InterceptMouseWheel = NumericUpDownEx.InterceptMouseWheelMode.WhenMouseOver,
                    Margin              = new Padding(3, 2, 3, 2),
                    Maximum             = new decimal(new[] { 99, 0, 0, 0 }),
                    Name = "nudKarma"
                };

                nudSkill.DoOneWayDataBinding("Visible", _skill.CharacterObject.SkillsSection, nameof(SkillsSection.HasKnowledgePoints));
                nudSkill.DoOneWayDataBinding("Enabled", _skill, nameof(KnowledgeSkill.AllowUpgrade));
                nudSkill.DoDatabinding("Value", _skill, nameof(Skill.Base));
                nudSkill.DoOneWayDataBinding("InterceptMouseWheel", _skill.CharacterObject.Options, nameof(CharacterOptions.InterceptMode));
                nudKarma.DoOneWayDataBinding("Enabled", _skill, nameof(KnowledgeSkill.AllowUpgrade));
                nudKarma.DoDatabinding("Value", _skill, nameof(Skill.Karma));
                nudKarma.DoOneWayDataBinding("InterceptMouseWheel", _skill.CharacterObject.Options, nameof(CharacterOptions.InterceptMode));

                nudSkill.UpdateLightDarkMode();
                nudSkill.TranslateWinForm();
                nudKarma.UpdateLightDarkMode();
                nudKarma.TranslateWinForm();
                tlpMain.Controls.Add(nudSkill, 1, 0);
                tlpMain.Controls.Add(nudKarma, 2, 0);

                chkNativeLanguage = new ColorableCheckBox(components)
                {
                    Anchor             = AnchorStyles.Left,
                    AutoSize           = true,
                    DefaultColorScheme = true,
                    Margin             = new Padding(3, 0, 3, 0),
                    Name = "chkNativeLanguage",
                    Tag  = "Skill_NativeLanguageLong",
                    Text = "Native",
                    UseVisualStyleBackColor = true
                };
                cboSpec = new ElasticComboBox
                {
                    Anchor            = AnchorStyles.Left | AnchorStyles.Right,
                    AutoCompleteMode  = AutoCompleteMode.Suggest,
                    FormattingEnabled = true,
                    Margin            = new Padding(3, 0, 3, 0),
                    Name    = "cboSpec",
                    TabStop = false
                };
                chkKarma = new ColorableCheckBox(components)
                {
                    Anchor             = AnchorStyles.Left,
                    AutoSize           = true,
                    DefaultColorScheme = true,
                    Name = "chkKarma",
                    UseVisualStyleBackColor = true
                };

                chkNativeLanguage.DoOneWayDataBinding("Visible", _skill, nameof(Skill.IsLanguage));
                chkNativeLanguage.Enabled = _skill.IsNativeLanguage || _skill.CharacterObject.SkillsSection.HasAvailableNativeLanguageSlots;
                chkNativeLanguage.DoDatabinding("Checked", _skill, nameof(Skill.IsNativeLanguage));

                cboSpec.BeginUpdate();
                cboSpec.DataSource    = null;
                cboSpec.DisplayMember = nameof(ListItem.Name);
                cboSpec.ValueMember   = nameof(ListItem.Value);
                cboSpec.DataSource    = _skill.CGLSpecializations;
                cboSpec.SelectedIndex = -1;
                cboSpec.DoOneWayDataBinding("Enabled", _skill, nameof(Skill.CanHaveSpecs));
                cboSpec.DoDatabinding("Text", _skill, nameof(Skill.Specialization));
                cboSpec.EndUpdate();

                chkKarma.DoOneWayDataBinding("Enabled", _skill, nameof(Skill.CanHaveSpecs));
                chkKarma.DoDatabinding("Checked", _skill, nameof(Skill.BuyWithKarma));

                chkNativeLanguage.UpdateLightDarkMode();
                chkNativeLanguage.TranslateWinForm();
                cboSpec.UpdateLightDarkMode();
                cboSpec.TranslateWinForm();
                chkKarma.UpdateLightDarkMode();
                chkKarma.TranslateWinForm();
                tlpMiddle.Controls.Add(chkNativeLanguage, 1, 0);
                tlpMiddle.Controls.Add(cboSpec, 2, 0);
                tlpMiddle.Controls.Add(chkKarma, 3, 0);
            }

            if (_skill.ForcedName)
            {
                this.DoOneWayDataBinding("Enabled", _skill, nameof(KnowledgeSkill.Enabled));
            }

            ResumeLayout();

            _skill.PropertyChanged += Skill_PropertyChanged;
            _skill.CharacterObject.SkillsSection.PropertyChanged += OnSkillsSectionPropertyChanged;
        }
        public SkillGroupControl(SkillGroup skillGroup)
        {
            if (skillGroup == null)
            {
                return;
            }
            _objGraphics = CreateGraphics();
            _skillGroup  = skillGroup;
            InitializeComponent();
            this.UpdateLightDarkMode();
            this.TranslateWinForm();

            //This is apparently a factor 30 faster than placed in load. NFI why
            Stopwatch sw = Stopwatch.StartNew();

            SuspendLayout();
            lblName.DoOneWayDataBinding("Text", _skillGroup, nameof(SkillGroup.CurrentDisplayName));
            lblName.DoOneWayDataBinding("ToolTipText", _skillGroup, nameof(SkillGroup.ToolTip));

            // Creating these controls outside of the designer saves on handles
            if (skillGroup.CharacterObject.Created)
            {
                lblGroupRating = new Label
                {
                    Anchor      = AnchorStyles.Right,
                    AutoSize    = true,
                    Font        = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, 0),
                    MinimumSize = new Size((int)(25 * _objGraphics.DpiX / 96.0f), 0),
                    Name        = "lblGroupRating",
                    TextAlign   = ContentAlignment.MiddleRight
                };
                btnCareerIncrease = new ButtonWithToolTip
                {
                    Anchor                  = AnchorStyles.Right,
                    AutoSize                = true,
                    AutoSizeMode            = AutoSizeMode.GrowAndShrink,
                    Image                   = Resources.add,
                    Margin                  = new Padding(3, 0, 3, 0),
                    Name                    = "btnCareerIncrease",
                    Padding                 = new Padding(1),
                    UseVisualStyleBackColor = true
                };
                btnCareerIncrease.Click += btnCareerIncrease_Click;

                btnCareerIncrease.DoOneWayDataBinding("Enabled", _skillGroup, nameof(SkillGroup.CareerCanIncrease));
                btnCareerIncrease.DoOneWayDataBinding("ToolTipText", _skillGroup, nameof(SkillGroup.UpgradeToolTip));

                lblGroupRating.DoOneWayDataBinding("Text", _skillGroup, nameof(SkillGroup.DisplayRating));

                lblGroupRating.UpdateLightDarkMode();
                lblGroupRating.TranslateWinForm();
                btnCareerIncrease.UpdateLightDarkMode();
                btnCareerIncrease.TranslateWinForm();

                tlpMain.Controls.Add(lblGroupRating, 2, 0);
                tlpMain.Controls.Add(btnCareerIncrease, 3, 0);
            }
            else
            {
                nudKarma = new NumericUpDownEx
                {
                    Anchor              = AnchorStyles.Right,
                    AutoSize            = true,
                    InterceptMouseWheel = NumericUpDownEx.InterceptMouseWheelMode.WhenMouseOver,
                    Margin              = new Padding(3, 2, 3, 2),
                    Maximum             = new decimal(new[] { 99, 0, 0, 0 }),
                    Name = "nudKarma"
                };
                nudSkill = new NumericUpDownEx
                {
                    Anchor              = AnchorStyles.Right,
                    AutoSize            = true,
                    InterceptMouseWheel = NumericUpDownEx.InterceptMouseWheelMode.WhenMouseOver,
                    Margin              = new Padding(3, 2, 3, 2),
                    Maximum             = new decimal(new[] { 99, 0, 0, 0 }),
                    Name = "nudSkill"
                };

                nudKarma.DoDatabinding("Value", _skillGroup, nameof(SkillGroup.Karma));
                nudKarma.DoOneWayDataBinding("Enabled", _skillGroup, nameof(SkillGroup.KarmaUnbroken));
                nudKarma.DoOneWayDataBinding("InterceptMouseWheel", _skillGroup.CharacterObject.Options, nameof(CharacterOptions.InterceptMode));

                nudSkill.DoOneWayDataBinding("Visible", _skillGroup.CharacterObject, nameof(Character.BuildMethodHasSkillPoints));
                nudSkill.DoDatabinding("Value", _skillGroup, nameof(SkillGroup.Base));
                nudSkill.DoOneWayDataBinding("Enabled", _skillGroup, nameof(SkillGroup.BaseUnbroken));
                nudSkill.DoOneWayDataBinding("InterceptMouseWheel", _skillGroup.CharacterObject.Options, nameof(CharacterOptions.InterceptMode));

                nudKarma.UpdateLightDarkMode();
                nudKarma.TranslateWinForm();
                nudSkill.UpdateLightDarkMode();
                nudSkill.TranslateWinForm();

                tlpMain.Controls.Add(nudSkill, 2, 0);
                tlpMain.Controls.Add(nudKarma, 3, 0);
            }

            ResumeLayout();
            sw.TaskEnd("Create skillgroup");
        }