# HG changeset patch # User moel.mich # Date 1280002549 0 # Node ID 119693c3b7d1948d59911eb1817058413c9326a3 # Parent 0b5cc38501e100f0d4ec0100798c994c6376e526 Replaced the SplitContainer with SplitContainerAdv. Now the panels are directly resized and the splitter can be drawn nicely. diff -r 0b5cc38501e1 -r 119693c3b7d1 GUI/MainForm.Designer.cs --- a/GUI/MainForm.Designer.cs Sun Jul 18 17:08:33 2010 +0000 +++ b/GUI/MainForm.Designer.cs Sat Jul 24 20:15:49 2010 +0000 @@ -62,7 +62,6 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.treeView = new Aga.Controls.Tree.TreeViewAdv(); this.sensor = new Aga.Controls.Tree.TreeColumn(); this.value = new Aga.Controls.Tree.TreeColumn(); this.min = new Aga.Controls.Tree.TreeColumn(); @@ -101,47 +100,17 @@ this.hddMenuItem = new System.Windows.Forms.MenuItem(); this.helpMenuItem = new System.Windows.Forms.MenuItem(); this.aboutMenuItem = new System.Windows.Forms.MenuItem(); - this.splitContainer = new System.Windows.Forms.SplitContainer(); - this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel(); this.sensorContextMenu = new System.Windows.Forms.ContextMenu(); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.timer = new System.Windows.Forms.Timer(this.components); + this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv(); + this.treeView = new Aga.Controls.Tree.TreeViewAdv(); + this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel(); this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel2.SuspendLayout(); this.splitContainer.SuspendLayout(); this.SuspendLayout(); // - // treeView - // - this.treeView.BackColor = System.Drawing.SystemColors.Window; - this.treeView.Columns.Add(this.sensor); - this.treeView.Columns.Add(this.value); - this.treeView.Columns.Add(this.min); - this.treeView.Columns.Add(this.max); - this.treeView.DefaultToolTipProvider = null; - this.treeView.Dock = System.Windows.Forms.DockStyle.Fill; - this.treeView.DragDropMarkColor = System.Drawing.Color.Black; - this.treeView.FullRowSelect = true; - this.treeView.GridLineStyle = Aga.Controls.Tree.GridLineStyle.Horizontal; - this.treeView.LineColor = System.Drawing.SystemColors.ControlDark; - this.treeView.Location = new System.Drawing.Point(0, 0); - this.treeView.Model = null; - this.treeView.Name = "treeView"; - this.treeView.NodeControls.Add(this.nodeImage); - this.treeView.NodeControls.Add(this.nodeCheckBox); - this.treeView.NodeControls.Add(this.nodeTextBoxText); - this.treeView.NodeControls.Add(this.nodeTextBoxValue); - this.treeView.NodeControls.Add(this.nodeTextBoxMin); - this.treeView.NodeControls.Add(this.nodeTextBoxMax); - this.treeView.RowHeight = 18; - this.treeView.SelectedNode = null; - this.treeView.Size = new System.Drawing.Size(386, 488); - this.treeView.TabIndex = 0; - this.treeView.Text = "treeView"; - this.treeView.UseColumns = true; - this.treeView.NodeMouseDoubleClick += new System.EventHandler(this.treeView_NodeMouseDoubleClick); - this.treeView.Click += new System.EventHandler(this.treeView_Click); - // // sensor // this.sensor.Header = "Sensor"; @@ -392,34 +361,6 @@ this.aboutMenuItem.Text = "About"; this.aboutMenuItem.Click += new System.EventHandler(this.aboutMenuItem_Click); // - // splitContainer - // - this.splitContainer.Location = new System.Drawing.Point(12, 12); - this.splitContainer.Name = "splitContainer"; - this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer.Panel1 - // - this.splitContainer.Panel1.Controls.Add(this.treeView); - // - // splitContainer.Panel2 - // - this.splitContainer.Panel2.Controls.Add(this.plotPanel); - this.splitContainer.Panel2.Cursor = System.Windows.Forms.Cursors.Default; - this.splitContainer.Size = new System.Drawing.Size(386, 662); - this.splitContainer.SplitterDistance = 488; - this.splitContainer.SplitterWidth = 3; - this.splitContainer.TabIndex = 3; - // - // plotPanel - // - this.plotPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.plotPanel.Location = new System.Drawing.Point(0, 0); - this.plotPanel.Name = "plotPanel"; - this.plotPanel.Size = new System.Drawing.Size(386, 171); - this.plotPanel.TabIndex = 0; - // // saveFileDialog // this.saveFileDialog.DefaultExt = "txt"; @@ -433,14 +374,76 @@ this.timer.Interval = 1000; this.timer.Tick += new System.EventHandler(this.timer_Tick); // + // splitContainer + // + this.splitContainer.Border3DStyle = System.Windows.Forms.Border3DStyle.Raised; + this.splitContainer.Color = System.Drawing.SystemColors.Control; + this.splitContainer.Cursor = System.Windows.Forms.Cursors.Default; + this.splitContainer.Location = new System.Drawing.Point(12, 12); + this.splitContainer.Name = "splitContainer"; + this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer.Panel1 + // + this.splitContainer.Panel1.Controls.Add(this.treeView); + // + // splitContainer.Panel2 + // + this.splitContainer.Panel2.Controls.Add(this.plotPanel); + this.splitContainer.Panel2.Cursor = System.Windows.Forms.Cursors.Default; + this.splitContainer.Size = new System.Drawing.Size(386, 483); + this.splitContainer.SplitterDistance = 354; + this.splitContainer.SplitterWidth = 5; + this.splitContainer.TabIndex = 3; + // + // treeView + // + this.treeView.BackColor = System.Drawing.SystemColors.Window; + this.treeView.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.treeView.Columns.Add(this.sensor); + this.treeView.Columns.Add(this.value); + this.treeView.Columns.Add(this.min); + this.treeView.Columns.Add(this.max); + this.treeView.DefaultToolTipProvider = null; + this.treeView.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeView.DragDropMarkColor = System.Drawing.Color.Black; + this.treeView.FullRowSelect = true; + this.treeView.GridLineStyle = Aga.Controls.Tree.GridLineStyle.Horizontal; + this.treeView.LineColor = System.Drawing.SystemColors.ControlDark; + this.treeView.Location = new System.Drawing.Point(0, 0); + this.treeView.Model = null; + this.treeView.Name = "treeView"; + this.treeView.NodeControls.Add(this.nodeImage); + this.treeView.NodeControls.Add(this.nodeCheckBox); + this.treeView.NodeControls.Add(this.nodeTextBoxText); + this.treeView.NodeControls.Add(this.nodeTextBoxValue); + this.treeView.NodeControls.Add(this.nodeTextBoxMin); + this.treeView.NodeControls.Add(this.nodeTextBoxMax); + this.treeView.RowHeight = 18; + this.treeView.SelectedNode = null; + this.treeView.Size = new System.Drawing.Size(386, 354); + this.treeView.TabIndex = 0; + this.treeView.Text = "treeView"; + this.treeView.UseColumns = true; + this.treeView.NodeMouseDoubleClick += new System.EventHandler(this.treeView_NodeMouseDoubleClick); + this.treeView.Click += new System.EventHandler(this.treeView_Click); + // + // plotPanel + // + this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.plotPanel.Location = new System.Drawing.Point(0, 0); + this.plotPanel.Name = "plotPanel"; + this.plotPanel.Size = new System.Drawing.Size(386, 124); + this.plotPanel.TabIndex = 0; + // // MainForm // - this.Menu = this.mainMenu; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(410, 686); + this.ClientSize = new System.Drawing.Size(418, 596); this.Controls.Add(this.splitContainer); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Menu = this.mainMenu; this.Name = "MainForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "Open Hardware Monitor"; @@ -467,7 +470,7 @@ private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxValue; private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxMin; private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxMax; - private System.Windows.Forms.SplitContainer splitContainer; + private SplitContainerAdv splitContainer; private PlotPanel plotPanel; private System.Windows.Forms.MenuItem viewMenuItem; private System.Windows.Forms.MenuItem plotMenuItem; diff -r 0b5cc38501e1 -r 119693c3b7d1 GUI/MainForm.cs --- a/GUI/MainForm.cs Sun Jul 18 17:08:33 2010 +0000 +++ b/GUI/MainForm.cs Sat Jul 24 20:15:49 2010 +0000 @@ -100,8 +100,8 @@ } ClientSize = new Size( - Utilities.Config.Get("mainForm.Width", ClientSize.Width), - Utilities.Config.Get("mainForm.Height", ClientSize.Height)); + Utilities.Config.Get("mainForm.Width", 470), + Utilities.Config.Get("mainForm.Height", 640)); foreach (TreeColumn column in treeView.Columns) column.Width = Math.Max(20, Math.Min(400, diff -r 0b5cc38501e1 -r 119693c3b7d1 GUI/PlotPanel.Designer.cs --- a/GUI/PlotPanel.Designer.cs Sun Jul 18 17:08:33 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - - Version: MPL 1.1/GPL 2.0/LGPL 2.1 - - The contents of this file are subject to the Mozilla Public License Version - 1.1 (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" basis, - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - for the specific language governing rights and limitations under the License. - - The Original Code is the Open Hardware Monitor code. - - The Initial Developer of the Original Code is - Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2010 - the Initial Developer. All Rights Reserved. - - Contributor(s): - - Alternatively, the contents of this file may be used under the terms of - either the GNU General Public License Version 2 or later (the "GPL"), or - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - in which case the provisions of the GPL or the LGPL are applicable instead - of those above. If you wish to allow use of your version of this file only - under the terms of either the GPL or the LGPL, and not to allow others to - use your version of this file under the terms of the MPL, indicate your - decision by deleting the provisions above and replace them with the notice - and other provisions required by the GPL or the LGPL. If you do not delete - the provisions above, a recipient may use your version of this file under - the terms of any one of the MPL, the GPL or the LGPL. - -*/ - -namespace OpenHardwareMonitor.GUI { - partial class PlotPanel { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) { - if (disposing && (components != null)) { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() { - this.SuspendLayout(); - // - // PlotPanel - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.Name = "PlotPanel"; - this.Size = new System.Drawing.Size(170, 168); - this.ResumeLayout(false); - - } - - #endregion - } -} diff -r 0b5cc38501e1 -r 119693c3b7d1 GUI/PlotPanel.cs --- a/GUI/PlotPanel.cs Sun Jul 18 17:08:33 2010 +0000 +++ b/GUI/PlotPanel.cs Sat Jul 24 20:15:49 2010 +0000 @@ -1,4 +1,4 @@ -/* +/* Version: MPL 1.1/GPL 2.0/LGPL 2.1 @@ -44,7 +44,7 @@ using OpenHardwareMonitor.Hardware; namespace OpenHardwareMonitor.GUI { - public partial class PlotPanel : UserControl { + public class PlotPanel : UserControl { private DateTime now; private List clocks = new List(); @@ -61,12 +61,10 @@ public PlotPanel() { this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | - ControlStyles.AllPaintingInWmPaint | + ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); this.UpdateStyles(); - InitializeComponent(); - centerlower = new StringFormat(); centerlower.Alignment = StringAlignment.Center; centerlower.LineAlignment = StringAlignment.Near; @@ -103,9 +101,9 @@ float maxTemp = (float)Math.Ceiling(maxTempNullable.Value / 10) * 10; float minTemp = (float)Math.Floor(minTempNullable.Value / 10) * 10; - if (maxTemp == minTemp) - maxTemp += 10; - + if (maxTemp == minTemp) + maxTemp += 10; + int countTempMax = 4; float deltaTemp = maxTemp - minTemp; int countTemp = (int)Math.Round(deltaTemp / 2); @@ -125,9 +123,9 @@ private List GetTimeGrid() { - float maxTime = 5; + float maxTime = 5; if (temperatures.Count > 0) { - IEnumerator enumerator = + IEnumerator enumerator = temperatures[0].Plot.GetEnumerator(); if (enumerator.MoveNext()) { maxTime = (float)(now - enumerator.Current.Time).TotalMinutes; @@ -174,7 +172,7 @@ float leftScaleSpace = 5; float bottomScaleSpace = 5; - + g.Clear(Color.White); if (w > 0 && h > 0) { @@ -212,32 +210,31 @@ g.SmoothingMode = SmoothingMode.None; g.FillRectangle(Brushes.White, 0, 0, x0, r.Height); - g.FillRectangle(Brushes.White, x0 + w + 1, 0, r.Width - x0 - w, + g.FillRectangle(Brushes.White, x0 + w + 1, 0, r.Width - x0 - w, r.Height); for (int i = 1; i < timeGrid.Count; i++) { - float x = x0 + (timeGrid.Count - 1 - i) * w / (timeGrid.Count - 1); - g.DrawString(timeGrid[i].ToString(), Font, Brushes.Black, x, + float x = x0 + (timeGrid.Count - 1 - i) * w / (timeGrid.Count - 1); + g.DrawString(timeGrid[i].ToString(), Font, Brushes.Black, x, y0 + h + bottomScaleSpace, centerlower); } for (int i = 0; i < tempGrid.Count - 1; i++) { float y = y0 + (tempGrid.Count - 1 - i) * h / (tempGrid.Count - 1); - g.DrawString(tempGrid[i].ToString(), Font, Brushes.Black, + g.DrawString(tempGrid[i].ToString(), Font, Brushes.Black, x0 - leftScaleSpace, y, centerleft); } g.SmoothingMode = SmoothingMode.HighQuality; g.DrawString("[°C]", Font, Brushes.Black, x0 - leftScaleSpace, y0, - lowerleft); + lowerleft); g.DrawString("[min]", Font, Brushes.Black, x0 + w, - y0 + h + bottomScaleSpace, lowerleft); + y0 + h + bottomScaleSpace, lowerleft); } } - public void SetSensors(List sensors, - IDictionary colors) - { + public void SetSensors(List sensors, + IDictionary colors) { this.colors = colors; List clocks = new List(); List temperatures = new List(); diff -r 0b5cc38501e1 -r 119693c3b7d1 GUI/PlotPanel.resx --- a/GUI/PlotPanel.resx Sun Jul 18 17:08:33 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff -r 0b5cc38501e1 -r 119693c3b7d1 GUI/SplitContainerAdv.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GUI/SplitContainerAdv.cs Sat Jul 24 20:15:49 2010 +0000 @@ -0,0 +1,150 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace OpenHardwareMonitor.GUI { + public class SplitContainerAdv : SplitContainer { + + private int delta = 0; + private Border3DStyle border3DStyle = Border3DStyle.Raised; + private Color color = SystemColors.Control; + + public SplitContainerAdv() + : base() { + SetStyle(ControlStyles.ResizeRedraw, true); + SetStyle(ControlStyles.AllPaintingInWmPaint, true); + SetStyle(ControlStyles.UserPaint, true); + SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + SetStyle(ControlStyles.ContainerControl, true); + UpdateStyles(); + } + + protected override void OnPaint(PaintEventArgs e) { + base.OnPaint(e); + + Graphics g = e.Graphics; + Rectangle r = SplitterRectangle; + using (SolidBrush brush = new SolidBrush(color)) + g.FillRectangle(brush, r); + ControlPaint.DrawBorder3D(g, r, border3DStyle); + } + + protected override void OnKeyDown(KeyEventArgs e) { + if (!base.IsSplitterFixed) { + if (e.KeyData == Keys.Right || e.KeyData == Keys.Down) { + SplitterDistance += SplitterIncrement; + } else if (e.KeyData == Keys.Left || e.KeyData == Keys.Up) { + SplitterDistance -= SplitterIncrement; + } + Invalidate(); + } + } + + protected override void OnMouseDown(MouseEventArgs e) { + if (Orientation == Orientation.Vertical) { + delta = this.SplitterDistance - e.X; + Cursor.Current = Cursors.VSplit; + } else { + delta = this.SplitterDistance - e.Y; + Cursor.Current = Cursors.HSplit; + } + base.IsSplitterFixed = true; + } + + protected override void OnMouseMove(MouseEventArgs e) { + if (base.IsSplitterFixed) { + if (e.Button == MouseButtons.Left) { + if (Orientation == Orientation.Vertical) { + if (e.X > 0 && e.X < Width) { + SplitterDistance = e.X + delta < 0 ? 0 : e.X + delta; + } + } else { + if (e.Y > 0 && e.Y < Height) { + SplitterDistance = e.Y + delta < 0 ? 0 : e.Y + delta; + } + } + } else { + base.IsSplitterFixed = false; + } + Invalidate(); + } else { + if (SplitterRectangle.Contains(e.Location)) { + Cursor = Orientation == Orientation.Vertical ? + Cursors.VSplit : Cursors.HSplit; + } + } + } + + protected override void OnMouseLeave(EventArgs e) { + base.OnMouseLeave(e); + Cursor = Cursors.Default; + } + + protected override void OnMouseUp(MouseEventArgs e) { + delta = 0; + base.IsSplitterFixed = false; + Cursor.Current = Cursors.Default; + } + + public Border3DStyle Border3DStyle { + get { return border3DStyle; } + set { + border3DStyle = value; + Invalidate(false); + } + } + + public Color Color { + get { return color; } + set { + color = value; + Invalidate(false); + } + } + + public new bool IsSplitterFixed { + get { + return false; + } + } + + } +} diff -r 0b5cc38501e1 -r 119693c3b7d1 OpenHardwareMonitor.csproj --- a/OpenHardwareMonitor.csproj Sun Jul 18 17:08:33 2010 +0000 +++ b/OpenHardwareMonitor.csproj Sat Jul 24 20:15:49 2010 +0000 @@ -61,6 +61,9 @@ + + UserControl + Form @@ -82,6 +85,9 @@ + + Component + @@ -148,12 +154,6 @@ - - UserControl - - - PlotPanel.cs - @@ -170,10 +170,6 @@ AboutBox.cs Designer - - PlotPanel.cs - Designer -