modify UI
[marukotoolbox.git] / mp4box / SplashForm.cs
blobfc82466bf07221b39db7eada45e954de09265745
1 // ------------------------------------------------------------------
2 // Copyright (C) 2011-2015 Maruko Toolbox Project
3 //
4 // Authors: komaruchan <sandy_0308@hotmail.com>
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
15 // express or implied.
16 // See the License for the specific language governing permissions
17 // and limitations under the License.
18 // -------------------------------------------------------------------
21 using System;
22 using System.Collections.Generic;
23 using System.ComponentModel;
24 using System.Data;
25 using System.Drawing;
26 using System.Text;
27 using System.Windows.Forms;
28 using System.Drawing.Drawing2D;
30 namespace mp4box
32 using Extension;
33 public partial class SplashForm : Form
35 public static class ClassStyles
37 public static readonly Int32
38 CS_BYTEALIGNCLIENT = 0x1000,
39 CS_BYTEALIGNWINDOW = 0x2000,
40 CS_CLASSDC = 0x0040,
41 CS_DBLCLKS = 0x0008,
42 CS_DROPSHADOW = 0x00020000,
43 CS_GLOBALCLASS = 0x4000,
44 CS_HREDRAW = 0x0002,
45 CS_NOCLOSE = 0x0200,
46 CS_OWNDC = 0x0020,
47 CS_PARENTDC = 0x0080,
48 CS_SAVEBITS = 0x0800,
49 CS_VREDRAW = 0x0001;
52 protected override CreateParams CreateParams
54 get
56 CreateParams cp = base.CreateParams;
57 cp.ClassStyle |= ClassStyles.CS_DROPSHADOW;
58 return cp;
62 //int iCount = 0;
63 public SplashForm()
65 InitializeComponent();
66 //去掉外框
67 this.FormBorderStyle = FormBorderStyle.None;
68 //屏幕中央
69 this.StartPosition = FormStartPosition.CenterScreen;
70 this.Opacity = 0.1;
73 private void SplashForm_Load(object sender, EventArgs e)
75 ArtTextLabel TitleLabel = new ArtTextLabel();
76 TitleLabel.AutoSize = true;
77 TitleLabel.Font = new Font("微软雅黑", 21.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134)));
78 TitleLabel.ForeColor = Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(241)))), ((int)(((byte)(191)))));
79 TitleLabel.BackColor = Color.Transparent;
80 TitleLabel.Location = new Point(300, 110);
81 TitleLabel.Name = "TitleLabel";
82 TitleLabel.Size = new Size(208, 29);
83 TitleLabel.TabIndex = 2;
84 TitleLabel.Text = "小丸工具箱";
85 TitleLabel.Parent = pictureBox;
87 LuneartTextLabel.Parent = pictureBox;
90 private void timer_Tick(object sender, EventArgs e)
92 this.InvokeIfRequired(() =>
93 this.Opacity += 0.1);
95 //if (iCount > 800)
96 //{
97 // //启动动画完了之后..
98 // this.Close();
99 // return;
101 //iCount += 10;
102 ////窗体透明度减小
103 //this.Opacity = 1 - Convert.ToDouble(iCount) / 1000;
106 private void SplashForm_Paint(object sender, PaintEventArgs e)
108 List<Point> list = new List<Point>();
109 int width = this.Width;
110 int height = this.Height;
111 #region 四个圆角
113 //左上
114 list.Add(new Point(0, 5));
115 list.Add(new Point(1, 5));
116 list.Add(new Point(1, 3));
117 list.Add(new Point(2, 3));
118 list.Add(new Point(2, 2));
119 list.Add(new Point(3, 2));
120 list.Add(new Point(3, 1));
121 list.Add(new Point(5, 1));
122 list.Add(new Point(5, 0));
123 //右上
124 list.Add(new Point(width - 5, 0));
125 list.Add(new Point(width - 5, 1));
126 list.Add(new Point(width - 3, 1));
127 list.Add(new Point(width - 3, 2));
128 list.Add(new Point(width - 2, 2));
129 list.Add(new Point(width - 2, 3));
130 list.Add(new Point(width - 1, 3));
131 list.Add(new Point(width - 1, 5));
132 list.Add(new Point(width - 0, 5));
133 //右下
134 list.Add(new Point(width - 0, height - 5));
135 list.Add(new Point(width - 1, height - 5));
136 list.Add(new Point(width - 1, height - 3));
137 list.Add(new Point(width - 2, height - 3));
138 list.Add(new Point(width - 2, height - 2));
139 list.Add(new Point(width - 3, height - 2));
140 list.Add(new Point(width - 3, height - 1));
141 list.Add(new Point(width - 5, height - 1));
142 list.Add(new Point(width - 5, height - 0));
143 //左下
144 list.Add(new Point(5, height - 0));
145 list.Add(new Point(5, height - 1));
146 list.Add(new Point(3, height - 1));
147 list.Add(new Point(3, height - 2));
148 list.Add(new Point(2, height - 2));
149 list.Add(new Point(2, height - 3));
150 list.Add(new Point(1, height - 3));
151 list.Add(new Point(1, height - 5));
152 list.Add(new Point(0, height - 5));
153 #endregion
154 Point[] points = list.ToArray();
155 GraphicsPath shape = new GraphicsPath();
156 shape.AddPolygon(points);
157 this.Region = new System.Drawing.Region(shape);
160 private void pictureBox_DoubleClick(object sender, EventArgs e)
162 if (this.Owner != null)
163 this.Close();
166 private void Type(Control sender, int p_1, double p_2)
168 GraphicsPath oPath = new GraphicsPath();
169 oPath.AddClosedCurve(
170 new Point[] {
171 new Point(0, sender.Height / p_1),
172 new Point(sender.Width / p_1, 0),
173 new Point(sender.Width - sender.Width / p_1, 0),
174 new Point(sender.Width, sender.Height / p_1),
175 new Point(sender.Width, sender.Height - sender.Height / p_1),
176 new Point(sender.Width - sender.Width / p_1, sender.Height),
177 new Point(sender.Width / p_1, sender.Height),
178 new Point(0, sender.Height - sender.Height / p_1) },
180 (float)p_2);
182 sender.Region = new Region(oPath);
188 class ArtTextLabel : Label
190 int _borderSize = 3;
191 Color _borderColor = Color.Gray;
192 protected override void OnPaint(PaintEventArgs pe)
194 base.OnPaint(pe);
195 PointF pt = new PointF(0, 0);
196 RenderRelievoText(pe.Graphics, pt);
200 //边框
201 private void RenderBordText(Graphics g, PointF point)
203 using (Brush brush = new SolidBrush(_borderColor))
205 for (int i = 1; i <= _borderSize; i++)
207 g.DrawString(
208 base.Text,
209 base.Font,
210 brush,
211 point.X - i,
212 point.Y);
213 g.DrawString(
214 base.Text,
215 base.Font,
216 brush,
217 point.X,
218 point.Y - i);
219 g.DrawString(
220 base.Text,
221 base.Font,
222 brush,
223 point.X + i,
224 point.Y);
225 g.DrawString(
226 base.Text,
227 base.Font,
228 brush,
229 point.X,
230 point.Y + i);
233 using (Brush brush = new SolidBrush(base.ForeColor))
235 g.DrawString(
236 base.Text, base.Font, brush, point);
240 //印版
241 private void RenderFormeText(Graphics g, PointF point)
243 using (Brush brush = new SolidBrush(_borderColor))
245 for (int i = 1; i <= _borderSize; i++)
247 g.DrawString(
248 base.Text,
249 base.Font,
250 brush,
251 point.X - i,
252 point.Y + i);
255 using (Brush brush = new SolidBrush(base.ForeColor))
257 g.DrawString(
258 base.Text, base.Font, brush, point);
263 //浮雕。
264 private void RenderRelievoText(Graphics g, PointF point)
266 using (Brush brush = new SolidBrush(_borderColor))
268 for (int i = 1; i <= _borderSize; i++)
270 g.DrawString(
271 base.Text,
272 base.Font,
273 brush,
274 point.X + i,
275 point.Y);
276 g.DrawString(
277 base.Text,
278 base.Font,
279 brush,
280 point.X,
281 point.Y + i);
284 using (Brush brush = new SolidBrush(base.ForeColor))
286 g.DrawString(
287 base.Text, base.Font, brush, point);