/// <summary> /// Creates a new instance. /// </summary> /// <param name="colorEditor">The editor this instance belongs to.</param> public ColorUIWrapper(XNAColorUITypeEditor colorEditor) { 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 }); _control.BackColor = System.Drawing.SystemColors.Control; Panel alphaPanel = new Panel(); alphaPanel.BackColor = System.Drawing.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 = System.Drawing.ContentAlignment.MiddleCenter; alphaPanel.Controls.Add(_lblAlpha); _startMethodInfo = _control.GetType().GetMethod("Start"); _endMethodInfo = _control.GetType().GetMethod("End"); _valuePropertyInfo = _control.GetType().GetProperty("Value"); _control.SizeChanged += new EventHandler(OnControlSizeChanged); }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="colorEditor">The editor this instance belongs to.</param> public ColorUIWrapper(XNAColorUITypeEditor colorEditor) { var colorUiType = typeof(ColorEditor).GetNestedType("ColorUI", BindingFlags.CreateInstance | BindingFlags.NonPublic); var constructorInfo = colorUiType.GetConstructor(new Type[] { typeof(ColorEditor) }); _control = (Control)constructorInfo.Invoke(new object[] { colorEditor }); _control.BackColor = System.Drawing.SystemColors.Control; var alphaPanel = new Panel { BackColor = System.Drawing.SystemColors.Control, Dock = DockStyle.Right, Width = 28 }; _control.Controls.Add(alphaPanel); _tbAlpha = new TrackBar { Orientation = Orientation.Vertical, Dock = DockStyle.Fill, TickStyle = TickStyle.None, Maximum = byte.MaxValue, Minimum = byte.MinValue }; _tbAlpha.ValueChanged += new EventHandler(OnTrackBarAlphaValueChanged); alphaPanel.Controls.Add(_tbAlpha); _lblAlpha = new Label { Text = "0", Dock = DockStyle.Bottom, TextAlign = System.Drawing.ContentAlignment.MiddleCenter }; alphaPanel.Controls.Add(_lblAlpha); _startMethodInfo = _control.GetType().GetMethod("Start"); _endMethodInfo = _control.GetType().GetMethod("End"); _valuePropertyInfo = _control.GetType().GetProperty("Value"); _control.SizeChanged += new EventHandler(OnControlSizeChanged); }