void ReleaseDesignerOutlets() { if (Avatar != null) { Avatar.Dispose(); Avatar = null; } if (BottomConstraint != null) { BottomConstraint.Dispose(); BottomConstraint = null; } if (BottomRuler2 != null) { BottomRuler2.Dispose(); BottomRuler2 = null; } if (IconBox != null) { IconBox.Dispose(); IconBox = null; } if (ImageCollection != null) { ImageCollection.Dispose(); ImageCollection = null; } if (Input != null) { Input.Dispose(); Input = null; } if (InputBoxHieghtConstraint != null) { InputBoxHieghtConstraint.Dispose(); InputBoxHieghtConstraint = null; } if (MentionUser != null) { MentionUser.Dispose(); MentionUser = null; } if (PickImage != null) { PickImage.Dispose(); PickImage = null; } if (TakeImage != null) { TakeImage.Dispose(); TakeImage = null; } }
private void Timer_Tick(object sender, EventArgs e) { lock (Locker) { if (!(sender is Timer timer)) { return; } if (_count == 0 && _panel.Controls.Count > 0) { _panel.Controls.Clear(); } for (var i = 0; i < 3; i++) { _panel.SuspendLayout(); try { var box = new IconBox(_path, _count++, _button.BackColor, _button.ForeColor, _button.FlatAppearance.MouseOverBackColor); if (_panel.Controls.Contains(box)) { box.Dispose(); continue; } _iconBoxes.Add(box); _panel.Controls.Add(box); } catch (Exception ex) when(ex.IsCaught()) { timer.Enabled = false; if (_count > 0) { _count = 0; } break; } finally { _panel.ResumeLayout(false); } } var max = _panel.Width / _panel.Controls[0].Width; for (var i = 0; i < _panel.Controls.Count; i++) { if (_panel.Controls[i] == null) { continue; } var line = i / max; var column = i - line * max; _panel.Controls[i].Location = new Point(column * _panel.Controls[i].Width, line * _panel.Controls[i].Height); } if (timer.Enabled || _panel.Enabled) { return; } _panel.Enabled = true; _textBox.Enabled = true; _progressCircle.Active = false; _buttonPanel.SuspendLayout(); _buttonPanel.Controls.Clear(); _buttonPanel.Controls.Add(_button); _buttonPanel.BorderStyle = BorderStyle.FixedSingle; _buttonPanel.ResumeLayout(false); TaskBarProgress.SetState(Handle, TaskBarProgressState.NoProgress); if (!_panel.Focus()) { _panel.Select(); } } }