📄 blistcontroltoolbar.cs
字号:
namespace Imps.Client.Pc.Controls
{
using Imps.Client.Pc;
using Imps.Client.Pc.WndlessControls;
using Imps.Client.Resource;
using Imps.Client.Utils;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
public class BListControlToolbar : UserControl
{
private Color _clrTextBoxBorder = Color.FromArgb(0x1a, 0x68, 0xb3);
private ToolStripDropDown _dropdown;
private string _lastString = "";
private WndlessPictureBox _pbClear;
private WndlessPictureBox _pbMagnifier;
private WndlessButton _pbMenu;
private Rectangle _rectTextBox = Rectangle.Empty;
private ToolTip _searchTip = new ToolTip();
private bool _simpleMode;
private string _tipText;
private string _tipTextClear = "";
private string _tipTextMagnifier = "";
private string _tipTextMenu = "";
private WndlessControlCollection _wndlessControls;
private IContainer components;
private XTrackBar ctlDisplayMode;
private XTextBox tbSearch;
public BListControlToolbar()
{
this.set_DoubleBuffered(true);
this.InitializeComponent();
this.InitializeWndlessComponent();
this.LoadDefaultResource();
this.TryLoadStyle();
this.AdjustChildControls();
this._searchTip.AutomaticDelay = 800;
this._searchTip.AutoPopDelay = 0xbb8;
this._searchTip.InitialDelay = 800;
this._searchTip.ReshowDelay = 500;
this._searchTip.ShowAlways = true;
ListControlToolbarStyle.Instance.StyleChanged += new EventHandler(this.Instance_StyleChanged);
base.MouseLeave += new EventHandler(this.BListControlToolbar_MouseLeave);
base.MouseMove += new MouseEventHandler(this.BListControlToolbar_MouseMove);
base.GotFocus += new EventHandler(this.BListControlToolbar_GotFocus);
}
private void _pbClear_Click(object sender, EventArgs e)
{
this.tbSearch.Clear();
this._pbClear.Visible = false;
this._searchTip.SetToolTip(this, this.TipText);
this._searchTip.Hide(this);
}
public void AdjustChildControls()
{
try
{
base.SuspendLayout();
int num = 2;
int x = base.Width - 1;
int y = 0;
if (this.ctlDisplayMode.Visible)
{
x -= this.ctlDisplayMode.Width;
y = (base.Height - this.ctlDisplayMode.Height) / 2;
this.ctlDisplayMode.SetBounds(x, y, 0, 0, BoundsSpecified.Location);
}
if (this._pbMenu.Visible)
{
x -= this._pbMenu.Width + num;
y = (base.Height - this._pbMenu.Height) / 2;
this._pbMenu.SetBounds(x, y, 0, 0, BoundsSpecified.Location);
}
x -= this._pbClear.Width + 4;
y = (base.Height - this._pbClear.Height) / 2;
this._pbClear.SetBounds(x, y, 0, 0, BoundsSpecified.Location);
this._pbMagnifier.SetBounds(4, y, 0, 0, BoundsSpecified.Location);
x = this._pbMagnifier.Right + num;
y = (base.Height - this.tbSearch.Height) / 2;
int width = this._pbClear.Left - num;
width -= x;
this.tbSearch.SetBounds(x, y, width, 0, BoundsSpecified.Width | BoundsSpecified.Location);
}
catch
{
}
finally
{
base.ResumeLayout();
}
}
private void BListControlToolbar_GotFocus(object sender, EventArgs e)
{
this.tbSearch.Focus();
}
private void BListControlToolbar_MouseHover(object sender, EventArgs e)
{
}
private void BListControlToolbar_MouseLeave(object sender, EventArgs e)
{
}
private void BListControlToolbar_MouseMove(object sender, MouseEventArgs e)
{
try
{
this.ResetTip();
}
catch
{
}
}
private void BListControlToolbar_SizeChanged(object sender, EventArgs e)
{
this.AdjustChildControls();
}
protected override void Dispose(bool disposing)
{
ListControlToolbarStyle.Instance.StyleChanged -= new EventHandler(this.Instance_StyleChanged);
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
public void HideTip()
{
this._searchTip.Hide(this);
}
private void InitializeComponent()
{
this.tbSearch = new XTextBox();
this.ctlDisplayMode = new XTrackBar();
base.SuspendLayout();
this.tbSearch.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
this.tbSearch.BackColor = Color.White;
this.tbSearch.BorderStyle = BorderStyle.None;
this.tbSearch.EmptyTextTip = "";
this.tbSearch.EmptyTextTipColor = Color.DarkGray;
this.tbSearch.Location = new System.Drawing.Point(0, 1);
this.tbSearch.Name = "tbSearch";
this.tbSearch.Size = new Size(0x8a, 13);
this.tbSearch.TabIndex = 0;
this.tbSearch.TabStop = false;
this.tbSearch.TextChanged += new EventHandler(this.tbSearch_TextChanged);
this.tbSearch.Font = this.Font;
this.ctlDisplayMode.Anchor = AnchorStyles.Right | AnchorStyles.Top;
this.ctlDisplayMode.BackColor = Color.Transparent;
this.ctlDisplayMode.BarInnerColor = Color.FromArgb(8, 0x33, 0x5d);
this.ctlDisplayMode.BarOuterColor = Color.FromArgb(8, 0x33, 0x5d);
this.ctlDisplayMode.ColorSchema = XTrackBar.ColorSchemas.Fetion;
this.ctlDisplayMode.LargeChange = 1;
this.ctlDisplayMode.Location = new System.Drawing.Point(0xb9, 1);
this.ctlDisplayMode.Maximum = 3;
this.ctlDisplayMode.Name = "ctlDisplayMode";
this.ctlDisplayMode.Size = new Size(0x43, 20);
this.ctlDisplayMode.SmallChange = 1;
this.ctlDisplayMode.TabIndex = 1;
this.ctlDisplayMode.TabStop = false;
this.ctlDisplayMode.ThumbInnerColor = Color.FromArgb(0xba, 0xbf, 0xc5);
this.ctlDisplayMode.ThumbPenColor = Color.FromArgb(20, 0x53, 0x88);
this.ctlDisplayMode.ThumbSize = 6;
this.ctlDisplayMode.Value = 0;
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.Controls.Add(this.ctlDisplayMode);
base.Controls.Add(this.tbSearch);
base.Name = "BListControlToolbar";
base.Size = new Size(0xfc, 0x17);
base.ResumeLayout(false);
base.PerformLayout();
}
private void InitializeWndlessComponent()
{
try
{
this._wndlessControls = new WndlessControlCollection(this);
this._pbMagnifier = new WndlessPictureBox();
this._pbMagnifier.AutoSize = true;
this._pbClear = new WndlessPictureBox();
this._pbClear.AutoSize = true;
this._pbClear.Anchor = AnchorStyles.Right | AnchorStyles.Top;
this._pbClear.Visible = false;
this._pbClear.Click += new EventHandler(this._pbClear_Click);
this._pbMenu = new WndlessButton();
this._pbMenu.AutoSize = true;
this._pbMenu.Visible = false;
this._pbMenu.Anchor = AnchorStyles.Right | AnchorStyles.Top;
this._pbMenu.Click += new EventHandler(this.pbMenu_Click);
this._wndlessControls.Add(this._pbMagnifier);
this._wndlessControls.Add(this._pbClear);
this._wndlessControls.Add(this._pbMenu);
}
catch (Exception exception)
{
Trace.WriteLine(exception.ToString());
}
}
private void Instance_StyleChanged(object sender, EventArgs e)
{
this.LoadDefaultResource();
this.TryLoadStyle();
}
private void LoadDefaultResource()
{
try
{
Assembly asm = Assembly.GetCallingAssembly();
this.BackgroundImage = null;
this._pbMagnifier.Image = ResourceHelper.GetResImage(asm, "Imps.Client.Pc.Resource.Magnifier.png");
this._pbClear.Image = ResourceHelper.GetResImage(asm, "Imps.Client.Pc.Resource.Clear.png");
this._pbMenu.Image = ResourceHelper.GetResImage(asm, "Imps.Client.Pc.Resource.ListControlToolbar_Menu.png");
this.DisplayModeTrackBar.set_Padding(new Padding(5, 10, 4, 1));
}
catch (Exception exception)
{
Trace.WriteLine(exception.ToString());
}
}
protected override void OnPaint(PaintEventArgs e)
{
int num = 2;
Graphics g = e.Graphics;
Image backgoundImage = ListControlToolbarStyle.Instance.BackgoundImage;
if (backgoundImage == null)
{
backgoundImage = this.BackgroundImage;
}
if (this.SimpleMode)
{
using (Brush brush = new SolidBrush(this.BackColor))
{
g.FillRectangle(brush, base.ClientRectangle);
goto Label_0060;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -