123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace ScreenSaverEf
- {
- public partial class MainForm : Form
- {
- readonly Image _imgSky = Properties.Resources.sky;
- readonly Image _imgDn = Properties.Resources.dn;
- readonly Image _imgC = Properties.Resources.st_kei10a02_;
- PointF _posSky;
- PointF _posDn;
- PointF _posSkyReset;
- PointF _posDnReset;
- PointF _posC = PointF.Empty;
- PointF _posCr;
-
- Rectangle _blkDn;
- #region POSC_DATA
- readonly float[] _cx = new float[] {
- -6,
- -5.5F,
- -5,
- -4,
- -3,
- -1.5F,
- 0,
- 1.5F,
- 3,
- 4,
- 5,
- 5.5F,
- 6,5.5F,5,4,3,1.5F,0,-1.5F,-3,-4,-5,-5.5F,
- };
- int _cxi = 6;
- readonly float[] _cy = new float[] {
- -6,
- -5,
- -3,
- 0,
- 3,
- 5,
- 6,5,3,0,-3,-5
- };
- int _cyi = 3;
- #endregion
- int? _scrNo;
- public MainForm()
- {
- InitializeComponent();
- }
- public MainForm(int scrNo)
- : this()
- {
- _scrNo = scrNo;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- var rect = _scrNo.HasValue ? Screen.AllScreens[_scrNo.Value].Bounds : Screen.PrimaryScreen.Bounds;
- var p = Location; p.Offset(rect.Location);
- Location = p;
- Size = rect.Size;
- FormBorderStyle = FormBorderStyle.None;
- TopMost = true;
- ResetPos();
- UpdateTimer.Start();
- }
- private void ResetPos()
- {
- _posSkyReset = _posSky = new PointF(-_imgSky.Width + Width, (Height - 600) / 2f);
- _posDnReset = _posDn = new PointF(-_imgDn.Width + Width, (Height - 600) / 2f);
- _posCr = new PointF(Width - _imgC.Width, (Height - 600) / 2f);
- _blkDn = new Rectangle(new Point(0, (int)_posSky.Y + _imgSky.Height), new Size(Width, (Height - 600) / 2));
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- _posSky.X += .5f;
- _posDn.X += 1.5f;
- _cxi++;
- if (_cxi % 2 == 0)
- _cyi++;
- if (_cxi > _cx.Length - 1) _cxi = 0;
- if (_cyi > _cy.Length - 1) _cyi = 0;
- _posC.X = _posCr.X + _cx[_cxi];
- _posC.Y = _posCr.Y + _cy[_cyi] - 14;
- Invalidate();
- }
- private void Form1_Paint(object sender, PaintEventArgs e)
- {
- var dc = e.Graphics;
- if (UpdateTimer.Enabled)
- {
- if (_posSky.X > 0 && _posSky.X <= Width)
- dc.DrawImage(_imgSky, new PointF(-_imgSky.Width + _posSky.X, _posSky.Y));
- if (_posSky.X > Width)
- _posSky.X = _posSkyReset.X;
- dc.DrawImage(_imgSky, _posSky);
- if (_posDn.X > 0 && _posDn.X <= Width)
- dc.DrawImage(_imgDn, new PointF(-_imgDn.Width + _posDn.X, _posDn.Y));
- if (_posDn.X > Width)
- _posDn.X = _posDnReset.X;
- dc.DrawImage(_imgDn, _posDn);
- dc.DrawImage(_imgC, _posC);
- dc.FillRectangle(Brushes.Black, _blkDn);
- }
- else
- {
- dc.DrawString("µã»÷¿ªÊ¼", new Font("΢ÈíÑźÚ", 20), Brushes.White, ClientSize.Width / 2f, ClientSize.Height / 2f);
- }
- }
- private void Form1_MouseClick(object sender, MouseEventArgs e)
- {
- if (UpdateTimer.Enabled)
- Application.Exit();
- else
- UpdateTimer.Start();
- }
- private void Form1_Resize(object sender, EventArgs e)
- {
- ResetPos();
- }
- private void Form1_KeyPress(object sender, KeyPressEventArgs e)
- {
- Application.Exit();
- }
- private void Form1_KeyDown(object sender, KeyEventArgs e)
- {
- Application.Exit();
- }
- private void Form1_KeyUp(object sender, KeyEventArgs e)
- {
- Application.Exit();
- }
- private void Form1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
- {
- Application.Exit();
- }
- }
- }
|