diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll index e8a4287f..3bac3c51 100644 Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ diff --git a/Bin/SunnyUI.pdb b/Bin/SunnyUI.pdb index a1317047..c33cf149 100644 Binary files a/Bin/SunnyUI.pdb and b/Bin/SunnyUI.pdb differ diff --git a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe index 1a03fbe5..b46845ec 100644 Binary files a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe and b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe differ diff --git a/SunnyUI.Demo/Bin/SunnyUI.dll b/SunnyUI.Demo/Bin/SunnyUI.dll index e8a4287f..3bac3c51 100644 Binary files a/SunnyUI.Demo/Bin/SunnyUI.dll and b/SunnyUI.Demo/Bin/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Charts/FBarChart.cs b/SunnyUI.Demo/Charts/FBarChart.cs index a4c01a53..2dad7e64 100644 --- a/SunnyUI.Demo/Charts/FBarChart.cs +++ b/SunnyUI.Demo/Charts/FBarChart.cs @@ -24,20 +24,20 @@ var series = new UIBarSeries(); series.Name = "Bar1"; - series.AddData(11); - series.AddData(15); - series.AddData(12); - series.AddData(14); - series.AddData(13); + series.AddData(+11); + series.AddData(+15); + series.AddData(+12); + series.AddData(+14); + series.AddData(+13); option.Series.Add(series); series = new UIBarSeries(); series.Name = "Bar2"; - series.AddData(22); - series.AddData(21); - series.AddData(25); - series.AddData(23); - series.AddData(24); + series.AddData(-22); + series.AddData(0); + series.AddData(-25); + series.AddData(-23); + series.AddData(-24); option.Series.Add(series); option.XAxis.Data.Add("Mon"); @@ -46,6 +46,8 @@ option.XAxis.Data.Add("Thu"); option.XAxis.Data.Add("Fri"); + option.ToolTip = new UIBarToolTip(); + BarChart.SetOption(option); } diff --git a/SunnyUI.Demo/Controls/FButton.Designer.cs b/SunnyUI.Demo/Controls/FButton.Designer.cs index 2dc466ac..c974dd0a 100644 --- a/SunnyUI.Demo/Controls/FButton.Designer.cs +++ b/SunnyUI.Demo/Controls/FButton.Designer.cs @@ -80,14 +80,17 @@ this.uiImageButton1 = new Sunny.UI.UIImageButton(); this.uiImageButton2 = new Sunny.UI.UIImageButton(); this.uiImageButton3 = new Sunny.UI.UIImageButton(); + this.uiImageButton4 = new Sunny.UI.UIImageButton(); this.PagePanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.uiImageButton1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.uiImageButton2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.uiImageButton3)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.uiImageButton4)).BeginInit(); this.SuspendLayout(); // // PagePanel // + this.PagePanel.Controls.Add(this.uiImageButton4); this.PagePanel.Controls.Add(this.uiImageButton3); this.PagePanel.Controls.Add(this.uiImageButton2); this.PagePanel.Controls.Add(this.uiImageButton1); @@ -953,6 +956,21 @@ this.uiImageButton3.TabStop = false; this.uiImageButton3.Text = null; // + // uiImageButton4 + // + this.uiImageButton4.Cursor = System.Windows.Forms.Cursors.Hand; + this.uiImageButton4.Image = global::Sunny.UI.Demo.Properties.Resources.dashboard0; + this.uiImageButton4.ImageHover = global::Sunny.UI.Demo.Properties.Resources.dashboard; + this.uiImageButton4.ImageOffset = new System.Drawing.Point(12, 5); + this.uiImageButton4.ImagePress = global::Sunny.UI.Demo.Properties.Resources.dashboard0; + this.uiImageButton4.Location = new System.Drawing.Point(630, 435); + this.uiImageButton4.Name = "uiImageButton4"; + this.uiImageButton4.Size = new System.Drawing.Size(70, 61); + this.uiImageButton4.TabIndex = 52; + this.uiImageButton4.TabStop = false; + this.uiImageButton4.Text = "Home"; + this.uiImageButton4.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + // // FButton // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); @@ -965,6 +983,7 @@ ((System.ComponentModel.ISupportInitialize)(this.uiImageButton1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.uiImageButton2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.uiImageButton3)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.uiImageButton4)).EndInit(); this.ResumeLayout(false); } @@ -1023,5 +1042,6 @@ private UIImageButton uiImageButton3; private UIImageButton uiImageButton2; private UIImageButton uiImageButton1; + private UIImageButton uiImageButton4; } } \ No newline at end of file diff --git a/SunnyUI/Charts/UIBarChart.cs b/SunnyUI/Charts/UIBarChart.cs index f8a6de70..017f96f1 100644 --- a/SunnyUI/Charts/UIBarChart.cs +++ b/SunnyUI/Charts/UIBarChart.cs @@ -79,7 +79,7 @@ namespace Sunny.UI { if (minZero) { - float h = (float)(DrawSize.Height * series.Data[j] / (end * interval)); + float h = Math.Abs((float)(DrawSize.Height * series.Data[j] / (end * interval))); Bars[i].Add(new BarInfo() { Rect = new RectangleF( @@ -90,25 +90,74 @@ namespace Sunny.UI } else if (maxZero) { + float h = Math.Abs((float)(DrawSize.Height * series.Data[j] / (start * interval))); + Bars[i].Add(new BarInfo() + { + Rect = new RectangleF( + barX + x1 * (i + 1) + x2 * i, + BarOption.Grid.Top + 1, + x2, h - 1) + }); } 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; + } + + lowH.ConsoleWriteLine(); + highH.ConsoleWriteLine(); + + if (series.Data[j] >= 0) + { + float h = Math.Abs((float)(highH *series.Data[j] /highV )); + Bars[i].Add(new BarInfo() + { + Rect = new RectangleF( + barX + x1 * (i + 1) + x2 * i, + DrawOrigin.Y - lowH- h, + x2, h) + }); + } + else + { + float h = Math.Abs((float)(lowH*series.Data[j] /lowV )); + Bars[i].Add(new BarInfo() + { + Rect = new RectangleF( + barX + x1 * (i + 1) + x2 * i, + DrawOrigin.Y - lowH+1, + x2, h-1) + }); + } } barX += DrawBarWidth; } } - for (int i = 0; i < BarOption.XAxis.Data.Count; i++) + if (BarOption.ToolTip != null) { - string str = BarOption.XAxis.Data[i]; - foreach (var series in BarOption.Series) + for (int i = 0; i < BarOption.XAxis.Data.Count; i++) { - str += '\n'; - str += series.Name + " : " + series.Data[i].ToString(BarOption.ToolTip.ValueFormat); - } + string str = BarOption.XAxis.Data[i]; + foreach (var series in BarOption.Series) + { + str += '\n'; + str += series.Name + " : " + series.Data[i].ToString(BarOption.ToolTip.ValueFormat); + } - Bars[0][i].Tips = str; + Bars[0][i].Tips = str; + } } } @@ -255,7 +304,7 @@ namespace Sunny.UI private void DrawAxis(Graphics g) { - g.DrawLine(ChartStyle.ForeColor, DrawOrigin, new Point(DrawOrigin.X + DrawSize.Width, DrawOrigin.Y)); + //g.DrawLine(ChartStyle.ForeColor, DrawOrigin, new Point(DrawOrigin.X + DrawSize.Width, DrawOrigin.Y)); g.DrawLine(ChartStyle.ForeColor, DrawOrigin, new Point(DrawOrigin.X, DrawOrigin.Y - DrawSize.Height)); if (BarOption.XAxis.AxisTick.Show) @@ -273,11 +322,24 @@ namespace Sunny.UI } else { - start = DrawOrigin.X; - for (int i = 0; i <= BarOption.XAxis.Data.Count; i++) + bool haveZero = false; + for (int i = YAxisStart; i <= YAxisEnd; i++) { - g.DrawLine(ChartStyle.ForeColor, start, DrawOrigin.Y, start, DrawOrigin.Y + BarOption.XAxis.AxisTick.Length); - start += DrawBarWidth; + if (i == 0) + { + haveZero = true; + break; + } + } + + if (!haveZero) + { + start = DrawOrigin.X; + for (int i = 0; i <= BarOption.XAxis.Data.Count; i++) + { + g.DrawLine(ChartStyle.ForeColor, start, DrawOrigin.Y, start, DrawOrigin.Y + BarOption.XAxis.AxisTick.Length); + start += DrawBarWidth; + } } } } @@ -310,6 +372,17 @@ namespace Sunny.UI g.DrawLine(pn, DrawOrigin.X, start, Width - BarOption.Grid.Right, start); } } + else + { + g.DrawLine(ChartStyle.ForeColor, DrawOrigin.X, start, Width - BarOption.Grid.Right, start); + + float lineStart = DrawOrigin.X; + for (int j = 0; j <= BarOption.XAxis.Data.Count; j++) + { + g.DrawLine(ChartStyle.ForeColor, lineStart, start, lineStart, start + BarOption.XAxis.AxisTick.Length); + lineStart += DrawBarWidth; + } + } start -= DrawBarHeight; } diff --git a/SunnyUI/Controls/UIImageButton.cs b/SunnyUI/Controls/UIImageButton.cs index 0f5dfc62..39878aae 100644 --- a/SunnyUI/Controls/UIImageButton.cs +++ b/SunnyUI/Controls/UIImageButton.cs @@ -282,6 +282,19 @@ namespace Sunny.UI Invalidate(); } + public Point imageOffset; + + [DefaultValue(typeof(Point),"0, 0")] + public Point ImageOffset + { + get => imageOffset; + set + { + imageOffset = value; + Invalidate(); + } + } + /// /// 绘制按钮 /// @@ -319,7 +332,7 @@ namespace Sunny.UI if (img != null) { if (SizeMode == PictureBoxSizeMode.Normal) - pe.Graphics.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height)); + pe.Graphics.DrawImage(img, new Rectangle(ImageOffset.X, ImageOffset.Y, img.Width, img.Height)); if (SizeMode == PictureBoxSizeMode.StretchImage) pe.Graphics.DrawImage(img, new Rectangle(0, 0, Width, Height));