Commit 419b527d HZH

Revert "移动窗体"

This reverts commit 3f45e622.
1 个父辈 f27f1d76
......@@ -37,7 +37,6 @@ namespace HZH_Controls.Forms
public FrmBack()
{
InitializeComponent();
InitFormMove(this.panTop);
}
private void btnBack1_btnClick(object sender, EventArgs e)
......
......@@ -10,7 +10,6 @@ using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
......@@ -290,7 +289,7 @@ namespace HZH_Controls.Forms
protected virtual void DoEnter()
{
}
/// <summary>
/// 设置重绘区域
/// </summary>
......@@ -359,7 +358,7 @@ namespace HZH_Controls.Forms
#region 事件区
/// <summary>
/// 关闭时发生
/// </summary>
......@@ -372,7 +371,7 @@ namespace HZH_Controls.Forms
(base.Owner as FrmTransparent).Close();
}
}
/// <summary>
/// 快捷键
/// </summary>
......@@ -467,44 +466,5 @@ namespace HZH_Controls.Forms
}
#endregion
#region 窗体拖动 English:Form drag
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
/// <summary>
/// 通过Windows的API控制窗体的拖动
/// </summary>
/// <param name="hwnd"></param>
public static void MouseDown(IntPtr hwnd)
{
ReleaseCapture();
SendMessage(hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
#endregion
/// <summary>
/// 在构造函数中调用设置窗体移动
/// </summary>
/// <param name="c">拖动控件,一般为标题栏</param>
protected void InitFormMove(params Control[] cs)
{
foreach (Control c in cs)
{
if (c != null && !c.IsDisposed)
c.MouseDown += c_MouseDown;
}
}
void c_MouseDown(object sender, MouseEventArgs e)
{
MouseDown(this.Handle);
}
}
}
......@@ -25,7 +25,6 @@ namespace HZH_Controls.Forms
bool blnisEnterClose = true)
{
InitializeComponent();
InitFormMove(this.lblTitle);
if (!string.IsNullOrWhiteSpace(strTitle))
lblTitle.Text = strTitle;
lblMsg.Text = strMessage;
......
......@@ -52,7 +52,6 @@ namespace HZH_Controls.Forms
public FrmWithTitle()
{
InitializeComponent();
InitFormMove(this.lblTitle);
}
private void btnClose_MouseDown(object sender, MouseEventArgs e)
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace HZH_Controls
{
public interface ITheme
{
/// <summary>
/// 重置主题
/// </summary>
/// <param name="theme"></param>
void ResetTheme(ThemeEntity theme);
/// <summary>
/// 是否禁用一键换肤,默认禁用
/// </summary>
bool EnabledTheme { get; set; }
}
public class ThemeEntity
{
/// <summary>
/// 边框颜色
/// </summary>
public Color? BorderColor { get; set; }
/// <summary>
/// 填充颜色
/// </summary>
public Color? FillColor { get; set; }
/// <summary>
/// 背景色
/// </summary>
public Color? BackColor { get; set; }
/// <summary>
/// 前景色
/// </summary>
public Color? ForeColor { get; set; }
/// <summary>
/// 字体颜色
/// </summary>
public Color? FontColor { get; set; }
/// <summary>
/// 选中颜色
/// </summary>
public Color? SelectedColor { get; set; }
/// <summary>
/// 选中字体颜色
/// </summary>
public Color? SelectedFontColor { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HZH_Controls.Controls;
namespace HZH_Controls.Theme
{
public abstract class ThemeBase : IControlTheme
{
public virtual bool ControlTheme(Control control)
{
#region 按钮 English:Button
if (control is UCBtnExt)
{
return Theme_UCBtnExt(control as UCBtnExt);
}
else if (control is UCBtnFillet)
{
return Theme_UCBtnFillet(control as UCBtnFillet);
}
else if (control is UCBtnImg)
{
return Theme_UCBtnImg(control as UCBtnImg);
}
else if (control is UCDropDownBtn)
{
return Theme_UCDropDownBtn(control as UCDropDownBtn);
}
else if (control is UCBtnsGroup)
{
return Theme_UCBtnsGroup(control as UCBtnsGroup);
}
#endregion
#region Checkbox English:Checkbox
else if (control is UCCheckBox)
{
return Theme_UCCheckBox(control as UCCheckBox);
}
#endregion
#region UCComboBox English:UCComboBox
else if (control is UCComboBox)
{
return Theme_UCComboBox(control as UCComboBox);
}
#endregion
#region Datagridview English:Datagridview
else if (control is UCDataGridView)
{
return Theme_UCDataGridView(control as UCDataGridView);
}
else if (control is UCDataGridViewRow)
{
return Theme_UCDataGridViewRow(control as UCDataGridViewRow);
}
else if (control is UCDataGridViewTreeRow)
{
return Theme_UCDataGridViewTreeRow(control as UCDataGridViewTreeRow);
}
#endregion
#region UCDatePickerExt English:UCDatePickerExt
else if (control is UCDatePickerExt)
{
return Theme_UCDatePickerExt(control as UCDatePickerExt);
}
#endregion
#region KeyBorder English:KeyBorder
else if (control is UCKeyBorderAll)
{
return Theme_UCKeyBorderAll(control as UCKeyBorderAll);
}
else if (control is UCKeyBorderNum)
{
return Theme_UCKeyBorderNum(control as UCKeyBorderNum);
}
else if (control is UCKeyBorderPay)
{
return Theme_UCKeyBorderPay(control as UCKeyBorderPay);
}
#endregion
#region List English:List
else if (control is TreeViewEx)
{
return Theme_TreeViewEx(control as TreeViewEx);
}
else if (control is UCHorizontalList)
{
return Theme_UCHorizontalList(control as UCHorizontalList);
}
else if (control is UCListExt)
{
return Theme_UCListExt(control as UCListExt);
}
else if (control is UCListItemExt)
{
return Theme_UCListItemExt(control as UCListItemExt);
}
else if (control is UCListView)
{
return Theme_UCListView(control as UCListView);
}
else if (control is UCListViewItem)
{
return Theme_UCListViewItem(control as UCListViewItem);
}
else if (control is UCPagerControlBase)
{
return Theme_UCPagerControl(control as UCPagerControlBase);
}
#endregion
#region Menu English:Menu
else if (control is UCMenu)
{
return Theme_UCMenu(control as UCMenu);
}
else if (control is UCMenuChildrenItem)
{
return Theme_UCMenuChildrenItem(control as UCMenuChildrenItem);
}
else if (control is UCMenuParentItem)
{
return Theme_UCMenuParentItem(control as UCMenuParentItem);
}
#endregion
#region UCCrumbNavigation English:UCCrumbNavigation
else if (control is UCCrumbNavigation)
{
return Theme_UCCrumbNavigation(control as UCCrumbNavigation);
}
#endregion
#region UCPanelTitle English:UCPanelTitle
else if (control is UCPanelTitle)
{
return Theme_UCPanelTitle(control as UCPanelTitle);
}
#endregion
#region Process English:Process
else if (control is UCProcessEllipse)
{
return Theme_UCProcessEllipse(control as UCProcessEllipse);
}
else if (control is UCProcessExt)
{
return Theme_UCProcessExt(control as UCProcessExt);
}
else if (control is UCProcessLine)
{
return Theme_UCProcessLine(control as UCProcessLine);
}
else if (control is UCProcessLineExt)
{
return Theme_UCProcessLineExt(control as UCProcessLineExt);
}
else if (control is UCProcessWave)
{
return Theme_UCProcessWave(control as UCProcessWave);
}
#endregion
#region UCRadioButton English:UCRadioButton
else if (control is UCRadioButton)
{
return Theme_UCRadioButton(control as UCRadioButton);
}
#endregion
#region SplitLine English:SplitLine
else if (control is UCSplitLine_H)
{
return Theme_UCSplitLine_H(control as UCSplitLine_H);
}
else if (control is UCSplitLine_V)
{
return Theme_UCSplitLine_V(control as UCSplitLine_V);
}
#endregion
#region UCStep English:UCStep
else if (control is UCStep)
{
return Theme_UCStep(control as UCStep);
}
#endregion
#region UCSwitch English:UCSwitch
else if (control is UCSwitch)
{
return Theme_UCSwitch(control as UCSwitch);
}
#endregion
#region TabControlExt English:TabControlExt
else if (control is TabControlExt)
{
return Theme_TabControlExt(control as TabControlExt);
}
#endregion
#region Textbox English:Textbox
else if (control is TextBoxEx)
{
return Theme_TextBoxEx(control as TextBoxEx);
}
else if (control is TextBoxTransparent)
{
return Theme_TextBoxTransparent(control as TextBoxTransparent);
}
else if (control is UCNumTextBox)
{
return Theme_UCNumTextBox(control as UCNumTextBox);
}
else if (control is UCTextBoxEx)
{
return Theme_UCTextBoxEx(control as UCTextBoxEx);
}
#endregion
#region Wave English:Wave
else if (control is UCWave)
{
return Theme_UCWave(control as UCWave);
}
else if (control is UCWaveChart)
{
return Theme_UCWaveChart(control as UCWaveChart);
}
#endregion
else
{
return CustomControlTheme(control);
}
}
#region 具体控件主题 English:Specific Control Theme
#region 按钮 English:Button
protected abstract bool Theme_UCBtnExt(UCBtnExt c);
protected abstract bool Theme_UCBtnFillet(UCBtnFillet c);
protected abstract bool Theme_UCBtnImg(UCBtnImg c);
protected abstract bool Theme_UCDropDownBtn(UCDropDownBtn c);
protected abstract bool Theme_UCBtnsGroup(UCBtnsGroup c);
#endregion
#region Checkbox English:Checkbox
/// <summary>
/// 功能描述:Checkbox English:Checkbox
/// 作  者:HZH
/// 创建日期:2019-08-28 09:06:38
/// 任务编号:POS
/// </summary>
/// <param name="c">c</param>
protected abstract bool Theme_UCCheckBox(UCCheckBox c);
#endregion
#region UCComboBox English:UCComboBox
/// <summary>
/// 功能描述:UCComboBox English:UCComboBox
/// 作  者:HZH
/// 创建日期:2019-08-28 09:07:31
/// 任务编号:POS
/// </summary>
/// <param name="c">c</param>
protected abstract bool Theme_UCComboBox(UCComboBox c);
#endregion
#region Datagridview English:Datagridview
protected abstract bool Theme_UCDataGridView(UCDataGridView c);
protected abstract bool Theme_UCDataGridViewRow(UCDataGridViewRow c);
protected abstract bool Theme_UCDataGridViewTreeRow(UCDataGridViewTreeRow c);
#endregion
#region UCDatePickerExt English:UCDatePickerExt
protected abstract bool Theme_UCDatePickerExt(UCDatePickerExt c);
#endregion
#region UCKeyBorderAll English:UCKeyBorderAll
protected abstract bool Theme_UCKeyBorderAll(UCKeyBorderAll c);
protected abstract bool Theme_UCKeyBorderNum(UCKeyBorderNum c);
protected abstract bool Theme_UCKeyBorderPay(UCKeyBorderPay c);
#endregion
#region List English:List
protected abstract bool Theme_TreeViewEx(TreeViewEx c);
protected abstract bool Theme_UCHorizontalList(UCHorizontalList c);
protected abstract bool Theme_UCListExt(UCListExt c);
protected abstract bool Theme_UCListItemExt(UCListItemExt c);
protected abstract bool Theme_UCListView(UCListView c);
protected abstract bool Theme_UCListViewItem(UCListViewItem c);
protected abstract bool Theme_UCPagerControl(UCPagerControlBase c);
#endregion
#region Menu English:Menu
protected abstract bool Theme_UCMenu(UCMenu c);
protected abstract bool Theme_UCMenuChildrenItem(UCMenuChildrenItem c);
protected abstract bool Theme_UCMenuParentItem(UCMenuParentItem c);
#endregion
#region UCCrumbNavigation English:UCCrumbNavigation
protected abstract bool Theme_UCCrumbNavigation(UCCrumbNavigation c);
#endregion
#region UCPanelTitle English:UCPanelTitle
protected abstract bool Theme_UCPanelTitle(UCPanelTitle c);
#endregion
#region Process English:Process
protected abstract bool Theme_UCProcessEllipse(UCProcessEllipse c);
protected abstract bool Theme_UCProcessExt(UCProcessExt c);
protected abstract bool Theme_UCProcessLine(UCProcessLine c);
protected abstract bool Theme_UCProcessLineExt(UCProcessLineExt c);
protected abstract bool Theme_UCProcessWave(UCProcessWave c);
#endregion
#region UCRadioButton English:UCRadioButton
protected abstract bool Theme_UCRadioButton(UCRadioButton c);
#endregion
#region SplitLine English:SplitLine
protected abstract bool Theme_UCSplitLine_H(UCSplitLine_H c);
protected abstract bool Theme_UCSplitLine_V(UCSplitLine_V c);
#endregion
#region UCStep English:UCStep
protected abstract bool Theme_UCStep(UCStep c);
#endregion
#region UCSwitch English:UCSwitch
protected abstract bool Theme_UCSwitch(UCSwitch c);
#endregion
#region TabControlExt English:TabControlExt
protected abstract bool Theme_TabControlExt(TabControlExt c);
#endregion
#region Textbox English:Textbox
protected abstract bool Theme_TextBoxEx(TextBoxEx c);
protected abstract bool Theme_TextBoxTransparent(TextBoxTransparent c);
protected abstract bool Theme_UCNumTextBox(UCNumTextBox c);
protected abstract bool Theme_UCTextBoxEx(UCTextBoxEx c);
#endregion
#region Wave English:Wave
protected abstract bool Theme_UCWave(UCWave c);
protected abstract bool Theme_UCWaveChart(UCWaveChart c);
#endregion
#endregion
#region 自定义控件主题,如果需要对自定义的控件进行处理,请添加对应的主题类,使用partial关键字,然后重写此函数即可 English:Custom control theme. If you need to process the custom control, add the corresponding topic class, use the partial keyword, and then rewrite the function.
/// <summary>
/// 功能描述:自定义控件主题,如果需要对自定义的控件进行处理,请添加对应的主题类,使用partial关键字,然后重写此函数即可 English:Custom control theme. If you need to process the custom control, add the corresponding topic class, use the partial keyword, and then rewrite the function.
/// 作  者:HZH
/// 创建日期:2019-08-28 09:58:04
/// 任务编号:
/// </summary>
/// <param name="control">control</param>
protected virtual bool CustomControlTheme(Control control)
{
return true;
}
#endregion
#region 获取控件真实的背景色,当为透明色时取父控件颜色 English:Gets the true background color of the control and the parent color when it is transparent
/// <summary>
/// 功能描述:获取控件真实的背景色,当为透明色时取父控件颜色 English:Gets the true background color of the control and the parent color when it is transparent
/// 作  者:HZH
/// 创建日期:2019-08-28 11:15:22
/// 任务编号:
/// </summary>
/// <param name="control">control</param>
/// <returns>返回值</returns>
protected Color GetBackColor(Control control)
{
if (control.BackColor == Color.Transparent && control.Parent != null)
{
return GetBackColor(control.Parent);
}
else
{
return control.BackColor;
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HZH_Controls.Theme
{
public enum ThemeTypes
{
Default,
Blue
}
}
当你需要使用主题时,请按照以下步骤处理:
1、请添加主题类,比如Blue,然后继承抽象类ThemeBase并实现它
2、在ThemeTypes中添加对应的枚举,比如Blue
3、在需要做主题控制的窗体上,添加UCTheme控件,然后选择主题
如果你需要在已有的主题上对其他控件进行主题控制的时候,比如在Blue主题的基础上,对一个名称为panTop的panel进行设置背景色,请按照以下步骤处理:
1、添加一个类BlueExt(这个名字随意)
2、修改类名称为Blue并添加关键字partial
3、重写CustomControlTheme函数,在CustomControlTheme函数中对panTop修改颜色
----------------------
When you need to use a theme, follow these steps:
1, please add a theme class, such as Blue, and then inherit the abstract class ThemeBase and implement it
2. Add the corresponding enumeration in ThemeTypes, such as Blue.
3. On the form that needs to do the theme control, add the UCTheme control, then select the theme.
If you need to control the theme of other controls on an existing theme, such as setting the background color for a panel named panTop based on the Blue theme, follow these steps:
1, add a class BlueExt (this name is free)
2, modify the class name to Blue and add the keyword partial
3, rewrite the CustomControlTheme function, modify the color of the panTop in the CustomControlTheme function
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!