/// <summary> /// Initializes a new instance of the <see cref="NuGenSwitcher"/> class. /// </summary> /// <param name="serviceProvider"><para>Requires:</para> /// <para><see cref="INuGenButtonStateService"/></para> /// <para><see cref="INuGenControlStateService"/></para> /// <para><see cref="INuGenSwitchButtonLayoutManager"/></para> /// <para><see cref="INuGenSwitchButtonRenderer"/></para> /// <para><see cref="INuGenPanelRenderer"/></para> /// </param> /// <exception cref="ArgumentNullException"><paramref name="serviceProvider"/> is <see langword="null"/>.</exception> public NuGenSwitcher(INuGenServiceProvider serviceProvider) : base(serviceProvider) { _buttonPageDictionary = new Dictionary <NuGenSwitchButton, NuGenSwitchPage>(); _pageButtonDictionary = new Dictionary <NuGenSwitchPage, NuGenSwitchButton>(); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.Opaque, false); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.Selectable, true); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.SetStyle(ControlStyles.UserPaint, true); this.BackColor = Color.Transparent; _switchPanel = new NuGenSwitchPanel(serviceProvider); _switchPanel.BackColor = Color.Blue; this.RebuildLayout(); _switchPanel.Parent = this; _switchPanel.SelectedSwitchButtonChanged += _switchPanel_SelectedSwitchButtonChanged; _switchPanel.SwitchButtonImageAlignChanged += _switchPanel_SwitchButtonImageAlignChanged; _switchPanel.SwitchButtonTextAlignChanged += _switchPanel_SwitchButtonTextAlignChanged; _switchPanel.SwitchButtonSizeChanged += _switchPanel_SwitchButtonSizeChanged; }
private Padding GetPadding() { if (this.Orientation == NuGenOrientationStyle.Horizontal) { return(NuGenSwitchPanel.GetHorizontalPadding()); } return(NuGenSwitchPanel.GetVerticalPadding()); }
/// <summary> /// </summary> /// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (disposing) { if (_switchPanel != null) { _switchPanel.SelectedSwitchButtonChanged -= _switchPanel_SelectedSwitchButtonChanged; _switchPanel.SwitchButtonImageAlignChanged -= _switchPanel_SwitchButtonImageAlignChanged; _switchPanel.SwitchButtonTextAlignChanged -= _switchPanel_SwitchButtonTextAlignChanged; _switchPanel.SwitchButtonSizeChanged -= _switchPanel_SwitchButtonSizeChanged; _switchPanel.Dispose(); _switchPanel = null; } } base.Dispose(disposing); }
/// <summary> /// </summary> /// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (disposing) { if (_switchPanel != null) { _switchPanel.SelectedSwitchButtonChanged -= _switchPanel_SelectedSwitchButtonChanged; _switchPanel.SwitchButtonImageAlignChanged -= _switchPanel_SwitchButtonImageAlignChanged; _switchPanel.SwitchButtonTextAlignChanged -= _switchPanel_SwitchButtonTextAlignChanged; _switchPanel.SwitchButtonSizeChanged -= _switchPanel_SwitchButtonSizeChanged; _switchPanel.Dispose(); _switchPanel = null; } } base.Dispose(disposing); }
/// <summary> /// Initializes a new instance of the <see cref="NuGenSwitcher"/> class. /// </summary> /// <param name="serviceProvider"><para>Requires:</para> /// <para><see cref="INuGenButtonStateService"/></para> /// <para><see cref="INuGenControlStateService"/></para> /// <para><see cref="INuGenSwitchButtonLayoutManager"/></para> /// <para><see cref="INuGenSwitchButtonRenderer"/></para> /// <para><see cref="INuGenPanelRenderer"/></para> /// </param> /// <exception cref="ArgumentNullException"><paramref name="serviceProvider"/> is <see langword="null"/>.</exception> public NuGenSwitcher(INuGenServiceProvider serviceProvider) : base(serviceProvider) { _buttonPageDictionary = new Dictionary<NuGenSwitchButton, NuGenSwitchPage>(); _pageButtonDictionary = new Dictionary<NuGenSwitchPage, NuGenSwitchButton>(); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.Opaque, false); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.Selectable, true); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.SetStyle(ControlStyles.UserPaint, true); this.BackColor = Color.Transparent; _switchPanel = new NuGenSwitchPanel(serviceProvider); _switchPanel.BackColor = Color.Blue; this.RebuildLayout(); _switchPanel.Parent = this; _switchPanel.SelectedSwitchButtonChanged += _switchPanel_SelectedSwitchButtonChanged; _switchPanel.SwitchButtonImageAlignChanged += _switchPanel_SwitchButtonImageAlignChanged; _switchPanel.SwitchButtonTextAlignChanged += _switchPanel_SwitchButtonTextAlignChanged; _switchPanel.SwitchButtonSizeChanged += _switchPanel_SwitchButtonSizeChanged; }