Esempio n. 1
0
        private Control MakeActiveSkill(Skill arg)
        {
            SkillControl2 control = new SkillControl2(arg);

            _controls.Add(control);
            control.CustomAttributeChanged += Control_CustomAttributeChanged;
            return(control);
        }
        private Control MakeActiveSkill(Skill arg)
        {
            SkillControl2 objSkillControl = new SkillControl2(arg)
            {
                Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top
            };

            _lstSkillControls.Add(objSkillControl);
            objSkillControl.CustomAttributeChanged += Control_CustomAttributeChanged;
            return(objSkillControl);
        }
        public void RealLoad()
        {
            if (ParentForm is CharacterShared frmParent)
            {
                _objCharacter = frmParent.CharacterObject;
            }
            else
            {
                _objCharacter = new Character();
                Utils.BreakIfDebug();
            }

            Stopwatch sw    = Stopwatch.StartNew(); //Benchmark, should probably remove in release
            Stopwatch parts = Stopwatch.StartNew();

            //Keep everything visible until ready to display everything. This
            //seems to prevent redrawing everything each time anything is added
            //Not benched, but should be faster

            //Might also be useless horseshit, 2 lines

            //Visible = false;
            SuspendLayout();

            Stopwatch swDisplays = Stopwatch.StartNew();

            _lstActiveSkills = new BindingListDisplay <Skill>(_objCharacter.SkillsSection.Skills, MakeActiveSkill)
            {
                Dock = DockStyle.Fill
            };
            Control MakeActiveSkill(Skill arg)
            {
                SkillControl2 objSkillControl = new SkillControl2(arg);

                objSkillControl.CustomAttributeChanged += Control_CustomAttributeChanged;
                return(objSkillControl);
            }

            RefreshSkillLabels();

            swDisplays.TaskEnd("_lstActiveSkills");

            tlpActiveSkills.Controls.Add(_lstActiveSkills, 0, 2);
            tlpActiveSkills.SetColumnSpan(_lstActiveSkills, 3);

            swDisplays.TaskEnd("_lstActiveSkills add");

            _lstKnowledgeSkills = new BindingListDisplay <KnowledgeSkill>(_objCharacter.SkillsSection.KnowledgeSkills,
                                                                          knoSkill => new KnowledgeSkillControl(knoSkill))
            {
                Dock = DockStyle.Fill
            };
            RefreshKnowledgeSkillLabels();

            swDisplays.TaskEnd("_lstKnowledgeSkills");

            tlpBottomPanel.Controls.Add(_lstKnowledgeSkills, 0, 2);
            tlpBottomPanel.SetColumnSpan(_lstKnowledgeSkills, 3);

            swDisplays.TaskEnd("_lstKnowledgeSkills add");

            if (_objCharacter.SkillsSection.SkillGroups.Count > 0)
            {
                _lstSkillGroups = new BindingListDisplay <SkillGroup>(_objCharacter.SkillsSection.SkillGroups,
                                                                      group => new SkillGroupControl(group))
                {
                    Dock = DockStyle.Fill
                };
                _lstSkillGroups.Filter(x => x.SkillList.Any(y => _objCharacter.SkillsSection.SkillsDictionary.ContainsKey(y.Name)), true);
                _lstSkillGroups.Sort(new SkillGroupSorter(SkillsSection.CompareSkillGroups));
                RefreshSkillGroupLabels();

                swDisplays.TaskEnd("_lstSkillGroups");

                tlpSkillGroups.Controls.Add(_lstSkillGroups, 0, 1);
                tlpSkillGroups.SetColumnSpan(_lstSkillGroups, 2);

                swDisplays.TaskEnd("_lstSkillGroups add");
            }
            else
            {
                tlpSkillGroups.Visible      = false;
                tlpActiveSkills.Margin      = new Padding(0);
                tlpTopPanel.ColumnStyles[0] = new ColumnStyle(SizeType.AutoSize);
                tlpTopPanel.ColumnStyles[1] = new ColumnStyle(SizeType.Percent, 100F);
            }

            parts.TaskEnd("MakeSkillDisplay()");

            cboDisplayFilter.BeginUpdate();
            cboDisplayFilter.DataSource       = null;
            cboDisplayFilter.ValueMember      = "Item2";
            cboDisplayFilter.DisplayMember    = "Item1";
            cboDisplayFilter.DataSource       = _lstDropDownActiveSkills;
            cboDisplayFilter.SelectedIndex    = 1;
            cboDisplayFilter.MaxDropDownItems = _lstDropDownActiveSkills.Count;
            cboDisplayFilter.EndUpdate();

            cboDisplayFilterKnowledge.BeginUpdate();
            cboDisplayFilterKnowledge.DataSource       = null;
            cboDisplayFilterKnowledge.ValueMember      = "Item2";
            cboDisplayFilterKnowledge.DisplayMember    = "Item1";
            cboDisplayFilterKnowledge.DataSource       = _lstDropDownKnowledgeSkills;
            cboDisplayFilterKnowledge.SelectedIndex    = 1;
            cboDisplayFilterKnowledge.MaxDropDownItems = _lstDropDownKnowledgeSkills.Count;
            cboDisplayFilterKnowledge.EndUpdate();
            parts.TaskEnd("_ddl databind");

            cboSort.BeginUpdate();
            cboSort.DataSource       = null;
            cboSort.ValueMember      = "Item2";
            cboSort.DisplayMember    = "Item1";
            cboSort.DataSource       = _sortList;
            cboSort.SelectedIndex    = 0;
            cboSort.MaxDropDownItems = _sortList.Count;
            cboSort.EndUpdate();

            cboSortKnowledge.BeginUpdate();
            cboSortKnowledge.DataSource       = null;
            cboSortKnowledge.ValueMember      = "Item2";
            cboSortKnowledge.DisplayMember    = "Item1";
            cboSortKnowledge.DataSource       = _lstSortKnowledgeList;
            cboSortKnowledge.SelectedIndex    = 0;
            cboSortKnowledge.MaxDropDownItems = _lstSortKnowledgeList.Count;
            cboSortKnowledge.EndUpdate();

            parts.TaskEnd("_sort databind");

            if (_lstSkillGroups != null)
            {
                _lstSkillGroups.ChildPropertyChanged += MakeDirtyWithCharacterUpdate;
            }
            _lstActiveSkills.ChildPropertyChanged    += MakeDirtyWithCharacterUpdate;
            _lstKnowledgeSkills.ChildPropertyChanged += MakeDirtyWithCharacterUpdate;

            if (!_objCharacter.Created)
            {
                lblGroupsSp.DoOneWayDataBinding("Visible", _objCharacter, nameof(Character.BuildMethodHasSkillPoints));
                lblActiveSp.DoOneWayDataBinding("Visible", _objCharacter, nameof(Character.BuildMethodHasSkillPoints));
                lblBuyWithKarma.DoOneWayDataBinding("Visible", _objCharacter, nameof(Character.BuildMethodHasSkillPoints));

                lblKnoSp.DoOneWayDataBinding("Visible", _objCharacter.SkillsSection, nameof(SkillsSection.HasKnowledgePoints));
                lblKnoBwk.DoOneWayDataBinding("Visible", _objCharacter.SkillsSection, nameof(SkillsSection.HasKnowledgePoints));
                UpdateKnoSkillRemaining();
            }
            else
            {
                flpSkillGroupLabels.Visible = false;

                lblActiveSp.Visible     = false;
                lblActiveKarma.Visible  = false;
                lblBuyWithKarma.Visible = false;

                flpKnowledgeSkillsLabels.Visible = false;
                lblKnoBwk.Visible = false;
                lblKnowledgeSkillPoints.Visible      = false;
                lblKnowledgeSkillPointsTitle.Visible = false;
            }

            btnExotic.Visible = XmlManager.Load("skills.xml").SelectSingleNode("/chummer/skills/skill[exotic = \"True\"]") != null;

            _objCharacter.SkillsSection.Skills.ListChanged          += SkillsOnListChanged;
            _objCharacter.SkillsSection.SkillGroups.ListChanged     += SkillGroupsOnListChanged;
            _objCharacter.SkillsSection.KnowledgeSkills.ListChanged += KnowledgeSkillsOnListChanged;
            ResumeLayout(true);
            sw.Stop();
            Debug.WriteLine("RealLoad() in {0} ms", sw.Elapsed.TotalMilliseconds);
        }
Esempio n. 4
0
 private Control MakeActiveSkill(Skill arg)
 {
     SkillControl2 control = new SkillControl2(arg);
     controls.Add(control);
     control.CustomAttributeChanged += Control_CustomAttributeChanged;
     return control;
 }