/// <summary> /// Creates a new instance. /// </summary> /// <param name="colorEditor">The editor this instance belongs to.</param> public ColorUIWrapper(ColorEditorEx colorEditor, IWindowsFormsEditorService service) { _service = service; Type colorUiType = typeof(ColorEditor).GetNestedType("ColorUI", BindingFlags.CreateInstance | BindingFlags.NonPublic); ConstructorInfo constructorInfo = colorUiType.GetConstructor(new Type[] { typeof(ColorEditor) }); _control = (Control)constructorInfo.Invoke(new object[] { colorEditor }); Panel alphaPanel = new Panel(); alphaPanel.BackColor = SystemColors.Control; alphaPanel.Dock = DockStyle.Right; alphaPanel.Width = 28; _control.Controls.Add(alphaPanel); _tbAlpha = new TrackBar(); _tbAlpha.Orientation = Orientation.Vertical; _tbAlpha.Dock = DockStyle.Fill; _tbAlpha.TickStyle = TickStyle.None; _tbAlpha.Maximum = byte.MaxValue; _tbAlpha.Minimum = byte.MinValue; _tbAlpha.ValueChanged += new EventHandler(OnTrackBarAlphaValueChanged); alphaPanel.Controls.Add(_tbAlpha); _lblAlpha = new Label(); _lblAlpha.Text = "0"; _lblAlpha.Dock = DockStyle.Bottom; _lblAlpha.TextAlign = ContentAlignment.MiddleCenter; _lblAlpha.Click += new EventHandler(OnAlphaClick); alphaPanel.Controls.Add(_lblAlpha); _startMethodInfo = _control.GetType().GetMethod("Start"); _endMethodInfo = _control.GetType().GetMethod("End"); _valuePropertyInfo = _control.GetType().GetProperty("Value"); _control.Layout += new LayoutEventHandler(_control_Layout); TabControl tabControl = (TabControl)_control.Controls[0]; tabControl.SelectedIndexChanged += new EventHandler(tabControl_SelectedIndexChanged); _control.BackColor = _control.BackColor; //to update color of the tabs (xp style bug) //tabControl.Appearance = TabAppearance.FlatButtons; //tabControl.Alignment = TabAlignment.Bottom; }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="colorEditor">The editor this instance belongs to.</param> public ColorUIWrapper(ColorEditorEx colorEditor, IWindowsFormsEditorService service) { _service = service; Type colorUiType = typeof(ColorEditor).GetNestedType("ColorUI", BindingFlags.CreateInstance | BindingFlags.NonPublic); ConstructorInfo constructorInfo = colorUiType.GetConstructor(new Type[] { typeof(ColorEditor) }); _control = (Control)constructorInfo.Invoke(new object[] { colorEditor }); Panel alphaPanel = new Panel(); alphaPanel.BackColor = SystemColors.Control; alphaPanel.Dock = DockStyle.Right; alphaPanel.Width = 28; _control.Controls.Add(alphaPanel); _tbAlpha = new TrackBar(); _tbAlpha.Orientation = Orientation.Vertical; _tbAlpha.Dock = DockStyle.Fill; _tbAlpha.TickStyle = TickStyle.None; _tbAlpha.Maximum = byte.MaxValue; _tbAlpha.Minimum = byte.MinValue; _tbAlpha.ValueChanged += new EventHandler(OnTrackBarAlphaValueChanged); alphaPanel.Controls.Add(_tbAlpha); _lblAlpha = new Label(); _lblAlpha.Text = "0"; _lblAlpha.Dock = DockStyle.Bottom; _lblAlpha.TextAlign = ContentAlignment.MiddleCenter; _lblAlpha.Click += new EventHandler(OnAlphaClick); alphaPanel.Controls.Add(_lblAlpha); _startMethodInfo = _control.GetType().GetMethod("Start"); _endMethodInfo = _control.GetType().GetMethod("End"); _valuePropertyInfo = _control.GetType().GetProperty("Value"); _control.Layout += new LayoutEventHandler(_control_Layout); TabControl tabControl = (TabControl)_control.Controls[0]; tabControl.SelectedIndexChanged += new EventHandler(tabControl_SelectedIndexChanged); _control.BackColor = _control.BackColor; //to update color of the tabs (xp style bug) //tabControl.Appearance = TabAppearance.FlatButtons; //tabControl.Alignment = TabAlignment.Bottom; }