Пример #1
0
			/// <summary>
			/// Initializes a new instance of the ColorPicker class with default settings
			/// </summary>
			public ColorPicker(ColorCellEditor editor)
			{
				if (editor == null)
				{
					throw new ArgumentNullException("editor", "editor cannot be null");
				}
					
				this.editor = editor;
				
				this.webHeightSet = false;
				this.systemHeightSet = false;
			
				this.tabControl = new TabControl();
				this.customTabPage = new ThemedTabPage();
				this.palette = new ColorPalette(editor);
				this.webTabPage = new ThemedTabPage();
				this.webListBox = new ColorListBox();
				this.systemTabPage = new ThemedTabPage();
				this.systemListBox = new ColorListBox();
				this.tabControl.SuspendLayout();
				this.SuspendLayout();
				// 
				// tabControl1
				// 
				this.tabControl.Controls.Add(this.customTabPage);
				this.tabControl.Controls.Add(this.webTabPage);
				this.tabControl.Controls.Add(this.systemTabPage);
				this.tabControl.Location = new System.Drawing.Point(0, 0);
				this.tabControl.Name = "tabControl";
				this.tabControl.SelectedIndex = 0;
				this.tabControl.Size = new Size(this.DefaultSize.Width - 2, this.DefaultSize.Height - 2);
				this.tabControl.TabIndex = 0;
				this.tabControl.TabStop = false;
				this.tabControl.GotFocus += new EventHandler(tabControl_GotFocus);
				// 
				// customTabPage
				// 
				this.customTabPage.Location = new System.Drawing.Point(4, 22);
				this.customTabPage.Name = "customTabPage";
				this.customTabPage.Size = new System.Drawing.Size(192, 214);
				this.customTabPage.TabIndex = 0;
				this.customTabPage.Text = "Custom";
				this.customTabPage.Controls.Add(this.palette);
				//
				// palette
				//
				this.palette.Dock = DockStyle.Fill;
				this.palette.Picked += new EventHandler(this.OnPalettePick);
				this.palette.KeyPress += new KeyPressEventHandler(this.editor.OnKeyPress);
				// 
				// webTabPage
				// 
				this.webTabPage.Location = new System.Drawing.Point(4, 22);
				this.webTabPage.Name = "webTabPage";
				this.webTabPage.Size = new System.Drawing.Size(192, 214);
				this.webTabPage.TabIndex = 1;
				this.webTabPage.Text = "Web";
				this.webTabPage.Controls.Add(this.webListBox);
				// 
				// webListBox
				// 
				this.webListBox.DrawMode = DrawMode.OwnerDrawFixed;
				this.webListBox.BorderStyle = BorderStyle.FixedSingle;
				this.webListBox.IntegralHeight = false;
				this.webListBox.Sorted = false;
				this.webListBox.Dock = DockStyle.Fill;
				this.webListBox.Click += new EventHandler(OnListClick);
				this.webListBox.DrawItem += new DrawItemEventHandler(OnListDrawItem);
				this.webListBox.KeyDown += new KeyEventHandler(OnListKeyDown);
				this.webListBox.KeyPress += new KeyPressEventHandler(this.editor.OnKeyPress);
				// 
				// systemTabPage
				// 
				this.systemTabPage.Location = new System.Drawing.Point(4, 22);
				this.systemTabPage.Name = "systemTabPage";
				this.systemTabPage.Size = new System.Drawing.Size(192, 214);
				this.systemTabPage.TabIndex = 2;
				this.systemTabPage.Text = "System";
				this.systemTabPage.Controls.Add(this.systemListBox);
				// 
				// systemListBox
				// 
				this.systemListBox.DrawMode = DrawMode.OwnerDrawFixed;
				this.systemListBox.BorderStyle = BorderStyle.FixedSingle;
				this.systemListBox.IntegralHeight = false;
				this.systemListBox.Sorted = false;
				this.systemListBox.Dock = DockStyle.Fill;
				this.systemListBox.Click += new EventHandler(OnListClick);
				this.systemListBox.DrawItem += new DrawItemEventHandler(OnListDrawItem);
				this.systemListBox.KeyDown += new KeyEventHandler(OnListKeyDown);
				this.systemListBox.FontChanged += new EventHandler(OnFontChanged);
				this.systemListBox.KeyPress += new KeyPressEventHandler(this.editor.OnKeyPress);

				// for some reason Array.Sort craps out with the WebColorComparer, 
				// so the WebColors property returns an array that is already sorted
				//Array.Sort(this.WebColors, new ColorCellEditor.ColorPicker.WebColorComparer());
				for (int i=0; i<this.WebColors.Length; i++)
				{
					this.webListBox.Items.Add(this.WebColors[i]);
				}

				Array.Sort(this.SystemColors, new ColorCellEditor.ColorPicker.SystemColorComparer());
				for (int i=0; i<this.SystemColors.Length; i++)
				{
					this.systemListBox.Items.Add(this.SystemColors[i]);
				}

				// 
				// ColorPicker
				// 
				this.Controls.Add(this.tabControl);
				this.Name = "ColorPicker";
				this.Size = this.DefaultSize;
				this.tabControl.ResumeLayout(false);
				this.ResumeLayout(false);

				this.AdjustListBoxItemHeight();
			}
Пример #2
0
				/// <summary>
				/// 
				/// </summary>
				public ColorPalette(ColorCellEditor editor) : base()
				{
					if (editor == null)
					{
						throw new ArgumentNullException("editor", "editor cannot be null");
					}
					
					this.editor = editor;
					
					this.focus = new Point(0, 0);
					this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
					this.SetStyle(ControlStyles.UserPaint, true);
					this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
					this.SetStyle(ControlStyles.DoubleBuffer, true);
					this.BackColor = Color.Transparent;
					this.Size = new Size(200, 200);
				}