private void SelectIcon( SelectIconUserControl selectedControl) { this.SelectedIconRelativePath = selectedControl?.Icon.RelativePath; this.DialogResult = DialogResult.OK; }
private void ShowIcons( TreeNode node) { var iconList = node.Tag as List <IconController.IconFile>; var panel = this.IconsFlowLayoutPanel; var selectedCtrl = default(SelectIconUserControl); try { panel.SuspendLayout(); panel.Controls.Clear(); foreach (var icon in iconList) { var ctrl = new SelectIconUserControl(); ctrl.Button.BackgroundImageLayout = ImageLayout.Zoom; ctrl.Button.BackgroundImage = System.Drawing.Image.FromFile( icon.FullPath); ctrl.Label.Text = icon.Name; ctrl.Icon = icon; ctrl.Button.Font = panel.Font; ctrl.Label.Font = panel.Font; ctrl.Button.Click += (s, e) => { this.SelectIcon(ctrl); }; panel.Controls.Add(ctrl); if (selectedCtrl == null) { if (string.IsNullOrEmpty( this.SelectedIconRelativePath)) { if (this.ParrentSpell != null) { if (!string.IsNullOrEmpty(icon.SkillName)) { if (this.ParrentSpell.Keyword.Contains(icon.SkillName) || this.ParrentSpell.SpellTitle.Contains(icon.SkillName)) { selectedCtrl = ctrl; } } } } else { if (icon.RelativePath.ToLower() == this.SelectedIconRelativePath.ToLower()) { selectedCtrl = ctrl; } } } } } finally { panel.ResumeLayout(); } if (selectedCtrl != null) { this.IconsFlowLayoutPanel.ScrollControlIntoView(selectedCtrl); selectedCtrl.BackColor = Color.Lavender; selectedCtrl.Focus(); Application.DoEvents(); } }