1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Tiền sử lý trong C# pptx

6 435 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Tiền sử lý trong C#
Trường học Unknown University
Chuyên ngành C# Programming
Thể loại Tài liệu
Năm xuất bản 2023
Thành phố Unknown
Định dạng
Số trang 6
Dung lượng 36 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Trang 1

Tiền sử lý trong C#

Chào các bác

Em có đoạn code sau em không hiểu cái từ #region cho lắm

bác nào có thể giả thích rõ hơn cho được không

nếu có tài liều hướng dẫn về cái này Port cho xin ,cái này ít thấy sách nào viết

using System;

using System.Collections.Generic;

using System.Text;

using System.Drawing.Drawing2D;

using System.Drawing;

using System.Windows.Forms;

namespace RibbonStyle

{

publicclassTabPanel : System.Windows.Forms.Panel

{

public TabPanel()

{

timer1.Interval = 1;

timer1.Tick += newEventHandler(timer1_Tick);

this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

}

int X0;

int XF;

int Y0;

int YF;

int T = 8;

int i_Zero = 180;

int i_Sweep = 90;

int X; int Y;

GraphicsPath path;

int D = -1;

int R0 = 215;

int G0 = 227;

int B0 = 242;

Color _BaseColor = Color.FromArgb(215, 227, 242);

Color _BaseColorOn = Color.FromArgb(215, 227, 242);

int i_mode = 0; //0 Entering, 1 Leaving

int i_factor = 1;

int i_fR = 1; int i_fG = 1; int i_fB = 1;

int i_Op = 255;

string S_TXT = "";

publicColor BaseColor

{

get

{

return _BaseColor;

}

set

{

_BaseColor = value;

R0 = _BaseColor.R;

B0 = _BaseColor.B;

Trang 2

G0 = _BaseColor.G;

}

}

publicColor BaseColorOn

{

get

{

return _BaseColorOn;

}

set

{

_BaseColorOn = value;

R0 = _BaseColor.R;

B0 = _BaseColor.B;

G0 = _BaseColor.G;

}

}

publicstring Caption

{

get

{

return S_TXT;

}

set

{

S_TXT = value;

this.Refresh();

}

}

publicint Speed

{

get

{

return i_factor;

}

set

{

i_factor = value;

}

}

publicint Opacity

{

get

{

return i_Op;

}

set

{

if value < 256 | value > -1)

{ i_Op = value; }

}

}

protectedoverridevoid OnPaint(System.Windows.Forms.PaintEventArgs e) {

Trang 3

X0 = 0; XF = this.Width + X0 - 3;

Y0 = 0; YF = this.Height + Y0 - 3;

Point P0 = newPoint(X0, Y0);

Point PF = newPoint(X0, Y0 + YF);

Pen b1 = newPen(Color.FromArgb(i_Op, R0 - 18, G0 - 17, B0 - 19));

Pen b2 = newPen(Color.FromArgb(i_Op, R0 - 39, G0 - 24, B0 - 3));

Pen b3 = newPen(Color.FromArgb(i_Op, R0 + 11, G0 + 9, B0 + 3));

Pen b4 = newPen(Color.FromArgb(i_Op, R0 - 8, G0 - 4, B0 - 2));

Pen b5 = newPen(Color.FromArgb(i_Op, R0, G0, B0));

Pen b6 = newPen(Color.FromArgb(i_Op, R0 - 16, G0 - 11, B0 - 5));

Pen b8 = newPen(Color.FromArgb(i_Op, R0 + 1, G0 + +5, B0 + 3));

Pen b7 = newPen(Color.FromArgb(i_Op, R0 - 22, G0 - 10, B0));

T = 1;

DrawArc3(0, 20);

e.Graphics.PageUnit = GraphicsUnit.Pixel;

Brush B4 = b4.Brush;

e.Graphics.SmoothingMode = SmoothingMode.None;

X = X0; Y = Y0; i_Zero = 180; D = 0;

e.Graphics.FillPath(b5.Brush, path);

LinearGradientBrush brocha = newLinearGradientBrush(P0, PF, b6.Color, b8.Color); DrawArc2(15, YF - 20);

e.Graphics.FillPath(brocha, path);

DrawArc2(YF - 16, 12);

Pen bdown = newPen(Color.FromArgb(i_Op, R0 - 22, G0 - 11, B0));

e.Graphics.FillPath(bdown.Brush, path);

T = 6;

DrawArc();

DrawArc();

e.Graphics.DrawPath(b2, path);

DrawArc();

e.Graphics.DrawPath(b3, path);

Point P_EX = Cursor.Position;

P_EX = this.PointToClient(P_EX);

int ix = 10 + this.Width / 2 - S_TXT.Length * (int)this.Font.Size / 2;

PointF P_TXT = newPointF(ix, this.Height - 20);

Pen pen = newPen(this.ForeColor);

e.Graphics.DrawString(S_TXT, this.Font, pen.Brush, P_TXT);

base.OnPaint(e);

}

protectedoverridevoid OnMouseEnter(EventArgs e)

{

Point P_EX = Cursor.Position;

P_EX = this.PointToClient(P_EX);

if (P_EX.X > 0 | P_EX.X < this.Width | P_EX.Y > 0 | P_EX.Y < this.Height)

{

i_mode = 0;

timer1.Start();

}

base.OnMouseEnter(e);

}

protectedoverridevoid OnMouseLeave(EventArgs e)

{

Trang 4

Point P_EX = Cursor.Position;

P_EX = this.PointToClient(P_EX);

if (P_EX.X < 0 | P_EX.X >= this.Width | P_EX.Y < 0 | P_EX.Y >= this.Height) {

i_mode = 1;

timer1.Start();

}

base.OnMouseLeave(e);

}

publicvoid DrawArc()

{

X = X0; Y = Y0; i_Zero = 180; D++;

path = newGraphicsPath();

path.AddArc(X + D, Y + D, T, T, i_Zero, i_Sweep); i_Zero += 90; X += XF - 6; path.AddArc(X - D, Y + D, T, T, i_Zero, i_Sweep); i_Zero += 90; Y += YF - 6; path.AddArc(X - D, Y - D, T, T, i_Zero, i_Sweep); i_Zero += 90; X -= XF - 6; path.AddArc(X + D, Y - D, T, T, i_Zero, i_Sweep); i_Zero += 90; Y -= YF - 6; path.AddArc(X + D, Y + D, T, T, i_Zero, i_Sweep);

}

publicvoid DrawArc2(int OF_Y, int SW_Y)

{

X = X0 + 4; Y = Y0 + OF_Y; i_Zero = 180;

path = newGraphicsPath();

path.AddArc(X + D, Y + D, T, T, i_Zero, i_Sweep); i_Zero += 90; X += XF - 8; path.AddArc(X - D, Y + D, T, T, i_Zero, i_Sweep); i_Zero += 90; Y += SW_Y; path.AddArc(X - D, Y - D, T, T, i_Zero, i_Sweep); i_Zero += 90; X -= XF - 8; path.AddArc(X + D, Y - D, T, T, i_Zero, i_Sweep); i_Zero += 90; Y -= SW_Y; path.AddArc(X + D, Y + D, T, T, i_Zero, i_Sweep);

}

publicvoid DrawArc3(int OF_Y, int SW_Y)

{

X = X0; Y = Y0 + OF_Y; i_Zero = 180;

path = newGraphicsPath();

path.AddArc(X + D, Y + D, T, T, i_Zero, i_Sweep); i_Zero += 90; X += XF; path.AddArc(X - D, Y + D, T, T, i_Zero, i_Sweep); i_Zero += 90; Y += SW_Y; path.AddArc(X - D, Y - D, T, T, i_Zero, i_Sweep); i_Zero += 90; X -= XF; path.AddArc(X + D, Y - D, T, T, i_Zero, i_Sweep); i_Zero += 90; Y -= SW_Y; path.AddArc(X + D, Y + D, T, T, i_Zero, i_Sweep);

}

privateTimer timer1 = newTimer();

void timer1_Tick(object sender, EventArgs e)

{

#region Entering

if (i_mode == 0)

{

if (System.Math.Abs(_BaseColorOn.R - R0) > i_factor)

{ i_fR = i_factor; }

else { i_fR = 1; }

if (System.Math.Abs(_BaseColorOn.G - G0) > i_factor)

{ i_fG = i_factor; }

else { i_fG = 1; }

if (System.Math.Abs(_BaseColorOn.B - B0) > i_factor)

{ i_fB = i_factor; }

else { i_fB = 1; }

if (_BaseColorOn.R < R0)

{

Trang 5

R0 -= i_fR;

}

elseif (_BaseColorOn.R > R0)

{

R0 += i_fR;

}

if (_BaseColorOn.G < G0)

{

G0 -= i_fG;

}

elseif (_BaseColorOn.G > G0)

{

G0 += i_fG;

}

if (_BaseColorOn.B < B0)

{

B0 -= i_fB;

}

elseif (_BaseColorOn.B > B0)

{

B0 += i_fB;

}

if (_BaseColorOn == Color.FromArgb(R0, G0, B0)) {

timer1.Stop();

}

else

{

this.Refresh();

}

}

#endregion

#region Leaving

if (i_mode == 1)

{

if (System.Math.Abs(_BaseColor.R - R0) < i_factor) { i_fR = 1; }

else { i_fR = i_factor; }

if (System.Math.Abs(_BaseColor.G - G0) < i_factor) { i_fG = 1; }

else { i_fG = i_factor; }

if (System.Math.Abs(_BaseColor.B - B0) < i_factor) { i_fB = 1; }

else { i_fB = i_factor; }

if (_BaseColor.R < R0)

{

R0 -= i_fR;

}

elseif (_BaseColor.R > R0)

{

R0 += i_fR;

}

if (_BaseColor.G < G0)

{

G0 -= i_fG;

}

Trang 6

elseif (_BaseColor.G > G0)

{

G0 += i_fG;

}

if (_BaseColor.B < B0)

{

B0 -= i_fB;

}

elseif (_BaseColor.B > B0)

{

B0 += i_fB;

}

if (_BaseColor == Color.FromArgb(R0, G0, B0)) {

timer1.Stop();

}

else

{

this.Refresh();

}

}

#endregion

}

protectedoverridevoid OnResize(EventArgs eventargs) {

this.Refresh();

base.OnResize(eventargs);

}

}

}

Ngày đăng: 12/12/2013, 19:16

TỪ KHÓA LIÊN QUAN

w