195 lines
6.9 KiB
C#
195 lines
6.9 KiB
C#
using System;
|
||
using System.Drawing;
|
||
using System.Runtime.InteropServices;
|
||
using System.Windows.Forms;
|
||
using Tech_Demo.Presenter;
|
||
using Tech_Demo.View;
|
||
|
||
namespace Tech_Demo.View.Impl
|
||
{
|
||
public partial class MainView : Form, IMainView
|
||
{
|
||
public MainPresenter Presenter { private get; set; }
|
||
|
||
[DllImport("user32")]
|
||
private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
|
||
|
||
public const Int32 AW_HOR_POSITIVE = 0x00000001; // 从左到右打开窗口
|
||
public const Int32 AW_HOR_NEGATIVE = 0x00000002; // 从右到左打开窗口
|
||
public const Int32 AW_VER_POSITIVE = 0x00000004; // 从上到下打开窗口
|
||
public const Int32 AW_VER_NEGATIVE = 0x00000008; // 从下到上打开窗口
|
||
public const Int32 AW_CENTER = 0x00000010; //若使用了AW_HIDE标志,则使窗口向内重叠;若未使用AW_HIDE标志,则使窗口向外扩展。
|
||
public const Int32 AW_HIDE = 0x00010000; //隐藏窗口,缺省则显示窗口。
|
||
public const Int32 AW_ACTIVATE = 0x00020000; //激活窗口。在使用了AW_HIDE标志后不要使用这个标志。
|
||
public const Int32 AW_SLIDE = 0x00040000; //使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略。
|
||
public const Int32 AW_BLEND = 0x00080000; //使用淡出效果。只有当hWnd为顶层窗口的时候才可以使用此标志。
|
||
|
||
public MainView()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void Form1_Load(object sender, EventArgs e)
|
||
{
|
||
panelContainer.Controls.Clear();
|
||
var playerView = new PlayerView();
|
||
playerView.Presenter = new PlayerPresenter(playerView);
|
||
playerView.Dock = DockStyle.Fill;
|
||
panelContainer.Controls.Add(playerView);
|
||
// AnimateWindow(playerView.Handle, 1000, AW_HOR_POSITIVE | AW_SLIDE);
|
||
// UCOverview uo = new UCOverview();
|
||
// uo.Dock = DockStyle.Fill;
|
||
// panelContainer.Controls.Add(uo);
|
||
}
|
||
|
||
private void button3_Click(object sender, EventArgs e)
|
||
{
|
||
throw new System.NotImplementedException();
|
||
}
|
||
|
||
private void button4_Click(object sender, EventArgs e)
|
||
{
|
||
// DialogResult dialogResult =
|
||
// MessageBox.Show(@"确定要退出吗?", @"确定退出?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||
// if (dialogResult.Equals(DialogResult.OK))
|
||
// {
|
||
// System.Environment.Exit(0);
|
||
// // Application.Exit();
|
||
// }
|
||
Boolean exist = false;
|
||
Panel settingView = null;
|
||
foreach (Control panelContainerControl in panelContainer.Controls)
|
||
{
|
||
Console.WriteLine(panelContainerControl.Name);
|
||
// 存在设置
|
||
if(panelContainerControl.Name.Equals("settings"))
|
||
{
|
||
exist = true;
|
||
settingView = (Panel) panelContainerControl;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (exist == false)
|
||
{
|
||
var panel = new Panel();
|
||
panel.Size = new System.Drawing.Size(300, 670);
|
||
panel.BackColor = Color.White;
|
||
panel.Dock = DockStyle.Left;
|
||
panel.Name = "settings";
|
||
AnimateWindow(panel.Handle, 1000, AW_BLEND);
|
||
panelContainer.Controls.Add(panel);
|
||
}
|
||
else
|
||
{
|
||
// 销毁
|
||
settingView.Dispose();
|
||
}
|
||
|
||
}
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
var playerView = new PlayerView();
|
||
playerView.Dock = DockStyle.Fill;
|
||
foreach (Control container in this.panelContainer.Controls)
|
||
{
|
||
container.Dispose();
|
||
}
|
||
|
||
this.panelContainer.Controls.Clear();
|
||
this.panelContainer.Controls.Add(playerView);
|
||
}
|
||
|
||
private void panel2_Paint(object sender, PaintEventArgs e)
|
||
{
|
||
// throw new System.NotImplementedException();
|
||
}
|
||
|
||
private void pictureBox2_Click(object sender, EventArgs e)
|
||
{
|
||
DialogResult dialogResult =
|
||
MessageBox.Show(@"确定要退出吗?", @"确定退出?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||
if (dialogResult.Equals(DialogResult.OK))
|
||
{
|
||
System.Environment.Exit(0);
|
||
// Application.Exit();
|
||
}
|
||
}
|
||
|
||
private void pictureBox2_MouseHover(object sender, EventArgs e)
|
||
{
|
||
}
|
||
|
||
private void closeBtn_MouseHover(object sender, EventArgs e)
|
||
{
|
||
closeBtn.BackColor = Color.Crimson;
|
||
}
|
||
|
||
private void closeBtn_MouseLeave(object sender, EventArgs e)
|
||
{
|
||
closeBtn.BackColor = Color.FromArgb(0, 110, 255);
|
||
}
|
||
|
||
[DllImport("user32.dll")]
|
||
public static extern bool ReleaseCapture();
|
||
|
||
[DllImport("user32.dll")]
|
||
private static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
|
||
|
||
private const int WM_SYSCOMMAND = 0x0112;
|
||
private const int SC_MOVE = 0xF010;
|
||
private const int HTCAPTION = 0x0002;
|
||
|
||
private void TopPanel_MouseDown(object sender, MouseEventArgs e)
|
||
{
|
||
ReleaseCapture();
|
||
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
|
||
}
|
||
|
||
private void pictureBox3_Click(object sender, EventArgs e)
|
||
{
|
||
this.WindowState = this.WindowState == FormWindowState.Maximized
|
||
? FormWindowState.Normal
|
||
: FormWindowState.Maximized;
|
||
this.panelContainer.Refresh();
|
||
}
|
||
|
||
private void pictureBox4_Click(object sender, EventArgs e)
|
||
{
|
||
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
|
||
}
|
||
|
||
private void closeBtn_MouseMove(object sender, MouseEventArgs e)
|
||
{
|
||
closeBtn.BackColor = Color.Crimson;
|
||
}
|
||
|
||
private void pictureBox3_MouseMove(object sender, MouseEventArgs e)
|
||
{
|
||
pictureBox3.BackColor = Color.FromArgb(0, 98, 229);
|
||
}
|
||
|
||
|
||
private void pictureBox4_MouseMove(object sender, MouseEventArgs e)
|
||
{
|
||
pictureBox4.BackColor = Color.FromArgb(0, 98, 229);
|
||
}
|
||
|
||
private void pictureBox3_MouseLeave(object sender, EventArgs e)
|
||
{
|
||
pictureBox3.BackColor = Color.FromArgb(0, 110, 255);
|
||
}
|
||
|
||
|
||
private void pictureBox4_MouseLeave(object sender, EventArgs e)
|
||
{
|
||
pictureBox4.BackColor = Color.FromArgb(0, 110, 255);;
|
||
}
|
||
|
||
private void panelContainer_Paint(object sender, PaintEventArgs e)
|
||
{
|
||
// throw new System.NotImplementedException();
|
||
}
|
||
}
|
||
} |