示例#1
0
	//private bool noActivate = true;
	//---

	///<summary>
	///Create a clock control that allows the user to select a time.
	///<param name="topMost">An option to keep this window topmost.</param>
	///<param name="showOKCancelButtons"></param>
	///<param name="showAMPMButtons"></param>
	///</summary>
	public ClockControl(bool topMost = false, bool showOKCancelButtons = true, bool showAMPMButtons = true) {//, bool noActivate = true) {
		this.topMost = topMost;
		//this.noActivate = noActivate;
		SuspendLayout();
		Padding = new Padding(20, 0, 20, 0);
		Margin = Padding.Empty;
		Dock = DockStyle.Fill;
		GripStyle = ToolStripGripStyle.Hidden;
		CanOverflow = false;
		TabStop = true; // allows key interaction
		showFocusCues = base.ShowFocusCues;
		//CloseOnEscapeKey = true;

		ClockFaceSizeFactor = 1.586;
		ButtonGapFactor = 1.2;
		FocusDotFactor = 0.3;
		ClockItemAMAngleDegrees = 130;
		ClockItemPMAngleDegrees = 50;
		HeaderClockFaceGap = 20;
		ClockItemAMDistanceFactor = 1.3;
		ClockItemPMDistanceFactor = 1.3;
		ShowMinuteFaceAfterHourValueSelected = true;
		Renderer = new ClockRenderer { RoundedEdges = false };

		headerItems.AddRange(new [] { ClockItemHour, ClockItemColon, ClockItemMinute, ClockItemAMPM });

		//String family = "Lucida Sans";
		//String family = "Century Gothic";
		//String family = "Calibri";
		//String family = "Arial";
		//String family = "Tahoma";
		String family = "Segoe UI";
		ClockItemHour.Font = new Font(family, 10f, FontStyle.Regular, GraphicsUnit.Point);
		ClockItemColon.Font = new Font(family, 10f, FontStyle.Regular, GraphicsUnit.Point);
		ClockItemMinute.Font = new Font(family, 10f, FontStyle.Regular, GraphicsUnit.Point);
		ClockItemAMPM.Font = new Font("Segoe UI Semibold", 10f, FontStyle.Regular, GraphicsUnit.Point);
		ClockItemAM.Font = new Font(family, 10f, FontStyle.Regular, GraphicsUnit.Point);
		ClockItemPM.Font = new Font(family, 10f, FontStyle.Regular, GraphicsUnit.Point);
		//Font = new Font("Lucida Sans Unicode", 10f, FontStyle.Regular, GraphicsUnit.Point);

		ClockButtonOK.Margin = new Padding(2, 1, 2, 2);
		ClockButtonCancel.Margin = new Padding(2, 1, 2, 2);

		Items.Add(ClockItemHour);
		Items.Add(ClockItemColon);
		Items.Add(ClockItemMinute);
		Items.Add(ClockItemAMPM);

		for (int i = 0; i < 60; i += 1) {
			int value = (i + 15) % 60;
			String text = (value % 5 == 0 ? value.ToString("0#") : "");
			ClockNumberItem item = new ClockNumberItem(value, text, i * 360d / 60, value % 5 != 0);
			item.Visible = false;
			Items.Add(item);
			minuteItems.Add(item);
		}

		for (int i = 9; i < 21; i++) {
			int value = (i + 2) % 12 + 1;
			String text = value.ToString();
			ClockNumberItem item = new ClockNumberItem(value, text, i * 360d / 12, false);
			//item.Visible = false;
			Items.Add(item);
			hourItems.Add(item);
		}

		if (showAMPMButtons) {
			Items.Add(ClockItemAM);
			Items.Add(ClockItemPM);
		}

		if (showOKCancelButtons) {
			Items.Add(ClockButtonOK);
			Items.Add(ClockButtonCancel);
		}

		UpdateClockItemFonts();
		Value = DateTime.Now;
		ResumeLayout(false);

		ClockButtonOK.Click += btn_Click;
		ClockButtonCancel.Click += btn_Click;
	}
示例#2
0
		private static Point GetLocation(ClockControl clock, ClockNumberItem item, int gap = 3) {
			return GetLocation(clock.ClockFaceCenter, clock.ClockFaceSize, item.AngleDegrees, item.PreferredSize, gap);
		}