diff --git a/Bin/SunnyUI.Demo.exe b/Bin/SunnyUI.Demo.exe index 02bdc88b..e6aa8368 100644 Binary files a/Bin/SunnyUI.Demo.exe and b/Bin/SunnyUI.Demo.exe differ diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll index 09d709b9..160f77cc 100644 Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Charts/FBarChartEx.Designer.cs b/SunnyUI.Demo/Charts/FBarChartEx.Designer.cs index 83269560..8f857bb4 100644 --- a/SunnyUI.Demo/Charts/FBarChartEx.Designer.cs +++ b/SunnyUI.Demo/Charts/FBarChartEx.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/SunnyUI.Demo/Charts/FBarChartEx.cs b/SunnyUI.Demo/Charts/FBarChartEx.cs index 6dd79779..7268dd46 100644 --- a/SunnyUI.Demo/Charts/FBarChartEx.cs +++ b/SunnyUI.Demo/Charts/FBarChartEx.cs @@ -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); + } } } diff --git a/SunnyUI.Demo/Controls/FNavigation.Designer.cs b/SunnyUI.Demo/Controls/FNavigation.Designer.cs index cd45f751..ca8b50ec 100644 --- a/SunnyUI.Demo/Controls/FNavigation.Designer.cs +++ b/SunnyUI.Demo/Controls/FNavigation.Designer.cs @@ -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; // diff --git a/SunnyUI/Charts/UIBarChartEx.cs b/SunnyUI/Charts/UIBarChartEx.cs index e06ace24..0661e997 100644 --- a/SunnyUI/Charts/UIBarChartEx.cs +++ b/SunnyUI/Charts/UIBarChartEx.cs @@ -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()); - 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()); + 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()); + 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(); } } } diff --git a/SunnyUI/Charts/UIBarChartOption.cs b/SunnyUI/Charts/UIBarChartOption.cs index 187501a9..92d5b358 100644 --- a/SunnyUI/Charts/UIBarChartOption.cs +++ b/SunnyUI/Charts/UIBarChartOption.cs @@ -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); diff --git a/SunnyUI/Static/UDir.cs b/SunnyUI/Static/UDir.cs index f80d4c62..f8bee919 100644 --- a/SunnyUI/Static/UDir.cs +++ b/SunnyUI/Static/UDir.cs @@ -33,22 +33,12 @@ namespace Sunny.UI public static class DirEx { /// - /// 处理文件夹名称末尾加反斜杠\ - /// - /// 文件夹名称 - /// 结果 - public static string DealPath(this string dir) - { - return dir.Right(1) == "\\" ? dir : dir + "\\"; - } - - /// - /// 当前可执行文件路径,末尾包括\ + /// 当前可执行文件路径,末尾包括文件夹分隔符(windows为\,linux为/) /// /// 结果 public static string CurrentDir() { - return AppDomain.CurrentDomain.BaseDirectory.DealPath(); + return Environment.CurrentDirectory.DealPath(); } /// diff --git a/SunnyUI/Static/UMessageTip.cs b/SunnyUI/Static/UMessageTip.cs index 5ba12798..b6bf77ad 100644 --- a/SunnyUI/Static/UMessageTip.cs +++ b/SunnyUI/Static/UMessageTip.cs @@ -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) diff --git a/SunnyUI/Static/UString.cs b/SunnyUI/Static/UString.cs index 1c59a729..6521e514 100644 --- a/SunnyUI/Static/UString.cs +++ b/SunnyUI/Static/UString.cs @@ -36,6 +36,16 @@ namespace Sunny.UI /// public static class StringEx { + /// + /// 处理文件夹名称末尾加文件夹分隔符(windows为\,linux为/) + /// + /// 文件夹名称 + /// 结果 + public static string DealPath(this string dir) + { + return dir.IsNullOrEmpty() ? dir : (dir[dir.Length - 1] == Path.DirectorySeparatorChar ? dir : dir + Path.DirectorySeparatorChar); + } + /// /// 默认加密密码 /// diff --git a/SunnyUI/Static/USystem.cs b/SunnyUI/Static/USystem.cs index bbe9ee23..0e8089ef 100644 --- a/SunnyUI/Static/USystem.cs +++ b/SunnyUI/Static/USystem.cs @@ -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 /// 程序已经运行 /// /// 是否运行 - [EnvironmentPermission(SecurityAction.LinkDemand, Unrestricted = true)] public static bool ProcessIsRun() { Process instance = RunningInstance(); @@ -310,14 +308,12 @@ namespace Sunny.UI /// 将程序调至前台 /// /// 显示风格 - [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函数,正常显示窗口