Beispiel #1
0
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     if (!m_Applicable)
     {
         e.Graphics.Clear(this.BackColor);
     }
     else if (!m_bolDisplayCurrentColour)
     {
         // draw standard selection marker (in design mode also)
         if (g_Bitmap16 == null)
         {
             g_Bitmap16 = ColourPanel.GenerateMoreColoursBitmap(ColourPanel.GetStandard17Colours());
         }
         e.Graphics.DrawImage(g_Bitmap16, new Rectangle(0, 0, Width, Height));
     }
     else if (this.DesignMode)
     {
         e.Graphics.Clear(Color.LightBlue);
     }
     else
     {
         if (m_Current.IsEmpty)
         {
             e.Graphics.Clear(Color.White);
             Image image = BlackWhite ? Resources.AM.BlackWhiteText : Resources.AM.RedCross;
             if (image != null && m_Applicable)
             {
                 e.Graphics.DrawImageUnscaled(image, (Width - image.Width) / 2, (Height - image.Height) / 2);
                 image.Dispose();
             }
         }
         else if (m_Current.A < 255)
         {
             e.Graphics.Clear(this.BackColor);
             using (SolidBrush br = new SolidBrush(m_Current))
             {
                 e.Graphics.FillRectangle(br, 0, 0, Width, Height);
             }
         }
         else
         {
             e.Graphics.Clear(m_Current);
         }
     }
     if (!m_Applicable || !Enabled)
     {
         using (Brush br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.DiagonalCross, Color.Gray))
             e.Graphics.FillRectangle(br, new Rectangle(0, 0, Width, Height));
     }
     if (Focused)
     {
         e.Graphics.DrawRectangle(GUIUtilities.FocusPen, 3, 3, Width - 6, Height - 6);
     }
 }
Beispiel #2
0
		internal static string GetParameterValueName(Parameters parameter, int value)
		{
			switch (parameter)
			{
				case Parameters.FillColour:
				case Parameters.LineColour:
				case Parameters.TextColour:
					int index = ColourPanel.GetStandard17Colours().IndexOf(Color.FromArgb(value));
					if (index >= 0)
						return Strings.Item("Colour_" + index);
					return Strings.Item("Custom_Colour");
				case Parameters.LineWidth:
					float points = value / 100f / Geometry.POINTUNIT;
					return points.ToString("0.#") + " " + Strings.Item("pt");
				case Parameters.LinePattern:
					return Strings.Item("Line_" + (DashStyle)value);
				case Parameters.FillPattern:
					return Strings.Item("Hatch_" + (Shape.FillStyleC.Patterns)value);
				case Parameters.TextAlignment:
					switch ((StringAlignment)value)
					{
						case StringAlignment.Near:
							return Strings.Item("Align_Left");
						case StringAlignment.Center:
							return Strings.Item("Align_Centre");
						case StringAlignment.Far:
							return Strings.Item("Align_Right");
						default:
							return "?";
					}
				case Parameters.TextVerticalAlignment:
					switch ((StringAlignment)value)
					{
						case StringAlignment.Near:
							return Strings.Item("Align_Top");
						case StringAlignment.Center:
							return Strings.Item("Align_Middle");
						case StringAlignment.Far:
							return Strings.Item("Align_Bottom");
						default:
							return "?";
					}
				case Parameters.ArrowheadEndSize:
				case Parameters.ArrowheadStartSize:
					return (value / 1000).ToString("%");
				case Parameters.ArrowheadEndType:
				case Parameters.ArrowheadStartType:
					return Strings.Item("Arrowhead_" + (Lined.ArrowheadC.Styles)value);
				default:
					Debug.Fail("Unexpected eParameter in GetParameterValueName:" + parameter);
					return value.ToString();
			}
		}
Beispiel #3
0
		internal static int[] GetStandardParameterValues(Parameters parameter)
		{
			// gets the values for the parameters which are offered to the user.  Mostly only the styles are implemented
			List<int> list = new List<int>();
			switch (parameter)
			{
				case Parameters.FillColour:
				case Parameters.LineColour:
				case Parameters.TextColour:
					// values are the same for all of these
					list.AddRange(from col in ColourPanel.GetStandard17Colours() select col.ToArgb());
					break;
				case Parameters.LineWidth:
					return StandardLineWidths;
				case Parameters.LinePattern:
					list.AddRange(StandardLinePatterns.Cast<int>()); //.Select(Function(eStyle) CType(eStyle, Integer)))
					break;
				case Parameters.FillPattern:
					list.AddRange(StandardFillPatterns.Cast<int>()); //.Select(Function(ePattern) CType(ePattern, Integer)))
					break;
				case Parameters.ArrowheadEndType:
				case Parameters.ArrowheadStartType:
					foreach (Lined.ArrowheadC.Styles eType in Enum.GetValues(typeof(Lined.ArrowheadC.Styles)))
					{
						list.Add((int)eType);
					}
					break;
				case Parameters.ArrowheadEndSize:
				case Parameters.ArrowheadStartSize:
					list.AddRange(new[] { 650, 1000, 1500, 2500 });
					break;
				default:
					throw new ArgumentException();
					// it is not intended to implement this for the tools etc (when doing configuration some of these are not really treated as parameters anyway)
			}
			return list.ToArray();
		}