old_flsystem/FLSystem/Forms/plugin_control.cs

136 lines
3.7 KiB
C#
Raw Normal View History

2022-09-20 03:10:29 +00:00
using Api.Framework;
using Api.Framework.SDK;
using Api.Framework.Tools;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using UI.Framework.Forms;
namespace FLSystem.Forms
{
public partial class plugin_control : DevExpress.XtraEditors.XtraUserControl
{
private Plugin Plugin;
public plugin_control(Plugin plugin)
{
try
{
InitializeComponent();
this.Plugin = plugin;
}
catch (Exception ex)
{
if (!this.IsDisposed)
BaseForm.ShowError(ex);
}
}
public new void Refresh()
{
try
{
this.groupBox1.Text = this.Plugin.Name;
this.buttonCheck2.Checked = Plugin.IsRun;
this.pictureEdit1.Image = Plugin.IsRun ? Plugin.Logo : Util.ToGrey(Plugin.Logo);
this.ForeColor = Plugin.IsRun ? Color.Black : Color.Gray;
}
catch (Exception)
{ }
}
private void pictureEdit1_Properties_Click(object sender, EventArgs e)
{
try
{
if (Plugin.IsRun) Plugin.ShowForm();
}
catch (Exception ex)
{
if (!this.IsDisposed)
BaseForm.ShowError(ex);
}
}
private void buttonCheck1_Click(object sender, EventArgs e)
{
this.buttonCheck2.Enabled = false;
try
{
if (this.buttonCheck2.Checked)
PluginClient.Install(Plugin);
else
PluginClient.UnInstall(Plugin);
}
catch (Exception ex)
{
if (!this.IsDisposed)
BaseForm.ShowError(ex);
}
finally
{
this.buttonCheck2.Enabled = true;
}
this.Refresh();
}
private void plugin_control_Load(object sender, EventArgs e)
{
this.Refresh();
}
//重绘边框
private void Draw(Rectangle rectangle, Graphics g, int _radius)
{
//GraphicsPath gp = null;
//try
//{
// Pen shadowPen = new Pen(Color.Gray);
// gp = DrawRoundRect(rectangle.X, rectangle.Y, rectangle.Width - 2, rectangle.Height - 1, _radius);
// g.DrawPath(shadowPen, gp);
//}
//catch (Exception)
//{ }
//finally
//{
// if (gp != null)
// gp.Dispose();
//}
}
public GraphicsPath DrawRoundRect(int x, int y, int width, int height, int radius)
{
GraphicsPath gp = new GraphicsPath();
try
{
gp.AddArc(x, y, radius, radius, 180, 90);
gp.AddArc(width - radius, y, radius, radius, 270, 90);
gp.AddArc(width - radius, height - radius, radius, radius, 0, 90);
gp.AddArc(x, height - radius, radius, radius, 90, 90);
gp.CloseAllFigures();
}
catch (Exception)
{ }
return gp;
}
private void plugin_control_Paint(object sender, PaintEventArgs e)
{
Graphics g = null;
try
{
g = this.CreateGraphics();
Draw(this.ClientRectangle, g, 20);
}
catch (Exception)
{ }
finally
{
if (g != null)
g.Dispose();
}
}
}
}