56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
|
|
using MGdu.WinFormUI;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
|
|||
|
|
namespace RySkins
|
|||
|
|
{
|
|||
|
|
public partial class SKinForm : GMForm
|
|||
|
|
{
|
|||
|
|
public SKinForm()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
public SKinForm(string[] args)
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 显示在父窗体中间,如果没有父窗体,则显示在显示器中间
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="parent"></param>
|
|||
|
|
public void ShowInCenter(Form parent)
|
|||
|
|
{
|
|||
|
|
this.StartPosition = FormStartPosition.Manual;
|
|||
|
|
var screen = Screen.FromControl(this);
|
|||
|
|
if (parent==null) //如果没有父窗体,则显示在显示器中间
|
|||
|
|
{
|
|||
|
|
Location = new Point((screen.WorkingArea.Width-Width)/2,(screen.WorkingArea.Height-Height)/2);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var x = parent.Left+(parent.Width - Width) / 2;
|
|||
|
|
var y =parent.Top+ (parent.Height - Height) / 2;
|
|||
|
|
if((x+Width)> screen.WorkingArea.X+ screen.WorkingArea.Width)
|
|||
|
|
{
|
|||
|
|
x = screen.WorkingArea.X + screen.WorkingArea.Width - Width;
|
|||
|
|
}
|
|||
|
|
if ((y + Height) > screen.WorkingArea.Y + screen.WorkingArea.Height)
|
|||
|
|
{
|
|||
|
|
y = screen.WorkingArea.Y + screen.WorkingArea.Height - Height;
|
|||
|
|
}
|
|||
|
|
Location = new Point(x, y);
|
|||
|
|
}
|
|||
|
|
private void SKinForm_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!this.DesignMode)
|
|||
|
|
{ base.XTheme = new ThemeForm(); }
|
|||
|
|
//Opacity = 0.97;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|