📄 newcontrol.cs
字号:
}
}
_nowTier = -1;
this.Cursor = System.Windows.Forms.Cursors.Default;
}
else
{
if (_nowTier != -1)
{
_nowTier = -1;
this.Cursor = System.Windows.Forms.Cursors.Default;
}
}
//base.OnMouseMove(e);
}
protected override void OnMouseDown(MouseEventArgs e)
{
if (_nowTier != -1)
{
_dragTier = true;
}
else if (e.Y > _heightOfCpt)
{
if (_ifScroll == true && e.X > this.Width - 15)
{
int t_n = e.Y;
if (t_n < _heightOfCpt + 15)
{
_nowStartRow -= 1;
_nowScrollY = _heightOfCpt + 15 + (this.Height - _heightOfCpt - 30) * _nowStartRow / _field.Count;
this.OnPaint(new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle));
}
else if (t_n > this.Height - 15)
{
_nowStartRow += 1;
_nowScrollY = _heightOfCpt + 15 + (this.Height - _heightOfCpt - 30) * _nowStartRow / _field.Count;
this.OnPaint(new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle));
}
else if (t_n > _nowScrollY && t_n < _nowScrollY + 34)
{
_dragScroll = true;
_nowScrollInY = t_n - _nowScrollY;
}
else
{
_nowScrollY = t_n - _heightOfCpt - 15;
_nowStartRow = _field.Count * (_nowScrollY - _heightOfCpt - 15) / (this.Height - _heightOfCpt - 30);
this.OnPaint(new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle));
}
}
else
{
int t_n = _nowStartRow + (e.Y - _heightOfCpt) / _heightOfRow;
if (_nowChecked != t_n)
{
_nowChecked = t_n;
this.OnPaint(new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle));
}
}
}
this.Focus();
//base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
if (_dragTier == true)
{
_dragTier = false;
}
else if (_dragScroll == true)
{
_dragScroll = false;
}
//base.OnMouseUp(e);
}
protected override void OnMouseWheel(MouseEventArgs e)
{
if (e.Delta > 0)
{
_nowStartRow -= 1;
}
else
{
_nowStartRow += 1;
}
_nowScrollY = _heightOfCpt + 15 + (this.Height - _heightOfCpt - 30) * _nowStartRow / _field.Count;
this.OnPaint(new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle));
}
}
}
/*
class JPM_PushPanelBox_ImageAndString
{
public System.Drawing.Image _Image;
public string _String;
}
public class JPM_PushPanelBox_Panel
{
/// <summary>
/// const
/// </summary>
public const int ENTITY_TYPE_STRING = 0;
public const int ENTITY_TYPE_IMAGE = 1;
public const int ENTITY_TYPE_IMAGEANDSTRING = 2;
public const int BACKGROUND_MODE_CENTER = 0;
public const int BACKGROUND_MODE_STRETCH = 1;
public const int ENTITY_MODE_CENTER = 0;
public const int ENTITY_MODE_LEFT = 1;
public const int ENTTTY_MODE_RIGHT = 2;
public const int ENTITY_POS_TOLEFT = 4;
public const int ENTITY_POS_TOTOP = 4;
int _width = 0;
int _height = 0;
System.Collections.ArrayList _entitys = new System.Collections.ArrayList();
System.Collections.ArrayList _entityTypes = new System.Collections.ArrayList();
System.Drawing.Color _backgroundColor = Color.White;
System.Drawing.Image _backgroundImage;
int _backgroundImageMode = BACKGROUND_MODE_CENTER;
bool _entityBorder = true;
int _entityMode = ENTITY_MODE_CENTER;
int _heightOfRow;
bool _ifScroll = false;
bool _dragScroll = false;
int _nowScrollY = 0;
int _nowScrollInY = 0;
int _nowStartRow = 0;
int _nowChecked = -1;
public System.Drawing.Color BackgroundColor
{
set
{
_backgroundColor = value;
}
get
{
return _backgroundColor;
}
}
public System.Drawing.Image BackgoundImage
{
set
{
_backgroundImage = value;
}
get
{
return _backgroundImage;
}
}
public int BackgroundMode
{
set
{
_backgroundImageMode = value;
}
get
{
return _backgroundImageMode;
}
}
public bool EntityBorder
{
set
{
_entityBorder = value;
}
get
{
return _entityBorder;
}
}
public int EntityMode
{
set
{
_entityMode = value;
}
get
{
return _entityMode;
}
}
public int HeightOfRow
{
set
{
_heightOfRow = value;
}
get
{
return _heightOfRow;
}
}
public void AddAnEntity(string theStr)
{
_entitys.Add(theStr);
_entityTypes.Add(ENTITY_TYPE_STRING);
}
public void AddAnEntity(System.Drawing.Image theImage)
{
_entitys.Add(theImage);
_entityTypes.Add(ENTITY_TYPE_IMAGE);
}
public void AddAnEntity(System.Drawing.Image theImage, string theStr)
{
JPM_PushPanelBox_ImageAndString t_IS = new JPM_PushPanelBox_ImageAndString();
t_IS._Image = theImage;
t_IS._String = theStr;
_entitys.Add(t_IS);
_entityTypes.Add(ENTITY_TYPE_IMAGEANDSTRING);
}
public System.Drawing.Image GetPanelUIBuffer(int NewWidth, int NewHeight, System.Drawing.Font PFont)
{
int t_r, t_rc,t_et;
int t_cOfDirRows;
string t_str;
SizeF t_sizeF;
JPM_PushPanelBox_ImageAndString t_IS;
System.Drawing.Image t_imageSource = global::NewControl.Resource.BMP_LISTSOURCE;
System.Drawing.Image t_image;
System.Drawing.SolidBrush t_BBrush = new SolidBrush(Color.Black);
System.Drawing.Bitmap t_bmpBuffer = new Bitmap(NewWidth,NewHeight);
System.Drawing.Graphics t_G = Graphics.FromImage(t_bmpBuffer);
_width = NewWidth;
_height = NewHeight;
t_G.FillRectangle(new SolidBrush(_backgroundColor),new Rectangle(0,0,NewWidth,NewHeight));
if (_backgroundImageMode == BACKGROUND_MODE_CENTER)
{
if (_backgroundImage != null)
{
t_G.DrawImageUnscaled(_backgroundImage, new Rectangle((NewWidth - _backgroundImage.Width) / 2, (NewHeight - _backgroundImage.Height) / 2, _backgroundImage.Width, _backgroundImage.Height));
}
}
else
{
if (_backgroundImage != null)
{
t_G.DrawImage(_backgroundImage, new Rectangle(0,0,NewWidth,NewHeight));
}
}
t_cOfDirRows = NewHeight/_heightOfRow;
t_rc = _heightOfRow>_entitys.Count?_entitys.Count:_heightOfRow;
if (_nowStartRow < 0)
{
_nowStartRow = 0;
}
else if (_nowStartRow >= _entitys.Count)
{
_nowStartRow = _entitys.Count - 1;
}
if (_entityMode == ENTITY_MODE_CENTER)
{
for (t_r = 0; t_r < t_rc; t_r++)
{
t_et = (int)_entityTypes[_nowStartRow+t_r];
if (t_et == ENTITY_TYPE_STRING)
{
t_str = (string)_entitys[t_r];
t_G.DrawString(t_str, PFont, t_BBrush, (NewWidth - t_G.MeasureString(t_str, PFont).Width + ENTITY_POS_TOLEFT) / 2,(_heightOfRow-ENTITY_POS_TOTOP) * t_r + _heightOfRow / 2);
}
else if (t_et == ENTITY_TYPE_IMAGE)
{
t_image = (System.Drawing.Image)_entitys[t_r];
t_G.DrawImage(t_image,(NewWidth-_heightOfRow+ENTITY_POS_TOLEFT)/2,(_heightOfRow-ENTITY_POS_TOTOP)*t_r,_heightOfRow,_heightOfRow);
}
else if (t_et == ENTITY_TYPE_IMAGEANDSTRING)
{
t_IS = (JPM_PushPanelBox_ImageAndString)_entitys[t_r];
t_str = t_IS._String;
t_image = t_IS._Image;
t_sizeF = t_G.MeasureString(t_IS._String, PFont);
t_et = _heightOfRow - (int)t_sizeF.Height-ENTITY_POS_TOLEFT;// A Temp Use
t_G.DrawImage(t_image, (NewWidth - t_et) / 2, _heightOfRow * t_r+ENTITY_POS_TOTOP, t_et, t_et);
t_G.DrawString(t_str, PFont, t_BBrush, (NewWidth - (int)t_sizeF.Width) / 2, _heightOfRow * t_r + t_et + ENTITY_POS_TOTOP);
}
}
}
else if (_entityMode == ENTITY_MODE_LEFT)
{
for (t_r = 0; t_r < t_rc; t_r++)
{
t_et = (int)_entityTypes[_nowStartRow + t_r];
if (t_et == ENTITY_TYPE_STRING)
{
t_str = (string)_entitys[t_r];
t_G.DrawString(t_str, PFont, t_BBrush, ENTITY_POS_TOLEFT , (_heightOfRow - ENTITY_POS_TOTOP) * t_r + _heightOfRow / 2);
}
else if (t_et == ENTITY_TYPE_IMAGE)
{
t_image = (System.Drawing.Image)_entitys[t_r];
t_G.DrawImage(t_image, ENTITY_POS_TOLEFT, (_heightOfRow - ENTITY_POS_TOTOP) * t_r, _heightOfRow, _heightOfRow);
}
else if (t_et == ENTITY_TYPE_IMAGEANDSTRING)
{
t_IS = (JPM_PushPanelBox_ImageAndString)_entitys[t_r];
t_str = t_IS._String;
t_image = t_IS._Image;
t_sizeF = t_G.MeasureString(t_IS._String, PFont);
t_et = _heightOfRow - (int)t_sizeF.Height - ENTITY_POS_TOLEFT;// A Temp Use
t_G.DrawImage(t_image, ENTITY_POS_TOLEFT, _heightOfRow * t_r + ENTITY_POS_TOTOP, t_et, t_et);
t_G.DrawString(t_str, PFont, t_BBrush, ENTITY_POS_TOLEFT, _heightOfRow * t_r + t_et + ENTITY_POS_TOTOP);
}
}
}
if (_entitys.Count > t_cOfDirRows)
{
int t_w,t_h;
t_w = NewWidth-15;
t_h = NewHeight-15;
if( _nowScrollY<15 )
{
_nowScrollY = 15;
}
else if( _nowScrollY>t_h-34 )
{
_nowScrollY = t_h-34;
}
_ifScroll = true;
t_G.DrawImage(t_imageSource, new Rectangle(t_w, 0, 15, 15), new Rectangle(1, 0, 15, 15), GraphicsUnit.Pixel);
t_G.DrawImage(t_imageSource, new Rectangle(t_w,t_h, 15, 15), new Rectangle(1, 15, 15, 15), GraphicsUnit.Pixel);
t_G.DrawImage(t_imageSource,new Rectangle(t_w,15,15,t_h-14),new Rectangle(1,0,15,1),GraphicsUnit.Pixel);
t_G.DrawImage(t_imageSource, new Rectangle(16, 0, 13, 34),new Rectangle(),GraphicsUnit.Pixel);
}
return t_bmpBuffer;
}
public bool OnMouseDown(int X,int Y)
{
if (_ifScroll == true && X > _width - 15)
{
if (Y < 15)
{
}
else if (Y > _height - 15)
{
}
else if (Y > _nowScrollY && Y < _nowScrollY + 34)
{
}
else
{
}
return true;
}
else
{
return true;
}
}
}
public class JPM_PushPanelBox : System.Windows.Forms.Control
{
}
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -