UIBarChartEx:增加一种紧凑型的显示方式
This commit is contained in:
parent
c1855fed6c
commit
cc0df55012
Binary file not shown.
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
18
SunnyUI.Demo/Charts/FBarChartEx.Designer.cs
generated
18
SunnyUI.Demo/Charts/FBarChartEx.Designer.cs
generated
@ -34,6 +34,7 @@
|
||||
this.uiImageButton1 = new Sunny.UI.UIImageButton();
|
||||
this.uiLine1 = new Sunny.UI.UILine();
|
||||
this.BarChart = new Sunny.UI.UIBarChartEx();
|
||||
this.uiSymbolButton2 = new Sunny.UI.UISymbolButton();
|
||||
this.PagePanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.uiImageButton3)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.uiImageButton2)).BeginInit();
|
||||
@ -42,6 +43,7 @@
|
||||
//
|
||||
// PagePanel
|
||||
//
|
||||
this.PagePanel.Controls.Add(this.uiSymbolButton2);
|
||||
this.PagePanel.Controls.Add(this.uiSymbolButton1);
|
||||
this.PagePanel.Controls.Add(this.uiImageButton3);
|
||||
this.PagePanel.Controls.Add(this.uiImageButton2);
|
||||
@ -59,7 +61,7 @@
|
||||
this.uiSymbolButton1.Name = "uiSymbolButton1";
|
||||
this.uiSymbolButton1.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
|
||||
this.uiSymbolButton1.Size = new System.Drawing.Size(100, 27);
|
||||
this.uiSymbolButton1.Symbol = 61952;
|
||||
this.uiSymbolButton1.Symbol = 61568;
|
||||
this.uiSymbolButton1.TabIndex = 34;
|
||||
this.uiSymbolButton1.Text = "数据";
|
||||
this.uiSymbolButton1.Click += new System.EventHandler(this.uiSymbolButton1_Click);
|
||||
@ -129,6 +131,19 @@
|
||||
this.BarChart.TabIndex = 35;
|
||||
this.BarChart.Text = "uiBarChartEx1";
|
||||
//
|
||||
// uiSymbolButton2
|
||||
//
|
||||
this.uiSymbolButton2.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.uiSymbolButton2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiSymbolButton2.Location = new System.Drawing.Point(456, 466);
|
||||
this.uiSymbolButton2.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiSymbolButton2.Name = "uiSymbolButton2";
|
||||
this.uiSymbolButton2.Size = new System.Drawing.Size(100, 27);
|
||||
this.uiSymbolButton2.Symbol = 61568;
|
||||
this.uiSymbolButton2.TabIndex = 36;
|
||||
this.uiSymbolButton2.Text = "数据";
|
||||
this.uiSymbolButton2.Click += new System.EventHandler(this.uiSymbolButton2_Click);
|
||||
//
|
||||
// FBarChartEx
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
||||
@ -153,5 +168,6 @@
|
||||
private UIImageButton uiImageButton1;
|
||||
private UILine uiLine1;
|
||||
private UIBarChartEx BarChart;
|
||||
private UISymbolButton uiSymbolButton2;
|
||||
}
|
||||
}
|
@ -92,5 +92,61 @@ namespace Sunny.UI.Demo
|
||||
option.ToolTip.AxisPointer.Type = UIAxisPointerType.Shadow;
|
||||
BarChart.SetOption(option);
|
||||
}
|
||||
|
||||
private void uiSymbolButton2_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
UIBarOption option = new UIBarOption();
|
||||
option.Title = new UITitle();
|
||||
option.Title.Text = "SunnyUI";
|
||||
option.Title.SubText = "BarChartEx";
|
||||
|
||||
//设置Legend
|
||||
option.Legend = new UILegend();
|
||||
option.Legend.Orient = UIOrient.Horizontal;
|
||||
option.Legend.Top = UITopAlignment.Top;
|
||||
option.Legend.Left = UILeftAlignment.Left;
|
||||
option.Legend.AddData("Bar1");
|
||||
option.Legend.AddData("Bar2");
|
||||
option.Legend.AddData("Bar3");
|
||||
|
||||
var series = new UIBarSeries();
|
||||
series.ShowValue = true;
|
||||
series.ShowValueFontSize = 6f;
|
||||
series.MaxWidth = 22;
|
||||
series.Name = "Bar1";
|
||||
series.AddData(1);
|
||||
option.Series.Add(series);
|
||||
|
||||
series = new UIBarSeries();
|
||||
series.ShowValue = true;
|
||||
series.ShowValueFontSize = 10.5f;
|
||||
series.MaxWidth = 22;
|
||||
series.Name = "Bar2";
|
||||
series.AddData(2);
|
||||
series.AddData(3);
|
||||
option.Series.Add(series);
|
||||
|
||||
series = new UIBarSeries();
|
||||
series.ShowValue = true;
|
||||
series.ShowValueFontSize = 16f;
|
||||
series.MaxWidth = 22;
|
||||
series.Name = "Bar3";
|
||||
series.AddData(4);
|
||||
series.AddData(5);
|
||||
series.AddData(6);
|
||||
option.Series.Add(series);
|
||||
|
||||
option.XAxis.Data.Add("Mon");
|
||||
option.XAxis.Data.Add("Tue");
|
||||
option.XAxis.Data.Add("Wed");
|
||||
option.XAxis.Data.Add("Thu");
|
||||
option.XAxis.Data.Add("Fri");
|
||||
|
||||
option.ToolTip = new UIBarToolTip();
|
||||
option.ToolTip.AxisPointer.Type = UIAxisPointerType.Shadow;
|
||||
option.AutoSizeBarsCompact = true;
|
||||
option.AutoSizeBarsCompactValue = 0.1f;
|
||||
BarChart.SetOption(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
7
SunnyUI.Demo/Controls/FNavigation.Designer.cs
generated
7
SunnyUI.Demo/Controls/FNavigation.Designer.cs
generated
@ -197,10 +197,11 @@
|
||||
//
|
||||
// uiNavMenu1
|
||||
//
|
||||
this.uiNavMenu1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
|
||||
this.uiNavMenu1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.uiNavMenu1.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll;
|
||||
this.uiNavMenu1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiNavMenu1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
|
||||
this.uiNavMenu1.FullRowSelect = true;
|
||||
this.uiNavMenu1.ItemHeight = 50;
|
||||
this.uiNavMenu1.Location = new System.Drawing.Point(30, 157);
|
||||
this.uiNavMenu1.Name = "uiNavMenu1";
|
||||
@ -261,7 +262,9 @@
|
||||
treeNode40,
|
||||
treeNode41,
|
||||
treeNode42});
|
||||
this.uiNavMenu1.ShowLines = false;
|
||||
this.uiNavMenu1.Size = new System.Drawing.Size(253, 353);
|
||||
this.uiNavMenu1.Style = Sunny.UI.UIStyle.Custom;
|
||||
this.uiNavMenu1.TabIndex = 1;
|
||||
this.uiNavMenu1.MenuItemClick += new Sunny.UI.UINavMenu.OnMenuItemClick(this.uiNavMenu1_MenuItemClick);
|
||||
//
|
||||
@ -273,6 +276,7 @@
|
||||
this.uiNavMenu2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250)))));
|
||||
this.uiNavMenu2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiNavMenu2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
this.uiNavMenu2.FullRowSelect = true;
|
||||
this.uiNavMenu2.HoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
|
||||
this.uiNavMenu2.ItemHeight = 50;
|
||||
this.uiNavMenu2.Location = new System.Drawing.Point(299, 157);
|
||||
@ -336,6 +340,7 @@
|
||||
treeNode20,
|
||||
treeNode21});
|
||||
this.uiNavMenu2.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
|
||||
this.uiNavMenu2.ShowLines = false;
|
||||
this.uiNavMenu2.Size = new System.Drawing.Size(253, 353);
|
||||
this.uiNavMenu2.TabIndex = 2;
|
||||
//
|
||||
|
@ -89,11 +89,13 @@ namespace Sunny.UI
|
||||
|
||||
if (Option.AutoSizeBars)
|
||||
{
|
||||
//每个柱子等宽
|
||||
float x1 = DrawSize.Width * 1.0f / DataCount / 4;
|
||||
float x2 = x1 * 2;
|
||||
|
||||
if (Option.AutoSizeBarsCompact)
|
||||
{
|
||||
//紧凑
|
||||
for (int i = 0; i < Option.SeriesCount; i++)
|
||||
{
|
||||
var series = Option.Series[i];
|
||||
@ -171,6 +173,7 @@ namespace Sunny.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
//宽松
|
||||
for (int i = 0; i < Option.SeriesCount; i++)
|
||||
{
|
||||
var series = Option.Series[i];
|
||||
@ -247,89 +250,178 @@ namespace Sunny.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Option.SeriesCount; i++)
|
||||
//每个序列等宽
|
||||
if (Option.AutoSizeBarsCompact)
|
||||
{
|
||||
var series = Option.Series[i];
|
||||
float x1;
|
||||
if (Option.FixedSeriesCount > 0)
|
||||
x1 = DrawBarWidth / (Option.FixedSeriesCount * 2 + Option.FixedSeriesCount + 1);
|
||||
else
|
||||
x1 = DrawBarWidth / (series.Data.Count * 2 + series.Data.Count + 1);
|
||||
//紧凑
|
||||
|
||||
float x2 = x1 * 2;
|
||||
float CompactWidth = DrawBarWidth / 4.0f * Option.AutoSizeBarsCompactValue;
|
||||
|
||||
Bars.TryAdd(i, new List<BarInfo>());
|
||||
for (int j = 0; j < series.Data.Count; j++)
|
||||
for (int i = 0; i < Option.SeriesCount; i++)
|
||||
{
|
||||
Color color = ChartStyle.GetColor(i);
|
||||
if (series.Colors.Count > 0 && j >= 0 && j < series.Colors.Count)
|
||||
color = series.Colors[j];
|
||||
|
||||
float xx;
|
||||
if (Option.FixedSeriesCount > 0)
|
||||
xx = barX + DrawBarWidth / (series.Data.Count * 2 + series.Data.Count + 1) * ((j + 1) * 3 - 1);
|
||||
else
|
||||
xx = barX + x1 * ((j + 1) * 3 - 1);
|
||||
|
||||
var series = Option.Series[i];
|
||||
float x1 = DrawBarWidth / series.Data.Count / 4.0f;
|
||||
float x2 = x1 * 2;
|
||||
float ww = Math.Min(x2, series.MaxWidth);
|
||||
xx -= ww / 2.0f;
|
||||
|
||||
if (YAxisStart >= 0)
|
||||
{
|
||||
float h = Math.Abs((float)(DrawSize.Height * (series.Data[j] - start * interval) / ((end - start) * interval)));
|
||||
float sx = barX + (DrawBarWidth - ww * series.Data.Count - (series.Data.Count - 1) * CompactWidth) / 2.0f;
|
||||
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - h, ww, h),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
else if (YAxisEnd <= 0)
|
||||
Bars.TryAdd(i, new List<BarInfo>());
|
||||
for (int j = 0; j < series.Data.Count; j++)
|
||||
{
|
||||
float h = Math.Abs((float)(DrawSize.Height * (end * interval - series.Data[j]) / ((end - start) * interval)));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, Option.Grid.Top + 1, ww, h - 1),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
float lowH = 0;
|
||||
float highH = 0;
|
||||
float DrawBarHeight = DrawSize.Height * 1.0f / (YAxisEnd - YAxisStart);
|
||||
float lowV = 0;
|
||||
float highV = 0;
|
||||
for (int k = YAxisStart; k <= YAxisEnd; k++)
|
||||
{
|
||||
if (k < 0) lowH += DrawBarHeight;
|
||||
if (k > 0) highH += DrawBarHeight;
|
||||
if (k < 0) lowV += (float)YAxisInterval;
|
||||
if (k > 0) highV += (float)YAxisInterval;
|
||||
}
|
||||
Color color = ChartStyle.GetColor(i);
|
||||
if (series.Colors.Count > 0 && j >= 0 && j < series.Colors.Count)
|
||||
color = series.Colors[j];
|
||||
|
||||
if (series.Data[j] >= 0)
|
||||
float xx = sx;
|
||||
|
||||
if (YAxisStart >= 0)
|
||||
{
|
||||
float h = Math.Abs((float)(highH * series.Data[j] / highV));
|
||||
float h = Math.Abs((float)(DrawSize.Height * (series.Data[j] - start * interval) / ((end - start) * interval)));
|
||||
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - lowH - h, ww, h),
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - h, ww, h),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
else if (YAxisEnd <= 0)
|
||||
{
|
||||
float h = Math.Abs((float)(DrawSize.Height * (end * interval - series.Data[j]) / ((end - start) * interval)));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, Option.Grid.Top + 1, ww, h - 1),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
float h = Math.Abs((float)(lowH * series.Data[j] / lowV));
|
||||
float lowH = 0;
|
||||
float highH = 0;
|
||||
float DrawBarHeight = DrawSize.Height * 1.0f / (YAxisEnd - YAxisStart);
|
||||
float lowV = 0;
|
||||
float highV = 0;
|
||||
for (int k = YAxisStart; k <= YAxisEnd; k++)
|
||||
{
|
||||
if (k < 0) lowH += DrawBarHeight;
|
||||
if (k > 0) highH += DrawBarHeight;
|
||||
if (k < 0) lowV += (float)YAxisInterval;
|
||||
if (k > 0) highV += (float)YAxisInterval;
|
||||
}
|
||||
|
||||
if (series.Data[j] >= 0)
|
||||
{
|
||||
float h = Math.Abs((float)(highH * series.Data[j] / highV));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - lowH - h, ww, h),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
float h = Math.Abs((float)(lowH * series.Data[j] / lowV));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - lowH + 1, ww, h - 1),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
sx += ww + CompactWidth;
|
||||
}
|
||||
|
||||
barX += DrawBarWidth;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//宽松
|
||||
for (int i = 0; i < Option.SeriesCount; i++)
|
||||
{
|
||||
var series = Option.Series[i];
|
||||
float x1;
|
||||
if (Option.FixedSeriesCount > 0)
|
||||
x1 = DrawBarWidth / (Option.FixedSeriesCount * 2 + Option.FixedSeriesCount + 1);
|
||||
else
|
||||
x1 = DrawBarWidth / (series.Data.Count * 2 + series.Data.Count + 1);
|
||||
|
||||
float x2 = x1 * 2;
|
||||
|
||||
Bars.TryAdd(i, new List<BarInfo>());
|
||||
for (int j = 0; j < series.Data.Count; j++)
|
||||
{
|
||||
Color color = ChartStyle.GetColor(i);
|
||||
if (series.Colors.Count > 0 && j >= 0 && j < series.Colors.Count)
|
||||
color = series.Colors[j];
|
||||
|
||||
float xx;
|
||||
if (Option.FixedSeriesCount > 0)
|
||||
xx = barX + DrawBarWidth / (series.Data.Count * 2 + series.Data.Count + 1) * ((j + 1) * 3 - 1);
|
||||
else
|
||||
xx = barX + x1 * ((j + 1) * 3 - 1);
|
||||
|
||||
float ww = Math.Min(x2, series.MaxWidth);
|
||||
xx -= ww / 2.0f;
|
||||
|
||||
if (YAxisStart >= 0)
|
||||
{
|
||||
float h = Math.Abs((float)(DrawSize.Height * (series.Data[j] - start * interval) / ((end - start) * interval)));
|
||||
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - lowH + 1, ww, h - 1),
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - h, ww, h),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (YAxisEnd <= 0)
|
||||
{
|
||||
float h = Math.Abs((float)(DrawSize.Height * (end * interval - series.Data[j]) / ((end - start) * interval)));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, Option.Grid.Top + 1, ww, h - 1),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
float lowH = 0;
|
||||
float highH = 0;
|
||||
float DrawBarHeight = DrawSize.Height * 1.0f / (YAxisEnd - YAxisStart);
|
||||
float lowV = 0;
|
||||
float highV = 0;
|
||||
for (int k = YAxisStart; k <= YAxisEnd; k++)
|
||||
{
|
||||
if (k < 0) lowH += DrawBarHeight;
|
||||
if (k > 0) highH += DrawBarHeight;
|
||||
if (k < 0) lowV += (float)YAxisInterval;
|
||||
if (k > 0) highV += (float)YAxisInterval;
|
||||
}
|
||||
|
||||
barX += DrawBarWidth;
|
||||
if (series.Data[j] >= 0)
|
||||
{
|
||||
float h = Math.Abs((float)(highH * series.Data[j] / highV));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - lowH - h, ww, h),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
float h = Math.Abs((float)(lowH * series.Data[j] / lowV));
|
||||
Bars[i].Add(new BarInfo()
|
||||
{
|
||||
Rect = new RectangleF(xx, DrawOrigin.Y - lowH + 1, ww, h - 1),
|
||||
Color = color
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
barX += DrawBarWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,16 +474,21 @@ namespace Sunny.UI
|
||||
|
||||
if (s.ShowValue)
|
||||
{
|
||||
Font fontShow = null;
|
||||
if (s.ShowValueFontSize > 0) fontShow = new Font(SubFont.Name, s.ShowValueFontSize);
|
||||
|
||||
string value = s.Data[j].ToString("F" + Option.YAxis.AxisLabel.DecimalCount);
|
||||
SizeF sf = g.MeasureString(value, SubFont);
|
||||
SizeF sf = g.MeasureString(value, fontShow ?? SubFont);
|
||||
if (s.Data[j] < 0)
|
||||
g.DrawString(value, SubFont, bars[j].Color,
|
||||
g.DrawString(value, fontShow ?? SubFont, bars[j].Color,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Bottom + 1);
|
||||
else
|
||||
g.DrawString(value, SubFont, bars[j].Color,
|
||||
g.DrawString(value, fontShow ?? SubFont, bars[j].Color,
|
||||
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
|
||||
bars[j].Rect.Top - sf.Height);
|
||||
|
||||
fontShow?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,6 +245,8 @@ namespace Sunny.UI
|
||||
|
||||
public bool ShowValue { get; set; }
|
||||
|
||||
public float ShowValueFontSize { get; set; } = 0;
|
||||
|
||||
public void AddData(double value)
|
||||
{
|
||||
Data.Add(value);
|
||||
|
@ -33,22 +33,12 @@ namespace Sunny.UI
|
||||
public static class DirEx
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理文件夹名称末尾加反斜杠\
|
||||
/// </summary>
|
||||
/// <param name="dir">文件夹名称</param>
|
||||
/// <returns>结果</returns>
|
||||
public static string DealPath(this string dir)
|
||||
{
|
||||
return dir.Right(1) == "\\" ? dir : dir + "\\";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前可执行文件路径,末尾包括\
|
||||
/// 当前可执行文件路径,末尾包括文件夹分隔符(windows为\,linux为/)
|
||||
/// </summary>
|
||||
/// <returns>结果</returns>
|
||||
public static string CurrentDir()
|
||||
{
|
||||
return AppDomain.CurrentDomain.BaseDirectory.DealPath();
|
||||
return Environment.CurrentDirectory.DealPath();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -469,7 +469,6 @@ namespace Sunny.UI
|
||||
|| controlOrItem is GroupBox
|
||||
|| controlOrItem is Panel
|
||||
|| controlOrItem is TabControl
|
||||
|| controlOrItem is DataGrid
|
||||
|| controlOrItem is DataGridView
|
||||
|| controlOrItem is ListBox
|
||||
|| controlOrItem is ListView)
|
||||
|
@ -36,6 +36,16 @@ namespace Sunny.UI
|
||||
/// </summary>
|
||||
public static class StringEx
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理文件夹名称末尾加文件夹分隔符(windows为\,linux为/)
|
||||
/// </summary>
|
||||
/// <param name="dir">文件夹名称</param>
|
||||
/// <returns>结果</returns>
|
||||
public static string DealPath(this string dir)
|
||||
{
|
||||
return dir.IsNullOrEmpty() ? dir : (dir[dir.Length - 1] == Path.DirectorySeparatorChar ? dir : dir + Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 默认加密密码
|
||||
/// </summary>
|
||||
|
@ -27,7 +27,6 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
@ -299,7 +298,6 @@ namespace Sunny.UI
|
||||
/// 程序已经运行
|
||||
/// </summary>
|
||||
/// <returns>是否运行</returns>
|
||||
[EnvironmentPermission(SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public static bool ProcessIsRun()
|
||||
{
|
||||
Process instance = RunningInstance();
|
||||
@ -310,14 +308,12 @@ namespace Sunny.UI
|
||||
/// 将程序调至前台
|
||||
/// </summary>
|
||||
/// <param name="showStyle">显示风格</param>
|
||||
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public static void BringToFront(int showStyle = SW_SHOW)
|
||||
{
|
||||
Process instance = RunningInstance();
|
||||
HandleRunningInstance(instance, showStyle);
|
||||
}
|
||||
|
||||
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public static Process RunningInstance()
|
||||
{
|
||||
Process currentProcess = Process.GetCurrentProcess();
|
||||
@ -352,7 +348,6 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
private static void HandleRunningInstance(Process instance, int showStyle)
|
||||
{
|
||||
User.ShowWindowAsync(instance.MainWindowHandle, showStyle); //调用api函数,正常显示窗口
|
||||
|
Loading…
x
Reference in New Issue
Block a user