?? dxmutgui.cs
字號:
e.TextureColor.States[(int)ControlState.Pressed] = WhiteColorValue;
// Assign the element
SetDefaultElement(ControlType.RadioButton, RadioButton.BoxLayer, e);
//-------------------------------------
// RadioButton - Check
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(81, 54, 108, 81));
// Assign the element
SetDefaultElement(ControlType.RadioButton, RadioButton.CheckLayer, e);
//-------------------------------------
// ComboBox - Main
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(7, 81, 247, 123));
e.SetFont(0);
e.TextureColor.States[(int)ControlState.Normal] = new ColorValue(0.8f, 0.8f, 0.8f, 0.55f);
e.TextureColor.States[(int)ControlState.Focus] = new ColorValue(0.95f, 0.95f, 0.95f, 0.6f);
e.TextureColor.States[(int)ControlState.Disabled] = new ColorValue(0.8f, 0.8f, 0.8f, 0.25f);
e.FontColor.States[(int)ControlState.MouseOver] = new ColorValue(0,0,0,1.0f);
e.FontColor.States[(int)ControlState.Pressed] = new ColorValue(0,0,0,1.0f);
e.FontColor.States[(int)ControlState.Disabled] = new ColorValue(0.8f, 0.8f, 0.8f, 0.8f);
// Assign the element
SetDefaultElement(ControlType.ComboBox, ComboBox.MainLayer, e);
//-------------------------------------
// ComboBox - Button
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(98, 189, 151, 238));
e.TextureColor.States[(int)ControlState.Normal] = new ColorValue(1.0f, 1.0f, 1.0f, 0.55f);
e.TextureColor.States[(int)ControlState.Pressed] = new ColorValue(0.55f, 0.55f, 0.55f, 1.0f);
e.TextureColor.States[(int)ControlState.Focus] = new ColorValue(1.0f, 1.0f, 1.0f, 0.75f);
e.TextureColor.States[(int)ControlState.Disabled] = new ColorValue(1.0f, 1.0f, 1.0f, 0.25f);
// Assign the element
SetDefaultElement(ControlType.ComboBox, ComboBox.ComboButtonLayer, e);
//-------------------------------------
// ComboBox - Dropdown
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(13, 123, 241, 160));
e.SetFont(0, BlackColorValue, DrawTextFormat.Left | DrawTextFormat.Top);
// Assign the element
SetDefaultElement(ControlType.ComboBox, ComboBox.DropdownLayer, e);
//-------------------------------------
// ComboBox - Selection
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(12, 163, 239, 183));
e.SetFont(0, WhiteColorValue, DrawTextFormat.Left | DrawTextFormat.Top);
// Assign the element
SetDefaultElement(ControlType.ComboBox, ComboBox.SelectionLayer, e);
//-------------------------------------
// Slider - Track
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(1, 187, 93, 228));
e.TextureColor.States[(int)ControlState.Normal] = new ColorValue(1.0f, 1.0f, 1.0f, 0.55f);
e.TextureColor.States[(int)ControlState.Focus] = new ColorValue(1.0f, 1.0f, 1.0f, 0.75f);
e.TextureColor.States[(int)ControlState.Disabled] = new ColorValue(1.0f, 1.0f, 1.0f, 0.25f);
// Assign the element
SetDefaultElement(ControlType.Slider, Slider.TrackLayer, e);
//-------------------------------------
// Slider - Button
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(151, 193, 192, 234));
// Assign the element
SetDefaultElement(ControlType.Slider, Slider.ButtonLayer, e);
//-------------------------------------
// Scrollbar - Track
//-------------------------------------
int scrollBarStartX = 196;
int scrollBarStartY = 191;
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(scrollBarStartX + 0, scrollBarStartY + 21, scrollBarStartX + 22, scrollBarStartY + 32));
// Assign the element
SetDefaultElement(ControlType.Scrollbar, ScrollBar.TrackLayer, e);
//-------------------------------------
// Scrollbar - Up Arrow
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(scrollBarStartX + 0, scrollBarStartY + 1, scrollBarStartX + 22, scrollBarStartY + 21));
e.TextureColor.States[(int)ControlState.Disabled] = new ColorValue(0.8f, 0.8f, 0.8f, 1.0f);
// Assign the element
SetDefaultElement(ControlType.Scrollbar, ScrollBar.UpButtonLayer, e);
//-------------------------------------
// Scrollbar - Down Arrow
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(scrollBarStartX + 0, scrollBarStartY + 32, scrollBarStartX + 22, scrollBarStartY + 53));
e.TextureColor.States[(int)ControlState.Disabled] = new ColorValue(0.8f, 0.8f, 0.8f, 1.0f);
// Assign the element
SetDefaultElement(ControlType.Scrollbar, ScrollBar.DownButtonLayer, e);
//-------------------------------------
// Scrollbar - Button
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(220, 192, 238, 234));
// Assign the element
SetDefaultElement(ControlType.Scrollbar, ScrollBar.ThumbLayer, e);
//-------------------------------------
// EditBox
//-------------------------------------
// Element assignment:
// 0 - text area
// 1 - top left border
// 2 - top border
// 3 - top right border
// 4 - left border
// 5 - right border
// 6 - lower left border
// 7 - lower border
// 8 - lower right border
e.SetFont(0, BlackColorValue, DrawTextFormat.Left | DrawTextFormat.Top);
// Assign the styles
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(14, 90, 241, 113));
SetDefaultElement(ControlType.EditBox, EditBox.TextLayer, e);
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(8, 82, 14, 90));
SetDefaultElement(ControlType.EditBox, EditBox.TopLeftBorder, e);
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(14, 82, 241, 90));
SetDefaultElement(ControlType.EditBox, EditBox.TopBorder, e);
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(241, 82, 246, 90));
SetDefaultElement(ControlType.EditBox, EditBox.TopRightBorder, e);
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(8, 90, 14, 113));
SetDefaultElement(ControlType.EditBox, EditBox.LeftBorder, e);
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(241, 90, 246, 113));
SetDefaultElement(ControlType.EditBox, EditBox.RightBorder, e);
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(8, 113, 14, 121));
SetDefaultElement(ControlType.EditBox, EditBox.LowerLeftBorder, e);
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(14, 113, 241, 121));
SetDefaultElement(ControlType.EditBox, EditBox.LowerBorder, e);
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(241, 113, 246, 121));
SetDefaultElement(ControlType.EditBox, EditBox.LowerRightBorder, e);
//-------------------------------------
// Listbox - Main
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(13, 123, 241, 160));
e.SetFont(0, BlackColorValue, DrawTextFormat.Left | DrawTextFormat.Top);
// Assign the element
SetDefaultElement(ControlType.ListBox, ListBox.MainLayer, e);
//-------------------------------------
// Listbox - Selection
//-------------------------------------
e.SetTexture(0, System.Drawing.Rectangle.FromLTRB(16, 166, 240, 183));
e.SetFont(0, WhiteColorValue, DrawTextFormat.Left | DrawTextFormat.Top);
// Assign the element
SetDefaultElement(ControlType.ListBox, ListBox.SelectionLayer, e);
}
/// <summary>Removes all controls from this dialog</summary>
public void RemoveAllControls()
{
controlList.Clear();
if ( (controlFocus != null) && (controlFocus.Parent == this) )
controlFocus = null;
controlMouseOver = null;
}
/// <summary>Clears the radio button group</summary>
public void ClearRadioButtonGroup(uint groupIndex)
{
// Find all radio buttons with the given group number
foreach(Control c in controlList)
{
if (c.ControlType == ControlType.RadioButton)
{
RadioButton rb = c as RadioButton;
// Clear the radio button checked setting
if (rb.ButtonGroup == groupIndex)
rb.SetChecked(false, false);
}
}
}
/// <summary>Clears the combo box of all items</summary>
public void ClearComboBox(int id)
{
ComboBox comboBox = GetComboBox(id);
if (comboBox == null)
return;
comboBox.Clear();
}
#region Message handling
private static bool isDragging;
/// <summary>
/// Handle messages for this dialog
/// </summary>
public bool MessageProc(IntPtr hWnd, NativeMethods.WindowMessage msg, IntPtr wParam, IntPtr lParam)
{
// If caption is enable, check for clicks in the caption area.
if (hasCaption)
{
if (msg == NativeMethods.WindowMessage.LeftButtonDown || msg == NativeMethods.WindowMessage.LeftButtonDoubleClick)
{
// Current mouse position
short mouseX = NativeMethods.LoWord((uint)lParam.ToInt32());
short mouseY = NativeMethods.HiWord((uint)lParam.ToInt32());
if (mouseX >= dialogX && mouseX < dialogX + width &&
mouseY >= dialogY && mouseY < dialogY + captionHeight)
{
isDragging = true;
NativeMethods.SetCapture(hWnd);
return true;
}
}
else if ( (msg == NativeMethods.WindowMessage.LeftButtonUp) && isDragging)
{
// Current mouse position
short mouseX = NativeMethods.LoWord((uint)lParam.ToInt32());
short mouseY = NativeMethods.HiWord((uint)lParam.ToInt32());
if (mouseX >= dialogX && mouseX < dialogX + width &&
mouseY >= dialogY && mouseY < dialogY + captionHeight)
{
NativeMethods.ReleaseCapture();
isDragging = false;
return true;
}
}
}
// If the dialog is minimized, don't send any messages to controls.
if (isDialogMinimized)
return false;
// If a control is in focus, it belongs to this dialog, and it's enabled, then give
// it the first chance at handling the message.
if (controlFocus != null &&
controlFocus.Parent == this &&
controlFocus.IsEnabled)
{
// If the control MsgProc handles it, then we don't.
if (controlFocus.MsgProc(hWnd, msg, wParam, lParam))
return true;
}
switch(msg)
{
// Call OnFocusIn()/OnFocusOut() of the control that currently has the focus
// as the application is activated/deactivated. This matches the Windows
// behavior.
case NativeMethods.WindowMessage.ActivateApplication:
{
if (controlFocus != null &&
controlFocus.Parent == this &&
controlFocus.IsEnabled)
{
if (wParam != IntPtr.Zero)
controlFocus.OnFocusIn();
else
controlFocus.OnFocusOut();
}
}
break;
// Keyboard messages
case NativeMethods.WindowMessage.KeyDown:
case NativeMethods.WindowMessage.SystemKeyDown:
case NativeMethods.WindowMessage.KeyUp:
case NativeMethods.WindowMessage.SystemKeyUp:
{
// If a control is in focus, it belongs to this dialog, and it's enabled, then give
// it the first chance at handling the message.
if (controlFocus != null &&
controlFocus.Parent == this &&
controlFocus.IsEnabled)
{
// If the control MsgProc handles it, then we don't.
if (controlFocus.HandleKeyboard(msg, wParam, lParam))
return true;
}
// Not yet handled, see if this matches a control's hotkey
if (msg == NativeMethods.WindowMessage.KeyUp)
{
foreach(Control c in controlList)
{
// Was the hotkey hit?
if (c.Hotkey == (System.Windows.Forms.Keys)wParam.ToInt32())
{
// Yup!
c.OnHotKey();
return true;
}
}
}
if (msg == NativeMethods.WindowMessage.KeyDown)
{
// If keyboard input is not enabled, this message should be ignored
if (!usingKeyboardInput)
return false;
System.Windows.Forms.Keys key = (System.Windows.Forms.Keys)wParam.ToInt32();
switch(key)
{
case System.Windows.Forms.Keys.Right:
case System.Windows.Forms.Keys.Down:
if (controlFocus != null)
{
OnCycleFocus(true);
return true;
}
break;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -