diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index adc79b4..ae0a4a3 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -34,24 +34,17 @@ jobs: } | Set-Content Directory.Build.props - name: Restore application packages - run: dotnet restore LibreHardwareMonitor.Windows.Forms\LibreHardwareMonitor.Windows.Forms.csproj + run: dotnet restore LibreHardwareMonitor.Windows.WinUI\LibreHardwareMonitor.Windows.WinUI.csproj - name: Build application - run: dotnet build LibreHardwareMonitor.Windows.Forms\LibreHardwareMonitor.Windows.Forms.csproj -c Release --no-restore -p:Platform=x64 + run: dotnet build LibreHardwareMonitor.Windows.WinUI\LibreHardwareMonitor.Windows.WinUI.csproj -c Release --no-restore -p:Platform=x64 - - name: Publish net472 application + - name: Publish WinUI application uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # 7.0.1 with: - name: LibreHardwareMonitor.Windows.Forms + name: LibreHardwareMonitor.Windows.WinUI path: | - bin/Release/net472 - - - name: Publish net10.0 application - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # 7.0.1 - with: - name: LibreHardwareMonitor.Windows.Forms (.NET 10) - path: | - bin/Release/net10.0-windows + bin/Release/net10.0-windows10.0.19041.0 - name: Restore library packages run: dotnet restore LibreHardwareMonitorLib\LibreHardwareMonitorLib.csproj diff --git a/.github/workflows/pull requests.yml b/.github/workflows/pull requests.yml index 6bd3f3e..12415bf 100644 --- a/.github/workflows/pull requests.yml +++ b/.github/workflows/pull requests.yml @@ -34,24 +34,17 @@ jobs: } | Set-Content Directory.Build.props - name: Restore application packages - run: dotnet restore LibreHardwareMonitor.Windows.Forms\LibreHardwareMonitor.Windows.Forms.csproj + run: dotnet restore LibreHardwareMonitor.Windows.WinUI\LibreHardwareMonitor.Windows.WinUI.csproj - name: Build application - run: dotnet build LibreHardwareMonitor.Windows.Forms\LibreHardwareMonitor.Windows.Forms.csproj -c Release --no-restore -p:Platform=x64 + run: dotnet build LibreHardwareMonitor.Windows.WinUI\LibreHardwareMonitor.Windows.WinUI.csproj -c Release --no-restore -p:Platform=x64 - - name: Publish net472 application + - name: Publish WinUI application uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # 7.0.1 with: - name: LibreHardwareMonitor.Windows.Forms + name: LibreHardwareMonitor.Windows.WinUI path: | - bin/Release/net472 - - - name: Publish net10.0 application - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # 7.0.1 - with: - name: LibreHardwareMonitor.Windows.Forms (.NET 10) - path: | - bin/Release/net10.0-windows + bin/Release/net10.0-windows10.0.19041.0 - name: Restore library packages run: dotnet restore LibreHardwareMonitorLib\LibreHardwareMonitorLib.csproj diff --git a/Aga.Controls/Aga.Controls.csproj b/Aga.Controls/Aga.Controls.csproj deleted file mode 100644 index 1c4a035..0000000 --- a/Aga.Controls/Aga.Controls.csproj +++ /dev/null @@ -1,128 +0,0 @@ - - - true - x64;x86;ARM64 - - - 9.0.30729 - net472 - Aga.Controls - http://sourceforge.net/projects/treeviewadv/ - Copyright © Andrey Gliznetsov 2006 - 2009 - 1.7.0.0 - 1.7.0.0 - true - ..\bin\$(Configuration)\ - - - full - TRACE;DEBUG;PERF_TEST - - - pdbonly - - - - - - - - True - True - Resources.resx - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - Component - - - TreeViewAdv.cs - - - - - - - - Designer - ResXFileCodeGenerator - Resources.Designer.cs - - - TreeViewAdv.cs - - - - - - - - - - - - - - diff --git a/Aga.Controls/Aga.Controls.sln b/Aga.Controls/Aga.Controls.sln deleted file mode 100644 index 9c7ba8c..0000000 --- a/Aga.Controls/Aga.Controls.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aga.Controls", "Aga.Controls.csproj", "{E73BB233-D88B-44A7-A98F-D71EE158381D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Aga.Controls/BitmapHelper.cs b/Aga.Controls/BitmapHelper.cs deleted file mode 100644 index a29b1c2..0000000 --- a/Aga.Controls/BitmapHelper.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Drawing.Imaging; - -namespace Aga.Controls -{ - public static class BitmapHelper - { - [StructLayout(LayoutKind.Sequential)] - private struct PixelData - { - public byte B; - public byte G; - public byte R; - public byte A; - } - - public static void SetAlphaChanelValue(Bitmap image, byte value) - { - if (image == null) - throw new ArgumentNullException("image"); - if (image.PixelFormat != PixelFormat.Format32bppArgb) - throw new ArgumentException("Wrong PixelFormat"); - - BitmapData bitmapData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), - ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); - unsafe - { - PixelData* pPixel = (PixelData*)bitmapData.Scan0; - for (int i = 0; i < bitmapData.Height; i++) - { - for (int j = 0; j < bitmapData.Width; j++) - { - pPixel->A = value; - pPixel++; - } - pPixel += bitmapData.Stride - (bitmapData.Width * 4); - } - } - image.UnlockBits(bitmapData); - } - } -} diff --git a/Aga.Controls/GifDecoder.cs b/Aga.Controls/GifDecoder.cs deleted file mode 100644 index e611155..0000000 --- a/Aga.Controls/GifDecoder.cs +++ /dev/null @@ -1,864 +0,0 @@ -#pragma warning disable 675 // Bitwise-or operator used on a sign-extended operand - -#region Java Info -/** - * Class GifDecoder - Decodes a GIF file into one or more frames. - *
- * Example:
- *    GifDecoder d = new GifDecoder();
- *    d.read("sample.gif");
- *    int n = d.getFrameCount();
- *    for (int i = 0; i < n; i++) {
- *       BufferedImage frame = d.getFrame(i);  // frame i
- *       int t = d.getDelay(i);  // display duration of frame in milliseconds
- *       // do something with frame
- *    }
- * 
- * No copyright asserted on the source code of this class. May be used for - * any purpose, however, refer to the Unisys LZW patent for any additional - * restrictions. Please forward any corrections to kweiner@fmsware.com. - * - * @author Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's ImageMagick. - * @version 1.03 November 2003 - * - */ -#endregion - -using System; -using System.Collections; -using System.Drawing; -using System.Drawing.Imaging; -using System.IO; - -namespace Aga.Controls -{ - public class GifFrame - { - private Image _image; - public Image Image - { - get { return _image; } - } - - private int _delay; - public int Delay - { - get { return _delay; } - } - - public GifFrame(Image im, int del) - { - _image = im; - _delay = del; - } - } - - public class GifDecoder - { - public const int StatusOK = 0;//File read status: No errors. - public const int StatusFormatError = 1; //File read status: Error decoding file (may be partially decoded) - public const int StatusOpenError = 2; //Unable to open source. - - private Stream inStream; - private int status; - - private int width; // full image width - private int height; // full image height - private bool gctFlag; // global color table used - private int gctSize; // size of global color table - private int loopCount = 1; // iterations; 0 = repeat forever - - private int[] gct; // global color table - private int[] lct; // local color table - private int[] act; // active color table - - private int bgIndex; // background color index - private int bgColor; // background color - private int lastBgColor; // previous bg color - private int pixelAspect; // pixel aspect ratio - - private bool lctFlag; // local color table flag - private bool interlace; // interlace flag - private int lctSize; // local color table size - - private int ix, iy, iw, ih; // current image rectangle - private Rectangle lastRect; // last image rect - private Image image; // current frame - private Bitmap bitmap; - private Image lastImage; // previous frame - - private byte[] block = new byte[256]; // current data block - private int blockSize = 0; // block size - - // last graphic control extension info - private int dispose = 0; - // 0=no action; 1=leave in place; 2=restore to bg; 3=restore to prev - private int lastDispose = 0; - private bool transparency = false; // use transparent color - private int delay = 0; // delay in milliseconds - private int transIndex; // transparent color index - - private const int MaxStackSize = 4096; - // max decoder pixel stack size - - // LZW decoder working arrays - private short[] prefix; - private byte[] suffix; - private byte[] pixelStack; - private byte[] pixels; - - private ArrayList frames; // frames read from current file - private int frameCount; - private bool _makeTransparent; - - /** - * Gets the number of frames read from file. - * @return frame count - */ - public int FrameCount - { - get - { - return frameCount; - } - } - - /** - * Gets the first (or only) image read. - * - * @return BufferedImage containing first frame, or null if none. - */ - public Image Image - { - get - { - return GetFrame(0).Image; - } - } - - /** - * Gets the "Netscape" iteration count, if any. - * A count of 0 means repeat indefinitiely. - * - * @return iteration count if one was specified, else 1. - */ - public int LoopCount - { - get - { - return loopCount; - } - } - - public GifDecoder(Stream stream, bool makeTransparent) - { - _makeTransparent = makeTransparent; - if (Read(stream) != 0) - throw new InvalidOperationException(); - } - - /** - * Creates new frame image from current data (and previous - * frames as specified by their disposition codes). - */ - private int[] GetPixels(Bitmap bitmap) - { - int [] pixels = new int [ 3 * image.Width * image.Height ]; - int count = 0; - for (int th = 0; th < image.Height; th++) - { - for (int tw = 0; tw < image.Width; tw++) - { - Color color = bitmap.GetPixel(tw, th); - pixels[count] = color.R; - count++; - pixels[count] = color.G; - count++; - pixels[count] = color.B; - count++; - } - } - return pixels; - } - - private void SetPixels(int[] pixels) - { - int count = 0; - for (int th = 0; th < image.Height; th++) - { - for (int tw = 0; tw < image.Width; tw++) - { - Color color = Color.FromArgb( pixels[count++] ); - bitmap.SetPixel( tw, th, color ); - } - } - if (_makeTransparent) - bitmap.MakeTransparent(bitmap.GetPixel(0, 0)); - } - - private void SetPixels() - { - // expose destination image's pixels as int array - // int[] dest = - // (( int ) image.getRaster().getDataBuffer()).getData(); - int[] dest = GetPixels( bitmap ); - - // fill in starting image contents based on last image's dispose code - if (lastDispose > 0) - { - if (lastDispose == 3) - { - // use image before last - int n = frameCount - 2; - if (n > 0) - { - lastImage = GetFrame(n - 1).Image; - } - else - { - lastImage = null; - } - } - - if (lastImage != null) - { - // int[] prev = - // ((DataBufferInt) lastImage.getRaster().getDataBuffer()).getData(); - int[] prev = GetPixels( new Bitmap( lastImage ) ); - Array.Copy(prev, 0, dest, 0, width * height); - // copy pixels - - if (lastDispose == 2) - { - // fill last image rect area with background color - Graphics g = Graphics.FromImage( image ); - Color c = Color.Empty; - if (transparency) - { - c = Color.FromArgb( 0, 0, 0, 0 ); // assume background is transparent - } - else - { - c = Color.FromArgb( lastBgColor ) ; - // c = new Color(lastBgColor); // use given background color - } - Brush brush = new SolidBrush( c ); - g.FillRectangle( brush, lastRect ); - brush.Dispose(); - g.Dispose(); - } - } - } - - // copy each source line to the appropriate place in the destination - int pass = 1; - int inc = 8; - int iline = 0; - for (int i = 0; i < ih; i++) - { - int line = i; - if (interlace) - { - if (iline >= ih) - { - pass++; - switch (pass) - { - case 2 : - iline = 4; - break; - case 3 : - iline = 2; - inc = 4; - break; - case 4 : - iline = 1; - inc = 2; - break; - } - } - line = iline; - iline += inc; - } - line += iy; - if (line < height) - { - int k = line * width; - int dx = k + ix; // start of line in dest - int dlim = dx + iw; // end of dest line - if ((k + width) < dlim) - { - dlim = k + width; // past dest edge - } - int sx = i * iw; // start of line in source - while (dx < dlim) - { - // map color and insert in destination - int index = ((int) pixels[sx++]) & 0xff; - int c = act[index]; - if (c != 0) - { - dest[dx] = c; - } - dx++; - } - } - } - SetPixels( dest ); - } - - /** - * Gets the image contents of frame n. - * - * @return BufferedImage representation of frame. - */ - public GifFrame GetFrame(int n) - { - if ((n >= 0) && (n < frameCount)) - return (GifFrame)frames[n]; - else - throw new ArgumentOutOfRangeException(); - } - - /** - * Gets image size. - * - * @return GIF image dimensions - */ - public Size FrameSize - { - get - { - return new Size(width, height); - } - } - - /** - * Reads GIF image from stream - * - * @param BufferedInputStream containing GIF file. - * @return read status code (0 = no errors) - */ - private int Read( Stream inStream ) - { - Init(); - if ( inStream != null) - { - this.inStream = inStream; - ReadHeader(); - if (!Error()) - { - ReadContents(); - if (frameCount < 0) - { - status = StatusFormatError; - } - } - inStream.Close(); - } - else - { - status = StatusOpenError; - } - return status; - } - - - /** - * Decodes LZW image data into pixel array. - * Adapted from John Cristy's ImageMagick. - */ - private void DecodeImageData() - { - int NullCode = -1; - int npix = iw * ih; - int available, - clear, - code_mask, - code_size, - end_of_information, - in_code, - old_code, - bits, - code, - count, - i, - datum, - data_size, - first, - top, - bi, - pi; - - if ((pixels == null) || (pixels.Length < npix)) - { - pixels = new byte[npix]; // allocate new pixel array - } - if (prefix == null) prefix = new short[MaxStackSize]; - if (suffix == null) suffix = new byte[MaxStackSize]; - if (pixelStack == null) pixelStack = new byte[MaxStackSize + 1]; - - // Initialize GIF data stream decoder. - - data_size = Read(); - clear = 1 << data_size; - end_of_information = clear + 1; - available = clear + 2; - old_code = NullCode; - code_size = data_size + 1; - code_mask = (1 << code_size) - 1; - for (code = 0; code < clear; code++) - { - prefix[code] = 0; - suffix[code] = (byte) code; - } - - // Decode GIF pixel stream. - - datum = bits = count = first = top = pi = bi = 0; - - for (i = 0; i < npix;) - { - if (top == 0) - { - if (bits < code_size) - { - // Load bytes until there are enough bits for a code. - if (count == 0) - { - // Read a new data block. - count = ReadBlock(); - if (count <= 0) - break; - bi = 0; - } - datum += (((int) block[bi]) & 0xff) << bits; - bits += 8; - bi++; - count--; - continue; - } - - // Get the next code. - - code = datum & code_mask; - datum >>= code_size; - bits -= code_size; - - // Interpret the code - - if ((code > available) || (code == end_of_information)) - break; - if (code == clear) - { - // Reset decoder. - code_size = data_size + 1; - code_mask = (1 << code_size) - 1; - available = clear + 2; - old_code = NullCode; - continue; - } - if (old_code == NullCode) - { - pixelStack[top++] = suffix[code]; - old_code = code; - first = code; - continue; - } - in_code = code; - if (code == available) - { - pixelStack[top++] = (byte) first; - code = old_code; - } - while (code > clear) - { - pixelStack[top++] = suffix[code]; - code = prefix[code]; - } - first = ((int) suffix[code]) & 0xff; - - // Add a new string to the string table, - - if (available >= MaxStackSize) - break; - pixelStack[top++] = (byte) first; - prefix[available] = (short) old_code; - suffix[available] = (byte) first; - available++; - if (((available & code_mask) == 0) - && (available < MaxStackSize)) - { - code_size++; - code_mask += available; - } - old_code = in_code; - } - - // Pop a pixel off the pixel stack. - - top--; - pixels[pi++] = pixelStack[top]; - i++; - } - - for (i = pi; i < npix; i++) - { - pixels[i] = 0; // clear missing pixels - } - - } - - /** - * Returns true if an error was encountered during reading/decoding - */ - private bool Error() - { - return status != StatusOK; - } - - /** - * Initializes or re-initializes reader - */ - private void Init() - { - status = StatusOK; - frameCount = 0; - frames = new ArrayList(); - gct = null; - lct = null; - } - - /** - * Reads a single byte from the input stream. - */ - private int Read() - { - int curByte = 0; - try - { - curByte = inStream.ReadByte(); - } - catch (IOException) - { - status = StatusFormatError; - } - return curByte; - } - - /** - * Reads next variable length block from input. - * - * @return number of bytes stored in "buffer" - */ - private int ReadBlock() - { - blockSize = Read(); - int n = 0; - if (blockSize > 0) - { - try - { - int count = 0; - while (n < blockSize) - { - count = inStream.Read(block, n, blockSize - n); - if (count == -1) - break; - n += count; - } - } - catch (IOException) - { - } - - if (n < blockSize) - { - status = StatusFormatError; - } - } - return n; - } - - /** - * Reads color table as 256 RGB integer values - * - * @param ncolors int number of colors to read - * @return int array containing 256 colors (packed ARGB with full alpha) - */ - private int[] ReadColorTable(int ncolors) - { - int nbytes = 3 * ncolors; - int[] tab = null; - byte[] c = new byte[nbytes]; - int n = 0; - try - { - n = inStream.Read(c, 0, c.Length ); - } - catch (IOException) - { - } - if (n < nbytes) - { - status = StatusFormatError; - } - else - { - tab = new int[256]; // max size to avoid bounds checks - int i = 0; - int j = 0; - while (i < ncolors) - { - int r = ((int) c[j++]) & 0xff; - int g = ((int) c[j++]) & 0xff; - int b = ((int) c[j++]) & 0xff; - tab[i++] = ( int ) ( 0xff000000 | (r << 16) | (g << 8) | b ); - } - } - return tab; - } - - /** - * Main file parser. Reads GIF content blocks. - */ - private void ReadContents() - { - // read GIF file content blocks - bool done = false; - while (!(done || Error())) - { - int code = Read(); - switch (code) - { - - case 0x2C : // image separator - ReadImage(); - break; - - case 0x21 : // extension - code = Read(); - switch (code) - { - case 0xf9 : // graphics control extension - ReadGraphicControlExt(); - break; - - case 0xff : // application extension - ReadBlock(); - String app = ""; - for (int i = 0; i < 11; i++) - { - app += (char) block[i]; - } - if (app.Equals("NETSCAPE2.0")) - { - ReadNetscapeExt(); - } - else - Skip(); // don't care - break; - - default : // uninteresting extension - Skip(); - break; - } - break; - - case 0x3b : // terminator - done = true; - break; - - case 0x00 : // bad byte, but keep going and see what happens - break; - - default : - status = StatusFormatError; - break; - } - } - } - - /** - * Reads Graphics Control Extension values - */ - private void ReadGraphicControlExt() - { - Read(); // block size - int packed = Read(); // packed fields - dispose = (packed & 0x1c) >> 2; // disposal method - if (dispose == 0) - { - dispose = 1; // elect to keep old image if discretionary - } - transparency = (packed & 1) != 0; - delay = ReadShort() * 10; // delay in milliseconds - transIndex = Read(); // transparent color index - Read(); // block terminator - } - - /** - * Reads GIF file header information. - */ - private void ReadHeader() - { - String id = ""; - for (int i = 0; i < 6; i++) - { - id += (char) Read(); - } - if (!id.StartsWith("GIF")) - { - status = StatusFormatError; - return; - } - - ReadLSD(); - if (gctFlag && !Error()) - { - gct = ReadColorTable(gctSize); - bgColor = gct[bgIndex]; - } - } - - /** - * Reads next frame image - */ - private void ReadImage() - { - ix = ReadShort(); // (sub)image position & size - iy = ReadShort(); - iw = ReadShort(); - ih = ReadShort(); - - int packed = Read(); - lctFlag = (packed & 0x80) != 0; // 1 - local color table flag - interlace = (packed & 0x40) != 0; // 2 - interlace flag - // 3 - sort flag - // 4-5 - reserved - lctSize = 2 << (packed & 7); // 6-8 - local color table size - - if (lctFlag) - { - lct = ReadColorTable(lctSize); // read table - act = lct; // make local table active - } - else - { - act = gct; // make global table active - if (bgIndex == transIndex) - bgColor = 0; - } - int save = 0; - if (transparency) - { - save = act[transIndex]; - act[transIndex] = 0; // set transparent color if specified - } - - if (act == null) - { - status = StatusFormatError; // no color table defined - } - - if (Error()) return; - - DecodeImageData(); // decode pixel data - Skip(); - - if (Error()) return; - - frameCount++; - - // create new image to receive frame data - // image = - // new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE); - - bitmap = new Bitmap( width, height ); - image = bitmap; - SetPixels(); // transfer pixel data to image - - frames.Add(new GifFrame(bitmap, delay)); // add image to frame list - - if (transparency) - { - act[transIndex] = save; - } - ResetFrame(); - - } - - /** - * Reads Logical Screen Descriptor - */ - private void ReadLSD() - { - - // logical screen size - width = ReadShort(); - height = ReadShort(); - - // packed fields - int packed = Read(); - gctFlag = (packed & 0x80) != 0; // 1 : global color table flag - // 2-4 : color resolution - // 5 : gct sort flag - gctSize = 2 << (packed & 7); // 6-8 : gct size - - bgIndex = Read(); // background color index - pixelAspect = Read(); // pixel aspect ratio - } - - /** - * Reads Netscape extenstion to obtain iteration count - */ - private void ReadNetscapeExt() - { - do - { - ReadBlock(); - if (block[0] == 1) - { - // loop count sub-block - int b1 = ((int) block[1]) & 0xff; - int b2 = ((int) block[2]) & 0xff; - loopCount = (b2 << 8) | b1; - } - } while ((blockSize > 0) && !Error()); - } - - /** - * Reads next 16-bit value, LSB first - */ - private int ReadShort() - { - // read 16-bit value, LSB first - return Read() | (Read() << 8); - } - - /** - * Resets frame state for reading next image. - */ - private void ResetFrame() - { - lastDispose = dispose; - lastRect = new Rectangle(ix, iy, iw, ih); - lastImage = image; - lastBgColor = bgColor; - // int dispose = 0; - lct = null; - } - - /** - * Skips variable length blocks up to and including - * next zero length block. - */ - private void Skip() - { - do - { - ReadBlock(); - } while ((blockSize > 0) && !Error()); - } - } -} diff --git a/Aga.Controls/NumericTextBox.cs b/Aga.Controls/NumericTextBox.cs deleted file mode 100644 index 0dcef4a..0000000 --- a/Aga.Controls/NumericTextBox.cs +++ /dev/null @@ -1,189 +0,0 @@ -using System; -using System.ComponentModel; -using System.Windows.Forms; -using System.Globalization; - - -namespace Aga.Controls -{ - /// - /// Restricts the entry of characters to digits, the negative sign, - /// the decimal point, and editing keystrokes (backspace). - /// It does not handle the AltGr key so any keys that can be created in any - /// combination with AltGr these are not filtered - /// - public class NumericTextBox : TextBox - { - private const int WM_PASTE = 0x302; - private NumberStyles numberStyle = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign; - - /// - /// Restricts the entry of characters to digits, the negative sign, - /// the decimal point, and editing keystrokes (backspace). - /// It does not handle the AltGr key - /// - /// - protected override void OnKeyPress(KeyPressEventArgs e) - { - base.OnKeyPress(e); - - e.Handled = invalidNumeric(e.KeyChar); - } - - - /// - /// Main method for verifying allowed keypresses. - /// This does not catch cut paste copy ... operations. - /// - /// - /// - private bool invalidNumeric(char key) - { - bool handled = false; - - NumberFormatInfo numberFormatInfo = CultureInfo.CurrentCulture.NumberFormat; - string decimalSeparator = numberFormatInfo.NumberDecimalSeparator; - string negativeSign = numberFormatInfo.NegativeSign; - - string keyString = key.ToString(); - - if (Char.IsDigit(key)) - { - // Digits are OK - } - else if (AllowDecimalSeparator && keyString.Equals(decimalSeparator)) - { - if (Text.IndexOf(decimalSeparator) >= 0) - { - handled = true; - } - } - else if (AllowNegativeSign && keyString.Equals(negativeSign)) - { - if (Text.IndexOf(negativeSign) >= 0) - { - handled = true; - } - } - else if (key == '\b') - { - // Backspace key is OK - } - else if ((ModifierKeys & (Keys.Control)) != 0) - { - // Let the edit control handle control and alt key combinations - } - else - { - // Swallow this invalid key and beep - handled = true; - } - return handled; - } - - - /// - /// Method invoked when Windows sends a message. - /// - /// Message from Windows. - /// - /// This is over-ridden so that the user can not use - /// cut or paste operations to bypass the TextChanging event. - /// This catches ContextMenu Paste, Shift+Insert, Ctrl+V, - /// While it is generally frowned upon to override WndProc, no - /// other simple mechanism was apparent to simultaneously and - /// transparently intercept so many different operations. - /// - protected override void WndProc(ref Message m) - { - // Switch to handle message... - switch (m.Msg) - { - case WM_PASTE: - { - // Get clipboard object to paste - IDataObject clipboardData = Clipboard.GetDataObject(); - - // Get text from clipboard data - string pasteText = (string)clipboardData.GetData( - DataFormats.UnicodeText); - - // Get the number of characters to replace - int selectionLength = SelectionLength; - - // If no replacement or insertion, we are done - if (pasteText.Length == 0) - { - break; - } - else if (selectionLength != 0) - { - base.Text = base.Text.Remove(SelectionStart, selectionLength); - } - - bool containsInvalidChars = false; - foreach (char c in pasteText) - { - if (containsInvalidChars) - { - break; - } - else if (invalidNumeric(c)) - { - containsInvalidChars = true; - } - } - - if (!containsInvalidChars) - { - base.Text = base.Text.Insert(SelectionStart, pasteText); - } - - return; - } - - } - base.WndProc(ref m); - } - - - public int IntValue - { - get - { - int intValue; - Int32.TryParse(this.Text, numberStyle, CultureInfo.CurrentCulture.NumberFormat, out intValue); - return intValue; - } - } - - public decimal DecimalValue - { - get - { - decimal decimalValue; - Decimal.TryParse(this.Text, numberStyle, CultureInfo.CurrentCulture.NumberFormat, out decimalValue); - return decimalValue; - } - } - - - private bool allowNegativeSign; - [DefaultValue(true)] - public bool AllowNegativeSign - { - get { return allowNegativeSign; } - set { allowNegativeSign = value; } - } - - private bool allowDecimalSeparator; - [DefaultValue(true)] - public bool AllowDecimalSeparator - { - get { return allowDecimalSeparator; } - set { allowDecimalSeparator = value; } - } - - } - -} diff --git a/Aga.Controls/PerformanceAnalyzer.cs b/Aga.Controls/PerformanceAnalyzer.cs deleted file mode 100644 index 94fdd6e..0000000 --- a/Aga.Controls/PerformanceAnalyzer.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Diagnostics; - -namespace Aga.Controls -{ - /// - /// Is used to analyze code performance - /// - public static class PerformanceAnalyzer - { - public class PerformanceInfo - { - private string _name; - public string Name - { - get { return _name; } - } - - private int _count = 0; - public int Count - { - get { return _count; } - set { _count = value; } - } - - private double _totalTime = 0; - public double TotalTime - { - get { return _totalTime; } - set { _totalTime = value; } - } - - private Int64 _start; - public Int64 Start - { - get { return _start; } - set { _start = value; } - } - - public PerformanceInfo(string name) - { - _name = name; - } - } - - private static Dictionary _performances = new Dictionary(); - - public static IEnumerable Performances - { - get - { - return _performances.Values; - } - } - - [Conditional("DEBUG")] - public static void Start(string pieceOfCode) - { - PerformanceInfo info = null; - lock(_performances) - { - if (_performances.ContainsKey(pieceOfCode)) - info = _performances[pieceOfCode]; - else - { - info = new PerformanceInfo(pieceOfCode); - _performances.Add(pieceOfCode, info); - } - - info.Count++; - info.Start = TimeCounter.GetStartValue(); - } - } - - [Conditional("DEBUG")] - public static void Finish(string pieceOfCode) - { - lock (_performances) - { - if (_performances.ContainsKey(pieceOfCode)) - { - PerformanceInfo info = _performances[pieceOfCode]; - info.Count++; - info.TotalTime += TimeCounter.Finish(info.Start); - } - } - } - - public static void Reset() - { - _performances.Clear(); - } - - public static string GenerateReport() - { - return GenerateReport(0); - } - - public static string GenerateReport(string mainPieceOfCode) - { - if (_performances.ContainsKey(mainPieceOfCode)) - return GenerateReport(_performances[mainPieceOfCode].TotalTime); - else - return GenerateReport(0); - } - - public static string GenerateReport(double totalTime) - { - StringBuilder sb = new StringBuilder(); - int len = 0; - foreach (PerformanceInfo info in Performances) - len = Math.Max(info.Name.Length, len); - - sb.AppendLine("Name".PadRight(len) + " Count Total Time, ms Avg. Time, ms Percentage, %"); - sb.AppendLine("----------------------------------------------------------------------------------------------"); - foreach (PerformanceInfo info in Performances) - { - sb.Append(info.Name.PadRight(len)); - double p = 0; - double avgt = 0; - if (totalTime != 0) - p = info.TotalTime / totalTime; - if (info.Count > 0) - avgt = info.TotalTime * 1000 / info.Count; - string c = info.Count.ToString("0,0").PadRight(20); - string tt = (info.TotalTime * 1000).ToString("0,0.00").PadRight(20); - string t = avgt.ToString("0.0000").PadRight(20); - string sp = (p * 100).ToString("###").PadRight(20); - sb.AppendFormat(" " + c + tt + t + sp + "\n"); - } - return sb.ToString(); - } - } -} diff --git a/Aga.Controls/Properties/Resources.Designer.cs b/Aga.Controls/Properties/Resources.Designer.cs deleted file mode 100644 index a1aaf8c..0000000 --- a/Aga.Controls/Properties/Resources.Designer.cs +++ /dev/null @@ -1,133 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.235 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Aga.Controls.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Aga.Controls.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - internal static System.Drawing.Bitmap check { - get { - object obj = ResourceManager.GetObject("check", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - internal static byte[] DVSplit { - get { - object obj = ResourceManager.GetObject("DVSplit", resourceCulture); - return ((byte[])(obj)); - } - } - - internal static System.Drawing.Bitmap Folder { - get { - object obj = ResourceManager.GetObject("Folder", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - internal static System.Drawing.Bitmap FolderClosed { - get { - object obj = ResourceManager.GetObject("FolderClosed", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - internal static System.Drawing.Bitmap Leaf { - get { - object obj = ResourceManager.GetObject("Leaf", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - internal static byte[] loading_icon { - get { - object obj = ResourceManager.GetObject("loading_icon", resourceCulture); - return ((byte[])(obj)); - } - } - - internal static System.Drawing.Bitmap minus { - get { - object obj = ResourceManager.GetObject("minus", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - internal static System.Drawing.Bitmap plus { - get { - object obj = ResourceManager.GetObject("plus", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - internal static System.Drawing.Bitmap uncheck { - get { - object obj = ResourceManager.GetObject("uncheck", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - internal static System.Drawing.Bitmap unknown { - get { - object obj = ResourceManager.GetObject("unknown", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/Aga.Controls/Properties/Resources.resx b/Aga.Controls/Properties/Resources.resx deleted file mode 100644 index a23f6cc..0000000 --- a/Aga.Controls/Properties/Resources.resx +++ /dev/null @@ -1,151 +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 - - - - ..\Resources\check.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\DVSplit.cur;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\Folder.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\FolderClosed.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Leaf.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\loading_icon;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\minus.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\plus.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\uncheck.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\unknown.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - \ No newline at end of file diff --git a/Aga.Controls/ResourceHelper.cs b/Aga.Controls/ResourceHelper.cs deleted file mode 100644 index 6f865e0..0000000 --- a/Aga.Controls/ResourceHelper.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.IO; -using System.Reflection; -using System.Windows.Forms; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls -{ - public static class ResourceHelper - { - // VSpilt Cursor with Innerline (symbolisize hidden column) - private static Cursor _dVSplitCursor = GetCursor(Properties.Resources.DVSplit); - public static Cursor DVSplitCursor - { - get { return _dVSplitCursor; } - } - - private static GifDecoder _loadingIcon = GetGifDecoder(Properties.Resources.loading_icon); - public static GifDecoder LoadingIcon - { - get { return _loadingIcon; } - } - - /// - /// Help function to convert byte[] from resource into Cursor Type - /// - /// - /// - private static Cursor GetCursor(byte[] data) - { - using (MemoryStream s = new MemoryStream(data)) - return new Cursor(s); - } - - /// - /// Help function to convert byte[] from resource into GifDecoder Type - /// - /// - /// - private static GifDecoder GetGifDecoder(byte[] data) - { - using(MemoryStream ms = new MemoryStream(data)) - return new GifDecoder(ms, true); - } - - } -} diff --git a/Aga.Controls/Resources/DVSplit.cur b/Aga.Controls/Resources/DVSplit.cur deleted file mode 100644 index 2e25be2..0000000 Binary files a/Aga.Controls/Resources/DVSplit.cur and /dev/null differ diff --git a/Aga.Controls/Resources/Folder.bmp b/Aga.Controls/Resources/Folder.bmp deleted file mode 100644 index f515f9e..0000000 Binary files a/Aga.Controls/Resources/Folder.bmp and /dev/null differ diff --git a/Aga.Controls/Resources/FolderClosed.bmp b/Aga.Controls/Resources/FolderClosed.bmp deleted file mode 100644 index 7e848d4..0000000 Binary files a/Aga.Controls/Resources/FolderClosed.bmp and /dev/null differ diff --git a/Aga.Controls/Resources/Leaf.bmp b/Aga.Controls/Resources/Leaf.bmp deleted file mode 100644 index 79254b2..0000000 Binary files a/Aga.Controls/Resources/Leaf.bmp and /dev/null differ diff --git a/Aga.Controls/Resources/check.bmp b/Aga.Controls/Resources/check.bmp deleted file mode 100644 index 11c9cfa..0000000 Binary files a/Aga.Controls/Resources/check.bmp and /dev/null differ diff --git a/Aga.Controls/Resources/loading_icon b/Aga.Controls/Resources/loading_icon deleted file mode 100644 index ca716ed..0000000 Binary files a/Aga.Controls/Resources/loading_icon and /dev/null differ diff --git a/Aga.Controls/Resources/minus.bmp b/Aga.Controls/Resources/minus.bmp deleted file mode 100644 index c6539d9..0000000 Binary files a/Aga.Controls/Resources/minus.bmp and /dev/null differ diff --git a/Aga.Controls/Resources/plus.bmp b/Aga.Controls/Resources/plus.bmp deleted file mode 100644 index d54ab87..0000000 Binary files a/Aga.Controls/Resources/plus.bmp and /dev/null differ diff --git a/Aga.Controls/Resources/uncheck.bmp b/Aga.Controls/Resources/uncheck.bmp deleted file mode 100644 index 673b1ba..0000000 Binary files a/Aga.Controls/Resources/uncheck.bmp and /dev/null differ diff --git a/Aga.Controls/Resources/unknown.bmp b/Aga.Controls/Resources/unknown.bmp deleted file mode 100644 index ed34bd4..0000000 Binary files a/Aga.Controls/Resources/unknown.bmp and /dev/null differ diff --git a/Aga.Controls/StringCollectionEditor.cs b/Aga.Controls/StringCollectionEditor.cs deleted file mode 100644 index 411fa49..0000000 --- a/Aga.Controls/StringCollectionEditor.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.ComponentModel.Design; - -namespace Aga.Controls -{ - public class StringCollectionEditor : CollectionEditor - { - public StringCollectionEditor(Type type): base(type) - { - } - - protected override Type CreateCollectionItemType() - { - return typeof(string); - } - - protected override object CreateInstance(Type itemType) - { - return ""; - } - } -} diff --git a/Aga.Controls/TextHelper.cs b/Aga.Controls/TextHelper.cs deleted file mode 100644 index 10b7475..0000000 --- a/Aga.Controls/TextHelper.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; - -namespace Aga.Controls -{ - public static class TextHelper - { - public static StringAlignment TranslateAligment(HorizontalAlignment alignment) - { - if (alignment == HorizontalAlignment.Left) - return StringAlignment.Near; - else if (alignment == HorizontalAlignment.Right) - return StringAlignment.Far; - else - return StringAlignment.Center; - } - - public static TextFormatFlags TranslateAligmentToFlag(HorizontalAlignment alignment) - { - if (alignment == HorizontalAlignment.Left) - return TextFormatFlags.Left; - else if (alignment == HorizontalAlignment.Right) - return TextFormatFlags.Right; - else - return TextFormatFlags.HorizontalCenter; - } - - public static TextFormatFlags TranslateTrimmingToFlag(StringTrimming trimming) - { - if (trimming == StringTrimming.EllipsisCharacter) - return TextFormatFlags.EndEllipsis; - else if (trimming == StringTrimming.EllipsisPath) - return TextFormatFlags.PathEllipsis; - if (trimming == StringTrimming.EllipsisWord) - return TextFormatFlags.WordEllipsis; - if (trimming == StringTrimming.Word) - return TextFormatFlags.WordBreak; - else - return TextFormatFlags.Default; - } - } -} diff --git a/Aga.Controls/Threading/AbortableThreadPool.cs b/Aga.Controls/Threading/AbortableThreadPool.cs deleted file mode 100644 index 5424e89..0000000 --- a/Aga.Controls/Threading/AbortableThreadPool.cs +++ /dev/null @@ -1,118 +0,0 @@ -// Stephen Toub -// stoub@microsoft.com - -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; - -namespace Aga.Controls.Threading -{ - public class AbortableThreadPool - { - private LinkedList _callbacks = new LinkedList(); - private Dictionary _threads = new Dictionary(); - - public WorkItem QueueUserWorkItem(WaitCallback callback) - { - return QueueUserWorkItem(callback, null); - } - - public WorkItem QueueUserWorkItem(WaitCallback callback, object state) - { - if (callback == null) throw new ArgumentNullException("callback"); - - WorkItem item = new WorkItem(callback, state, ExecutionContext.Capture()); - lock (_callbacks) - { - _callbacks.AddLast(item); - } - ThreadPool.QueueUserWorkItem(new WaitCallback(HandleItem)); - return item; - } - - private void HandleItem(object ignored) - { - WorkItem item = null; - try - { - lock (_callbacks) - { - if (_callbacks.Count > 0) - { - item = _callbacks.First.Value; - _callbacks.RemoveFirst(); - } - if (item == null) - return; - _threads.Add(item, Thread.CurrentThread); - - } - ExecutionContext.Run(item.Context, - delegate { item.Callback(item.State); }, null); - } - finally - { - lock (_callbacks) - { - if (item != null) - _threads.Remove(item); - } - } - } - - public bool IsMyThread(Thread thread) - { - lock (_callbacks) - { - foreach (Thread t in _threads.Values) - { - if (t == thread) - return true; - } - return false; - } - } - - public WorkItemStatus Cancel(WorkItem item, bool allowAbort) - { - if (item == null) - throw new ArgumentNullException("item"); - lock (_callbacks) - { - LinkedListNode node = _callbacks.Find(item); - if (node != null) - { - _callbacks.Remove(node); - return WorkItemStatus.Queued; - } - else if (_threads.ContainsKey(item)) - { - if (allowAbort) - { - _threads[item].Abort(); - _threads.Remove(item); - return WorkItemStatus.Aborted; - } - else - return WorkItemStatus.Executing; - } - else - return WorkItemStatus.Completed; - } - } - - public void CancelAll(bool allowAbort) - { - lock (_callbacks) - { - _callbacks.Clear(); - if (allowAbort) - { - foreach (Thread t in _threads.Values) - t.Abort(); - } - } - } - } -} diff --git a/Aga.Controls/Threading/WorkItem.cs b/Aga.Controls/Threading/WorkItem.cs deleted file mode 100644 index 0bcaf4c..0000000 --- a/Aga.Controls/Threading/WorkItem.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; - -namespace Aga.Controls.Threading -{ - public sealed class WorkItem - { - private WaitCallback _callback; - private object _state; - private ExecutionContext _ctx; - - internal WorkItem(WaitCallback wc, object state, ExecutionContext ctx) - { - _callback = wc; - _state = state; - _ctx = ctx; - } - - internal WaitCallback Callback - { - get - { - return _callback; - } - } - - internal object State - { - get - { - return _state; - } - } - - internal ExecutionContext Context - { - get - { - return _ctx; - } - } - } -} diff --git a/Aga.Controls/Threading/WorkItemStatus.cs b/Aga.Controls/Threading/WorkItemStatus.cs deleted file mode 100644 index ec4becb..0000000 --- a/Aga.Controls/Threading/WorkItemStatus.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Threading -{ - public enum WorkItemStatus - { - Completed, - Queued, - Executing, - Aborted - } -} diff --git a/Aga.Controls/TimeCounter.cs b/Aga.Controls/TimeCounter.cs deleted file mode 100644 index e06c180..0000000 --- a/Aga.Controls/TimeCounter.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Runtime.InteropServices; -using System.Diagnostics.CodeAnalysis; - -namespace Aga.Controls -{ - /// - /// High resolution timer, used to test performance - /// - public static class TimeCounter - { - private static Int64 _start; - - /// - /// Start time counting - /// - public static void Start() - { - _start = 0; - QueryPerformanceCounter(ref _start); - } - - public static Int64 GetStartValue() - { - Int64 t = 0; - QueryPerformanceCounter(ref t); - return t; - } - - /// - /// Finish time counting - /// - /// time in seconds elapsed from Start till Finish - public static double Finish() - { - return Finish(_start); - } - - public static double Finish(Int64 start) - { - Int64 finish = 0; - QueryPerformanceCounter(ref finish); - - Int64 freq = 0; - QueryPerformanceFrequency(ref freq); - return (finish - start) / (double)freq; - } - - [DllImport("Kernel32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool QueryPerformanceCounter(ref Int64 performanceCount); - - [DllImport("Kernel32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool QueryPerformanceFrequency(ref Int64 frequency); - } -} diff --git a/Aga.Controls/Tree/AutoRowHeightLayout.cs b/Aga.Controls/Tree/AutoRowHeightLayout.cs deleted file mode 100644 index 953df02..0000000 --- a/Aga.Controls/Tree/AutoRowHeightLayout.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public class AutoRowHeightLayout: IRowLayout - { - private DrawContext _measureContext; - private TreeViewAdv _treeView; - private List _rowCache; - - public AutoRowHeightLayout(TreeViewAdv treeView, int rowHeight) - { - _rowCache = new List(); - _treeView = treeView; - PreferredRowHeight = rowHeight; - _measureContext = new DrawContext(); - _measureContext.Graphics = Graphics.FromImage(new Bitmap(1, 1)); - } - - private int _rowHeight; - public int PreferredRowHeight - { - get { return _rowHeight; } - set { _rowHeight = value; } - } - - - public int PageRowCount - { - get - { - if (_treeView.RowCount == 0) - return 0; - else - { - int pageHeight = _treeView.DisplayRectangle.Height - _treeView.ColumnHeaderHeight; - int y = 0; - for (int i = _treeView.RowCount - 1; i >= 0; i--) - { - y += GetRowHeight(i); - if (y > pageHeight) - return Math.Max(0, _treeView.RowCount - 1 - i); - } - return _treeView.RowCount; - } - } - } - - public int CurrentPageSize - { - get - { - if (_treeView.RowCount == 0) - return 0; - else - { - int pageHeight = _treeView.DisplayRectangle.Height - _treeView.ColumnHeaderHeight; - int y = 0; - for (int i = _treeView.FirstVisibleRow; i < _treeView.RowCount; i++) - { - y += GetRowHeight(i); - if (y > pageHeight) - return Math.Max(0, i - _treeView.FirstVisibleRow); - } - return Math.Max(0, _treeView.RowCount - _treeView.FirstVisibleRow); - } - } - } - - public Rectangle GetRowBounds(int rowNo) - { - if (rowNo >= _rowCache.Count) - { - int count = _rowCache.Count; - int y = count > 0 ? _rowCache[count - 1].Bottom : 0; - for (int i = count; i <= rowNo; i++) - { - int height = GetRowHeight(i); - _rowCache.Add(new Rectangle(0, y, 0, height)); - y += height; - } - if (rowNo < _rowCache.Count - 1) - return Rectangle.Empty; - } - if (rowNo >= 0 && rowNo < _rowCache.Count) - return _rowCache[rowNo]; - else - return Rectangle.Empty; - } - - private int GetRowHeight(int rowNo) - { - if (rowNo < _treeView.RowMap.Count) - { - TreeNodeAdv node = _treeView.RowMap[rowNo]; - if (node.Height == null) - { - int res = 0; - _measureContext.Font = _treeView.Font; - foreach (NodeControl nc in _treeView.NodeControls) - { - int h = nc.GetActualSize(node, _measureContext).Height; - if (h > res) - res = h; - } - node.Height = res; - } - return node.Height.Value; - } - else - return 0; - } - - public int GetRowAt(Point point) - { - int py = point.Y - _treeView.ColumnHeaderHeight; - int y = 0; - for (int i = _treeView.FirstVisibleRow; i < _treeView.RowCount; i++) - { - int h = GetRowHeight(i); - if (py >= y && py < y + h) - return i; - else - y += h; - } - return -1; - } - - public int GetFirstRow(int lastPageRow) - { - int pageHeight = _treeView.DisplayRectangle.Height - _treeView.ColumnHeaderHeight; - int y = 0; - for (int i = lastPageRow; i >= 0; i--) - { - y += GetRowHeight(i); - if (y > pageHeight) - return Math.Max(0, i + 1); - } - return 0; - } - - public void ClearCache() - { - _rowCache.Clear(); - } - } -} diff --git a/Aga.Controls/Tree/ClassDiagram.cd b/Aga.Controls/Tree/ClassDiagram.cd deleted file mode 100644 index 1a44c01..0000000 --- a/Aga.Controls/Tree/ClassDiagram.cd +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - Tree\TreeModel.cs - AAAkgAAAAAAQAGQAAAAAEAAAEAACQAAAUAAAAAAAAQE= - - - - - - - - - - - - Tree\TreePath.cs - GABAAAAAAAACAAAAAAIAAAAAAAAACAAAAAAAAAAAAAA= - - - - - - - - - - - Tree\Node.cs - AAAgABAAgCAAAAAAAgAEVAAQAAAQAAAIAAsgCAAAAAA= - - - - - - - - - - Tree\Node.cs - - - - - - - - Tree\NodeControls\NodeControl.cs - AAAAAAAAgAAAgsIAAAhAQAAwAAAAEAAAAEAIAAAAAAA= - - - - - - - - Tree\ITreeModel.cs - AAAEAAAAAAAAAEQAAAAAEAAAEAAAQAAAAAAAAAAAAAA= - - - - - - Tree\IToolTipProvider.cs - AAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAA= - - - \ No newline at end of file diff --git a/Aga.Controls/Tree/ColumnCollection.cs b/Aga.Controls/Tree/ColumnCollection.cs deleted file mode 100644 index b5c6aff..0000000 --- a/Aga.Controls/Tree/ColumnCollection.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Collections.ObjectModel; - -namespace Aga.Controls.Tree -{ - /*internal class ColumnCollection: Collection - { - public int TotalWidth - { - get - { - int res = 0; - foreach (Column c in Items) - res += c.Width; - return res; - } - } - }*/ -} diff --git a/Aga.Controls/Tree/DrawContext.cs b/Aga.Controls/Tree/DrawContext.cs deleted file mode 100644 index 4fe8b1d..0000000 --- a/Aga.Controls/Tree/DrawContext.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public struct DrawContext - { - private Graphics _graphics; - public Graphics Graphics - { - get { return _graphics; } - set { _graphics = value; } - } - - private Rectangle _bounds; - public Rectangle Bounds - { - get { return _bounds; } - set { _bounds = value; } - } - - private Font _font; - public Font Font - { - get { return _font; } - set { _font = value; } - } - - private DrawSelectionMode _drawSelection; - public DrawSelectionMode DrawSelection - { - get { return _drawSelection; } - set { _drawSelection = value; } - } - - private bool _drawFocus; - public bool DrawFocus - { - get { return _drawFocus; } - set { _drawFocus = value; } - } - - private NodeControl _currentEditorOwner; - public NodeControl CurrentEditorOwner - { - get { return _currentEditorOwner; } - set { _currentEditorOwner = value; } - } - - private bool _enabled; - public bool Enabled - { - get { return _enabled; } - set { _enabled = value; } - } - } -} diff --git a/Aga.Controls/Tree/DropNodeValidatingEventArgs.cs b/Aga.Controls/Tree/DropNodeValidatingEventArgs.cs deleted file mode 100644 index fb7ef00..0000000 --- a/Aga.Controls/Tree/DropNodeValidatingEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - public class DropNodeValidatingEventArgs: EventArgs - { - Point _point; - TreeNodeAdv _node; - - public DropNodeValidatingEventArgs(Point point, TreeNodeAdv node) - { - _point = point; - _node = node; - } - - public Point Point - { - get { return _point; } - } - - public TreeNodeAdv Node - { - get { return _node; } - set { _node = value; } - } - } -} diff --git a/Aga.Controls/Tree/DropPosition.cs b/Aga.Controls/Tree/DropPosition.cs deleted file mode 100644 index 7356326..0000000 --- a/Aga.Controls/Tree/DropPosition.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - public struct DropPosition - { - private TreeNodeAdv _node; - public TreeNodeAdv Node - { - get { return _node; } - set { _node = value; } - } - - private NodePosition _position; - public NodePosition Position - { - get { return _position; } - set { _position = value; } - } - } -} diff --git a/Aga.Controls/Tree/EditorContext.cs b/Aga.Controls/Tree/EditorContext.cs deleted file mode 100644 index ffea2fa..0000000 --- a/Aga.Controls/Tree/EditorContext.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public struct EditorContext - { - private TreeNodeAdv _currentNode; - public TreeNodeAdv CurrentNode - { - get { return _currentNode; } - set { _currentNode = value; } - } - - private Control _editor; - public Control Editor - { - get { return _editor; } - set { _editor = value; } - } - - private NodeControl _owner; - public NodeControl Owner - { - get { return _owner; } - set { _owner = value; } - } - - private Rectangle _bounds; - public Rectangle Bounds - { - get { return _bounds; } - set { _bounds = value; } - } - - private DrawContext _drawContext; - public DrawContext DrawContext - { - get { return _drawContext; } - set { _drawContext = value; } - } - } -} diff --git a/Aga.Controls/Tree/Enums.cs b/Aga.Controls/Tree/Enums.cs deleted file mode 100644 index 3a83e9a..0000000 --- a/Aga.Controls/Tree/Enums.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - public enum DrawSelectionMode - { - None, Active, Inactive, FullRowSelect - } - - public enum TreeSelectionMode - { - Single, Multi, MultiSameParent - } - - public enum NodePosition - { - Inside, Before, After - } - - public enum VerticalAlignment - { - Top, Bottom, Center - } - - public enum IncrementalSearchMode - { - None, Standard, Continuous - } - - [Flags] - public enum GridLineStyle - { - None = 0, - Horizontal = 1, - Vertical = 2, - HorizontalAndVertical = 3 - } - - public enum ImageScaleMode - { - /// - /// Don't scale - /// - Clip, - /// - /// Scales image to fit the display rectangle, aspect ratio is not fixed. - /// - Fit, - /// - /// Scales image down if it is larger than display rectangle, taking aspect ratio into account - /// - ScaleDown, - /// - /// Scales image up if it is smaller than display rectangle, taking aspect ratio into account - /// - ScaleUp, - /// - /// Scales image to match the display rectangle, taking aspect ratio into account - /// - AlwaysScale, - - } -} diff --git a/Aga.Controls/Tree/FixedRowHeightLayout.cs b/Aga.Controls/Tree/FixedRowHeightLayout.cs deleted file mode 100644 index 316b3dc..0000000 --- a/Aga.Controls/Tree/FixedRowHeightLayout.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - internal class FixedRowHeightLayout : IRowLayout - { - private TreeViewAdv _treeView; - - public FixedRowHeightLayout(TreeViewAdv treeView, int rowHeight) - { - _treeView = treeView; - PreferredRowHeight = rowHeight; - } - - private int _rowHeight; - public int PreferredRowHeight - { - get { return _rowHeight; } - set { _rowHeight = value; } - } - - public Rectangle GetRowBounds(int rowNo) - { - return new Rectangle(0, rowNo * _rowHeight, 0, _rowHeight); - } - - public int PageRowCount - { - get - { - return Math.Max((_treeView.DisplayRectangle.Height - _treeView.ColumnHeaderHeight) / _rowHeight, 0); - } - } - - public int CurrentPageSize - { - get - { - return PageRowCount; - } - } - - public int GetRowAt(Point point) - { - point = new Point(point.X, point.Y + (_treeView.FirstVisibleRow * _rowHeight) - _treeView.ColumnHeaderHeight); - return point.Y / _rowHeight; - } - - public int GetFirstRow(int lastPageRow) - { - return Math.Max(0, lastPageRow - PageRowCount + 1); - } - - public void ClearCache() - { - } - } -} diff --git a/Aga.Controls/Tree/IRowLayout.cs b/Aga.Controls/Tree/IRowLayout.cs deleted file mode 100644 index 9a9018f..0000000 --- a/Aga.Controls/Tree/IRowLayout.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - internal interface IRowLayout - { - int PreferredRowHeight - { - get; - set; - } - - int PageRowCount - { - get; - } - - int CurrentPageSize - { - get; - } - - Rectangle GetRowBounds(int rowNo); - - int GetRowAt(Point point); - - int GetFirstRow(int lastPageRow); - - void ClearCache(); - } -} diff --git a/Aga.Controls/Tree/IToolTipProvider.cs b/Aga.Controls/Tree/IToolTipProvider.cs deleted file mode 100644 index 3f3e086..0000000 --- a/Aga.Controls/Tree/IToolTipProvider.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public interface IToolTipProvider - { - string GetToolTip(TreeNodeAdv node, NodeControl nodeControl); - } -} diff --git a/Aga.Controls/Tree/ITreeModel.cs b/Aga.Controls/Tree/ITreeModel.cs deleted file mode 100644 index 680d255..0000000 --- a/Aga.Controls/Tree/ITreeModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Collections; - -namespace Aga.Controls.Tree -{ - public interface ITreeModel - { - IEnumerable GetChildren(TreePath treePath); - bool IsLeaf(TreePath treePath); - - event EventHandler NodesChanged; - event EventHandler NodesInserted; - event EventHandler NodesRemoved; - event EventHandler StructureChanged; - } -} diff --git a/Aga.Controls/Tree/IncrementalSearch.cs b/Aga.Controls/Tree/IncrementalSearch.cs deleted file mode 100644 index 1390562..0000000 --- a/Aga.Controls/Tree/IncrementalSearch.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Aga.Controls.Tree.NodeControls; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; - -namespace Aga.Controls.Tree -{ - internal class IncrementalSearch - { - private const int SearchTimeout = 300; //end of incremental search timeot in msec - - private TreeViewAdv _tree; - private TreeNodeAdv _currentNode; - private string _searchString = ""; - private DateTime _lastKeyPressed = DateTime.Now; - - public IncrementalSearch(TreeViewAdv tree) - { - _tree = tree; - } - - public void Search(Char value) - { - if (!Char.IsControl(value)) - { - Char ch = Char.ToLowerInvariant(value); - DateTime dt = DateTime.Now; - TimeSpan ts = dt - _lastKeyPressed; - _lastKeyPressed = dt; - if (ts.TotalMilliseconds < SearchTimeout) - { - if (_searchString == value.ToString()) - FirstCharSearch(ch); - else - ContinuousSearch(ch); - } - else - { - FirstCharSearch(ch); - } - } - } - - private void ContinuousSearch(Char value) - { - if (value == ' ' && String.IsNullOrEmpty(_searchString)) - return; //Ingnore leading space - - _searchString += value; - DoContinuousSearch(); - } - - private void FirstCharSearch(Char value) - { - if (value == ' ') - return; - - _searchString = value.ToString(); - TreeNodeAdv node = null; - if (_tree.SelectedNode != null) - node = _tree.SelectedNode.NextVisibleNode; - if (node == null) - node = _tree.Root.NextVisibleNode; - - if (node != null) - foreach (string label in IterateNodeLabels(node)) - { - if (label.StartsWith(_searchString)) - { - _tree.SelectedNode = _currentNode; - return; - } - } - } - - public virtual void EndSearch() - { - _currentNode = null; - _searchString = ""; - } - - protected IEnumerable IterateNodeLabels(TreeNodeAdv start) - { - _currentNode = start; - while(_currentNode != null) - { - foreach (string label in GetNodeLabels(_currentNode)) - yield return label; - - _currentNode = _currentNode.NextVisibleNode; - if (_currentNode == null) - _currentNode = _tree.Root; - - if (start == _currentNode) - break; - } - } - - private IEnumerable GetNodeLabels(TreeNodeAdv node) - { - foreach (NodeControl nc in _tree.NodeControls) - { - BindableControl bc = nc as BindableControl; - if (bc != null && bc.IncrementalSearchEnabled) - { - object obj = bc.GetValue(node); - if (obj != null) - yield return obj.ToString().ToLowerInvariant(); - } - } - } - - private bool DoContinuousSearch() - { - bool found = false; - if (!String.IsNullOrEmpty(_searchString)) - { - TreeNodeAdv node = null; - if (_tree.SelectedNode != null) - node = _tree.SelectedNode; - if (node == null) - node = _tree.Root.NextVisibleNode; - - if (!String.IsNullOrEmpty(_searchString)) - { - foreach (string label in IterateNodeLabels(node)) - { - if (label.StartsWith(_searchString)) - { - found = true; - _tree.SelectedNode = _currentNode; - break; - } - } - } - } - return found; - } - - } -} diff --git a/Aga.Controls/Tree/Input/ClickColumnState.cs b/Aga.Controls/Tree/Input/ClickColumnState.cs deleted file mode 100644 index 12146c9..0000000 --- a/Aga.Controls/Tree/Input/ClickColumnState.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - internal class ClickColumnState : ColumnState - { - private Point _location; - - public ClickColumnState(TreeViewAdv tree, TreeColumn column, Point location) - : base(tree, column) - { - _location = location; - } - - public override void KeyDown(KeyEventArgs args) - { - } - - public override void MouseDown(TreeNodeAdvMouseEventArgs args) - { - } - - public override bool MouseMove(MouseEventArgs args) - { - if (TreeViewAdv.Dist(_location, args.Location) > TreeViewAdv.ItemDragSensivity - && Tree.AllowColumnReorder) - { - Tree.Input = new ReorderColumnState(Tree, Column, args.Location); - Tree.UpdateView(); - } - return true; - } - - public override void MouseUp(TreeNodeAdvMouseEventArgs args) - { - Tree.ChangeInput(); - Tree.UpdateView(); - Tree.OnColumnClicked(Column); - } - } -} diff --git a/Aga.Controls/Tree/Input/ColumnState.cs b/Aga.Controls/Tree/Input/ColumnState.cs deleted file mode 100644 index 2b8fc7d..0000000 --- a/Aga.Controls/Tree/Input/ColumnState.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - internal abstract class ColumnState : InputState - { - private TreeColumn _column; - public TreeColumn Column - { - get { return _column; } - } - - public ColumnState(TreeViewAdv tree, TreeColumn column) - : base(tree) - { - _column = column; - } - } -} diff --git a/Aga.Controls/Tree/Input/InputState.cs b/Aga.Controls/Tree/Input/InputState.cs deleted file mode 100644 index b347d4f..0000000 --- a/Aga.Controls/Tree/Input/InputState.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Windows.Forms; -namespace Aga.Controls.Tree -{ - internal abstract class InputState - { - private TreeViewAdv _tree; - - public TreeViewAdv Tree - { - get { return _tree; } - } - - public InputState(TreeViewAdv tree) - { - _tree = tree; - } - - public abstract void KeyDown(System.Windows.Forms.KeyEventArgs args); - public abstract void MouseDown(TreeNodeAdvMouseEventArgs args); - public abstract void MouseUp(TreeNodeAdvMouseEventArgs args); - - /// - /// handle OnMouseMove event - /// - /// - /// true if event was handled and should be dispatched - public virtual bool MouseMove(MouseEventArgs args) - { - return false; - } - - public virtual void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) - { - } - } -} diff --git a/Aga.Controls/Tree/Input/InputWithControl.cs b/Aga.Controls/Tree/Input/InputWithControl.cs deleted file mode 100644 index 6559b67..0000000 --- a/Aga.Controls/Tree/Input/InputWithControl.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - internal class InputWithControl: NormalInputState - { - public InputWithControl(TreeViewAdv tree): base(tree) - { - } - - protected override void DoMouseOperation(TreeNodeAdvMouseEventArgs args) - { - if (Tree.SelectionMode == TreeSelectionMode.Single) - { - base.DoMouseOperation(args); - } - else if (CanSelect(args.Node)) - { - args.Node.IsSelected = !args.Node.IsSelected; - Tree.SelectionStart = args.Node; - } - } - - protected override void MouseDownAtEmptySpace(TreeNodeAdvMouseEventArgs args) - { - } - } -} diff --git a/Aga.Controls/Tree/Input/InputWithShift.cs b/Aga.Controls/Tree/Input/InputWithShift.cs deleted file mode 100644 index 777fc7a..0000000 --- a/Aga.Controls/Tree/Input/InputWithShift.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - internal class InputWithShift: NormalInputState - { - public InputWithShift(TreeViewAdv tree): base(tree) - { - } - - protected override void FocusRow(TreeNodeAdv node) - { - Tree.SuspendSelectionEvent = true; - try - { - if (Tree.SelectionMode == TreeSelectionMode.Single || Tree.SelectionStart == null) - base.FocusRow(node); - else if (CanSelect(node)) - { - SelectAllFromStart(node); - Tree.CurrentNode = node; - Tree.ScrollTo(node); - } - } - finally - { - Tree.SuspendSelectionEvent = false; - } - } - - protected override void DoMouseOperation(TreeNodeAdvMouseEventArgs args) - { - if (Tree.SelectionMode == TreeSelectionMode.Single || Tree.SelectionStart == null) - { - base.DoMouseOperation(args); - } - else if (CanSelect(args.Node)) - { - Tree.SuspendSelectionEvent = true; - try - { - SelectAllFromStart(args.Node); - } - finally - { - Tree.SuspendSelectionEvent = false; - } - } - } - - protected override void MouseDownAtEmptySpace(TreeNodeAdvMouseEventArgs args) - { - } - - private void SelectAllFromStart(TreeNodeAdv node) - { - Tree.ClearSelectionInternal(); - int a = node.Row; - int b = Tree.SelectionStart.Row; - for (int i = Math.Min(a, b); i <= Math.Max(a, b); i++) - { - if (Tree.SelectionMode == TreeSelectionMode.Multi || Tree.RowMap[i].Parent == node.Parent) - Tree.RowMap[i].IsSelected = true; - } - } - } -} diff --git a/Aga.Controls/Tree/Input/NormalInputState.cs b/Aga.Controls/Tree/Input/NormalInputState.cs deleted file mode 100644 index 7a66be9..0000000 --- a/Aga.Controls/Tree/Input/NormalInputState.cs +++ /dev/null @@ -1,202 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; - -namespace Aga.Controls.Tree -{ - internal class NormalInputState : InputState - { - private bool _mouseDownFlag = false; - - public NormalInputState(TreeViewAdv tree) : base(tree) - { - } - - public override void KeyDown(KeyEventArgs args) - { - if (Tree.CurrentNode == null && Tree.Root.Nodes.Count > 0) - Tree.CurrentNode = Tree.Root.Nodes[0]; - - if (Tree.CurrentNode != null) - { - switch (args.KeyCode) - { - case Keys.Right: - if (!Tree.CurrentNode.IsExpanded) - Tree.CurrentNode.IsExpanded = true; - else if (Tree.CurrentNode.Nodes.Count > 0) - Tree.SelectedNode = Tree.CurrentNode.Nodes[0]; - args.Handled = true; - break; - case Keys.Left: - if (Tree.CurrentNode.IsExpanded) - Tree.CurrentNode.IsExpanded = false; - else if (Tree.CurrentNode.Parent != Tree.Root) - Tree.SelectedNode = Tree.CurrentNode.Parent; - args.Handled = true; - break; - case Keys.Down: - NavigateForward(1); - args.Handled = true; - break; - case Keys.Up: - NavigateBackward(1); - args.Handled = true; - break; - case Keys.PageDown: - NavigateForward(Math.Max(1, Tree.CurrentPageSize - 1)); - args.Handled = true; - break; - case Keys.PageUp: - NavigateBackward(Math.Max(1, Tree.CurrentPageSize - 1)); - args.Handled = true; - break; - case Keys.Home: - if (Tree.RowMap.Count > 0) - FocusRow(Tree.RowMap[0]); - args.Handled = true; - break; - case Keys.End: - if (Tree.RowMap.Count > 0) - FocusRow(Tree.RowMap[Tree.RowMap.Count-1]); - args.Handled = true; - break; - case Keys.Subtract: - Tree.CurrentNode.Collapse(); - args.Handled = true; - args.SuppressKeyPress = true; - break; - case Keys.Add: - Tree.CurrentNode.Expand(); - args.Handled = true; - args.SuppressKeyPress = true; - break; - case Keys.Multiply: - Tree.CurrentNode.ExpandAll(); - args.Handled = true; - args.SuppressKeyPress = true; - break; - case Keys.A: - if (args.Modifiers == Keys.Control) - Tree.SelectAllNodes(); - break; - } - } - } - - public override void MouseDown(TreeNodeAdvMouseEventArgs args) - { - if (args.Node != null) - { - Tree.ItemDragMode = true; - Tree.ItemDragStart = args.Location; - - if (args.Button == MouseButtons.Left || args.Button == MouseButtons.Right) - { - Tree.BeginUpdate(); - try - { - Tree.CurrentNode = args.Node; - if (args.Node.IsSelected) - _mouseDownFlag = true; - else - { - _mouseDownFlag = false; - DoMouseOperation(args); - } - } - finally - { - Tree.EndUpdate(); - } - } - - } - else - { - Tree.ItemDragMode = false; - MouseDownAtEmptySpace(args); - } - } - - public override void MouseUp(TreeNodeAdvMouseEventArgs args) - { - Tree.ItemDragMode = false; - if (_mouseDownFlag && args.Node != null) - { - if (args.Button == MouseButtons.Left) - DoMouseOperation(args); - else if (args.Button == MouseButtons.Right) - Tree.CurrentNode = args.Node; - } - _mouseDownFlag = false; - } - - - private void NavigateBackward(int n) - { - int row = Math.Max(Tree.CurrentNode.Row - n, 0); - if (row != Tree.CurrentNode.Row) - FocusRow(Tree.RowMap[row]); - } - - private void NavigateForward(int n) - { - int row = Math.Min(Tree.CurrentNode.Row + n, Tree.RowCount - 1); - if (row != Tree.CurrentNode.Row) - FocusRow(Tree.RowMap[row]); - } - - protected virtual void MouseDownAtEmptySpace(TreeNodeAdvMouseEventArgs args) - { - Tree.ClearSelection(); - } - - protected virtual void FocusRow(TreeNodeAdv node) - { - Tree.SuspendSelectionEvent = true; - try - { - Tree.ClearSelectionInternal(); - Tree.CurrentNode = node; - Tree.SelectionStart = node; - node.IsSelected = true; - Tree.ScrollTo(node); - } - finally - { - Tree.SuspendSelectionEvent = false; - } - } - - protected bool CanSelect(TreeNodeAdv node) - { - if (Tree.SelectionMode == TreeSelectionMode.MultiSameParent) - { - return (Tree.SelectionStart == null || node.Parent == Tree.SelectionStart.Parent); - } - else - return true; - } - - protected virtual void DoMouseOperation(TreeNodeAdvMouseEventArgs args) - { - if (Tree.SelectedNodes.Count == 1 && args.Node != null && args.Node.IsSelected) - return; - - Tree.SuspendSelectionEvent = true; - try - { - Tree.ClearSelectionInternal(); - if (args.Node != null) - args.Node.IsSelected = true; - Tree.SelectionStart = args.Node; - } - finally - { - Tree.SuspendSelectionEvent = false; - } - } - } -} diff --git a/Aga.Controls/Tree/Input/ReorderColumnState.cs b/Aga.Controls/Tree/Input/ReorderColumnState.cs deleted file mode 100644 index 181cca5..0000000 --- a/Aga.Controls/Tree/Input/ReorderColumnState.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Windows.Forms; - -namespace Aga.Controls.Tree -{ - internal class ReorderColumnState : ColumnState - { - #region Properties - - private Point _location; - public Point Location - { - get { return _location; } - } - - private Bitmap _ghostImage; - public Bitmap GhostImage - { - get { return _ghostImage; } - } - - private TreeColumn _dropColumn; - public TreeColumn DropColumn - { - get { return _dropColumn; } - } - - private int _dragOffset; - public int DragOffset - { - get { return _dragOffset; } - } - - #endregion - - public ReorderColumnState(TreeViewAdv tree, TreeColumn column, Point initialMouseLocation) - : base(tree, column) - { - _location = new Point(initialMouseLocation.X + Tree.OffsetX, 0); - _dragOffset = tree.GetColumnX(column) - initialMouseLocation.X; - _ghostImage = column.CreateGhostImage(new Rectangle(0, 0, column.Width, tree.ColumnHeaderHeight), tree.Font); - } - - public override void KeyDown(KeyEventArgs args) - { - args.Handled = true; - if (args.KeyCode == Keys.Escape) - FinishResize(); - } - - public override void MouseDown(TreeNodeAdvMouseEventArgs args) - { - } - - public override void MouseUp(TreeNodeAdvMouseEventArgs args) - { - FinishResize(); - } - - public override bool MouseMove(MouseEventArgs args) - { - _dropColumn = null; - _location = new Point(args.X + Tree.OffsetX, 0); - int x = 0; - foreach (TreeColumn c in Tree.Columns) - { - if (c.IsVisible) - { - if (_location.X < x + c.Width / 2) - { - _dropColumn = c; - break; - } - x += c.Width; - } - } - Tree.UpdateHeaders(); - return true; - } - - private void FinishResize() - { - Tree.ChangeInput(); - if (Column == DropColumn) - Tree.UpdateView(); - else - { - Tree.Columns.Remove(Column); - if (DropColumn == null) - Tree.Columns.Add(Column); - else - Tree.Columns.Insert(Tree.Columns.IndexOf(DropColumn), Column); - - Tree.OnColumnReordered(Column); - } - } - } -} \ No newline at end of file diff --git a/Aga.Controls/Tree/Input/ResizeColumnState.cs b/Aga.Controls/Tree/Input/ResizeColumnState.cs deleted file mode 100644 index e4d8653..0000000 --- a/Aga.Controls/Tree/Input/ResizeColumnState.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Security.Permissions; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - internal class ResizeColumnState: ColumnState - { - private Point _initLocation; - private int _initWidth; - - public ResizeColumnState(TreeViewAdv tree, TreeColumn column, Point p) - : base(tree, column) - { - _initLocation = p; - _initWidth = column.Width; - } - - public override void KeyDown(KeyEventArgs args) - { - args.Handled = true; - if (args.KeyCode == Keys.Escape) - FinishResize(); - } - - public override void MouseDown(TreeNodeAdvMouseEventArgs args) - { - } - - public override void MouseUp(TreeNodeAdvMouseEventArgs args) - { - FinishResize(); - } - - private void FinishResize() - { - Tree.ChangeInput(); - Tree.FullUpdate(); - Tree.OnColumnWidthChanged(Column); - } - - public override bool MouseMove(MouseEventArgs args) - { - Column.Width = _initWidth + args.Location.X - _initLocation.X; - Tree.UpdateView(); - return true; - } - - public override void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) - { - Tree.AutoSizeColumn(Column); - } - } -} diff --git a/Aga.Controls/Tree/ListModel.cs b/Aga.Controls/Tree/ListModel.cs deleted file mode 100644 index 4d833e2..0000000 --- a/Aga.Controls/Tree/ListModel.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Collections; - -namespace Aga.Controls.Tree -{ - public class ListModel : TreeModelBase - { - private IList _list; - - public int Count - { - get { return _list.Count; } - } - - public ListModel() - { - _list = new List(); - } - - public ListModel(IList list) - { - _list = list; - } - - public override IEnumerable GetChildren(TreePath treePath) - { - return _list; - } - - public override bool IsLeaf(TreePath treePath) - { - return true; - } - - public void AddRange(IEnumerable items) - { - foreach (object obj in items) - _list.Add(obj); - OnStructureChanged(new TreePathEventArgs(TreePath.Empty)); - } - - public void Add(object item) - { - _list.Add(item); - OnNodesInserted(new TreeModelEventArgs(TreePath.Empty, new int[] { _list.Count - 1 }, new object[] { item })); - } - - public void Clear() - { - _list.Clear(); - OnStructureChanged(new TreePathEventArgs(TreePath.Empty)); - } - } -} diff --git a/Aga.Controls/Tree/NativeMethods.cs b/Aga.Controls/Tree/NativeMethods.cs deleted file mode 100644 index 81e2635..0000000 --- a/Aga.Controls/Tree/NativeMethods.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Drawing; -using System.Runtime.InteropServices; - - -namespace Aga.Controls.Tree -{ - internal static class NativeMethods - { - public const int DCX_WINDOW = 0x01; - public const int DCX_CACHE = 0x02; - public const int DCX_NORESETATTRS = 0x04; - public const int DCX_CLIPCHILDREN = 0x08; - public const int DCX_CLIPSIBLINGS = 0x10; - public const int DCX_PARENTCLIP = 0x20; - public const int DCX_EXCLUDERGN = 0x40; - public const int DCX_INTERSECTRGN = 0x80; - public const int DCX_EXCLUDEUPDATE = 0x100; - public const int DCX_INTERSECTUPDATE = 0x200; - public const int DCX_LOCKWINDOWUPDATE = 0x400; - public const int DCX_VALIDATE = 0x200000; - - public const int WM_THEMECHANGED = 0x031A; - public const int WM_NCPAINT = 0x85; - public const int WM_NCCALCSIZE = 0x83; - - public const int WS_BORDER = 0x800000; - public const int WS_EX_CLIENTEDGE = 0x200; - - public const int WVR_HREDRAW = 0x100; - public const int WVR_VREDRAW = 0x200; - public const int WVR_REDRAW = (WVR_HREDRAW | WVR_VREDRAW); - - [StructLayout(LayoutKind.Sequential)] - public struct NCCALCSIZE_PARAMS - { - public RECT rgrc0, rgrc1, rgrc2; - public IntPtr lppos; - } - - [StructLayout(LayoutKind.Sequential)] - public struct RECT - { - public int Left; - public int Top; - public int Right; - public int Bottom; - - public static RECT FromRectangle(Rectangle rectangle) - { - RECT result = new RECT(); - result.Left = rectangle.Left; - result.Top = rectangle.Top; - result.Right = rectangle.Right; - result.Bottom = rectangle.Bottom; - return result; - } - - public Rectangle ToRectangle() - { - return new Rectangle(Left, Top, Right - Left, Bottom - Top); - } - } - - [DllImport("user32.dll", SetLastError = true)] - public static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags); - - [DllImport("user32.dll")] - public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); - - [DllImport("user32.dll")] - public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); - } -} diff --git a/Aga.Controls/Tree/Node.cs b/Aga.Controls/Tree/Node.cs deleted file mode 100644 index 733c089..0000000 --- a/Aga.Controls/Tree/Node.cs +++ /dev/null @@ -1,257 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Collections.ObjectModel; -using System.Windows.Forms; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - public class Node - { - #region NodeCollection - - private class NodeCollection : Collection - { - private Node _owner; - - public NodeCollection(Node owner) - { - _owner = owner; - } - - protected override void ClearItems() - { - while (this.Count != 0) - this.RemoveAt(this.Count - 1); - } - - protected override void InsertItem(int index, Node item) - { - if (item == null) - throw new ArgumentNullException("item"); - - if (item.Parent != _owner) - { - if (item.Parent != null) - item.Parent.Nodes.Remove(item); - item._parent = _owner; - item._index = index; - for (int i = index; i < Count; i++) - this[i]._index++; - base.InsertItem(index, item); - - TreeModel model = _owner.FindModel(); - if (model != null) - model.OnNodeInserted(_owner, index, item); - } - } - - protected override void RemoveItem(int index) - { - Node item = this[index]; - item._parent = null; - item._index = -1; - for (int i = index + 1; i < Count; i++) - this[i]._index--; - base.RemoveItem(index); - - TreeModel model = _owner.FindModel(); - if (model != null) - model.OnNodeRemoved(_owner, index, item); - } - - protected override void SetItem(int index, Node item) - { - if (item == null) - throw new ArgumentNullException("item"); - - RemoveAt(index); - InsertItem(index, item); - } - } - - #endregion - - #region Properties - - private TreeModel _model; - internal TreeModel Model - { - get { return _model; } - set { _model = value; } - } - - private NodeCollection _nodes; - public Collection Nodes - { - get { return _nodes; } - } - - private Node _parent; - public Node Parent - { - get { return _parent; } - set - { - if (value != _parent) - { - if (_parent != null) - _parent.Nodes.Remove(this); - - if (value != null) - value.Nodes.Add(this); - } - } - } - - private int _index = -1; - public int Index - { - get - { - return _index; - } - } - - public Node PreviousNode - { - get - { - int index = Index; - if (index > 0) - return _parent.Nodes[index - 1]; - else - return null; - } - } - - public Node NextNode - { - get - { - int index = Index; - if (index >= 0 && index < _parent.Nodes.Count - 1) - return _parent.Nodes[index + 1]; - else - return null; - } - } - - private string _text; - public virtual string Text - { - get { return _text; } - set - { - if (_text != value) - { - _text = value; - NotifyModel(); - } - } - } - - private CheckState _checkState; - public virtual CheckState CheckState - { - get { return _checkState; } - set - { - if (_checkState != value) - { - _checkState = value; - NotifyModel(); - } - } - } - - private Image _image; - public Image Image - { - get { return _image; } - set - { - if (_image != value) - { - _image = value; - NotifyModel(); - } - } - } - - private object _tag; - public object Tag - { - get { return _tag; } - set { _tag = value; } - } - - public bool IsChecked - { - get - { - return CheckState != CheckState.Unchecked; - } - set - { - if (value) - CheckState = CheckState.Checked; - else - CheckState = CheckState.Unchecked; - } - } - - public virtual bool IsLeaf - { - get - { - return false; - } - } - - #endregion - - public Node() - : this(string.Empty) - { - } - - public Node(string text) - { - _text = text; - _nodes = new NodeCollection(this); - } - - public override string ToString() - { - return Text; - } - - private TreeModel FindModel() - { - Node node = this; - while (node != null) - { - if (node.Model != null) - return node.Model; - node = node.Parent; - } - return null; - } - - protected void NotifyModel() - { - TreeModel model = FindModel(); - if (model != null && Parent != null) - { - TreePath path = model.GetPath(Parent); - if (path != null) - { - TreeModelEventArgs args = new TreeModelEventArgs(path, new int[] { Index }, new object[] { this }); - model.OnNodesChanged(args); - } - } - } - } -} diff --git a/Aga.Controls/Tree/NodeControlInfo.cs b/Aga.Controls/Tree/NodeControlInfo.cs deleted file mode 100644 index c884a26..0000000 --- a/Aga.Controls/Tree/NodeControlInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Aga.Controls.Tree.NodeControls; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - public struct NodeControlInfo - { - public static readonly NodeControlInfo Empty = new NodeControlInfo(null, Rectangle.Empty, null); - - private NodeControl _control; - public NodeControl Control - { - get { return _control; } - } - - private Rectangle _bounds; - public Rectangle Bounds - { - get { return _bounds; } - } - - private TreeNodeAdv _node; - public TreeNodeAdv Node - { - get { return _node; } - } - - public NodeControlInfo(NodeControl control, Rectangle bounds, TreeNodeAdv node) - { - _control = control; - _bounds = bounds; - _node = node; - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/BaseTextControl.cs b/Aga.Controls/Tree/NodeControls/BaseTextControl.cs deleted file mode 100644 index 20e5f84..0000000 --- a/Aga.Controls/Tree/NodeControls/BaseTextControl.cs +++ /dev/null @@ -1,314 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Windows.Forms; -using System.Reflection; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - public abstract class BaseTextControl : EditableControl - { - private TextFormatFlags _baseFormatFlags; - private TextFormatFlags _formatFlags; - private Pen _focusPen; - private StringFormat _format; - - #region Properties - - private Font _font = null; - public Font Font - { - get - { - if (_font == null) - return Control.DefaultFont; - else - return _font; - } - set - { - if (value == Control.DefaultFont) - _font = null; - else - _font = value; - } - } - - protected bool ShouldSerializeFont() - { - return (_font != null); - } - - private HorizontalAlignment _textAlign = HorizontalAlignment.Left; - [DefaultValue(HorizontalAlignment.Left)] - public HorizontalAlignment TextAlign - { - get { return _textAlign; } - set - { - _textAlign = value; - SetFormatFlags(); - } - } - - private StringTrimming _trimming = StringTrimming.None; - [DefaultValue(StringTrimming.None)] - public StringTrimming Trimming - { - get { return _trimming; } - set - { - _trimming = value; - SetFormatFlags(); - } - } - - private bool _displayHiddenContentInToolTip = true; - [DefaultValue(true)] - public bool DisplayHiddenContentInToolTip - { - get { return _displayHiddenContentInToolTip; } - set { _displayHiddenContentInToolTip = value; } - } - - private bool _useCompatibleTextRendering = false; - [DefaultValue(false)] - public bool UseCompatibleTextRendering - { - get { return _useCompatibleTextRendering; } - set { _useCompatibleTextRendering = value; } - } - - [DefaultValue(false)] - public bool TrimMultiLine - { - get; - set; - } - - #endregion - - protected BaseTextControl() - { - IncrementalSearchEnabled = true; - _focusPen = new Pen(Color.Black); - _focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; - - _format = new StringFormat(StringFormatFlags.LineLimit | StringFormatFlags.NoClip | StringFormatFlags.FitBlackBox | StringFormatFlags.MeasureTrailingSpaces); - _baseFormatFlags = TextFormatFlags.PreserveGraphicsClipping | - TextFormatFlags.PreserveGraphicsTranslateTransform; - SetFormatFlags(); - LeftMargin = 3; - } - - private void SetFormatFlags() - { - _format.Alignment = TextHelper.TranslateAligment(TextAlign); - _format.Trimming = Trimming; - - _formatFlags = _baseFormatFlags | TextHelper.TranslateAligmentToFlag(TextAlign) - | TextHelper.TranslateTrimmingToFlag(Trimming); - } - - public override Size MeasureSize(TreeNodeAdv node, DrawContext context) - { - return GetLabelSize(node, context); - } - - protected Size GetLabelSize(TreeNodeAdv node, DrawContext context) - { - return GetLabelSize(node, context, GetLabel(node)); - } - - protected Size GetLabelSize(TreeNodeAdv node, DrawContext context, string label) - { - PerformanceAnalyzer.Start("GetLabelSize"); - CheckThread(); - Font font = GetDrawingFont(node, context, label); - Size s = Size.Empty; - if (UseCompatibleTextRendering) - s = TextRenderer.MeasureText(label, font); - else - { - SizeF sf = context.Graphics.MeasureString(label, font); - s = new Size((int)Math.Ceiling(sf.Width), (int)Math.Ceiling(sf.Height)); - } - PerformanceAnalyzer.Finish("GetLabelSize"); - - if (!s.IsEmpty) - return s; - else - return new Size(10, Font.Height); - } - - protected Font GetDrawingFont(TreeNodeAdv node, DrawContext context, string label) - { - Font font = context.Font; - if (DrawTextMustBeFired(node)) - { - DrawEventArgs args = new DrawEventArgs(node, this, context, label); - args.Font = context.Font; - OnDrawText(args); - font = args.Font; - } - return font; - } - - protected void SetEditControlProperties(Control control, TreeNodeAdv node) - { - string label = GetLabel(node); - DrawContext context = new DrawContext(); - context.Font = control.Font; - control.Font = GetDrawingFont(node, context, label); - } - - public override void Draw(TreeNodeAdv node, DrawContext context) - { - if (context.CurrentEditorOwner == this && node == Parent.CurrentNode) - return; - - PerformanceAnalyzer.Start("BaseTextControl.Draw"); - string label = GetLabel(node); - Rectangle bounds = GetBounds(node, context); - Rectangle focusRect = new Rectangle(bounds.X, context.Bounds.Y, - bounds.Width, context.Bounds.Height); - - Brush backgroundBrush; - Color textColor; - Font font; - CreateBrushes(node, context, label, out backgroundBrush, out textColor, out font, ref label); - - if (backgroundBrush != null) - context.Graphics.FillRectangle(backgroundBrush, focusRect); - if (context.DrawFocus) - { - focusRect.Width--; - focusRect.Height--; - if (context.DrawSelection == DrawSelectionMode.None) - _focusPen.Color = SystemColors.ControlText; - else - _focusPen.Color = SystemColors.InactiveCaption; - context.Graphics.DrawRectangle(_focusPen, focusRect); - } - - PerformanceAnalyzer.Start("BaseTextControl.DrawText"); - if (UseCompatibleTextRendering) - TextRenderer.DrawText(context.Graphics, label, font, bounds, textColor, _formatFlags); - else - context.Graphics.DrawString(label, font, GetFrush(textColor), bounds, _format); - PerformanceAnalyzer.Finish("BaseTextControl.DrawText"); - - PerformanceAnalyzer.Finish("BaseTextControl.Draw"); - } - - private static Dictionary _brushes = new Dictionary(); - private static Brush GetFrush(Color color) - { - Brush br; - if (_brushes.ContainsKey(color)) - br = _brushes[color]; - else - { - br = new SolidBrush(color); - _brushes.Add(color, br); - } - return br; - } - - private void CreateBrushes(TreeNodeAdv node, DrawContext context, string text, out Brush backgroundBrush, out Color textColor, out Font font, ref string label) - { - textColor = Parent.ForeColor; - backgroundBrush = null; - font = context.Font; - if (context.DrawSelection == DrawSelectionMode.Active) - { - textColor = SystemColors.HighlightText; - backgroundBrush = SystemBrushes.Highlight; - } - else if (context.DrawSelection == DrawSelectionMode.Inactive) - { - textColor = Parent.ForeColor; - backgroundBrush = SystemBrushes.InactiveBorder; - } - else if (context.DrawSelection == DrawSelectionMode.FullRowSelect) - textColor = Parent.ForeColor; - - if (!context.Enabled) - textColor = SystemColors.GrayText; - - if (DrawTextMustBeFired(node)) - { - DrawEventArgs args = new DrawEventArgs(node, this, context, text); - args.Text = label; - args.TextColor = textColor; - args.BackgroundBrush = backgroundBrush; - args.Font = font; - - OnDrawText(args); - - textColor = args.TextColor; - backgroundBrush = args.BackgroundBrush; - font = args.Font; - label = args.Text; - } - } - - public string GetLabel(TreeNodeAdv node) - { - if (node != null && node.Tag != null) - { - object obj = GetValue(node); - if (obj != null) - return FormatLabel(obj); - } - return string.Empty; - } - - protected virtual string FormatLabel(object obj) - { - var res = obj.ToString(); - if (TrimMultiLine && res != null) - { - string[] parts = res.Split('\n'); - if (parts.Length > 1) - return parts[0] + "..."; - } - return res; - } - - public void SetLabel(TreeNodeAdv node, string value) - { - SetValue(node, value); - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - if (disposing) - { - _focusPen.Dispose(); - _format.Dispose(); - } - } - - /// - /// Fires when control is going to draw a text. Can be used to change text or back color - /// - public event EventHandler DrawText; - protected virtual void OnDrawText(DrawEventArgs args) - { - TreeViewAdv tree = args.Node.Tree; - if (tree != null) - tree.FireDrawControl(args); - if (DrawText != null) - DrawText(this, args); - } - - protected virtual bool DrawTextMustBeFired(TreeNodeAdv node) - { - return DrawText != null || (node.Tree != null && node.Tree.DrawControlMustBeFired()); - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/BindableControl.cs b/Aga.Controls/Tree/NodeControls/BindableControl.cs deleted file mode 100644 index 673d8fc..0000000 --- a/Aga.Controls/Tree/NodeControls/BindableControl.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Reflection; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - public abstract class BindableControl : NodeControl - { - private struct MemberAdapter - { - private object _obj; - private PropertyInfo _pi; - private FieldInfo _fi; - - public static readonly MemberAdapter Empty = new MemberAdapter(); - - public Type MemberType - { - get - { - if (_pi != null) - return _pi.PropertyType; - else if (_fi != null) - return _fi.FieldType; - else - return null; - } - } - - public object Value - { - get - { - if (_pi != null && _pi.CanRead) - return _pi.GetValue(_obj, null); - else if (_fi != null) - return _fi.GetValue(_obj); - else - return null; - } - set - { - if (_pi != null && _pi.CanWrite) - _pi.SetValue(_obj, value, null); - else if (_fi != null) - _fi.SetValue(_obj, value); - } - } - - public MemberAdapter(object obj, PropertyInfo pi) - { - _obj = obj; - _pi = pi; - _fi = null; - } - - public MemberAdapter(object obj, FieldInfo fi) - { - _obj = obj; - _fi = fi; - _pi = null; - } - } - - #region Properties - - private bool _virtualMode = false; - [DefaultValue(false), Category("Data")] - public bool VirtualMode - { - get { return _virtualMode; } - set { _virtualMode = value; } - } - - private string _propertyName = ""; - [DefaultValue(""), Category("Data")] - public string DataPropertyName - { - get { return _propertyName; } - set - { - if (_propertyName == null) - _propertyName = string.Empty; - _propertyName = value; - } - } - - private bool _incrementalSearchEnabled = false; - [DefaultValue(false)] - public bool IncrementalSearchEnabled - { - get { return _incrementalSearchEnabled; } - set { _incrementalSearchEnabled = value; } - } - - #endregion - - public virtual object GetValue(TreeNodeAdv node) - { - if (VirtualMode) - { - NodeControlValueEventArgs args = new NodeControlValueEventArgs(node); - OnValueNeeded(args); - return args.Value; - } - else - { - try - { - return GetMemberAdapter(node).Value; - } - catch (TargetInvocationException ex) - { - if (ex.InnerException != null) - throw new ArgumentException(ex.InnerException.Message, ex.InnerException); - else - throw new ArgumentException(ex.Message); - } - } - } - - public virtual void SetValue(TreeNodeAdv node, object value) - { - if (VirtualMode) - { - NodeControlValueEventArgs args = new NodeControlValueEventArgs(node); - args.Value = value; - OnValuePushed(args); - } - else - { - try - { - MemberAdapter ma = GetMemberAdapter(node); - ma.Value = value; - } - catch (TargetInvocationException ex) - { - if (ex.InnerException != null) - throw new ArgumentException(ex.InnerException.Message, ex.InnerException); - else - throw new ArgumentException(ex.Message); - } - } - } - - public Type GetPropertyType(TreeNodeAdv node) - { - return GetMemberAdapter(node).MemberType; - } - - private MemberAdapter GetMemberAdapter(TreeNodeAdv node) - { - if (node.Tag != null && !string.IsNullOrEmpty(DataPropertyName)) - { - Type type = node.Tag.GetType(); - PropertyInfo pi = type.GetProperty(DataPropertyName); - if (pi != null) - return new MemberAdapter(node.Tag, pi); - else - { - FieldInfo fi = type.GetField(DataPropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - if (fi != null) - return new MemberAdapter(node.Tag, fi); - } - } - return MemberAdapter.Empty; - } - - public override string ToString() - { - if (string.IsNullOrEmpty(DataPropertyName)) - return GetType().Name; - else - return string.Format("{0} ({1})", GetType().Name, DataPropertyName); - } - - public event EventHandler ValueNeeded; - private void OnValueNeeded(NodeControlValueEventArgs args) - { - if (ValueNeeded != null) - ValueNeeded(this, args); - } - - public event EventHandler ValuePushed; - private void OnValuePushed(NodeControlValueEventArgs args) - { - if (ValuePushed != null) - ValuePushed(this, args); - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/ClassDiagram.cd b/Aga.Controls/Tree/NodeControls/ClassDiagram.cd deleted file mode 100644 index 733d539..0000000 --- a/Aga.Controls/Tree/NodeControls/ClassDiagram.cd +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - Tree\NodeControls\NodeStateIcon.cs - ABAAAAAAAAQAQAAAAAAAAAAAAAAAAAAAQIAAAAAAAAA= - - - - - - Tree\NodeControls\BindableControl.cs - FAAAAAAQIBAQCgAEAAAAIAAAAAAAAAEMAAACAAAAAAE= - - - - - - Tree\NodeControls\NodeCheckBox.cs - AAEAAAAAAAACgkQCAAAAAAigAgAAEGABAAAIAAAAAAA= - - - - - - Tree\NodeControls\NodeControl.cs - AAAAAJAAgIgBkkoQAAgAQAAwAAABEIQAAEBIAAAAAAA= - - - - - - - - - Tree\NodeControls\NodeIcon.cs - ABAAAAAAAAAAAgAAAAAAAAAgAAAAAAAAAAAAAAAAAAA= - - - - - - Tree\NodeControls\NodePlusMinus.cs - AAAAAAAAAAAAAgAAAAAAAEAgAAAAMCAAAAAIACAAAAA= - - - - - - Tree\NodeControls\BaseTextControl.cs - AAAAICBQACAAIgACBCAEAQA8AgmFoAAwAAAAACACAMA= - - - - - - Tree\NodeControls\NodeTextBox.cs - QQQAhAAAADAMgAAAABAAAAAAAgEAIAAAAAAAAIAAAAA= - - - - - - Tree\NodeControls\EditableControl.cs - QQAgAAAACGgkAMAABAEEkADAEAAUEAAABAGoAAAAAQA= - - - - - - Tree\NodeControls\NodeComboBox.cs - wQACAAAAAAAMAEBAAAAAAABAAAAAAAABAAAAAAAAAAA= - - - - - - Tree\NodeControls\NodeNumericUpDown.cs - wQAAAACAAAAEAABAIAAQIAAAAAAAAAABAAAIAAAAAII= - - - - - - Tree\NodeControls\InteractiveControl.cs - AAAABAAAAAAAAAAACAAAAAAAABAAAQAAAAAAAAIAAAA= - - - - - - Tree\NodeControls\NodeDecimalTextBox.cs - AQAAAAAAAACAAAACAAAAAAQAAAAAIAAAAAgAAAAAAAA= - - - - - - Tree\NodeControls\NodeIntegerTextBox.cs - AQAAAAAAAAAAAAACAAAAAAQAAAAAIAAAAAAAAAAAAAA= - - - \ No newline at end of file diff --git a/Aga.Controls/Tree/NodeControls/DrawEventArgs.cs b/Aga.Controls/Tree/NodeControls/DrawEventArgs.cs deleted file mode 100644 index 8333c1f..0000000 --- a/Aga.Controls/Tree/NodeControls/DrawEventArgs.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; - -namespace Aga.Controls.Tree.NodeControls -{ - public class DrawEventArgs : NodeEventArgs - { - private DrawContext _context; - public DrawContext Context - { - get { return _context; } - } - - private Brush _textBrush; - [Obsolete("Use TextColor")] - public Brush TextBrush - { - get { return _textBrush; } - set { _textBrush = value; } - } - - private Brush _backgroundBrush; - public Brush BackgroundBrush - { - get { return _backgroundBrush; } - set { _backgroundBrush = value; } - } - - private Font _font; - public Font Font - { - get { return _font; } - set { _font = value; } - } - - private Color _textColor; - public Color TextColor - { - get { return _textColor; } - set { _textColor = value; } - } - - private string _text; - public string Text - { - get { return _text; } - set { _text = value; } - } - - - private EditableControl _control; - public EditableControl Control - { - get { return _control; } - } - - public DrawEventArgs(TreeNodeAdv node, EditableControl control, DrawContext context, string text) - : base(node) - { - _control = control; - _context = context; - _text = text; - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/EditEventArgs.cs b/Aga.Controls/Tree/NodeControls/EditEventArgs.cs deleted file mode 100644 index d26033b..0000000 --- a/Aga.Controls/Tree/NodeControls/EditEventArgs.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; - -namespace Aga.Controls.Tree.NodeControls -{ - public class EditEventArgs : NodeEventArgs - { - private Control _control; - public Control Control - { - get { return _control; } - } - - public EditEventArgs(TreeNodeAdv node, Control control) - : base(node) - { - _control = control; - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/EditableControl.cs b/Aga.Controls/Tree/NodeControls/EditableControl.cs deleted file mode 100644 index ec2a9d9..0000000 --- a/Aga.Controls/Tree/NodeControls/EditableControl.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - public abstract class EditableControl : InteractiveControl - { - private Timer _timer; - private bool _editFlag; - - #region Properties - - private bool _editOnClick = false; - [DefaultValue(false)] - public bool EditOnClick - { - get { return _editOnClick; } - set { _editOnClick = value; } - } - - #endregion - - protected EditableControl() - { - _timer = new Timer(); - _timer.Interval = 500; - _timer.Tick += new EventHandler(TimerTick); - } - - private void TimerTick(object sender, EventArgs e) - { - _timer.Stop(); - if (_editFlag) - BeginEdit(); - _editFlag = false; - } - - public void SetEditorBounds(EditorContext context) - { - Size size = CalculateEditorSize(context); - context.Editor.Bounds = new Rectangle(context.Bounds.X, context.Bounds.Y, - Math.Min(size.Width, context.Bounds.Width), - Math.Min(size.Height, Parent.ClientSize.Height - context.Bounds.Y) - ); - } - - protected abstract Size CalculateEditorSize(EditorContext context); - - protected virtual bool CanEdit(TreeNodeAdv node) - { - return (node.Tag != null) && IsEditEnabled(node); - } - - public void BeginEdit() - { - if (Parent != null && Parent.CurrentNode != null && CanEdit(Parent.CurrentNode)) - { - CancelEventArgs args = new CancelEventArgs(); - OnEditorShowing(args); - if (!args.Cancel) - { - var editor = CreateEditor(Parent.CurrentNode); - Parent.DisplayEditor(editor, this); - } - } - } - - public void EndEdit(bool applyChanges) - { - if (Parent != null) - if (Parent.HideEditor(applyChanges)) - OnEditorHided(); - } - - public virtual void UpdateEditor(Control control) - { - } - - internal void ApplyChanges(TreeNodeAdv node, Control editor) - { - DoApplyChanges(node, editor); - OnChangesApplied(); - } - - internal void DoDisposeEditor(Control editor) - { - DisposeEditor(editor); - } - - protected abstract void DoApplyChanges(TreeNodeAdv node, Control editor); - - protected abstract Control CreateEditor(TreeNodeAdv node); - - protected abstract void DisposeEditor(Control editor); - - public virtual void Cut(Control control) - { - } - - public virtual void Copy(Control control) - { - } - - public virtual void Paste(Control control) - { - } - - public virtual void Delete(Control control) - { - } - - public override void MouseDown(TreeNodeAdvMouseEventArgs args) - { - _editFlag = (!EditOnClick && args.Button == MouseButtons.Left - && args.ModifierKeys == Keys.None && args.Node.IsSelected); - } - - public override void MouseUp(TreeNodeAdvMouseEventArgs args) - { - if (args.Node.IsSelected) - { - if (EditOnClick && args.Button == MouseButtons.Left && args.ModifierKeys == Keys.None) - { - Parent.ItemDragMode = false; - BeginEdit(); - args.Handled = true; - } - else if (_editFlag)// && args.Node.IsSelected) - _timer.Start(); - } - } - - public override void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) - { - _editFlag = false; - _timer.Stop(); - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - if (disposing) - _timer.Dispose(); - } - - #region Events - - public event CancelEventHandler EditorShowing; - protected void OnEditorShowing(CancelEventArgs args) - { - if (EditorShowing != null) - EditorShowing(this, args); - } - - public event EventHandler EditorHided; - protected void OnEditorHided() - { - if (EditorHided != null) - EditorHided(this, EventArgs.Empty); - } - - public event EventHandler ChangesApplied; - protected void OnChangesApplied() - { - if (ChangesApplied != null) - ChangesApplied(this, EventArgs.Empty); - } - - #endregion - } -} diff --git a/Aga.Controls/Tree/NodeControls/ExpandingIcon.cs b/Aga.Controls/Tree/NodeControls/ExpandingIcon.cs deleted file mode 100644 index bd2c34c..0000000 --- a/Aga.Controls/Tree/NodeControls/ExpandingIcon.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Threading; -using System.Windows.Forms; - -namespace Aga.Controls.Tree.NodeControls -{ - /// - /// Displays an animated icon for those nodes, who are in expanding state. - /// Parent TreeView must have AsyncExpanding property set to true. - /// - public class ExpandingIcon: NodeControl - { - private static GifDecoder _gif = ResourceHelper.LoadingIcon; - private static int _index = 0; - private static volatile Thread _animatingThread; - private static object _lock = new object(); - - public override Size MeasureSize(TreeNodeAdv node, DrawContext context) - { - return ResourceHelper.LoadingIcon.FrameSize; - } - - protected override void OnIsVisibleValueNeeded(NodeControlValueEventArgs args) - { - args.Value = args.Node.IsExpandingNow; - base.OnIsVisibleValueNeeded(args); - } - - public override void Draw(TreeNodeAdv node, DrawContext context) - { - Rectangle rect = GetBounds(node, context); - Image img = _gif.GetFrame(_index).Image; - context.Graphics.DrawImage(img, rect.Location); - } - - public static void Start() - { - lock (_lock) - { - if (_animatingThread == null) - { - _index = 0; - _animatingThread = new Thread(new ThreadStart(IterateIcons)); - _animatingThread.IsBackground = true; - _animatingThread.Priority = ThreadPriority.Lowest; - _animatingThread.Start(); - } - } - } - - public static void Stop() - { - lock (_lock) - { - _index = 0; - _animatingThread = null; - } - } - - private static void IterateIcons() - { - while (_animatingThread != null) - { - if (_index < _gif.FrameCount - 1) - _index++; - else - _index = 0; - - if (IconChanged != null) - IconChanged(null, EventArgs.Empty); - - int delay = _gif.GetFrame(_index).Delay; - Thread.Sleep(delay); - } - System.Diagnostics.Debug.WriteLine("IterateIcons Stopped"); - } - - public static event EventHandler IconChanged; - } -} diff --git a/Aga.Controls/Tree/NodeControls/InteractiveControl.cs b/Aga.Controls/Tree/NodeControls/InteractiveControl.cs deleted file mode 100644 index 0a9f803..0000000 --- a/Aga.Controls/Tree/NodeControls/InteractiveControl.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - public abstract class InteractiveControl : BindableControl - { - private bool _editEnabled = false; - [DefaultValue(false)] - public bool EditEnabled - { - get { return _editEnabled; } - set { _editEnabled = value; } - } - - protected bool IsEditEnabled(TreeNodeAdv node) - { - if (EditEnabled) - { - NodeControlValueEventArgs args = new NodeControlValueEventArgs(node); - args.Value = true; - OnIsEditEnabledValueNeeded(args); - return Convert.ToBoolean(args.Value); - } - else - return false; - } - - public event EventHandler IsEditEnabledValueNeeded; - private void OnIsEditEnabledValueNeeded(NodeControlValueEventArgs args) - { - if (IsEditEnabledValueNeeded != null) - IsEditEnabledValueNeeded(this, args); - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/LabelEventArgs.cs b/Aga.Controls/Tree/NodeControls/LabelEventArgs.cs deleted file mode 100644 index d792253..0000000 --- a/Aga.Controls/Tree/NodeControls/LabelEventArgs.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree.NodeControls -{ - public class LabelEventArgs : EventArgs - { - private object _subject; - public object Subject - { - get { return _subject; } - } - - private string _oldLabel; - public string OldLabel - { - get { return _oldLabel; } - } - - private string _newLabel; - public string NewLabel - { - get { return _newLabel; } - } - - public LabelEventArgs(object subject, string oldLabel, string newLabel) - { - _subject = subject; - _oldLabel = oldLabel; - _newLabel = newLabel; - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeCheckBox.cs b/Aga.Controls/Tree/NodeControls/NodeCheckBox.cs deleted file mode 100644 index dbfb3cb..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeCheckBox.cs +++ /dev/null @@ -1,192 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using Aga.Controls.Properties; -using System.Reflection; -using System.Windows.Forms; -using System.Windows.Forms.VisualStyles; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeCheckBox : InteractiveControl - { - public const int ImageSize = 13; - - private Bitmap _check; - private Bitmap _uncheck; - private Bitmap _unknown; - - #region Properties - - private bool _threeState; - [DefaultValue(false)] - public bool ThreeState - { - get { return _threeState; } - set { _threeState = value; } - } - - #endregion - - public NodeCheckBox() - : this(string.Empty) - { - } - - public NodeCheckBox(string propertyName) - { - _check = Resources.check; - _uncheck = Resources.uncheck; - _unknown = Resources.unknown; - DataPropertyName = propertyName; - LeftMargin = 0; - } - - public override Size MeasureSize(TreeNodeAdv node, DrawContext context) - { - int scaledX = node.Tree.GetScaledSize(ImageSize, false); - int scaledY = node.Tree.GetScaledSize(ImageSize); - return new Size(scaledX, scaledY); - } - - public override void Draw(TreeNodeAdv node, DrawContext context) - { - Rectangle bounds = GetBounds(node, context); - CheckState state = GetCheckState(node); - if (TreeViewAdv.CustomCheckRenderFunc != null) - { - TreeViewAdv.CustomCheckRenderFunc(context.Graphics, bounds, state == CheckState.Checked); - } - else if (Application.RenderWithVisualStyles) - { - VisualStyleRenderer renderer; - int scaledX = node.Tree.GetScaledSize(ImageSize, false); - int scaledY = node.Tree.GetScaledSize(ImageSize); - if (state == CheckState.Indeterminate) - renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.MixedNormal); - else if (state == CheckState.Checked) - renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.CheckedNormal); - else - renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.UncheckedNormal); - renderer.DrawBackground(context.Graphics, new Rectangle(bounds.X, bounds.Y, scaledX, scaledY)); - } - else - { - Image img; - if (state == CheckState.Indeterminate) - img = _unknown; - else if (state == CheckState.Checked) - img = _check; - else - img = _uncheck; - context.Graphics.DrawImage(img, bounds.Location); - } - } - - protected virtual CheckState GetCheckState(TreeNodeAdv node) - { - object obj = GetValue(node); - if (obj is CheckState) - return (CheckState)obj; - else if (obj is bool) - return (bool)obj ? CheckState.Checked : CheckState.Unchecked; - else - return CheckState.Unchecked; - } - - protected virtual void SetCheckState(TreeNodeAdv node, CheckState value) - { - if (VirtualMode) - { - SetValue(node, value); - OnCheckStateChanged(node); - } - else - { - Type type = GetPropertyType(node); - if (type == typeof(CheckState)) - { - SetValue(node, value); - OnCheckStateChanged(node); - } - else if (type == typeof(bool)) - { - SetValue(node, value != CheckState.Unchecked); - OnCheckStateChanged(node); - } - } - } - - public override void MouseDown(TreeNodeAdvMouseEventArgs args) - { - if (args.Button == MouseButtons.Left && IsEditEnabled(args.Node)) - { - DrawContext context = new DrawContext(); - context.Bounds = args.ControlBounds; - Rectangle rect = GetBounds(args.Node, context); - if (rect.Contains(args.ViewLocation)) - { - CheckState state = GetCheckState(args.Node); - state = GetNewState(state); - SetCheckState(args.Node, state); - Parent.UpdateView(); - args.Handled = true; - } - } - } - - public override void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) - { - args.Handled = true; - } - - private CheckState GetNewState(CheckState state) - { - if (state == CheckState.Indeterminate) - return CheckState.Unchecked; - else if(state == CheckState.Unchecked) - return CheckState.Checked; - else - return ThreeState ? CheckState.Indeterminate : CheckState.Unchecked; - } - - public override void KeyDown(KeyEventArgs args) - { - if (args.KeyCode == Keys.Space && EditEnabled) - { - Parent.BeginUpdate(); - try - { - if (Parent.CurrentNode != null) - { - CheckState value = GetNewState(GetCheckState(Parent.CurrentNode)); - foreach (TreeNodeAdv node in Parent.Selection) - if (IsEditEnabled(node)) - SetCheckState(node, value); - } - } - finally - { - Parent.EndUpdate(); - } - args.Handled = true; - } - } - - public event EventHandler CheckStateChanged; - protected void OnCheckStateChanged(TreePathEventArgs args) - { - if (CheckStateChanged != null) - CheckStateChanged(this, args); - } - - protected void OnCheckStateChanged(TreeNodeAdv node) - { - TreePath path = this.Parent.GetPath(node); - OnCheckStateChanged(new TreePathEventArgs(path)); - } - - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeComboBox.cs b/Aga.Controls/Tree/NodeControls/NodeComboBox.cs deleted file mode 100644 index 8aff375..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeComboBox.cs +++ /dev/null @@ -1,232 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Windows.Forms; -using System.Reflection; -using System.ComponentModel; -using System.Drawing.Design; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeComboBox : BaseTextControl - { - #region Properties - - private int _editorWidth = 100; - [DefaultValue(100)] - public int EditorWidth - { - get { return _editorWidth; } - set { _editorWidth = value; } - } - - private int _editorHeight = 100; - [DefaultValue(100)] - public int EditorHeight - { - get { return _editorHeight; } - set { _editorHeight = value; } - } - - private List _dropDownItems; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")] - [Editor(typeof(StringCollectionEditor), typeof(UITypeEditor)), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - public List DropDownItems - { - get { return _dropDownItems; } - } - - #endregion - - public event EventHandler CreatingEditor; - - public NodeComboBox() - { - _dropDownItems = new List(); - } - - protected override Size CalculateEditorSize(EditorContext context) - { - if (Parent.UseColumns) - { - if (context.Editor is CheckedListBox) - return new Size(context.Bounds.Size.Width, EditorHeight); - else - return context.Bounds.Size; - } - else - { - if (context.Editor is CheckedListBox) - return new Size(EditorWidth, EditorHeight); - else - return new Size(EditorWidth, context.Bounds.Height); - } - } - - protected override Control CreateEditor(TreeNodeAdv node) - { - Control c; - object value = GetValue(node); - if (IsCheckedListBoxRequired(node)) - c = CreateCheckedListBox(node); - else - c = CreateCombo(node); - OnCreatingEditor(new EditEventArgs(node, c)); - return c; - } - - protected override void DisposeEditor(Control editor) - { - } - - protected virtual void OnCreatingEditor(EditEventArgs args) - { - if (CreatingEditor != null) - CreatingEditor(this, args); - } - - protected virtual bool IsCheckedListBoxRequired(TreeNodeAdv node) - { - object value = GetValue(node); - if (value != null) - { - Type t = value.GetType(); - object[] arr = t.GetCustomAttributes(typeof(FlagsAttribute), false); - return (t.IsEnum && arr.Length == 1); - } - return false; - } - - private Control CreateCombo(TreeNodeAdv node) - { - ComboBox comboBox = new ComboBox(); - if (DropDownItems != null) - comboBox.Items.AddRange(DropDownItems.ToArray()); - comboBox.SelectedItem = GetValue(node); - comboBox.DropDownStyle = ComboBoxStyle.DropDownList; - comboBox.DropDownClosed += new EventHandler(EditorDropDownClosed); - SetEditControlProperties(comboBox, node); - return comboBox; - } - - private Control CreateCheckedListBox(TreeNodeAdv node) - { - CheckedListBox listBox = new CheckedListBox(); - listBox.CheckOnClick = true; - - object value = GetValue(node); - Type enumType = GetEnumType(node); - foreach (object obj in Enum.GetValues(enumType)) - { - object[] attributes = enumType.GetField(obj.ToString()).GetCustomAttributes(typeof(BrowsableAttribute), false); - if (attributes.Length == 0 || ((BrowsableAttribute)attributes[0]).Browsable) - listBox.Items.Add(obj, IsContain(value, obj)); - } - - SetEditControlProperties(listBox, node); - if (CreatingEditor != null) - CreatingEditor(this, new EditEventArgs(node, listBox)); - return listBox; - } - - protected virtual Type GetEnumType(TreeNodeAdv node) - { - object value = GetValue(node); - return value.GetType(); - } - - private bool IsContain(object value, object enumElement) - { - if (value == null || enumElement == null) - return false; - if (value.GetType().IsEnum) - { - int i1 = (int)value; - int i2 = (int)enumElement; - return (i1 & i2) == i2; - } - else - { - var arr = value as object[]; - foreach (object obj in arr) - if ((int)obj == (int)enumElement) - return true; - return false; - } - } - - protected override string FormatLabel(object obj) - { - var arr = obj as object[]; - if (arr != null) - { - StringBuilder sb = new StringBuilder(); - foreach (object t in arr) - { - if (sb.Length > 0) - sb.Append(", "); - sb.Append(t); - } - return sb.ToString(); - } - else - return base.FormatLabel(obj); - } - - void EditorDropDownClosed(object sender, EventArgs e) - { - EndEdit(true); - } - - public override void UpdateEditor(Control control) - { - if (control is ComboBox) - (control as ComboBox).DroppedDown = true; - } - - protected override void DoApplyChanges(TreeNodeAdv node, Control editor) - { - var combo = editor as ComboBox; - if (combo != null) - { - if (combo.DropDownStyle == ComboBoxStyle.DropDown) - SetValue(node, combo.Text); - else - SetValue(node, combo.SelectedItem); - } - else - { - var listBox = editor as CheckedListBox; - Type type = GetEnumType(node); - if (IsFlags(type)) - { - int res = 0; - foreach (object obj in listBox.CheckedItems) - res |= (int)obj; - object val = Enum.ToObject(type, res); - SetValue(node, val); - } - else - { - List list = new List(); - foreach (object obj in listBox.CheckedItems) - list.Add(obj); - SetValue(node, list.ToArray()); - } - } - } - - private bool IsFlags(Type type) - { - object[] atr = type.GetCustomAttributes(typeof(FlagsAttribute), false); - return atr.Length == 1; - } - - public override void MouseUp(TreeNodeAdvMouseEventArgs args) - { - if (args.Node != null && args.Node.IsSelected) //Workaround of specific ComboBox control behavior - base.MouseUp(args); - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeControl.cs b/Aga.Controls/Tree/NodeControls/NodeControl.cs deleted file mode 100644 index 9243e61..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeControl.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - [DesignTimeVisible(false), ToolboxItem(false)] - public abstract class NodeControl : Component - { - #region Properties - - private TreeViewAdv _parent; - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public TreeViewAdv Parent - { - get { return _parent; } - set - { - if (value != _parent) - { - if (_parent != null) - _parent.NodeControls.Remove(this); - - if (value != null) - value.NodeControls.Add(this); - } - } - } - - private IToolTipProvider _toolTipProvider; - [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public IToolTipProvider ToolTipProvider - { - get { return _toolTipProvider; } - set { _toolTipProvider = value; } - } - - private TreeColumn _parentColumn; - public TreeColumn ParentColumn - { - get { return _parentColumn; } - set - { - _parentColumn = value; - if (_parent != null) - _parent.FullUpdate(); - } - } - - private VerticalAlignment _verticalAlign = VerticalAlignment.Center; - [DefaultValue(VerticalAlignment.Center)] - public VerticalAlignment VerticalAlign - { - get { return _verticalAlign; } - set - { - _verticalAlign = value; - if (_parent != null) - _parent.FullUpdate(); - } - } - - private int _leftMargin = 0; - public int LeftMargin - { - get { return _leftMargin; } - set - { - if (value < 0) - throw new ArgumentOutOfRangeException(); - - _leftMargin = value; - if (_parent != null) - _parent.FullUpdate(); - } - } - #endregion - - internal virtual void AssignParent(TreeViewAdv parent) - { - _parent = parent; - } - - protected virtual Rectangle GetBounds(TreeNodeAdv node, DrawContext context) - { - Rectangle r = context.Bounds; - Size s = GetActualSize(node, context); - Size bs = new Size(r.Width - LeftMargin, Math.Min(r.Height, s.Height)); - switch (VerticalAlign) - { - case VerticalAlignment.Top: - return new Rectangle(new Point(r.X + LeftMargin, r.Y), bs); - case VerticalAlignment.Bottom: - return new Rectangle(new Point(r.X + LeftMargin, r.Bottom - s.Height), bs); - default: - return new Rectangle(new Point(r.X + LeftMargin, r.Y + (r.Height - s.Height) / 2), bs); - } - } - - protected void CheckThread() - { - if (Parent != null && Control.CheckForIllegalCrossThreadCalls) - if (Parent.InvokeRequired) - throw new InvalidOperationException("Cross-thread calls are not allowed"); - } - - public bool IsVisible(TreeNodeAdv node) - { - NodeControlValueEventArgs args = new NodeControlValueEventArgs(node); - args.Value = true; - OnIsVisibleValueNeeded(args); - return Convert.ToBoolean(args.Value); - } - - internal Size GetActualSize(TreeNodeAdv node, DrawContext context) - { - if (IsVisible(node)) - { - Size s = MeasureSize(node, context); - return new Size(s.Width + LeftMargin, s.Height); - } - else - return Size.Empty; - } - - public abstract Size MeasureSize(TreeNodeAdv node, DrawContext context); - - public abstract void Draw(TreeNodeAdv node, DrawContext context); - - public virtual string GetToolTip(TreeNodeAdv node) - { - if (ToolTipProvider != null) - return ToolTipProvider.GetToolTip(node, this); - else - return string.Empty; - } - - public virtual void MouseDown(TreeNodeAdvMouseEventArgs args) - { - } - - public virtual void MouseUp(TreeNodeAdvMouseEventArgs args) - { - } - - public virtual void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) - { - } - - public virtual void KeyDown(KeyEventArgs args) - { - } - - public virtual void KeyUp(KeyEventArgs args) - { - } - - public event EventHandler IsVisibleValueNeeded; - protected virtual void OnIsVisibleValueNeeded(NodeControlValueEventArgs args) - { - if (IsVisibleValueNeeded != null) - IsVisibleValueNeeded(this, args); - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeControlValueEventArgs.cs b/Aga.Controls/Tree/NodeControls/NodeControlValueEventArgs.cs deleted file mode 100644 index 3686440..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeControlValueEventArgs.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeControlValueEventArgs : NodeEventArgs - { - private object _value; - public object Value - { - get { return _value; } - set { _value = value; } - } - - public NodeControlValueEventArgs(TreeNodeAdv node) - :base(node) - { - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeControlsCollection.cs b/Aga.Controls/Tree/NodeControls/NodeControlsCollection.cs deleted file mode 100644 index f31e05e..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeControlsCollection.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.ComponentModel.Design; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Drawing.Design; - -namespace Aga.Controls.Tree.NodeControls -{ - internal class NodeControlsCollection : Collection - { - private TreeViewAdv _tree; - - public NodeControlsCollection(TreeViewAdv tree) - { - _tree = tree; - } - - protected override void ClearItems() - { - _tree.BeginUpdate(); - try - { - while (this.Count != 0) - this.RemoveAt(this.Count - 1); - } - finally - { - _tree.EndUpdate(); - } - } - - protected override void InsertItem(int index, NodeControl item) - { - if (item == null) - throw new ArgumentNullException("item"); - - if (item.Parent != _tree) - { - if (item.Parent != null) - { - item.Parent.NodeControls.Remove(item); - } - base.InsertItem(index, item); - item.AssignParent(_tree); - _tree.FullUpdate(); - } - } - - protected override void RemoveItem(int index) - { - NodeControl value = this[index]; - value.AssignParent(null); - base.RemoveItem(index); - _tree.FullUpdate(); - } - - protected override void SetItem(int index, NodeControl item) - { - if (item == null) - throw new ArgumentNullException("item"); - - _tree.BeginUpdate(); - try - { - RemoveAt(index); - InsertItem(index, item); - } - finally - { - _tree.EndUpdate(); - } - } - } - - internal class NodeControlCollectionEditor : CollectionEditor - { - private Type[] _types; - - public NodeControlCollectionEditor(Type type) - : base(type) - { - _types = new Type[] { typeof(NodeTextBox), typeof(NodeIntegerTextBox), typeof(NodeDecimalTextBox), - typeof(NodeComboBox), typeof(NodeCheckBox), - typeof(NodeStateIcon), typeof(NodeIcon), typeof(NodeNumericUpDown), typeof(ExpandingIcon) }; - } - - protected override System.Type[] CreateNewItemTypes() - { - return _types; - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeDecimalTextBox.cs b/Aga.Controls/Tree/NodeControls/NodeDecimalTextBox.cs deleted file mode 100644 index 20ada8e..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeDecimalTextBox.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Windows.Forms; -using System.Reflection; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeDecimalTextBox : NodeTextBox - { - private bool _allowDecimalSeparator = true; - [DefaultValue(true)] - public bool AllowDecimalSeparator - { - get { return _allowDecimalSeparator; } - set { _allowDecimalSeparator = value; } - } - - private bool _allowNegativeSign = true; - [DefaultValue(true)] - public bool AllowNegativeSign - { - get { return _allowNegativeSign; } - set { _allowNegativeSign = value; } - } - - protected NodeDecimalTextBox() - { - } - - protected override TextBox CreateTextBox() - { - NumericTextBox textBox = new NumericTextBox(); - textBox.AllowDecimalSeparator = AllowDecimalSeparator; - textBox.AllowNegativeSign = AllowNegativeSign; - return textBox; - } - - protected override void DoApplyChanges(TreeNodeAdv node, Control editor) - { - SetValue(node, (editor as NumericTextBox).DecimalValue); - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeEventArgs.cs b/Aga.Controls/Tree/NodeControls/NodeEventArgs.cs deleted file mode 100644 index cedccbf..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeEventArgs.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeEventArgs : EventArgs - { - private TreeNodeAdv _node; - public TreeNodeAdv Node - { - get { return _node; } - } - - public NodeEventArgs(TreeNodeAdv node) - { - _node = node; - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeIcon.cs b/Aga.Controls/Tree/NodeControls/NodeIcon.cs deleted file mode 100644 index d86340c..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeIcon.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Windows.Forms; -using Aga.Controls.Properties; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeIcon : BindableControl - { - public NodeIcon() - { - LeftMargin = 1; - } - - public override Size MeasureSize(TreeNodeAdv node, DrawContext context) - { - Image image = GetIcon(node); - if (image != null) - { - int scaledX = node.Tree.GetScaledSize(image.Size.Width, false); - int scaledY = node.Tree.GetScaledSize(image.Size.Height); - return new Size(scaledX, scaledY); ; - } - else - { - return Size.Empty; - } - } - - - public override void Draw(TreeNodeAdv node, DrawContext context) - { - Image image = GetIcon(node); - if (image != null) - { - Rectangle r = GetBounds(node, context); - if ( image.Width > 0 && image.Height > 0 ) - { - switch (_scaleMode) - { - case ImageScaleMode.Fit: - context.Graphics.DrawImage(image, r); - break; - case ImageScaleMode.ScaleDown: - { - float factor = Math.Min((float)r.Width / (float)image.Width, (float)r.Height / (float)image.Height); - if (factor < 1) - context.Graphics.DrawImage(image, r.X, r.Y, image.Width * factor, image.Height * factor); - else - context.Graphics.DrawImage(image, r.X, r.Y, image.Width, image.Height); - } break; - case ImageScaleMode.ScaleUp: - { - float factor = Math.Max((float)r.Width / (float)image.Width, (float)r.Height / (float)image.Height); - if (factor > 1) - context.Graphics.DrawImage(image, r.X, r.Y, image.Width * factor, image.Height * factor); - else - context.Graphics.DrawImage(image, r.X, r.Y, image.Width, image.Height); - } break; - case ImageScaleMode.AlwaysScale: - { - float fx = (float)r.Width / (float)image.Width; - float fy = (float)r.Height / (float)image.Height; - if (Math.Min(fx, fy) < 1) - { //scale down - float factor = Math.Min(fx, fy); - context.Graphics.DrawImage(image, r.X, r.Y, image.Width * factor, image.Height * factor); - } - else if (Math.Max(fx, fy) > 1) - { - float factor = Math.Max(fx, fy); - context.Graphics.DrawImage(image, r.X, r.Y, image.Width * factor, image.Height * factor); - } - else - context.Graphics.DrawImage(image, r.X, r.Y, image.Width, image.Height); - } break; - case ImageScaleMode.Clip: - default: - context.Graphics.DrawImage(image, r.X, r.Y, image.Width, image.Height); - break; - } - } - - } - } - - protected virtual Image GetIcon(TreeNodeAdv node) - { - return GetValue(node) as Image; - } - - private ImageScaleMode _scaleMode = ImageScaleMode.Clip; - [DefaultValue("Clip"), Category("Appearance")] - public ImageScaleMode ScaleMode - { - get { return _scaleMode; } - set { _scaleMode = value; } - } - - - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeIntegerTextBox.cs b/Aga.Controls/Tree/NodeControls/NodeIntegerTextBox.cs deleted file mode 100644 index 7e6d075..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeIntegerTextBox.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.ComponentModel; -using System.Windows.Forms; - -namespace Aga.Controls.Tree.NodeControls -{ - - public class NodeIntegerTextBox : NodeTextBox - { - private bool _allowNegativeSign = true; - [DefaultValue(true)] - public bool AllowNegativeSign - { - get { return _allowNegativeSign; } - set { _allowNegativeSign = value; } - } - - public NodeIntegerTextBox() - { - } - - protected override TextBox CreateTextBox() - { - NumericTextBox textBox = new NumericTextBox(); - textBox.AllowDecimalSeparator = false; - textBox.AllowNegativeSign = AllowNegativeSign; - return textBox; - } - - protected override void DoApplyChanges(TreeNodeAdv node, Control editor) - { - SetValue(node, (editor as NumericTextBox).IntValue); - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeNumericUpDown.cs b/Aga.Controls/Tree/NodeControls/NodeNumericUpDown.cs deleted file mode 100644 index 743e6f7..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeNumericUpDown.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Windows.Forms; -using System.Reflection; -using System.ComponentModel; -using System.Drawing.Design; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeNumericUpDown : BaseTextControl - { - #region Properties - - private int _editorWidth = 100; - [DefaultValue(100)] - public int EditorWidth - { - get { return _editorWidth; } - set { _editorWidth = value; } - } - - private int _decimalPlaces = 0; - [Category("Data"), DefaultValue(0)] - public int DecimalPlaces - { - get - { - return this._decimalPlaces; - } - set - { - this._decimalPlaces = value; - } - } - - private decimal _increment = 1; - [Category("Data"), DefaultValue(1)] - public decimal Increment - { - get - { - return this._increment; - } - set - { - this._increment = value; - } - } - - private decimal _minimum = 0; - [Category("Data"), DefaultValue(0)] - public decimal Minimum - { - get - { - return _minimum; - } - set - { - _minimum = value; - } - } - - private decimal _maximum = 100; - [Category("Data"), DefaultValue(100)] - public decimal Maximum - { - get - { - return this._maximum; - } - set - { - this._maximum = value; - } - } - - #endregion - - public NodeNumericUpDown() - { - } - - protected override Size CalculateEditorSize(EditorContext context) - { - if (Parent.UseColumns) - return context.Bounds.Size; - else - return new Size(EditorWidth, context.Bounds.Height); - } - - protected override Control CreateEditor(TreeNodeAdv node) - { - NumericUpDown num = new NumericUpDown(); - num.Increment = Increment; - num.DecimalPlaces = DecimalPlaces; - num.Minimum = Minimum; - num.Maximum = Maximum; - num.Value = (decimal)GetValue(node); - SetEditControlProperties(num, node); - return num; - } - - protected override void DisposeEditor(Control editor) - { - } - - protected override void DoApplyChanges(TreeNodeAdv node, Control editor) - { - SetValue(node, (editor as NumericUpDown).Value); - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodePlusMinus.cs b/Aga.Controls/Tree/NodeControls/NodePlusMinus.cs deleted file mode 100644 index 209f5d8..0000000 --- a/Aga.Controls/Tree/NodeControls/NodePlusMinus.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using Aga.Controls.Properties; -using System.Windows.Forms; -using System.Windows.Forms.VisualStyles; - -namespace Aga.Controls.Tree.NodeControls -{ - internal class NodePlusMinus : NodeControl - { - public const int ImageSize = 9; - public const int Width = 16; - private Bitmap _plus; - private Bitmap _minus; - - private VisualStyleRenderer _openedRenderer; - private VisualStyleRenderer OpenedRenderer - { - get - { - if (_openedRenderer == null) - _openedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened); - return _openedRenderer; - - } - } - - private VisualStyleRenderer _closedRenderer; - private VisualStyleRenderer ClosedRenderer - { - get - { - if (_closedRenderer == null) - _closedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed); - return _closedRenderer; - } - } - - public NodePlusMinus() - { - _plus = Resources.plus; - _minus = Resources.minus; - } - - public override Size MeasureSize(TreeNodeAdv node, DrawContext context) - { - int scaledX = node.Tree.GetScaledSize(Width, false); - int scaledY = node.Tree.GetScaledSize(Width); - return new Size(scaledX, scaledY); - } - - public override void Draw(TreeNodeAdv node, DrawContext context) - { - if (node.CanExpand) - { - Rectangle r = context.Bounds; - int scaledX = node.Tree.GetScaledSize(ImageSize, false); - int scaledY = node.Tree.GetScaledSize(ImageSize); - int dy = (int)Math.Round((float)(r.Height - scaledY) / 2); - if (TreeViewAdv.CustomPlusMinusRenderFunc != null) - { - TreeViewAdv.CustomPlusMinusRenderFunc(context.Graphics, r, node.IsExpanded); - return; - } - else if (Application.RenderWithVisualStyles) - { - VisualStyleRenderer renderer; - if (node.IsExpanded) - renderer = OpenedRenderer; - else - renderer = ClosedRenderer; - renderer.DrawBackground(context.Graphics, new Rectangle(r.X, r.Y + dy, scaledX, scaledY)); - } - else - { - Image img; - if (node.IsExpanded) - img = _minus; - else - img = _plus; - context.Graphics.DrawImageUnscaled(img, new Point(r.X, r.Y + dy)); - } - } - } - - public override void MouseDown(TreeNodeAdvMouseEventArgs args) - { - if (args.Button == MouseButtons.Left) - { - args.Handled = true; - if (args.Node.CanExpand) - args.Node.IsExpanded = !args.Node.IsExpanded; - } - } - - public override void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) - { - args.Handled = true; // Supress expand/collapse when double click on plus/minus - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeStateIcon.cs b/Aga.Controls/Tree/NodeControls/NodeStateIcon.cs deleted file mode 100644 index bd041e8..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeStateIcon.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using Aga.Controls.Properties; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeStateIcon: NodeIcon - { - private Image _leaf; - private Image _opened; - private Image _closed; - - public NodeStateIcon() - { - _leaf = MakeTransparent(Resources.Leaf); - _opened = MakeTransparent(Resources.Folder); - _closed = MakeTransparent(Resources.FolderClosed); - } - - private static Image MakeTransparent(Bitmap bitmap) - { - bitmap.MakeTransparent(bitmap.GetPixel(0,0)); - return bitmap; - } - - protected override Image GetIcon(TreeNodeAdv node) - { - Image icon = base.GetIcon(node); - if (icon != null) - return icon; - else if (node.IsLeaf) - return _leaf; - else if (node.CanExpand && node.IsExpanded) - return _opened; - else - return _closed; - } - } -} diff --git a/Aga.Controls/Tree/NodeControls/NodeTextBox.cs b/Aga.Controls/Tree/NodeControls/NodeTextBox.cs deleted file mode 100644 index 81065d8..0000000 --- a/Aga.Controls/Tree/NodeControls/NodeTextBox.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Windows.Forms; -using System.Reflection; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeTextBox : BaseTextControl - { - private const int MinTextBoxWidth = 30; - - public NodeTextBox() - { - } - - protected override Size CalculateEditorSize(EditorContext context) - { - if (Parent.UseColumns) - return context.Bounds.Size; - else - { - Size size = GetLabelSize(context.CurrentNode, context.DrawContext, _label); - int width = Math.Max(size.Width + Font.Height, MinTextBoxWidth); // reserve a place for new typed character - return new Size(width, size.Height); - } - } - - public override void KeyDown(KeyEventArgs args) - { - if (args.KeyCode == Keys.F2 && Parent.CurrentNode != null && EditEnabled) - { - args.Handled = true; - BeginEdit(); - } - } - - protected override Control CreateEditor(TreeNodeAdv node) - { - TextBox textBox = CreateTextBox(); - textBox.TextAlign = TextAlign; - textBox.Text = GetLabel(node); - textBox.BorderStyle = BorderStyle.FixedSingle; - textBox.TextChanged += EditorTextChanged; - textBox.KeyDown += EditorKeyDown; - _label = textBox.Text; - SetEditControlProperties(textBox, node); - return textBox; - } - - protected virtual TextBox CreateTextBox() - { - return new TextBox(); - } - - protected override void DisposeEditor(Control editor) - { - var textBox = editor as TextBox; - textBox.TextChanged -= EditorTextChanged; - textBox.KeyDown -= EditorKeyDown; - } - - private void EditorKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - EndEdit(false); - else if (e.KeyCode == Keys.Enter) - EndEdit(true); - } - - private string _label; - private void EditorTextChanged(object sender, EventArgs e) - { - var textBox = sender as TextBox; - _label = textBox.Text; - Parent.UpdateEditorBounds(); - } - - protected override void DoApplyChanges(TreeNodeAdv node, Control editor) - { - var label = (editor as TextBox).Text; - string oldLabel = GetLabel(node); - if (oldLabel != label) - { - SetLabel(node, label); - OnLabelChanged(node.Tag, oldLabel, label); - } - } - - public override void Cut(Control control) - { - (control as TextBox).Cut(); - } - - public override void Copy(Control control) - { - (control as TextBox).Copy(); - } - - public override void Paste(Control control) - { - (control as TextBox).Paste(); - } - - public override void Delete(Control control) - { - var textBox = control as TextBox; - int len = Math.Max(textBox.SelectionLength, 1); - if (textBox.SelectionStart < textBox.Text.Length) - { - int start = textBox.SelectionStart; - textBox.Text = textBox.Text.Remove(textBox.SelectionStart, len); - textBox.SelectionStart = start; - } - } - - public event EventHandler LabelChanged; - protected void OnLabelChanged(object subject, string oldLabel, string newLabel) - { - if (LabelChanged != null) - LabelChanged(this, new LabelEventArgs(subject, oldLabel, newLabel)); - } - } -} diff --git a/Aga.Controls/Tree/SortedTreeModel.cs b/Aga.Controls/Tree/SortedTreeModel.cs deleted file mode 100644 index 96f22c2..0000000 --- a/Aga.Controls/Tree/SortedTreeModel.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Collections; - -namespace Aga.Controls.Tree -{ - public class SortedTreeModel: TreeModelBase - { - private ITreeModel _innerModel; - public ITreeModel InnerModel - { - get { return _innerModel; } - } - - private IComparer _comparer; - public IComparer Comparer - { - get { return _comparer; } - set - { - _comparer = value; - OnStructureChanged(new TreePathEventArgs(TreePath.Empty)); - } - } - - public SortedTreeModel(ITreeModel innerModel) - { - _innerModel = innerModel; - _innerModel.NodesChanged += new EventHandler(_innerModel_NodesChanged); - _innerModel.NodesInserted += new EventHandler(_innerModel_NodesInserted); - _innerModel.NodesRemoved += new EventHandler(_innerModel_NodesRemoved); - _innerModel.StructureChanged += new EventHandler(_innerModel_StructureChanged); - } - - void _innerModel_StructureChanged(object sender, TreePathEventArgs e) - { - OnStructureChanged(e); - } - - void _innerModel_NodesRemoved(object sender, TreeModelEventArgs e) - { - OnStructureChanged(new TreePathEventArgs(e.Path)); - } - - void _innerModel_NodesInserted(object sender, TreeModelEventArgs e) - { - OnStructureChanged(new TreePathEventArgs(e.Path)); - } - - void _innerModel_NodesChanged(object sender, TreeModelEventArgs e) - { - OnStructureChanged(new TreePathEventArgs(e.Path)); - } - - public override IEnumerable GetChildren(TreePath treePath) - { - if (Comparer != null) - { - ArrayList list = new ArrayList(); - IEnumerable res = InnerModel.GetChildren(treePath); - if (res != null) - { - foreach (object obj in res) - list.Add(obj); - list.Sort(Comparer); - return list; - } - else - return null; - } - else - return InnerModel.GetChildren(treePath); - } - - public override bool IsLeaf(TreePath treePath) - { - return InnerModel.IsLeaf(treePath); - } - } -} diff --git a/Aga.Controls/Tree/TreeColumn.cs b/Aga.Controls/Tree/TreeColumn.cs deleted file mode 100644 index 1dff0d7..0000000 --- a/Aga.Controls/Tree/TreeColumn.cs +++ /dev/null @@ -1,385 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.ComponentModel; -using System.Windows.Forms; -using System.Drawing; -using System.Windows.Forms.VisualStyles; -using System.Drawing.Imaging; - -namespace Aga.Controls.Tree -{ - [TypeConverter(typeof(TreeColumn.TreeColumnConverter)), DesignTimeVisible(false), ToolboxItem(false)] - public class TreeColumn : Component - { - private class TreeColumnConverter : ComponentConverter - { - public TreeColumnConverter() - : base(typeof(TreeColumn)) - { - } - - public override bool GetPropertiesSupported(ITypeDescriptorContext context) - { - return false; - } - } - - private const int HeaderLeftMargin = 5; - private const int HeaderRightMargin = 5; - private const int SortOrderMarkMargin = 8; - - private TextFormatFlags _headerFlags; - private TextFormatFlags _baseHeaderFlags = TextFormatFlags.NoPadding | - TextFormatFlags.EndEllipsis | - TextFormatFlags.VerticalCenter | - TextFormatFlags.PreserveGraphicsTranslateTransform; - - #region Properties - - private TreeColumnCollection _owner; - internal TreeColumnCollection Owner - { - get { return _owner; } - set { _owner = value; } - } - - [Browsable(false)] - public int Index - { - get - { - if (Owner != null) - return Owner.IndexOf(this); - else - return -1; - } - } - - private string _header; - [Localizable(true)] - public string Header - { - get { return _header; } - set - { - _header = value; - OnHeaderChanged(); - } - } - - private string _tooltipText; - [Localizable(true)] - public string TooltipText - { - get { return _tooltipText; } - set { _tooltipText = value; } - } - - private int _width; - [DefaultValue(50), Localizable(true)] - public int Width - { - get - { - return _width; - } - set - { - if (_width != value) - { - _width = Math.Max(MinColumnWidth, value); - if (_maxColumnWidth > 0) - { - _width = Math.Min(_width, MaxColumnWidth); - } - OnWidthChanged(); - } - } - } - - private int _minColumnWidth; - [DefaultValue(0)] - public int MinColumnWidth - { - get { return _minColumnWidth; } - set - { - if (value < 0) - throw new ArgumentOutOfRangeException("value"); - - _minColumnWidth = value; - Width = Math.Max(value, Width); - } - } - - private int _maxColumnWidth; - [DefaultValue(0)] - public int MaxColumnWidth - { - get { return _maxColumnWidth; } - set - { - if (value < 0) - throw new ArgumentOutOfRangeException("value"); - - _maxColumnWidth = value; - if (value > 0) - Width = Math.Min(value, _width); - } - } - - private bool _visible = true; - [DefaultValue(true)] - public bool IsVisible - { - get { return _visible; } - set - { - _visible = value; - OnIsVisibleChanged(); - } - } - - private HorizontalAlignment _textAlign = HorizontalAlignment.Left; - [DefaultValue(HorizontalAlignment.Left)] - public HorizontalAlignment TextAlign - { - get { return _textAlign; } - set - { - if (value != _textAlign) - { - _textAlign = value; - _headerFlags = _baseHeaderFlags | TextHelper.TranslateAligmentToFlag(value); - OnHeaderChanged(); - } - } - } - - private bool _sortable = false; - [DefaultValue(false)] - public bool Sortable - { - get { return _sortable; } - set { _sortable = value; } - } - - private SortOrder _sort_order = SortOrder.None; - public SortOrder SortOrder - { - get { return _sort_order; } - set - { - if (value == _sort_order) - return; - _sort_order = value; - OnSortOrderChanged(); - } - } - - public Size SortMarkSize - { - get - { - if (Application.RenderWithVisualStyles) - return new Size(9, 5); - else - return new Size(7, 4); - } - } - #endregion - - public TreeColumn(): - this(string.Empty, 50) - { - } - - public TreeColumn(string header, int width) - { - _header = header; - _width = width; - _headerFlags = _baseHeaderFlags | TextFormatFlags.Left; - } - - public override string ToString() - { - if (string.IsNullOrEmpty(Header)) - return GetType().Name; - else - return Header; - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - } - - #region Draw - - private static VisualStyleRenderer _normalRenderer; - private static VisualStyleRenderer _pressedRenderer; - private static VisualStyleRenderer _hotRenderer; - - private static void CreateRenderers() - { - if (Application.RenderWithVisualStyles && _normalRenderer == null) - { - _normalRenderer = new VisualStyleRenderer(VisualStyleElement.Header.Item.Normal); - _pressedRenderer = new VisualStyleRenderer(VisualStyleElement.Header.Item.Pressed); - _hotRenderer = new VisualStyleRenderer(VisualStyleElement.Header.Item.Hot); - } - } - - internal Bitmap CreateGhostImage(Rectangle bounds, Font font) - { - Bitmap b = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb); - Graphics gr = Graphics.FromImage(b); - gr.FillRectangle(SystemBrushes.ControlDark, bounds); - DrawContent(gr, bounds, font); - BitmapHelper.SetAlphaChanelValue(b, 150); - return b; - } - - internal void Draw(Graphics gr, Rectangle bounds, Font font, bool pressed, bool hot) - { - DrawBackground(gr, bounds, pressed, hot); - DrawContent(gr, bounds, font); - } - - private void DrawContent(Graphics gr, Rectangle bounds, Font font) - { - if (TreeViewAdv.CustomColumnTextRenderFunc != null) - { - TreeViewAdv.CustomColumnTextRenderFunc(gr, bounds, font, Header); - } - else - { - Rectangle innerBounds = new Rectangle(bounds.X + HeaderLeftMargin, bounds.Y, - bounds.Width - HeaderLeftMargin - HeaderRightMargin, - bounds.Height); - - if (SortOrder != SortOrder.None) - innerBounds.Width -= (SortMarkSize.Width + SortOrderMarkMargin); - - Size maxTextSize = TextRenderer.MeasureText(gr, Header, font, innerBounds.Size, TextFormatFlags.NoPadding); - Size textSize = TextRenderer.MeasureText(gr, Header, font, innerBounds.Size, _baseHeaderFlags); - - if (SortOrder != SortOrder.None) - { - int tw = Math.Min(textSize.Width, innerBounds.Size.Width); - - int x = 0; - if (TextAlign == HorizontalAlignment.Left) - x = innerBounds.X + tw + SortOrderMarkMargin; - else if (TextAlign == HorizontalAlignment.Right) - x = innerBounds.Right + SortOrderMarkMargin; - else - x = innerBounds.X + tw + (innerBounds.Width - tw) / 2 + SortOrderMarkMargin; - DrawSortMark(gr, bounds, x); - } - - if (textSize.Width < maxTextSize.Width) - TextRenderer.DrawText(gr, Header, font, innerBounds, SystemColors.ControlText, _baseHeaderFlags | TextFormatFlags.Left); - else - TextRenderer.DrawText(gr, Header, font, innerBounds, SystemColors.ControlText, _headerFlags); - } - } - - private void DrawSortMark(Graphics gr, Rectangle bounds, int x) - { - int y = bounds.Y + bounds.Height / 2 - 2; - x = Math.Max(x, bounds.X + SortOrderMarkMargin); - - int w2 = SortMarkSize.Width / 2; - if (SortOrder == SortOrder.Ascending) - { - Point[] points = new Point[] { new Point(x, y), new Point(x + SortMarkSize.Width, y), new Point(x + w2, y + SortMarkSize.Height) }; - gr.FillPolygon(SystemBrushes.ControlDark, points); - } - else if (SortOrder == SortOrder.Descending) - { - Point[] points = new Point[] { new Point(x - 1, y + SortMarkSize.Height), new Point(x + SortMarkSize.Width, y + SortMarkSize.Height), new Point(x + w2, y - 1) }; - gr.FillPolygon(SystemBrushes.ControlDark, points); - } - } - - internal static void DrawDropMark(Graphics gr, Rectangle rect) - { - gr.FillRectangle(SystemBrushes.HotTrack, rect.X-1, rect.Y, 2, rect.Height); - } - - internal static void DrawBackground(Graphics gr, Rectangle bounds, bool pressed, bool hot) - { - if (TreeViewAdv.CustomColumnBackgroundRenderFunc != null) - { - TreeViewAdv.CustomColumnBackgroundRenderFunc(gr, bounds, pressed, hot); - } - else - { - if (Application.RenderWithVisualStyles) - { - CreateRenderers(); - if (pressed) - _pressedRenderer.DrawBackground(gr, bounds); - else if (hot) - _hotRenderer.DrawBackground(gr, bounds); - else - _normalRenderer.DrawBackground(gr, bounds); - } - else - { - gr.FillRectangle(SystemBrushes.Control, bounds); - Pen p1 = SystemPens.ControlLightLight; - Pen p2 = SystemPens.ControlDark; - Pen p3 = SystemPens.ControlDarkDark; - if (pressed) - gr.DrawRectangle(p2, bounds.X, bounds.Y, bounds.Width, bounds.Height); - else - { - gr.DrawLine(p1, bounds.X, bounds.Y, bounds.Right, bounds.Y); - gr.DrawLine(p3, bounds.X, bounds.Bottom, bounds.Right, bounds.Bottom); - gr.DrawLine(p3, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 1); - gr.DrawLine(p1, bounds.Left, bounds.Y + 1, bounds.Left, bounds.Bottom - 2); - gr.DrawLine(p2, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 2); - gr.DrawLine(p2, bounds.X, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1); - } - } - } - } - - #endregion - - #region Events - - public event EventHandler HeaderChanged; - private void OnHeaderChanged() - { - if (HeaderChanged != null) - HeaderChanged(this, EventArgs.Empty); - } - - public event EventHandler SortOrderChanged; - private void OnSortOrderChanged() - { - if (SortOrderChanged != null) - SortOrderChanged(this, EventArgs.Empty); - } - - public event EventHandler IsVisibleChanged; - private void OnIsVisibleChanged() - { - if (IsVisibleChanged != null) - IsVisibleChanged(this, EventArgs.Empty); - } - - public event EventHandler WidthChanged; - private void OnWidthChanged() - { - if (WidthChanged != null) - WidthChanged(this, EventArgs.Empty); - } - - #endregion - } -} diff --git a/Aga.Controls/Tree/TreeColumnCollection.cs b/Aga.Controls/Tree/TreeColumnCollection.cs deleted file mode 100644 index 2368ec6..0000000 --- a/Aga.Controls/Tree/TreeColumnCollection.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Windows.Forms; - -namespace Aga.Controls.Tree -{ - internal class TreeColumnCollection : Collection - { - private TreeViewAdv _treeView; - - public TreeColumnCollection(TreeViewAdv treeView) - { - _treeView = treeView; - } - - protected override void InsertItem(int index, TreeColumn item) - { - base.InsertItem(index, item); - BindEvents(item); - _treeView.UpdateColumns(); - } - - protected override void RemoveItem(int index) - { - UnbindEvents(this[index]); - base.RemoveItem(index); - _treeView.UpdateColumns(); - } - - protected override void SetItem(int index, TreeColumn item) - { - UnbindEvents(this[index]); - base.SetItem(index, item); - item.Owner = this; - BindEvents(item); - _treeView.UpdateColumns(); - } - - protected override void ClearItems() - { - foreach (TreeColumn c in Items) - UnbindEvents(c); - Items.Clear(); - _treeView.UpdateColumns(); - } - - private void BindEvents(TreeColumn item) - { - item.Owner = this; - item.HeaderChanged += HeaderChanged; - item.IsVisibleChanged += IsVisibleChanged; - item.WidthChanged += WidthChanged; - item.SortOrderChanged += SortOrderChanged; - } - - private void UnbindEvents(TreeColumn item) - { - item.Owner = null; - item.HeaderChanged -= HeaderChanged; - item.IsVisibleChanged -= IsVisibleChanged; - item.WidthChanged -= WidthChanged; - item.SortOrderChanged -= SortOrderChanged; - } - - void SortOrderChanged(object sender, EventArgs e) - { - TreeColumn changed = sender as TreeColumn; - //Only one column at a time can have a sort property set - if (changed.SortOrder != SortOrder.None) - { - foreach (TreeColumn col in this) - { - if (col != changed) - col.SortOrder = SortOrder.None; - } - } - _treeView.UpdateHeaders(); - } - - void WidthChanged(object sender, EventArgs e) - { - _treeView.ChangeColumnWidth(sender as TreeColumn); - } - - void IsVisibleChanged(object sender, EventArgs e) - { - _treeView.FullUpdate(); - } - - void HeaderChanged(object sender, EventArgs e) - { - _treeView.UpdateView(); - } - } -} diff --git a/Aga.Controls/Tree/TreeColumnEventArgs.cs b/Aga.Controls/Tree/TreeColumnEventArgs.cs deleted file mode 100644 index 405c707..0000000 --- a/Aga.Controls/Tree/TreeColumnEventArgs.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - public class TreeColumnEventArgs: EventArgs - { - private TreeColumn _column; - public TreeColumn Column - { - get { return _column; } - } - - public TreeColumnEventArgs(TreeColumn column) - { - _column = column; - } - } -} diff --git a/Aga.Controls/Tree/TreeListAdapter.cs b/Aga.Controls/Tree/TreeListAdapter.cs deleted file mode 100644 index 819e568..0000000 --- a/Aga.Controls/Tree/TreeListAdapter.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - /// - /// Converts IEnumerable interface to ITreeModel. - /// Allows to display a plain list in the TreeView - /// - public class TreeListAdapter : ITreeModel - { - private System.Collections.IEnumerable _list; - - public TreeListAdapter(System.Collections.IEnumerable list) - { - _list = list; - } - - #region ITreeModel Members - - public System.Collections.IEnumerable GetChildren(TreePath treePath) - { - if (treePath.IsEmpty()) - return _list; - else - return null; - } - - public bool IsLeaf(TreePath treePath) - { - return true; - } - - public event EventHandler NodesChanged; - public void OnNodesChanged(TreeModelEventArgs args) - { - if (NodesChanged != null) - NodesChanged(this, args); - } - - public event EventHandler StructureChanged; - public void OnStructureChanged(TreePathEventArgs args) - { - if (StructureChanged != null) - StructureChanged(this, args); - } - - public event EventHandler NodesInserted; - public void OnNodeInserted(TreeModelEventArgs args) - { - if (NodesInserted != null) - NodesInserted(this, args); - } - - public event EventHandler NodesRemoved; - public void OnNodeRemoved(TreeModelEventArgs args) - { - if (NodesRemoved != null) - NodesRemoved(this, args); - } - - #endregion - } -} diff --git a/Aga.Controls/Tree/TreeModel.cs b/Aga.Controls/Tree/TreeModel.cs deleted file mode 100644 index 14ef857..0000000 --- a/Aga.Controls/Tree/TreeModel.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Collections.ObjectModel; - -namespace Aga.Controls.Tree -{ - /// - /// Provides a simple ready to use implementation of . Warning: this class is not optimized - /// to work with big amount of data. In this case create you own implementation of ITreeModel, and pay attention - /// on GetChildren and IsLeaf methods. - /// - public class TreeModel : ITreeModel - { - private Node _root; - public Node Root - { - get { return _root; } - } - - public Collection Nodes - { - get { return _root.Nodes; } - } - - public TreeModel() - { - _root = new Node(); - _root.Model = this; - } - - public TreePath GetPath(Node node) - { - if (node == _root) - return TreePath.Empty; - else - { - Stack stack = new Stack(); - while (node != _root) - { - stack.Push(node); - node = node.Parent; - } - return new TreePath(stack.ToArray()); - } - } - - public Node FindNode(TreePath path) - { - if (path.IsEmpty()) - return _root; - else - return FindNode(_root, path, 0); - } - - private Node FindNode(Node root, TreePath path, int level) - { - foreach (Node node in root.Nodes) - if (node == path.FullPath[level]) - { - if (level == path.FullPath.Length - 1) - return node; - else - return FindNode(node, path, level + 1); - } - return null; - } - - #region ITreeModel Members - - public System.Collections.IEnumerable GetChildren(TreePath treePath) - { - Node node = FindNode(treePath); - if (node != null) - foreach (Node n in node.Nodes) - yield return n; - else - yield break; - } - - public bool IsLeaf(TreePath treePath) - { - Node node = FindNode(treePath); - if (node != null) - return node.IsLeaf; - else - throw new ArgumentException("treePath"); - } - - public event EventHandler NodesChanged; - internal void OnNodesChanged(TreeModelEventArgs args) - { - if (NodesChanged != null) - NodesChanged(this, args); - } - - public event EventHandler StructureChanged; - public void OnStructureChanged(TreePathEventArgs args) - { - if (StructureChanged != null) - StructureChanged(this, args); - } - - public event EventHandler NodesInserted; - internal void OnNodeInserted(Node parent, int index, Node node) - { - if (NodesInserted != null) - { - TreeModelEventArgs args = new TreeModelEventArgs(GetPath(parent), new int[] { index }, new object[] { node }); - NodesInserted(this, args); - } - - } - - public event EventHandler NodesRemoved; - internal void OnNodeRemoved(Node parent, int index, Node node) - { - if (NodesRemoved != null) - { - TreeModelEventArgs args = new TreeModelEventArgs(GetPath(parent), new int[] { index }, new object[] { node }); - NodesRemoved(this, args); - } - } - - #endregion - } -} diff --git a/Aga.Controls/Tree/TreeModelBase.cs b/Aga.Controls/Tree/TreeModelBase.cs deleted file mode 100644 index a366295..0000000 --- a/Aga.Controls/Tree/TreeModelBase.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - public abstract class TreeModelBase: ITreeModel - { - public abstract System.Collections.IEnumerable GetChildren(TreePath treePath); - public abstract bool IsLeaf(TreePath treePath); - - - public event EventHandler NodesChanged; - protected void OnNodesChanged(TreeModelEventArgs args) - { - if (NodesChanged != null) - NodesChanged(this, args); - } - - public event EventHandler StructureChanged; - protected void OnStructureChanged(TreePathEventArgs args) - { - if (StructureChanged != null) - StructureChanged(this, args); - } - - public event EventHandler NodesInserted; - protected void OnNodesInserted(TreeModelEventArgs args) - { - if (NodesInserted != null) - NodesInserted(this, args); - } - - public event EventHandler NodesRemoved; - protected void OnNodesRemoved(TreeModelEventArgs args) - { - if (NodesRemoved != null) - NodesRemoved(this, args); - } - - public virtual void Refresh() - { - OnStructureChanged(new TreePathEventArgs(TreePath.Empty)); - } - } -} diff --git a/Aga.Controls/Tree/TreeModelEventArgs.cs b/Aga.Controls/Tree/TreeModelEventArgs.cs deleted file mode 100644 index 5148e63..0000000 --- a/Aga.Controls/Tree/TreeModelEventArgs.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - public class TreeModelEventArgs: TreePathEventArgs - { - private object[] _children; - public object[] Children - { - get { return _children; } - } - - private int[] _indices; - public int[] Indices - { - get { return _indices; } - } - - /// - /// - /// - /// Path to a parent node - /// Child nodes - public TreeModelEventArgs(TreePath parent, object[] children) - : this(parent, null, children) - { - } - - /// - /// - /// - /// Path to a parent node - /// Indices of children in parent nodes collection - /// Child nodes - public TreeModelEventArgs(TreePath parent, int[] indices, object[] children) - : base(parent) - { - if (children == null) - throw new ArgumentNullException(); - - if (indices != null && indices.Length != children.Length) - throw new ArgumentException("indices and children arrays must have the same length"); - - _indices = indices; - _children = children; - } - } -} diff --git a/Aga.Controls/Tree/TreeNodeAdv.cs b/Aga.Controls/Tree/TreeNodeAdv.cs deleted file mode 100644 index c2c6668..0000000 --- a/Aga.Controls/Tree/TreeNodeAdv.cs +++ /dev/null @@ -1,443 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Runtime.Serialization; -using System.Security.Permissions; - -namespace Aga.Controls.Tree -{ - [Serializable] - public sealed class TreeNodeAdv : ISerializable - { - #region NodeCollection - private class NodeCollection : Collection - { - private TreeNodeAdv _owner; - - public NodeCollection(TreeNodeAdv owner) - { - _owner = owner; - } - - protected override void ClearItems() - { - while (this.Count != 0) - this.RemoveAt(this.Count - 1); - } - - protected override void InsertItem(int index, TreeNodeAdv item) - { - if (item == null) - throw new ArgumentNullException("item"); - - if (item.Parent != _owner) - { - if (item.Parent != null) - item.Parent.Nodes.Remove(item); - item._parent = _owner; - item._index = index; - for (int i = index; i < Count; i++) - this[i]._index++; - base.InsertItem(index, item); - } - - if (_owner.Tree != null && _owner.Tree.Model == null) - { - _owner.Tree.SmartFullUpdate(); - } - } - - protected override void RemoveItem(int index) - { - TreeNodeAdv item = this[index]; - item._parent = null; - item._index = -1; - for (int i = index + 1; i < Count; i++) - this[i]._index--; - base.RemoveItem(index); - - if (_owner.Tree != null && _owner.Tree.Model == null) - { - _owner.Tree.UpdateSelection(); - _owner.Tree.SmartFullUpdate(); - } - } - - protected override void SetItem(int index, TreeNodeAdv item) - { - if (item == null) - throw new ArgumentNullException("item"); - RemoveAt(index); - InsertItem(index, item); - } - } - #endregion - - #region Events - - public event EventHandler Collapsing; - internal void OnCollapsing() - { - if (Collapsing != null) - Collapsing(this, new TreeViewAdvEventArgs(this)); - } - - public event EventHandler Collapsed; - internal void OnCollapsed() - { - if (Collapsed != null) - Collapsed(this, new TreeViewAdvEventArgs(this)); - } - - public event EventHandler Expanding; - internal void OnExpanding() - { - if (Expanding != null) - Expanding(this, new TreeViewAdvEventArgs(this)); - } - - public event EventHandler Expanded; - internal void OnExpanded() - { - if (Expanded != null) - Expanded(this, new TreeViewAdvEventArgs(this)); - } - - #endregion - - #region Properties - - private TreeViewAdv _tree; - public TreeViewAdv Tree - { - get { return _tree; } - } - - private int _row; - public int Row - { - get { return _row; } - internal set { _row = value; } - } - - private int _index = -1; - public int Index - { - get - { - return _index; - } - } - - private bool _isSelected; - public bool IsSelected - { - get { return _isSelected; } - set - { - if (_isSelected != value) - { - if (Tree.IsMyNode(this)) - { - //_tree.OnSelectionChanging - if (value) - { - if (!_tree.Selection.Contains(this)) - _tree.Selection.Add(this); - - if (_tree.Selection.Count == 1) - _tree.CurrentNode = this; - } - else - _tree.Selection.Remove(this); - _tree.UpdateView(); - _tree.OnSelectionChanged(); - } - _isSelected = value; - } - } - } - - /// - /// Returns true if all parent nodes of this node are expanded. - /// - internal bool IsVisible - { - get - { - TreeNodeAdv node = _parent; - while (node != null) - { - if (!node.IsExpanded) - return false; - node = node.Parent; - } - return true; - } - } - - private bool _isLeaf; - public bool IsLeaf - { - get { return _isLeaf; } - internal set { _isLeaf = value; } - } - - private bool _isExpandedOnce; - public bool IsExpandedOnce - { - get { return _isExpandedOnce; } - internal set { _isExpandedOnce = value; } - } - - private bool _isExpanded; - public bool IsExpanded - { - get { return _isExpanded; } - set - { - if (value) - Expand(); - else - Collapse(); - } - } - - internal void AssignIsExpanded(bool value) - { - _isExpanded = value; - } - - private TreeNodeAdv _parent; - public TreeNodeAdv Parent - { - get { return _parent; } - } - - public int Level - { - get - { - if (_parent == null) - return 0; - else - return _parent.Level + 1; - } - } - - public TreeNodeAdv PreviousNode - { - get - { - if (_parent != null) - { - int index = Index; - if (index > 0) - return _parent.Nodes[index - 1]; - } - return null; - } - } - - public TreeNodeAdv NextNode - { - get - { - if (_parent != null) - { - int index = Index; - if (index < _parent.Nodes.Count - 1) - return _parent.Nodes[index + 1]; - } - return null; - } - } - - internal TreeNodeAdv BottomNode - { - get - { - TreeNodeAdv parent = this.Parent; - if (parent != null) - { - if (parent.NextNode != null) - return parent.NextNode; - else - return parent.BottomNode; - } - return null; - } - } - - internal TreeNodeAdv NextVisibleNode - { - get - { - if (IsExpanded && Nodes.Count > 0) - return Nodes[0]; - else - { - TreeNodeAdv nn = NextNode; - if (nn != null) - return nn; - else - return BottomNode; - } - } - } - - public bool CanExpand - { - get - { - return (Nodes.Count > 0 || (!IsExpandedOnce && !IsLeaf)); - } - } - - private object _tag; - public object Tag - { - get { return _tag; } - } - - private Collection _nodes; - internal Collection Nodes - { - get { return _nodes; } - } - - private ReadOnlyCollection _children; - public ReadOnlyCollection Children - { - get - { - return _children; - } - } - - private int? _rightBounds; - internal int? RightBounds - { - get { return _rightBounds; } - set { _rightBounds = value; } - } - - private int? _height; - internal int? Height - { - get { return _height; } - set { _height = value; } - } - - private bool _isExpandingNow; - internal bool IsExpandingNow - { - get { return _isExpandingNow; } - set { _isExpandingNow = value; } - } - - private bool _autoExpandOnStructureChanged = true; - public bool AutoExpandOnStructureChanged - { - get { return _autoExpandOnStructureChanged; } - set { _autoExpandOnStructureChanged = value; } - } - - #endregion - - public TreeNodeAdv(object tag) - : this(null, tag) - { - } - - internal TreeNodeAdv(TreeViewAdv tree, object tag) - { - _row = -1; - _tree = tree; - _nodes = new NodeCollection(this); - _children = new ReadOnlyCollection(_nodes); - _tag = tag; - } - - public override string ToString() - { - if (Tag != null) - return Tag.ToString(); - else - return base.ToString(); - } - - public void Collapse() - { - if (_isExpanded) - Collapse(true); - } - - public void CollapseAll() - { - Collapse(false); - } - - public void Collapse(bool ignoreChildren) - { - SetIsExpanded(false, ignoreChildren); - } - - public void Expand() - { - if (!_isExpanded) - Expand(true); - } - - public void ExpandAll() - { - Expand(false); - } - - public void Expand(bool ignoreChildren) - { - SetIsExpanded(true, ignoreChildren); - } - - private void SetIsExpanded(bool value, bool ignoreChildren) - { - if (Tree == null) - _isExpanded = value; - else - Tree.SetIsExpanded(this, value, ignoreChildren); - } - - #region ISerializable Members - - private TreeNodeAdv(SerializationInfo info, StreamingContext context) - : this(null, null) - { - int nodesCount = 0; - nodesCount = info.GetInt32("NodesCount"); - _isExpanded = info.GetBoolean("IsExpanded"); - _tag = info.GetValue("Tag", typeof(object)); - - for (int i = 0; i < nodesCount; i++) - { - TreeNodeAdv child = (TreeNodeAdv)info.GetValue("Child" + i, typeof(TreeNodeAdv)); - Nodes.Add(child); - } - - } - - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - info.AddValue("IsExpanded", IsExpanded); - info.AddValue("NodesCount", Nodes.Count); - if ((Tag != null) && Tag.GetType().IsSerializable) - info.AddValue("Tag", Tag, Tag.GetType()); - - for (int i = 0; i < Nodes.Count; i++) - info.AddValue("Child" + i, Nodes[i], typeof(TreeNodeAdv)); - - } - - #endregion - } -} diff --git a/Aga.Controls/Tree/TreeNodeAdvMouseEventArgs.cs b/Aga.Controls/Tree/TreeNodeAdvMouseEventArgs.cs deleted file mode 100644 index 145c5b8..0000000 --- a/Aga.Controls/Tree/TreeNodeAdvMouseEventArgs.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public class TreeNodeAdvMouseEventArgs : MouseEventArgs - { - private TreeNodeAdv _node; - public TreeNodeAdv Node - { - get { return _node; } - internal set { _node = value; } - } - - private NodeControl _control; - public NodeControl Control - { - get { return _control; } - internal set { _control = value; } - } - - private Point _viewLocation; - public Point ViewLocation - { - get { return _viewLocation; } - internal set { _viewLocation = value; } - } - - private Keys _modifierKeys; - public Keys ModifierKeys - { - get { return _modifierKeys; } - internal set { _modifierKeys = value; } - } - - private bool _handled; - public bool Handled - { - get { return _handled; } - set { _handled = value; } - } - - private Rectangle _controlBounds; - public Rectangle ControlBounds - { - get { return _controlBounds; } - internal set { _controlBounds = value; } - } - - public TreeNodeAdvMouseEventArgs(MouseEventArgs args) - : base(args.Button, args.Clicks, args.X, args.Y, args.Delta) - { - } - } -} diff --git a/Aga.Controls/Tree/TreePath.cs b/Aga.Controls/Tree/TreePath.cs deleted file mode 100644 index 4b923ff..0000000 --- a/Aga.Controls/Tree/TreePath.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Text; -using System.Collections.ObjectModel; - -namespace Aga.Controls.Tree -{ - public class TreePath - { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TreePath Empty = new TreePath(); - - private object[] _path; - public object[] FullPath - { - get { return _path; } - } - - public object LastNode - { - get - { - if (_path.Length > 0) - return _path[_path.Length - 1]; - else - return null; - } - } - - public object FirstNode - { - get - { - if (_path.Length > 0) - return _path[0]; - else - return null; - } - } - - public TreePath() - { - _path = new object[0]; - } - - public TreePath(object node) - { - _path = new object[] { node }; - } - - public TreePath(object[] path) - { - _path = path; - } - - public TreePath(TreePath parent, object node) - { - _path = new object[parent.FullPath.Length + 1]; - for (int i = 0; i < _path.Length - 1; i++) - _path[i] = parent.FullPath[i]; - _path[_path.Length - 1] = node; - } - - public bool IsEmpty() - { - return (_path.Length == 0); - } - } -} diff --git a/Aga.Controls/Tree/TreePathEventArgs.cs b/Aga.Controls/Tree/TreePathEventArgs.cs deleted file mode 100644 index 6ee8a4d..0000000 --- a/Aga.Controls/Tree/TreePathEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - public class TreePathEventArgs : EventArgs - { - private TreePath _path; - public TreePath Path - { - get { return _path; } - } - - public TreePathEventArgs() - { - _path = new TreePath(); - } - - public TreePathEventArgs(TreePath path) - { - if (path == null) - throw new ArgumentNullException(); - - _path = path; - } - } -} diff --git a/Aga.Controls/Tree/TreeViewAdv.Designer.cs b/Aga.Controls/Tree/TreeViewAdv.Designer.cs deleted file mode 100644 index b08e641..0000000 --- a/Aga.Controls/Tree/TreeViewAdv.Designer.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Windows.Forms; - -namespace Aga.Controls.Tree -{ - partial class TreeViewAdv - { - private System.ComponentModel.IContainer components = null; - - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - if (_dragBitmap != null) _dragBitmap.Dispose(); - if (_dragTimer != null) _dragTimer.Dispose(); - if (_linePen != null) _linePen.Dispose(); - if (_markPen != null) _markPen.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this._vScrollBar = new System.Windows.Forms.VScrollBar(); - this._hScrollBar = new System.Windows.Forms.HScrollBar(); - this._errorProvider = new System.Windows.Forms.ErrorProvider(this.components); - ((System.ComponentModel.ISupportInitialize)(this._errorProvider)).BeginInit(); - this.SuspendLayout(); - // - // _vScrollBar - // - this._vScrollBar.LargeChange = 1; - this._vScrollBar.Location = new System.Drawing.Point(0, 0); - this._vScrollBar.Maximum = 0; - this._vScrollBar.Name = "_vScrollBar"; - this._vScrollBar.Size = new System.Drawing.Size(13, 80); - this._vScrollBar.TabIndex = 1; - this._vScrollBar.ValueChanged += new System.EventHandler(this._vScrollBar_ValueChanged); - this._vScrollBar.Scroll += new System.Windows.Forms.ScrollEventHandler(this._vScrollBar_Scroll); - // - // _hScrollBar - // - this._hScrollBar.LargeChange = 1; - this._hScrollBar.Location = new System.Drawing.Point(0, 0); - this._hScrollBar.Maximum = 0; - this._hScrollBar.Name = "_hScrollBar"; - this._hScrollBar.Size = new System.Drawing.Size(80, 13); - this._hScrollBar.TabIndex = 2; - this._hScrollBar.ValueChanged += new System.EventHandler(this._hScrollBar_ValueChanged); - this._hScrollBar.Scroll += new System.Windows.Forms.ScrollEventHandler(this._hScrollBar_Scroll); - // - // TreeViewAdv - // - this.BackColor = System.Drawing.SystemColors.Window; - this.Controls.Add(this._vScrollBar); - this.Controls.Add(this._hScrollBar); - ((System.ComponentModel.ISupportInitialize)(this._errorProvider)).EndInit(); - this.ResumeLayout(false); - - } - #endregion - - private VScrollBar _vScrollBar; - private HScrollBar _hScrollBar; - private ErrorProvider _errorProvider; - } -} diff --git a/Aga.Controls/Tree/TreeViewAdv.Draw.cs b/Aga.Controls/Tree/TreeViewAdv.Draw.cs deleted file mode 100644 index 60f8662..0000000 --- a/Aga.Controls/Tree/TreeViewAdv.Draw.cs +++ /dev/null @@ -1,310 +0,0 @@ -using System; -using System.Drawing; -using System.Diagnostics; -using System.Drawing.Drawing2D; -using System.Windows.Forms; -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public partial class TreeViewAdv - { - public void AutoSizeColumn(TreeColumn column) - { - if (!Columns.Contains(column)) - throw new ArgumentException("column"); - - DrawContext context = new DrawContext(); - context.Graphics = Graphics.FromImage(new Bitmap(1, 1)); - context.Font = this.Font; - int res = 0; - for (int row = 0; row < RowCount; row++) - { - if (row < RowMap.Count) - { - int w = 0; - TreeNodeAdv node = RowMap[row]; - foreach (NodeControl nc in NodeControls) - { - if (nc.ParentColumn == column) - w += nc.GetActualSize(node, _measureContext).Width; - } - res = Math.Max(res, w); - } - } - - if (res > 0) - column.Width = res; - } - - private void CreatePens() - { - CreateLinePen(); - CreateMarkPen(); - } - - private void CreateMarkPen() - { - GraphicsPath path = new GraphicsPath(); - path.AddLines(new Point[] { new Point(0, 0), new Point(1, 1), new Point(-1, 1), new Point(0, 0) }); - CustomLineCap cap = new CustomLineCap(null, path); - cap.WidthScale = 1.0f; - - _markPen = new Pen(_dragDropMarkColor, _dragDropMarkWidth); - _markPen.CustomStartCap = cap; - _markPen.CustomEndCap = cap; - } - - private void CreateLinePen() - { - _linePen = new Pen(_lineColor); - _linePen.DashStyle = DashStyle.Dot; - } - - protected override void OnPaint(PaintEventArgs e) - { - BeginPerformanceCount(); - PerformanceAnalyzer.Start("OnPaint"); - - DrawContext context = new DrawContext(); - context.Graphics = e.Graphics; - context.Font = this.Font; - context.Enabled = Enabled; - - int y = 0; - int gridHeight = 0; - - if (UseColumns) - { - DrawColumnHeaders(e.Graphics); - y += ColumnHeaderHeight; - if (Columns.Count == 0 || e.ClipRectangle.Height <= y) - return; - } - - int firstRowY = _rowLayout.GetRowBounds(FirstVisibleRow).Y; - y -= firstRowY; - - e.Graphics.ResetTransform(); - e.Graphics.TranslateTransform(-OffsetX, y); - Rectangle displayRect = DisplayRectangle; - for (int row = FirstVisibleRow; row < RowCount; row++) - { - Rectangle rowRect = _rowLayout.GetRowBounds(row); - gridHeight += rowRect.Height; - if (rowRect.Y + y > displayRect.Bottom) - break; - else - DrawRow(e, ref context, row, rowRect); - } - - if ((GridLineStyle & GridLineStyle.Vertical) == GridLineStyle.Vertical && UseColumns) - DrawVerticalGridLines(e.Graphics, firstRowY); - - if (_dropPosition.Node != null && DragMode && HighlightDropPosition) - DrawDropMark(e.Graphics); - - e.Graphics.ResetTransform(); - DrawScrollBarsBox(e.Graphics); - - if (DragMode && _dragBitmap != null) - e.Graphics.DrawImage(_dragBitmap, PointToClient(MousePosition)); - - PerformanceAnalyzer.Finish("OnPaint"); - EndPerformanceCount(e); - } - - private void DrawRow(PaintEventArgs e, ref DrawContext context, int row, Rectangle rowRect) - { - TreeNodeAdv node = RowMap[row]; - context.DrawSelection = DrawSelectionMode.None; - context.CurrentEditorOwner = CurrentEditorOwner; - if (DragMode) - { - if ((_dropPosition.Node == node) && _dropPosition.Position == NodePosition.Inside && HighlightDropPosition) - context.DrawSelection = DrawSelectionMode.Active; - } - else - { - if (node.IsSelected && Focused) - context.DrawSelection = DrawSelectionMode.Active; - else if (node.IsSelected && !Focused && !HideSelection) - context.DrawSelection = DrawSelectionMode.Inactive; - } - context.DrawFocus = Focused && CurrentNode == node; - - OnRowDraw(e, node, context, row, rowRect); - - if ((GridLineStyle & GridLineStyle.Horizontal) == GridLineStyle.Horizontal) { - e.Graphics.DrawLine(CustomHorizontalLinePen, 0, rowRect.Bottom, e.Graphics.ClipBounds.Right, rowRect.Bottom); - } - - if (FullRowSelect) - { - context.DrawFocus = false; - if (context.DrawSelection == DrawSelectionMode.Active || context.DrawSelection == DrawSelectionMode.Inactive) - { - Rectangle focusRect = new Rectangle(OffsetX, rowRect.Y, ClientRectangle.Width, rowRect.Height); - if (context.DrawSelection == DrawSelectionMode.Active) - { - e.Graphics.FillRectangle(CustomSelectedRowBrush, focusRect); - context.DrawSelection = DrawSelectionMode.FullRowSelect; - } - else - { - e.Graphics.FillRectangle(CustomSelectedRowBrush, focusRect); - context.DrawSelection = DrawSelectionMode.None; - } - } - } - - if (ShowLines) - DrawLines(e.Graphics, node, rowRect); - - DrawNode(node, context); - } - - private void DrawVerticalGridLines(Graphics gr, int y) - { - int x = 0; - foreach (TreeColumn c in Columns) - { - if (c.IsVisible) - { - x += c.Width; - gr.DrawLine(SystemPens.InactiveBorder, x - 1, y, x - 1, gr.ClipBounds.Bottom); - } - } - } - - private void DrawColumnHeaders(Graphics gr) - { - PerformanceAnalyzer.Start("DrawColumnHeaders"); - ReorderColumnState reorder = Input as ReorderColumnState; - int x = 0; - TreeColumn.DrawBackground(gr, new Rectangle(0, 0, ClientRectangle.Width + 2, ColumnHeaderHeight - 1), false, false); - gr.TranslateTransform(-OffsetX, 0); - foreach (TreeColumn c in Columns) - { - if (c.IsVisible) - { - if (x >= OffsetX && x - OffsetX < this.Bounds.Width)// skip invisible columns - { - Rectangle rect = new Rectangle(x, 0, c.Width, ColumnHeaderHeight - 1); - gr.SetClip(rect); - bool pressed = ((Input is ClickColumnState || reorder != null) && ((Input as ColumnState).Column == c)); - c.Draw(gr, rect, Font, pressed, _hotColumn == c); - gr.ResetClip(); - - if (reorder != null && reorder.DropColumn == c) - TreeColumn.DrawDropMark(gr, rect); - } - x += c.Width; - } - } - - if (reorder != null) - { - if (reorder.DropColumn == null) - TreeColumn.DrawDropMark(gr, new Rectangle(x, 0, 0, ColumnHeaderHeight)); - gr.DrawImage(reorder.GhostImage, new Point(reorder.Location.X + + reorder.DragOffset, reorder.Location.Y)); - } - PerformanceAnalyzer.Finish("DrawColumnHeaders"); - } - - public void DrawNode(TreeNodeAdv node, DrawContext context) - { - foreach (NodeControlInfo item in GetNodeControls(node)) - { - if (item.Bounds.Right >= OffsetX && item.Bounds.X - OffsetX < this.Bounds.Width)// skip invisible nodes - { - context.Bounds = item.Bounds; - context.Graphics.SetClip(context.Bounds); - item.Control.Draw(node, context); - context.Graphics.ResetClip(); - } - } - } - - private void DrawScrollBarsBox(Graphics gr) - { - Rectangle r1 = DisplayRectangle; - Rectangle r2 = ClientRectangle; - gr.FillRectangle(SystemBrushes.Control, - new Rectangle(r1.Right, r1.Bottom, r2.Width - r1.Width, r2.Height - r1.Height)); - } - - private void DrawDropMark(Graphics gr) - { - if (_dropPosition.Position == NodePosition.Inside) - return; - - Rectangle rect = GetNodeBounds(_dropPosition.Node); - int right = DisplayRectangle.Right - LeftMargin + OffsetX; - int y = rect.Y; - if (_dropPosition.Position == NodePosition.After) - y = rect.Bottom; - gr.DrawLine(_markPen, rect.X, y, right, y); - } - - private void DrawLines(Graphics gr, TreeNodeAdv node, Rectangle rowRect) - { - if (UseColumns && Columns.Count > 0) - gr.SetClip(new Rectangle(0, rowRect.Y, Columns[0].Width, rowRect.Bottom)); - - TreeNodeAdv curNode = node; - while (curNode != _root && curNode != null) - { - int level = curNode.Level; - int scaledIndent = node.Tree.GetScaledSize(_indent, false); - int x = (level - 1) * scaledIndent + NodePlusMinus.ImageSize / 2 + LeftMargin; - int width = node.Tree.GetScaledSize(NodePlusMinus.Width - NodePlusMinus.ImageSize / 2, false); - int y = rowRect.Y; - int y2 = y + rowRect.Height; - - if (curNode == node) - { - int midy = y + rowRect.Height / 2; - gr.DrawLine(_linePen, x, midy, x + width, midy); - if (curNode.NextNode == null) - y2 = y + rowRect.Height / 2; - } - - if (node.Row == 0) - y = rowRect.Height / 2; - if (curNode.NextNode != null || curNode == node) - gr.DrawLine(_linePen, x, y, x, y2); - - curNode = curNode.Parent; - } - - gr.ResetClip(); - } - - #region Performance - - private double _totalTime; - private int _paintCount; - - [Conditional("PERF_TEST")] - private void BeginPerformanceCount() - { - _paintCount++; - TimeCounter.Start(); - } - - [Conditional("PERF_TEST")] - private void EndPerformanceCount(PaintEventArgs e) - { - double time = TimeCounter.Finish(); - _totalTime += time; - string debugText = string.Format("FPS {0:0.0}; Avg. FPS {1:0.0}", - 1 / time, 1 / (_totalTime / _paintCount)); - e.Graphics.FillRectangle(Brushes.White, new Rectangle(DisplayRectangle.Width - 150, DisplayRectangle.Height - 20, 150, 20)); - e.Graphics.DrawString(debugText, Control.DefaultFont, Brushes.Gray, - new PointF(DisplayRectangle.Width - 150, DisplayRectangle.Height - 20)); - } - #endregion - - } -} diff --git a/Aga.Controls/Tree/TreeViewAdv.Editor.cs b/Aga.Controls/Tree/TreeViewAdv.Editor.cs deleted file mode 100644 index b65aca0..0000000 --- a/Aga.Controls/Tree/TreeViewAdv.Editor.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using Aga.Controls.Tree.NodeControls; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - partial class TreeViewAdv - { - private TreeNodeAdv _editingNode; - - public EditableControl CurrentEditorOwner { get; private set; } - public Control CurrentEditor { get; private set; } - - public void HideEditor() - { - if (CurrentEditorOwner != null) - CurrentEditorOwner.EndEdit(false); - } - - internal void DisplayEditor(Control editor, EditableControl owner) - { - if (editor == null || owner == null || CurrentNode == null) - throw new ArgumentNullException(); - - HideEditor(false); - - CurrentEditor = editor; - CurrentEditorOwner = owner; - _editingNode = CurrentNode; - - editor.Validating += EditorValidating; - UpdateEditorBounds(); - UpdateView(); - editor.Parent = this; - editor.Focus(); - owner.UpdateEditor(editor); - } - - internal bool HideEditor(bool applyChanges) - { - if (CurrentEditor != null) - { - if (applyChanges) - { - if (!ApplyChanges()) - return false; - } - - //Check once more if editor was closed in ApplyChanges - if (CurrentEditor != null) - { - CurrentEditor.Validating -= EditorValidating; - CurrentEditorOwner.DoDisposeEditor(CurrentEditor); - - CurrentEditor.Parent = null; - CurrentEditor.Dispose(); - - CurrentEditor = null; - CurrentEditorOwner = null; - _editingNode = null; - } - } - return true; - } - - private bool ApplyChanges() - { - try - { - CurrentEditorOwner.ApplyChanges(_editingNode, CurrentEditor); - _errorProvider.Clear(); - return true; - } - catch (ArgumentException ex) - { - _errorProvider.SetError(CurrentEditor, ex.Message); - /*CurrentEditor.Validating -= EditorValidating; - MessageBox.Show(this, ex.Message, "Value is not valid", MessageBoxButtons.OK, MessageBoxIcon.Warning); - CurrentEditor.Focus(); - CurrentEditor.Validating += EditorValidating;*/ - return false; - } - } - - void EditorValidating(object sender, System.ComponentModel.CancelEventArgs e) - { - e.Cancel = !ApplyChanges(); - } - - public void UpdateEditorBounds() - { - if (CurrentEditor != null) - { - EditorContext context = new EditorContext(); - context.Owner = CurrentEditorOwner; - context.CurrentNode = CurrentNode; - context.Editor = CurrentEditor; - context.DrawContext = _measureContext; - SetEditorBounds(context); - } - } - - private void SetEditorBounds(EditorContext context) - { - foreach (NodeControlInfo info in GetNodeControls(context.CurrentNode)) - { - if (context.Owner == info.Control && info.Control is EditableControl) - { - Point p = info.Bounds.Location; - p.X += info.Control.LeftMargin; - p.X -= OffsetX; - p.Y -= (_rowLayout.GetRowBounds(FirstVisibleRow).Y - ColumnHeaderHeight); - int width = DisplayRectangle.Width - p.X; - if (UseColumns && info.Control.ParentColumn != null && Columns.Contains(info.Control.ParentColumn)) - { - Rectangle rect = GetColumnBounds(info.Control.ParentColumn.Index); - width = rect.Right - OffsetX - p.X; - } - context.Bounds = new Rectangle(p.X, p.Y, width, info.Bounds.Height); - ((EditableControl)info.Control).SetEditorBounds(context); - return; - } - } - } - - private Rectangle GetColumnBounds(int column) - { - int x = 0; - for (int i = 0; i < Columns.Count; i++) - { - if (Columns[i].IsVisible) - { - if (i < column) - x += Columns[i].Width; - else - return new Rectangle(x, 0, Columns[i].Width, 0); - } - } - return Rectangle.Empty; - } - } -} diff --git a/Aga.Controls/Tree/TreeViewAdv.Input.cs b/Aga.Controls/Tree/TreeViewAdv.Input.cs deleted file mode 100644 index 466a233..0000000 --- a/Aga.Controls/Tree/TreeViewAdv.Input.cs +++ /dev/null @@ -1,568 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; -using Aga.Controls.Tree.NodeControls; -using System.Drawing.Imaging; -using System.Threading; - -namespace Aga.Controls.Tree -{ - public partial class TreeViewAdv - { - #region Keys - - protected override bool IsInputChar(char charCode) - { - return true; - } - - protected override bool IsInputKey(Keys keyData) - { - if (((keyData & Keys.Up) == Keys.Up) - || ((keyData & Keys.Down) == Keys.Down) - || ((keyData & Keys.Left) == Keys.Left) - || ((keyData & Keys.Right) == Keys.Right)) - return true; - else - return base.IsInputKey(keyData); - } - - internal void ChangeInput() - { - if ((ModifierKeys & Keys.Shift) == Keys.Shift) - { - if (!(Input is InputWithShift)) - Input = new InputWithShift(this); - } - else if ((ModifierKeys & Keys.Control) == Keys.Control) - { - if (!(Input is InputWithControl)) - Input = new InputWithControl(this); - } - else - { - if (!(Input.GetType() == typeof(NormalInputState))) - Input = new NormalInputState(this); - } - } - - protected override void OnKeyDown(KeyEventArgs e) - { - base.OnKeyDown(e); - if (!e.Handled) - { - if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.ControlKey) - ChangeInput(); - Input.KeyDown(e); - if (!e.Handled) - { - foreach (NodeControlInfo item in GetNodeControls(CurrentNode)) - { - item.Control.KeyDown(e); - if (e.Handled) - break; - } - } - } - } - - protected override void OnKeyUp(KeyEventArgs e) - { - base.OnKeyUp(e); - if (!e.Handled) - { - if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.ControlKey) - ChangeInput(); - if (!e.Handled) - { - foreach (NodeControlInfo item in GetNodeControls(CurrentNode)) - { - item.Control.KeyUp(e); - if (e.Handled) - return; - } - } - } - } - - protected override void OnKeyPress(KeyPressEventArgs e) - { - base.OnKeyPress(e); - if (!e.Handled) - _search.Search(e.KeyChar); - } - - #endregion - - #region Mouse - - private TreeNodeAdvMouseEventArgs CreateMouseArgs(MouseEventArgs e) - { - TreeNodeAdvMouseEventArgs args = new TreeNodeAdvMouseEventArgs(e); - args.ViewLocation = new Point(e.X + OffsetX, - e.Y + _rowLayout.GetRowBounds(FirstVisibleRow).Y - ColumnHeaderHeight); - args.ModifierKeys = ModifierKeys; - args.Node = GetNodeAt(e.Location); - NodeControlInfo info = GetNodeControlInfoAt(args.Node, e.Location); - args.ControlBounds = info.Bounds; - args.Control = info.Control; - return args; - } - - protected override void OnMouseWheel(MouseEventArgs e) - { - _search.EndSearch(); - if (SystemInformation.MouseWheelScrollLines > 0) - { - // Accumulate sub-120 deltas from high-resolution precision trackpads. - // Classic scroll wheels always send multiples of 120; precision devices - // send smaller values (e.g. 15) that would integer-divide to zero. - _wheelDeltaRemainder += e.Delta; - int lines = _wheelDeltaRemainder / 120 * SystemInformation.MouseWheelScrollLines; - _wheelDeltaRemainder %= 120; - if (lines != 0) - { - int newValue = _vScrollBar.Value - lines; - newValue = Math.Min(_vScrollBar.Maximum - _vScrollBar.LargeChange + 1, newValue); - newValue = Math.Min(_vScrollBar.Maximum, newValue); - _vScrollBar.Value = Math.Max(_vScrollBar.Minimum, newValue); - } - } - base.OnMouseWheel(e); - } - - private int _wheelDeltaRemainder; - - protected override void OnMouseDown(MouseEventArgs e) - { - if (CurrentEditorOwner != null) - { - CurrentEditorOwner.EndEdit(true); - return; - } - - if (!Focused) - Focus(); - - _search.EndSearch(); - if (e.Button == MouseButtons.Left) - { - TreeColumn c; - c = GetColumnDividerAt(e.Location); - if (c != null) - { - Input = new ResizeColumnState(this, c, e.Location); - return; - } - c = GetColumnAt(e.Location); - if (c != null) - { - Input = new ClickColumnState(this, c, e.Location); - UpdateView(); - return; - } - } - - ChangeInput(); - TreeNodeAdvMouseEventArgs args = CreateMouseArgs(e); - - if (args.Node != null && args.Control != null) - args.Control.MouseDown(args); - - if (!args.Handled) - Input.MouseDown(args); - - base.OnMouseDown(e); - } - - protected override void OnMouseClick(MouseEventArgs e) - { - //TODO: Disable when click on plusminus icon - TreeNodeAdvMouseEventArgs args = CreateMouseArgs(e); - if (args.Node != null) - OnNodeMouseClick(args); - - base.OnMouseClick(e); - } - - protected override void OnMouseDoubleClick(MouseEventArgs e) - { - TreeNodeAdvMouseEventArgs args = CreateMouseArgs(e); - - if (args.Node != null && args.Control != null) - args.Control.MouseDoubleClick(args); - - if (!args.Handled) - { - if (args.Node != null) - OnNodeMouseDoubleClick(args); - else - Input.MouseDoubleClick(args); - - if (!args.Handled) - { - if (args.Node != null && args.Button == MouseButtons.Left) - args.Node.IsExpanded = !args.Node.IsExpanded; - } - } - - base.OnMouseDoubleClick(e); - } - - protected override void OnMouseUp(MouseEventArgs e) - { - TreeNodeAdvMouseEventArgs args = CreateMouseArgs(e); - if (Input is ResizeColumnState) - Input.MouseUp(args); - else - { - if (args.Node != null && args.Control != null) - args.Control.MouseUp(args); - if (!args.Handled) - Input.MouseUp(args); - - base.OnMouseUp(e); - } - } - - protected override void OnMouseMove(MouseEventArgs e) - { - if (Input.MouseMove(e)) - return; - - base.OnMouseMove(e); - SetCursor(e); - UpdateToolTip(e); - if (ItemDragMode && Dist(e.Location, ItemDragStart) > ItemDragSensivity - && CurrentNode != null && CurrentNode.IsSelected) - { - ItemDragMode = false; - _toolTip.Active = false; - OnItemDrag(e.Button, Selection.ToArray()); - } - } - - protected override void OnMouseLeave(EventArgs e) - { - _hotColumn = null; - UpdateHeaders(); - base.OnMouseLeave(e); - } - - private void SetCursor(MouseEventArgs e) - { - TreeColumn col; - col = GetColumnDividerAt(e.Location); - if (col == null) - _innerCursor = null; - else - { - if (col.Width == 0) - _innerCursor = ResourceHelper.DVSplitCursor; - else - _innerCursor = Cursors.VSplit; - } - - col = GetColumnAt(e.Location); - if (col != _hotColumn) - { - _hotColumn = col; - UpdateHeaders(); - } - } - - internal TreeColumn GetColumnAt(Point p) - { - if (p.Y > ColumnHeaderHeight) - return null; - - int x = -OffsetX; - foreach (TreeColumn col in Columns) - { - if (col.IsVisible) - { - Rectangle rect = new Rectangle(x, 0, col.Width, ColumnHeaderHeight); - x += col.Width; - if (rect.Contains(p)) - return col; - } - } - return null; - } - - internal int GetColumnX(TreeColumn column) - { - int x = -OffsetX; - foreach (TreeColumn col in Columns) - { - if (col.IsVisible) - { - if (column == col) - return x; - else - x += col.Width; - } - } - return x; - } - - internal TreeColumn GetColumnDividerAt(Point p) - { - if (p.Y > ColumnHeaderHeight) - return null; - - int x = -OffsetX; - TreeColumn prevCol = null; - Rectangle left, right; - foreach (TreeColumn col in Columns) - { - if (col.IsVisible) - { - if (col.Width > 0) - { - left = new Rectangle(x, 0, DividerWidth / 2, ColumnHeaderHeight); - right = new Rectangle(x + col.Width - (DividerWidth / 2), 0, DividerWidth / 2, ColumnHeaderHeight); - if (left.Contains(p) && prevCol != null) - return prevCol; - else if (right.Contains(p)) - return col; - } - prevCol = col; - x += col.Width; - } - } - - left = new Rectangle(x, 0, DividerWidth / 2, ColumnHeaderHeight); - if (left.Contains(p) && prevCol != null) - return prevCol; - - return null; - } - - TreeColumn _tooltipColumn; - private void UpdateToolTip(MouseEventArgs e) - { - TreeColumn col = GetColumnAt(e.Location); - if (col != null) - { - if (col != _tooltipColumn) - SetTooltip(col.TooltipText); - } - else - DisplayNodesTooltip(e); - _tooltipColumn = col; - } - - TreeNodeAdv _hotNode; - NodeControl _hotControl; - private void DisplayNodesTooltip(MouseEventArgs e) - { - if (ShowNodeToolTips) - { - TreeNodeAdvMouseEventArgs args = CreateMouseArgs(e); - if (args.Node != null && args.Control != null) - { - if (args.Node != _hotNode || args.Control != _hotControl) - SetTooltip(GetNodeToolTip(args)); - } - else - _toolTip.SetToolTip(this, null); - - _hotControl = args.Control; - _hotNode = args.Node; - } - else - _toolTip.SetToolTip(this, null); - } - - private void SetTooltip(string text) - { - if (!String.IsNullOrEmpty(text)) - { - _toolTip.Active = false; - _toolTip.SetToolTip(this, text); - _toolTip.Active = true; - } - else - _toolTip.SetToolTip(this, null); - } - - private string GetNodeToolTip(TreeNodeAdvMouseEventArgs args) - { - string msg = args.Control.GetToolTip(args.Node); - - BaseTextControl btc = args.Control as BaseTextControl; - if (btc != null && btc.DisplayHiddenContentInToolTip && String.IsNullOrEmpty(msg)) - { - Size ms = btc.GetActualSize(args.Node, _measureContext); - if (ms.Width > args.ControlBounds.Size.Width || ms.Height > args.ControlBounds.Size.Height - || args.ControlBounds.Right - OffsetX > DisplayRectangle.Width) - msg = btc.GetLabel(args.Node); - } - - if (String.IsNullOrEmpty(msg) && DefaultToolTipProvider != null) - msg = DefaultToolTipProvider.GetToolTip(args.Node, args.Control); - - return msg; - } - - #endregion - - #region DragDrop - - private bool _dragAutoScrollFlag = false; - private Bitmap _dragBitmap = null; - private System.Threading.Timer _dragTimer; - - private void StartDragTimer() - { - if (_dragTimer == null) - _dragTimer = new System.Threading.Timer(new TimerCallback(DragTimerTick), null, 0, 100); - } - - private void StopDragTimer() - { - if (_dragTimer != null) - { - _dragTimer.Dispose(); - _dragTimer = null; - } - } - - private void SetDropPosition(Point pt) - { - TreeNodeAdv node = GetNodeAt(pt); - OnDropNodeValidating(pt, ref node); - _dropPosition.Node = node; - if (node != null) - { - Rectangle first = _rowLayout.GetRowBounds(FirstVisibleRow); - Rectangle bounds = _rowLayout.GetRowBounds(node.Row); - float pos = (pt.Y + first.Y - ColumnHeaderHeight - bounds.Y) / (float)bounds.Height; - if (pos < TopEdgeSensivity) - _dropPosition.Position = NodePosition.Before; - else if (pos > (1 - BottomEdgeSensivity)) - _dropPosition.Position = NodePosition.After; - else - _dropPosition.Position = NodePosition.Inside; - } - } - - private void DragTimerTick(object state) - { - _dragAutoScrollFlag = true; - } - - private void DragAutoScroll() - { - _dragAutoScrollFlag = false; - Point pt = PointToClient(MousePosition); - if (pt.Y < 20 && _vScrollBar.Value > 0) - _vScrollBar.Value--; - else if (pt.Y > Height - 20 && _vScrollBar.Value <= _vScrollBar.Maximum - _vScrollBar.LargeChange) - _vScrollBar.Value++; - } - - public void DoDragDropSelectedNodes(DragDropEffects allowedEffects) - { - if (SelectedNodes.Count > 0) - { - TreeNodeAdv[] nodes = new TreeNodeAdv[SelectedNodes.Count]; - SelectedNodes.CopyTo(nodes, 0); - DoDragDrop(nodes, allowedEffects); - } - } - - private void CreateDragBitmap(IDataObject data) - { - if (UseColumns || !DisplayDraggingNodes) - return; - - TreeNodeAdv[] nodes = data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[]; - if (nodes != null && nodes.Length > 0) - { - Rectangle rect = DisplayRectangle; - Bitmap bitmap = new Bitmap(rect.Width, rect.Height); - using (Graphics gr = Graphics.FromImage(bitmap)) - { - gr.Clear(BackColor); - DrawContext context = new DrawContext(); - context.Graphics = gr; - context.Font = Font; - context.Enabled = true; - int y = 0; - int maxWidth = 0; - foreach (TreeNodeAdv node in nodes) - { - if (node.Tree == this) - { - int x = 0; - int height = _rowLayout.GetRowBounds(node.Row).Height; - foreach (NodeControl c in NodeControls) - { - Size s = c.GetActualSize(node, context); - if (!s.IsEmpty) - { - int width = s.Width; - rect = new Rectangle(x, y, width, height); - x += (width + 1); - context.Bounds = rect; - c.Draw(node, context); - } - } - y += height; - maxWidth = Math.Max(maxWidth, x); - } - } - - if (maxWidth > 0 && y > 0) - { - _dragBitmap = new Bitmap(maxWidth, y, PixelFormat.Format32bppArgb); - using (Graphics tgr = Graphics.FromImage(_dragBitmap)) - tgr.DrawImage(bitmap, Point.Empty); - BitmapHelper.SetAlphaChanelValue(_dragBitmap, 150); - } - else - _dragBitmap = null; - } - } - } - - protected override void OnDragOver(DragEventArgs drgevent) - { - ItemDragMode = false; - Point pt = PointToClient(new Point(drgevent.X, drgevent.Y)); - if (_dragAutoScrollFlag) - DragAutoScroll(); - SetDropPosition(pt); - UpdateView(); - base.OnDragOver(drgevent); - } - - protected override void OnDragEnter(DragEventArgs drgevent) - { - _search.EndSearch(); - DragMode = true; - CreateDragBitmap(drgevent.Data); - base.OnDragEnter(drgevent); - } - - protected override void OnDragLeave(EventArgs e) - { - DragMode = false; - UpdateView(); - base.OnDragLeave(e); - } - - protected override void OnDragDrop(DragEventArgs drgevent) - { - DragMode = false; - UpdateView(); - base.OnDragDrop(drgevent); - } - - #endregion - } -} diff --git a/Aga.Controls/Tree/TreeViewAdv.Properties.cs b/Aga.Controls/Tree/TreeViewAdv.Properties.cs deleted file mode 100644 index 6d042d0..0000000 --- a/Aga.Controls/Tree/TreeViewAdv.Properties.cs +++ /dev/null @@ -1,727 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Drawing; -using System.Drawing.Design; -using System.Windows.Forms; - -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public partial class TreeViewAdv - { - private Cursor _innerCursor = null; - - public override Cursor Cursor - { - get - { - if (_innerCursor != null) - return _innerCursor; - else - return base.Cursor; - } - set - { - base.Cursor = value; - } - } - - #region Internal Properties - - private IRowLayout _rowLayout; - - private bool _dragMode; - private bool DragMode - { - get { return _dragMode; } - set - { - _dragMode = value; - if (!value) - { - StopDragTimer(); - if (_dragBitmap != null) - _dragBitmap.Dispose(); - _dragBitmap = null; - } - else - StartDragTimer(); - } - } - - internal int ColumnHeaderHeight - { - get - { - if (UseColumns) - return _columnHeaderHeight; - else - return 0; - } - } - - /// - /// returns all nodes, which parent is expanded - /// - private IEnumerable VisibleNodes - { - get - { - TreeNodeAdv node = Root; - while (node != null) - { - node = node.NextVisibleNode; - if (node != null) - yield return node; - } - } - } - - private bool _suspendSelectionEvent; - internal bool SuspendSelectionEvent - { - get { return _suspendSelectionEvent; } - set - { - if (value != _suspendSelectionEvent) - { - _suspendSelectionEvent = value; - if (!_suspendSelectionEvent && _fireSelectionEvent) - OnSelectionChanged(); - } - } - } - - private List _rowMap; - internal List RowMap - { - get { return _rowMap; } - } - - private TreeNodeAdv _selectionStart; - internal TreeNodeAdv SelectionStart - { - get { return _selectionStart; } - set { _selectionStart = value; } - } - - private InputState _input; - internal InputState Input - { - get { return _input; } - set - { - _input = value; - } - } - - private bool _itemDragMode; - internal bool ItemDragMode - { - get { return _itemDragMode; } - set { _itemDragMode = value; } - } - - private Point _itemDragStart; - internal Point ItemDragStart - { - get { return _itemDragStart; } - set { _itemDragStart = value; } - } - - - /// - /// Number of rows fits to the current page - /// - internal int CurrentPageSize - { - get - { - return _rowLayout.CurrentPageSize; - } - } - - /// - /// Number of all visible nodes (which parent is expanded) - /// - internal int RowCount - { - get - { - return RowMap.Count; - } - } - - private int _contentWidth = 0; - private int ContentWidth - { - get - { - return _contentWidth; - } - } - - private int _firstVisibleRow; - internal int FirstVisibleRow - { - get { return _firstVisibleRow; } - set - { - HideEditor(); - _firstVisibleRow = value; - UpdateView(); - } - } - - private int _offsetX; - public int OffsetX - { - get { return _offsetX; } - private set - { - HideEditor(); - _offsetX = value; - UpdateView(); - } - } - - public override Rectangle DisplayRectangle - { - get - { - Rectangle r = ClientRectangle; - //r.Y += ColumnHeaderHeight; - //r.Height -= ColumnHeaderHeight; - int w = _vScrollBar.Visible ? _vScrollBar.Width : 0; - int h = _hScrollBar.Visible ? _hScrollBar.Height : 0; - return new Rectangle(r.X, r.Y, r.Width - w, r.Height - h); - } - } - - private List _selection; - internal List Selection - { - get { return _selection; } - } - - #endregion - - #region Public Properties - - #region DesignTime - - private bool _shiftFirstNode; - [DefaultValue(false), Category("Behavior")] - public bool ShiftFirstNode - { - get { return _shiftFirstNode; } - set { _shiftFirstNode = value; } - } - - private bool _displayDraggingNodes; - [DefaultValue(false), Category("Behavior")] - public bool DisplayDraggingNodes - { - get { return _displayDraggingNodes; } - set { _displayDraggingNodes = value; } - } - - private bool _fullRowSelect; - [DefaultValue(false), Category("Behavior")] - public bool FullRowSelect - { - get { return _fullRowSelect; } - set - { - _fullRowSelect = value; - UpdateView(); - } - } - - private bool _useColumns; - [DefaultValue(false), Category("Behavior")] - public bool UseColumns - { - get { return _useColumns; } - set - { - _useColumns = value; - FullUpdate(); - } - } - - private bool _allowColumnReorder; - [DefaultValue(false), Category("Behavior")] - public bool AllowColumnReorder - { - get { return _allowColumnReorder; } - set { _allowColumnReorder = value; } - } - - private bool _showLines = true; - [DefaultValue(true), Category("Behavior")] - public bool ShowLines - { - get { return _showLines; } - set - { - _showLines = value; - UpdateView(); - } - } - - private bool _showPlusMinus = true; - [DefaultValue(true), Category("Behavior")] - public bool ShowPlusMinus - { - get { return _showPlusMinus; } - set - { - _showPlusMinus = value; - FullUpdate(); - } - } - - private bool _showNodeToolTips = false; - [DefaultValue(false), Category("Behavior")] - public bool ShowNodeToolTips - { - get { return _showNodeToolTips; } - set { _showNodeToolTips = value; } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic"), DefaultValue(true), Category("Behavior"), Obsolete("No longer used")] - public bool KeepNodesExpanded - { - get { return true; } - set {} - } - - private ITreeModel _model; - /// - /// The model associated with this . - /// - /// - /// - [Browsable(false)] - public ITreeModel Model - { - get { return _model; } - set - { - if (_model != value) - { - AbortBackgroundExpandingThreads(); - if (_model != null) - UnbindModelEvents(); - _model = value; - CreateNodes(); - FullUpdate(); - if (_model != null) - BindModelEvents(); - } - } - } - - private static Font _font = SystemFonts.MessageBoxFont; - /// - /// The font to render content in. - /// - [Category("Appearance"), Description("The font to render TreeViewAdv content in.")] - public override Font Font - { - get - { - return (base.Font); - } - set - { - if (value == null) - base.Font = _font; - else - { - if (value == DefaultFont) - base.Font = _font; - else - base.Font = value; - } - } - } - public override void ResetFont() - { - Font = null; - } - private bool ShouldSerializeFont() - { - return (!Font.Equals(_font)); - } - // End font property - - private BorderStyle _borderStyle = BorderStyle.Fixed3D; - [DefaultValue(BorderStyle.Fixed3D), Category("Appearance")] - public BorderStyle BorderStyle - { - get - { - return this._borderStyle; - } - set - { - if (_borderStyle != value) - { - _borderStyle = value; - base.UpdateStyles(); - } - } - } - - private bool _autoRowHeight = false; - /// - /// Set to true to expand each row's height to fit the text of it's largest column. - /// - [DefaultValue(false), Category("Appearance"), Description("Expand each row's height to fit the text of it's largest column.")] - public bool AutoRowHeight - { - get - { - return _autoRowHeight; - } - set - { - _autoRowHeight = value; - if (value) - _rowLayout = new AutoRowHeightLayout(this, RowHeight); - else - _rowLayout = new FixedRowHeightLayout(this, RowHeight); - FullUpdate(); - } - } - - private GridLineStyle _gridLineStyle = GridLineStyle.None; - [DefaultValue(GridLineStyle.None), Category("Appearance")] - public GridLineStyle GridLineStyle - { - get - { - return _gridLineStyle; - } - set - { - if (value != _gridLineStyle) - { - _gridLineStyle = value; - UpdateView(); - OnGridLineStyleChanged(); - } - } - } - - private int _rowHeight = 16; - [DefaultValue(16), Category("Appearance")] - public int RowHeight - { - get - { - return _rowHeight; - } - set - { - if (value <= 0) - throw new ArgumentOutOfRangeException("value"); - - _rowHeight = value; - _rowLayout.PreferredRowHeight = value; - FullUpdate(); - } - } - - private TreeSelectionMode _selectionMode = TreeSelectionMode.Single; - [DefaultValue(TreeSelectionMode.Single), Category("Behavior")] - public TreeSelectionMode SelectionMode - { - get { return _selectionMode; } - set { _selectionMode = value; } - } - - private bool _hideSelection; - [DefaultValue(false), Category("Behavior")] - public bool HideSelection - { - get { return _hideSelection; } - set - { - _hideSelection = value; - UpdateView(); - } - } - - private float _topEdgeSensivity = 0.3f; - [DefaultValue(0.3f), Category("Behavior")] - public float TopEdgeSensivity - { - get { return _topEdgeSensivity; } - set - { - if (value < 0 || value > 1) - throw new ArgumentOutOfRangeException(); - _topEdgeSensivity = value; - } - } - - private float _bottomEdgeSensivity = 0.3f; - [DefaultValue(0.3f), Category("Behavior")] - public float BottomEdgeSensivity - { - get { return _bottomEdgeSensivity; } - set - { - if (value < 0 || value > 1) - throw new ArgumentOutOfRangeException("value should be from 0 to 1"); - _bottomEdgeSensivity = value; - } - } - - private bool _loadOnDemand; - [DefaultValue(false), Category("Behavior")] - public bool LoadOnDemand - { - get { return _loadOnDemand; } - set { _loadOnDemand = value; } - } - - private bool _unloadCollapsedOnReload = false; - [DefaultValue(false), Category("Behavior")] - public bool UnloadCollapsedOnReload - { - get { return _unloadCollapsedOnReload; } - set { _unloadCollapsedOnReload = value; } - } - - private int _indent = 19; - [DefaultValue(19), Category("Behavior")] - public int Indent - { - get { return _indent; } - set - { - _indent = value; - UpdateView(); - } - } - - private Color _lineColor = SystemColors.ControlDark; - [Category("Behavior")] - public Color LineColor - { - get { return _lineColor; } - set - { - _lineColor = value; - CreateLinePen(); - UpdateView(); - } - } - - private Color _dragDropMarkColor = Color.Black; - [Category("Behavior")] - public Color DragDropMarkColor - { - get { return _dragDropMarkColor; } - set - { - _dragDropMarkColor = value; - CreateMarkPen(); - } - } - - private float _dragDropMarkWidth = 3.0f; - [DefaultValue(3.0f), Category("Behavior")] - public float DragDropMarkWidth - { - get { return _dragDropMarkWidth; } - set - { - _dragDropMarkWidth = value; - CreateMarkPen(); - } - } - - private bool _highlightDropPosition = true; - [DefaultValue(true), Category("Behavior")] - public bool HighlightDropPosition - { - get { return _highlightDropPosition; } - set { _highlightDropPosition = value; } - } - - private TreeColumnCollection _columns; - [Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - public Collection Columns - { - get { return _columns; } - } - - private NodeControlsCollection _controls; - [Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - [Editor(typeof(NodeControlCollectionEditor), typeof(UITypeEditor))] - public Collection NodeControls - { - get - { - return _controls; - } - } - - private bool _asyncExpanding; - /// - /// When set to true, node contents will be read in background thread. - /// - [Category("Behavior"), DefaultValue(false), Description("Read children in a background thread when expanding.")] - public bool AsyncExpanding - { - get { return _asyncExpanding; } - set { _asyncExpanding = value; } - } - - #endregion - - #region RunTime - - private IToolTipProvider _defaultToolTipProvider = null; - [Browsable(false)] - public IToolTipProvider DefaultToolTipProvider - { - get { return _defaultToolTipProvider; } - set { _defaultToolTipProvider = value; } - } - - [Browsable(false)] - public IEnumerable AllNodes - { - get - { - if (_root.Nodes.Count > 0) - { - TreeNodeAdv node = _root.Nodes[0]; - while (node != null) - { - yield return node; - if (node.Nodes.Count > 0) - node = node.Nodes[0]; - else if (node.NextNode != null) - node = node.NextNode; - else - node = node.BottomNode; - } - } - } - } - - private DropPosition _dropPosition; - [Browsable(false)] - public DropPosition DropPosition - { - get { return _dropPosition; } - set { _dropPosition = value; } - } - - private TreeNodeAdv _root; - [Browsable(false)] - public TreeNodeAdv Root - { - get { return _root; } - } - - private ReadOnlyCollection _readonlySelection; - [Browsable(false)] - public ReadOnlyCollection SelectedNodes - { - get - { - return _readonlySelection; - } - } - - [Browsable(false)] - public TreeNodeAdv SelectedNode - { - get - { - if (Selection.Count > 0) - { - if (CurrentNode != null && CurrentNode.IsSelected) - return CurrentNode; - else - return Selection[0]; - } - else - return null; - } - set - { - if (SelectedNode == value) - return; - - BeginUpdate(); - try - { - if (value == null) - { - ClearSelectionInternal(); - } - else - { - if (!IsMyNode(value)) - throw new ArgumentException(); - - ClearSelectionInternal(); - value.IsSelected = true; - CurrentNode = value; - EnsureVisible(value); - } - } - finally - { - EndUpdate(); - } - } - } - - private TreeNodeAdv _currentNode; - [Browsable(false)] - public TreeNodeAdv CurrentNode - { - get { return _currentNode; } - internal set { _currentNode = value; } - } - - [Browsable(false)] - public int ItemCount - { - get { return RowMap.Count; } - } - - /// - /// Indicates the distance the content is scrolled to the left - /// - [Browsable(false)] - public int HorizontalScrollPosition - { - get - { - if (_hScrollBar.Visible) - return _hScrollBar.Value; - else - return 0; - } - } - - #endregion - - #endregion - - } -} diff --git a/Aga.Controls/Tree/TreeViewAdv.cs b/Aga.Controls/Tree/TreeViewAdv.cs deleted file mode 100644 index d149106..0000000 --- a/Aga.Controls/Tree/TreeViewAdv.cs +++ /dev/null @@ -1,1254 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Drawing; -using System.Security.Permissions; -using System.Threading; -using System.Windows.Forms; -using System.Collections; - -using Aga.Controls.Tree.NodeControls; -using Aga.Controls.Threading; - - -namespace Aga.Controls.Tree -{ - /// - /// Extensible advanced implemented in 100% managed C# code. - /// Features: Model/View architecture. Multiple column per node. Ability to select - /// multiple tree nodes. Different types of controls for each node column: - /// , Icon, Label... Drag and Drop highlighting. Load on - /// demand of nodes. Incremental search of nodes. - /// - public partial class TreeViewAdv : Control - { - public static Action CustomCheckRenderFunc; - public static Action CustomColumnBackgroundRenderFunc; - public static Action CustomColumnTextRenderFunc; - public static Color CustomSelectedTextColor = SystemColors.ControlText; - public static Pen CustomHorizontalLinePen = new Pen(Color.FromArgb(247, 247, 247)); - public static Action CustomPlusMinusRenderFunc; - public static Brush CustomSelectedRowBrush = new SolidBrush(Color.FromArgb(240, 240, 240)); - - private const int LeftMargin = 7; - internal const int ItemDragSensivity = 4; - private readonly int _columnHeaderHeight; - private const int DividerWidth = 9; - private const int DividerCorrectionGap = -2; - - private Pen _linePen; - private Pen _markPen; - private bool _suspendUpdate; - private bool _needFullUpdate; - private bool _fireSelectionEvent; - private NodePlusMinus _plusMinus; - private ToolTip _toolTip; - private DrawContext _measureContext; - private TreeColumn _hotColumn; - private IncrementalSearch _search; - private List _expandingNodes = new List(); - private AbortableThreadPool _threadPool = new AbortableThreadPool(); - - private float dpiX; - private float dpiY; - private float dpiXscale = 1; - private float dpiYscale = 1; - - #region Public Events - - [Category("Action")] - public event ItemDragEventHandler ItemDrag; - private void OnItemDrag(MouseButtons buttons, object item) - { - if (ItemDrag != null) - ItemDrag(this, new ItemDragEventArgs(buttons, item)); - } - - [Category("Behavior")] - public event EventHandler NodeMouseClick; - private void OnNodeMouseClick(TreeNodeAdvMouseEventArgs args) - { - if (NodeMouseClick != null) - NodeMouseClick(this, args); - } - - [Category("Behavior")] - public event EventHandler NodeMouseDoubleClick; - private void OnNodeMouseDoubleClick(TreeNodeAdvMouseEventArgs args) - { - if (NodeMouseDoubleClick != null) - NodeMouseDoubleClick(this, args); - } - - [Category("Behavior")] - public event EventHandler ColumnWidthChanged; - internal void OnColumnWidthChanged(TreeColumn column) - { - if (ColumnWidthChanged != null) - ColumnWidthChanged(this, new TreeColumnEventArgs(column)); - } - - [Category("Behavior")] - public event EventHandler ColumnReordered; - internal void OnColumnReordered(TreeColumn column) - { - if (ColumnReordered != null) - ColumnReordered(this, new TreeColumnEventArgs(column)); - } - - [Category("Behavior")] - public event EventHandler ColumnClicked; - internal void OnColumnClicked(TreeColumn column) - { - if (ColumnClicked != null) - ColumnClicked(this, new TreeColumnEventArgs(column)); - } - - [Category("Behavior")] - public event EventHandler SelectionChanged; - internal void OnSelectionChanged() - { - if (SuspendSelectionEvent) - _fireSelectionEvent = true; - else - { - _fireSelectionEvent = false; - if (SelectionChanged != null) - SelectionChanged(this, EventArgs.Empty); - } - } - - [Category("Behavior")] - public event EventHandler Collapsing; - private void OnCollapsing(TreeNodeAdv node) - { - if (Collapsing != null) - Collapsing(this, new TreeViewAdvEventArgs(node)); - } - - [Category("Behavior")] - public event EventHandler Collapsed; - private void OnCollapsed(TreeNodeAdv node) - { - if (Collapsed != null) - Collapsed(this, new TreeViewAdvEventArgs(node)); - } - - [Category("Behavior")] - public event EventHandler Expanding; - private void OnExpanding(TreeNodeAdv node) - { - if (Expanding != null) - Expanding(this, new TreeViewAdvEventArgs(node)); - } - - [Category("Behavior")] - public event EventHandler Expanded; - private void OnExpanded(TreeNodeAdv node) - { - if (Expanded != null) - Expanded(this, new TreeViewAdvEventArgs(node)); - } - - [Category("Behavior")] - public event EventHandler GridLineStyleChanged; - private void OnGridLineStyleChanged() - { - if (GridLineStyleChanged != null) - GridLineStyleChanged(this, EventArgs.Empty); - } - - [Category("Behavior")] - public event ScrollEventHandler Scroll; - protected virtual void OnScroll(ScrollEventArgs e) - { - if (Scroll != null) - Scroll(this, e); - } - - [Category("Behavior")] - public event EventHandler RowDraw; - protected virtual void OnRowDraw(PaintEventArgs e, TreeNodeAdv node, DrawContext context, int row, Rectangle rowRect) - { - if (RowDraw != null) - { - TreeViewRowDrawEventArgs args = new TreeViewRowDrawEventArgs(e.Graphics, e.ClipRectangle, node, context, row, rowRect); - RowDraw(this, args); - } - } - - /// - /// Fires when control is going to draw. Can be used to change text or back color - /// - [Category("Behavior")] - public event EventHandler DrawControl; - - internal bool DrawControlMustBeFired() - { - return DrawControl != null; - } - - internal void FireDrawControl(DrawEventArgs args) - { - OnDrawControl(args); - } - - protected virtual void OnDrawControl(DrawEventArgs args) - { - if (DrawControl != null) - DrawControl(this, args); - } - - - [Category("Drag Drop")] - public event EventHandler DropNodeValidating; - protected virtual void OnDropNodeValidating(Point point, ref TreeNodeAdv node) - { - if (DropNodeValidating != null) - { - DropNodeValidatingEventArgs args = new DropNodeValidatingEventArgs(point, node); - DropNodeValidating(this, args); - node = args.Node; - } - } - #endregion - - public TreeViewAdv() - { - InitializeComponent(); - SetDPI(); - SetStyle(ControlStyles.AllPaintingInWmPaint - | ControlStyles.UserPaint - | ControlStyles.OptimizedDoubleBuffer - | ControlStyles.ResizeRedraw - | ControlStyles.Selectable - , true); - - - if (Application.RenderWithVisualStyles) - _columnHeaderHeight = 20; - else - _columnHeaderHeight = 17; - _columnHeaderHeight = GetScaledSize(_columnHeaderHeight); - - //BorderStyle = BorderStyle.Fixed3D; - _hScrollBar.Height = SystemInformation.HorizontalScrollBarHeight; - _vScrollBar.Width = SystemInformation.VerticalScrollBarWidth; - _rowLayout = new FixedRowHeightLayout(this, RowHeight); - _rowMap = new List(); - _selection = new List(); - _readonlySelection = new ReadOnlyCollection(_selection); - _columns = new TreeColumnCollection(this); - _toolTip = new ToolTip(); - - _measureContext = new DrawContext(); - _measureContext.Font = Font; - _measureContext.Graphics = Graphics.FromImage(new Bitmap(1, 1)); - - Input = new NormalInputState(this); - _search = new IncrementalSearch(this); - CreateNodes(); - CreatePens(); - - ArrangeControls(); - - _plusMinus = new NodePlusMinus(); - _controls = new NodeControlsCollection(this); - - Font = _font; - ExpandingIcon.IconChanged += ExpandingIconChanged; - - BackColor = Color.Black; - } - - public void SetDPI() - { - // https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266(v=vs.85).aspx - const int _default_dpi = 96; - Graphics g = this.CreateGraphics(); - - try - { - this.dpiX = g.DpiX; - this.dpiY = g.DpiY; - } - finally - { - g.Dispose(); - } - if (dpiX > 0) - { - this.dpiXscale = dpiX / _default_dpi; - } - if (dpiY > 0) - { - this.dpiYscale = dpiY / _default_dpi; - } - } - - public int GetScaledSize(int size, bool useY = true) - { - int scaledsize = size; - - if (useY && this.dpiYscale > 1) - { - scaledsize = (int)(this.dpiYscale * size); - } - else if (this.dpiXscale > 1) - { - scaledsize = (int)(this.dpiXscale * size); - } - return scaledsize; - } - - void ExpandingIconChanged(object sender, EventArgs e) - { - if (IsHandleCreated && !IsDisposed) - BeginInvoke(new MethodInvoker(DrawIcons)); - } - - private void DrawIcons() - { - using (Graphics gr = Graphics.FromHwnd(this.Handle)) - { - //Apply the same Graphics Transform logic as used in OnPaint. - int y = 0; - if (UseColumns) - { - y += ColumnHeaderHeight; - if (Columns.Count == 0) - return; - } - int firstRowY = _rowLayout.GetRowBounds(FirstVisibleRow).Y; - y -= firstRowY; - gr.ResetTransform(); - gr.TranslateTransform(-OffsetX, y); - - DrawContext context = new DrawContext(); - context.Graphics = gr; - for (int i = 0; i < _expandingNodes.Count; i++) - { - foreach (NodeControlInfo item in GetNodeControls(_expandingNodes[i])) - { - if (item.Control is ExpandingIcon) - { - Rectangle bounds = item.Bounds; - if (item.Node.Parent == null && UseColumns) - bounds.Location = Point.Empty; // display root expanding icon at 0,0 - - context.Bounds = bounds; - item.Control.Draw(item.Node, context); - } - } - } - } - } - - #region Public Methods - - public TreePath GetPath(TreeNodeAdv node) - { - if (node == _root) - return TreePath.Empty; - else - { - Stack stack = new Stack(); - while (node != _root && node != null) - { - stack.Push(node.Tag); - node = node.Parent; - } - return new TreePath(stack.ToArray()); - } - } - - public TreeNodeAdv GetNodeAt(Point point) - { - NodeControlInfo info = GetNodeControlInfoAt(point); - return info.Node; - } - - public NodeControlInfo GetNodeControlInfoAt(Point point) - { - if (point.X < 0 || point.Y < 0) - return NodeControlInfo.Empty; - - int row = _rowLayout.GetRowAt(point); - if (row < RowCount && row >= 0) - return GetNodeControlInfoAt(RowMap[row], point); - else - return NodeControlInfo.Empty; - } - - private NodeControlInfo GetNodeControlInfoAt(TreeNodeAdv node, Point point) - { - Rectangle rect = _rowLayout.GetRowBounds(FirstVisibleRow); - point.Y += (rect.Y - ColumnHeaderHeight); - point.X += OffsetX; - foreach (NodeControlInfo info in GetNodeControls(node)) - if (info.Bounds.Contains(point)) - return info; - - if (FullRowSelect) - return new NodeControlInfo(null, Rectangle.Empty, node); - else - return NodeControlInfo.Empty; - } - - public void BeginUpdate() - { - _suspendUpdate = true; - SuspendSelectionEvent = true; - } - - public void EndUpdate() - { - _suspendUpdate = false; - if (_needFullUpdate) - FullUpdate(); - else - UpdateView(); - SuspendSelectionEvent = false; - } - - public void ExpandAll() - { - _root.ExpandAll(); - } - - public void CollapseAll() - { - _root.CollapseAll(); - } - - /// - /// Expand all parent nodes, and scroll to the specified node - /// - public void EnsureVisible(TreeNodeAdv node) - { - if (node == null) - throw new ArgumentNullException("node"); - - if (!IsMyNode(node)) - throw new ArgumentException(); - - TreeNodeAdv parent = node.Parent; - while (parent != _root) - { - parent.IsExpanded = true; - parent = parent.Parent; - } - ScrollTo(node); - } - - /// - /// Make node visible, scroll if needed. All parent nodes of the specified node must be expanded - /// - /// - public void ScrollTo(TreeNodeAdv node) - { - if (node == null) - throw new ArgumentNullException("node"); - - if (!IsMyNode(node)) - throw new ArgumentException(); - - if (node.Row < 0) - CreateRowMap(); - - int row = -1; - - if (node.Row < FirstVisibleRow) - row = node.Row; - else - { - int pageStart = _rowLayout.GetRowBounds(FirstVisibleRow).Top; - int rowBottom = _rowLayout.GetRowBounds(node.Row).Bottom; - if (rowBottom > pageStart + DisplayRectangle.Height - ColumnHeaderHeight) - row = _rowLayout.GetFirstRow(node.Row); - } - - if (row >= _vScrollBar.Minimum && row <= _vScrollBar.Maximum) - _vScrollBar.Value = row; - } - - public void ClearSelection() - { - BeginUpdate(); - try - { - ClearSelectionInternal(); - } - finally - { - EndUpdate(); - } - } - - internal void ClearSelectionInternal() - { - while (Selection.Count > 0) - { - var t = Selection[0]; - t.IsSelected = false; - Selection.Remove(t); //hack - } - } - - #endregion - - protected override void OnSizeChanged(EventArgs e) - { - ArrangeControls(); - SafeUpdateScrollBars(); - base.OnSizeChanged(e); - } - - private void ArrangeControls() - { - int hBarSize = _hScrollBar.Height; - int vBarSize = _vScrollBar.Width; - Rectangle clientRect = ClientRectangle; - - _hScrollBar.SetBounds(clientRect.X, clientRect.Bottom - hBarSize, - clientRect.Width - vBarSize, hBarSize); - - _vScrollBar.SetBounds(clientRect.Right - vBarSize, clientRect.Y, - vBarSize, clientRect.Height - hBarSize); - } - - private void SafeUpdateScrollBars() - { - if (InvokeRequired) - BeginInvoke(new MethodInvoker(UpdateScrollBars)); - else - UpdateScrollBars(); - } - - private void UpdateScrollBars() - { - UpdateVScrollBar(); - UpdateHScrollBar(); - UpdateVScrollBar(); - UpdateHScrollBar(); - _hScrollBar.Width = DisplayRectangle.Width; - _vScrollBar.Height = DisplayRectangle.Height; - } - - private void UpdateHScrollBar() - { - _hScrollBar.Maximum = ContentWidth; - _hScrollBar.LargeChange = Math.Max(DisplayRectangle.Width, 0); - _hScrollBar.SmallChange = 5; - _hScrollBar.Visible = _hScrollBar.LargeChange < _hScrollBar.Maximum; - _hScrollBar.Value = Math.Min(_hScrollBar.Value, _hScrollBar.Maximum - _hScrollBar.LargeChange + 1); - } - - private void UpdateVScrollBar() - { - _vScrollBar.Maximum = Math.Max(RowCount - 1, 0); - _vScrollBar.LargeChange = _rowLayout.PageRowCount; - _vScrollBar.Visible = (RowCount > 0) && (_vScrollBar.LargeChange <= _vScrollBar.Maximum); - _vScrollBar.Value = Math.Min(_vScrollBar.Value, _vScrollBar.Maximum - _vScrollBar.LargeChange + 1); - } - - protected override CreateParams CreateParams - { - [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] - get - { - CreateParams res = base.CreateParams; - switch (BorderStyle) - { - case BorderStyle.FixedSingle: - res.Style |= 0x800000; - break; - case BorderStyle.Fixed3D: - res.ExStyle |= 0x200; - break; - } - return res; - } - } - - protected override void OnGotFocus(EventArgs e) - { - UpdateView(); - ChangeInput(); - base.OnGotFocus(e); - } - - protected override void OnFontChanged(EventArgs e) - { - base.OnFontChanged(e); - _measureContext.Font = Font; - FullUpdate(); - } - - internal IEnumerable GetNodeControls(TreeNodeAdv node) - { - if (node == null) - yield break; - Rectangle rowRect = _rowLayout.GetRowBounds(node.Row); - foreach (NodeControlInfo n in GetNodeControls(node, rowRect)) - yield return n; - } - - internal IEnumerable GetNodeControls(TreeNodeAdv node, Rectangle rowRect) - { - if (node == null) - yield break; - - int scaledIndent = node.Tree.GetScaledSize(_indent, false); - int y = rowRect.Y; - int x = (node.Level - 1) * scaledIndent + LeftMargin; - int width = 0; - if (node.Row == 0 && ShiftFirstNode) - x -= scaledIndent; - Rectangle rect = Rectangle.Empty; - - if (ShowPlusMinus) - { - width = _plusMinus.GetActualSize(node, _measureContext).Width; - rect = new Rectangle(x, y, width, rowRect.Height); - if (UseColumns && Columns.Count > 0 && Columns[0].Width < rect.Right) - rect.Width = Columns[0].Width - x; - - yield return new NodeControlInfo(_plusMinus, rect, node); - x += width; - } - - if (!UseColumns) - { - foreach (NodeControl c in NodeControls) - { - Size s = c.GetActualSize(node, _measureContext); - if (!s.IsEmpty) - { - width = s.Width; - rect = new Rectangle(x, y, width, rowRect.Height); - x += rect.Width; - yield return new NodeControlInfo(c, rect, node); - } - } - } - else - { - int right = 0; - foreach (TreeColumn col in Columns) - { - if (col.IsVisible && col.Width > 0) - { - right += col.Width; - for (int i = 0; i < NodeControls.Count; i++) - { - NodeControl nc = NodeControls[i]; - if (nc.ParentColumn == col) - { - Size s = nc.GetActualSize(node, _measureContext); - if (!s.IsEmpty) - { - bool isLastControl = true; - for (int k = i + 1; k < NodeControls.Count; k++) - if (NodeControls[k].ParentColumn == col) - { - isLastControl = false; - break; - } - - width = right - x; - if (!isLastControl) - width = s.Width; - int maxWidth = Math.Max(0, right - x); - rect = new Rectangle(x, y, Math.Min(maxWidth, width), rowRect.Height); - x += width; - yield return new NodeControlInfo(nc, rect, node); - } - } - } - x = right; - } - } - } - } - - internal static double Dist(Point p1, Point p2) - { - return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2)); - } - - public void FullUpdate() - { - HideEditor(); - if (InvokeRequired) - BeginInvoke(new MethodInvoker(UnsafeFullUpdate)); - else - UnsafeFullUpdate(); - } - - private void UnsafeFullUpdate() - { - _rowLayout.ClearCache(); - CreateRowMap(); - SafeUpdateScrollBars(); - UpdateView(); - _needFullUpdate = false; - } - - internal void UpdateView() - { - if (!_suspendUpdate) - Invalidate(false); - } - - internal void UpdateHeaders() - { - Invalidate(new Rectangle(0, 0, Width, ColumnHeaderHeight)); - } - - internal void UpdateColumns() - { - FullUpdate(); - } - - private void CreateNodes() - { - Selection.Clear(); - SelectionStart = null; - _root = new TreeNodeAdv(this, null); - _root.IsExpanded = true; - if (_root.Nodes.Count > 0) - CurrentNode = _root.Nodes[0]; - else - CurrentNode = null; - } - - internal void ReadChilds(TreeNodeAdv parentNode) - { - ReadChilds(parentNode, false); - } - - internal void ReadChilds(TreeNodeAdv parentNode, bool performFullUpdate) - { - if (!parentNode.IsLeaf) - { - parentNode.IsExpandedOnce = true; - parentNode.Nodes.Clear(); - - if (Model != null) - { - IEnumerable items = Model.GetChildren(GetPath(parentNode)); - if (items != null) - foreach (object obj in items) - { - AddNewNode(parentNode, obj, -1); - if (performFullUpdate) - FullUpdate(); - } - } - - if (parentNode.AutoExpandOnStructureChanged) - parentNode.ExpandAll(); - } - } - - private void AddNewNode(TreeNodeAdv parent, object tag, int index) - { - TreeNodeAdv node = new TreeNodeAdv(this, tag); - AddNode(parent, index, node); - } - - private void AddNode(TreeNodeAdv parent, int index, TreeNodeAdv node) - { - if (index >= 0 && index < parent.Nodes.Count) - parent.Nodes.Insert(index, node); - else - parent.Nodes.Add(node); - - node.IsLeaf = Model.IsLeaf(GetPath(node)); - if (node.IsLeaf) - node.Nodes.Clear(); - if (!LoadOnDemand || node.IsExpandedOnce) - ReadChilds(node); - } - - private struct ExpandArgs - { - public TreeNodeAdv Node; - public bool Value; - public bool IgnoreChildren; - } - - public void AbortBackgroundExpandingThreads() - { - _threadPool.CancelAll(true); - for (int i = 0; i < _expandingNodes.Count; i++) - _expandingNodes[i].IsExpandingNow = false; - _expandingNodes.Clear(); - Invalidate(); - } - - internal void SetIsExpanded(TreeNodeAdv node, bool value, bool ignoreChildren) - { - ExpandArgs eargs = new ExpandArgs(); - eargs.Node = node; - eargs.Value = value; - eargs.IgnoreChildren = ignoreChildren; - - if (AsyncExpanding && LoadOnDemand && !_threadPool.IsMyThread(Thread.CurrentThread)) - { - WaitCallback wc = delegate(object argument) { SetIsExpanded((ExpandArgs)argument); }; - _threadPool.QueueUserWorkItem(wc, eargs); - } - else - SetIsExpanded(eargs); - } - - private void SetIsExpanded(ExpandArgs eargs) - { - bool update = !eargs.IgnoreChildren && !AsyncExpanding; - if (update) - BeginUpdate(); - try - { - if (IsMyNode(eargs.Node) && eargs.Node.IsExpanded != eargs.Value) - SetIsExpanded(eargs.Node, eargs.Value); - - if (!eargs.IgnoreChildren) - SetIsExpandedRecursive(eargs.Node, eargs.Value); - } - finally - { - if (update) - EndUpdate(); - } - } - - internal void SetIsExpanded(TreeNodeAdv node, bool value) - { - if (Root == node && !value) - return; //Can't collapse root node - - if (value) - { - OnExpanding(node); - node.OnExpanding(); - } - else - { - OnCollapsing(node); - node.OnCollapsing(); - } - - if (value && !node.IsExpandedOnce) - { - if (AsyncExpanding && LoadOnDemand) - { - AddExpandingNode(node); - node.AssignIsExpanded(true); - Invalidate(); - } - ReadChilds(node, AsyncExpanding); - RemoveExpandingNode(node); - } - node.AssignIsExpanded(value); - SmartFullUpdate(); - - if (value) - { - OnExpanded(node); - node.OnExpanded(); - } - else - { - OnCollapsed(node); - node.OnCollapsed(); - } - } - - private void RemoveExpandingNode(TreeNodeAdv node) - { - node.IsExpandingNow = false; - _expandingNodes.Remove(node); - if (_expandingNodes.Count <= 0) - ExpandingIcon.Stop(); - } - - private void AddExpandingNode(TreeNodeAdv node) - { - node.IsExpandingNow = true; - _expandingNodes.Add(node); - ExpandingIcon.Start(); - } - - internal void SetIsExpandedRecursive(TreeNodeAdv root, bool value) - { - for (int i = 0; i < root.Nodes.Count; i++) - { - TreeNodeAdv node = root.Nodes[i]; - node.IsExpanded = value; - SetIsExpandedRecursive(node, value); - } - } - - private void CreateRowMap() - { - RowMap.Clear(); - int row = 0; - _contentWidth = 0; - foreach (TreeNodeAdv node in VisibleNodes) - { - node.Row = row; - RowMap.Add(node); - if (!UseColumns) - { - _contentWidth = Math.Max(_contentWidth, GetNodeWidth(node)); - } - row++; - } - if (UseColumns) - { - _contentWidth = 0; - foreach (TreeColumn col in _columns) - if (col.IsVisible) - _contentWidth += col.Width; - } - } - - private int GetNodeWidth(TreeNodeAdv node) - { - if (node.RightBounds == null) - { - Rectangle res = GetNodeBounds(GetNodeControls(node, Rectangle.Empty)); - node.RightBounds = res.Right; - } - return node.RightBounds.Value; - } - - internal Rectangle GetNodeBounds(TreeNodeAdv node) - { - return GetNodeBounds(GetNodeControls(node)); - } - - private Rectangle GetNodeBounds(IEnumerable nodeControls) - { - Rectangle res = Rectangle.Empty; - foreach (NodeControlInfo info in nodeControls) - { - if (res == Rectangle.Empty) - res = info.Bounds; - else - res = Rectangle.Union(res, info.Bounds); - } - return res; - } - - private void _vScrollBar_ValueChanged(object sender, EventArgs e) - { - FirstVisibleRow = _vScrollBar.Value; - } - - private void _hScrollBar_ValueChanged(object sender, EventArgs e) - { - OffsetX = _hScrollBar.Value; - } - - private void _vScrollBar_Scroll(object sender, ScrollEventArgs e) - { - OnScroll(e); - } - - private void _hScrollBar_Scroll(object sender, ScrollEventArgs e) - { - OnScroll(e); - } - - internal void SmartFullUpdate() - { - if (_suspendUpdate) - _needFullUpdate = true; - else - FullUpdate(); - } - - internal bool IsMyNode(TreeNodeAdv node) - { - if (node == null) - return false; - - if (node.Tree != this) - return false; - - while (node.Parent != null) - node = node.Parent; - - return node == _root; - } - - internal void UpdateSelection() - { - bool flag = false; - - if (!IsMyNode(CurrentNode)) - CurrentNode = null; - if (!IsMyNode(_selectionStart)) - _selectionStart = null; - - for (int i = Selection.Count - 1; i >= 0; i--) - if (!IsMyNode(Selection[i])) - { - flag = true; - Selection.RemoveAt(i); - } - - if (flag) - OnSelectionChanged(); - } - - internal void ChangeColumnWidth(TreeColumn column) - { - if (!(_input is ResizeColumnState)) - { - FullUpdate(); - OnColumnWidthChanged(column); - } - } - - public TreeNodeAdv FindNode(TreePath path) - { - return FindNode(path, false); - } - - public TreeNodeAdv FindNode(TreePath path, bool readChilds) - { - if (path.IsEmpty()) - return _root; - else - return FindNode(_root, path, 0, readChilds); - } - - private TreeNodeAdv FindNode(TreeNodeAdv root, TreePath path, int level, bool readChilds) - { - if (!root.IsExpandedOnce && readChilds) - ReadChilds(root); - - for (int i = 0; i < root.Nodes.Count; i++) - { - TreeNodeAdv node = root.Nodes[i]; - if (node.Tag == path.FullPath[level]) - { - if (level == path.FullPath.Length - 1) - return node; - else - return FindNode(node, path, level + 1, readChilds); - } - } - return null; - } - - public TreeNodeAdv FindNodeByTag(object tag) - { - return FindNodeByTag(_root, tag); - } - - private TreeNodeAdv FindNodeByTag(TreeNodeAdv root, object tag) - { - foreach (TreeNodeAdv node in root.Nodes) - { - if (node.Tag == tag) - return node; - TreeNodeAdv res = FindNodeByTag(node, tag); - if (res != null) - return res; - } - return null; - } - - public void SelectAllNodes() - { - SuspendSelectionEvent = true; - try - { - if (SelectionMode == TreeSelectionMode.MultiSameParent) - { - if (CurrentNode != null) - { - foreach (TreeNodeAdv n in CurrentNode.Parent.Nodes) - n.IsSelected = true; - } - } - else if (SelectionMode == TreeSelectionMode.Multi) - { - SelectNodes(Root.Nodes); - } - } - finally - { - SuspendSelectionEvent = false; - } - } - - private void SelectNodes(Collection nodes) - { - foreach (TreeNodeAdv n in nodes) - { - n.IsSelected = true; - if (n.IsExpanded) - SelectNodes(n.Nodes); - } - } - - #region ModelEvents - private void BindModelEvents() - { - _model.NodesChanged += new EventHandler(_model_NodesChanged); - _model.NodesInserted += new EventHandler(_model_NodesInserted); - _model.NodesRemoved += new EventHandler(_model_NodesRemoved); - _model.StructureChanged += new EventHandler(_model_StructureChanged); - } - - private void UnbindModelEvents() - { - _model.NodesChanged -= new EventHandler(_model_NodesChanged); - _model.NodesInserted -= new EventHandler(_model_NodesInserted); - _model.NodesRemoved -= new EventHandler(_model_NodesRemoved); - _model.StructureChanged -= new EventHandler(_model_StructureChanged); - } - - private void _model_StructureChanged(object sender, TreePathEventArgs e) - { - if (e.Path == null) - throw new ArgumentNullException(); - - TreeNodeAdv node = FindNode(e.Path); - if (node != null) - { - if (node != Root) - node.IsLeaf = Model.IsLeaf(GetPath(node)); - - var list = new Dictionary(); - SaveExpandedNodes(node, list); - ReadChilds(node); - RestoreExpandedNodes(node, list); - - UpdateSelection(); - SmartFullUpdate(); - } - //else - // throw new ArgumentException("Path not found"); - } - - private void RestoreExpandedNodes(TreeNodeAdv node, Dictionary list) - { - if (node.Tag != null && list.ContainsKey(node.Tag)) - { - node.IsExpanded = true; - foreach (var child in node.Children) - RestoreExpandedNodes(child, list); - } - } - - private void SaveExpandedNodes(TreeNodeAdv node, Dictionary list) - { - if (node.IsExpanded && node.Tag != null) - { - list.Add(node.Tag, null); - foreach (var child in node.Children) - SaveExpandedNodes(child, list); - } - } - - private void _model_NodesRemoved(object sender, TreeModelEventArgs e) - { - TreeNodeAdv parent = FindNode(e.Path); - if (parent != null) - { - if (e.Indices != null) - { - List list = new List(e.Indices); - list.Sort(); - for (int n = list.Count - 1; n >= 0; n--) - { - int index = list[n]; - if (index >= 0 && index <= parent.Nodes.Count) - parent.Nodes.RemoveAt(index); - else - throw new ArgumentOutOfRangeException("Index out of range"); - } - } - else - { - for (int i = parent.Nodes.Count - 1; i >= 0; i--) - { - for (int n = 0; n < e.Children.Length; n++) - if (parent.Nodes[i].Tag == e.Children[n]) - { - parent.Nodes.RemoveAt(i); - break; - } - } - } - } - UpdateSelection(); - SmartFullUpdate(); - } - - private void _model_NodesInserted(object sender, TreeModelEventArgs e) - { - if (e.Indices == null) - throw new ArgumentNullException("Indices"); - - TreeNodeAdv parent = FindNode(e.Path); - if (parent != null) - { - for (int i = 0; i < e.Children.Length; i++) - AddNewNode(parent, e.Children[i], e.Indices[i]); - } - SmartFullUpdate(); - } - - private void _model_NodesChanged(object sender, TreeModelEventArgs e) - { - TreeNodeAdv parent = FindNode(e.Path); - if (parent != null && parent.IsVisible && parent.IsExpanded) - { - if (InvokeRequired) - BeginInvoke(new UpdateContentWidthDelegate(ClearNodesSize), e, parent); - else - ClearNodesSize(e, parent); - SmartFullUpdate(); - } - } - - private delegate void UpdateContentWidthDelegate(TreeModelEventArgs e, TreeNodeAdv parent); - private void ClearNodesSize(TreeModelEventArgs e, TreeNodeAdv parent) - { - if (e.Indices != null) - { - foreach (int index in e.Indices) - { - if (index >= 0 && index < parent.Nodes.Count) - { - TreeNodeAdv node = parent.Nodes[index]; - node.Height = node.RightBounds = null; - } - else - throw new ArgumentOutOfRangeException("Index out of range"); - } - } - else - { - foreach (TreeNodeAdv node in parent.Nodes) - { - foreach (object obj in e.Children) - if (node.Tag == obj) - { - node.Height = node.RightBounds = null; - } - } - } - } - #endregion - } -} diff --git a/Aga.Controls/Tree/TreeViewAdv.resx b/Aga.Controls/Tree/TreeViewAdv.resx deleted file mode 100644 index f11f8f7..0000000 --- a/Aga.Controls/Tree/TreeViewAdv.resx +++ /dev/null @@ -1,132 +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 - - - 127, 17 - - - 17, 17 - - - 236, 17 - - - False - - \ No newline at end of file diff --git a/Aga.Controls/Tree/TreeViewAdvCancelEventArgs.cs b/Aga.Controls/Tree/TreeViewAdvCancelEventArgs.cs deleted file mode 100644 index 2fb0827..0000000 --- a/Aga.Controls/Tree/TreeViewAdvCancelEventArgs.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - public class TreeViewAdvCancelEventArgs : TreeViewAdvEventArgs - { - private bool _cancel; - - public bool Cancel - { - get { return _cancel; } - set { _cancel = value; } - } - - public TreeViewAdvCancelEventArgs(TreeNodeAdv node) - : base(node) - { - } - - } -} diff --git a/Aga.Controls/Tree/TreeViewAdvEventArgs.cs b/Aga.Controls/Tree/TreeViewAdvEventArgs.cs deleted file mode 100644 index c041fc4..0000000 --- a/Aga.Controls/Tree/TreeViewAdvEventArgs.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Aga.Controls.Tree -{ - public class TreeViewAdvEventArgs : EventArgs - { - private TreeNodeAdv _node; - - public TreeNodeAdv Node - { - get { return _node; } - } - - public TreeViewAdvEventArgs(TreeNodeAdv node) - { - _node = node; - } - } -} diff --git a/Aga.Controls/Tree/TreeViewRowDrawEventArgs.cs b/Aga.Controls/Tree/TreeViewRowDrawEventArgs.cs deleted file mode 100644 index f27f001..0000000 --- a/Aga.Controls/Tree/TreeViewRowDrawEventArgs.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - public class TreeViewRowDrawEventArgs: PaintEventArgs - { - TreeNodeAdv _node; - DrawContext _context; - int _row; - Rectangle _rowRect; - - public TreeViewRowDrawEventArgs(Graphics graphics, Rectangle clipRectangle, TreeNodeAdv node, DrawContext context, int row, Rectangle rowRect) - : base(graphics, clipRectangle) - { - _node = node; - _context = context; - _row = row; - _rowRect = rowRect; - } - - public TreeNodeAdv Node - { - get { return _node; } - } - - public DrawContext Context - { - get { return _context; } - } - - public int Row - { - get { return _row; } - } - - public Rectangle RowRect - { - get { return _rowRect; } - } - } - -} diff --git a/Aga.Controls/license.txt b/Aga.Controls/license.txt deleted file mode 100644 index 428ceed..0000000 --- a/Aga.Controls/license.txt +++ /dev/null @@ -1,25 +0,0 @@ -The BSD License - -Copyright (c) 2009, Andrey Gliznetsov (a.gliznetsov@gmail.com) - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided -that the following conditions are met - -- Redistributions of source code must retain the above copyright notice, this list of conditions -and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, this list of conditions -and the following disclaimer in the documentation andor other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/LibreHardwareMonitor.Windows.Forms.csproj b/LibreHardwareMonitor.Windows.Forms/LibreHardwareMonitor.Windows.Forms.csproj deleted file mode 100644 index 82db4dd..0000000 --- a/LibreHardwareMonitor.Windows.Forms/LibreHardwareMonitor.Windows.Forms.csproj +++ /dev/null @@ -1,89 +0,0 @@ - - - WinExe - net472;net10.0-windows - x64;x86;ARM64 - win-x64;win-x86;win-arm64 - LibreHardwareMonitor.Windows.Forms - Libre Hardware Monitor - LibreHardwareMonitor - true - Resources\icon.ico - Resources\app.manifest - LibreHardwareMonitor.Windows.Forms.Program - true - ..\bin\$(Configuration)\ - latest - true - $(NoWarn);WFO1000 - - - - full - - - - none - - - - - - - - - - - - - - - - - - - AboutBox.cs - - - AuthForm.cs - - - MainForm.cs - - - ParameterForm.cs - - - InterfacePortForm.cs - - - - - - AboutBox.cs - - - AuthForm.cs - - - MainForm.cs - - - ParameterForm.cs - - - InterfacePortForm.cs - - - - - - - - - - - - - - diff --git a/LibreHardwareMonitor.Windows.Forms/Program.cs b/LibreHardwareMonitor.Windows.Forms/Program.cs deleted file mode 100644 index dad447f..0000000 --- a/LibreHardwareMonitor.Windows.Forms/Program.cs +++ /dev/null @@ -1,63 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.IO; -using System.Windows.Forms; -using LibreHardwareMonitor.Windows.Forms.UI; - -namespace LibreHardwareMonitor.Windows.Forms; - -public static class Program -{ - [STAThread] - public static void Main() - { - if (!AllRequiredFilesAvailable()) - Environment.Exit(0); - - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - using (MainForm form = new MainForm()) - { - form.FormClosed += delegate - { - Application.Exit(); - }; - Application.Run(); - } - } - - private static bool IsFileAvailable(string fileName) - { - string path = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar; - if (!File.Exists(path + fileName)) - { - MessageBox.Show("The following file could not be found: " + fileName + - "\nPlease extract all files from the archive.", "Error", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } - return true; - } - - private static bool AllRequiredFilesAvailable() - { - if (!IsFileAvailable("Aga.Controls.dll")) - return false; - - if (!IsFileAvailable("LibreHardwareMonitorLib.dll")) - return false; - - if (!IsFileAvailable("OxyPlot.dll")) - return false; - - if (!IsFileAvailable("OxyPlot.WindowsForms.dll")) - return false; - - return true; - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/TestScripts/LiquidCool.py b/LibreHardwareMonitor.Windows.Forms/TestScripts/LiquidCool.py deleted file mode 100644 index 6cf9a20..0000000 --- a/LibreHardwareMonitor.Windows.Forms/TestScripts/LiquidCool.py +++ /dev/null @@ -1,104 +0,0 @@ -################################################################ -# Install: -# * python -m pip install colorama -# * python -m pip install requests -# -# Usage: -# * MAKE SURE YOU READ THE WARNING -# * python LiquidCool.py -# -# Description: -# This script implements a simple load based control of two fans -# It first saves the original Fan settings, then starts -# monitoring the CPU and GPU load. It integrates those values -# to dampen the value changes somewhat. It then uses the maximum -# of the two values to set the fan speeds. -# -# Warning: This script is written as an example and may or may -# not kill your PC! Use at your own risk! -################################################################ - -import colorama -import json, requests -import time -import math - -url = 'http://127.0.0.1:8085' - -params = dict() - -pos = lambda x, y: '\x1b[%d;%dH' % (y, x) -clear = lambda : "\033[2J\033[1;1f" - -def getValue(sensorId): - params=dict(id=sensorId, action="Get") - resp = requests.post(url=url + "/Sensor", params = params, timeout=10); - result = json.loads(resp.text); - - if result["result"] != "ok": - raise Exception("Server returned error:\n " + result["message"].replace("\\n", "\n").replace("\\r", "")) - if result["value"] == None: - return None; - else: - return float(result["value"]) - -def setValue(sensorId, sensorValue): - if sensorValue == None: - sensorValue = "null" - params=dict(id=sensorId, action="Set", value=sensorValue) - resp = requests.post(url=url + "/Sensor", params = params, timeout=10); - result = json.loads(resp.text) - if result["result"] != "ok": - raise Exception("Server returned error:\n " + result["message"].replace("\\n", "\n").replace("\\r", "")) - -def draw_progressbar(x, y, description, progress): - p = '#'*math.floor(progress/5) - p1 = '-'*math.ceil((100-progress)/5) - print('{0}{1}[{2}{3}] {4}% '.format(pos(x,y), description, p, p1, math.floor(progress*100)/100), end='') - -def integrate(oldval, newval): - return float(oldval)*0.8 + float(newval) * 0.2 - -def main(): - colorama.init() - - print(clear()) - - try: - integratedCPU = getValue("/intelcpu/0/load/0"); - integratedGPU = getValue("/nvidiagpu/0/load/0"); - orgFan1 = getValue("/lpc/it8620e/control/0") - orgFan2 = getValue("/lpc/it8620e/control/1") - - while 1: - cpuLoad = getValue("/intelcpu/0/load/0"); - gpuLoad = getValue("/nvidiagpu/0/load/0"); - - integratedCPU = integrate(integratedCPU, cpuLoad) - integratedGPU = integrate(integratedGPU, gpuLoad) - fanVal = max(integratedCPU, integratedGPU) - fanVal = math.floor(fanVal*0.75) - - draw_progressbar(1, 1, "CPU: ", cpuLoad) - draw_progressbar(1, 2, "GPU: ", gpuLoad) - - draw_progressbar(1, 3, "IGPU: ", integratedCPU) - draw_progressbar(1, 4, "IGPU: ", integratedGPU) - - draw_progressbar(1, 5, "Fans: ", fanVal) - - setValue("/lpc/it8620e/control/0", fanVal); - setValue("/lpc/it8620e/control/1", fanVal); - - print(pos(1, 1)) - time.sleep(1) - except: - print(clear()) - setValue("/lpc/it8620e/control/0", orgFan1); - setValue("/lpc/it8620e/control/1", orgFan2); - raise - - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/TestScripts/basicrest.py b/LibreHardwareMonitor.Windows.Forms/TestScripts/basicrest.py deleted file mode 100644 index 37b6f04..0000000 --- a/LibreHardwareMonitor.Windows.Forms/TestScripts/basicrest.py +++ /dev/null @@ -1,71 +0,0 @@ -################################################################ -# Install: -# * python -m pip install requests -# -# Usage: -# * python basicrest.py -# -# Description: -# A simple test of the REST Like API -################################################################ - -import json, requests -import time - -url = 'http://127.0.0.1:8085' - -def findSensors(node): - sensors = {} - - if len(node["Children"]) > 0: - for child in node["Children"]: - sensors.update(findSensors(child)) - else: - if "Type" in node: - sensors[node["SensorId"]] = node - - return sensors - -def getValue(sensorId): - params=dict(id=sensorId, action="Get") - resp = requests.post(url=url + "/Sensor", params = params, timeout=10); - result = json.loads(resp.text); - - if result["result"] != "ok": - raise Exception("Server returned error:\n " + result["message"].replace("\\n", "\n").replace("\\r", "")) - if result["value"] == None: - return None; - else: - return float(result["value"]) - -def setValue(sensorId, sensorValue): - if sensorValue == None: - sensorValue = "null" - params=dict(id=sensorId, action="Set", value=sensorValue) - resp = requests.post(url=url + "/Sensor", params = params, timeout=10); - result = json.loads(resp.text) - if result["result"] != "ok": - raise Exception("Server returned error:\n " + result["message"].replace("\\n", "\n").replace("\\r", "")) - -def main(): - params = dict() - - print("Fetching all sensor ids:") - resp = requests.get(url=url + "/data.json", params=params, timeout=10) - data = json.loads(resp.text) - sensors = findSensors(data) - - for key, value in sensors.items(): - v = getValue(key) - print(key, ":", v); - - # Change the id to one of yours - print("Setting GPU Fan to full speed!") - setValue("/nvidiagpu/0/control/0", "100.0") - time.sleep(10); - print("Returning GPU Fan speed to default") - setValue("/nvidiagpu/0/control/0", None) - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/TestScripts/basicwmi.py b/LibreHardwareMonitor.Windows.Forms/TestScripts/basicwmi.py deleted file mode 100644 index 93b07b6..0000000 --- a/LibreHardwareMonitor.Windows.Forms/TestScripts/basicwmi.py +++ /dev/null @@ -1,17 +0,0 @@ -################################################################ -# Install: -# * python.exe -m pip install pypiwin32 -# * python.exe -m pip install wmi -# -# Usage: -# * !! Make sure librehardwaremonitor is running !! -# * python basicwmi.py -################################################################ - -import wmi - -hwmon = wmi.WMI(namespace="root\LibreHardwareMonitor") -sensors = hwmon.Sensor(SensorType="Control") - -for s in sensors: - print s diff --git a/LibreHardwareMonitor.Windows.Forms/UI/AboutBox.Designer.cs b/LibreHardwareMonitor.Windows.Forms/UI/AboutBox.Designer.cs deleted file mode 100644 index 9527553..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/AboutBox.Designer.cs +++ /dev/null @@ -1,173 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -namespace LibreHardwareMonitor.Windows.Forms.UI -{ - sealed partial class AboutBox - { - /// - /// 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 Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutBox)); - this.okButton = new System.Windows.Forms.Button(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.projectLinkLabel = new System.Windows.Forms.LinkLabel(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.licenseLinkLabel = new System.Windows.Forms.LinkLabel(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.okButton.Location = new System.Drawing.Point(269, 79); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 0; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - // - // pictureBox1 - // - this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); - this.pictureBox1.Location = new System.Drawing.Point(10, 11); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(48, 48); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; - this.pictureBox1.TabIndex = 1; - this.pictureBox1.TabStop = false; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(74, 12); - this.label1.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(117, 13); - this.label1.TabIndex = 2; - this.label1.Text = "Libre Hardware Monitor"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(74, 46); - this.label2.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(250, 13); - this.label2.TabIndex = 3; - this.label2.Text = "Copyright © LibreHardwareMonitor and Contributors"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(74, 29); - this.label3.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(127, 13); - this.label3.TabIndex = 4; - this.label3.Text = "Version 9.0.30729.1 Beta"; - // - // projectLinkLabel - // - this.projectLinkLabel.AutoSize = true; - this.projectLinkLabel.Location = new System.Drawing.Point(164, 80); - this.projectLinkLabel.Margin = new System.Windows.Forms.Padding(0); - this.projectLinkLabel.Name = "projectLinkLabel"; - this.projectLinkLabel.Size = new System.Drawing.Size(82, 13); - this.projectLinkLabel.TabIndex = 6; - this.projectLinkLabel.TabStop = true; - this.projectLinkLabel.Text = "Project Website"; - this.projectLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel_LinkClicked); - // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel1.Location = new System.Drawing.Point(10, 100); - this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(0, 0); - this.flowLayoutPanel1.TabIndex = 8; - // - // licenseLinkLabel - // - this.licenseLinkLabel.AutoSize = true; - this.licenseLinkLabel.Location = new System.Drawing.Point(25, 80); - this.licenseLinkLabel.Margin = new System.Windows.Forms.Padding(0); - this.licenseLinkLabel.Name = "licenseLinkLabel"; - this.licenseLinkLabel.Size = new System.Drawing.Size(107, 13); - this.licenseLinkLabel.TabIndex = 9; - this.licenseLinkLabel.TabStop = true; - this.licenseLinkLabel.Text = "Licensing Information"; - this.licenseLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel_LinkClicked); - // - // AboutBox - // - this.AcceptButton = this.okButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.AutoSize = true; - this.ClientSize = new System.Drawing.Size(359, 115); - this.Controls.Add(this.licenseLinkLabel); - this.Controls.Add(this.flowLayoutPanel1); - this.Controls.Add(this.projectLinkLabel); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.okButton); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "AboutBox"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "About"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.LinkLabel projectLinkLabel; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; - private System.Windows.Forms.LinkLabel licenseLinkLabel; - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/AboutBox.cs b/LibreHardwareMonitor.Windows.Forms/UI/AboutBox.cs deleted file mode 100644 index 17854db..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/AboutBox.cs +++ /dev/null @@ -1,36 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System.Diagnostics; -using System.Drawing; -using System.Windows.Forms; -using LibreHardwareMonitor.Windows.Forms.UI.Themes; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public sealed partial class AboutBox : Form -{ - public AboutBox() - { - InitializeComponent(); - Font = SystemFonts.MessageBoxFont; - label3.Text = "Version " + Application.ProductVersion; - projectLinkLabel.Links.Remove(projectLinkLabel.Links[0]); - projectLinkLabel.Links.Add(0, projectLinkLabel.Text.Length, "https://github.com/LibreHardwareMonitor/LibreHardwareMonitor"); - licenseLinkLabel.Links.Remove(licenseLinkLabel.Links[0]); - licenseLinkLabel.Links.Add(0, licenseLinkLabel.Text.Length, "https://www.mozilla.org/en-US/MPL/2.0/"); - Theme.Current.Apply(this); - } - - private void LinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - try - { - Process.Start(new ProcessStartInfo(e.Link.LinkData.ToString())); - } - catch { } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/AboutBox.resx b/LibreHardwareMonitor.Windows.Forms/UI/AboutBox.resx deleted file mode 100644 index f5e88f2..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/AboutBox.resx +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - vAAADrwBlbxySQAADUJJREFUaEPtWelTVHcWzcyXVBJjkkoqCbJDd9PdNCICouyiuAAKhB3BFZhMLOO+ - ILIoKq6AIIsYMSK474q4BEzUiRInJho1FZNUjeZL/os799zfe90NMpPumi/WVF7VrddU093n3Hvu8rvv - lT+vP68/r//Dq6WllZqamtmaqKGxgXbv3k3bt2+nrXV1tGXLFqrdtImqa6ppw4ZKK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saheew+KfwBThelnsj58TD7sQppfNtOuVV/4NcZaFCnU4CO8AAAAA - SUVORK5CYII= - - - \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/AuthForm.Designer.cs b/LibreHardwareMonitor.Windows.Forms/UI/AuthForm.Designer.cs deleted file mode 100644 index 734aa55..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/AuthForm.Designer.cs +++ /dev/null @@ -1,186 +0,0 @@ -namespace LibreHardwareMonitor.Windows.Forms.UI -{ - partial class AuthForm - { - /// - /// 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 Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AuthForm)); - this.enableHTTPAuthCheckBox = new System.Windows.Forms.CheckBox(); - this.httpAuthUsernameTextBox = new System.Windows.Forms.TextBox(); - this.httpAuthPasswordTextBox = new System.Windows.Forms.TextBox(); - this.httpUsernameLabel = new System.Windows.Forms.Label(); - this.httpPasswordLabel = new System.Windows.Forms.Label(); - this.credentialsGroupBox = new System.Windows.Forms.GroupBox(); - this.httpAuthCancelButton = new System.Windows.Forms.Button(); - this.httpAuthOkButton = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.credentialsGroupBox.SuspendLayout(); - this.SuspendLayout(); - // - // enableHTTPAuthCheckBox - // - this.enableHTTPAuthCheckBox.AutoSize = true; - this.enableHTTPAuthCheckBox.Location = new System.Drawing.Point(12, 12); - this.enableHTTPAuthCheckBox.Name = "enableHTTPAuthCheckBox"; - this.enableHTTPAuthCheckBox.Size = new System.Drawing.Size(191, 17); - this.enableHTTPAuthCheckBox.TabIndex = 0; - this.enableHTTPAuthCheckBox.Text = "Enable HTTP Basic Authentication"; - this.enableHTTPAuthCheckBox.UseVisualStyleBackColor = true; - this.enableHTTPAuthCheckBox.CheckedChanged += new System.EventHandler(this.EnableHTTPAuthCheckBox_CheckedChanged); - // - // httpAuthUsernameTextBox - // - this.httpAuthUsernameTextBox.Location = new System.Drawing.Point(102, 23); - this.httpAuthUsernameTextBox.MaxLength = 255; - this.httpAuthUsernameTextBox.Name = "httpAuthUsernameTextBox"; - this.httpAuthUsernameTextBox.Size = new System.Drawing.Size(171, 20); - this.httpAuthUsernameTextBox.TabIndex = 1; - // - // httpAuthPasswordTextBox - // - this.httpAuthPasswordTextBox.Location = new System.Drawing.Point(102, 60); - this.httpAuthPasswordTextBox.MaxLength = 255; - this.httpAuthPasswordTextBox.Name = "httpAuthPasswordTextBox"; - this.httpAuthPasswordTextBox.PasswordChar = '*'; - this.httpAuthPasswordTextBox.Size = new System.Drawing.Size(171, 20); - this.httpAuthPasswordTextBox.TabIndex = 2; - this.httpAuthPasswordTextBox.UseSystemPasswordChar = true; - // - // httpUsernameLabel - // - this.httpUsernameLabel.AutoSize = true; - this.httpUsernameLabel.Location = new System.Drawing.Point(6, 26); - this.httpUsernameLabel.Name = "httpUsernameLabel"; - this.httpUsernameLabel.Size = new System.Drawing.Size(90, 13); - this.httpUsernameLabel.TabIndex = 6; - this.httpUsernameLabel.Text = "HTTP UserName:"; - // - // httpPasswordLabel - // - this.httpPasswordLabel.AutoSize = true; - this.httpPasswordLabel.Location = new System.Drawing.Point(6, 63); - this.httpPasswordLabel.Name = "httpPasswordLabel"; - this.httpPasswordLabel.Size = new System.Drawing.Size(88, 13); - this.httpPasswordLabel.TabIndex = 7; - this.httpPasswordLabel.Text = "HTTP Password:"; - // - // credentialsGroupBox - // - this.credentialsGroupBox.Controls.Add(this.httpAuthUsernameTextBox); - this.credentialsGroupBox.Controls.Add(this.httpPasswordLabel); - this.credentialsGroupBox.Controls.Add(this.httpAuthPasswordTextBox); - this.credentialsGroupBox.Controls.Add(this.httpUsernameLabel); - this.credentialsGroupBox.Location = new System.Drawing.Point(12, 35); - this.credentialsGroupBox.Name = "credentialsGroupBox"; - this.credentialsGroupBox.Size = new System.Drawing.Size(279, 100); - this.credentialsGroupBox.TabIndex = 5; - this.credentialsGroupBox.TabStop = false; - this.credentialsGroupBox.Text = "Credentials"; - // - // httpAuthCancelButton - // - this.httpAuthCancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.httpAuthCancelButton.Location = new System.Drawing.Point(76, 206); - this.httpAuthCancelButton.Name = "httpAuthCancelButton"; - this.httpAuthCancelButton.Size = new System.Drawing.Size(75, 23); - this.httpAuthCancelButton.TabIndex = 3; - this.httpAuthCancelButton.Text = "Cancel"; - this.httpAuthCancelButton.UseVisualStyleBackColor = true; - this.httpAuthCancelButton.Click += new System.EventHandler(this.HttpAuthCancelButton_Click); - // - // httpAuthOkButton - // - this.httpAuthOkButton.Location = new System.Drawing.Point(157, 206); - this.httpAuthOkButton.Name = "httpAuthOkButton"; - this.httpAuthOkButton.Size = new System.Drawing.Size(75, 23); - this.httpAuthOkButton.TabIndex = 4; - this.httpAuthOkButton.Text = "OK"; - this.httpAuthOkButton.UseVisualStyleBackColor = true; - this.httpAuthOkButton.Click += new System.EventHandler(this.HttpAuthOkButton_Click); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 138); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(269, 26); - this.label1.TabIndex = 8; - this.label1.Text = "Password is stored hashed, if you forget it you will need \r\nto set a new one."; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 174); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(284, 26); - this.label2.TabIndex = 9; - this.label2.Text = "If the web server is running then it will need to be restarted \r\nfor the change t" + - "o take effect."; - // - // AuthForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.httpAuthCancelButton; - this.ClientSize = new System.Drawing.Size(305, 241); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.httpAuthOkButton); - this.Controls.Add(this.httpAuthCancelButton); - this.Controls.Add(this.credentialsGroupBox); - this.Controls.Add(this.enableHTTPAuthCheckBox); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "AuthForm"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Set HTTP Credentials"; - this.Load += new System.EventHandler(this.AuthForm_Load); - this.credentialsGroupBox.ResumeLayout(false); - this.credentialsGroupBox.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.CheckBox enableHTTPAuthCheckBox; - private System.Windows.Forms.TextBox httpAuthUsernameTextBox; - private System.Windows.Forms.TextBox httpAuthPasswordTextBox; - private System.Windows.Forms.Label httpUsernameLabel; - private System.Windows.Forms.Label httpPasswordLabel; - private System.Windows.Forms.GroupBox credentialsGroupBox; - private System.Windows.Forms.Button httpAuthCancelButton; - private System.Windows.Forms.Button httpAuthOkButton; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/AuthForm.cs b/LibreHardwareMonitor.Windows.Forms/UI/AuthForm.cs deleted file mode 100644 index 45cdd64..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/AuthForm.cs +++ /dev/null @@ -1,49 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Windows.Forms; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public partial class AuthForm : Form -{ - private readonly MainForm _parent; - - public AuthForm(MainForm m) - { - InitializeComponent(); - _parent = m; - } - - private void AuthForm_Load(object sender, EventArgs e) - { - httpAuthUsernameTextBox.Enabled = httpAuthPasswordTextBox.Enabled = enableHTTPAuthCheckBox.Checked = _parent.Server.AuthEnabled; - httpAuthUsernameTextBox.Text = _parent.Server.UserName; - } - - private void HttpAuthCancelButton_Click(object sender, EventArgs e) - { - Close(); - } - - private void HttpAuthOkButton_Click(object sender, EventArgs e) - { - _parent.Server.UserName = httpAuthUsernameTextBox.Text; - if (!string.IsNullOrWhiteSpace(httpAuthPasswordTextBox.Text)) - { - _parent.Server.SetPassword(httpAuthPasswordTextBox.Text); - } - _parent.Server.AuthEnabled = enableHTTPAuthCheckBox.Checked; - _parent.AuthWebServerMenuItemChecked = _parent.Server.AuthEnabled; - Close(); - } - - private void EnableHTTPAuthCheckBox_CheckedChanged(object sender, EventArgs e) - { - httpAuthUsernameTextBox.Enabled = httpAuthPasswordTextBox.Enabled = enableHTTPAuthCheckBox.Checked; - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/AuthForm.resx b/LibreHardwareMonitor.Windows.Forms/UI/AuthForm.resx deleted file mode 100644 index b7102bd..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/AuthForm.resx +++ /dev/null @@ -1,377 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAMAEBAAAAEAIABoBAAANgAAACAgAAABACAAqB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AAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA+AAAAAAfAAD4AAAAAB8AAPgA - AAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAf - AAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgA - AAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAf - AAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgA - AAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAP///////wAA//////// - AAD///////8AAP///////wAA////////AAA= - - - \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/Gadget.cs b/LibreHardwareMonitor.Windows.Forms/UI/Gadget.cs deleted file mode 100644 index b8b45ab..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/Gadget.cs +++ /dev/null @@ -1,178 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public abstract class Gadget : IDisposable -{ - private readonly GadgetWindow _window; - - public event EventHandler VisibleChanged; - - protected Gadget() - { - _window = new GadgetWindow(); - _window.Paint += delegate (object sender, PaintEventArgs e) - { - OnPaint(e); - }; - } - - public virtual void Dispose() - { - _window.Dispose(); - } - - public Point Location - { - get - { - return _window.Location; - } - set - { - _window.Location = value; - } - } - - public event EventHandler LocationChanged - { - add - { - _window.LocationChanged += value; - } - remove - { - _window.LocationChanged -= value; - } - } - - public virtual Size Size - { - get - { - return _window.Size; - } - set - { - _window.Size = value; - } - } - - public event EventHandler SizeChanged - { - add - { - _window.SizeChanged += value; - } - remove - { - _window.SizeChanged -= value; - } - } - - public byte Opacity - { - get - { - return _window.Opacity; - } - set - { - _window.Opacity = value; - } - } - - public bool LockPositionAndSize - { - get - { - return _window.LockPositionAndSize; - } - set - { - _window.LockPositionAndSize = value; - } - } - - public bool AlwaysOnTop - { - get - { - return _window.AlwaysOnTop; - } - set - { - _window.AlwaysOnTop = value; - } - } - - public ContextMenuStrip ContextMenuStrip - { - get - { - return _window.ContextMenuStrip; - } - set - { - _window.ContextMenuStrip = value; - } - } - - public event HitTestEventHandler HitTest - { - add - { - _window.HitTest += value; - } - remove - { - _window.HitTest -= value; - } - } - - public event MouseEventHandler MouseDoubleClick - { - add - { - _window.MouseDoubleClick += value; - } - remove - { - _window.MouseDoubleClick -= value; - } - } - - public bool Visible - { - get - { - return _window.Visible; - } - set - { - if (value != _window.Visible) - { - _window.Visible = value; - VisibleChanged?.Invoke(this, EventArgs.Empty); - - if (value) - Redraw(); - } - } - } - - public void Redraw() - { - _window.Redraw(); - } - - protected abstract void OnPaint(PaintEventArgs e); -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/GadgetWindow.cs b/LibreHardwareMonitor.Windows.Forms/UI/GadgetWindow.cs deleted file mode 100644 index e6b7ea9..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/GadgetWindow.cs +++ /dev/null @@ -1,574 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Text; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows.Forms; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public sealed class GadgetWindow : NativeWindow, IDisposable -{ - private bool _visible; - private bool _alwaysOnTop; - private byte _opacity = 255; - private Point _location = new Point(100, 100); - private Size _size = new Size(130, 84); - private readonly MethodInfo _commandDispatch; - private IntPtr _handleBitmapDC; - private Size _bufferSize; - private Graphics _graphics; - - public event EventHandler SizeChanged; - public event EventHandler LocationChanged; - public event HitTestEventHandler HitTest; - public event MouseEventHandler MouseDoubleClick; - - public GadgetWindow() - { - Type commandType = typeof(Form).Assembly.GetType("System.Windows.Forms.Command"); - _commandDispatch = commandType.GetMethod("DispatchID", - BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, - null, new[] { typeof(int) }, null); - - CreateHandle(CreateParams); - - // move window to the bottom - MoveToBottom(Handle); - - // prevent window from fading to a glass sheet when peek is invoked - try - { - bool value = true; - NativeMethods.DwmSetWindowAttribute(Handle, WindowAttribute.DWMWA_EXCLUDED_FROM_PEEK, ref value, Marshal.SizeOf(true)); - } - catch (DllNotFoundException) { } - catch (EntryPointNotFoundException) { } - - CreateBuffer(); - } - - private void ShowDesktopChanged(bool showDesktop) - { - if (showDesktop) - MoveToTopMost(Handle); - else - MoveToBottom(Handle); - } - - private void MoveToBottom(IntPtr handle) - { - NativeMethods.SetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); - } - - private void MoveToTopMost(IntPtr handle) - { - NativeMethods.SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); - } - - private CreateParams CreateParams - { - get - { - CreateParams cp = new CreateParams - { - Width = 4096, - Height = 4096, - X = _location.X, - Y = _location.Y, - ExStyle = WS_EX_LAYERED | WS_EX_TOOLWINDOW - }; - - return cp; - } - } - - protected override void WndProc(ref Message message) - { - switch (message.Msg) - { - case WM_COMMAND: - { - // need to dispatch the message for the context menu - if (message.LParam == IntPtr.Zero) - _commandDispatch.Invoke(null, new object[] {message.WParam.ToInt32() & 0xFFFF }); - } - break; - case WM_NCHITTEST: - { - message.Result = (IntPtr)HitResult.Caption; - if (HitTest != null) - { - Point p = new Point( - Macros.GET_X_LPARAM(message.LParam) - _location.X, - Macros.GET_Y_LPARAM(message.LParam) - _location.Y - ); - HitTestEventArgs e = new HitTestEventArgs(p, HitResult.Caption); - HitTest(this, e); - message.Result = (IntPtr)e.HitResult; - } - } - break; - case WM_NCLBUTTONDBLCLK: - { - MouseDoubleClick?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 2, Macros.GET_X_LPARAM(message.LParam) - _location.X, Macros.GET_Y_LPARAM(message.LParam) - _location.Y, 0)); - message.Result = IntPtr.Zero; - } - break; - case WM_NCRBUTTONDOWN: - { - message.Result = IntPtr.Zero; - } - break; - case WM_NCRBUTTONUP: - { - ContextMenuStrip?.Show(new Point(Macros.GET_X_LPARAM(message.LParam), Macros.GET_Y_LPARAM(message.LParam))); - message.Result = IntPtr.Zero; - } - break; - case WM_WINDOWPOSCHANGING: - { - WINDOWPOS wp = (WINDOWPOS)Marshal.PtrToStructure(message.LParam, typeof(WINDOWPOS)); - if (!LockPositionAndSize) - { - // prevent the window from leaving the screen - if ((wp.flags & SWP_NOMOVE) == 0) - { - Rectangle rect = Screen.GetWorkingArea(new Rectangle(wp.x, wp.y, wp.cx, wp.cy)); - const int margin = 16; - wp.x = Math.Max(wp.x, rect.Left - wp.cx + margin); - wp.x = Math.Min(wp.x, rect.Right - margin); - wp.y = Math.Max(wp.y, rect.Top - wp.cy + margin); - wp.y = Math.Min(wp.y, rect.Bottom - margin); - } - - // update location and fire event - if ((wp.flags & SWP_NOMOVE) == 0) - { - if (_location.X != wp.x || _location.Y != wp.y) - { - _location = new Point(wp.x, wp.y); - LocationChanged?.Invoke(this, EventArgs.Empty); - } - } - - // update size and fire event - if ((wp.flags & SWP_NOSIZE) == 0) - { - if (_size.Width != wp.cx || _size.Height != wp.cy) - { - _size = new Size(wp.cx, wp.cy); - SizeChanged?.Invoke(this, EventArgs.Empty); - } - } - - // update the size of the layered window - if ((wp.flags & SWP_NOSIZE) == 0) - NativeMethods.UpdateLayeredWindow(Handle, IntPtr.Zero, IntPtr.Zero, ref _size, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, 0); - - // update the position of the layered window - if ((wp.flags & SWP_NOMOVE) == 0) - NativeMethods.SetWindowPos(Handle, IntPtr.Zero, _location.X, _location.Y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING); - } - - // do not forward any move or size messages - wp.flags |= SWP_NOSIZE | SWP_NOMOVE; - - // suppress any frame changed events - wp.flags &= ~SWP_FRAMECHANGED; - - Marshal.StructureToPtr(wp, message.LParam, false); - message.Result = IntPtr.Zero; - } - break; - default: - { - base.WndProc(ref message); - } - break; - } - } - - private BlendFunction CreateBlendFunction() - { - return new BlendFunction { BlendOp = AC_SRC_OVER, BlendFlags = 0, SourceConstantAlpha = _opacity, AlphaFormat = AC_SRC_ALPHA }; - } - - private void CreateBuffer() - { - IntPtr handleScreenDC = NativeMethods.GetDC(IntPtr.Zero); - _handleBitmapDC = NativeMethods.CreateCompatibleDC(handleScreenDC); - NativeMethods.ReleaseDC(IntPtr.Zero, handleScreenDC); - _bufferSize = _size; - - BITMAPINFO info = new BITMAPINFO(); - info.Size = Marshal.SizeOf(info); - info.Width = _size.Width; - info.Height = -_size.Height; - info.BitCount = 32; - info.Planes = 1; - - IntPtr hBmp = NativeMethods.CreateDIBSection(_handleBitmapDC, ref info, 0, out IntPtr _, IntPtr.Zero, 0); - IntPtr hBmpOld = NativeMethods.SelectObject(_handleBitmapDC, hBmp); - NativeMethods.DeleteObject(hBmpOld); - - _graphics = Graphics.FromHdc(_handleBitmapDC); - - if (Environment.OSVersion.Version.Major > 5) - { - _graphics.TextRenderingHint = TextRenderingHint.SystemDefault; - _graphics.SmoothingMode = SmoothingMode.HighQuality; - } - } - - private void DisposeBuffer() - { - _graphics.Dispose(); - NativeMethods.DeleteDC(_handleBitmapDC); - } - - public void Dispose() - { - DisposeBuffer(); - } - - public PaintEventHandler Paint; - - public void Redraw() - { - if (!_visible || Paint == null) - return; - - if (_size != _bufferSize) - { - DisposeBuffer(); - CreateBuffer(); - } - - Paint(this, new PaintEventArgs(_graphics, new Rectangle(Point.Empty, _size))); - Point pointSource = Point.Empty; - BlendFunction blend = CreateBlendFunction(); - NativeMethods.UpdateLayeredWindow(Handle, IntPtr.Zero, IntPtr.Zero, ref _size, _handleBitmapDC, ref pointSource, 0, ref blend, ULW_ALPHA); - // make sure the window is at the right location - NativeMethods.SetWindowPos(Handle, IntPtr.Zero, _location.X, _location.Y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING); - } - - public byte Opacity - { - get - { - return _opacity; - } - set - { - if (_opacity != value) - { - _opacity = value; - BlendFunction blend = CreateBlendFunction(); - NativeMethods.UpdateLayeredWindow(Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, 0, ref blend, ULW_ALPHA); - } - } - } - - public bool Visible - { - get - { - return _visible; - } - set - { - if (_visible != value) - { - _visible = value; - NativeMethods.SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | (value ? SWP_SHOWWINDOW : SWP_HIDEWINDOW)); - - if (value) - { - if (!_alwaysOnTop) - ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged; - } - else - { - if (!_alwaysOnTop) - ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged; - } - } - } - } - - // if locked, the window can not be moved or resized - public bool LockPositionAndSize { get; set; } - - public bool AlwaysOnTop - { - get - { - return _alwaysOnTop; - } - set - { - if (value != _alwaysOnTop) - { - _alwaysOnTop = value; - - if (_alwaysOnTop) - { - if (_visible) - ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged; - - MoveToTopMost(Handle); - } - else - { - MoveToBottom(Handle); - - if (_visible) - ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged; - } - } - } - } - - public Size Size - { - get - { - return _size; - } - set - { - if (_size != value) - { - _size = value; - NativeMethods.UpdateLayeredWindow(Handle, IntPtr.Zero, IntPtr.Zero, ref _size, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, 0); - SizeChanged?.Invoke(this, EventArgs.Empty); - } - } - } - - public Point Location - { - get - { - return _location; - } - set - { - if (_location != value) - { - _location = value; - NativeMethods.SetWindowPos(Handle, IntPtr.Zero, _location.X, _location.Y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING); - LocationChanged?.Invoke(this, EventArgs.Empty); - } - } - } - - public ContextMenuStrip ContextMenuStrip { get; set; } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - private struct BlendFunction - { - public byte BlendOp; - public byte BlendFlags; - public byte SourceConstantAlpha; - public byte AlphaFormat; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - private struct WINDOWPOS - { - public readonly IntPtr hwnd; - public readonly IntPtr hwndInsertAfter; - public int x; - public int y; - public readonly int cx; - public readonly int cy; - public uint flags; - } - - [StructLayout(LayoutKind.Sequential)] - public struct BITMAPINFO - { - public int Size; - public int Width; - public int Height; - public short Planes; - public short BitCount; - public int Compression; - public int SizeImage; - public int XPelsPerMeter; - public int YPelsPerMeter; - public int ClrUsed; - public int ClrImportant; - public int Colors; - } - - public static readonly IntPtr HWND_BOTTOM = (IntPtr)1; - public static readonly IntPtr HWND_TOPMOST = (IntPtr)(-1); - - public const int WS_EX_LAYERED = 0x00080000; - public const int WS_EX_TOOLWINDOW = 0x00000080; - - public const uint SWP_NOSIZE = 0x0001; - public const uint SWP_NOMOVE = 0x0002; - public const uint SWP_NOACTIVATE = 0x0010; - public const uint SWP_FRAMECHANGED = 0x0020; - public const uint SWP_HIDEWINDOW = 0x0080; - public const uint SWP_SHOWWINDOW = 0x0040; - public const uint SWP_NOZORDER = 0x0004; - public const uint SWP_NOSENDCHANGING = 0x0400; - - public const int ULW_COLORKEY = 0x00000001; - public const int ULW_ALPHA = 0x00000002; - public const int ULW_OPAQUE = 0x00000004; - - public const byte AC_SRC_OVER = 0x00; - public const byte AC_SRC_ALPHA = 0x01; - - public const int WM_NCHITTEST = 0x0084; - public const int WM_NCLBUTTONDBLCLK = 0x00A3; - public const int WM_NCLBUTTONDOWN = 0x00A1; - public const int WM_NCLBUTTONUP = 0x00A2; - public const int WM_NCRBUTTONDOWN = 0x00A4; - public const int WM_NCRBUTTONUP = 0x00A5; - public const int WM_WINDOWPOSCHANGING = 0x0046; - public const int WM_COMMAND = 0x0111; - - public const int TPM_RIGHTBUTTON = 0x0002; - public const int TPM_VERTICAL = 0x0040; - - private enum WindowAttribute : int - { - DWMWA_NCRENDERING_ENABLED = 1, - DWMWA_NCRENDERING_POLICY, - DWMWA_TRANSITIONS_FORCEDISABLED, - DWMWA_ALLOW_NCPAINT, - DWMWA_CAPTION_BUTTON_BOUNDS, - DWMWA_NONCLIENT_RTL_LAYOUT, - DWMWA_FORCE_ICONIC_REPRESENTATION, - DWMWA_FLIP3D_POLICY, - DWMWA_EXTENDED_FRAME_BOUNDS, - DWMWA_HAS_ICONIC_BITMAP, - DWMWA_DISALLOW_PEEK, - DWMWA_EXCLUDED_FROM_PEEK, - DWMWA_LAST - } - - /// - /// Some macros imported and converted from the Windows SDK - /// - private static class Macros - { - public static ushort LOWORD(IntPtr l) - { - return (ushort)((ulong)l & 0xFFFF); - } - - public static ushort HIWORD(IntPtr l) - { - return (ushort)(((ulong)l >> 16) & 0xFFFF); - } - - public static int GET_X_LPARAM(IntPtr lp) - { - return (short)LOWORD(lp); - } - - public static int GET_Y_LPARAM(IntPtr lp) - { - return (short)HIWORD(lp); - } - } - - /// - /// Imported native methods - /// - private static class NativeMethods - { - private const string USER = "user32.dll"; - private const string GDI = "gdi32.dll"; - private const string DWMAPI = "dwmapi.dll"; - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, IntPtr pptDst, ref Size psize, IntPtr hdcSrc, IntPtr pprSrc, int crKey, IntPtr pblend, int dwFlags); - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, IntPtr pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, int crKey, ref BlendFunction pblend, int dwFlags); - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, IntPtr pptDst, IntPtr psize, IntPtr hdcSrc, IntPtr pprSrc, int crKey, ref BlendFunction pblend, int dwFlags); - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - public static extern IntPtr GetDC(IntPtr hWnd); - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - public static extern bool TrackPopupMenuEx(IntPtr hMenu, uint uFlags, int x, int y, IntPtr hWnd, IntPtr tpmParams); - - [DllImport(GDI, CallingConvention = CallingConvention.Winapi)] - public static extern IntPtr CreateCompatibleDC(IntPtr hDC); - - [DllImport(GDI, CallingConvention = CallingConvention.Winapi)] - public static extern IntPtr CreateDIBSection(IntPtr hdc, [In] ref BITMAPINFO pbmi, uint pila, out IntPtr ppvBits, IntPtr hSection, uint dwOffset); - - [DllImport(GDI, CallingConvention = CallingConvention.Winapi)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool DeleteDC(IntPtr hdc); - - [DllImport(GDI, CallingConvention = CallingConvention.Winapi)] - public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); - - [DllImport(GDI, CallingConvention = CallingConvention.Winapi)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool DeleteObject(IntPtr hObject); - - [DllImport(DWMAPI, CallingConvention = CallingConvention.Winapi)] - public static extern int DwmSetWindowAttribute(IntPtr hwnd, WindowAttribute dwAttribute, ref bool pvAttribute, int cbAttribute); - } -} - -public delegate void HitTestEventHandler(object sender, HitTestEventArgs e); - -public enum HitResult -{ - Transparent = -1, - Nowhere = 0, - Client = 1, - Caption = 2, - Left = 10, - Right = 11, - Top = 12, - TopLeft = 13, - TopRight = 14, - Bottom = 15, - BottomLeft = 16, - BottomRight = 17, - Border = 18 -} - -public class HitTestEventArgs : EventArgs -{ - public HitTestEventArgs(Point location, HitResult hitResult) - { - Location = location; - HitResult = hitResult; - } - public Point Location { get; } - public HitResult HitResult { get; set; } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/HardwareNode.cs b/LibreHardwareMonitor.Windows.Forms/UI/HardwareNode.cs deleted file mode 100644 index cb2f4f5..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/HardwareNode.cs +++ /dev/null @@ -1,157 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using LibreHardwareMonitor.Hardware; -using LibreHardwareMonitor.Windows.Forms.Utilities; -using System; -using System.Collections.Generic; -using System.Text; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class HardwareNode : Node, IExpandPersistNode -{ - private readonly PersistentSettings _settings; - private readonly UnitManager _unitManager; - private readonly List _typeNodes = new List(); - private readonly string _expandedIdentifier; - private bool _expanded; - - public event EventHandler PlotSelectionChanged; - - public HardwareNode(IHardware hardware, PersistentSettings settings, UnitManager unitManager) - { - _settings = settings; - _unitManager = unitManager; - _expandedIdentifier = new Identifier(hardware.Identifier, "expanded").ToString(); - Hardware = hardware; - Image = HardwareTypeImage.Instance.GetImage(hardware.HardwareType); - - foreach (SensorType sensorType in Enum.GetValues(typeof(SensorType))) - _typeNodes.Add(new TypeNode(sensorType, hardware.Identifier, _settings)); - - foreach (ISensor sensor in hardware.Sensors) - SensorAdded(sensor); - - hardware.SensorAdded += SensorAdded; - hardware.SensorRemoved += SensorRemoved; - - _expanded = settings.GetValue(_expandedIdentifier, true); - } - - - public override string Text - { - get { return Hardware.Name; } - set { Hardware.Name = value; } - } - - public override string ToolTip - { - get - { - IDictionary properties = Hardware.Properties; - - if (properties.Count > 0) - { - StringBuilder stringBuilder = new(); - stringBuilder.AppendLine("Hardware properties:"); - - foreach (KeyValuePair property in properties) - stringBuilder.AppendFormat(" • {0}: {1}\n", property.Key, property.Value); - - return stringBuilder.ToString(); - } - - return null; - } - } - - public IHardware Hardware { get; } - - public bool Expanded - { - get => _expanded; - set - { - _expanded = value; - _settings.SetValue(_expandedIdentifier, _expanded); - } - } - - private void UpdateNode(TypeNode node) - { - if (node.Nodes.Count > 0) - { - if (!Nodes.Contains(node)) - { - int i = 0; - while (i < Nodes.Count && ((TypeNode)Nodes[i]).SensorType < node.SensorType) - i++; - - Nodes.Insert(i, node); - } - } - else - { - if (Nodes.Contains(node)) - Nodes.Remove(node); - } - } - - private void SensorRemoved(ISensor sensor) - { - foreach (TypeNode typeNode in _typeNodes) - { - if (typeNode.SensorType == sensor.SensorType) - { - SensorNode sensorNode = null; - foreach (Node node in typeNode.Nodes) - { - if (node is SensorNode n && n.Sensor == sensor) - sensorNode = n; - } - if (sensorNode != null) - { - sensorNode.PlotSelectionChanged -= SensorPlotSelectionChanged; - typeNode.Nodes.Remove(sensorNode); - UpdateNode(typeNode); - } - } - } - PlotSelectionChanged?.Invoke(this, null); - } - - private void InsertSorted(Node node, ISensor sensor) - { - int i = 0; - while (i < node.Nodes.Count && ((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index) - i++; - - SensorNode sensorNode = new SensorNode(sensor, _settings, _unitManager); - sensorNode.PlotSelectionChanged += SensorPlotSelectionChanged; - node.Nodes.Insert(i, sensorNode); - } - - private void SensorPlotSelectionChanged(object sender, EventArgs e) - { - PlotSelectionChanged?.Invoke(this, null); - } - - private void SensorAdded(ISensor sensor) - { - foreach (TypeNode typeNode in _typeNodes) - { - if (typeNode.SensorType == sensor.SensorType) - { - InsertSorted(typeNode, sensor); - UpdateNode(typeNode); - } - } - - PlotSelectionChanged?.Invoke(this, null); - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/HardwareTypeImage.cs b/LibreHardwareMonitor.Windows.Forms/UI/HardwareTypeImage.cs deleted file mode 100644 index 0a59909..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/HardwareTypeImage.cs +++ /dev/null @@ -1,76 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System.Drawing; -using System.Collections.Generic; -using LibreHardwareMonitor.Hardware; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class HardwareTypeImage -{ - private readonly IDictionary _images = new Dictionary(); - - private HardwareTypeImage() { } - - public static HardwareTypeImage Instance { get; } = new HardwareTypeImage(); - - public Image GetImage(HardwareType hardwareType) - { - if (_images.TryGetValue(hardwareType, out Image image)) - return image; - - - switch (hardwareType) - { - case HardwareType.Cpu: - image = Utilities.EmbeddedResources.GetImage("cpu.png"); - break; - case HardwareType.GpuNvidia: - image = Utilities.EmbeddedResources.GetImage("nvidia.png"); - break; - case HardwareType.GpuAmd: - image = Utilities.EmbeddedResources.GetImage("amd.png"); - break; - case HardwareType.GpuIntel: - image = Utilities.EmbeddedResources.GetImage("intel.png"); - break; - case HardwareType.Storage: - image = Utilities.EmbeddedResources.GetImage("hdd.png"); - break; - case HardwareType.Motherboard: - image = Utilities.EmbeddedResources.GetImage("mainboard.png"); - break; - case HardwareType.SuperIO: - case HardwareType.EmbeddedController: - image = Utilities.EmbeddedResources.GetImage("chip.png"); - break; - case HardwareType.Memory: - image = Utilities.EmbeddedResources.GetImage("ram.png"); - break; - case HardwareType.Network: - image = Utilities.EmbeddedResources.GetImage("nic.png"); - break; - case HardwareType.Cooler: - image = Utilities.EmbeddedResources.GetImage("fan.png"); - break; - case HardwareType.Psu: - image = Utilities.EmbeddedResources.GetImage("power-supply.png"); - break; - case HardwareType.Battery: - image = Utilities.EmbeddedResources.GetImage("battery.png"); - break; - case HardwareType.PowerMonitor: - image = Utilities.EmbeddedResources.GetImage("powermonitor.png"); - break; - default: - image = new Bitmap(1, 1); - break; - } - _images.Add(hardwareType, image); - return image; - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/IExpandPersistNode.cs b/LibreHardwareMonitor.Windows.Forms/UI/IExpandPersistNode.cs deleted file mode 100644 index 36b8246..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/IExpandPersistNode.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public interface IExpandPersistNode -{ - bool Expanded { get; set; } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/InterfacePortForm.Designer.cs b/LibreHardwareMonitor.Windows.Forms/UI/InterfacePortForm.Designer.cs deleted file mode 100644 index 143ca58..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/InterfacePortForm.Designer.cs +++ /dev/null @@ -1,221 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -namespace LibreHardwareMonitor.Windows.Forms.UI -{ - partial class InterfacePortForm - { - /// - /// 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 Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InterfacePortForm)); - this.portOKButton = new System.Windows.Forms.Button(); - this.portCancelButton = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.webServerLinkLabel = new System.Windows.Forms.LinkLabel(); - this.portNumericUpDn = new System.Windows.Forms.NumericUpDown(); - this.label5 = new System.Windows.Forms.Label(); - this.interfaceLabel = new System.Windows.Forms.Label(); - this.interfaceComboBox = new System.Windows.Forms.ComboBox(); - ((System.ComponentModel.ISupportInitialize)(this.portNumericUpDn)).BeginInit(); - this.SuspendLayout(); - // - // portOKButton - // - this.portOKButton.Location = new System.Drawing.Point(244, 162); - this.portOKButton.Name = "portOKButton"; - this.portOKButton.Size = new System.Drawing.Size(75, 23); - this.portOKButton.TabIndex = 0; - this.portOKButton.Text = "OK"; - this.portOKButton.UseVisualStyleBackColor = true; - this.portOKButton.Click += new System.EventHandler(this.PortOKButton_Click); - // - // portCancelButton - // - this.portCancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.portCancelButton.Location = new System.Drawing.Point(162, 162); - this.portCancelButton.Name = "portCancelButton"; - this.portCancelButton.Size = new System.Drawing.Size(75, 23); - this.portCancelButton.TabIndex = 1; - this.portCancelButton.Text = "Cancel"; - this.portCancelButton.UseVisualStyleBackColor = true; - this.portCancelButton.Click += new System.EventHandler(this.PortCancelButton_Click); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 131); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(377, 13); - this.label1.TabIndex = 3; - this.label1.Text = "Note: You will need to open the port in firewall settings of the operating system" + - "."; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(13, 34); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(190, 13); - this.label2.TabIndex = 4; - this.label2.Text = "Port number for the remote web server:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(13, 64); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(443, 13); - this.label3.TabIndex = 5; - this.label3.Text = "If the web server is running then it will need to be restarted for the port chang" + - "e to take effect."; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(13, 86); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(262, 13); - this.label4.TabIndex = 6; - this.label4.Text = "The web server will be accessible from the browser at "; - // - // webServerLinkLabel - // - this.webServerLinkLabel.AutoSize = true; - this.webServerLinkLabel.Location = new System.Drawing.Point(269, 86); - this.webServerLinkLabel.Name = "webServerLinkLabel"; - this.webServerLinkLabel.Size = new System.Drawing.Size(55, 13); - this.webServerLinkLabel.TabIndex = 7; - this.webServerLinkLabel.TabStop = true; - this.webServerLinkLabel.Text = "linkLabel1"; - this.webServerLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.WebServerLinkLabel_LinkClicked); - // - // portNumericUpDn - // - this.portNumericUpDn.Location = new System.Drawing.Point(208, 32); - this.portNumericUpDn.Maximum = new decimal(new int[] { - 20000, - 0, - 0, - 0}); - this.portNumericUpDn.Minimum = new decimal(new int[] { - 8080, - 0, - 0, - 0}); - this.portNumericUpDn.Name = "portNumericUpDn"; - this.portNumericUpDn.Size = new System.Drawing.Size(75, 20); - this.portNumericUpDn.TabIndex = 8; - this.portNumericUpDn.Value = new decimal(new int[] { - 8080, - 0, - 0, - 0}); - this.portNumericUpDn.ValueChanged += new System.EventHandler(this.PortNumericUpDn_ValueChanged); - this.portNumericUpDn.KeyUp += new System.Windows.Forms.KeyEventHandler(this.PortNumericUpDn_KeyUp); - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(13, 109); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(304, 13); - this.label5.TabIndex = 9; - this.label5.Text = "You will have to start the server by clicking Run from the menu."; - // - // interfaceLabel - // - this.interfaceLabel.AutoSize = true; - this.interfaceLabel.Location = new System.Drawing.Point(14, 8); - this.interfaceLabel.Name = "interfaceLabel"; - this.interfaceLabel.Size = new System.Drawing.Size(217, 13); - this.interfaceLabel.TabIndex = 10; - this.interfaceLabel.Text = "Network interface for the remote web server:"; - // - // interfaceComboBox - // - this.interfaceComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.interfaceComboBox.FormattingEnabled = true; - this.interfaceComboBox.Location = new System.Drawing.Point(233, 6); - this.interfaceComboBox.Margin = new System.Windows.Forms.Padding(2); - this.interfaceComboBox.Name = "interfaceComboBox"; - this.interfaceComboBox.Size = new System.Drawing.Size(221, 21); - this.interfaceComboBox.TabIndex = 11; - this.interfaceComboBox.SelectedIndexChanged += new System.EventHandler(this.interfaceComboBox_SelectedIndexChanged); - // - // InterfacePortForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.portCancelButton; - this.ClientSize = new System.Drawing.Size(466, 202); - this.Controls.Add(this.interfaceComboBox); - this.Controls.Add(this.interfaceLabel); - this.Controls.Add(this.label5); - this.Controls.Add(this.portNumericUpDn); - this.Controls.Add(this.webServerLinkLabel); - this.Controls.Add(this.label4); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.portCancelButton); - this.Controls.Add(this.portOKButton); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "InterfacePortForm"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Set Port"; - this.Load += new System.EventHandler(this.PortForm_Load); - ((System.ComponentModel.ISupportInitialize)(this.portNumericUpDn)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button portOKButton; - private System.Windows.Forms.Button portCancelButton; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.LinkLabel webServerLinkLabel; - private System.Windows.Forms.NumericUpDown portNumericUpDn; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label interfaceLabel; - private System.Windows.Forms.ComboBox interfaceComboBox; - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/InterfacePortForm.cs b/LibreHardwareMonitor.Windows.Forms/UI/InterfacePortForm.cs deleted file mode 100644 index f326a34..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/InterfacePortForm.cs +++ /dev/null @@ -1,104 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Windows.Forms; -using System.Net; -using System.Net.Sockets; -using System.Diagnostics; -using static System.Windows.Forms.VisualStyles.VisualStyleElement; -using System.Net.NetworkInformation; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public partial class InterfacePortForm : Form -{ - private readonly MainForm _parent; - private string _localIP; - - public InterfacePortForm(MainForm m) - { - InitializeComponent(); - _parent = m; - _localIP = LoadNetworkInterfaces(_parent.Server.ListenerIp); - } - - private string LoadNetworkInterfaces(string selectedListenerIp) - { - IPHostEntry host; - interfaceComboBox.Items.Clear(); - host = Dns.GetHostEntry(Dns.GetHostName()); - foreach (IPAddress ip in host.AddressList) - { - if (ip.AddressFamily == AddressFamily.InterNetwork) - interfaceComboBox.Items.Add(ip.ToString()); - } - - interfaceComboBox.Items.Add("0.0.0.0"); - - // select the last one by default to match the existing behavior - if (interfaceComboBox.Items.Count > 0) - { - interfaceComboBox.SelectedIndex = interfaceComboBox.Items.Count - 1; - } - - // check to see if the selected listener IP is in our list. - if (interfaceComboBox.Items.Contains(selectedListenerIp)) - { - // default it to the previously selected IP. - interfaceComboBox.SelectedItem = selectedListenerIp; - } - return interfaceComboBox.SelectedItem as string; - } - - private void PortNumericUpDn_ValueChanged(object sender, EventArgs e) - { - string url = "http://" + _localIP + ":" + portNumericUpDn.Value + "/"; - webServerLinkLabel.Text = url; - webServerLinkLabel.Links.Remove(webServerLinkLabel.Links[0]); - webServerLinkLabel.Links.Add(0, webServerLinkLabel.Text.Length, url); - } - - private void PortOKButton_Click(object sender, EventArgs e) - { - _parent.Server.ListenerPort = (int)portNumericUpDn.Value; - _parent.Server.ListenerIp = _localIP; - Close(); - } - - private void PortCancelButton_Click(object sender, EventArgs e) - { - Close(); - } - - private void PortForm_Load(object sender, EventArgs e) - { - interfaceComboBox.SelectedValue = _parent.Server.ListenerIp; - portNumericUpDn.Value = _parent.Server.ListenerPort; - PortNumericUpDn_ValueChanged(null, null); - } - - private void WebServerLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - try - { - Process.Start(new ProcessStartInfo(e.Link.LinkData.ToString())); - } - catch { } - } - - private void PortNumericUpDn_KeyUp(object sender, KeyEventArgs e) - { - PortNumericUpDn_ValueChanged(null, null); - } - - private void interfaceComboBox_SelectedIndexChanged(object sender, EventArgs e) - { - - _localIP = interfaceComboBox.SelectedItem as string; - PortNumericUpDn_ValueChanged(null, null); - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/InterfacePortForm.resx b/LibreHardwareMonitor.Windows.Forms/UI/InterfacePortForm.resx deleted file mode 100644 index b7102bd..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/InterfacePortForm.resx +++ /dev/null @@ -1,377 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAMAEBAAAAEAIABoBAAANgAAACAgAAABACAAqBAAAJ4EAAAwMAAAAQAgAKglAABGFQAAKAAAABAA - AAAgAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEU8OykuDgdIIxQSURwdHU8ZGhpPFhYWTxQU - FE8SEhJPDxAPTw0KCk8KBQRPCAQDTwcDAU8HAQBPBgQEU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AAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA+AAAAAAfAAD4AAAAAB8AAPgA - AAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAf - AAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgA - AAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAf - AAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgA - AAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAP///////wAA//////// - AAD///////8AAP///////wAA////////AAA= - - - \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/MainForm.Designer.cs b/LibreHardwareMonitor.Windows.Forms/UI/MainForm.Designer.cs deleted file mode 100644 index 369317b..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/MainForm.Designer.cs +++ /dev/null @@ -1,1251 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -namespace LibreHardwareMonitor.Windows.Forms.UI -{ - sealed partial class MainForm - { - /// - /// 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 Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.sensor = new Aga.Controls.Tree.TreeColumn(); - this.value = new Aga.Controls.Tree.TreeColumn(); - this.min = new Aga.Controls.Tree.TreeColumn(); - this.max = new Aga.Controls.Tree.TreeColumn(); - this.nodeImage = new Aga.Controls.Tree.NodeControls.NodeIcon(); - this.nodeCheckBox = new Aga.Controls.Tree.NodeControls.NodeCheckBox(); - this.nodeTextBoxText = new Aga.Controls.Tree.NodeControls.NodeTextBox(); - this.nodeTextBoxValue = new Aga.Controls.Tree.NodeControls.NodeTextBox(); - this.nodeTextBoxMin = new Aga.Controls.Tree.NodeControls.NodeTextBox(); - this.nodeTextBoxMax = new Aga.Controls.Tree.NodeControls.NodeTextBox(); - this.mainMenu = new System.Windows.Forms.MenuStrip(); - this.fileMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveReportMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.MenuItem2 = new System.Windows.Forms.ToolStripSeparator(); - this.resetMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuItemFileHardware = new System.Windows.Forms.ToolStripMenuItem(); - this.mainboardMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.cpuMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.ramMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.gpuMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.powerMonitorMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.fanControllerMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.hddMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.nicMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.psuMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuItem6 = new System.Windows.Forms.ToolStripSeparator(); - this.exitMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.viewMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.resetMinMaxMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.expandAllNodesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.collpaseAllNodesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.resetPlotMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.MenuItem3 = new System.Windows.Forms.ToolStripSeparator(); - this.hiddenMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.plotMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.gadgetMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.MenuItem1 = new System.Windows.Forms.ToolStripSeparator(); - this.columnsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.valueMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.minMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.maxMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.optionsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startMinMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.minTrayMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.minCloseMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startupMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.separatorMenuItem = new System.Windows.Forms.ToolStripSeparator(); - this.temperatureUnitsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.celsiusMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.fahrenheitMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.plotLocationMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.plotWindowMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.plotBottomMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.plotRightMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.themeMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.strokeThicknessMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.strokeThickness1ptMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.strokeThickness2ptMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.strokeThickness3ptMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.strokeThickness4ptMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.splitPlotPanelScalingMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.splitPanelPercentageScalingMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.splitPanelFixedPlotScalingMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.splitPanelFixedSensorScalingMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.logSeparatorMenuItem = new System.Windows.Forms.ToolStripSeparator(); - this.logSensorsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.forceDriveWakeupItem = new System.Windows.Forms.ToolStripMenuItem(); - this.fileRotationMethod = new System.Windows.Forms.ToolStripMenuItem(); - this.perSessionFileRotationMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.dailyFileRotationMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.loggingIntervalMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.log1sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log2sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log5sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log10sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log30sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log1minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log2minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log5minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log10minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log30minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log1hMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log2hMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.log6hMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.updateIntervalMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.updateInterval250msMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.updateInterval500msMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.updateInterval1sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.updateInterval2sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.updateInterval5sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.updateInterval10sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.throttleAtaUpdateMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sensorValuesTimeWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.timeWindow30sMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow1minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow2minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow5minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow10minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow30minMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow1hMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow2hMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow6hMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow12hMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.timeWindow24hMenuItem = new LibreHardwareMonitor.Windows.Forms.UI.ToolStripRadioButtonMenuItem(); - this.webMenuItemSeparator = new System.Windows.Forms.ToolStripSeparator(); - this.webMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.runWebServerMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.serverInterfacePortMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.authWebServerMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.helpMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.aboutMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.treeContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); - this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); - this.timer = new System.Windows.Forms.Timer(this.components); - this.splitContainer = new LibreHardwareMonitor.Windows.Forms.UI.SplitContainerAdv(); - this.treeView = new Aga.Controls.Tree.TreeViewAdv(); - this.batteryMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.backgroundUpdater = new System.ComponentModel.BackgroundWorker(); - this.mainMenu.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); - this.splitContainer.Panel1.SuspendLayout(); - this.splitContainer.SuspendLayout(); - this.SuspendLayout(); - // - // sensor - // - this.sensor.Header = "Sensor"; - this.sensor.SortOrder = System.Windows.Forms.SortOrder.None; - this.sensor.TooltipText = null; - this.sensor.Width = 250; - this.sensor.WidthChanged += delegate { TreeView_ColumnWidthChanged(this.sensor); }; - // - // value - // - this.value.Header = "Value"; - this.value.SortOrder = System.Windows.Forms.SortOrder.None; - this.value.TooltipText = null; - this.value.Width = 100; - this.value.WidthChanged += delegate { TreeView_ColumnWidthChanged(this.value); }; - // - // min - // - this.min.Header = "Min"; - this.min.SortOrder = System.Windows.Forms.SortOrder.None; - this.min.TooltipText = null; - this.min.Width = 100; - this.min.WidthChanged += delegate { TreeView_ColumnWidthChanged(this.min); }; - // - // max - // - this.max.Header = "Max"; - this.max.SortOrder = System.Windows.Forms.SortOrder.None; - this.max.TooltipText = null; - this.max.Width = 100; - this.max.WidthChanged += delegate { TreeView_ColumnWidthChanged(this.max); }; - // - // nodeImage - // - this.nodeImage.DataPropertyName = "Image"; - this.nodeImage.LeftMargin = 1; - this.nodeImage.ParentColumn = this.sensor; - this.nodeImage.ScaleMode = Aga.Controls.Tree.ImageScaleMode.Fit; - // - // nodeCheckBox - // - this.nodeCheckBox.DataPropertyName = "Plot"; - this.nodeCheckBox.EditEnabled = true; - this.nodeCheckBox.LeftMargin = 3; - this.nodeCheckBox.ParentColumn = this.sensor; - // - // nodeTextBoxText - // - this.nodeTextBoxText.DataPropertyName = "Text"; - this.nodeTextBoxText.EditEnabled = true; - this.nodeTextBoxText.IncrementalSearchEnabled = true; - this.nodeTextBoxText.LeftMargin = 3; - this.nodeTextBoxText.ParentColumn = this.sensor; - this.nodeTextBoxText.Trimming = System.Drawing.StringTrimming.EllipsisCharacter; - this.nodeTextBoxText.UseCompatibleTextRendering = true; - // - // nodeTextBoxValue - // - this.nodeTextBoxValue.DataPropertyName = "Value"; - this.nodeTextBoxValue.IncrementalSearchEnabled = true; - this.nodeTextBoxValue.LeftMargin = 3; - this.nodeTextBoxValue.ParentColumn = this.value; - this.nodeTextBoxValue.Trimming = System.Drawing.StringTrimming.EllipsisCharacter; - this.nodeTextBoxValue.UseCompatibleTextRendering = true; - // - // nodeTextBoxMin - // - this.nodeTextBoxMin.DataPropertyName = "Min"; - this.nodeTextBoxMin.IncrementalSearchEnabled = true; - this.nodeTextBoxMin.LeftMargin = 3; - this.nodeTextBoxMin.ParentColumn = this.min; - this.nodeTextBoxMin.Trimming = System.Drawing.StringTrimming.EllipsisCharacter; - this.nodeTextBoxMin.UseCompatibleTextRendering = true; - // - // nodeTextBoxMax - // - this.nodeTextBoxMax.DataPropertyName = "Max"; - this.nodeTextBoxMax.IncrementalSearchEnabled = true; - this.nodeTextBoxMax.LeftMargin = 3; - this.nodeTextBoxMax.ParentColumn = this.max; - this.nodeTextBoxMax.Trimming = System.Drawing.StringTrimming.EllipsisCharacter; - this.nodeTextBoxMax.UseCompatibleTextRendering = true; - // - // mainMenu - // - this.mainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.fileMenuItem, - this.viewMenuItem, - this.optionsMenuItem, - this.helpMenuItem}); - this.mainMenu.Location = new System.Drawing.Point(0, 0); - this.mainMenu.Name = "mainMenu"; - this.mainMenu.Size = new System.Drawing.Size(418, 24); - this.mainMenu.TabIndex = 1; - // - // fileMenuItem - // - this.fileMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.saveReportMenuItem, - this.MenuItem2, - this.resetMenuItem, - this.menuItemFileHardware, - this.menuItem6, - this.exitMenuItem}); - this.fileMenuItem.Name = "fileMenuItem"; - this.fileMenuItem.Size = new System.Drawing.Size(37, 20); - this.fileMenuItem.Text = "File"; - // - // saveReportMenuItem - // - this.saveReportMenuItem.Name = "saveReportMenuItem"; - this.saveReportMenuItem.Size = new System.Drawing.Size(180, 22); - this.saveReportMenuItem.Text = "Save Report..."; - this.saveReportMenuItem.Click += new System.EventHandler(this.SaveReportMenuItem_Click); - // - // MenuItem2 - // - this.MenuItem2.Name = "MenuItem2"; - this.MenuItem2.Size = new System.Drawing.Size(177, 6); - // - // resetMenuItem - // - this.resetMenuItem.Name = "resetMenuItem"; - this.resetMenuItem.Size = new System.Drawing.Size(180, 22); - this.resetMenuItem.Text = "Reset"; - this.resetMenuItem.Click += new System.EventHandler(this.ResetClick); - // - // menuItem5 - // - this.menuItemFileHardware.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mainboardMenuItem, - this.cpuMenuItem, - this.ramMenuItem, - this.gpuMenuItem, - this.powerMonitorMenuItem, - this.fanControllerMenuItem, - this.hddMenuItem, - this.nicMenuItem, - this.psuMenuItem, - this.batteryMenuItem}); - this.menuItemFileHardware.Name = "menuItem5"; - this.menuItemFileHardware.Size = new System.Drawing.Size(180, 22); - this.menuItemFileHardware.Text = "Hardware"; - // - // mainboardMenuItem - // - this.mainboardMenuItem.Name = "mainboardMenuItem"; - this.mainboardMenuItem.Size = new System.Drawing.Size(180, 22); - this.mainboardMenuItem.Text = "Motherboard"; - // - // cpuMenuItem - // - this.cpuMenuItem.Name = "cpuMenuItem"; - this.cpuMenuItem.Size = new System.Drawing.Size(180, 22); - this.cpuMenuItem.Text = "CPU"; - // - // ramMenuItem - // - this.ramMenuItem.Name = "ramMenuItem"; - this.ramMenuItem.Size = new System.Drawing.Size(180, 22); - this.ramMenuItem.Text = "RAM"; - // - // gpuMenuItem - // - this.gpuMenuItem.Name = "gpuMenuItem"; - this.gpuMenuItem.Size = new System.Drawing.Size(180, 22); - this.gpuMenuItem.Text = "GPU"; - // - // powerMonitorMenuItem - // - this.powerMonitorMenuItem.Name = "powerMonitorMenuItem"; - this.powerMonitorMenuItem.Size = new System.Drawing.Size(180, 22); - this.powerMonitorMenuItem.Text = "Power Monitors"; - // - // fanControllerMenuItem - // - this.fanControllerMenuItem.Name = "fanControllerMenuItem"; - this.fanControllerMenuItem.Size = new System.Drawing.Size(180, 22); - this.fanControllerMenuItem.Text = "Fan Controllers"; - // - // hddMenuItem - // - this.hddMenuItem.Name = "hddMenuItem"; - this.hddMenuItem.Size = new System.Drawing.Size(180, 22); - this.hddMenuItem.Text = "Storage Devices"; - // - // nicMenuItem - // - this.nicMenuItem.Name = "nicMenuItem"; - this.nicMenuItem.Size = new System.Drawing.Size(180, 22); - this.nicMenuItem.Text = "Network"; - // - // psuMenuItem - // - this.psuMenuItem.Name = "psuMenuItem"; - this.psuMenuItem.Size = new System.Drawing.Size(180, 22); - this.psuMenuItem.Text = "Power supplies"; - // - // menuItem6 - // - this.menuItem6.Name = "menuItem6"; - this.menuItem6.Size = new System.Drawing.Size(177, 6); - // - // exitMenuItem - // - this.exitMenuItem.Name = "exitMenuItem"; - this.exitMenuItem.Size = new System.Drawing.Size(180, 22); - this.exitMenuItem.Text = "Exit"; - this.exitMenuItem.Click += new System.EventHandler(this.ExitClick); - // - // viewMenuItem - // - this.viewMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.resetMinMaxMenuItem, - this.expandAllNodesMenuItem, - this.collpaseAllNodesMenuItem, - this.resetPlotMenuItem, - this.MenuItem3, - this.hiddenMenuItem, - this.plotMenuItem, - this.gadgetMenuItem, - this.MenuItem1, - this.columnsMenuItem}); - this.viewMenuItem.Name = "viewMenuItem"; - this.viewMenuItem.Size = new System.Drawing.Size(44, 20); - this.viewMenuItem.Text = "View"; - // - // resetMinMaxMenuItem - // - this.resetMinMaxMenuItem.Name = "resetMinMaxMenuItem"; - this.resetMinMaxMenuItem.Size = new System.Drawing.Size(188, 22); - this.resetMinMaxMenuItem.Text = "Reset Min/Max"; - this.resetMinMaxMenuItem.Click += new System.EventHandler(this.ResetMinMaxMenuItem_Click); - // - // expandAllNodesMenuItem - // - this.expandAllNodesMenuItem.Name = "expandAllNodesMenuItem"; - this.expandAllNodesMenuItem.Size = new System.Drawing.Size(188, 22); - this.expandAllNodesMenuItem.Text = "Expand All Nodes"; - this.expandAllNodesMenuItem.Click += new System.EventHandler(this.ExpandAllNodes_Click); - // - // collpaseAllNodesMenuItem - // - this.collpaseAllNodesMenuItem.Name = "collpaseAllNodesMenuItem"; - this.collpaseAllNodesMenuItem.Size = new System.Drawing.Size(188, 22); - this.collpaseAllNodesMenuItem.Text = "Collapse All Nodes"; - this.collpaseAllNodesMenuItem.Click += new System.EventHandler(this.CollapseAllNodes_Click); - // - // resetPlotMenuItem - // - this.resetPlotMenuItem.Name = "resetPlotMenuItem"; - this.resetPlotMenuItem.Size = new System.Drawing.Size(188, 22); - this.resetPlotMenuItem.Text = "Reset Plot"; - this.resetPlotMenuItem.Click += new System.EventHandler(this.resetPlotMenuItem_Click); - // - // MenuItem3 - // - this.MenuItem3.Name = "MenuItem3"; - this.MenuItem3.Size = new System.Drawing.Size(185, 6); - // - // hiddenMenuItem - // - this.hiddenMenuItem.Name = "hiddenMenuItem"; - this.hiddenMenuItem.Size = new System.Drawing.Size(188, 22); - this.hiddenMenuItem.Text = "Show Hidden Sensors"; - // - // plotMenuItem - // - this.plotMenuItem.Name = "plotMenuItem"; - this.plotMenuItem.Size = new System.Drawing.Size(188, 22); - this.plotMenuItem.Text = "Show Plot"; - // - // gadgetMenuItem - // - this.gadgetMenuItem.Name = "gadgetMenuItem"; - this.gadgetMenuItem.Size = new System.Drawing.Size(188, 22); - this.gadgetMenuItem.Text = "Show Gadget"; - // - // MenuItem1 - // - this.MenuItem1.Name = "MenuItem1"; - this.MenuItem1.Size = new System.Drawing.Size(185, 6); - // - // columnsMenuItem - // - this.columnsMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.valueMenuItem, - this.minMenuItem, - this.maxMenuItem}); - this.columnsMenuItem.Name = "columnsMenuItem"; - this.columnsMenuItem.Size = new System.Drawing.Size(188, 22); - this.columnsMenuItem.Text = "Columns"; - // - // valueMenuItem - // - this.valueMenuItem.Name = "valueMenuItem"; - this.valueMenuItem.Size = new System.Drawing.Size(180, 22); - this.valueMenuItem.Text = "Value"; - // - // minMenuItem - // - this.minMenuItem.Name = "minMenuItem"; - this.minMenuItem.Size = new System.Drawing.Size(180, 22); - this.minMenuItem.Text = "Min"; - // - // maxMenuItem - // - this.maxMenuItem.Name = "maxMenuItem"; - this.maxMenuItem.Size = new System.Drawing.Size(180, 22); - this.maxMenuItem.Text = "Max"; - // - // optionsMenuItem - // - this.optionsMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.startMinMenuItem, - this.minTrayMenuItem, - this.minCloseMenuItem, - this.startupMenuItem, - this.separatorMenuItem, - this.temperatureUnitsMenuItem, - this.plotLocationMenuItem, - this.strokeThicknessMenuItem, - this.themeMenuItem, - this.splitPlotPanelScalingMenuItem, - this.logSeparatorMenuItem, - this.logSensorsMenuItem, - this.forceDriveWakeupItem, - this.loggingIntervalMenuItem, - this.updateIntervalMenuItem, - this.fileRotationMethod, - this.sensorValuesTimeWindowMenuItem, - this.webMenuItemSeparator, - this.webMenuItem}); - this.optionsMenuItem.Name = "optionsMenuItem"; - this.optionsMenuItem.Size = new System.Drawing.Size(61, 20); - this.optionsMenuItem.Text = "Options"; - // - // startMinMenuItem - // - this.startMinMenuItem.Name = "startMinMenuItem"; - this.startMinMenuItem.Size = new System.Drawing.Size(221, 22); - this.startMinMenuItem.Text = "Start Minimized"; - // - // minTrayMenuItem - // - this.minTrayMenuItem.Name = "minTrayMenuItem"; - this.minTrayMenuItem.Size = new System.Drawing.Size(221, 22); - this.minTrayMenuItem.Text = "Minimize To Tray"; - // - // minCloseMenuItem - // - this.minCloseMenuItem.Name = "minCloseMenuItem"; - this.minCloseMenuItem.Size = new System.Drawing.Size(221, 22); - this.minCloseMenuItem.Text = "Minimize On Close"; - // - // startupMenuItem - // - this.startupMenuItem.Name = "startupMenuItem"; - this.startupMenuItem.Size = new System.Drawing.Size(221, 22); - this.startupMenuItem.Text = "Run On Windows Startup"; - // - // separatorMenuItem - // - this.separatorMenuItem.Name = "separatorMenuItem"; - this.separatorMenuItem.Size = new System.Drawing.Size(218, 6); - // - // temperatureUnitsMenuItem - // - this.temperatureUnitsMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.celsiusMenuItem, - this.fahrenheitMenuItem}); - this.temperatureUnitsMenuItem.Name = "temperatureUnitsMenuItem"; - this.temperatureUnitsMenuItem.Size = new System.Drawing.Size(221, 22); - this.temperatureUnitsMenuItem.Text = "Temperature Unit"; - // - // celsiusMenuItem - // - this.celsiusMenuItem.CheckOnClick = true; - this.celsiusMenuItem.Name = "celsiusMenuItem"; - this.celsiusMenuItem.Size = new System.Drawing.Size(130, 22); - this.celsiusMenuItem.Text = "Celsius"; - this.celsiusMenuItem.Click += new System.EventHandler(this.CelsiusMenuItem_Click); - // - // fahrenheitMenuItem - // - this.fahrenheitMenuItem.CheckOnClick = true; - this.fahrenheitMenuItem.Name = "fahrenheitMenuItem"; - this.fahrenheitMenuItem.Size = new System.Drawing.Size(130, 22); - this.fahrenheitMenuItem.Text = "Fahrenheit"; - this.fahrenheitMenuItem.Click += new System.EventHandler(this.FahrenheitMenuItem_Click); - // - // plotLocationMenuItem - // - this.plotLocationMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.plotWindowMenuItem, - this.plotBottomMenuItem, - this.plotRightMenuItem}); - this.plotLocationMenuItem.Name = "plotLocationMenuItem"; - this.plotLocationMenuItem.Size = new System.Drawing.Size(221, 22); - this.plotLocationMenuItem.Text = "Plot Location"; - // - // plotWindowMenuItem - // - this.plotWindowMenuItem.CheckOnClick = true; - this.plotWindowMenuItem.Name = "plotWindowMenuItem"; - this.plotWindowMenuItem.Size = new System.Drawing.Size(118, 22); - this.plotWindowMenuItem.Text = "Window"; - // - // plotBottomMenuItem - // - this.plotBottomMenuItem.CheckOnClick = true; - this.plotBottomMenuItem.Name = "plotBottomMenuItem"; - this.plotBottomMenuItem.Size = new System.Drawing.Size(118, 22); - this.plotBottomMenuItem.Text = "Bottom"; - // - // plotRightMenuItem - // - this.plotRightMenuItem.CheckOnClick = true; - this.plotRightMenuItem.Name = "plotRightMenuItem"; - this.plotRightMenuItem.Size = new System.Drawing.Size(118, 22); - this.plotRightMenuItem.Text = "Right"; - // - // themeMenuItem - // - this.themeMenuItem.Name = "themeMenuItem"; - this.themeMenuItem.Size = new System.Drawing.Size(278, 22); - this.themeMenuItem.Text = "Theme"; - // - // strokeThicknessMenuItem - // - this.strokeThicknessMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.strokeThickness1ptMenuItem, - this.strokeThickness2ptMenuItem, - this.strokeThickness3ptMenuItem, - this.strokeThickness4ptMenuItem}); - this.strokeThicknessMenuItem.Name = "strokeThicknessMenuItem"; - this.strokeThicknessMenuItem.Size = new System.Drawing.Size(278, 22); - this.strokeThicknessMenuItem.Text = "Stroke Thickness"; - // - // strokeThickness1ptMenuItem - // - this.strokeThickness1ptMenuItem.CheckOnClick = true; - this.strokeThickness1ptMenuItem.Name = "strokeThickness1ptMenuItem"; - this.strokeThickness1ptMenuItem.Size = new System.Drawing.Size(224, 22); - this.strokeThickness1ptMenuItem.Text = "1pt"; - // - // strokeThickness2ptMenuItem - // - this.strokeThickness2ptMenuItem.CheckOnClick = true; - this.strokeThickness2ptMenuItem.Name = "strokeThickness2ptMenuItem"; - this.strokeThickness2ptMenuItem.Size = new System.Drawing.Size(224, 22); - this.strokeThickness2ptMenuItem.Text = "2pt"; - // - // strokeThickness3ptMenuItem - // - this.strokeThickness3ptMenuItem.CheckOnClick = true; - this.strokeThickness3ptMenuItem.Name = "strokeThickness3ptMenuItem"; - this.strokeThickness3ptMenuItem.Size = new System.Drawing.Size(224, 22); - this.strokeThickness3ptMenuItem.Text = "3pt"; - // - // strokeThickness4ptMenuItem - // - this.strokeThickness4ptMenuItem.CheckOnClick = true; - this.strokeThickness4ptMenuItem.Name = "strokeThickness4ptMenuItem"; - this.strokeThickness4ptMenuItem.Size = new System.Drawing.Size(224, 26); - this.strokeThickness4ptMenuItem.Text = "4pt"; - // - // attachedPlotPanelScalingMenuItem - // - this.splitPlotPanelScalingMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.splitPanelPercentageScalingMenuItem, - this.splitPanelFixedPlotScalingMenuItem, - this.splitPanelFixedSensorScalingMenuItem}); - this.splitPlotPanelScalingMenuItem.Name = "attachedPlotPanelScalingMenuItem"; - this.splitPlotPanelScalingMenuItem.Size = new System.Drawing.Size(221, 22); - this.splitPlotPanelScalingMenuItem.Text = "Split Panel Scaling Mode"; - // - // attachedPanelPercentageScalingMenuItem - // - this.splitPanelPercentageScalingMenuItem.CheckOnClick = true; - this.splitPanelPercentageScalingMenuItem.Name = "attachedPlotPanelPercentageScalingMenuItem"; - this.splitPanelPercentageScalingMenuItem.Size = new System.Drawing.Size(118, 22); - this.splitPanelPercentageScalingMenuItem.Text = "Percentage Scaling"; - // - // attachedPanelFixedWidthPlotPanelScalingMenuItem - // - this.splitPanelFixedPlotScalingMenuItem.CheckOnClick = true; - this.splitPanelFixedPlotScalingMenuItem.Name = "attachedBottomMenuItem"; - this.splitPanelFixedPlotScalingMenuItem.Size = new System.Drawing.Size(118, 22); - this.splitPanelFixedPlotScalingMenuItem.Text = "Fixed Size Plot Panel"; - // - // attachedPanelFixedWidthSensorPanelScalingMenuItem - // - this.splitPanelFixedSensorScalingMenuItem.CheckOnClick = true; - this.splitPanelFixedSensorScalingMenuItem.Name = "attachedRightMenuItem"; - this.splitPanelFixedSensorScalingMenuItem.Size = new System.Drawing.Size(118, 22); - this.splitPanelFixedSensorScalingMenuItem.Text = "Fixed Size Sensor Panel"; - // - // logSeparatorMenuItem - // - this.logSeparatorMenuItem.Name = "logSeparatorMenuItem"; - this.logSeparatorMenuItem.Size = new System.Drawing.Size(218, 6); - // - // logSensorsMenuItem - // - this.logSensorsMenuItem.Name = "logSensorsMenuItem"; - this.logSensorsMenuItem.Size = new System.Drawing.Size(221, 22); - this.logSensorsMenuItem.Text = "Log Sensors"; - // - // forceDriveWakeupItem - // - this.forceDriveWakeupItem.Name = "forceDriveWakeupItem"; - this.forceDriveWakeupItem.Size = new System.Drawing.Size(221, 22); - this.forceDriveWakeupItem.Text = "Force Drive Wakeup"; - // - // fileRotationMethod - // - this.fileRotationMethod.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.perSessionFileRotationMenuItem, - this.dailyFileRotationMenuItem}); - this.fileRotationMethod.Name = "fileRotationMethod"; - this.fileRotationMethod.Size = new System.Drawing.Size(246, 24); - this.fileRotationMethod.Text = "File rotation method"; - this.fileRotationMethod.ToolTipText = "Determine how the log file should rotate."; - // - // perSessionFileRotationMenuItem - // - this.perSessionFileRotationMenuItem.CheckOnClick = true; - this.perSessionFileRotationMenuItem.Name = "perSessionFileRotationMenuItem"; - this.perSessionFileRotationMenuItem.Size = new System.Drawing.Size(198, 24); - this.perSessionFileRotationMenuItem.Text = "Per session"; - this.perSessionFileRotationMenuItem.ToolTipText = "Create a new log file for each logging session"; - this.perSessionFileRotationMenuItem.Click += new System.EventHandler(this.perSessionFileRotationMenuItem_Click); - // - // dailyFileRotationMenuItem - // - this.dailyFileRotationMenuItem.CheckOnClick = true; - this.dailyFileRotationMenuItem.Name = "dailyFileRotationMenuItem"; - this.dailyFileRotationMenuItem.Size = new System.Drawing.Size(198, 24); - this.dailyFileRotationMenuItem.Text = "Daily"; - this.dailyFileRotationMenuItem.ToolTipText = "Create a new log file every day.\n If a file already exists for the current day, new data will be appended at the end."; - this.dailyFileRotationMenuItem.Click += new System.EventHandler(this.dailyFileRotationMenuItem_Click); - // - // loggingIntervalMenuItem - // - this.loggingIntervalMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.log1sMenuItem, - this.log2sMenuItem, - this.log5sMenuItem, - this.log10sMenuItem, - this.log30sMenuItem, - this.log1minMenuItem, - this.log2minMenuItem, - this.log5minMenuItem, - this.log10minMenuItem, - this.log30minMenuItem, - this.log1hMenuItem, - this.log2hMenuItem, - this.log6hMenuItem}); - this.loggingIntervalMenuItem.Name = "loggingIntervalMenuItem"; - this.loggingIntervalMenuItem.Size = new System.Drawing.Size(221, 22); - this.loggingIntervalMenuItem.Text = "Logging Interval"; - // - // log1sMenuItem - // - this.log1sMenuItem.CheckOnClick = true; - this.log1sMenuItem.Name = "log1sMenuItem"; - this.log1sMenuItem.Size = new System.Drawing.Size(107, 22); - this.log1sMenuItem.Text = "1s"; - // - // log2sMenuItem - // - this.log2sMenuItem.CheckOnClick = true; - this.log2sMenuItem.Name = "log2sMenuItem"; - this.log2sMenuItem.Size = new System.Drawing.Size(107, 22); - this.log2sMenuItem.Text = "2s"; - // - // log5sMenuItem - // - this.log5sMenuItem.CheckOnClick = true; - this.log5sMenuItem.Name = "log5sMenuItem"; - this.log5sMenuItem.Size = new System.Drawing.Size(107, 22); - this.log5sMenuItem.Text = "5s"; - // - // log10sMenuItem - // - this.log10sMenuItem.CheckOnClick = true; - this.log10sMenuItem.Name = "log10sMenuItem"; - this.log10sMenuItem.Size = new System.Drawing.Size(107, 22); - this.log10sMenuItem.Text = "10s"; - // - // log30sMenuItem - // - this.log30sMenuItem.CheckOnClick = true; - this.log30sMenuItem.Name = "log30sMenuItem"; - this.log30sMenuItem.Size = new System.Drawing.Size(107, 22); - this.log30sMenuItem.Text = "30s"; - // - // log1minMenuItem - // - this.log1minMenuItem.CheckOnClick = true; - this.log1minMenuItem.Name = "log1minMenuItem"; - this.log1minMenuItem.Size = new System.Drawing.Size(107, 22); - this.log1minMenuItem.Text = "1min"; - // - // log2minMenuItem - // - this.log2minMenuItem.CheckOnClick = true; - this.log2minMenuItem.Name = "log2minMenuItem"; - this.log2minMenuItem.Size = new System.Drawing.Size(107, 22); - this.log2minMenuItem.Text = "2min"; - // - // log5minMenuItem - // - this.log5minMenuItem.CheckOnClick = true; - this.log5minMenuItem.Name = "log5minMenuItem"; - this.log5minMenuItem.Size = new System.Drawing.Size(107, 22); - this.log5minMenuItem.Text = "5min"; - // - // log10minMenuItem - // - this.log10minMenuItem.CheckOnClick = true; - this.log10minMenuItem.Name = "log10minMenuItem"; - this.log10minMenuItem.Size = new System.Drawing.Size(107, 22); - this.log10minMenuItem.Text = "10min"; - // - // log30minMenuItem - // - this.log30minMenuItem.CheckOnClick = true; - this.log30minMenuItem.Name = "log30minMenuItem"; - this.log30minMenuItem.Size = new System.Drawing.Size(107, 22); - this.log30minMenuItem.Text = "30min"; - // - // log1hMenuItem - // - this.log1hMenuItem.CheckOnClick = true; - this.log1hMenuItem.Name = "log1hMenuItem"; - this.log1hMenuItem.Size = new System.Drawing.Size(107, 22); - this.log1hMenuItem.Text = "1h"; - // - // log2hMenuItem - // - this.log2hMenuItem.CheckOnClick = true; - this.log2hMenuItem.Name = "log2hMenuItem"; - this.log2hMenuItem.Size = new System.Drawing.Size(107, 22); - this.log2hMenuItem.Text = "2h"; - // - // log6hMenuItem - // - this.log6hMenuItem.CheckOnClick = true; - this.log6hMenuItem.Name = "log6hMenuItem"; - this.log6hMenuItem.Size = new System.Drawing.Size(107, 22); - this.log6hMenuItem.Text = "6h"; - // - // updateIntervalMenuItem - // - this.updateIntervalMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.updateInterval250msMenuItem, - this.updateInterval500msMenuItem, - this.updateInterval1sMenuItem, - this.updateInterval2sMenuItem, - this.updateInterval5sMenuItem, - this.updateInterval10sMenuItem, - this.throttleAtaUpdateMenuItem}); - this.updateIntervalMenuItem.Name = "updateIntervalMenuItem"; - this.updateIntervalMenuItem.Size = new System.Drawing.Size(221, 22); - this.updateIntervalMenuItem.Text = "Update Interval"; - // - // updateInterval250msMenuItem - // - this.updateInterval250msMenuItem.CheckOnClick = true; - this.updateInterval250msMenuItem.Name = "updateInterval250msMenuItem"; - this.updateInterval250msMenuItem.Size = new System.Drawing.Size(107, 22); - this.updateInterval250msMenuItem.Text = "250ms"; - // - // updateInterval500msMenuItem - // - this.updateInterval500msMenuItem.CheckOnClick = true; - this.updateInterval500msMenuItem.Name = "updateInterval500msMenuItem"; - this.updateInterval500msMenuItem.Size = new System.Drawing.Size(107, 22); - this.updateInterval500msMenuItem.Text = "500ms"; - // - // updateInterval1sMenuItem - // - this.updateInterval1sMenuItem.CheckOnClick = true; - this.updateInterval1sMenuItem.Name = "updateInterval1sMenuItem"; - this.updateInterval1sMenuItem.Size = new System.Drawing.Size(107, 22); - this.updateInterval1sMenuItem.Text = "1s"; - // - // updateInterval2sMenuItem - // - this.updateInterval2sMenuItem.CheckOnClick = true; - this.updateInterval2sMenuItem.Name = "updateInterval2sMenuItem"; - this.updateInterval2sMenuItem.Size = new System.Drawing.Size(107, 22); - this.updateInterval2sMenuItem.Text = "2s"; - // - // updateInterval5sMenuItem - // - this.updateInterval5sMenuItem.CheckOnClick = true; - this.updateInterval5sMenuItem.Name = "updateInterval5sMenuItem"; - this.updateInterval5sMenuItem.Size = new System.Drawing.Size(107, 22); - this.updateInterval5sMenuItem.Text = "5s"; - // - // updateInterval10sMenuItem - // - this.updateInterval10sMenuItem.CheckOnClick = true; - this.updateInterval10sMenuItem.Name = "updateInterval10sMenuItem"; - this.updateInterval10sMenuItem.Size = new System.Drawing.Size(107, 22); - this.updateInterval10sMenuItem.Text = "10s"; - // - // throttleATAUpdateMenuItem - // - this.throttleAtaUpdateMenuItem.CheckOnClick = true; - this.throttleAtaUpdateMenuItem.Name = "throttleATAUpdateMenuItem"; - this.throttleAtaUpdateMenuItem.Size = new System.Drawing.Size(107, 22); - this.throttleAtaUpdateMenuItem.Text = "Throttle ATA Storage"; - // - // sensorValuesTimeWindowMenuItem - // - this.sensorValuesTimeWindowMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.timeWindow30sMenuItem, - this.timeWindow1minMenuItem, - this.timeWindow2minMenuItem, - this.timeWindow5minMenuItem, - this.timeWindow10minMenuItem, - this.timeWindow30minMenuItem, - this.timeWindow1hMenuItem, - this.timeWindow2hMenuItem, - this.timeWindow6hMenuItem, - this.timeWindow12hMenuItem, - this.timeWindow24hMenuItem}); - this.sensorValuesTimeWindowMenuItem.Name = "sensorValuesTimeWindowMenuItem"; - this.sensorValuesTimeWindowMenuItem.Size = new System.Drawing.Size(221, 22); - this.sensorValuesTimeWindowMenuItem.Text = "Sensor Values Time Window"; - // - // timeWindow30sMenuItem - // - this.timeWindow30sMenuItem.CheckOnClick = true; - this.timeWindow30sMenuItem.Name = "timeWindow30sMenuItem"; - this.timeWindow30sMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow30sMenuItem.Text = "30s"; - // - // timeWindow1minMenuItem - // - this.timeWindow1minMenuItem.CheckOnClick = true; - this.timeWindow1minMenuItem.Name = "timeWindow1minMenuItem"; - this.timeWindow1minMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow1minMenuItem.Text = "1min"; - // - // timeWindow2minMenuItem - // - this.timeWindow2minMenuItem.CheckOnClick = true; - this.timeWindow2minMenuItem.Name = "timeWindow2minMenuItem"; - this.timeWindow2minMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow2minMenuItem.Text = "2min"; - // - // timeWindow5minMenuItem - // - this.timeWindow5minMenuItem.CheckOnClick = true; - this.timeWindow5minMenuItem.Name = "timeWindow5minMenuItem"; - this.timeWindow5minMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow5minMenuItem.Text = "5min"; - // - // timeWindow10minMenuItem - // - this.timeWindow10minMenuItem.CheckOnClick = true; - this.timeWindow10minMenuItem.Name = "timeWindow10minMenuItem"; - this.timeWindow10minMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow10minMenuItem.Text = "10min"; - // - // timeWindow30minMenuItem - // - this.timeWindow30minMenuItem.CheckOnClick = true; - this.timeWindow30minMenuItem.Name = "timeWindow30minMenuItem"; - this.timeWindow30minMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow30minMenuItem.Text = "30min"; - // - // timeWindow1hMenuItem - // - this.timeWindow1hMenuItem.CheckOnClick = true; - this.timeWindow1hMenuItem.Name = "timeWindow1hMenuItem"; - this.timeWindow1hMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow1hMenuItem.Text = "1h"; - // - // timeWindow2hMenuItem - // - this.timeWindow2hMenuItem.CheckOnClick = true; - this.timeWindow2hMenuItem.Name = "timeWindow2hMenuItem"; - this.timeWindow2hMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow2hMenuItem.Text = "2h"; - // - // timeWindow6hMenuItem - // - this.timeWindow6hMenuItem.CheckOnClick = true; - this.timeWindow6hMenuItem.Name = "timeWindow6hMenuItem"; - this.timeWindow6hMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow6hMenuItem.Text = "6h"; - // - // timeWindow12hMenuItem - // - this.timeWindow12hMenuItem.CheckOnClick = true; - this.timeWindow12hMenuItem.Name = "timeWindow12hMenuItem"; - this.timeWindow12hMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow12hMenuItem.Text = "12h"; - // - // timeWindow24hMenuItem - // - this.timeWindow24hMenuItem.CheckOnClick = true; - this.timeWindow24hMenuItem.Name = "timeWindow24hMenuItem"; - this.timeWindow24hMenuItem.Size = new System.Drawing.Size(107, 22); - this.timeWindow24hMenuItem.Text = "24h"; - // - // webMenuItemSeparator - // - this.webMenuItemSeparator.Name = "webMenuItemSeparator"; - this.webMenuItemSeparator.Size = new System.Drawing.Size(218, 6); - // - // webMenuItem - // - this.webMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.runWebServerMenuItem, - this.serverInterfacePortMenuItem, - this.authWebServerMenuItem}); - this.webMenuItem.Name = "webMenuItem"; - this.webMenuItem.Size = new System.Drawing.Size(221, 22); - this.webMenuItem.Text = "Remote Web Server"; - // - // runWebServerMenuItem - // - this.runWebServerMenuItem.Name = "runWebServerMenuItem"; - this.runWebServerMenuItem.Size = new System.Drawing.Size(153, 22); - this.runWebServerMenuItem.Text = "Run"; - // - // serverPortMenuItem - // - this.serverInterfacePortMenuItem.Name = "serverInterfacePortMenuItem"; - this.serverInterfacePortMenuItem.Size = new System.Drawing.Size(153, 22); - this.serverInterfacePortMenuItem.Text = "Interface / Port"; - this.serverInterfacePortMenuItem.Click += new System.EventHandler(this.ServerInterfacePortMenuItem_Click); - // - // authWebServerMenuItem - // - this.authWebServerMenuItem.Name = "authWebServerMenuItem"; - this.authWebServerMenuItem.Size = new System.Drawing.Size(153, 22); - this.authWebServerMenuItem.Text = "Authentication"; - this.authWebServerMenuItem.Click += new System.EventHandler(this.AuthWebServerMenuItem_Click); - // - // helpMenuItem - // - this.helpMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.aboutMenuItem}); - this.helpMenuItem.Name = "helpMenuItem"; - this.helpMenuItem.Size = new System.Drawing.Size(44, 20); - this.helpMenuItem.Text = "Help"; - // - // aboutMenuItem - // - this.aboutMenuItem.Name = "aboutMenuItem"; - this.aboutMenuItem.Size = new System.Drawing.Size(107, 22); - this.aboutMenuItem.Text = "About"; - this.aboutMenuItem.Click += new System.EventHandler(this.AboutMenuItem_Click); - // - // treeContextMenu - // - this.treeContextMenu.Name = "treeContextMenu"; - this.treeContextMenu.Size = new System.Drawing.Size(61, 4); - // - // saveFileDialog - // - this.saveFileDialog.DefaultExt = "txt"; - this.saveFileDialog.FileName = "LibreHardwareMonitor.Report.txt"; - this.saveFileDialog.Filter = "Text Documents|*.txt|All Files|*.*"; - this.saveFileDialog.RestoreDirectory = true; - this.saveFileDialog.Title = "Save Report As"; - // - // timer - // - this.timer.Interval = 1000; - this.timer.Tick += new System.EventHandler(this.Timer_Tick); - // - // splitContainer - // - 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.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.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); - this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TreeView_MouseDown); - this.treeView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TreeView_MouseMove); - this.treeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TreeView_MouseUp); - this.treeView.SizeChanged += new System.EventHandler(this.TreeView_SizeChanged); - this.treeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TreeView_KeyDown); - // - // batteryMenuItem - // - this.batteryMenuItem.Name = "batteryMenuItem"; - this.batteryMenuItem.Size = new System.Drawing.Size(180, 22); - this.batteryMenuItem.Text = "Batteries"; - // - // MainForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(418, 533); - this.Controls.Add(this.splitContainer); - this.Controls.Add(this.mainMenu); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MainMenuStrip = this.mainMenu; - this.Name = "MainForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; - this.Text = "Libre Hardware Monitor"; - this.Load += new System.EventHandler(this.MainForm_Load); - this.ResizeEnd += new System.EventHandler(this.MainForm_MoveOrResize); - this.Move += new System.EventHandler(this.MainForm_MoveOrResize); - this.mainMenu.ResumeLayout(false); - this.mainMenu.PerformLayout(); - this.splitContainer.Panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); - this.splitContainer.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private Aga.Controls.Tree.TreeViewAdv treeView; - private System.Windows.Forms.MenuStrip mainMenu; - private System.Windows.Forms.ToolStripMenuItem fileMenuItem; - private System.Windows.Forms.ToolStripMenuItem exitMenuItem; - private Aga.Controls.Tree.TreeColumn sensor; - private Aga.Controls.Tree.TreeColumn value; - private Aga.Controls.Tree.TreeColumn min; - private Aga.Controls.Tree.TreeColumn max; - private Aga.Controls.Tree.NodeControls.NodeIcon nodeImage; - private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxText; - private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxValue; - private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxMin; - private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxMax; - private SplitContainerAdv splitContainer; - private System.Windows.Forms.ToolStripMenuItem viewMenuItem; - private System.Windows.Forms.ToolStripMenuItem plotMenuItem; - private Aga.Controls.Tree.NodeControls.NodeCheckBox nodeCheckBox; - private System.Windows.Forms.ToolStripMenuItem helpMenuItem; - private System.Windows.Forms.ToolStripMenuItem aboutMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveReportMenuItem; - private System.Windows.Forms.ToolStripMenuItem optionsMenuItem; - private System.Windows.Forms.ToolStripMenuItem hddMenuItem; - private System.Windows.Forms.ToolStripMenuItem minTrayMenuItem; - private System.Windows.Forms.ToolStripSeparator separatorMenuItem; - private System.Windows.Forms.ContextMenuStrip treeContextMenu; - private System.Windows.Forms.ToolStripMenuItem startMinMenuItem; - private System.Windows.Forms.ToolStripMenuItem startupMenuItem; - private System.Windows.Forms.SaveFileDialog saveFileDialog; - private System.Windows.Forms.Timer timer; - private System.Windows.Forms.ToolStripMenuItem hiddenMenuItem; - private System.Windows.Forms.ToolStripSeparator MenuItem1; - private System.Windows.Forms.ToolStripMenuItem columnsMenuItem; - private System.Windows.Forms.ToolStripMenuItem valueMenuItem; - private System.Windows.Forms.ToolStripMenuItem minMenuItem; - private System.Windows.Forms.ToolStripMenuItem maxMenuItem; - private System.Windows.Forms.ToolStripMenuItem temperatureUnitsMenuItem; - private System.Windows.Forms.ToolStripSeparator webMenuItemSeparator; - private ToolStripRadioButtonMenuItem celsiusMenuItem; - private ToolStripRadioButtonMenuItem fahrenheitMenuItem; - private System.Windows.Forms.ToolStripSeparator MenuItem2; - private System.Windows.Forms.ToolStripMenuItem resetMinMaxMenuItem; - private System.Windows.Forms.ToolStripMenuItem expandAllNodesMenuItem; - private System.Windows.Forms.ToolStripMenuItem collpaseAllNodesMenuItem; - private System.Windows.Forms.ToolStripMenuItem resetPlotMenuItem; - private System.Windows.Forms.ToolStripSeparator MenuItem3; - private System.Windows.Forms.ToolStripMenuItem gadgetMenuItem; - private System.Windows.Forms.ToolStripMenuItem minCloseMenuItem; - private System.Windows.Forms.ToolStripMenuItem resetMenuItem; - private System.Windows.Forms.ToolStripSeparator menuItem6; - private System.Windows.Forms.ToolStripMenuItem plotLocationMenuItem; - private ToolStripRadioButtonMenuItem plotWindowMenuItem; - private ToolStripRadioButtonMenuItem plotBottomMenuItem; - private ToolStripRadioButtonMenuItem plotRightMenuItem; - private System.Windows.Forms.ToolStripMenuItem splitPlotPanelScalingMenuItem; - private ToolStripRadioButtonMenuItem splitPanelPercentageScalingMenuItem; - private ToolStripRadioButtonMenuItem splitPanelFixedPlotScalingMenuItem; - private ToolStripRadioButtonMenuItem splitPanelFixedSensorScalingMenuItem; - private System.Windows.Forms.ToolStripMenuItem webMenuItem; - private System.Windows.Forms.ToolStripMenuItem runWebServerMenuItem; - private System.Windows.Forms.ToolStripMenuItem serverInterfacePortMenuItem; - private System.Windows.Forms.ToolStripMenuItem menuItemFileHardware; - private System.Windows.Forms.ToolStripMenuItem mainboardMenuItem; - private System.Windows.Forms.ToolStripMenuItem cpuMenuItem; - private System.Windows.Forms.ToolStripMenuItem gpuMenuItem; - private System.Windows.Forms.ToolStripMenuItem powerMonitorMenuItem; - private System.Windows.Forms.ToolStripMenuItem fanControllerMenuItem; - private System.Windows.Forms.ToolStripMenuItem ramMenuItem; - private System.Windows.Forms.ToolStripMenuItem logSensorsMenuItem; - private System.Windows.Forms.ToolStripMenuItem forceDriveWakeupItem; - private System.Windows.Forms.ToolStripSeparator logSeparatorMenuItem; - private System.Windows.Forms.ToolStripMenuItem loggingIntervalMenuItem; - private ToolStripRadioButtonMenuItem log1sMenuItem; - private ToolStripRadioButtonMenuItem log2sMenuItem; - private ToolStripRadioButtonMenuItem log5sMenuItem; - private ToolStripRadioButtonMenuItem log10sMenuItem; - private ToolStripRadioButtonMenuItem log30sMenuItem; - private ToolStripRadioButtonMenuItem log1minMenuItem; - private ToolStripRadioButtonMenuItem log2minMenuItem; - private ToolStripRadioButtonMenuItem log5minMenuItem; - private ToolStripRadioButtonMenuItem log10minMenuItem; - private ToolStripRadioButtonMenuItem log30minMenuItem; - private ToolStripRadioButtonMenuItem log1hMenuItem; - private ToolStripRadioButtonMenuItem log2hMenuItem; - private ToolStripRadioButtonMenuItem log6hMenuItem; - private System.Windows.Forms.ToolStripMenuItem updateIntervalMenuItem; - private ToolStripRadioButtonMenuItem updateInterval250msMenuItem; - private ToolStripRadioButtonMenuItem updateInterval500msMenuItem; - private ToolStripRadioButtonMenuItem updateInterval1sMenuItem; - private ToolStripRadioButtonMenuItem updateInterval2sMenuItem; - private ToolStripRadioButtonMenuItem updateInterval5sMenuItem; - private ToolStripRadioButtonMenuItem updateInterval10sMenuItem; - private System.Windows.Forms.ToolStripMenuItem throttleAtaUpdateMenuItem; - private System.Windows.Forms.ToolStripMenuItem nicMenuItem; - private System.Windows.Forms.ToolStripMenuItem sensorValuesTimeWindowMenuItem; - private ToolStripRadioButtonMenuItem timeWindow30sMenuItem; - private ToolStripRadioButtonMenuItem timeWindow1minMenuItem; - private ToolStripRadioButtonMenuItem timeWindow2minMenuItem; - private ToolStripRadioButtonMenuItem timeWindow5minMenuItem; - private ToolStripRadioButtonMenuItem timeWindow10minMenuItem; - private ToolStripRadioButtonMenuItem timeWindow30minMenuItem; - private ToolStripRadioButtonMenuItem timeWindow1hMenuItem; - private ToolStripRadioButtonMenuItem timeWindow2hMenuItem; - private ToolStripRadioButtonMenuItem timeWindow6hMenuItem; - private ToolStripRadioButtonMenuItem timeWindow12hMenuItem; - private ToolStripRadioButtonMenuItem timeWindow24hMenuItem; - private System.Windows.Forms.ToolStripMenuItem authWebServerMenuItem; - private System.Windows.Forms.ToolStripMenuItem psuMenuItem; - private System.Windows.Forms.ToolStripMenuItem batteryMenuItem; - private System.ComponentModel.BackgroundWorker backgroundUpdater; - private System.Windows.Forms.ToolStripMenuItem fileRotationMethod; - private ToolStripRadioButtonMenuItem perSessionFileRotationMenuItem; - private ToolStripRadioButtonMenuItem dailyFileRotationMenuItem; - private System.Windows.Forms.ToolStripMenuItem themeMenuItem; - private System.Windows.Forms.ToolStripMenuItem strokeThicknessMenuItem; - private ToolStripRadioButtonMenuItem strokeThickness4ptMenuItem; - private ToolStripRadioButtonMenuItem strokeThickness1ptMenuItem; - private ToolStripRadioButtonMenuItem strokeThickness2ptMenuItem; - private ToolStripRadioButtonMenuItem strokeThickness3ptMenuItem; - } -} - diff --git a/LibreHardwareMonitor.Windows.Forms/UI/MainForm.cs b/LibreHardwareMonitor.Windows.Forms/UI/MainForm.cs deleted file mode 100644 index a8dcd0e..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/MainForm.cs +++ /dev/null @@ -1,1471 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using Aga.Controls.Tree; -using Aga.Controls.Tree.NodeControls; -using LibreHardwareMonitor.Hardware; -using LibreHardwareMonitor.Hardware.Storage; -using LibreHardwareMonitor.Windows.Forms.UI.Themes; -using LibreHardwareMonitor.Windows.Forms.Utilities; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public sealed partial class MainForm : Form -{ - private ToolStripMenuItem _autoThemeMenuItem; - private readonly UserOption _autoStart; - private readonly Computer _computer; - private readonly SensorGadget _gadget; - private readonly Logger _logger; - private readonly UserRadioGroup _loggingInterval; - private readonly UserRadioGroup _updateInterval; - private readonly UserOption _throttleAtaUpdate; - private readonly UserOption _logSensors; - private readonly UserOption _forceDriveWakeup; - private readonly UserOption _minimizeOnClose; - private readonly UserOption _minimizeToTray; - private readonly PlotPanel _plotPanel; - private readonly UserOption _readBatterySensors; - private readonly UserOption _readCpuSensors; - private readonly UserOption _readFanControllersSensors; - private readonly UserOption _readGpuSensors; - private readonly UserOption _readPowerMonitorSensors; - private readonly UserOption _readHddSensors; - private readonly UserOption _readMainboardSensors; - private readonly UserOption _readNicSensors; - private readonly UserOption _readPsuSensors; - private readonly UserOption _readRamSensors; - private readonly Node _root; - private readonly UserOption _runWebServer; - private readonly UserRadioGroup _sensorValuesTimeWindow; - private readonly PersistentSettings _settings; - private readonly UserOption _showGadget; - private readonly StartupManager _startupManager = new(); - private readonly SystemTray _systemTray; - private readonly UnitManager _unitManager; - private readonly UpdateVisitor _updateVisitor = new(); - private readonly System.Threading.SynchronizationContext _uiSyncContext; - - private int _delayCount; - private Form _plotForm; - private UserRadioGroup _plotLocation; - private UserRadioGroup _splitPanelScalingSetting; - private bool _selectionDragging; - private IDictionary _sensorPlotColors = new Dictionary(); - private UserOption _showPlot; - private UserRadioGroup _strokeThickness; - private double _plotStrokeThickness = 2; - - public MainForm() - { - InitializeComponent(); - - _settings = new PersistentSettings(); - _settings.Load(Path.ChangeExtension(Application.ExecutablePath, ".config")); - - _unitManager = new UnitManager(_settings); - - // make sure the buffers used for double buffering are not disposed - // after each draw call - BufferedGraphicsManager.Current.MaximumBuffer = Screen.PrimaryScreen.Bounds.Size; - - // set the DockStyle here, to avoid conflicts with the MainMenu - splitContainer.Dock = DockStyle.Fill; - - Font = SystemFonts.MessageBoxFont; - treeView.Font = SystemFonts.MessageBoxFont; - - // Set the bounds immediately, so that our child components can be - // properly placed. - Bounds = new Rectangle - { - X = _settings.GetValue("mainForm.Location.X", Location.X), - Y = _settings.GetValue("mainForm.Location.Y", Location.Y), - Width = _settings.GetValue("mainForm.Width", 470), - Height = _settings.GetValue("mainForm.Height", 640) - }; - - Theme setTheme = Theme.All.FirstOrDefault(theme => _settings.GetValue("theme", "auto") == theme.Id); - if (setTheme != null) - { - Theme.Current = setTheme; - } - else - { - Theme.SetAutoTheme(); - } - - _plotPanel = new PlotPanel(_settings, _unitManager) { Font = SystemFonts.MessageBoxFont, Dock = DockStyle.Fill }; - - nodeCheckBox.IsVisibleValueNeeded += NodeCheckBox_IsVisibleValueNeeded; - nodeTextBoxText.DrawText += NodeTextBoxText_DrawText; - nodeTextBoxValue.DrawText += NodeTextBoxText_DrawText; - nodeTextBoxMin.DrawText += NodeTextBoxText_DrawText; - nodeTextBoxMax.DrawText += NodeTextBoxText_DrawText; - nodeTextBoxText.EditorShowing += NodeTextBoxText_EditorShowing; - - for (int i = 1; i < treeView.Columns.Count; i++) - { - TreeColumn column = treeView.Columns[i]; - column.Width = Math.Max(20, Math.Min(400, _settings.GetValue("treeView.Columns." + column.Header + ".Width", column.Width))); - } - - TreeModel treeModel = new(); - _root = new Node(Environment.MachineName) { Image = EmbeddedResources.GetImage("computer.png") }; - - treeModel.Nodes.Add(_root); - treeView.Model = treeModel; - - _computer = new Computer(_settings); - - _systemTray = new SystemTray(_computer, _settings, _unitManager); - _systemTray.HideShowCommand += HideShowClick; - _systemTray.ExitCommand += ExitClick; - - if (Software.OperatingSystem.IsUnix) - { - // Unix - treeView.RowHeight = Math.Max(treeView.RowHeight, 18); - splitContainer.BorderStyle = BorderStyle.None; - splitContainer.SplitterWidth = 4; - treeView.BorderStyle = BorderStyle.Fixed3D; - _plotPanel.BorderStyle = BorderStyle.Fixed3D; - gadgetMenuItem.Visible = false; - minCloseMenuItem.Visible = false; - minTrayMenuItem.Visible = false; - startMinMenuItem.Visible = false; - } - else - { - // Windows - treeView.RowHeight = Math.Max(treeView.Font.Height + 1, 18); - _gadget = new SensorGadget(_computer, _settings, _unitManager); - _gadget.HideShowCommand += HideShowClick; - } - - treeView.ShowNodeToolTips = true; - NodeToolTipProvider tooltipProvider = new(); - nodeTextBoxText.ToolTipProvider = tooltipProvider; - nodeTextBoxValue.ToolTipProvider = tooltipProvider; - _logger = new Logger(_computer); - var saved = _settings.GetValue("logger.fileRotation", 0); // 0 = PerSession, 1 = Daily. - _logger.FileRotationMethod = (LoggerFileRotation)Math.Max(0, Math.Min(saved, 1)); - perSessionFileRotationMenuItem.Checked = _logger.FileRotationMethod == LoggerFileRotation.PerSession; - dailyFileRotationMenuItem.Checked = _logger.FileRotationMethod == LoggerFileRotation.Daily; - - // Captured on the UI thread; HardwareAdded/HardwareRemoved can now fire on a background discovery thread - // (when a defer env var is set), so they re-dispatch here before touching the tree. - _uiSyncContext = System.Threading.SynchronizationContext.Current; - _computer.HardwareAdded += HardwareAdded; - _computer.HardwareRemoved += HardwareRemoved; - - if (PawnIo.PawnIo.IsInstalled) - { - if (PawnIo.PawnIo.Version < new Version(2, 0, 0, 0)) - { - DialogResult result = MessageBox.Show("PawnIO is outdated, do you want to update it?", nameof(LibreHardwareMonitor), MessageBoxButtons.OKCancel); - if (result == DialogResult.OK) - InstallPawnIO(); - } - } - else - { - DialogResult result = MessageBox.Show("PawnIO is not installed, do you want to install it?", nameof(LibreHardwareMonitor), MessageBoxButtons.OKCancel); - if (result == DialogResult.OK) - InstallPawnIO(); - } - - _computer.Open(); - - static void InstallPawnIO() - { - string path = ExtractPawnIO(); - if (!string.IsNullOrEmpty(path)) - { - var process = Process.Start(new ProcessStartInfo(path, "-install")); - process?.WaitForExit(); - - File.Delete(path); - } - } - - static string ExtractPawnIO() - { - string destination = Path.Combine(Directory.GetCurrentDirectory(), "PawnIO_setup.exe"); - - try - { - - using Stream resourceStream = typeof(MainForm).Assembly.GetManifestResourceStream("LibreHardwareMonitor.Resources.PawnIO_setup.exe"); - using FileStream fileStream = new(destination, FileMode.Create, FileAccess.Write); - resourceStream.CopyTo(fileStream); - - return destination; - } - catch - { - return null; - } - } - - backgroundUpdater.DoWork += BackgroundUpdater_DoWork; - timer.Enabled = true; - - UserOption showHiddenSensors = new("hiddenMenuItem", false, hiddenMenuItem, _settings); - showHiddenSensors.Changed += delegate { treeModel.ForceVisible = showHiddenSensors.Value; }; - - UserOption showValue = new("valueMenuItem", true, valueMenuItem, _settings); - showValue.Changed += delegate { treeView.Columns[1].IsVisible = showValue.Value; }; - - UserOption showMin = new("minMenuItem", false, minMenuItem, _settings); - showMin.Changed += delegate { treeView.Columns[2].IsVisible = showMin.Value; }; - - UserOption showMax = new("maxMenuItem", true, maxMenuItem, _settings); - showMax.Changed += delegate { treeView.Columns[3].IsVisible = showMax.Value; }; - - _ = new UserOption("startMinMenuItem", false, startMinMenuItem, _settings); - _minimizeToTray = new UserOption("minTrayMenuItem", true, minTrayMenuItem, _settings); - _minimizeToTray.Changed += delegate { _systemTray.IsMainIconEnabled = _minimizeToTray.Value; }; - - _minimizeOnClose = new UserOption("minCloseMenuItem", false, minCloseMenuItem, _settings); - - _autoStart = new UserOption(null, _startupManager.Startup, startupMenuItem, _settings); - _autoStart.Changed += delegate - { - try - { - _startupManager.Startup = _autoStart.Value; - } - catch (InvalidOperationException) - { - MessageBox.Show("Updating the auto-startup option failed.", - "Error", - MessageBoxButtons.OK, - MessageBoxIcon.Error); - - _autoStart.Value = _startupManager.Startup; - } - }; - - _readMainboardSensors = new UserOption("mainboardMenuItem", true, mainboardMenuItem, _settings); - _readMainboardSensors.Changed += delegate { _computer.IsMotherboardEnabled = _readMainboardSensors.Value; }; - - _readCpuSensors = new UserOption("cpuMenuItem", true, cpuMenuItem, _settings); - _readCpuSensors.Changed += delegate { _computer.IsCpuEnabled = _readCpuSensors.Value; }; - - _readRamSensors = new UserOption("ramMenuItem", true, ramMenuItem, _settings); - _readRamSensors.Changed += delegate { _computer.IsMemoryEnabled = _readRamSensors.Value; }; - - _readGpuSensors = new UserOption("gpuMenuItem", true, gpuMenuItem, _settings); - _readGpuSensors.Changed += delegate { _computer.IsGpuEnabled = _readGpuSensors.Value; }; - - _readPowerMonitorSensors = new UserOption("powerMonitorMenuItem", true, powerMonitorMenuItem, _settings); - _readPowerMonitorSensors.Changed += delegate { _computer.IsPowerMonitorEnabled = _readPowerMonitorSensors.Value; }; - - _readFanControllersSensors = new UserOption("fanControllerMenuItem", true, fanControllerMenuItem, _settings); - _readFanControllersSensors.Changed += delegate { _computer.IsControllerEnabled = _readFanControllersSensors.Value; }; - - _readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem, _settings); - _readHddSensors.Changed += delegate { _computer.IsStorageEnabled = _readHddSensors.Value; }; - - _readNicSensors = new UserOption("nicMenuItem", true, nicMenuItem, _settings); - _readNicSensors.Changed += delegate { _computer.IsNetworkEnabled = _readNicSensors.Value; }; - - _readPsuSensors = new UserOption("psuMenuItem", true, psuMenuItem, _settings); - _readPsuSensors.Changed += delegate { _computer.IsPsuEnabled = _readPsuSensors.Value; }; - - _readBatterySensors = new UserOption("batteryMenuItem", true, batteryMenuItem, _settings); - _readBatterySensors.Changed += delegate { _computer.IsBatteryEnabled = _readBatterySensors.Value; }; - - _showGadget = new UserOption("gadgetMenuItem", false, gadgetMenuItem, _settings); - - _forceDriveWakeup = new UserOption("forceDriveWakeupItem", false, forceDriveWakeupItem, _settings); - _forceDriveWakeup.Changed += delegate - { - _computer.Hardware - .OfType() - .ToList() - .ForEach(sd => - { - sd.ForceWakeup = _forceDriveWakeup.Value; - }); - }; - - // Prevent Menu From Closing When UnClicking Hardware Items - menuItemFileHardware.DropDown.Closing += StopFileHardwareMenuFromClosing; - - _showGadget.Changed += delegate - { - if (_gadget != null) - _gadget.Visible = _showGadget.Value; - }; - - celsiusMenuItem.Checked = _unitManager.TemperatureUnit == TemperatureUnit.Celsius; - fahrenheitMenuItem.Checked = !celsiusMenuItem.Checked; - - Server = new HttpServer(_root, - _computer, - _settings.GetValue("listenerIp", "?"), - _settings.GetValue("listenerPort", 8085), - _settings.GetValue("authenticationEnabled", false), - _settings.GetValue("authenticationUserName", ""), - _settings.GetValue("authenticationPassword", "")); - - if (Server.PlatformNotSupported) - { - webMenuItemSeparator.Visible = false; - webMenuItem.Visible = false; - } - - _runWebServer = new UserOption("runWebServerMenuItem", false, runWebServerMenuItem, _settings); - _runWebServer.Changed += delegate - { - if (_runWebServer.Value) - Server.StartHttpListener(); - else - Server.StopHttpListener(); - }; - - authWebServerMenuItem.Checked = _settings.GetValue("authenticationEnabled", false); - - _logSensors = new UserOption("logSensorsMenuItem", false, logSensorsMenuItem, _settings); - - _loggingInterval = new UserRadioGroup("loggingInterval", - 0, - new[] - { - log1sMenuItem, - log2sMenuItem, - log5sMenuItem, - log10sMenuItem, - log30sMenuItem, - log1minMenuItem, - log2minMenuItem, - log5minMenuItem, - log10minMenuItem, - log30minMenuItem, - log1hMenuItem, - log2hMenuItem, - log6hMenuItem - }, - _settings); - - _loggingInterval.Changed += (sender, e) => - { - switch (_loggingInterval.Value) - { - case 0: - _logger.LoggingInterval = new TimeSpan(0, 0, 1); - break; - case 1: - _logger.LoggingInterval = new TimeSpan(0, 0, 2); - break; - case 2: - _logger.LoggingInterval = new TimeSpan(0, 0, 5); - break; - case 3: - _logger.LoggingInterval = new TimeSpan(0, 0, 10); - break; - case 4: - _logger.LoggingInterval = new TimeSpan(0, 0, 30); - break; - case 5: - _logger.LoggingInterval = new TimeSpan(0, 1, 0); - break; - case 6: - _logger.LoggingInterval = new TimeSpan(0, 2, 0); - break; - case 7: - _logger.LoggingInterval = new TimeSpan(0, 5, 0); - break; - case 8: - _logger.LoggingInterval = new TimeSpan(0, 10, 0); - break; - case 9: - _logger.LoggingInterval = new TimeSpan(0, 30, 0); - break; - case 10: - _logger.LoggingInterval = new TimeSpan(1, 0, 0); - break; - case 11: - _logger.LoggingInterval = new TimeSpan(2, 0, 0); - break; - case 12: - _logger.LoggingInterval = new TimeSpan(6, 0, 0); - break; - } - }; - - _updateInterval = new UserRadioGroup("updateIntervalMenuItem", - 2, - new[] - { - updateInterval250msMenuItem, - updateInterval500msMenuItem, - updateInterval1sMenuItem, - updateInterval2sMenuItem, - updateInterval5sMenuItem, - updateInterval10sMenuItem - }, - _settings); - - _updateInterval.Changed += (sender, e) => - { - switch (_updateInterval.Value) - { - case 0: - timer.Interval = 250; - break; - case 1: - timer.Interval = 500; - break; - case 2: - timer.Interval = 1000; - break; - case 3: - timer.Interval = 2000; - break; - case 4: - timer.Interval = 5000; - break; - case 5: - timer.Interval = 10000; - break; - } - }; - - _throttleAtaUpdate = new UserOption("throttleAtaUpdateMenuItem", false, throttleAtaUpdateMenuItem, _settings); - _throttleAtaUpdate.Changed += (sender, e) => - { - switch (_throttleAtaUpdate.Value) - { - case true: - StorageDevice.ThrottleInterval = TimeSpan.FromSeconds(30); - break; - - case false: - StorageDevice.ThrottleInterval = TimeSpan.Zero; - break; - } - }; - - _sensorValuesTimeWindow = new UserRadioGroup("sensorValuesTimeWindow", - 10, - new[] - { - timeWindow30sMenuItem, - timeWindow1minMenuItem, - timeWindow2minMenuItem, - timeWindow5minMenuItem, - timeWindow10minMenuItem, - timeWindow30minMenuItem, - timeWindow1hMenuItem, - timeWindow2hMenuItem, - timeWindow6hMenuItem, - timeWindow12hMenuItem, - timeWindow24hMenuItem - }, - _settings); - - perSessionFileRotationMenuItem.Checked = _logger.FileRotationMethod == LoggerFileRotation.PerSession; - dailyFileRotationMenuItem.Checked = _logger.FileRotationMethod == LoggerFileRotation.Daily; - - _sensorValuesTimeWindow.Changed += (sender, e) => - { - TimeSpan timeWindow = TimeSpan.Zero; - switch (_sensorValuesTimeWindow.Value) - { - case 0: - timeWindow = new TimeSpan(0, 0, 30); - break; - case 1: - timeWindow = new TimeSpan(0, 1, 0); - break; - case 2: - timeWindow = new TimeSpan(0, 2, 0); - break; - case 3: - timeWindow = new TimeSpan(0, 5, 0); - break; - case 4: - timeWindow = new TimeSpan(0, 10, 0); - break; - case 5: - timeWindow = new TimeSpan(0, 30, 0); - break; - case 6: - timeWindow = new TimeSpan(1, 0, 0); - break; - case 7: - timeWindow = new TimeSpan(2, 0, 0); - break; - case 8: - timeWindow = new TimeSpan(6, 0, 0); - break; - case 9: - timeWindow = new TimeSpan(12, 0, 0); - break; - case 10: - timeWindow = new TimeSpan(24, 0, 0); - break; - } - - _computer.Accept(new SensorVisitor(delegate(ISensor sensor) { sensor.ValuesTimeWindow = timeWindow; })); - }; - - InitializeTheme(); - InitializePlotForm(); - InitializeSplitter(); - - startupMenuItem.Visible = _startupManager.IsAvailable; - - if (startMinMenuItem.Checked) - { - if (!minTrayMenuItem.Checked) - { - WindowState = FormWindowState.Minimized; - Show(); - } - } - else - { - Show(); - } - - // Create a handle, otherwise calling Close() does not fire FormClosed - - // Make sure the settings are saved when the user logs off - Microsoft.Win32.SystemEvents.SessionEnded += delegate - { - _computer.Close(); - SaveConfiguration(); - if (_runWebServer.Value) - Server.Quit(); - }; - - Microsoft.Win32.SystemEvents.PowerModeChanged += PowerModeChanged; - } - - private void StopFileHardwareMenuFromClosing(object sender, ToolStripDropDownClosingEventArgs e) - { - if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) - { - e.Cancel = true; - } - } - - public bool AuthWebServerMenuItemChecked - { - get { return authWebServerMenuItem.Checked; } - set { authWebServerMenuItem.Checked = value; } - } - - public HttpServer Server { get; } - - private void BackgroundUpdater_DoWork(object sender, DoWorkEventArgs e) - { - _computer.Accept(_updateVisitor); - - if (_logSensors != null && _logSensors.Value && _delayCount >= 4) - _logger.Log(); - - if (_delayCount < 4) - _delayCount++; - - _plotPanel.InvalidatePlot(); - } - - private void PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs eventArgs) - { - if (eventArgs.Mode == Microsoft.Win32.PowerModes.Resume) - { - _computer.Reset(); - } - } - - private void InitializeTheme() - { - mainMenu.Renderer = new ThemedToolStripRenderer(); - treeContextMenu.Renderer = new ThemedToolStripRenderer(); - ThemedVScrollIndicator.AddToControl(treeView); - ThemedHScrollIndicator.AddToControl(treeView); - - string themeSetting = _settings.GetValue("theme", "auto"); - bool themeSelected = false; - - void ClearThemeMenu() - { - foreach (ToolStripItem x in themeMenuItem.DropDownItems) - { - if (x is ToolStripMenuItem tmi) - { - tmi.Checked = false; - } - } - } - - if (Theme.SupportsAutoThemeSwitching()) - { - _autoThemeMenuItem = new ToolStripMenuItem(); - _autoThemeMenuItem.Text = "Auto"; - _autoThemeMenuItem.Click += (o, e) => - { - ClearThemeMenu(); - _autoThemeMenuItem.Checked = true; - Theme.SetAutoTheme(); - _settings.SetValue("theme", "auto"); - PlotSelectionChanged(o, e); - }; - themeMenuItem.DropDownItems.Add(_autoThemeMenuItem); - } - - foreach (Theme theme in Theme.All) - { - ToolStripMenuItem item = new ToolStripMenuItem(); - item.Text = theme.DisplayName; - item.Click += (o, e) => - { - ClearThemeMenu(); - item.Checked = true; - Theme.Current = theme; - _settings.SetValue("theme", theme.Id); - PlotSelectionChanged(o, e); - }; - themeMenuItem.DropDownItems.Add(item); - - if (themeSetting == theme.Id) - { - item.PerformClick(); - themeSelected = true; - } - } - - if (!themeSelected) - { - themeMenuItem.DropDownItems[0].PerformClick(); - } - - Theme.Current.Apply(this); - } - - private void InitializeSplitter() - { - splitContainer.SplitterDistance = _settings.GetValue("splitContainer.SplitterDistance", 400); - splitContainer.SplitterMoved += delegate { _settings.SetValue("splitContainer.SplitterDistance", splitContainer.SplitterDistance); }; - } - - private void InitializePlotForm() - { - _plotForm = new Form { FormBorderStyle = FormBorderStyle.SizableToolWindow, ShowInTaskbar = false, StartPosition = FormStartPosition.Manual }; - AddOwnedForm(_plotForm); - _plotForm.Bounds = new Rectangle - { - X = _settings.GetValue("plotForm.Location.X", -100000), - Y = _settings.GetValue("plotForm.Location.Y", 100), - Width = _settings.GetValue("plotForm.Width", 600), - Height = _settings.GetValue("plotForm.Height", 400) - }; - - _showPlot = new UserOption("plotMenuItem", false, plotMenuItem, _settings); - _plotLocation = new UserRadioGroup("plotLocation", 0, new[] { plotWindowMenuItem, plotBottomMenuItem, plotRightMenuItem }, _settings); - _splitPanelScalingSetting = new UserRadioGroup("splitPanelScalingSetting", 0, new[] { splitPanelPercentageScalingMenuItem, splitPanelFixedPlotScalingMenuItem, splitPanelFixedSensorScalingMenuItem }, _settings); - - _showPlot.Changed += delegate - { - if (_plotLocation.Value == 0) - { - if (_showPlot.Value && Visible) - { - Theme.Current.Apply(_plotForm); - _plotForm.Show(); - } - else - _plotForm.Hide(); - } - else - { - splitContainer.Panel2Collapsed = !_showPlot.Value; - } - - treeView.Invalidate(); - }; - - _strokeThickness = new UserRadioGroup("plotStroke", 1, new[] { strokeThickness1ptMenuItem, strokeThickness2ptMenuItem, strokeThickness3ptMenuItem, strokeThickness4ptMenuItem }, _settings); - - _strokeThickness.Changed += (sender, e) => - { - _plotStrokeThickness = (_strokeThickness.Value >= 0 && _strokeThickness.Value <= 3) - ? _strokeThickness.Value + 1 - : 4; - _plotPanel.UpdateStrokeThickness(_plotStrokeThickness); - }; - - _plotLocation.Changed += delegate - { - switch (_plotLocation.Value) - { - case 0: - splitContainer.Panel2.Controls.Clear(); - splitContainer.Panel2Collapsed = true; - _plotForm.Controls.Add(_plotPanel); - if (_showPlot.Value && Visible) - _plotForm.Show(); - break; - case 1: - _plotForm.Controls.Clear(); - _plotForm.Hide(); - splitContainer.Orientation = Orientation.Horizontal; - splitContainer.Panel2.Controls.Add(_plotPanel); - splitContainer.Panel2Collapsed = !_showPlot.Value; - break; - case 2: - _plotForm.Controls.Clear(); - _plotForm.Hide(); - splitContainer.Orientation = Orientation.Vertical; - splitContainer.Panel2.Controls.Add(_plotPanel); - splitContainer.Panel2Collapsed = !_showPlot.Value; - break; - } - }; - - _splitPanelScalingSetting.Changed += delegate - { - switch (_splitPanelScalingSetting.Value) - { - case 0: - splitContainer.FixedPanel = FixedPanel.None; - break; - case 1: - splitContainer.FixedPanel = FixedPanel.Panel2; - break; - case 2: - splitContainer.FixedPanel = FixedPanel.Panel1; - break; - } - }; - - _plotForm.FormClosing += delegate(object sender, FormClosingEventArgs e) - { - if (e.CloseReason == CloseReason.UserClosing) - { - // just switch off the plotting when the user closes the form - if (_plotLocation.Value == 0) - { - _showPlot.Value = false; - } - - e.Cancel = true; - } - }; - - void MoveOrResizePlotForm(object sender, EventArgs e) - { - if (_plotForm.WindowState != FormWindowState.Minimized) - { - _settings.SetValue("plotForm.Location.X", _plotForm.Bounds.X); - _settings.SetValue("plotForm.Location.Y", _plotForm.Bounds.Y); - _settings.SetValue("plotForm.Width", _plotForm.Bounds.Width); - _settings.SetValue("plotForm.Height", _plotForm.Bounds.Height); - } - } - - _plotForm.Move += MoveOrResizePlotForm; - _plotForm.Resize += MoveOrResizePlotForm; - - _plotForm.VisibleChanged += delegate - { - Rectangle bounds = new(_plotForm.Location, _plotForm.Size); - Screen screen = Screen.FromRectangle(bounds); - Rectangle intersection = Rectangle.Intersect(screen.WorkingArea, bounds); - if (intersection.Width < Math.Min(16, bounds.Width) || - intersection.Height < Math.Min(16, bounds.Height)) - { - _plotForm.Location = new Point(screen.WorkingArea.Width / 2 - bounds.Width / 2, - screen.WorkingArea.Height / 2 - bounds.Height / 2); - } - }; - - VisibleChanged += delegate - { - if (Visible && _showPlot.Value && _plotLocation.Value == 0) - _plotForm.Show(); - else - _plotForm.Hide(); - }; - - Theme.Current.Apply(_plotForm); - } - - private void InsertSorted(IList nodes, HardwareNode node) - { - int i = 0; - while (i < nodes.Count && nodes[i] is HardwareNode && ((HardwareNode)nodes[i]).Hardware.HardwareType <= node.Hardware.HardwareType) - i++; - - nodes.Insert(i, node); - } - - private void SubHardwareAdded(IHardware hardware, Node node) - { - HardwareNode hardwareNode = new(hardware, _settings, _unitManager); - hardwareNode.PlotSelectionChanged += PlotSelectionChanged; - InsertSorted(node.Nodes, hardwareNode); - foreach (IHardware subHardware in hardware.SubHardware) - SubHardwareAdded(subHardware, hardwareNode); - } - - private void HardwareAdded(IHardware hardware) - { - if (_uiSyncContext != null && System.Threading.SynchronizationContext.Current != _uiSyncContext) - { - _uiSyncContext.Post(_ => HardwareAdded(hardware), null); - return; - } - - SubHardwareAdded(hardware, _root); - PlotSelectionChanged(this, null); - } - - private void HardwareRemoved(IHardware hardware) - { - if (_uiSyncContext != null && System.Threading.SynchronizationContext.Current != _uiSyncContext) - { - _uiSyncContext.Post(_ => HardwareRemoved(hardware), null); - return; - } - - List nodesToRemove = new(); - foreach (Node node in _root.Nodes) - { - if (node is HardwareNode hardwareNode && hardwareNode.Hardware == hardware) - nodesToRemove.Add(hardwareNode); - } - - foreach (HardwareNode hardwareNode in nodesToRemove) - { - _root.Nodes.Remove(hardwareNode); - hardwareNode.PlotSelectionChanged -= PlotSelectionChanged; - } - - PlotSelectionChanged(this, null); - } - - private void NodeTextBoxText_DrawText(object sender, DrawEventArgs e) - { - if (e.Node.Tag is Node node) - { - if (node.IsVisible) - { - if (plotMenuItem.Checked && node is SensorNode sensorNode && _sensorPlotColors.TryGetValue(sensorNode.Sensor, out Color color)) - e.TextColor = color; - } - else - e.TextColor = Color.DarkGray; - } - } - - private void PlotSelectionChanged(object sender, EventArgs e) - { - List selected = new(); - IDictionary colors = new Dictionary(); - int colorIndex = 0; - - foreach (TreeNodeAdv node in treeView.AllNodes) - { - if (node.Tag is SensorNode sensorNode) - { - if (sensorNode.Plot) - { - if (!sensorNode.PenColor.HasValue) - { - colors.Add(sensorNode.Sensor, - Theme.Current.PlotColorPalette[colorIndex % Theme.Current.PlotColorPalette.Length]); - } - - selected.Add(sensorNode.Sensor); - } - - colorIndex++; - } - } - - // if a sensor is assigned a color that's already being used by another - // sensor, try to assign it a new color. This is done only after the - // previous loop sets an unchanging default color for all sensors, so that - // colors jump around as little as possible as sensors get added/removed - // from the plot - var usedColors = new List(); - foreach (ISensor curSelectedSensor in selected) - { - if (!colors.ContainsKey(curSelectedSensor)) - continue; - - Color curColor = colors[curSelectedSensor]; - if (usedColors.Contains(curColor)) - { - foreach (Color potentialNewColor in Theme.Current.PlotColorPalette) - { - if (!colors.Values.Contains(potentialNewColor)) - { - colors[curSelectedSensor] = potentialNewColor; - usedColors.Add(potentialNewColor); - break; - } - } - } - else - { - usedColors.Add(curColor); - } - } - - foreach (TreeNodeAdv node in treeView.AllNodes) - { - if (node.Tag is SensorNode sensorNode && sensorNode.Plot && sensorNode.PenColor.HasValue) - colors.Add(sensorNode.Sensor, sensorNode.PenColor.Value); - } - - _sensorPlotColors = colors; - _plotPanel.SetSensors(selected, colors, _plotStrokeThickness); - } - - private void NodeTextBoxText_EditorShowing(object sender, CancelEventArgs e) - { - e.Cancel = !(treeView.CurrentNode != null && (treeView.CurrentNode.Tag is SensorNode || treeView.CurrentNode.Tag is HardwareNode)); - } - - private void NodeCheckBox_IsVisibleValueNeeded(object sender, NodeControlValueEventArgs e) - { - e.Value = e.Node.Tag is SensorNode && plotMenuItem.Checked; - } - - private void ExitClick(object sender, EventArgs e) - { - CloseApplication(); - } - - private void Timer_Tick(object sender, EventArgs e) - { - treeView.Invalidate(); - _systemTray.Redraw(); - _gadget?.Redraw(); - - if (!backgroundUpdater.IsBusy) - backgroundUpdater.RunWorkerAsync(); - } - - private void SaveConfiguration() - { - if (_plotPanel == null || _settings == null) - return; - - _plotPanel.SetCurrentSettings(); - - foreach (TreeColumn column in treeView.Columns) - _settings.SetValue("treeView.Columns." + column.Header + ".Width", column.Width); - - _settings.SetValue("listenerIp", Server.ListenerIp); - _settings.SetValue("listenerPort", Server.ListenerPort); - _settings.SetValue("authenticationEnabled", Server.AuthEnabled); - _settings.SetValue("authenticationUserName", Server.UserName); - _settings.SetValue("authenticationPassword", Server.PasswordSHA256); - - string fileName = Path.ChangeExtension(Application.ExecutablePath, ".config"); - - try - { - _settings.Save(fileName); - } - catch (UnauthorizedAccessException) - { - MessageBox.Show("Access to the path '" + - fileName + - "' is denied. " + - "The current settings could not be saved.", - "Error", - MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - catch (IOException) - { - MessageBox.Show("The path '" + - fileName + - "' is not writeable. " + - "The current settings could not be saved.", - "Error", - MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - - private void MainForm_Load(object sender, EventArgs e) - { - Rectangle newBounds = new() - { - X = _settings.GetValue("mainForm.Location.X", Location.X), - Y = _settings.GetValue("mainForm.Location.Y", Location.Y), - Width = _settings.GetValue("mainForm.Width", 470), - Height = _settings.GetValue("mainForm.Height", 640) - }; - - Rectangle fullWorkingArea = new(int.MaxValue, int.MaxValue, int.MinValue, int.MinValue); - - foreach (Screen screen in Screen.AllScreens) - fullWorkingArea = Rectangle.Union(fullWorkingArea, screen.Bounds); - - Rectangle intersection = Rectangle.Intersect(fullWorkingArea, newBounds); - if (intersection.Width < 20 || intersection.Height < 20 || !_settings.Contains("mainForm.Location.X")) - { - newBounds.X = (Screen.PrimaryScreen.WorkingArea.Width / 2) - (newBounds.Width / 2); - newBounds.Y = (Screen.PrimaryScreen.WorkingArea.Height / 2) - (newBounds.Height / 2); - } - - Bounds = newBounds; - - RestoreCollapsedNodeState(treeView); - - FormClosed += MainForm_FormClosed; - } - - private void RestoreCollapsedNodeState(TreeViewAdv treeViewAdv) - { - var collapsedHwNodes = treeViewAdv.AllNodes - .Where(n => n.IsExpanded && n.Tag is IExpandPersistNode expandPersistNode && !expandPersistNode.Expanded) - .OrderByDescending(n => n.Level) - .ToList(); - - foreach (TreeNodeAdv node in collapsedHwNodes) - { - node.IsExpanded = false; - } - } - - private void CloseApplication() - { - FormClosed -= MainForm_FormClosed; - - Visible = false; - _systemTray.IsMainIconEnabled = false; - timer.Enabled = false; - _computer.Close(); - SaveConfiguration(); - if (_runWebServer.Value) - Server.Quit(); - - _systemTray.Dispose(); - timer.Dispose(); - backgroundUpdater.Dispose(); - - Application.Exit(); - } - - private void MainForm_FormClosed(object sender, FormClosedEventArgs e) - { - CloseApplication(); - } - - private void AboutMenuItem_Click(object sender, EventArgs e) - { - _ = new AboutBox().ShowDialog(); - } - - private void TreeView_Click(object sender, EventArgs e) - { - if (!(e is MouseEventArgs m) || (m.Button != MouseButtons.Left && m.Button != MouseButtons.Right)) - return; - - NodeControlInfo info = treeView.GetNodeControlInfoAt(new Point(m.X, m.Y)); - if (m.Button == MouseButtons.Left && info.Node != null) - { - if (info.Node.Tag is IExpandPersistNode expandPersistNode) - { - expandPersistNode.Expanded = info.Node.IsExpanded; - } - return; - } - - treeView.SelectedNode = info.Node; - if (info.Node != null) - { - if (info.Node.Tag is SensorNode node && node.Sensor != null) - { - treeContextMenu.Items.Clear(); - if (node.Sensor.Parameters.Count > 0) - { - ToolStripItem item = new ToolStripMenuItem("Parameters..."); - item.Click += delegate { ShowParameterForm(node.Sensor); }; - treeContextMenu.Items.Add(item); - } - - if (nodeTextBoxText.EditEnabled) - { - ToolStripItem item = new ToolStripMenuItem("Rename"); - item.Click += delegate { nodeTextBoxText.BeginEdit(); }; - treeContextMenu.Items.Add(item); - } - - if (node.IsVisible) - { - ToolStripItem item = new ToolStripMenuItem("Hide"); - item.Click += delegate { node.IsVisible = false; }; - treeContextMenu.Items.Add(item); - } - else - { - ToolStripItem item = new ToolStripMenuItem("Unhide"); - item.Click += delegate { node.IsVisible = true; }; - treeContextMenu.Items.Add(item); - } - - treeContextMenu.Items.Add(new ToolStripSeparator()); - { - ToolStripItem item = new ToolStripMenuItem("Pen Color..."); - item.Click += delegate - { - ColorDialog dialog = new() { Color = node.PenColor.GetValueOrDefault() }; - if (dialog.ShowDialog() == DialogResult.OK) - node.PenColor = dialog.Color; - }; - - treeContextMenu.Items.Add(item); - } - - { - ToolStripItem item = new ToolStripMenuItem("Reset Pen Color"); - item.Click += delegate { node.PenColor = null; }; - treeContextMenu.Items.Add(item); - } - - treeContextMenu.Items.Add(new ToolStripSeparator()); - { - ToolStripMenuItem item = new("Show in Tray") { Checked = _systemTray.Contains(node.Sensor) }; - item.Click += delegate - { - if (item.Checked) - _systemTray.Remove(node.Sensor); - else - _systemTray.Add(node.Sensor, true); - }; - - treeContextMenu.Items.Add(item); - } - - if (_gadget != null) - { - ToolStripMenuItem item = new("Show in Gadget") { Checked = _gadget.Contains(node.Sensor) }; - item.Click += delegate - { - if (item.Checked) - { - _gadget.Remove(node.Sensor); - } - else - { - _gadget.Add(node.Sensor); - } - }; - - treeContextMenu.Items.Add(item); - } - - if (node.Sensor.Control != null) - { - treeContextMenu.Items.Add(new ToolStripSeparator()); - IControl control = node.Sensor.Control; - ToolStripMenuItem controlItem = new("Control"); - ToolStripItem defaultItem = new ToolStripMenuItem("Default") { Checked = control.ControlMode == ControlMode.Default }; - controlItem.DropDownItems.Add(defaultItem); - defaultItem.Click += delegate { control.SetDefault(); }; - ToolStripMenuItem manualItem = new("Manual"); - controlItem.DropDownItems.Add(manualItem); - manualItem.Checked = control.ControlMode == ControlMode.Software; - for (int i = 0; i <= 100; i += 5) - { - if (i <= control.MaxSoftwareValue && - i >= control.MinSoftwareValue) - { - ToolStripMenuItem item = new ToolStripRadioButtonMenuItem(i + " %"); - manualItem.DropDownItems.Add(item); - item.Checked = control.ControlMode == ControlMode.Software && Math.Round(control.SoftwareValue) == i; - int softwareValue = i; - item.Click += delegate { control.SetSoftware(softwareValue); }; - } - } - - treeContextMenu.Items.Add(controlItem); - } - - treeContextMenu.Show(treeView, new Point(m.X, m.Y)); - } - - if (info.Node.Tag is HardwareNode hardwareNode && hardwareNode.Hardware != null) - { - treeContextMenu.Items.Clear(); - - if (nodeTextBoxText.EditEnabled) - { - ToolStripItem item = new ToolStripMenuItem("Rename"); - item.Click += delegate { nodeTextBoxText.BeginEdit(); }; - treeContextMenu.Items.Add(item); - } - - treeContextMenu.Show(treeView, new Point(m.X, m.Y)); - } - } - } - - private void SaveReportMenuItem_Click(object sender, EventArgs e) - { - string report = _computer.GetReport(); - if (saveFileDialog.ShowDialog() == DialogResult.OK) - { - using (TextWriter w = new StreamWriter(saveFileDialog.FileName)) - { - w.Write(report); - } - } - } - - private void SysTrayHideShow() - { - Visible = !Visible; - if (Visible) - Activate(); - } - - protected override void WndProc(ref Message m) - { - const int WM_SYSCOMMAND = 0x112; - const int WM_WININICHANGE = 0x001A; - const int SC_MINIMIZE = 0xF020; - const int SC_CLOSE = 0xF060; - - if (_minimizeToTray.Value && m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_MINIMIZE) - { - SysTrayHideShow(); - } - else if (m.Msg == WM_WININICHANGE && Marshal.PtrToStringUni(m.LParam) == "ImmersiveColorSet" && _autoThemeMenuItem?.Checked == true) - { - Theme.SetAutoTheme(); - } - else if (_minimizeOnClose.Value && m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_CLOSE) - { - //Apparently the user wants to minimize rather than close - //Now we still need to check if we're going to the tray or not - //Note: the correct way to do this would be to send out SC_MINIMIZE, - //but since the code here is so simple, - //that would just be a waste of time. - if (_minimizeToTray.Value) - SysTrayHideShow(); - else - WindowState = FormWindowState.Minimized; - } - else - { - base.WndProc(ref m); - } - } - - private void HideShowClick(object sender, EventArgs e) - { - SysTrayHideShow(); - } - - private void ShowParameterForm(ISensor sensorForm) - { - ParameterForm form = new() { Parameters = sensorForm.Parameters, captionLabel = { Text = sensorForm.Name } }; - form.ShowDialog(); - } - - private void TreeView_NodeMouseDoubleClick(object sender, TreeNodeAdvMouseEventArgs e) - { - if (e.Node.Tag is SensorNode node && node.Sensor != null && node.Sensor.Parameters.Count > 0) - ShowParameterForm(node.Sensor); - } - - private void CelsiusMenuItem_Click(object sender, EventArgs e) - { - celsiusMenuItem.Checked = true; - fahrenheitMenuItem.Checked = false; - _unitManager.TemperatureUnit = TemperatureUnit.Celsius; - } - - private void FahrenheitMenuItem_Click(object sender, EventArgs e) - { - celsiusMenuItem.Checked = false; - fahrenheitMenuItem.Checked = true; - _unitManager.TemperatureUnit = TemperatureUnit.Fahrenheit; - } - - private void ResetMinMaxMenuItem_Click(object sender, EventArgs e) - { - _computer.Accept(new SensorVisitor(delegate(ISensor sensorClick) - { - sensorClick.ResetMin(); - sensorClick.ResetMax(); - })); - } - - private void ExpandAllNodes_Click(object sender, EventArgs e) - { - treeView.ExpandAll(); - - foreach (var node in treeView.AllNodes) - { - if (node.Tag is IExpandPersistNode expandPersistNode) - { - expandPersistNode.Expanded = true; - } - } - } - - private void CollapseAllNodes_Click(object sender, EventArgs e) - { - treeView.CollapseAll(); - - foreach (var node in treeView.AllNodes) - { - if (node.Tag is IExpandPersistNode expandPersistNode) - { - expandPersistNode.Expanded = false; - } - } - } - - private void resetPlotMenuItem_Click(object sender, EventArgs e) - { - _computer.Accept(new SensorVisitor(delegate (ISensor sensorClick) - { - sensorClick.ClearValues(); - })); - } - - private void MainForm_MoveOrResize(object sender, EventArgs e) - { - if (WindowState != FormWindowState.Minimized) - { - _settings.SetValue("mainForm.Location.X", Bounds.X); - _settings.SetValue("mainForm.Location.Y", Bounds.Y); - _settings.SetValue("mainForm.Width", Bounds.Width); - _settings.SetValue("mainForm.Height", Bounds.Height); - } - } - - private void ResetClick(object sender, EventArgs e) - { - // disable the fallback MainIcon during reset, otherwise icon visibility - // might be lost - _systemTray.IsMainIconEnabled = false; - _computer.Reset(); - // restore the MainIcon setting - _systemTray.IsMainIconEnabled = _minimizeToTray.Value; - } - - private void TreeView_MouseMove(object sender, MouseEventArgs e) - { - _selectionDragging &= (e.Button & (MouseButtons.Left | MouseButtons.Right)) > 0; - if (_selectionDragging) - treeView.SelectedNode = treeView.GetNodeAt(e.Location); - } - - private void TreeView_MouseDown(object sender, MouseEventArgs e) - { - _selectionDragging = true; - } - - private void TreeView_MouseUp(object sender, MouseEventArgs e) - { - _selectionDragging = false; - } - - private void TreeView_SizeChanged(object sender, EventArgs e) - { - int newWidth = treeView.Width; - for (int i = 1; i < treeView.Columns.Count; i++) - { - if (treeView.Columns[i].IsVisible) - newWidth -= treeView.Columns[i].Width; - } - treeView.Columns[0].Width = newWidth; - } - - private void TreeView_KeyDown(object sender, KeyEventArgs e) - { - if (treeView.SelectedNode != null) - { - switch (e.KeyCode) - { - case Keys.Right: - if (treeView.SelectedNode.Tag is IExpandPersistNode expandPersistNodeR) - { - expandPersistNodeR.Expanded = true; - } - return; - case Keys.Left: - if (treeView.SelectedNode.Tag is IExpandPersistNode expandPersistNodeL) - { - expandPersistNodeL.Expanded = false; - } - return; - } - } - } - - private void TreeView_ColumnWidthChanged(TreeColumn column) - { - int index = treeView.Columns.IndexOf(column); - int columnsWidth = 0; - foreach (TreeColumn treeColumn in treeView.Columns) - { - if (treeColumn.IsVisible) - columnsWidth += treeColumn.Width; - } - - int nextColumnIndex = index + 1; - while (nextColumnIndex < treeView.Columns.Count && treeView.Columns[nextColumnIndex].IsVisible == false) - nextColumnIndex++; - - if (nextColumnIndex < treeView.Columns.Count) { - int diff = treeView.Width - columnsWidth; - treeView.Columns[nextColumnIndex].Width = Math.Max(20, treeView.Columns[nextColumnIndex].Width + diff); - } - } - - private void ServerInterfacePortMenuItem_Click(object sender, EventArgs e) - { - new InterfacePortForm(this).ShowDialog(); - } - - private void AuthWebServerMenuItem_Click(object sender, EventArgs e) - { - new AuthForm(this).ShowDialog(); - } - - private void perSessionFileRotationMenuItem_Click(object sender, EventArgs e) - { - dailyFileRotationMenuItem.Checked = false; - perSessionFileRotationMenuItem.Checked = true; - _logger.FileRotationMethod = LoggerFileRotation.PerSession; - _settings.SetValue("logger.fileRotation", (int)LoggerFileRotation.PerSession); - } - - private void dailyFileRotationMenuItem_Click(object sender, EventArgs e) - { - dailyFileRotationMenuItem.Checked = true; - perSessionFileRotationMenuItem.Checked = false; - _logger.FileRotationMethod = LoggerFileRotation.Daily; - _settings.SetValue("logger.fileRotation", (int)LoggerFileRotation.Daily); - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/MainForm.resx b/LibreHardwareMonitor.Windows.Forms/UI/MainForm.resx deleted file mode 100644 index 17a6d78..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/MainForm.resx +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 164, 17 - - - 293, 17 - - - 483, 17 - - - - - AAABAAMAEBAAAAEAIABoBAAANgAAACAgAAABACAAqBAAAJ4EAAAwMAAAAQAgAKglAABGFQAAKAAAABAA - AAAgAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEU8OykuDgdIIxQSURwdHU8ZGhpPFhYWTxQU - FE8SEhJPDxAPTw0KCk8KBQRPCAQDTwcDAU8HAQBPBgQEUQUFBTxLVVb/L215/zdXXP89Ozv/ODc3/zM0 - M/8vLy//Kioq/yYlJf8iJif/Gycp/xggI/8UHiD/Eh4g/w4SE/8GBARRQWRr/xGXtP8yUln/NDIx/y4u - Lf8qKir/KSgo/ycnJ/8lJCP/Iikq/xs4Pf8aOD7/GzpB/xo4Pf8SGhv/BwMDT01aXP46Ulj+Pzc0/kdH - R/5MTU3+Q0ND/jw8PP43Nzf+Ly8v/igoKP4lKCn+Iico/hwiI/4cHyD/FBMU/wYHBk9XVVX+Rj8+/klJ - Sf6ioqL+rq+u/p+fn/6YmJj+j4+P/oSEhP56enr+dXJy/mNgYP4iHx7+Gxka/xUVFf8HBwdPW1pa/kVF - RP5YWFj+rq6u/r6+vv6wsK/+qamp/qCgoP6UlJT+iYmJ/oGBgf5xcXH+JCQk/hsbG/8WFhb/BwcHT15e - Xv5ISEj+Wlpa/rW1tf7Gxsb+tra2/qysq/6hoaL+lpaW/oyMjP6EhIT+cnJy/iQkJP4cHBz/GBgY/wcH - B09jY2P+TUxM/l5eXv7AwMD+0dHR/r6+vv6vr6/+o6Ok/pmYmf6Rk5P+iouK/nd4d/4lJSX+HR0d/xkZ - Gf8HBwdPZ2dn/lBQUP5iYmL+ysrK/tzc3P7Hxsf+tbS1/qmpqf6fn5/+mJiY/o6Pj/57e3z+JSUm/h4e - Hv8aGhr/CAgIT2tra/5TU1P+ZGRk/t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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA+AAAAAAfAAD4AAAAAB8AAPgA - AAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAf - AAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgA - AAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAf - AAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgA - AAAAHwAA+AAAAAAfAAD4AAAAAB8AAPgAAAAAHwAA+AAAAAAfAAD4AAAAAB8AAP///////wAA//////// - AAD///////8AAP///////wAA////////AAA= - - - \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/Node.cs b/LibreHardwareMonitor.Windows.Forms/UI/Node.cs deleted file mode 100644 index 2f1b3af..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/Node.cs +++ /dev/null @@ -1,168 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections.ObjectModel; -using System.Drawing; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class Node -{ - private Node _parent; - private readonly NodeCollection _nodes; - private string _text; - private bool _visible; - - public delegate void NodeEventHandler(Node node); - public event NodeEventHandler IsVisibleChanged; - public event NodeEventHandler NodeAdded; - public event NodeEventHandler NodeRemoved; - - private TreeModel RootTreeModel() - { - Node node = this; - while (node != null) - { - if (node.Model != null) - return node.Model; - node = node._parent; - } - return null; - } - - public Node() : this(string.Empty) { } - - public Node(string text) - { - _text = text; - _nodes = new NodeCollection(this); - _visible = true; - } - - public TreeModel Model { get; set; } - - public Node Parent - { - get { return _parent; } - set - { - if (value != _parent) - { - _parent?._nodes.Remove(this); - value?._nodes.Add(this); - } - } - } - - public Collection Nodes - { - get { return _nodes; } - } - - public virtual string Text - { - get { return _text; } - set - { - _text = value; - } - } - - public virtual string ToolTip { get; } - - public Image Image { get; set; } - - public virtual bool IsVisible - { - get { return _visible; } - set - { - if (value != _visible) - { - _visible = value; - TreeModel model = RootTreeModel(); - if (model != null && _parent != null) - { - int index = 0; - for (int i = 0; i < _parent._nodes.Count; i++) - { - Node node = _parent._nodes[i]; - if (node == this) - break; - if (node.IsVisible || model.ForceVisible) - index++; - } - if (model.ForceVisible) - { - model.OnNodeChanged(_parent, index, this); - } - else - { - if (value) - model.OnNodeInserted(_parent, index, this); - else - model.OnNodeRemoved(_parent, index, this); - } - } - IsVisibleChanged?.Invoke(this); - } - } - } - - private class NodeCollection : Collection - { - private readonly Node _owner; - - public NodeCollection(Node owner) - { - _owner = owner; - } - - protected override void ClearItems() - { - while (Count != 0) - RemoveAt(Count - 1); - } - - protected override void InsertItem(int index, Node item) - { - if (item == null) - throw new ArgumentNullException(nameof(item)); - - if (item._parent != _owner) - { - item._parent?._nodes.Remove(item); - item._parent = _owner; - base.InsertItem(index, item); - - TreeModel model = _owner.RootTreeModel(); - model?.OnStructureChanged(_owner); - _owner.NodeAdded?.Invoke(item); - } - } - - protected override void RemoveItem(int index) - { - Node item = this[index]; - item._parent = null; - base.RemoveItem(index); - - TreeModel model = _owner.RootTreeModel(); - model?.OnStructureChanged(_owner); - _owner.NodeRemoved?.Invoke(item); - } - - protected override void SetItem(int index, Node item) - { - if (item == null) - throw new ArgumentNullException(nameof(item)); - - RemoveAt(index); - InsertItem(index, item); - } - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/NodeToolTipProvider.cs b/LibreHardwareMonitor.Windows.Forms/UI/NodeToolTipProvider.cs deleted file mode 100644 index 4edb37c..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/NodeToolTipProvider.cs +++ /dev/null @@ -1,14 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// All Rights Reserved. - -using Aga.Controls.Tree; -using Aga.Controls.Tree.NodeControls; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -internal class NodeToolTipProvider : IToolTipProvider -{ - public string GetToolTip(TreeNodeAdv node, NodeControl nodeControl) => (node.Tag as Node)?.ToolTip; -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/NotifyIconAdv.cs b/LibreHardwareMonitor.Windows.Forms/UI/NotifyIconAdv.cs deleted file mode 100644 index a3a8eef..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/NotifyIconAdv.cs +++ /dev/null @@ -1,861 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.ComponentModel; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Reflection; -using System.Windows.Forms; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class NotifyIconAdv : IDisposable -{ - private readonly NotifyIcon _genericNotifyIcon; - private readonly NotifyIconWindowsImplementation _windowsNotifyIcon; - - public NotifyIconAdv() - { - if (Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix) - _genericNotifyIcon = new NotifyIcon(); - else - _windowsNotifyIcon = new NotifyIconWindowsImplementation(); - } - - public event EventHandler BalloonTipClicked - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.BalloonTipClicked += value; - else - _windowsNotifyIcon.BalloonTipClicked += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.BalloonTipClicked -= value; - else - _windowsNotifyIcon.BalloonTipClicked -= value; - } - } - - public event EventHandler BalloonTipClosed - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.BalloonTipClosed += value; - else - _windowsNotifyIcon.BalloonTipClosed += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.BalloonTipClosed -= value; - else - _windowsNotifyIcon.BalloonTipClosed -= value; - } - } - - public event EventHandler BalloonTipShown - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.BalloonTipShown += value; - else - _windowsNotifyIcon.BalloonTipShown += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.BalloonTipShown -= value; - else - _windowsNotifyIcon.BalloonTipShown -= value; - } - } - - public event EventHandler Click - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.Click += value; - else - _windowsNotifyIcon.Click += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.Click -= value; - else - _windowsNotifyIcon.Click -= value; - } - } - - public event EventHandler DoubleClick - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.DoubleClick += value; - else - _windowsNotifyIcon.DoubleClick += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.DoubleClick -= value; - else - _windowsNotifyIcon.DoubleClick -= value; - } - } - - public event MouseEventHandler MouseClick - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseClick += value; - else - _windowsNotifyIcon.MouseClick += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseClick -= value; - else - _windowsNotifyIcon.MouseClick -= value; - } - } - - public event MouseEventHandler MouseDoubleClick - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseDoubleClick += value; - else - _windowsNotifyIcon.MouseDoubleClick += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseDoubleClick -= value; - else - _windowsNotifyIcon.MouseDoubleClick -= value; - } - } - - public event MouseEventHandler MouseDown - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseDown += value; - else - _windowsNotifyIcon.MouseDown += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseDown -= value; - else - _windowsNotifyIcon.MouseDown -= value; - } - } - - public event MouseEventHandler MouseMove - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseMove += value; - else - _windowsNotifyIcon.MouseMove += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseMove -= value; - else - _windowsNotifyIcon.MouseMove -= value; - } - } - - public event MouseEventHandler MouseUp - { - add - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseUp += value; - else - _windowsNotifyIcon.MouseUp += value; - } - remove - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.MouseUp -= value; - else - _windowsNotifyIcon.MouseUp -= value; - } - } - - public string BalloonTipText - { - get - { - if (_genericNotifyIcon != null) - return _genericNotifyIcon.BalloonTipText; - - - return _windowsNotifyIcon.BalloonTipText; - } - set - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.BalloonTipText = value; - else - _windowsNotifyIcon.BalloonTipText = value; - } - } - - public ToolTipIcon BalloonTipIcon - { - get - { - if (_genericNotifyIcon != null) - return _genericNotifyIcon.BalloonTipIcon; - - - return _windowsNotifyIcon.BalloonTipIcon; - } - set - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.BalloonTipIcon = value; - else - _windowsNotifyIcon.BalloonTipIcon = value; - } - } - - public string BalloonTipTitle - { - get - { - if (_genericNotifyIcon != null) - return _genericNotifyIcon.BalloonTipTitle; - - - return _windowsNotifyIcon.BalloonTipTitle; - } - set - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.BalloonTipTitle = value; - else - _windowsNotifyIcon.BalloonTipTitle = value; - } - } - - public ContextMenuStrip ContextMenuStrip - { - get - { - if (_genericNotifyIcon != null) - return _genericNotifyIcon.ContextMenuStrip; - - - return _windowsNotifyIcon.ContextMenuStrip; - } - set - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.ContextMenuStrip = value; - else - _windowsNotifyIcon.ContextMenuStrip = value; - } - } - - public object Tag { get; set; } - - public Icon Icon - { - get - { - if (_genericNotifyIcon != null) - return _genericNotifyIcon.Icon; - - - return _windowsNotifyIcon.Icon; - } - set - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.Icon = value; - else - _windowsNotifyIcon.Icon = value; - } - } - - public string Text - { - get - { - if (_genericNotifyIcon != null) - return _genericNotifyIcon.Text; - - - return _windowsNotifyIcon.Text; - } - set - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.Text = value; - else - _windowsNotifyIcon.Text = value; - } - } - - public bool Visible - { - get - { - if (_genericNotifyIcon != null) - return _genericNotifyIcon.Visible; - - - return _windowsNotifyIcon.Visible; - } - set - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.Visible = value; - else - _windowsNotifyIcon.Visible = value; - } - } - - public void Dispose() - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.Dispose(); - else - _windowsNotifyIcon.Dispose(); - } - - public void ShowBalloonTip(int timeout) - { - ShowBalloonTip(timeout, BalloonTipTitle, BalloonTipText, BalloonTipIcon); - } - - public void ShowBalloonTip(int timeout, string tipTitle, string tipText, - ToolTipIcon tipIcon) - { - if (_genericNotifyIcon != null) - _genericNotifyIcon.ShowBalloonTip(timeout, tipTitle, tipText, tipIcon); - else - _windowsNotifyIcon.ShowBalloonTip(timeout, tipTitle, tipText, tipIcon); - } - - private class NotifyIconWindowsImplementation : Component - { - - private static int _nextId; - private readonly object _syncObj = new object(); - private Icon _icon; - private string _text = ""; - private readonly int _id; - private bool _created; - private NotifyIconNativeWindow _window; - private bool _doubleClickDown; - private bool _visible; - private readonly MethodInfo _commandDispatch; - - public event EventHandler BalloonTipClicked; - public event EventHandler BalloonTipClosed; - public event EventHandler BalloonTipShown; - public event EventHandler Click; - public event EventHandler DoubleClick; - public event MouseEventHandler MouseClick; - public event MouseEventHandler MouseDoubleClick; - public event MouseEventHandler MouseDown; - public event MouseEventHandler MouseMove; - public event MouseEventHandler MouseUp; - - public string BalloonTipText { get; set; } - public ToolTipIcon BalloonTipIcon { get; set; } - public string BalloonTipTitle { get; set; } - public ContextMenuStrip ContextMenuStrip { get; set; } - - public Icon Icon - { - get - { - return _icon; - } - set - { - if (_icon != value) - { - _icon = value; - UpdateNotifyIcon(_visible); - } - } - } - - public string Text - { - get - { - return _text; - } - set - { - if (value == null) - value = ""; - - if (value.Length > 63) - throw new ArgumentOutOfRangeException(); - - if (!value.Equals(_text)) - { - _text = value; - if (_visible) - UpdateNotifyIcon(_visible); - } - } - } - - public bool Visible - { - get - { - return _visible; - } - set - { - if (_visible != value) - { - _visible = value; - UpdateNotifyIcon(_visible); - } - } - } - - public NotifyIconWindowsImplementation() - { - BalloonTipText = ""; - BalloonTipTitle = ""; - - _commandDispatch = typeof(Form).Assembly. - GetType("System.Windows.Forms.Command").GetMethod("DispatchID", - BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, - null, new[] { typeof(int) }, null); - - _id = ++_nextId; - _window = new NotifyIconNativeWindow(this); - UpdateNotifyIcon(_visible); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - if (_window != null) - { - _icon = null; - _text = ""; - UpdateNotifyIcon(false); - _window.DestroyHandle(); - _window = null; - ContextMenuStrip = null; - } - } - else - { - if (_window != null && _window.Handle != IntPtr.Zero) - { - NativeMethods.PostMessage(new HandleRef(_window, _window.Handle), WM_CLOSE, 0, 0); - _window.ReleaseHandle(); - } - } - base.Dispose(disposing); - } - - public void ShowBalloonTip(int timeout) - { - ShowBalloonTip(timeout, BalloonTipTitle, BalloonTipText, BalloonTipIcon); - } - - public void ShowBalloonTip(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon) - { - if (timeout < 0) - throw new ArgumentOutOfRangeException(nameof(timeout)); - - if (string.IsNullOrEmpty(tipText)) - throw new ArgumentException("tipText"); - - if (DesignMode) - return; - - if (_created) - { - NativeMethods.NotifyIconData data = new NativeMethods.NotifyIconData(); - if (_window.Handle == IntPtr.Zero) - _window.CreateHandle(new CreateParams()); - - data.Window = _window.Handle; - data.ID = _id; - data.Flags = NativeMethods.NotifyIconDataFlags.Info; - data.TimeoutOrVersion = timeout; - data.InfoTitle = tipTitle; - data.Info = tipText; - data.InfoFlags = (int)tipIcon; - - NativeMethods.Shell_NotifyIcon(NativeMethods.NotifyIconMessage.Modify, data); - } - } - - private void ShowContextMenu() - { - if (ContextMenuStrip == null) - return; - - NativeMethods.Point p = new NativeMethods.Point(); - NativeMethods.GetCursorPos(ref p); - NativeMethods.SetForegroundWindow(new HandleRef(_window, _window.Handle)); - - ContextMenuStrip?.GetType().InvokeMember("ShowInTaskbar", - BindingFlags.NonPublic | BindingFlags.InvokeMethod | - BindingFlags.Instance, null, ContextMenuStrip, new object[] { p.X, p.Y }); - } - - private void UpdateNotifyIcon(bool showNotifyIcon) - { - if (DesignMode) - return; - - lock (_syncObj) - { - _window.LockReference(showNotifyIcon); - - NativeMethods.NotifyIconData data = new NativeMethods.NotifyIconData { CallbackMessage = WM_TRAYMOUSEMESSAGE, Flags = NativeMethods.NotifyIconDataFlags.Message }; - - if (showNotifyIcon && _window.Handle == IntPtr.Zero) - _window.CreateHandle(new CreateParams()); - - data.Window = _window.Handle; - data.ID = _id; - - if (_icon != null) - { - data.Flags |= NativeMethods.NotifyIconDataFlags.Icon; - data.Icon = _icon.Handle; - } - - data.Flags |= NativeMethods.NotifyIconDataFlags.Tip; - data.Tip = _text; - - if (showNotifyIcon && _icon != null) - { - if (!_created) - { - if (NativeMethods.Shell_NotifyIcon(NativeMethods.NotifyIconMessage.Modify, data)) - { - _created = true; - } - else - { - int i = 0; - do - { - _created = NativeMethods.Shell_NotifyIcon(NativeMethods.NotifyIconMessage.Add, data); - if (!_created) - { - System.Threading.Thread.Sleep(200); - i++; - } - } while (!_created && i < 40); - } - } - else - { - NativeMethods.Shell_NotifyIcon(NativeMethods.NotifyIconMessage.Modify, data); - } - } - else - { - if (_created) - { - int i = 0; - bool deleted; - do - { - deleted = NativeMethods.Shell_NotifyIcon(NativeMethods.NotifyIconMessage.Delete, data); - if (!deleted) - { - System.Threading.Thread.Sleep(200); - i++; - } - } while (!deleted && i < 40); - _created = false; - } - } - } - } - - private void ProcessMouseDown(MouseButtons button, bool doubleClick) - { - if (doubleClick) - { - DoubleClick?.Invoke(this, new MouseEventArgs(button, 2, 0, 0, 0)); - MouseDoubleClick?.Invoke(this, new MouseEventArgs(button, 2, 0, 0, 0)); - - _doubleClickDown = true; - } - - MouseDown?.Invoke(this, new MouseEventArgs(button, doubleClick ? 2 : 1, 0, 0, 0)); - } - - private void ProcessMouseUp(MouseButtons button) - { - MouseUp?.Invoke(this, new MouseEventArgs(button, 0, 0, 0, 0)); - - if (!_doubleClickDown) - { - Click?.Invoke(this, new MouseEventArgs(button, 0, 0, 0, 0)); - MouseClick?.Invoke(this, new MouseEventArgs(button, 0, 0, 0, 0)); - } - _doubleClickDown = false; - } - - private void ProcessInitMenuPopup(ref Message message) - { - _window.DefWndProc(ref message); - } - - private void WndProc(ref Message message) - { - switch (message.Msg) - { - case WM_DESTROY: - UpdateNotifyIcon(false); - return; - case WM_COMMAND: - if (message.LParam != IntPtr.Zero) - { - _window.DefWndProc(ref message); - return; - } - _commandDispatch.Invoke(null, new object[] { message.WParam.ToInt32() & 0xFFFF }); - return; - case WM_INITMENUPOPUP: - ProcessInitMenuPopup(ref message); - return; - case WM_TRAYMOUSEMESSAGE: - switch ((int)message.LParam) - { - case WM_MOUSEMOVE: - MouseMove?.Invoke(this, - new MouseEventArgs(Control.MouseButtons, 0, 0, 0, 0)); - return; - case WM_LBUTTONDOWN: - ProcessMouseDown(MouseButtons.Left, false); - return; - case WM_LBUTTONUP: - ProcessMouseUp(MouseButtons.Left); - return; - case WM_LBUTTONDBLCLK: - ProcessMouseDown(MouseButtons.Left, true); - return; - case WM_RBUTTONDOWN: - ProcessMouseDown(MouseButtons.Right, false); - return; - case WM_RBUTTONUP: - if (ContextMenuStrip != null) - ShowContextMenu(); - ProcessMouseUp(MouseButtons.Right); - return; - case WM_RBUTTONDBLCLK: - ProcessMouseDown(MouseButtons.Right, true); - return; - case WM_MBUTTONDOWN: - ProcessMouseDown(MouseButtons.Middle, false); - return; - case WM_MBUTTONUP: - ProcessMouseUp(MouseButtons.Middle); - return; - case WM_MBUTTONDBLCLK: - ProcessMouseDown(MouseButtons.Middle, true); - return; - case NIN_BALLOONSHOW: - BalloonTipShown?.Invoke(this, EventArgs.Empty); - return; - case NIN_BALLOONHIDE: - case NIN_BALLOONTIMEOUT: - BalloonTipClosed?.Invoke(this, EventArgs.Empty); - return; - case NIN_BALLOONUSERCLICK: - BalloonTipClicked?.Invoke(this, EventArgs.Empty); - return; - default: - return; - } - } - - if (message.Msg == _wmTaskBarCreated) - { - lock (_syncObj) - { - _created = false; - } - UpdateNotifyIcon(_visible); - } - - _window.DefWndProc(ref message); - } - - private class NotifyIconNativeWindow : NativeWindow - { - private readonly NotifyIconWindowsImplementation _reference; - private GCHandle _referenceHandle; - - internal NotifyIconNativeWindow(NotifyIconWindowsImplementation component) - { - _reference = component; - } - - ~NotifyIconNativeWindow() - { - if (Handle != IntPtr.Zero) - NativeMethods.PostMessage(new HandleRef(this, Handle), WM_CLOSE, 0, 0); - } - - public void LockReference(bool locked) - { - if (locked) - { - if (!_referenceHandle.IsAllocated) - { - _referenceHandle = GCHandle.Alloc(_reference, GCHandleType.Normal); - } - } - else - { - if (_referenceHandle.IsAllocated) - _referenceHandle.Free(); - } - } - - protected override void OnThreadException(Exception e) - { - Application.OnThreadException(e); - } - - protected override void WndProc(ref Message m) - { - _reference.WndProc(ref m); - } - } - - private const int WM_NULL = 0x00; - private const int WM_DESTROY = 0x02; - private const int WM_CLOSE = 0x10; - private const int WM_COMMAND = 0x111; - private const int WM_INITMENUPOPUP = 0x117; - private const int WM_MOUSEMOVE = 0x200; - private const int WM_LBUTTONDOWN = 0x201; - private const int WM_LBUTTONUP = 0x202; - private const int WM_LBUTTONDBLCLK = 0x203; - private const int WM_RBUTTONDOWN = 0x204; - private const int WM_RBUTTONUP = 0x205; - private const int WM_RBUTTONDBLCLK = 0x206; - private const int WM_MBUTTONDOWN = 0x207; - private const int WM_MBUTTONUP = 0x208; - private const int WM_MBUTTONDBLCLK = 0x209; - private const int WM_TRAYMOUSEMESSAGE = 0x800; - - private const int NIN_BALLOONSHOW = 0x402; - private const int NIN_BALLOONHIDE = 0x403; - private const int NIN_BALLOONTIMEOUT = 0x404; - private const int NIN_BALLOONUSERCLICK = 0x405; - - private static readonly int _wmTaskBarCreated = NativeMethods.RegisterWindowMessage("TaskbarCreated"); - - private static class NativeMethods - { - private const string DllNameUser32 = "user32.dll"; - private const string DllNameShell32 = "shell32.dll"; - - [DllImport(DllNameUser32, CharSet = CharSet.Auto)] - public static extern IntPtr PostMessage(HandleRef hwnd, int msg, int wparam, int lparam); - - [DllImport(DllNameUser32, CharSet = CharSet.Auto)] - public static extern int RegisterWindowMessage(string msg); - - [Flags] - public enum NotifyIconDataFlags : int - { - Message = 0x1, - Icon = 0x2, - Tip = 0x4, - State = 0x8, - Info = 0x10 - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - public class NotifyIconData - { - private int _size = Marshal.SizeOf(typeof(NotifyIconData)); - public IntPtr Window; - public int ID; - public NotifyIconDataFlags Flags; - public int CallbackMessage; - public IntPtr Icon; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] - public string Tip; - public int State; - public int StateMask; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string Info; - public int TimeoutOrVersion; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] - public string InfoTitle; - public int InfoFlags; - } - - public enum NotifyIconMessage : int - { - Add = 0x0, - Modify = 0x1, - Delete = 0x2 - } - - [DllImport(DllNameShell32, CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool Shell_NotifyIcon(NotifyIconMessage message, NotifyIconData pnid); - - [DllImport(DllNameUser32, CharSet = CharSet.Auto, ExactSpelling = true)] - public static extern bool TrackPopupMenuEx(HandleRef hmenu, int fuFlags, int x, int y, HandleRef hwnd, IntPtr tpm); - - [StructLayout(LayoutKind.Sequential)] - public struct Point - { - public readonly int X; - public readonly int Y; - } - - [DllImport(DllNameUser32, CharSet = CharSet.Auto, ExactSpelling = true)] - public static extern bool GetCursorPos(ref Point point); - - [DllImport(DllNameUser32, CharSet = CharSet.Auto, ExactSpelling = true)] - public static extern bool SetForegroundWindow(HandleRef hWnd); - } - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/ParameterForm.Designer.cs b/LibreHardwareMonitor.Windows.Forms/UI/ParameterForm.Designer.cs deleted file mode 100644 index ed08b02..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/ParameterForm.Designer.cs +++ /dev/null @@ -1,202 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -namespace LibreHardwareMonitor.Windows.Forms.UI -{ - partial class ParameterForm - { - /// - /// 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 Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.captionLabel = new System.Windows.Forms.Label(); - this.dataGridView = new System.Windows.Forms.DataGridView(); - this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Default = new System.Windows.Forms.DataGridViewCheckBoxColumn(); - this.ValueColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.bindingSource = new System.Windows.Forms.BindingSource(this.components); - this.descriptionLabel = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit(); - this.SuspendLayout(); - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(186, 213); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 2; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.OkButton_Click); - // - // cancelButton - // - this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(267, 213); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 3; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - // - // captionLabel - // - this.captionLabel.AutoSize = true; - this.captionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.captionLabel.Location = new System.Drawing.Point(12, 9); - this.captionLabel.Name = "captionLabel"; - this.captionLabel.Size = new System.Drawing.Size(80, 13); - this.captionLabel.TabIndex = 4; - this.captionLabel.Text = "captionLabel"; - // - // dataGridView - // - this.dataGridView.AllowUserToAddRows = false; - this.dataGridView.AllowUserToDeleteRows = false; - this.dataGridView.AllowUserToResizeRows = false; - this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.dataGridView.AutoGenerateColumns = false; - this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Window; - this.dataGridView.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.NameColumn, - this.Default, - this.ValueColumn}); - this.dataGridView.DataSource = this.bindingSource; - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dataGridView.DefaultCellStyle = dataGridViewCellStyle2; - this.dataGridView.Location = new System.Drawing.Point(15, 30); - this.dataGridView.MultiSelect = false; - this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowHeadersVisible = false; - this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView.ShowRowErrors = false; - this.dataGridView.Size = new System.Drawing.Size(327, 121); - this.dataGridView.TabIndex = 0; - this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellEndEdit); - this.dataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.DataGridView_CellValidating); - this.dataGridView.CurrentCellDirtyStateChanged += new System.EventHandler(this.DataGridView_CurrentCellDirtyStateChanged); - this.dataGridView.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_RowEnter); - // - // NameColumn - // - this.NameColumn.DataPropertyName = "Name"; - this.NameColumn.HeaderText = "Name"; - this.NameColumn.Name = "NameColumn"; - this.NameColumn.ReadOnly = true; - this.NameColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - // - // Default - // - this.Default.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; - this.Default.DataPropertyName = "Default"; - this.Default.HeaderText = "Default"; - this.Default.Name = "Default"; - this.Default.Width = 47; - // - // ValueColumn - // - this.ValueColumn.DataPropertyName = "Value"; - this.ValueColumn.HeaderText = "Value"; - this.ValueColumn.Name = "ValueColumn"; - this.ValueColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - // - // bindingSource - // - this.bindingSource.AllowNew = false; - // - // descriptionLabel - // - this.descriptionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.descriptionLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.descriptionLabel.Location = new System.Drawing.Point(15, 154); - this.descriptionLabel.Name = "descriptionLabel"; - this.descriptionLabel.Padding = new System.Windows.Forms.Padding(2); - this.descriptionLabel.Size = new System.Drawing.Size(327, 50); - this.descriptionLabel.TabIndex = 6; - this.descriptionLabel.Text = "descriptionLabel"; - // - // ParameterForm - // - this.AcceptButton = this.okButton; - this.AccessibleName = ""; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(354, 248); - this.Controls.Add(this.descriptionLabel); - this.Controls.Add(this.dataGridView); - this.Controls.Add(this.captionLabel); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ParameterForm"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Parameters"; - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - public System.Windows.Forms.Label captionLabel; - private System.Windows.Forms.DataGridView dataGridView; - private System.Windows.Forms.Label descriptionLabel; - private System.Windows.Forms.BindingSource bindingSource; - private System.Windows.Forms.DataGridViewTextBoxColumn NameColumn; - private System.Windows.Forms.DataGridViewCheckBoxColumn Default; - private System.Windows.Forms.DataGridViewTextBoxColumn ValueColumn; - - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/ParameterForm.cs b/LibreHardwareMonitor.Windows.Forms/UI/ParameterForm.cs deleted file mode 100644 index 084c28a..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/ParameterForm.cs +++ /dev/null @@ -1,135 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Windows.Forms; -using LibreHardwareMonitor.Hardware; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public partial class ParameterForm : Form -{ - private IReadOnlyList _parameters; - private BindingList _parameterRows; - - public ParameterForm() - { - InitializeComponent(); - } - - public IReadOnlyList Parameters - { - get - { - return _parameters; - } - set - { - _parameters = value; - _parameterRows = new BindingList(); - - foreach (IParameter parameter in _parameters) - { - _parameterRows.Add(new ParameterRow(parameter)); - } - - bindingSource.DataSource = _parameterRows; - } - } - - private class ParameterRow : INotifyPropertyChanged - { - public readonly IParameter Parameter; - private float _value = float.NaN; - private bool _default = true; - - public event PropertyChangedEventHandler PropertyChanged; - - private void NotifyPropertyChanged(String propertyName) - { - if (PropertyChanged != null) - PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - - public ParameterRow(IParameter parameter) - { - Parameter = parameter; - Value = parameter.Value; - Default = parameter.IsDefault; - } - - public string Name - { - get { return Parameter.Name; } - } - - public float Value - { - get { return _value; } - set - { - _default = false; - _value = value; - NotifyPropertyChanged(nameof(Default)); - NotifyPropertyChanged(nameof(Value)); - } - } - - public bool Default - { - get { return _default; } - set - { - _default = value; - if (_default) - _value = Parameter.DefaultValue; - NotifyPropertyChanged(nameof(Default)); - NotifyPropertyChanged(nameof(Value)); - } - } - } - - private void DataGridView_RowEnter(object sender, DataGridViewCellEventArgs e) - { - if (e.RowIndex >= 0 && e.RowIndex < _parameters.Count) - descriptionLabel.Text = _parameters[e.RowIndex].Description; - else - descriptionLabel.Text = string.Empty; - } - - private void DataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) - { - if (e.ColumnIndex == 2 && !float.TryParse(e.FormattedValue.ToString(), out float _)) - { - dataGridView.Rows[e.RowIndex].Cells[0].ErrorText = "Invalid value"; - e.Cancel = true; - } - } - - private void DataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) - { - dataGridView.Rows[e.RowIndex].Cells[0].ErrorText = string.Empty; - } - - private void OkButton_Click(object sender, EventArgs e) - { - foreach (ParameterRow row in _parameterRows) - { - if (row.Default) - row.Parameter.IsDefault = true; - else - row.Parameter.Value = row.Value; - } - } - - private void DataGridView_CurrentCellDirtyStateChanged(object sender, EventArgs e) - { - if (dataGridView.CurrentCell is DataGridViewCheckBoxCell || dataGridView.CurrentCell is DataGridViewComboBoxCell) - dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit); - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/ParameterForm.resx b/LibreHardwareMonitor.Windows.Forms/UI/ParameterForm.resx deleted file mode 100644 index 64a7248..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/ParameterForm.resx +++ /dev/null @@ -1,132 +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 - - - True - - - True - - - True - - - 17, 17 - - \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/PlotPanel.cs b/LibreHardwareMonitor.Windows.Forms/UI/PlotPanel.cs deleted file mode 100644 index b050b53..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/PlotPanel.cs +++ /dev/null @@ -1,463 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using LibreHardwareMonitor.Hardware; -using LibreHardwareMonitor.Windows.Forms.Utilities; -using OxyPlot; -using OxyPlot.Annotations; -using OxyPlot.Axes; -using OxyPlot.WindowsForms; -using OxyPlot.Series; -using LibreHardwareMonitor.Windows.Forms.UI.Themes; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class PlotPanel : UserControl -{ - private readonly PersistentSettings _settings; - private readonly UnitManager _unitManager; - private readonly PlotView _plot; - private readonly PlotModel _model; - private readonly TimeSpanAxis _timeAxis = new TimeSpanAxis(); - private readonly SortedDictionary _axes = new SortedDictionary(); - private readonly Dictionary _annotations = new Dictionary(); - private UserOption _stackedAxes; - private UserOption _showAxesLabels; - private UserOption _timeAxisEnableZoom; - private UserOption _yAxesEnableZoom; - private DateTime _now; - private float _dpiX; - private float _dpiY; - private double _dpiXScale = 1; - private double _dpiYScale = 1; - private Point _rightClickEnter; - private bool _cancelContextMenu = false; - - public PlotPanel(PersistentSettings settings, UnitManager unitManager) - { - _settings = settings; - _unitManager = unitManager; - - SetDpi(); - _model = CreatePlotModel(); - - _plot = new PlotView { Dock = DockStyle.Fill, Model = _model, BackColor = Color.Black, ContextMenuStrip = CreateMenu() }; - _plot.MouseDown += (sender, e) => - { - if (e.Button == MouseButtons.Right) - { - _rightClickEnter = e.Location; - } - }; - _plot.MouseMove += (sender, e) => - { - if (e.Button == MouseButtons.Right) - { - if (!_cancelContextMenu && e.Location.DistanceTo(_rightClickEnter) > 10.0f) - { - _cancelContextMenu = true; - } - } - }; - - UpdateAxesPosition(); - - SuspendLayout(); - Controls.Add(_plot); - ResumeLayout(true); - _plot.ShowTracker(new TrackerHitResult()); - _plot.HideTracker(); - foreach (Control plotControl in _plot.Controls) - { - plotControl.BackColor = Theme.Current.PlotBackgroundColor; - plotControl.ForeColor = Theme.Current.PlotTextColor; - } - ApplyTheme(); - } - - public void ApplyTheme() - { - _model.Background = Theme.Current.PlotBackgroundColor.ToOxyColor(); - _model.PlotAreaBorderColor = Theme.Current.PlotBorderColor.ToOxyColor(); - foreach (Axis axis in _model.Axes) - { - axis.AxislineColor = Theme.Current.PlotBorderColor.ToOxyColor(); - axis.MajorGridlineColor = Theme.Current.PlotGridMajorColor.ToOxyColor(); - axis.MinorGridlineColor = Theme.Current.PlotGridMinorColor.ToOxyColor(); - axis.TextColor = Theme.Current.PlotTextColor.ToOxyColor(); - axis.TitleColor = Theme.Current.PlotTextColor.ToOxyColor(); - axis.MinorTicklineColor = Theme.Current.PlotBorderColor.ToOxyColor(); - axis.TicklineColor = Theme.Current.PlotBorderColor.ToOxyColor(); - } - foreach (LineAnnotation annotation in _model.Annotations.Select(x => x as LineAnnotation).Where(x => x != null)) - { - annotation.Color = Theme.Current.PlotBorderColor.ToOxyColor(); - } - } - - public void SetCurrentSettings() - { - foreach (LinearAxis axis in _axes.Values) - { - _settings.SetValue("plotPanel.Min" + axis.Key, (float)axis.ActualMinimum); - _settings.SetValue("plotPanel.Max" + axis.Key, (float)axis.ActualMaximum); - } - _settings.SetValue("plotPanel.MinTimeSpan", (float)_timeAxis.ActualMinimum); - _settings.SetValue("plotPanel.MaxTimeSpan", (float)_timeAxis.ActualMaximum); - } - - private ContextMenuStrip CreateMenu() - { - ContextMenuStrip menu = new ContextMenuStrip(); - menu.Renderer = new ThemedToolStripRenderer(); - menu.Opening += (sender, e) => - { - if (_cancelContextMenu) - { - e.Cancel = true; - _cancelContextMenu = false; - } - }; - - ToolStripMenuItem stackedAxesMenuItem = new ToolStripMenuItem("Stacked Axes"); - _stackedAxes = new UserOption("stackedAxes", true, stackedAxesMenuItem, _settings); - _stackedAxes.Changed += (sender, e) => - { - UpdateAxesPosition(); - InvalidatePlot(); - }; - menu.Items.Add(stackedAxesMenuItem); - - ToolStripMenuItem showAxesLabelsMenuItem = new ToolStripMenuItem("Show Axes Labels"); - _showAxesLabels = new UserOption("showAxesLabels", true, showAxesLabelsMenuItem, _settings); - _showAxesLabels.Changed += (sender, e) => - { - if (_showAxesLabels.Value) - _model.PlotMargins = new OxyThickness(double.NaN); - else - _model.PlotMargins = new OxyThickness(0); - }; - menu.Items.Add(showAxesLabelsMenuItem); - - ToolStripMenuItem timeAxisMenuItem = new ToolStripMenuItem("Time Axis"); - ToolStripMenuItem[] timeAxisMenuItems = - { new ToolStripMenuItem("Enable Zoom"), - new ToolStripMenuItem("Auto", null, (s, e) => { TimeAxisZoom(0, double.NaN); }), - new ToolStripMenuItem("5 min", null, (s, e) => { TimeAxisZoom(0, 5 * 60); }), - new ToolStripMenuItem("10 min", null, (s, e) => { TimeAxisZoom(0, 10 * 60); }), - new ToolStripMenuItem("20 min", null, (s, e) => { TimeAxisZoom(0, 20 * 60); }), - new ToolStripMenuItem("30 min", null, (s, e) => { TimeAxisZoom(0, 30 * 60); }), - new ToolStripMenuItem("45 min", null, (s, e) => { TimeAxisZoom(0, 45 * 60); }), - new ToolStripMenuItem("1 h", null, (s, e) => { TimeAxisZoom(0, 60 * 60); }), - new ToolStripMenuItem("1.5 h", null, (s, e) => { TimeAxisZoom(0, 1.5 * 60 * 60); }), - new ToolStripMenuItem("2 h", null, (s, e) => { TimeAxisZoom(0, 2 * 60 * 60); }), - new ToolStripMenuItem("3 h", null, (s, e) => { TimeAxisZoom(0, 3 * 60 * 60); }), - new ToolStripMenuItem("6 h", null, (s, e) => { TimeAxisZoom(0, 6 * 60 * 60); }), - new ToolStripMenuItem("12 h", null, (s, e) => { TimeAxisZoom(0, 12 * 60 * 60); }), - new ToolStripMenuItem("24 h", null, (s, e) => { TimeAxisZoom(0, 24 * 60 * 60); }) }; - - foreach (ToolStripItem mi in timeAxisMenuItems) - timeAxisMenuItem.DropDownItems.Add(mi); - menu.Items.Add(timeAxisMenuItem); - - _timeAxisEnableZoom = new UserOption("timeAxisEnableZoom", true, timeAxisMenuItems[0], _settings); - _timeAxisEnableZoom.Changed += (sender, e) => - { - _timeAxis.IsZoomEnabled = _timeAxisEnableZoom.Value; - }; - - ToolStripMenuItem yAxesMenuItem = new ToolStripMenuItem("Value Axes"); - ToolStripMenuItem[] yAxesMenuItems = - { new ToolStripMenuItem("Enable Zoom"), - new ToolStripMenuItem("Autoscale All", null, (s, e) => { AutoscaleAllYAxes(); }) }; - - foreach (ToolStripItem mi in yAxesMenuItems) - yAxesMenuItem.DropDownItems.Add(mi); - menu.Items.Add(yAxesMenuItem); - - _yAxesEnableZoom = new UserOption("yAxesEnableZoom", true, yAxesMenuItems[0], _settings); - _yAxesEnableZoom.Changed += (sender, e) => - { - foreach (LinearAxis axis in _axes.Values) - axis.IsZoomEnabled = _yAxesEnableZoom.Value; - }; - - return menu; - } - - private PlotModel CreatePlotModel() - { - _timeAxis.Position = AxisPosition.Bottom; - _timeAxis.MajorGridlineStyle = LineStyle.Solid; - _timeAxis.MajorGridlineThickness = 1; - _timeAxis.MajorGridlineColor = OxyColor.FromRgb(192, 192, 192); - _timeAxis.MinorGridlineStyle = LineStyle.Solid; - _timeAxis.MinorGridlineThickness = 1; - _timeAxis.MinorGridlineColor = OxyColor.FromRgb(232, 232, 232); - _timeAxis.StartPosition = 1; - _timeAxis.EndPosition = 0; - _timeAxis.MinimumPadding = 0; - _timeAxis.MaximumPadding = 0; - _timeAxis.AbsoluteMinimum = 0; - _timeAxis.Minimum = 0; - _timeAxis.AbsoluteMaximum = 24 * 60 * 60; - _timeAxis.Zoom( - _settings.GetValue("plotPanel.MinTimeSpan", 0.0f), - _settings.GetValue("plotPanel.MaxTimeSpan", 10.0f * 60)); - _timeAxis.StringFormat = "h:mm"; - - var units = new Dictionary - { - { SensorType.Voltage, "V" }, - { SensorType.Current, "A" }, - { SensorType.Clock, "MHz" }, - { SensorType.Temperature, "°C" }, - { SensorType.Load, "%" }, - { SensorType.Fan, "RPM" }, - { SensorType.Flow, "L/h" }, - { SensorType.Control, "%" }, - { SensorType.Level, "%" }, - { SensorType.Factor, "1" }, - { SensorType.Power, "W" }, - { SensorType.Data, "GB" }, - { SensorType.Frequency, "Hz" }, - { SensorType.Energy, "mWh" }, - { SensorType.Noise, "dBA" }, - { SensorType.Conductivity, "µS/cm" }, - { SensorType.Humidity, "%" } - }; - - foreach (SensorType type in Enum.GetValues(typeof(SensorType))) - { - string typeName = type.ToString(); - var axis = new LinearAxis - { - Position = AxisPosition.Left, - MajorGridlineStyle = LineStyle.Solid, - MajorGridlineThickness = 1, - MajorGridlineColor = _timeAxis.MajorGridlineColor, - MinorGridlineStyle = LineStyle.Solid, - MinorGridlineThickness = 1, - MinorGridlineColor = _timeAxis.MinorGridlineColor, - AxislineStyle = LineStyle.Solid, - Title = typeName, - Key = typeName, - }; - - var annotation = new LineAnnotation - { - Type = LineAnnotationType.Horizontal, - ClipByXAxis = false, - ClipByYAxis = false, - LineStyle = LineStyle.Solid, - Color = Theme.Current.PlotBorderColor.ToOxyColor(), - YAxisKey = typeName, - StrokeThickness = 2, - }; - -#pragma warning disable CS0618 //obsolete warning - - axis.AxisChanged += (sender, args) => annotation.Y = axis.ActualMinimum; - axis.TransformChanged += (sender, args) => annotation.Y = axis.ActualMinimum; - -#pragma warning restore CS0618 //obsolete warning - - axis.Zoom(_settings.GetValue("plotPanel.Min" + axis.Key, float.NaN), _settings.GetValue("plotPanel.Max" + axis.Key, float.NaN)); - - if (units.ContainsKey(type)) - axis.Unit = units[type]; - - _axes.Add(type, axis); - _annotations.Add(type, annotation); - } - - var model = new ScaledPlotModel(_dpiXScale, _dpiYScale); - model.Axes.Add(_timeAxis); - foreach (LinearAxis axis in _axes.Values) - model.Axes.Add(axis); - model.IsLegendVisible = false; - - return model; - } - - private void SetDpi() - { - // https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266(v=vs.85).aspx - const int defaultDpi = 96; - Graphics g = CreateGraphics(); - - try - { - _dpiX = g.DpiX; - _dpiY = g.DpiY; - } - finally - { - g.Dispose(); - } - - if (_dpiX > 0) - _dpiXScale = _dpiX / defaultDpi; - if (_dpiY > 0) - _dpiYScale = _dpiY / defaultDpi; - } - - public void SetSensors(List sensors, IDictionary colors, double strokeThickness) - { - _model.Series.Clear(); - var types = new HashSet(); - - - DataPoint CreateDataPoint(SensorType type, SensorValue value) - { - float displayedValue; - - if (type == SensorType.Temperature && _unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) - { - displayedValue = UnitManager.CelsiusToFahrenheit(value.Value).Value; - } - else - { - displayedValue = value.Value; - } - - return new DataPoint((_now - value.Time).TotalSeconds, displayedValue); - } - - - foreach (ISensor sensor in sensors) - { - var series = new LineSeries - { - ItemsSource = sensor.Values.Select(value => CreateDataPoint(sensor.SensorType, value)), - Color = colors[sensor].ToOxyColor(), - StrokeThickness = strokeThickness, - YAxisKey = _axes[sensor.SensorType].Key, - Title = sensor.Hardware.Name + " " + sensor.Name - }; - - _model.Series.Add(series); - - types.Add(sensor.SensorType); - } - - foreach (KeyValuePair pair in _axes.Reverse()) - { - LinearAxis axis = pair.Value; - SensorType type = pair.Key; - axis.IsAxisVisible = types.Contains(type); - } - - UpdateAxesPosition(); - InvalidatePlot(); - } - - public void UpdateStrokeThickness(double strokeThickness) - { - foreach (LineSeries series in _model.Series) - { - series.StrokeThickness = strokeThickness; - } - InvalidatePlot(); - } - - private void UpdateAxesPosition() - { - if (_stackedAxes.Value) - { - int count = _axes.Values.Count(axis => axis.IsAxisVisible); - double start = 0.0; - foreach (KeyValuePair pair in _axes.Reverse()) - { - LinearAxis axis = pair.Value; - axis.StartPosition = start; - double delta = axis.IsAxisVisible ? 1.0 / count : 0; - start += delta; - axis.EndPosition = start; - axis.PositionTier = 0; - axis.MajorGridlineStyle = LineStyle.Solid; - axis.MinorGridlineStyle = LineStyle.Solid; - LineAnnotation annotation = _annotations[pair.Key]; - annotation.Y = axis.ActualMinimum; - if (!_model.Annotations.Contains(annotation)) - _model.Annotations.Add(annotation); - } - } - else - { - int tier = 0; - - foreach (KeyValuePair pair in _axes.Reverse()) - { - LinearAxis axis = pair.Value; - - if (axis.IsAxisVisible) - { - axis.StartPosition = 0; - axis.EndPosition = 1; - axis.PositionTier = tier; - tier++; - } - else - { - axis.StartPosition = 0; - axis.EndPosition = 0; - axis.PositionTier = 0; - } - axis.MajorGridlineStyle = LineStyle.None; - axis.MinorGridlineStyle = LineStyle.None; - LineAnnotation annotation = _annotations[pair.Key]; - if (_model.Annotations.Contains(annotation)) - _model.Annotations.Remove(_annotations[pair.Key]); - } - } - } - - public void InvalidatePlot() - { - _now = DateTime.UtcNow; - - if (_axes != null) - { - foreach (KeyValuePair pair in _axes) - { - LinearAxis axis = pair.Value; - SensorType type = pair.Key; - if (type == SensorType.Temperature) - axis.Unit = _unitManager.TemperatureUnit == TemperatureUnit.Celsius ? "°C" : "°F"; - - if (!_stackedAxes.Value) - continue; - - var annotation = _annotations[pair.Key]; - annotation.Y = axis.ActualMaximum; - } - } - - _plot?.InvalidatePlot(true); - } - - public void TimeAxisZoom(double min, double max) - { - bool timeAxisIsZoomEnabled = _timeAxis.IsZoomEnabled; - - _timeAxis.IsZoomEnabled = true; - _timeAxis.Zoom(min, max); - InvalidatePlot(); - _timeAxis.IsZoomEnabled = timeAxisIsZoomEnabled; - } - - public void AutoscaleAllYAxes() - { - foreach (LinearAxis axis in _axes.Values) - axis.Zoom(double.NaN, double.NaN); - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/ScaledPlotModel.cs b/LibreHardwareMonitor.Windows.Forms/UI/ScaledPlotModel.cs deleted file mode 100644 index 9e1b89d..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/ScaledPlotModel.cs +++ /dev/null @@ -1,33 +0,0 @@ -using OxyPlot; -using OxyPlot.Legends; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -class ScaledPlotModel : PlotModel -{ - public ScaledPlotModel(double dpiXscale, double dpiYscale) - { - PlotMargins = new OxyThickness(PlotMargins.Left * dpiXscale, - PlotMargins.Top * dpiYscale, - PlotMargins.Right * dpiXscale, - PlotMargins.Bottom * dpiYscale); - - Padding = new OxyThickness(Padding.Left * dpiXscale, - Padding.Top * dpiYscale, - Padding.Right * dpiXscale, - Padding.Bottom * dpiYscale); - - TitlePadding *= dpiXscale; - - Legend legend = new(); - - legend.LegendSymbolLength *= dpiXscale; - legend.LegendSymbolMargin *= dpiXscale; - legend.LegendPadding *= dpiXscale; - legend.LegendColumnSpacing *= dpiXscale; - legend.LegendItemSpacing *= dpiXscale; - legend.LegendMargin *= dpiXscale; - - Legends.Add(legend); - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/SensorGadget.cs b/LibreHardwareMonitor.Windows.Forms/UI/SensorGadget.cs deleted file mode 100644 index 3162906..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/SensorGadget.cs +++ /dev/null @@ -1,1347 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.Windows.Forms; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using LibreHardwareMonitor.Hardware; -using LibreHardwareMonitor.Windows.Forms.UI.Themes; -using LibreHardwareMonitor.Windows.Forms.Utilities; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class SensorGadget : Gadget -{ - private const int TopBorder = 6; - private const int BottomBorder = 7; - private const int LeftBorder = 6; - private const int RightBorder = 7; - - private readonly UnitManager _unitManager; - private Image _back = Utilities.EmbeddedResources.GetImage("gadget.png"); - private Image _image; - private Image _fore; - private Image _barBack = Utilities.EmbeddedResources.GetImage("barback.png"); - private Image _barFore = Utilities.EmbeddedResources.GetImage("bar.png"); - private bool _customBarBack; - private bool _customBarFore; - private Image _backTinted; - private Image _barBackTinted; - private Image _barForeTinted; - private Image _background = new Bitmap(1, 1); - private bool _backgroundDirty = true; - private readonly float _scale; - private float _fontSize; - private int _iconSize; - private int _hardwareLineHeight; - private int _sensorLineHeight; - private int _rightMargin; - private int _leftMargin; - private int _topMargin; - private int _bottomMargin; - private int _progressWidth; - - private readonly IDictionary> _sensors = new SortedDictionary>(new HardwareComparer()); - private readonly PersistentSettings _settings; - private readonly UserOption _hardwareNames; - - private Font _largeFont; - private Font _smallFont; - private Brush _textBrush; - private StringFormat _stringFormat; - private StringFormat _trimStringFormat; - private StringFormat _alignRightStringFormat; - private Color _fontColor; - private Color _backgroundColor; - private readonly System.Threading.SynchronizationContext _uiSyncContext; - - public SensorGadget(IComputer computer, PersistentSettings settings, UnitManager unitManager) - { - _unitManager = unitManager; - _settings = settings; - // Captured on the UI thread so the now-possibly-background HardwareAdded/HardwareRemoved re-dispatch here. - _uiSyncContext = System.Threading.SynchronizationContext.Current; - computer.HardwareAdded += HardwareAdded; - computer.HardwareRemoved += HardwareRemoved; - - _stringFormat = new StringFormat { FormatFlags = StringFormatFlags.NoWrap }; - _trimStringFormat = new StringFormat { Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap }; - _alignRightStringFormat = new StringFormat { Alignment = StringAlignment.Far, FormatFlags = StringFormatFlags.NoWrap }; - - if (File.Exists("gadget_background.png")) - { - try - { - Image newBack = new Bitmap("gadget_background.png"); - _back.Dispose(); - _back = newBack; - } - catch { } - } - - if (File.Exists("gadget_image.png")) - { - try - { - _image = new Bitmap("gadget_image.png"); - } - catch { } - } - - if (File.Exists("gadget_foreground.png")) - { - try - { - _fore = new Bitmap("gadget_foreground.png"); - } - catch { } - } - - if (File.Exists("gadget_bar_background.png")) - { - try - { - Image newBarBack = new Bitmap("gadget_bar_background.png"); - _barBack.Dispose(); - _barBack = newBarBack; - _customBarBack = true; - } - catch { } - } - - if (File.Exists("gadget_bar_foreground.png")) - { - try - { - Image newBarColor = new Bitmap("gadget_bar_foreground.png"); - _barFore.Dispose(); - _barFore = newBarColor; - _customBarFore = true; - } - catch { } - } - - Location = new Point(settings.GetValue("sensorGadget.Location.X", 100), settings.GetValue("sensorGadget.Location.Y", 100)); - LocationChanged += delegate - { - settings.SetValue("sensorGadget.Location.X", Location.X); - settings.SetValue("sensorGadget.Location.Y", Location.Y); - }; - - // get the custom to default dpi ratio - using (Bitmap b = new Bitmap(1, 1)) - { - _scale = b.HorizontalResolution / 96.0f; - } - - SetFontSize(settings.GetValue("sensorGadget.FontSize", 7.5f)); - Resize(settings.GetValue("sensorGadget.Width", Size.Width)); - - ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); - ToolStripMenuItem hardwareNamesItem = new ToolStripMenuItem("Hardware Names"); - contextMenuStrip.Items.Add(hardwareNamesItem); - ToolStripMenuItem fontSizeMenu = new ToolStripMenuItem("Font Size"); - for (int i = 0; i < 5; i++) - { - float size; - string name; - switch (i) - { - case 0: size = 6.5f; name = "Small"; break; - case 1: size = 7.5f; name = "Medium"; break; - case 2: size = 9f; name = "Large"; break; - case 3: size = 11f; name = "Very Large"; break; - case 4: size = 22f; name = "Extremely Large"; break; - default: throw new NotImplementedException(); - } - - ToolStripItem item = new ToolStripMenuItem(name) { Checked = _fontSize == size }; - item.Click += delegate - { - SetFontSize(size); - settings.SetValue("sensorGadget.FontSize", size); - foreach (ToolStripMenuItem mi in fontSizeMenu.DropDownItems) - mi.Checked = mi == item; - }; - fontSizeMenu.DropDownItems.Add(item); - } - contextMenuStrip.Items.Add(fontSizeMenu); - - Color fontColor = settings.GetValue("sensorGadget.FontColor", Color.White); - SetFontColor(fontColor); - - ToolStripMenuItem fontColorMenu = new ToolStripMenuItem("Font Color"); - ToolStripItem chooseFontColorItem = new ToolStripMenuItem("Choose..."); - chooseFontColorItem.Click += delegate - { - if (TrySelectColor(fontColor, out Color selectedColor)) - { - fontColor = selectedColor; - SetFontColor(fontColor); - settings.SetValue("sensorGadget.FontColor", fontColor); - Redraw(); - } - }; - fontColorMenu.DropDownItems.Add(chooseFontColorItem); - - ToolStripItem defaultFontColorItem = new ToolStripMenuItem("Default"); - defaultFontColorItem.Click += delegate - { - fontColor = Color.White; - SetFontColor(fontColor); - settings.Remove("sensorGadget.FontColor"); - Redraw(); - }; - fontColorMenu.DropDownItems.Add(defaultFontColorItem); - contextMenuStrip.Items.Add(fontColorMenu); - - Color backgroundColor = settings.GetValue("sensorGadget.BackgroundColor", Color.FromArgb(0)); - SetBackgroundColor(backgroundColor); - - ToolStripMenuItem backgroundColorMenu = new ToolStripMenuItem("Background Color"); - ToolStripItem chooseBackgroundItem = new ToolStripMenuItem("Choose..."); - chooseBackgroundItem.Click += delegate - { - if (TrySelectColor(backgroundColor.A == 0 ? Color.White : backgroundColor, out Color selectedColor)) - { - backgroundColor = selectedColor; - SetBackgroundColor(backgroundColor); - settings.SetValue("sensorGadget.BackgroundColor", backgroundColor); - } - }; - backgroundColorMenu.DropDownItems.Add(chooseBackgroundItem); - - ToolStripItem defaultBackgroundItem = new ToolStripMenuItem("Default"); - defaultBackgroundItem.Click += delegate - { - Color color = Color.FromArgb(0); - backgroundColor = color; - SetBackgroundColor(color); - settings.Remove("sensorGadget.BackgroundColor"); - }; - backgroundColorMenu.DropDownItems.Add(defaultBackgroundItem); - contextMenuStrip.Items.Add(backgroundColorMenu); - contextMenuStrip.Items.Add(new ToolStripSeparator()); - ToolStripMenuItem lockItem = new ToolStripMenuItem("Lock Position and Size"); - contextMenuStrip.Items.Add(lockItem); - contextMenuStrip.Items.Add(new ToolStripSeparator()); - ToolStripMenuItem alwaysOnTopItem = new ToolStripMenuItem("Always on Top"); - contextMenuStrip.Items.Add(alwaysOnTopItem); - ToolStripMenuItem opacityMenu = new ToolStripMenuItem("Opacity"); - contextMenuStrip.Items.Add(opacityMenu); - Opacity = (byte)settings.GetValue("sensorGadget.Opacity", 255); - - for (int i = 0; i < 5; i++) - { - ToolStripMenuItem item = new ToolStripMenuItem((20 * (i + 1)).ToString() + " %"); - byte o = (byte)(51 * (i + 1)); - item.Checked = Opacity == o; - item.Click += delegate - { - Opacity = o; - settings.SetValue("sensorGadget.Opacity", Opacity); - foreach (ToolStripMenuItem mi in opacityMenu.DropDownItems) - mi.Checked = mi == item; - }; - opacityMenu.DropDownItems.Add(item); - } - - contextMenuStrip.Items.Add(new ToolStripSeparator()); - ToolStripMenuItem hideShowItem = new ToolStripMenuItem("Hide/Show Main Window"); - contextMenuStrip.Items.Add(hideShowItem); - - ContextMenuStrip = contextMenuStrip; - - _hardwareNames = new UserOption("sensorGadget.Hardwarenames", true, hardwareNamesItem, settings); - _hardwareNames.Changed += delegate - { - Resize(); - }; - - UserOption alwaysOnTop = new UserOption("sensorGadget.AlwaysOnTop", false, alwaysOnTopItem, settings); - alwaysOnTop.Changed += delegate - { - AlwaysOnTop = alwaysOnTop.Value; - }; - UserOption lockPositionAndSize = new UserOption("sensorGadget.LockPositionAndSize", false, lockItem, settings); - lockPositionAndSize.Changed += delegate - { - LockPositionAndSize = lockPositionAndSize.Value; - }; - - hideShowItem.Click += delegate - { - SendHideShowCommand(); - }; - - HitTest += delegate (object sender, HitTestEventArgs e) - { - if (lockPositionAndSize.Value) - return; - - if (e.Location.X < LeftBorder) - { - e.HitResult = HitResult.Left; - return; - } - if (e.Location.X > Size.Width - 1 - RightBorder) - { - e.HitResult = HitResult.Right; - } - }; - - SizeChanged += delegate - { - settings.SetValue("sensorGadget.Width", Size.Width); - Redraw(); - }; - - VisibleChanged += delegate - { - Rectangle bounds = new Rectangle(Location, Size); - Screen screen = Screen.FromRectangle(bounds); - Rectangle intersection = Rectangle.Intersect(screen.WorkingArea, bounds); - if (intersection.Width < Math.Min(16, bounds.Width) || intersection.Height < Math.Min(16, bounds.Height)) - { - Location = new Point(screen.WorkingArea.Width / 2 - bounds.Width / 2, screen.WorkingArea.Height / 2 - bounds.Height / 2); - } - }; - - MouseDoubleClick += delegate - { - SendHideShowCommand(); - }; - } - - public override void Dispose() - { - - _largeFont.Dispose(); - _largeFont = null; - - _smallFont.Dispose(); - _smallFont = null; - - _textBrush.Dispose(); - _textBrush = null; - - _stringFormat.Dispose(); - _stringFormat = null; - - _trimStringFormat.Dispose(); - _trimStringFormat = null; - - _alignRightStringFormat.Dispose(); - _alignRightStringFormat = null; - - _back.Dispose(); - _back = null; - - _barFore.Dispose(); - _barFore = null; - - _barBack.Dispose(); - _barBack = null; - - if (_backTinted != null) - { - _backTinted.Dispose(); - _backTinted = null; - } - if (_barForeTinted != null) - { - _barForeTinted.Dispose(); - _barForeTinted = null; - } - if (_barBackTinted != null) - { - _barBackTinted.Dispose(); - _barBackTinted = null; - } - - _background.Dispose(); - _background = null; - - if (_image != null) - { - _image.Dispose(); - _image = null; - } - - if (_fore != null) - { - _fore.Dispose(); - _fore = null; - } - - base.Dispose(); - } - - private void HardwareRemoved(IHardware hardware) - { - if (_uiSyncContext != null && System.Threading.SynchronizationContext.Current != _uiSyncContext) - { - _uiSyncContext.Post(_ => HardwareRemoved(hardware), null); - return; - } - - hardware.SensorAdded -= SensorAdded; - hardware.SensorRemoved -= SensorRemoved; - - foreach (ISensor sensor in hardware.Sensors) - SensorRemoved(sensor); - - foreach (IHardware subHardware in hardware.SubHardware) - HardwareRemoved(subHardware); - } - - private void HardwareAdded(IHardware hardware) - { - if (_uiSyncContext != null && System.Threading.SynchronizationContext.Current != _uiSyncContext) - { - _uiSyncContext.Post(_ => HardwareAdded(hardware), null); - return; - } - - foreach (ISensor sensor in hardware.Sensors) - SensorAdded(sensor); - - hardware.SensorAdded += SensorAdded; - hardware.SensorRemoved += SensorRemoved; - - foreach (IHardware subHardware in hardware.SubHardware) - HardwareAdded(subHardware); - } - - private void SensorAdded(ISensor sensor) - { - if (_settings.GetValue(new Identifier(sensor.Identifier, "gadget").ToString(), false)) - Add(sensor); - } - - private void SensorRemoved(ISensor sensor) - { - if (Contains(sensor)) - Remove(sensor, false); - } - - public bool Contains(ISensor sensor) - { - return _sensors.Values.Any(list => list.Contains(sensor)); - } - - public void Add(ISensor sensor) - { - if (Contains(sensor)) - return; - - - // get the right hardware - IHardware hardware = sensor.Hardware; - while (hardware.Parent != null) - hardware = hardware.Parent; - - // get the sensor list associated with the hardware - if (!_sensors.TryGetValue(hardware, out IList list)) - { - list = new List(); - _sensors.Add(hardware, list); - } - - // insert the sensor at the right position - int i = 0; - while (i < list.Count && (list[i].SensorType < sensor.SensorType || (list[i].SensorType == sensor.SensorType && list[i].Index < sensor.Index))) - i++; - - list.Insert(i, sensor); - - _settings.SetValue(new Identifier(sensor.Identifier, "gadget").ToString(), true); - Resize(); - } - - public void Remove(ISensor sensor) - { - Remove(sensor, true); - } - - private void Remove(ISensor sensor, bool deleteConfig) - { - if (deleteConfig) - _settings.Remove(new Identifier(sensor.Identifier, "gadget").ToString()); - - foreach (KeyValuePair> keyValue in _sensors) - { - if (keyValue.Value.Contains(sensor)) - { - keyValue.Value.Remove(sensor); - if (keyValue.Value.Count == 0) - { - _sensors.Remove(keyValue.Key); - break; - } - } - } - Resize(); - } - - public event EventHandler HideShowCommand; - - public void SendHideShowCommand() - { - HideShowCommand?.Invoke(this, null); - } - - private Font CreateFont(float size, FontStyle style) - { - try - { - return new Font(SystemFonts.MessageBoxFont.FontFamily, size, style); - } - catch (ArgumentException) - { - // if the style is not supported, fall back to the original one - return new Font(SystemFonts.MessageBoxFont.FontFamily, size, - SystemFonts.MessageBoxFont.Style); - } - } - - private void SetFontSize(float size) - { - _fontSize = size; - _largeFont = CreateFont(_fontSize, FontStyle.Bold); - _smallFont = CreateFont(_fontSize, FontStyle.Regular); - - double scaledFontSize = _fontSize * _scale; - _iconSize = (int)Math.Round(1.5 * scaledFontSize); - _hardwareLineHeight = (int)Math.Round(1.66 * scaledFontSize); - _sensorLineHeight = (int)Math.Round(1.33 * scaledFontSize); - _leftMargin = LeftBorder + (int)Math.Round(0.3 * scaledFontSize); - _rightMargin = RightBorder + (int)Math.Round(0.3 * scaledFontSize); - _topMargin = TopBorder; - _bottomMargin = BottomBorder + (int)Math.Round(0.3 * scaledFontSize); - _progressWidth = (int)Math.Round(5.3 * scaledFontSize); - - Resize((int)Math.Round(17.3 * scaledFontSize)); - } - - private void SetFontColor(Color color) - { - _fontColor = color; - _textBrush?.Dispose(); - _textBrush = new SolidBrush(color); - - _barBackTinted?.Dispose(); - _barBackTinted = _customBarBack ? null : CreateBarTint(_barBack, _fontColor); - _barForeTinted?.Dispose(); - _barForeTinted = _customBarFore ? null : CreateBarTint(_barFore, _fontColor); - } - - private void SetBackgroundColor(Color color) - { - _backgroundColor = color; - _backTinted?.Dispose(); - _backTinted = null; - - // Transparent means "Default" and keeps the embedded/custom image as-is. - if (_backgroundColor.A > 0) - { - _backTinted = CreateBackgroundTint(_back, _backgroundColor); - } - - _backgroundDirty = true; - Redraw(); - } - - private static Image CreateBackgroundTint(Image source, Color targetColor) - { - Bitmap sourceBitmap = new Bitmap(source); - Rectangle rect = new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height); - Bitmap workingSource = sourceBitmap.PixelFormat == PixelFormat.Format32bppArgb - ? sourceBitmap - : sourceBitmap.Clone(rect, PixelFormat.Format32bppArgb); - Bitmap result = new Bitmap(workingSource.Width, workingSource.Height, PixelFormat.Format32bppPArgb); - - float targetHue = targetColor.GetHue() / 360f; - float targetSaturation = targetColor.GetSaturation(); - float targetValue = GetColorValue(targetColor); - bool isGrayscaleTarget = targetSaturation <= 0.001f; - - BitmapData srcData = null; - BitmapData dstData = null; - try - { - srcData = workingSource.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); - dstData = result.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppPArgb); - - int srcLength = srcData.Stride * workingSource.Height; - int dstLength = dstData.Stride * result.Height; - byte[] srcBuffer = new byte[srcLength]; - byte[] dstBuffer = new byte[dstLength]; - Marshal.Copy(srcData.Scan0, srcBuffer, 0, srcLength); - - for (int y = 0; y < workingSource.Height; y++) - { - int srcRow = y * srcData.Stride; - int dstRow = y * dstData.Stride; - for (int x = 0; x < workingSource.Width; x++) - { - int srcIndex = srcRow + (x * 4); - int dstIndex = dstRow + (x * 4); - byte b = srcBuffer[srcIndex + 0]; - byte g = srcBuffer[srcIndex + 1]; - byte r = srcBuffer[srcIndex + 2]; - byte a = srcBuffer[srcIndex + 3]; - - if (a == 0) - { - // For PArgb targets, keep fully transparent pixels black. - dstBuffer[dstIndex + 0] = 0; - dstBuffer[dstIndex + 1] = 0; - dstBuffer[dstIndex + 2] = 0; - dstBuffer[dstIndex + 3] = 0; - continue; - } - - Color c = Color.FromArgb(a, r, g, b); - float sourceSaturation = c.GetSaturation(); - float sourceValue = c.GetBrightness(); - float saturation = isGrayscaleTarget - ? 0f - : Math.Min(1f, Math.Max(sourceSaturation * 0.25f, targetSaturation * 0.85f)); - float value = Math.Min(1f, (sourceValue * 0.55f) + (targetValue * 0.45f)); - Color tinted = ColorFromHsv(targetHue, saturation, value, a); - - // Destination format is 32bppPArgb, so RGB must be premultiplied by A. - dstBuffer[dstIndex + 0] = (byte)((tinted.B * tinted.A + 127) / 255); - dstBuffer[dstIndex + 1] = (byte)((tinted.G * tinted.A + 127) / 255); - dstBuffer[dstIndex + 2] = (byte)((tinted.R * tinted.A + 127) / 255); - dstBuffer[dstIndex + 3] = tinted.A; - } - } - - Marshal.Copy(dstBuffer, 0, dstData.Scan0, dstLength); - } - finally - { - if (srcData != null) - workingSource.UnlockBits(srcData); - if (dstData != null) - result.UnlockBits(dstData); - - if (!ReferenceEquals(workingSource, sourceBitmap)) - workingSource.Dispose(); - - sourceBitmap.Dispose(); - } - - return result; - } - - private static Image CreateBarTint(Image source, Color targetColor) - { - Bitmap sourceBitmap = new Bitmap(source); - Bitmap result = new Bitmap(sourceBitmap.Width, sourceBitmap.Height, PixelFormat.Format32bppPArgb); - - for (int y = 0; y < sourceBitmap.Height; y++) - { - for (int x = 0; x < sourceBitmap.Width; x++) - { - Color c = sourceBitmap.GetPixel(x, y); - if (c.A == 0) - { - result.SetPixel(x, y, c); - continue; - } - - // Bars should follow selected text color directly. - // Preserve source alpha for antialiasing/edge transparency. - Color tinted = Color.FromArgb(c.A, targetColor.R, targetColor.G, targetColor.B); - result.SetPixel(x, y, tinted); - } - } - - sourceBitmap.Dispose(); - return result; - } - - private static Color ColorFromHsv(float hue, float saturation, float value, int alpha) - { - if (saturation <= 0) - { - int v = (int)Math.Round(value * 255); - return Color.FromArgb(alpha, v, v, v); - } - - float h = (hue % 1.0f + 1.0f) % 1.0f * 6.0f; - int i = (int)Math.Floor(h); - float f = h - i; - float p = value * (1 - saturation); - float q = value * (1 - saturation * f); - float t = value * (1 - saturation * (1 - f)); - - (float r, float g, float b) = i switch - { - 0 => (value, t, p), - 1 => (q, value, p), - 2 => (p, value, t), - 3 => (p, q, value), - 4 => (t, p, value), - _ => (value, p, q) - }; - - return Color.FromArgb(alpha, - (int)Math.Round(r * 255), - (int)Math.Round(g * 255), - (int)Math.Round(b * 255)); - } - - private static bool TrySelectColor(Color initialColor, out Color selectedColor) - { - using Form form = new Form - { - Text = "Select Color", - FormBorderStyle = FormBorderStyle.Sizable, - StartPosition = FormStartPosition.CenterScreen, - MinimizeBox = false, - MaximizeBox = false, - ClientSize = new Size(460, 340), - MinimumSize = new Size(420, 320), - AutoScaleMode = AutoScaleMode.Font - }; - form.Icon = EmbeddedResources.GetIcon("icon.ico"); - - Panel svBox = new Panel - { - BorderStyle = BorderStyle.FixedSingle, - Cursor = Cursors.Cross - }; - Panel hueBox = new Panel - { - BorderStyle = BorderStyle.FixedSingle, - Cursor = Cursors.Cross - }; - SetDoubleBuffered(svBox); - SetDoubleBuffered(hueBox); - SetDoubleBuffered(form); - - float currentHue = initialColor.GetHue() / 360f; - float currentSaturation = initialColor.GetSaturation(); - float currentValue = GetColorValue(initialColor); - Color current = ColorFromHsv(currentHue, currentSaturation, currentValue, 255); - - int svSelectorX = 0; - int svSelectorY = 0; - int hueSelectorY = 0; - - Panel preview = new Panel - { - Size = new Size(34, 34), - BorderStyle = BorderStyle.FixedSingle, - BackColor = current - }; - - Label hexLabel = new Label - { - AutoSize = true, - Location = new Point(0, 0), - Text = "Hex:" - }; - TextBox hexTextBox = new TextBox - { - Width = 110, - Text = $"#{current.R:X2}{current.G:X2}{current.B:X2}" - }; - - Button okButton = new Button - { - Text = "OK", - DialogResult = DialogResult.OK, - AutoSize = true, - AutoSizeMode = AutoSizeMode.GrowAndShrink, - MinimumSize = new Size(75, 0), - Padding = new Padding(6, 2, 6, 2) - }; - Button cancelButton = new Button - { - Text = "Cancel", - DialogResult = DialogResult.Cancel, - AutoSize = true, - AutoSizeMode = AutoSizeMode.GrowAndShrink, - MinimumSize = new Size(75, 0), - Padding = new Padding(6, 2, 6, 2) - }; - bool updatingHexText = false; - - void LayoutControls() - { - const int padding = 12; - const int hueBarWidth = 24; - const int hueGap = 8; - int bottomRowHeight = Math.Max( - Math.Max(preview.Height, Math.Max(okButton.Height, cancelButton.Height)), - Math.Max(hexTextBox.PreferredSize.Height, hexLabel.Height)) + 8; - int rowTop = form.ClientSize.Height - padding - bottomRowHeight; - - svBox.Location = new Point(padding, padding); - svBox.Size = new Size( - Math.Max(200, form.ClientSize.Width - (2 * padding) - hueBarWidth - hueGap), - Math.Max(120, form.ClientSize.Height - (3 * padding) - bottomRowHeight)); - hueBox.Location = new Point(svBox.Right + hueGap, padding); - hueBox.Size = new Size(hueBarWidth, svBox.Height); - - preview.Location = new Point(padding, rowTop + (bottomRowHeight - preview.Height) / 2); - hexLabel.Location = new Point(preview.Right + 10, rowTop + (bottomRowHeight - hexLabel.Height) / 2); - hexTextBox.Location = new Point(hexLabel.Right + 6, rowTop + (bottomRowHeight - hexTextBox.Height) / 2); - - cancelButton.Location = new Point(form.ClientSize.Width - padding - cancelButton.Width, rowTop + (bottomRowHeight - cancelButton.Height) / 2); - okButton.Location = new Point(cancelButton.Left - 8 - okButton.Width, rowTop + (bottomRowHeight - okButton.Height) / 2); - } - - void SyncSelectorsFromCurrent() - { - svSelectorX = Math.Min(Math.Max(0, (int)Math.Round(currentSaturation * Math.Max(1, svBox.ClientSize.Width - 1))), Math.Max(0, svBox.ClientSize.Width - 1)); - svSelectorY = Math.Min(Math.Max(0, (int)Math.Round((1f - currentValue) * Math.Max(1, svBox.ClientSize.Height - 1))), Math.Max(0, svBox.ClientSize.Height - 1)); - hueSelectorY = Math.Min(Math.Max(0, (int)Math.Round(currentHue * Math.Max(1, hueBox.ClientSize.Height - 1))), Math.Max(0, hueBox.ClientSize.Height - 1)); - } - - void UpdateCurrentColor() - { - current = ColorFromHsv(currentHue, currentSaturation, currentValue, 255); - preview.BackColor = current; - updatingHexText = true; - hexTextBox.Text = $"#{current.R:X2}{current.G:X2}{current.B:X2}"; - updatingHexText = false; - } - - void UpdateSvFromPoint(Point p) - { - svSelectorX = Math.Min(Math.Max(0, p.X), Math.Max(0, svBox.ClientSize.Width - 1)); - svSelectorY = Math.Min(Math.Max(0, p.Y), Math.Max(0, svBox.ClientSize.Height - 1)); - currentSaturation = svSelectorX / (float)Math.Max(1, svBox.ClientSize.Width - 1); - currentValue = 1f - svSelectorY / (float)Math.Max(1, svBox.ClientSize.Height - 1); - UpdateCurrentColor(); - svBox.Invalidate(); - } - - void UpdateHueFromPoint(Point p) - { - int newHueSelectorY = Math.Min(Math.Max(0, p.Y), Math.Max(0, hueBox.ClientSize.Height - 1)); - if (newHueSelectorY == hueSelectorY) - return; - - hueSelectorY = newHueSelectorY; - currentHue = hueSelectorY / (float)Math.Max(1, hueBox.ClientSize.Height - 1); - UpdateCurrentColor(); - svBox.Invalidate(); - hueBox.Invalidate(); - } - - bool draggingSv = false; - bool draggingHue = false; - svBox.MouseDown += delegate(object sender, MouseEventArgs e) - { - if (e.Button != MouseButtons.Left) - return; - draggingSv = true; - UpdateSvFromPoint(e.Location); - }; - svBox.MouseMove += delegate(object sender, MouseEventArgs e) - { - if (draggingSv) - UpdateSvFromPoint(e.Location); - }; - svBox.MouseUp += delegate { draggingSv = false; }; - - hueBox.MouseDown += delegate(object sender, MouseEventArgs e) - { - if (e.Button != MouseButtons.Left) - return; - draggingHue = true; - UpdateHueFromPoint(e.Location); - }; - hueBox.MouseMove += delegate(object sender, MouseEventArgs e) - { - if (draggingHue) - UpdateHueFromPoint(e.Location); - }; - hueBox.MouseUp += delegate { draggingHue = false; }; - - svBox.Paint += delegate(object sender, PaintEventArgs e) - { - Rectangle rect = svBox.ClientRectangle; - if (rect.Width <= 1 || rect.Height <= 1) - return; - - rect.Width -= 1; - rect.Height -= 1; - e.Graphics.SmoothingMode = SmoothingMode.None; - - using (SolidBrush hueBrush = new SolidBrush(ColorFromHsv(currentHue, 1f, 1f, 255))) - e.Graphics.FillRectangle(hueBrush, rect); - - using (LinearGradientBrush satBrush = new LinearGradientBrush(rect, Color.White, Color.Transparent, LinearGradientMode.Horizontal)) - { - ColorBlend satBlend = new ColorBlend - { - Positions = new[] { 0f, 1f }, - Colors = new[] { Color.FromArgb(255, 255, 255, 255), Color.FromArgb(0, 255, 255, 255) } - }; - satBrush.InterpolationColors = satBlend; - e.Graphics.FillRectangle(satBrush, rect); - } - - using (LinearGradientBrush valueBrush = new LinearGradientBrush(rect, Color.Transparent, Color.Black, LinearGradientMode.Vertical)) - { - ColorBlend valueBlend = new ColorBlend - { - Positions = new[] { 0f, 1f }, - Colors = new[] { Color.FromArgb(0, 0, 0, 0), Color.FromArgb(255, 0, 0, 0) } - }; - valueBrush.InterpolationColors = valueBlend; - e.Graphics.FillRectangle(valueBrush, rect); - } - - Rectangle marker = new Rectangle(svSelectorX - 4, svSelectorY - 4, 8, 8); - using Pen outer = new Pen(Color.Black, 2f); - using Pen inner = new Pen(Color.White, 1f); - e.Graphics.DrawEllipse(outer, marker); - e.Graphics.DrawEllipse(inner, marker); - }; - hueBox.Paint += delegate(object sender, PaintEventArgs e) - { - Rectangle rect = hueBox.ClientRectangle; - if (rect.Width <= 1 || rect.Height <= 1) - return; - - rect.Width -= 1; - rect.Height -= 1; - - using (LinearGradientBrush hueBrush = new LinearGradientBrush(rect, Color.Red, Color.Red, LinearGradientMode.Vertical)) - { - hueBrush.InterpolationColors = new ColorBlend - { - Positions = new[] { 0f, 1f / 6f, 2f / 6f, 3f / 6f, 4f / 6f, 5f / 6f, 1f }, - Colors = new[] { Color.Red, Color.Yellow, Color.Lime, Color.Cyan, Color.Blue, Color.Magenta, Color.Red } - }; - e.Graphics.FillRectangle(hueBrush, rect); - } - - Rectangle marker = new Rectangle(0, hueSelectorY - 2, hueBox.ClientSize.Width - 1, 4); - using Pen outer = new Pen(Color.Black, 2f); - using Pen inner = new Pen(Color.White, 1f); - e.Graphics.DrawRectangle(outer, marker); - e.Graphics.DrawRectangle(inner, marker); - }; - hexTextBox.TextChanged += delegate - { - if (updatingHexText) - return; - - if (!TryParseHexColor(hexTextBox.Text, out Color parsedColor)) - return; - - float parsedHue = parsedColor.GetHue() / 360f; - float parsedSaturation = parsedColor.GetSaturation(); - float parsedValue = GetColorValue(parsedColor); - - currentHue = parsedHue; - currentSaturation = parsedSaturation; - currentValue = parsedValue; - SyncSelectorsFromCurrent(); - UpdateCurrentColor(); - svBox.Invalidate(); - hueBox.Invalidate(); - }; - - form.Controls.Add(svBox); - form.Controls.Add(hueBox); - form.Controls.Add(preview); - form.Controls.Add(hexLabel); - form.Controls.Add(hexTextBox); - form.Controls.Add(okButton); - form.Controls.Add(cancelButton); - form.AcceptButton = okButton; - form.CancelButton = cancelButton; - Theme.Current.Apply(form); - form.Resize += delegate - { - LayoutControls(); - SyncSelectorsFromCurrent(); - UpdateCurrentColor(); - svBox.Invalidate(); - hueBox.Invalidate(); - }; - LayoutControls(); - SyncSelectorsFromCurrent(); - UpdateCurrentColor(); - - if (form.ShowDialog() == DialogResult.OK) - { - selectedColor = current; - return true; - } - - selectedColor = initialColor; - return false; - } - - private static void SetDoubleBuffered(Control control) - { - typeof(Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) - ?.SetValue(control, true, null); - } - - private static float GetColorValue(Color color) - { - return Math.Max(color.R, Math.Max(color.G, color.B)) / 255f; - } - - private static bool TryParseHexColor(string input, out Color color) - { - color = Color.Empty; - if (string.IsNullOrWhiteSpace(input)) - return false; - - string hex = input.Trim(); - if (hex.StartsWith("#")) - hex = hex.Substring(1); - - if (hex.Length != 6) - return false; - - if (!int.TryParse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out int r)) - return false; - if (!int.TryParse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out int g)) - return false; - if (!int.TryParse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out int b)) - return false; - - color = Color.FromArgb(r, g, b); - return true; - } - - private void Resize() - { - Resize(Size.Width); - } - - private void Resize(int width) - { - int y = _topMargin; - - foreach (KeyValuePair> pair in _sensors) - { - if (_hardwareNames.Value) - { - if (y > _topMargin) - y += _hardwareLineHeight - _sensorLineHeight; - y += _hardwareLineHeight; - } - y += pair.Value.Count * _sensorLineHeight; - } - - if (_sensors.Count == 0) - y += 4 * _sensorLineHeight + _hardwareLineHeight; - - y += _bottomMargin; - Size = new Size(width, y); - } - - private void DrawImageWidthBorder(Graphics g, int width, int height, Image back, int t, int b, int l, int r) - { - GraphicsUnit u = GraphicsUnit.Pixel; - - g.DrawImage(back, new Rectangle(0, 0, l, t), new Rectangle(0, 0, l, t), u); - g.DrawImage(back, new Rectangle(l, 0, width - l - r, t), new Rectangle(l, 0, back.Width - l - r, t), u); - g.DrawImage(back, new Rectangle(width - r, 0, r, t), new Rectangle(back.Width - r, 0, r, t), u); - - g.DrawImage(back, new Rectangle(0, t, l, height - t - b), new Rectangle(0, t, l, back.Height - t - b), u); - g.DrawImage(back, new Rectangle(l, t, width - l - r, height - t - b), new Rectangle(l, t, back.Width - l - r, back.Height - t - b), u); - g.DrawImage(back, new Rectangle(width - r, t, r, height - t - b), new Rectangle(back.Width - r, t, r, back.Height - t - b), u); - - g.DrawImage(back, new Rectangle(0, height - b, l, b), new Rectangle(0, back.Height - b, l, b), u); - g.DrawImage(back, new Rectangle(l, height - b, width - l - r, b), new Rectangle(l, back.Height - b, back.Width - l - r, b), u); - g.DrawImage(back, new Rectangle(width - r, height - b, r, b), new Rectangle(back.Width - r, back.Height - b, r, b), u); - } - - private void DrawBackground(Graphics g) - { - int w = Size.Width; - int h = Size.Height; - - if (_backgroundDirty || w != _background.Width || h != _background.Height) - { - _background.Dispose(); - _background = new Bitmap(w, h, PixelFormat.Format32bppPArgb); - - using (Graphics graphics = Graphics.FromImage(_background)) - { - DrawImageWidthBorder(graphics, w, h, _backTinted ?? _back, TopBorder, BottomBorder, LeftBorder, RightBorder); - - if (_fore != null) - DrawImageWidthBorder(graphics, w, h, _fore, TopBorder, BottomBorder, LeftBorder, RightBorder); - - if (_image != null) - { - int width = w - LeftBorder - RightBorder; - int height = h - TopBorder - BottomBorder; - float xRatio = width / (float)_image.Width; - float yRatio = height / (float)_image.Height; - float destWidth, destHeight; - float xOffset, yOffset; - - if (xRatio < yRatio) - { - destWidth = width; - destHeight = _image.Height * xRatio; - xOffset = 0; - yOffset = 0.5f * (height - destHeight); - } - else - { - destWidth = _image.Width * yRatio; - destHeight = height; - xOffset = 0.5f * (width - destWidth); - yOffset = 0; - } - - graphics.DrawImage(_image, new RectangleF(LeftBorder + xOffset, TopBorder + yOffset, destWidth, destHeight)); - } - } - - _backgroundDirty = false; - } - - g.DrawImageUnscaled(_background, 0, 0); - } - - private void DrawProgress(Graphics g, float x, float y, float width, float height, float progress) - { - Image barBack = _barBackTinted ?? _barBack; - Image barFore = _barForeTinted ?? _barFore; - g.DrawImage(barBack, - new RectangleF(x + width * progress, y, width * (1 - progress), height), - new RectangleF(barBack.Width * progress, 0, (1 - progress) * barBack.Width, barBack.Height), - GraphicsUnit.Pixel); - g.DrawImage(barFore, - new RectangleF(x, y, width * progress, height), - new RectangleF(0, 0, progress * barFore.Width, barFore.Height), GraphicsUnit.Pixel); - } - - protected override void OnPaint(PaintEventArgs e) - { - try - { - Graphics g = e.Graphics; - int w = Size.Width; - - g.Clear(Color.Transparent); - DrawBackground(g); - - int x; - int y = _topMargin; - - if (_sensors.Count == 0) - { - x = LeftBorder + 1; - g.DrawString("Right-click on a sensor in the main window and select " + - "\"Show in Gadget\" to show the sensor here.", - _smallFont, _textBrush, - new Rectangle(x, y - 1, w - RightBorder - x, 0)); - } - - foreach (KeyValuePair> pair in _sensors) - { - if (_hardwareNames.Value) - { - if (y > _topMargin) - y += _hardwareLineHeight - _sensorLineHeight; - - x = LeftBorder + 1; - g.DrawImage(HardwareTypeImage.Instance.GetImage(pair.Key.HardwareType), new Rectangle(x, y + 1, _iconSize, _iconSize)); - x += _iconSize + 1; - g.DrawString(pair.Key.Name, _largeFont, _textBrush, new Rectangle(x, y - 1, w - RightBorder - x, 0), _stringFormat); - y += _hardwareLineHeight; - } - - foreach (ISensor sensor in pair.Value) - { - int remainingWidth; - - if ((sensor.SensorType != SensorType.Load && - sensor.SensorType != SensorType.Control && - sensor.SensorType != SensorType.Level && - sensor.SensorType != SensorType.Humidity) || !sensor.Value.HasValue) - { - string formatted; - - if (sensor.Value.HasValue) - { - string format = ""; - switch (sensor.SensorType) - { - case SensorType.Voltage: - format = "{0:F3} V"; - break; - case SensorType.Current: - format = "{0:F3} A"; - break; - case SensorType.Clock: - format = "{0:F0} MHz"; - break; - case SensorType.Frequency: - format = "{0:F0} Hz"; - break; - case SensorType.Temperature: - format = "{0:F1} °C"; - break; - case SensorType.Fan: - format = "{0:F0} RPM"; - break; - case SensorType.Flow: - format = "{0:F0} L/h"; - break; - case SensorType.Power: - format = "{0:F1} W"; - break; - case SensorType.Data: - format = "{0:F1} GB"; - break; - case SensorType.SmallData: - format = "{0:F0} MB"; - break; - case SensorType.Factor: - format = "{0:F3}"; - break; - case SensorType.TimeSpan: - format = "{0:g}"; - break; - case SensorType.Timing: - format = "{0:F3} ns"; - break; - case SensorType.Energy: - format = "{0:F0} mWh"; - break; - case SensorType.Noise: - format = "{0:F0} dBA"; - break; - case SensorType.Conductivity: - format = "{0:F1} µS/cm"; - break; - } - - if (sensor.SensorType == SensorType.Temperature && _unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) - { - formatted = $"{UnitManager.CelsiusToFahrenheit(sensor.Value):F1} °F"; - } - else if (sensor.SensorType == SensorType.Throughput) - { - string result; - switch (sensor.Name) - { - case "Connection Speed": - { - switch (sensor.Value) - { - case 100000000: - result = "100Mbps"; - break; - case 1000000000: - result = "1Gbps"; - break; - default: - { - if (sensor.Value < 1024) - result = $"{sensor.Value:F0} bps"; - else if (sensor.Value < 1048576) - result = $"{sensor.Value / 1024:F1} Kbps"; - else if (sensor.Value < 1073741824) - result = $"{sensor.Value / 1048576:F1} Mbps"; - else - result = $"{sensor.Value / 1073741824:F1} Gbps"; - } - break; - } - } - break; - default: - { - if (sensor.Value < 1048576) - result = $"{sensor.Value / 1024:F1} KB/s"; - else - result = $"{sensor.Value / 1048576:F1} MB/s"; - } - break; - } - formatted = result; - } - else if (sensor.SensorType == SensorType.TimeSpan) - { - formatted = string.Format(format, TimeSpan.FromSeconds(sensor.Value.Value)); - } - else - { - formatted = string.Format(format, sensor.Value); - } - } - else - { - formatted = "-"; - } - - g.DrawString(formatted, _smallFont, _textBrush, new RectangleF(-1, y - 1, w - _rightMargin + 3, 0), _alignRightStringFormat); - - remainingWidth = w - (int)Math.Floor(g.MeasureString(formatted, _smallFont, w, StringFormat.GenericTypographic).Width) - _rightMargin; - } - else - { - DrawProgress(g, w - _progressWidth - _rightMargin, y + 0.35f * _sensorLineHeight, _progressWidth, 0.6f * _sensorLineHeight, 0.01f * sensor.Value.Value); - remainingWidth = w - _progressWidth - _rightMargin; - } - - remainingWidth -= _leftMargin + 2; - if (remainingWidth > 0) - { - g.DrawString(sensor.Name, _smallFont, _textBrush, new RectangleF(_leftMargin - 1, y - 1, remainingWidth, 0), _trimStringFormat); - } - y += _sensorLineHeight; - } - } - } - catch (ArgumentException) - { - // #1425. - } - } - - private class HardwareComparer : IComparer - { - public int Compare(IHardware x, IHardware y) - { - switch (x) - { - case null when y == null: - return 0; - case null: - return -1; - } - - if (y == null) - return 1; - - if (x.HardwareType != y.HardwareType) - return x.HardwareType.CompareTo(y.HardwareType); - - return x.Identifier.CompareTo(y.Identifier); - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/SensorNode.cs b/LibreHardwareMonitor.Windows.Forms/UI/SensorNode.cs deleted file mode 100644 index 49fa946..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/SensorNode.cs +++ /dev/null @@ -1,288 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Drawing; -using System.Globalization; -using System.Text; -using LibreHardwareMonitor.Hardware; -using LibreHardwareMonitor.Windows.Forms.Utilities; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class SensorNode : Node -{ - private readonly PersistentSettings _settings; - private readonly UnitManager _unitManager; - private Color? _penColor; - private bool _plot; - - public SensorNode(ISensor sensor, PersistentSettings settings, UnitManager unitManager) - { - Sensor = sensor; - _settings = settings; - _unitManager = unitManager; - - switch (sensor.SensorType) - { - case SensorType.Voltage: - Format = "{0:F3} V"; - break; - case SensorType.Current: - Format = "{0:F3} A"; - break; - case SensorType.Clock: - Format = "{0:F1} MHz"; - break; - case SensorType.Load: - Format = "{0:F1} %"; - break; - case SensorType.Temperature: - Format = "{0:F1} °C"; - break; - case SensorType.Fan: - Format = "{0:F0} RPM"; - break; - case SensorType.Flow: - Format = "{0:F1} L/h"; - break; - case SensorType.Control: - Format = "{0:F1} %"; - break; - case SensorType.Level: - Format = "{0:F1} %"; - break; - case SensorType.Power: - Format = "{0:F1} W"; - break; - case SensorType.Data: - Format = "{0:F1} GB"; - break; - case SensorType.SmallData: - Format = "{0:F1} MB"; - break; - case SensorType.Factor: - Format = "{0:F3}"; - break; - case SensorType.Frequency: - Format = "{0:F1} Hz"; - break; - case SensorType.Throughput: - Format = "{0:F1} B/s"; - break; - case SensorType.TimeSpan: - Format = "{0:g}"; - break; - case SensorType.Timing: - Format = "{0:F3} ns"; - break; - case SensorType.Energy: - Format = "{0:F0} mWh"; - break; - case SensorType.Noise: - Format = "{0:F0} dBA"; - break; - case SensorType.Conductivity: - Format = "{0:F1} µS/cm"; - break; - case SensorType.Humidity: - Format = "{0:F0} %"; - break; - } - - bool hidden = settings.GetValue(new Identifier(sensor.Identifier, "hidden").ToString(), sensor.IsDefaultHidden); - base.IsVisible = !hidden; - Plot = settings.GetValue(new Identifier(sensor.Identifier, "plot").ToString(), false); - string id = new Identifier(sensor.Identifier, "penColor").ToString(); - - if (settings.Contains(id)) - PenColor = settings.GetValue(id, Color.Black); - } - - public event EventHandler PlotSelectionChanged; - - public string Format { get; set; } = ""; - - public override bool IsVisible - { - get { return base.IsVisible; } - set - { - base.IsVisible = value; - _settings.SetValue(new Identifier(Sensor.Identifier, "hidden").ToString(), !value); - } - } - - public string Max - { - get { return ValueToString(Sensor.Max); } - } - - public string Min - { - get { return ValueToString(Sensor.Min); } - } - - public Color? PenColor - { - get { return _penColor; } - set - { - _penColor = value; - - string id = new Identifier(Sensor.Identifier, "penColor").ToString(); - if (value.HasValue) - _settings.SetValue(id, value.Value); - else - _settings.Remove(id); - - PlotSelectionChanged?.Invoke(this, null); - } - } - - public bool Plot - { - get { return _plot; } - set - { - _plot = value; - _settings.SetValue(new Identifier(Sensor.Identifier, "plot").ToString(), value); - PlotSelectionChanged?.Invoke(this, null); - } - } - - public ISensor Sensor { get; } - - public override string Text - { - get { return Sensor.Name; } - set { Sensor.Name = value; } - } - - public override string ToolTip - { - get - { - StringBuilder stringBuilder = new(); - - if (Sensor is ICriticalSensorLimits criticalSensorLimits) - OptionallyAppendCriticalRange(stringBuilder, criticalSensorLimits.CriticalLowLimit, criticalSensorLimits.CriticalHighLimit, "critical"); - - if (Sensor is ISensorLimits sensorLimits) - OptionallyAppendCriticalRange(stringBuilder, sensorLimits.LowLimit, sensorLimits.HighLimit, "normal"); - - return stringBuilder.ToString(); - } - } - - public string Value - { - get { return ValueToString(Sensor.Value); } - } - - public string ValueToString(float? value) - { - if (value.HasValue) - { - switch (Sensor.SensorType) - { - case SensorType.Temperature when _unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit: - { - return $"{value * 1.8 + 32:F1} °F"; - } - case SensorType.Throughput: - { - string result; - switch (Sensor.Name) - { - case "Connection Speed": - { - switch (value) - { - case 100000000: - { - result = "100Mbps"; - break; - } - case 1000000000: - { - result = "1Gbps"; - break; - } - default: - { - if (value < 1024) - result = $"{value:F0} bps"; - else if (value < 1048576) - result = $"{value / 1024:F1} Kbps"; - else if (value < 1073741824) - result = $"{value / 1048576:F1} Mbps"; - else - result = $"{value / 1073741824:F1} Gbps"; - } - - break; - } - - break; - } - default: - { - const int _1MB = 1048576; - - result = value < _1MB ? $"{value / 1024:F1} KB/s" : $"{value / _1MB:F1} MB/s"; - - break; - } - } - - return result; - } - case SensorType.TimeSpan: - { - return string.Format(Format, TimeSpan.FromSeconds(value.Value)); - } - default: - { - return string.Format(Format, value); - } - } - } - - return "-"; - } - - private void OptionallyAppendCriticalRange(StringBuilder str, float? min, float? max, string kind) - { - if (min.HasValue) - { - str.AppendLine(max.HasValue - ? $"{CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(kind)} range: {ValueToString(min)} to {ValueToString(max)}." - : $"Minimal {kind} value: {ValueToString(min)}."); - } - else if (max.HasValue) - { - str.AppendLine($"Maximal {kind} value: {ValueToString(max)}."); - } - } - - public override bool Equals(object obj) - { - if (obj == null) - return false; - - if (!(obj is SensorNode s)) - return false; - - - return (Sensor == s.Sensor); - } - - public override int GetHashCode() - { - return Sensor.GetHashCode(); - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/SensorNotifyIcon.cs b/LibreHardwareMonitor.Windows.Forms/UI/SensorNotifyIcon.cs deleted file mode 100644 index f427d15..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/SensorNotifyIcon.cs +++ /dev/null @@ -1,314 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.Drawing.Text; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using LibreHardwareMonitor.Hardware; -using LibreHardwareMonitor.Windows.Forms.Utilities; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class SensorNotifyIcon : IDisposable -{ - private readonly UnitManager _unitManager; - private readonly NotifyIconAdv _notifyIcon; - private readonly Bitmap _bitmap; - private readonly Graphics _graphics; - private Color _color; - private Color _darkColor; - private Brush _brush; - private Brush _darkBrush; - private readonly Pen _pen; - private readonly Font _font; - private readonly Font _smallFont; - - public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor, PersistentSettings settings, UnitManager unitManager) - { - _unitManager = unitManager; - Sensor = sensor; - _notifyIcon = new NotifyIconAdv(); - - Color defaultColor = Color.White; - if (sensor.SensorType == SensorType.Load || sensor.SensorType == SensorType.Control || sensor.SensorType == SensorType.Level) - defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1); - - Color = settings.GetValue(new Identifier(sensor.Identifier, "traycolor").ToString(), defaultColor); - - _pen = new Pen(Color.FromArgb(96, Color.Black)); - ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); - ToolStripItem hideShowItem = new ToolStripMenuItem("Hide/Show"); - hideShowItem.Click += delegate - { - sensorSystemTray.SendHideShowCommand(); - }; - contextMenuStrip.Items.Add(hideShowItem); - contextMenuStrip.Items.Add(new ToolStripSeparator()); - ToolStripItem removeItem = new ToolStripMenuItem("Remove Sensor"); - removeItem.Click += delegate - { - sensorSystemTray.Remove(Sensor); - }; - contextMenuStrip.Items.Add(removeItem); - ToolStripItem colorItem = new ToolStripMenuItem("Change Color..."); - colorItem.Click += delegate - { - ColorDialog dialog = new ColorDialog { Color = Color }; - if (dialog.ShowDialog() == DialogResult.OK) - { - Color = dialog.Color; - settings.SetValue(new Identifier(sensor.Identifier, - "traycolor").ToString(), Color); - } - }; - contextMenuStrip.Items.Add(colorItem); - contextMenuStrip.Items.Add(new ToolStripSeparator()); - ToolStripItem exitItem = new ToolStripMenuItem("Exit"); - exitItem.Click += delegate - { - sensorSystemTray.SendExitCommand(); - }; - contextMenuStrip.Items.Add(exitItem); - _notifyIcon.ContextMenuStrip = contextMenuStrip; - _notifyIcon.DoubleClick += delegate - { - sensorSystemTray.SendHideShowCommand(); - }; - - // get the default dpi to create an icon with the correct size - float dpiX, dpiY; - using (Bitmap b = new Bitmap(1, 1, PixelFormat.Format32bppArgb)) - { - dpiX = b.HorizontalResolution; - dpiY = b.VerticalResolution; - } - - // adjust the size of the icon to current dpi (default is 16x16 at 96 dpi) - int width = (int)Math.Round(16 * dpiX / 96); - int height = (int)Math.Round(16 * dpiY / 96); - - // make sure it does never get smaller than 16x16 - width = width < 16 ? 16 : width; - height = height < 16 ? 16 : height; - - // adjust the font size to the icon size - FontFamily family = SystemFonts.MessageBoxFont.FontFamily; - float baseSize; - switch (family.Name) - { - case "Segoe UI": baseSize = 12; break; - case "Tahoma": baseSize = 11; break; - default: baseSize = 12; break; - } - - _font = new Font(family, baseSize * width / 16.0f, GraphicsUnit.Pixel); - _smallFont = new Font(family, 0.75f * baseSize * width / 16.0f, GraphicsUnit.Pixel); - - _bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); - _graphics = Graphics.FromImage(_bitmap); - if (Environment.OSVersion.Version.Major > 5) - { - _graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; - _graphics.SmoothingMode = SmoothingMode.HighQuality; - } - } - - public ISensor Sensor { get; } - - public Color Color - { - get { return _color; } - set - { - _color = value; - _darkColor = Color.FromArgb(255, _color.R / 3, _color.G / 3, _color.B / 3); - Brush brush = _brush; - _brush = new SolidBrush(_color); - brush?.Dispose(); - Brush darkBrush = _darkBrush; - _darkBrush = new SolidBrush(_darkColor); - darkBrush?.Dispose(); - } - } - - public void Dispose() - { - Icon icon = _notifyIcon.Icon; - _notifyIcon.Icon = null; - icon?.Destroy(); - _notifyIcon.Dispose(); - - _brush?.Dispose(); - _darkBrush?.Dispose(); - _pen.Dispose(); - _graphics.Dispose(); - _bitmap.Dispose(); - _font.Dispose(); - _smallFont.Dispose(); - } - - private string GetString() - { - if (!Sensor.Value.HasValue) - return "-"; - - switch (Sensor.SensorType) - { - case SensorType.Temperature: - return _unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit ? $"{UnitManager.CelsiusToFahrenheit(Sensor.Value):F0}" : $"{Sensor.Value:F0}"; - case SensorType.TimeSpan: - return $"{TimeSpan.FromSeconds(Sensor.Value.Value):g}"; - case SensorType.Timing: - return $"{Sensor.Value.Value:F3}"; - case SensorType.Clock: - case SensorType.Fan: - case SensorType.Flow: - return $"{1e-3f * Sensor.Value:F1}"; - case SensorType.Voltage: - case SensorType.Current: - case SensorType.SmallData: - case SensorType.Factor: - case SensorType.Throughput: - case SensorType.Conductivity: - return $"{Sensor.Value:F1}"; - case SensorType.Control: - case SensorType.Frequency: - case SensorType.Level: - case SensorType.Power: - case SensorType.Data: - case SensorType.Load: - case SensorType.Energy: - case SensorType.Noise: - case SensorType.Humidity: - return $"{Sensor.Value:F0}"; - default: - return "-"; - } - } - - private Icon CreateTransparentIcon() - { - string text = GetString(); - int count = 0; - for (int i = 0; i < text.Length; i++) - if ((text[i] >= '0' && text[i] <= '9') || text[i] == '-') - count++; - bool small = count > 2; - - _graphics.Clear(Color.Black); - Rectangle bounds = new Rectangle(Point.Empty, _bitmap.Size); - TextRenderer.DrawText(_graphics, text, small ? _smallFont : _font, - bounds, Color.White, Color.Black, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); - - BitmapData data = _bitmap.LockBits( - new Rectangle(0, 0, _bitmap.Width, _bitmap.Height), - ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); - - IntPtr Scan0 = data.Scan0; - - int numBytes = _bitmap.Width * _bitmap.Height * 4; - byte[] bytes = new byte[numBytes]; - Marshal.Copy(Scan0, bytes, 0, numBytes); - _bitmap.UnlockBits(data); - - byte red, green, blue; - for (int i = 0; i < bytes.Length; i += 4) - { - blue = bytes[i]; - green = bytes[i + 1]; - red = bytes[i + 2]; - - bytes[i] = _color.B; - bytes[i + 1] = _color.G; - bytes[i + 2] = _color.R; - bytes[i + 3] = (byte)(0.3 * red + 0.59 * green + 0.11 * blue); - } - - return IconFactory.Create(bytes, _bitmap.Width, _bitmap.Height, - PixelFormat.Format32bppArgb); - } - - private Icon CreatePercentageIcon() - { - try - { - _graphics.Clear(Color.Transparent); - } - catch (ArgumentException) - { - _graphics.Clear(Color.Black); - } - _graphics.FillRectangle(_darkBrush, 0.5f, -0.5f, _bitmap.Width - 2, _bitmap.Height); - float value = Sensor.Value.GetValueOrDefault(); - float y = (float)(_bitmap.Height * 0.01f) * (100 - value); - _graphics.FillRectangle(_brush, 0.5f, -0.5f + y, _bitmap.Width - 2, _bitmap.Height - y); - _graphics.DrawRectangle(_pen, 1, 0, _bitmap.Width - 3, _bitmap.Height - 1); - - return IconFactory.Create(_bitmap); - } - - public void Update() - { - Icon icon = _notifyIcon.Icon; - - switch (Sensor.SensorType) - { - case SensorType.Load: - case SensorType.Control: - case SensorType.Level: - _notifyIcon.Icon = CreatePercentageIcon(); - break; - default: - _notifyIcon.Icon = CreateTransparentIcon(); - break; - } - - icon?.Destroy(); - - string format = ""; - switch (Sensor.SensorType) - { - case SensorType.Voltage: format = "\n{0}: {1:F2} V"; break; - case SensorType.Current: format = "\n{0}: {1:F2} A"; break; - case SensorType.Clock: format = "\n{0}: {1:F0} MHz"; break; - case SensorType.Load: format = "\n{0}: {1:F1} %"; break; - case SensorType.Temperature: format = "\n{0}: {1:F1} °C"; break; - case SensorType.Fan: format = "\n{0}: {1:F0} RPM"; break; - case SensorType.Flow: format = "\n{0}: {1:F0} L/h"; break; - case SensorType.Control: format = "\n{0}: {1:F1} %"; break; - case SensorType.Level: format = "\n{0}: {1:F1} %"; break; - case SensorType.Power: format = "\n{0}: {1:F0} W"; break; - case SensorType.Data: format = "\n{0}: {1:F0} GB"; break; - case SensorType.Factor: format = "\n{0}: {1:F3} GB"; break; - case SensorType.Energy: format = "\n{0}: {0:F0} mWh"; break; - case SensorType.Noise: format = "\n{0}: {0:F0} dBA"; break; - case SensorType.Conductivity: format = "\n{0}: {0:F1} µS/cm"; break; - case SensorType.Humidity: format = "\n{0}: {0:F0} %"; break; - case SensorType.Timing: format = "\n{0}: {0:F3} ns"; break; - } - - string formattedValue = string.Format(format, Sensor.Name, Sensor.Value); - - if (Sensor.SensorType == SensorType.Temperature && _unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) - { - format = "\n{0}: {1:F1} °F"; - formattedValue = string.Format(format, Sensor.Name, UnitManager.CelsiusToFahrenheit(Sensor.Value)); - } - - string hardwareName = Sensor.Hardware.Name; - hardwareName = hardwareName.Substring(0, Math.Min(63 - formattedValue.Length, hardwareName.Length)); - string text = hardwareName + formattedValue; - if (text.Length > 63) - text = null; - - _notifyIcon.Text = text; - _notifyIcon.Visible = true; - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/ShowDesktop.cs b/LibreHardwareMonitor.Windows.Forms/UI/ShowDesktop.cs deleted file mode 100644 index 220f684..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/ShowDesktop.cs +++ /dev/null @@ -1,157 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Runtime.InteropServices; -using System.Windows.Forms; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class ShowDesktop : IDisposable -{ - private readonly NativeWindow _referenceWindow; - private readonly string _referenceWindowCaption = "LibreHardwareMonitorShowDesktopReferenceWindow"; - private readonly System.Threading.Timer _timer; - private bool _showDesktop; - - /// - /// Prevents a default instance of the class from being created. - /// - private ShowDesktop() - { - // Create a reference window to detect show desktop - _referenceWindow = new NativeWindow(); - - CreateParams cp = new CreateParams { ExStyle = GadgetWindow.WS_EX_TOOLWINDOW, Caption = _referenceWindowCaption }; - _referenceWindow.CreateHandle(cp); - NativeMethods.SetWindowPos(_referenceWindow.Handle, - GadgetWindow.HWND_BOTTOM, - 0, - 0, - 0, - 0, - GadgetWindow.SWP_NOMOVE | - GadgetWindow.SWP_NOSIZE | - GadgetWindow.SWP_NOACTIVATE | - GadgetWindow.SWP_NOSENDCHANGING); - - // start a repeated timer to detect "Show Desktop" events - _timer = new System.Threading.Timer(OnTimer, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); - } - - public delegate void ShowDesktopChangedEventHandler(bool showDesktop); - - private event ShowDesktopChangedEventHandler ShowDesktopChangedEvent; - - // notify when the "show desktop" mode is changed - public event ShowDesktopChangedEventHandler ShowDesktopChanged - { - add - { - // start the monitor timer when someone is listening - if (ShowDesktopChangedEvent == null) - StartTimer(); - - ShowDesktopChangedEvent += value; - } - remove - { - ShowDesktopChangedEvent -= value; - // stop the monitor timer if nobody is interested - if (ShowDesktopChangedEvent == null) - StopTimer(); - } - } - - public static ShowDesktop Instance { get; } = new ShowDesktop(); - - /// - public void Dispose() - { - _timer?.Dispose(); - _referenceWindow.ReleaseHandle(); - } - - private void StartTimer() - { - _timer.Change(0, 200); - } - - private void StopTimer() - { - _timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); - } - - // the desktop worker window (if available) can hide the reference window - private IntPtr GetDesktopWorkerWindow() - { - IntPtr shellWindow = NativeMethods.GetShellWindow(); - if (shellWindow == IntPtr.Zero) - return IntPtr.Zero; - - - NativeMethods.GetWindowThreadProcessId(shellWindow, out int shellId); - - IntPtr workerWindow = IntPtr.Zero; - while ((workerWindow = NativeMethods.FindWindowEx(IntPtr.Zero, workerWindow, "WorkerW", null)) != IntPtr.Zero) - { - NativeMethods.GetWindowThreadProcessId(workerWindow, out int workerId); - if (workerId == shellId) - { - IntPtr window = NativeMethods.FindWindowEx(workerWindow, IntPtr.Zero, "SHELLDLL_DefView", null); - if (window != IntPtr.Zero) - { - IntPtr desktopWindow = NativeMethods.FindWindowEx(window, IntPtr.Zero, "SysListView32", null); - if (desktopWindow != IntPtr.Zero) - return workerWindow; - } - } - } - - return IntPtr.Zero; - } - - private void OnTimer(object state) - { - bool showDesktopDetected; - - IntPtr workerWindow = GetDesktopWorkerWindow(); - if (workerWindow != IntPtr.Zero) - { - // search if the reference window is behind the worker window - IntPtr reference = NativeMethods.FindWindowEx(IntPtr.Zero, workerWindow, null, _referenceWindowCaption); - showDesktopDetected = reference != IntPtr.Zero; - } - else - { - // if there is no worker window, then nothing can hide the reference - showDesktopDetected = false; - } - - if (_showDesktop != showDesktopDetected) - { - _showDesktop = showDesktopDetected; - ShowDesktopChangedEvent?.Invoke(_showDesktop); - } - } - - private static class NativeMethods - { - private const string USER = "user32.dll"; - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - public static extern IntPtr GetShellWindow(); - - [DllImport(USER, CallingConvention = CallingConvention.Winapi)] - public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int processId); - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/SplitContainerAdv.cs b/LibreHardwareMonitor.Windows.Forms/UI/SplitContainerAdv.cs deleted file mode 100644 index a2da4b5..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/SplitContainerAdv.cs +++ /dev/null @@ -1,125 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Drawing; -using System.Windows.Forms; -using LibreHardwareMonitor.Windows.Forms.UI.Themes; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class SplitContainerAdv : SplitContainer -{ - private int _delta; - private bool _mouseOver; - - public SplitContainerAdv() - { - 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(_mouseOver ? Theme.Current.SplitterHoverColor : Theme.Current.SplitterColor)) - g.FillRectangle(brush, r); - } - - protected override void OnKeyDown(KeyEventArgs e) - { - if (!IsSplitterFixed) - { - switch (e.KeyData) - { - case Keys.Right: - case Keys.Down: - SplitterDistance += SplitterIncrement; - break; - case Keys.Left: - case Keys.Up: - SplitterDistance -= SplitterIncrement; - break; - } - - Invalidate(); - } - } - - protected override void OnMouseDown(MouseEventArgs e) - { - if (Orientation == Orientation.Vertical) - { - _delta = SplitterDistance - e.X; - Cursor.Current = Cursors.VSplit; - } - else - { - _delta = SplitterDistance - e.Y; - Cursor.Current = Cursors.HSplit; - } - IsSplitterFixed = true; - } - - protected override void OnMouseEnter(EventArgs e) - { - base.OnMouseEnter(e); - _mouseOver = true; - Invalidate(); - } - - protected override void OnMouseMove(MouseEventArgs e) - { - if (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 - { - 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; - _mouseOver = false; - Invalidate(); - } - - protected override void OnMouseUp(MouseEventArgs e) - { - _delta = 0; - IsSplitterFixed = false; - Cursor.Current = Cursors.Default; - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/StartupManager.cs b/LibreHardwareMonitor.Windows.Forms/UI/StartupManager.cs deleted file mode 100644 index 18e610a..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/StartupManager.cs +++ /dev/null @@ -1,180 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.IO; -using System.Linq; -using System.Security; -using System.Security.Principal; -using System.Windows.Forms; -using Microsoft.Win32; -using Microsoft.Win32.TaskScheduler; -using Action = Microsoft.Win32.TaskScheduler.Action; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class StartupManager -{ - private const string RegistryPath = @"Software\Microsoft\Windows\CurrentVersion\Run"; - private bool _startup; - - public StartupManager() - { - if (Environment.OSVersion.Platform >= PlatformID.Unix) - { - IsAvailable = false; - return; - } - - if (IsAdministrator() && TaskService.Instance.Connected) - { - IsAvailable = true; - - Task task = GetTask(); - if (task != null) - { - foreach (Action action in task.Definition.Actions) - { - if (action.ActionType == TaskActionType.Execute && action is ExecAction execAction) - { - if (execAction.Path.Equals(Application.ExecutablePath, StringComparison.OrdinalIgnoreCase)) - _startup = true; - } - } - } - } - else - { - try - { - using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(RegistryPath)) - { - string value = (string)registryKey?.GetValue(nameof(LibreHardwareMonitor)); - - if (value != null) - _startup = value == Application.ExecutablePath; - } - - IsAvailable = true; - } - catch (SecurityException) - { - IsAvailable = false; - } - } - } - - public bool IsAvailable { get; } - - public bool Startup - { - get { return _startup; } - set - { - if (_startup != value) - { - if (IsAvailable) - { - if (TaskService.Instance.Connected) - { - if (value) - CreateTask(); - else - DeleteTask(); - - _startup = value; - } - else - { - try - { - if (value) - CreateRegistryKey(); - else - DeleteRegistryKey(); - - _startup = value; - } - catch (UnauthorizedAccessException) - { - throw new InvalidOperationException(); - } - } - } - else - { - throw new InvalidOperationException(); - } - } - } - } - - private static bool IsAdministrator() - { - try - { - WindowsIdentity identity = WindowsIdentity.GetCurrent(); - WindowsPrincipal principal = new WindowsPrincipal(identity); - - return principal.IsInRole(WindowsBuiltInRole.Administrator); - } - catch - { - return false; - } - } - - private static Task GetTask() - { - try - { - return TaskService.Instance.AllTasks.FirstOrDefault(x => x.Name.Equals(nameof(LibreHardwareMonitor), StringComparison.OrdinalIgnoreCase)); - } - catch - { - return null; - } - } - - private void CreateTask() - { - TaskDefinition taskDefinition = TaskService.Instance.NewTask(); - taskDefinition.RegistrationInfo.Description = "Starts LibreHardwareMonitor on Windows startup."; - - taskDefinition.Triggers.Add(new LogonTrigger()); - - taskDefinition.Settings.StartWhenAvailable = true; - taskDefinition.Settings.DisallowStartIfOnBatteries = false; - taskDefinition.Settings.StopIfGoingOnBatteries = false; - taskDefinition.Settings.ExecutionTimeLimit = TimeSpan.Zero; - taskDefinition.Settings.AllowHardTerminate = false; - - taskDefinition.Principal.RunLevel = TaskRunLevel.Highest; - taskDefinition.Principal.LogonType = TaskLogonType.InteractiveToken; - - taskDefinition.Actions.Add(new ExecAction(Application.ExecutablePath, "", Path.GetDirectoryName(Application.ExecutablePath))); - - TaskService.Instance.RootFolder.RegisterTaskDefinition(nameof(LibreHardwareMonitor), taskDefinition); - } - - private static void DeleteTask() - { - Task task = GetTask(); - task?.Folder.DeleteTask(task.Name, false); - } - - private static void CreateRegistryKey() - { - RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistryPath); - registryKey?.SetValue(nameof(LibreHardwareMonitor), Application.ExecutablePath); - } - - private static void DeleteRegistryKey() - { - RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistryPath); - registryKey?.DeleteValue(nameof(LibreHardwareMonitor)); - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/SystemTray.cs b/LibreHardwareMonitor.Windows.Forms/UI/SystemTray.cs deleted file mode 100644 index 580fcf3..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/SystemTray.cs +++ /dev/null @@ -1,200 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using LibreHardwareMonitor.Hardware; -using LibreHardwareMonitor.Windows.Forms.Utilities; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class SystemTray : IDisposable -{ - private IComputer _computer; - private readonly PersistentSettings _settings; - private readonly UnitManager _unitManager; - private readonly List _sensorList = new List(); - private bool _mainIconEnabled; - private readonly NotifyIconAdv _mainIcon; - private readonly System.Threading.SynchronizationContext _uiSyncContext; - - public SystemTray(IComputer computer, PersistentSettings settings, UnitManager unitManager) - { - _computer = computer; - _settings = settings; - _unitManager = unitManager; - // Captured on the UI thread so the now-possibly-background HardwareAdded/HardwareRemoved re-dispatch here. - _uiSyncContext = System.Threading.SynchronizationContext.Current; - computer.HardwareAdded += HardwareAdded; - computer.HardwareRemoved += HardwareRemoved; - - _mainIcon = new NotifyIconAdv(); - - ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); - ToolStripItem hideShowItem = new ToolStripMenuItem("Hide/Show"); - hideShowItem.Click += delegate - { - SendHideShowCommand(); - }; - contextMenuStrip.Items.Add(hideShowItem); - contextMenuStrip.Items.Add(new ToolStripSeparator()); - ToolStripItem exitItem = new ToolStripMenuItem("Exit"); - exitItem.Click += delegate - { - SendExitCommand(); - }; - contextMenuStrip.Items.Add(exitItem); - _mainIcon.ContextMenuStrip = contextMenuStrip; - _mainIcon.DoubleClick += delegate - { - SendHideShowCommand(); - }; - _mainIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico"); - _mainIcon.Text = "Libre Hardware Monitor"; - } - - private void HardwareRemoved(IHardware hardware) - { - if (_uiSyncContext != null && System.Threading.SynchronizationContext.Current != _uiSyncContext) - { - _uiSyncContext.Post(_ => HardwareRemoved(hardware), null); - return; - } - - hardware.SensorAdded -= SensorAdded; - hardware.SensorRemoved -= SensorRemoved; - - foreach (ISensor sensor in hardware.Sensors) - SensorRemoved(sensor); - - foreach (IHardware subHardware in hardware.SubHardware) - HardwareRemoved(subHardware); - } - - private void HardwareAdded(IHardware hardware) - { - if (_uiSyncContext != null && System.Threading.SynchronizationContext.Current != _uiSyncContext) - { - _uiSyncContext.Post(_ => HardwareAdded(hardware), null); - return; - } - - foreach (ISensor sensor in hardware.Sensors) - SensorAdded(sensor); - - hardware.SensorAdded += SensorAdded; - hardware.SensorRemoved += SensorRemoved; - - foreach (IHardware subHardware in hardware.SubHardware) - HardwareAdded(subHardware); - } - - private void SensorAdded(ISensor sensor) - { - if (_settings.GetValue(new Identifier(sensor.Identifier, "tray").ToString(), false)) - Add(sensor, false); - } - - private void SensorRemoved(ISensor sensor) - { - if (Contains(sensor)) - Remove(sensor, false); - } - - public void Dispose() - { - foreach (SensorNotifyIcon icon in _sensorList) - icon.Dispose(); - _mainIcon.Dispose(); - } - - public void Redraw() - { - foreach (SensorNotifyIcon icon in _sensorList) - icon.Update(); - } - - public bool Contains(ISensor sensor) - { - foreach (SensorNotifyIcon icon in _sensorList) - if (icon.Sensor == sensor) - return true; - return false; - } - - public void Add(ISensor sensor, bool balloonTip) - { - if (Contains(sensor)) - return; - - - _sensorList.Add(new SensorNotifyIcon(this, sensor, _settings, _unitManager)); - UpdateMainIconVisibility(); - _settings.SetValue(new Identifier(sensor.Identifier, "tray").ToString(), true); - } - - public void Remove(ISensor sensor) - { - Remove(sensor, true); - } - - private void Remove(ISensor sensor, bool deleteConfig) - { - if (deleteConfig) - { - _settings.Remove(new Identifier(sensor.Identifier, "tray").ToString()); - _settings.Remove(new Identifier(sensor.Identifier, "traycolor").ToString()); - } - SensorNotifyIcon instance = null; - foreach (SensorNotifyIcon icon in _sensorList) - { - if (icon.Sensor == sensor) - instance = icon; - } - if (instance != null) - { - _sensorList.Remove(instance); - UpdateMainIconVisibility(); - instance.Dispose(); - } - } - - public event EventHandler HideShowCommand; - - public void SendHideShowCommand() - { - HideShowCommand?.Invoke(this, null); - } - - public event EventHandler ExitCommand; - - public void SendExitCommand() - { - ExitCommand?.Invoke(this, null); - } - - private void UpdateMainIconVisibility() - { - if (_mainIconEnabled) - _mainIcon.Visible = _sensorList.Count == 0; - else - _mainIcon.Visible = false; - } - - public bool IsMainIconEnabled - { - get { return _mainIconEnabled; } - set - { - if (_mainIconEnabled != value) - { - _mainIconEnabled = value; - UpdateMainIconVisibility(); - } - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/Theme.cs b/LibreHardwareMonitor.Windows.Forms/UI/Theme.cs deleted file mode 100644 index 33d7f0f..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/Theme.cs +++ /dev/null @@ -1,297 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using Aga.Controls.Tree; -using Microsoft.Win32; - -namespace LibreHardwareMonitor.Windows.Forms.UI.Themes -{ - public abstract class Theme - { - private static Theme _current = new LightTheme(); - public static Theme Current - { - get { return _current; } - set - { - _current = value; - foreach (Form form in Application.OpenForms) - { - _current.Apply(form); - } - - Init(); - } - } - - private static void Init() - { - TreeViewAdv.CustomPlusMinusRenderFunc = (g, rect, isExpanded) => - { - int x = rect.Left; - int y = rect.Top + 5; - int size = 8; - using (Brush brush = new SolidBrush(Current.BackgroundColor)) - { - g.FillRectangle(brush, x - 1, y - 1, size + 4, size + 4); - } - using (Pen pen = new Pen(Current.TreeOutlineColor)) - { - - g.DrawRectangle(pen, x, y, size, size); - g.DrawLine(pen, x + 2, y + (size / 2), x + size - 2, y + (size / 2)); - if (!isExpanded) - { - g.DrawLine(pen, x + (size / 2), y + 2, x + (size / 2), y + size - 2); - } - } - }; - - TreeViewAdv.CustomCheckRenderFunc = (g, rect, isChecked) => - { - int x = rect.Left; - int y = rect.Top + 1; - int size = 12; - using (Brush brush = new SolidBrush(Current.BackgroundColor)) - { - g.FillRectangle(brush, x - 1, y - 1, 12, 12); - } - using (Pen pen = new Pen(Current.TreeOutlineColor)) - { - g.DrawRectangle(pen, x, y, size, size); - if (isChecked) - { - x += 3; - y += 3; - g.DrawLine(pen, x, y + 3, x + 2, y + 5); - g.DrawLine(pen, x + 2, y + 5, x + 6, y + 1); - g.DrawLine(pen, x, y + 4, x + 2, y + 6); - g.DrawLine(pen, x + 2, y + 6, x + 6, y + 2); - } - } - }; - - TreeViewAdv.CustomColumnBackgroundRenderFunc = (g, rect, isPressed, isHot) => - { - using (Brush brush = new SolidBrush(Current.TreeBackgroundColor)) - { - g.FillRectangle(brush, rect); - } - using (Pen pen = new Pen(Current.TreeRowSepearatorColor)) - { - g.DrawLine(pen, rect.Left, rect.Top, rect.Right, rect.Top); - g.DrawLine(pen, rect.Left, rect.Top + 1, rect.Right, rect.Top + 1); - } - }; - - TreeViewAdv.CustomColumnTextRenderFunc = (g, rect, font, text) => - { - TextRenderer.DrawText(g, text, font, rect, Current.TreeTextColor, TextFormatFlags.Left); - }; - - TreeViewAdv.CustomHorizontalLinePen = new Pen(Current.TreeRowSepearatorColor); - TreeViewAdv.CustomSelectedRowBrush = new SolidBrush(Current.TreeSelectedBackgroundColor); - TreeViewAdv.CustomSelectedTextColor = Current.TreeSelectedTextColor; - } - - private static List _all; - public static List All - { - get - { - if (_all == null) - { - _all = new List(); - foreach (Type type in typeof(Theme).Assembly.GetTypes()) - { - if (type != typeof(Theme) && typeof(Theme).IsAssignableFrom(type)) - { - _all.Add((Theme)type.GetConstructor(new Type[] { }).Invoke(new object[] { })); - } - } - } - return _all.OrderBy(x => x.DisplayName).ToList(); - } - } - - public static bool SupportsAutoThemeSwitching() - { - if (Software.OperatingSystem.IsUnix) - { - return false; - } - - if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", -1) is int useLightTheme) - { - return useLightTheme != -1; - } - return false; - } - - public static void SetAutoTheme() - { - if (Software.OperatingSystem.IsUnix) - { - return; - } - - if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 1) is int useLightTheme) - { - if (useLightTheme > 0) - { - Current = new LightTheme(); - } - else - { - Current = new DarkTheme(); - } - } - else - { - // Fallback incase registry fails - Current = new LightTheme(); - } - } - - public Theme(string id, string displayName) - { - Id = id; - DisplayName = displayName; - } - - public string Id { get; } - public string DisplayName { get; } - public abstract Color BackgroundColor { get; } - public abstract Color ForegroundColor { get; } - public abstract Color HyperlinkColor { get; } - public abstract Color LineColor { get; } - public abstract Color StrongLineColor { get; } - public abstract Color SelectedBackgroundColor { get; } - public abstract Color SelectedForegroundColor { get; } - - // button - public virtual Color ButtonBackgroundColor => BackgroundColor; - public virtual Color ButtonBorderColor => ForegroundColor; - public virtual Color ButtonHoverBackgroundColor => SelectedBackgroundColor; - public virtual Color ButtonPressedBackgroundColor => LineColor; - public virtual Color ButtonTextColor => ForegroundColor; - - // menu - public virtual Color MenuBackgroundColor => BackgroundColor; - public virtual Color MenuBorderColor => StrongLineColor; - public virtual Color MenuForegroundColor => ForegroundColor; - public virtual Color MenuSelectedBackgroundColor => SelectedBackgroundColor; - public virtual Color MenuSelectedForegroundColor => SelectedForegroundColor; - - // plot - public virtual Color PlotBackgroundColor => BackgroundColor; - public virtual Color PlotBorderColor => ForegroundColor; - public abstract Color[] PlotColorPalette { get; } - public abstract Color PlotGridMajorColor { get; } - public abstract Color PlotGridMinorColor { get; } - public virtual Color PlotTextColor => ForegroundColor; - - // scrollbar - public virtual Color ScrollbarBackground => BackgroundColor; - public virtual Color ScrollbarTrack => StrongLineColor; - - // splitter - public virtual Color SplitterColor => BackgroundColor; - public virtual Color SplitterHoverColor => SelectedBackgroundColor; - - // tree - public virtual Color TreeBackgroundColor => BackgroundColor; - public virtual Color TreeOutlineColor => ForegroundColor; - public virtual Color TreeSelectedBackgroundColor => SelectedBackgroundColor; - public virtual Color TreeTextColor => ForegroundColor; - public virtual Color TreeSelectedTextColor => SelectedForegroundColor; - public virtual Color TreeRowSepearatorColor => LineColor; - - // window - public virtual Color WindowTitlebarBackgroundColor => BackgroundColor; - public abstract bool WindowTitlebarFallbackToImmersiveDarkMode { get; } - public virtual Color WindowTitlebarForegroundColor => ForegroundColor; - - public void Apply(Form form) - { - if (IsWindows10OrGreater(22000)) - { - // Windows 11, Set the titlebar color based on theme - int color = ColorTranslator.ToWin32(WindowTitlebarBackgroundColor); - DwmSetWindowAttribute(form.Handle, DWMWA_CAPTION_COLOR, ref color, sizeof(int)); - color = ColorTranslator.ToWin32(WindowTitlebarForegroundColor); - DwmSetWindowAttribute(form.Handle, DWMWA_TEXT_COLOR, ref color, sizeof(int)); - } - else if (IsWindows10OrGreater(17763)) - { - // Windows 10, fallback to using "Immersive Dark Mode" instead - var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; - if (IsWindows10OrGreater(18985)) - { - // Windows 10 20H1 or later - attribute = DWMWA_USE_IMMERSIVE_DARK_MODE; - } - int useImmersiveDarkMode = WindowTitlebarFallbackToImmersiveDarkMode ? 1 : 0; - DwmSetWindowAttribute(form.Handle, (int)attribute, ref useImmersiveDarkMode, sizeof(int)); - } - form.BackColor = BackgroundColor; - foreach (Control control in form.Controls) - { - Apply(control); - } - } - - public void Apply(Control control) - { - if (control is Button button) - { - button.ForeColor = ButtonTextColor; - button.FlatStyle = FlatStyle.Flat; - button.FlatAppearance.BorderColor = ButtonBorderColor; - button.FlatAppearance.MouseOverBackColor = ButtonHoverBackgroundColor; - button.FlatAppearance.MouseDownBackColor = ButtonPressedBackgroundColor; - } - else if (control is LinkLabel linkLabel) - { - linkLabel.LinkColor = HyperlinkColor; - } - else if (control is PlotPanel plotPanel) - { - plotPanel.ApplyTheme(); - } - else if (control is TreeViewAdv treeView) - { - treeView.BackColor = TreeBackgroundColor; - treeView.ForeColor = TreeTextColor; - treeView.LineColor = TreeOutlineColor; - } - else - { - control.BackColor = BackgroundColor; - control.ForeColor = ForegroundColor; - } - - foreach (Control child in control.Controls) - { - Apply(child); - } - } - - [DllImport("dwmapi.dll")] - private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize); - - private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; - private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; - private const int DWMWA_BORDER_COLOR = 34; - private const int DWMWA_CAPTION_COLOR = 35; - private const int DWMWA_TEXT_COLOR = 36; - - private static bool IsWindows10OrGreater(int build = -1) - { - return !Software.OperatingSystem.IsUnix && Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build; - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/Themes/BlackTheme.cs b/LibreHardwareMonitor.Windows.Forms/UI/Themes/BlackTheme.cs deleted file mode 100644 index 63badcf..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/Themes/BlackTheme.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Drawing; -using System.Linq; - -namespace LibreHardwareMonitor.Windows.Forms.UI.Themes -{ - public class BlackTheme : LightTheme - { - private readonly Color[] _plotColorPalette; - public override Color ForegroundColor => Color.FromArgb(218, 218, 218); - public override Color BackgroundColor => Color.FromArgb(0, 0, 0); - public override Color HyperlinkColor => Color.FromArgb(144, 220, 232); - public override Color SelectedForegroundColor => ForegroundColor; - public override Color SelectedBackgroundColor => ColorTranslator.FromHtml("#090A17"); - public override Color LineColor => ColorTranslator.FromHtml("#070A12"); - public override Color StrongLineColor => ColorTranslator.FromHtml("#091217"); - public override Color[] PlotColorPalette => _plotColorPalette; - public override Color PlotGridMajorColor => Color.FromArgb(73, 73, 73); - public override Color PlotGridMinorColor => Color.FromArgb(33, 33, 33); - public override bool WindowTitlebarFallbackToImmersiveDarkMode => true; - - public BlackTheme() : base("black", "Black") - { - string[] colors = { - "#FF2525", - "#1200FF", - "#00FF5B", - "#FFE53B", - "#00FFFF", - "#FF0A6C", - "#2D27FF", - "#FF2CDF", - "#00E1FD", - "#0A5057" - }; - - _plotColorPalette = colors.Select(color => ColorTranslator.FromHtml(color)).ToArray(); - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/Themes/DarkTheme.cs b/LibreHardwareMonitor.Windows.Forms/UI/Themes/DarkTheme.cs deleted file mode 100644 index 62ec8d8..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/Themes/DarkTheme.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Drawing; -using System.Linq; - -namespace LibreHardwareMonitor.Windows.Forms.UI.Themes -{ - public class DarkTheme : LightTheme - { - private readonly Color[] _plotColorPalette; - public override Color ForegroundColor => Color.FromArgb(233, 233, 233); - public override Color BackgroundColor => Color.FromArgb(30, 30, 30); - public override Color HyperlinkColor => Color.FromArgb(144, 220, 232); - public override Color SelectedForegroundColor => ForegroundColor; - public override Color SelectedBackgroundColor => Color.FromArgb(45, 45, 45); - public override Color LineColor => Color.FromArgb(38, 38, 38); - public override Color StrongLineColor => Color.FromArgb(53, 53, 53); - public override Color[] PlotColorPalette => _plotColorPalette; - public override Color PlotGridMajorColor => Color.FromArgb(93, 93, 93); - public override Color PlotGridMinorColor => Color.FromArgb(53, 53, 53); - public override bool WindowTitlebarFallbackToImmersiveDarkMode => true; - - public DarkTheme() : base("dark", "Dark") - { - string[] colors = { - "#F07178", - "#82AAFF", - "#C3E88D", - "#FFCB6B", - "#009688", - "#89DDF3", - "#FFE082", - "#7986CB", - "#C792EA", - "#FF5370", - "#73d1c8", - "#F78C6A" - }; - - _plotColorPalette = colors.Select(color => ColorTranslator.FromHtml(color)).ToArray(); - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/Themes/LightTheme.cs b/LibreHardwareMonitor.Windows.Forms/UI/Themes/LightTheme.cs deleted file mode 100644 index 6ff8b76..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/Themes/LightTheme.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Drawing; - -namespace LibreHardwareMonitor.Windows.Forms.UI.Themes -{ - public class LightTheme : Theme - { - private readonly Color[] _plotColorPalette = new Color[] { - Color.Blue, - Color.OrangeRed, - Color.Green, - Color.LightSeaGreen, - Color.Goldenrod, - Color.DarkViolet, - Color.YellowGreen, - Color.SaddleBrown, - Color.RoyalBlue, - Color.DeepPink, - Color.MediumSeaGreen, - Color.Olive, - Color.Firebrick - }; - - public LightTheme(string id, string displayName) : base(id, displayName) { } - public override Color ForegroundColor => Color.FromArgb(0, 0, 0); - public override Color BackgroundColor => Color.FromArgb(255, 255, 255); - public override Color HyperlinkColor => Color.FromArgb(0, 0, 255); - public override Color SelectedForegroundColor => ForegroundColor; - public override Color SelectedBackgroundColor => Color.FromArgb(240, 240, 240); - public override Color LineColor => Color.FromArgb(247, 247, 247); - public override Color StrongLineColor => Color.FromArgb(209, 209, 209); - public override Color[] PlotColorPalette => _plotColorPalette; - public override Color PlotGridMajorColor => Color.FromArgb(192, 192, 192); - public override Color PlotGridMinorColor => Color.FromArgb(232, 232, 232); - public override bool WindowTitlebarFallbackToImmersiveDarkMode => false; - - public LightTheme() : base("light", "Light") { } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/Themes/ThemedHScrollIndicator.cs b/LibreHardwareMonitor.Windows.Forms/UI/Themes/ThemedHScrollIndicator.cs deleted file mode 100644 index 9f27c6f..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/Themes/ThemedHScrollIndicator.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System.Drawing; -using System.Windows.Forms; - -namespace LibreHardwareMonitor.Windows.Forms.UI.Themes -{ - public class ThemedHScrollIndicator : Control - { - private readonly HScrollBar _scrollbar; - private int _startValue = 0; - private int _startPos = 0; - private bool _isScrolling = false; - - public static void AddToControl(Control control) - { - foreach (Control child in control.Controls) - { - if (child is HScrollBar scrollbar) - { - control.Controls.Add(new ThemedHScrollIndicator(scrollbar)); - return; - } - } - } - - public ThemedHScrollIndicator(HScrollBar scrollBar) - { - _scrollbar = scrollBar; - - Height = 8; - SetStyle(ControlStyles.ResizeRedraw, true); - SetStyle(ControlStyles.AllPaintingInWmPaint, true); - SetStyle(ControlStyles.UserPaint, true); - SetStyle(ControlStyles.OptimizedDoubleBuffer, true); - Left = 0; - Top = scrollBar.Parent.Height - Height; - Size = new Size(scrollBar.Parent.Width, Height); - Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom; - Visible = scrollBar.Visible; - - scrollBar.VisibleChanged += (s, e) => Visible = (s as ScrollBar).Visible; - scrollBar.Scroll += (s, e) => Invalidate(); - scrollBar.ValueChanged += (s, e) => Invalidate(); - - scrollBar.Height = 0; - this.MouseDown += OnMouseDown; - } - - private void OnMouseDown(object sender, MouseEventArgs e) - { - if (_isScrolling) - return; - - _isScrolling = true; - - //note: this.Capture is true when the control is clicked, no need to handle this - - _startPos = e.X; - _startValue = _scrollbar.Value; - - this.MouseUp += OnMouseUp; - this.MouseMove += OnMouseMove; - } - - private void OnMouseUp(object sender, MouseEventArgs e) - { - _isScrolling = false; - this.MouseUp -= OnMouseUp; - this.MouseMove -= OnMouseMove; - } - - private void OnMouseMove(object sender, MouseEventArgs e) - { - if (!_isScrolling) - return; - - //pixel to range scaling: - double totalRange = _scrollbar.Maximum - _scrollbar.Minimum; - - if (totalRange <= 0) - return; - - double scaleToPercent = totalRange / Bounds.Width; - double scrollValue = _startValue + (e.X - _startPos) * scaleToPercent; - - if (scrollValue < _scrollbar.Minimum) - scrollValue = _scrollbar.Minimum; - - if (scrollValue > (_scrollbar.Maximum - _scrollbar.LargeChange)) - scrollValue = _scrollbar.Maximum - _scrollbar.LargeChange; - - _scrollbar.Value = (int)scrollValue; - Refresh(); - } - - protected override void OnPaint(PaintEventArgs e) - { - Graphics g = e.Graphics; - - using (SolidBrush brush = new SolidBrush(Theme.Current.ScrollbarBackground)) - g.FillRectangle(brush, new Rectangle(0, 0, Bounds.Width, Bounds.Height)); - - int width = Bounds.Width; - int range = _scrollbar.Maximum - _scrollbar.Minimum; - - if (range > 0) - { - int start = width * (_scrollbar.Value - _scrollbar.Minimum) / range; - int end = width * (_scrollbar.Value - _scrollbar.Minimum + _scrollbar.LargeChange) / range; - using (SolidBrush brush = new SolidBrush(Theme.Current.ScrollbarTrack)) - g.FillRectangle(brush, new Rectangle(start, 2, end - start, Bounds.Height - 4)); - } - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/Themes/ThemedToolStripRenderer.cs b/LibreHardwareMonitor.Windows.Forms/UI/Themes/ThemedToolStripRenderer.cs deleted file mode 100644 index e6f6682..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/Themes/ThemedToolStripRenderer.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Drawing; -using System.Windows.Forms; - -namespace LibreHardwareMonitor.Windows.Forms.UI.Themes -{ - public class ThemedToolStripRenderer : ToolStripRenderer - { - protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) - { - if (e.Item is not ToolStripSeparator) - { - base.OnRenderSeparator(e); - return; - } - - Rectangle bounds = new(Point.Empty, e.Item.Size); - using (Brush brush = new SolidBrush(Theme.Current.MenuBackgroundColor)) - e.Graphics.FillRectangle(brush, bounds); - } - - protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) - { - e.ArrowColor = e.Item.Selected ? Theme.Current.MenuSelectedForegroundColor : Theme.Current.MenuForegroundColor; - base.OnRenderArrow(e); - } - - protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) - { - using (Pen pen = new Pen(e.Item.Selected ? Theme.Current.MenuSelectedForegroundColor : Theme.Current.MenuForegroundColor)) - { - int x = 10; - int y = 6; - e.Graphics.DrawLine(pen, x, y + 3, x + 2, y + 5); - e.Graphics.DrawLine(pen, x + 2, y + 5, x + 6, y + 1); - e.Graphics.DrawLine(pen, x, y + 4, x + 2, y + 6); - e.Graphics.DrawLine(pen, x + 2, y + 6, x + 6, y + 2); - } - } - - protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) - { - e.TextColor = e.Item.Selected ? Theme.Current.MenuSelectedForegroundColor : Theme.Current.MenuForegroundColor; - base.OnRenderItemText(e); - } - - protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) - { - if (e.ToolStrip.Parent is not Form) - { - Rectangle bounds = new(Point.Empty, new Size(e.ToolStrip.Width - 1, e.ToolStrip.Height - 1)); - using (Pen pen = new Pen(Theme.Current.MenuBorderColor)) - e.Graphics.DrawRectangle(pen, bounds); - } - } - - protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) - { - Rectangle bounds = new(Point.Empty, e.ToolStrip.Size); - using (Brush brush = new SolidBrush(Theme.Current.MenuBackgroundColor)) - e.Graphics.FillRectangle(brush, bounds); - } - - protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) - { - Rectangle bounds = new(Point.Empty, e.Item.Size); - - using (Brush brush = new SolidBrush(e.Item.Selected ? Theme.Current.MenuSelectedBackgroundColor : Theme.Current.MenuBackgroundColor)) - e.Graphics.FillRectangle(brush, bounds); - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/Themes/ThemedVScrollIndicator.cs b/LibreHardwareMonitor.Windows.Forms/UI/Themes/ThemedVScrollIndicator.cs deleted file mode 100644 index 31d59a7..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/Themes/ThemedVScrollIndicator.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System.Drawing; -using System.Windows.Forms; - -namespace LibreHardwareMonitor.Windows.Forms.UI.Themes -{ - public class ThemedVScrollIndicator : Control - { - private readonly VScrollBar _scrollbar; - private int _startValue = 0; - private int _startPos = 0; - private bool _isScrolling = false; - - public static void AddToControl(Control control) - { - foreach (Control child in control.Controls) - { - if (child is VScrollBar scrollbar) - { - control.Controls.Add(new ThemedVScrollIndicator(scrollbar)); - return; - } - } - } - - public ThemedVScrollIndicator(VScrollBar scrollBar) - { - _scrollbar = scrollBar; - - Width = 8; - SetStyle(ControlStyles.ResizeRedraw, true); - SetStyle(ControlStyles.AllPaintingInWmPaint, true); - SetStyle(ControlStyles.UserPaint, true); - SetStyle(ControlStyles.OptimizedDoubleBuffer, true); - Left = scrollBar.Parent.Width - Width; - Top = 0; - Size = new Size(Width, scrollBar.Parent.Height); - Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; - Visible = scrollBar.Visible; - - scrollBar.VisibleChanged += (s, e) => Visible = (s as ScrollBar).Visible; - scrollBar.Scroll += (s, e) => Invalidate(); - scrollBar.ValueChanged += (s, e) => Invalidate(); - - scrollBar.Width = 0; - this.MouseDown += OnMouseDown; - } - - private void OnMouseDown(object sender, MouseEventArgs e) - { - if (_isScrolling) - return; - - _isScrolling = true; - - //note: this.Capture is true when the control is clicked, no need to handle this - - _startPos = e.Y; - _startValue = _scrollbar.Value; - - this.MouseUp += OnMouseUp; - this.MouseMove += OnMouseMove; - } - - private void OnMouseUp(object sender, MouseEventArgs e) - { - _isScrolling = false; - this.MouseUp -= OnMouseUp; - this.MouseMove -= OnMouseMove; - } - - private void OnMouseMove(object sender, MouseEventArgs e) - { - if (!_isScrolling) - return; - - //pixel to range scaling: - double totalRange = _scrollbar.Maximum - _scrollbar.Minimum; - - if (totalRange <= 0) - return; - - double scaleToPercent = totalRange / Bounds.Height; - double scrollValue = _startValue + (e.Y - _startPos) * scaleToPercent; - - if (scrollValue < _scrollbar.Minimum) - scrollValue = _scrollbar.Minimum; - - if (scrollValue > (_scrollbar.Maximum - _scrollbar.LargeChange)) - scrollValue = _scrollbar.Maximum - _scrollbar.LargeChange; - - _scrollbar.Value = (int)scrollValue; - Refresh(); - } - - protected override void OnPaint(PaintEventArgs e) - { - Graphics g = e.Graphics; - - using (SolidBrush brush = new SolidBrush(Theme.Current.ScrollbarBackground)) - g.FillRectangle(brush, new Rectangle(0, 0, Bounds.Width, Bounds.Height)); - - int height = Bounds.Height; - int range = _scrollbar.Maximum - _scrollbar.Minimum; - - if (range > 0) - { - int start = height * (_scrollbar.Value - _scrollbar.Minimum) / range; - int end = height * (_scrollbar.Value - _scrollbar.Minimum + _scrollbar.LargeChange) / range; - using (SolidBrush brush = new SolidBrush(Theme.Current.ScrollbarTrack)) - g.FillRectangle(brush, new Rectangle(2, start, Bounds.Width - 4, end - start)); - } - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/ToolStripRadioButtonMenuItem.cs b/LibreHardwareMonitor.Windows.Forms/UI/ToolStripRadioButtonMenuItem.cs deleted file mode 100644 index 467defd..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/ToolStripRadioButtonMenuItem.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; -using System.Windows.Forms.VisualStyles; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -/// -/// https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/how-to-display-option-buttons-in-a-menustrip-windows-forms -/// -public class ToolStripRadioButtonMenuItem : ToolStripMenuItem -{ - public ToolStripRadioButtonMenuItem() - : base() - { - Initialize(); - } - - public ToolStripRadioButtonMenuItem(string text) - : base(text, null, (EventHandler)null) - { - Initialize(); - } - - public ToolStripRadioButtonMenuItem(Image image) - : base(null, image, (EventHandler)null) - { - Initialize(); - } - - public ToolStripRadioButtonMenuItem(string text, Image image) - : base(text, image, (EventHandler)null) - { - Initialize(); - } - - public ToolStripRadioButtonMenuItem(string text, Image image, - EventHandler onClick) - : base(text, image, onClick) - { - Initialize(); - } - - public ToolStripRadioButtonMenuItem(string text, Image image, - EventHandler onClick, string name) - : base(text, image, onClick, name) - { - Initialize(); - } - - public ToolStripRadioButtonMenuItem(string text, Image image, - params ToolStripItem[] dropDownItems) - : base(text, image, dropDownItems) - { - Initialize(); - } - - public ToolStripRadioButtonMenuItem(string text, Image image, - EventHandler onClick, Keys shortcutKeys) - : base(text, image, onClick) - { - Initialize(); - ShortcutKeys = shortcutKeys; - } - - // Called by all constructors to initialize CheckOnClick. - private void Initialize() - { - CheckOnClick = true; - } - - protected override void OnCheckedChanged(EventArgs e) - { - base.OnCheckedChanged(e); - - // If this item is no longer in the checked state or if its - // parent has not yet been initialized, do nothing. - if (!Checked || Parent == null) return; - - // Clear the checked state for all siblings. - foreach (ToolStripItem item in Parent.Items) - { - if (item is ToolStripRadioButtonMenuItem radioItem - && radioItem != this - && radioItem.Checked) - { - radioItem.Checked = false; - - // Only one item can be selected at a time, - // so there is no need to continue. - return; - } - } - } - - protected override void OnClick(EventArgs e) - { - // If the item is already in the checked state, do not call - // the base method, which would toggle the value. - if (Checked) return; - - base.OnClick(e); - } - - // Let the item paint itself, and then paint the RadioButton - // where the check mark is normally displayed. - protected override void OnPaint(PaintEventArgs e) - { - if (Image != null) - { - // If the client sets the Image property, the selection behavior - // remains unchanged, but the RadioButton is not displayed and the - // selection is indicated only by the selection rectangle. - base.OnPaint(e); - return; - } - else - { - // If the Image property is not set, call the base OnPaint method - // with the CheckState property temporarily cleared to prevent - // the check mark from being painted. - CheckState currentState = CheckState; - CheckState = CheckState.Unchecked; - base.OnPaint(e); - CheckState = currentState; - } - - // Determine the correct state of the RadioButton. - RadioButtonState buttonState = RadioButtonState.UncheckedNormal; - if (Enabled) - { - if (mouseDownState) - { - if (Checked) - buttonState = RadioButtonState.CheckedPressed; - else - buttonState = RadioButtonState.UncheckedPressed; - } - else if (mouseHoverState) - { - if (Checked) - buttonState = RadioButtonState.CheckedHot; - else - buttonState = RadioButtonState.UncheckedHot; - } - else - { - if (Checked) - buttonState = RadioButtonState.CheckedNormal; - } - } - else - { - if (Checked) - buttonState = RadioButtonState.CheckedDisabled; - else - buttonState = RadioButtonState.UncheckedDisabled; - } - - // Calculate the position at which to display the RadioButton. - int offset = (ContentRectangle.Height - - RadioButtonRenderer.GetGlyphSize( - e.Graphics, buttonState).Height) / 2; - - Point imageLocation = new Point( - ContentRectangle.Location.X + 4, - ContentRectangle.Location.Y + offset); - - // Paint the RadioButton. - RadioButtonRenderer.DrawRadioButton(e.Graphics, imageLocation, buttonState); - } - - private bool mouseHoverState; - - protected override void OnMouseEnter(EventArgs e) - { - mouseHoverState = true; - - // Force the item to repaint with the new RadioButton state. - Invalidate(); - - base.OnMouseEnter(e); - } - - protected override void OnMouseLeave(EventArgs e) - { - mouseHoverState = false; - base.OnMouseLeave(e); - } - - private bool mouseDownState; - - protected override void OnMouseDown(MouseEventArgs e) - { - mouseDownState = true; - - // Force the item to repaint with the new RadioButton state. - Invalidate(); - - base.OnMouseDown(e); - } - - protected override void OnMouseUp(MouseEventArgs e) - { - mouseDownState = false; - base.OnMouseUp(e); - } - - // Enable the item only if its parent item is in the checked state - // and its Enabled property has not been explicitly set to false. - public override bool Enabled - { - get - { - // Use the base value in design mode to prevent the designer - // from setting the base value to the calculated value. - if (!DesignMode - && OwnerItem is ToolStripMenuItem ownerMenuItem - && ownerMenuItem.CheckOnClick) - { - return base.Enabled && ownerMenuItem.Checked; - } - else - { - return base.Enabled; - } - } - set - { - base.Enabled = value; - } - } - - // When OwnerItem becomes available, if it is a ToolStripMenuItem - // with a CheckOnClick property value of true, subscribe to its - // CheckedChanged event. - protected override void OnOwnerChanged(EventArgs e) - { - if (OwnerItem is ToolStripMenuItem ownerMenuItem - && ownerMenuItem.CheckOnClick) - { - ownerMenuItem.CheckedChanged += - new EventHandler(OwnerMenuItem_CheckedChanged); - } - base.OnOwnerChanged(e); - } - - // When the checked state of the parent item changes, - // repaint the item so that the new Enabled state is displayed. - private void OwnerMenuItem_CheckedChanged(object sender, EventArgs e) - { - Invalidate(); - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/TreeModel.cs b/LibreHardwareMonitor.Windows.Forms/UI/TreeModel.cs deleted file mode 100644 index d475cd8..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/TreeModel.cs +++ /dev/null @@ -1,124 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using Aga.Controls.Tree; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class TreeModel : ITreeModel -{ - private readonly Node _root; - private bool _forceVisible; - - public TreeModel() - { - _root = new Node { Model = this }; - } - - public TreePath GetPath(Node node) - { - if (node == _root) - return TreePath.Empty; - - - Stack stack = new Stack(); - while (node != _root) - { - stack.Push(node); - node = node.Parent; - } - return new TreePath(stack.ToArray()); - } - - public Collection Nodes - { - get { return _root.Nodes; } - } - - private Node GetNode(TreePath treePath) - { - Node parent = _root; - foreach (object obj in treePath.FullPath) - { - if (!(obj is Node node) || node.Parent != parent) - return null; - parent = node; - } - return parent; - } - - public IEnumerable GetChildren(TreePath treePath) - { - Node node = GetNode(treePath); - if (node != null) - { - return node.Nodes.Where(n => _forceVisible || n.IsVisible).ToList(); - } - - return Enumerable.Empty(); - } - - public bool IsLeaf(TreePath treePath) - { - return false; - } - - public bool ForceVisible - { - get - { - return _forceVisible; - } - set - { - if (value != _forceVisible) - { - _forceVisible = value; - OnStructureChanged(_root); - } - } - } - -#pragma warning disable 67 - public event EventHandler NodesChanged; - public event EventHandler StructureChanged; - public event EventHandler NodesInserted; - public event EventHandler NodesRemoved; -#pragma warning restore 67 - - public void OnNodeChanged(Node parent, int index, Node node) - { - if (parent != null) - { - TreePath path = GetPath(parent); - if (path != null) - NodesChanged?.Invoke(this, new TreeModelEventArgs(path, new[] { index }, new object[] { node })); - } - } - - public void OnStructureChanged(Node node) - { - StructureChanged?.Invoke(this, new TreeModelEventArgs(GetPath(node), new object[0])); - } - - public void OnNodeInserted(Node parent, int index, Node node) - { - TreeModelEventArgs args = new TreeModelEventArgs(GetPath(parent), new[] { index }, new object[] { node }); - NodesInserted?.Invoke(this, args); - } - - public void OnNodeRemoved(Node parent, int index, Node node) - { - TreeModelEventArgs args = new TreeModelEventArgs(GetPath(parent), new[] { index }, new object[] { node }); - NodesRemoved?.Invoke(this, args); - } - -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/TypeNode.cs b/LibreHardwareMonitor.Windows.Forms/UI/TypeNode.cs deleted file mode 100644 index 23ab5df..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/TypeNode.cs +++ /dev/null @@ -1,153 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using LibreHardwareMonitor.Hardware; -using LibreHardwareMonitor.Windows.Forms.Utilities; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public sealed class TypeNode : Node, IExpandPersistNode -{ - private readonly PersistentSettings _settings; - private readonly string _expandedIdentifier; - private bool _expanded; - - public TypeNode(SensorType sensorType, Identifier parentId, PersistentSettings settings) - { - SensorType = sensorType; - _expandedIdentifier = new Identifier(parentId, SensorType.ToString(), ".expanded").ToString(); - _settings = settings; - - switch (sensorType) - { - case SensorType.Voltage: - Image = Utilities.EmbeddedResources.GetImage("voltage.png"); - Text = "Voltages"; - break; - case SensorType.Current: - Image = Utilities.EmbeddedResources.GetImage("voltage.png"); - Text = "Currents"; - break; - case SensorType.Energy: - Image = Utilities.EmbeddedResources.GetImage("battery.png"); - Text = "Capacities"; - break; - case SensorType.Clock: - Image = Utilities.EmbeddedResources.GetImage("clock.png"); - Text = "Clocks"; - break; - case SensorType.Load: - Image = Utilities.EmbeddedResources.GetImage("load.png"); - Text = "Load"; - break; - case SensorType.Temperature: - Image = Utilities.EmbeddedResources.GetImage("temperature.png"); - Text = "Temperatures"; - break; - case SensorType.Fan: - Image = Utilities.EmbeddedResources.GetImage("fan.png"); - Text = "Fans"; - break; - case SensorType.Flow: - Image = Utilities.EmbeddedResources.GetImage("flow.png"); - Text = "Flows"; - break; - case SensorType.Control: - Image = Utilities.EmbeddedResources.GetImage("control.png"); - Text = "Controls"; - break; - case SensorType.Level: - Image = Utilities.EmbeddedResources.GetImage("level.png"); - Text = "Levels"; - break; - case SensorType.Power: - Image = Utilities.EmbeddedResources.GetImage("power.png"); - Text = "Powers"; - break; - case SensorType.Data: - Image = Utilities.EmbeddedResources.GetImage("data.png"); - Text = "Data"; - break; - case SensorType.SmallData: - Image = Utilities.EmbeddedResources.GetImage("data.png"); - Text = "Data"; - break; - case SensorType.Factor: - Image = Utilities.EmbeddedResources.GetImage("factor.png"); - Text = "Factors"; - break; - case SensorType.Frequency: - Image = Utilities.EmbeddedResources.GetImage("clock.png"); - Text = "Frequencies"; - break; - case SensorType.Throughput: - Image = Utilities.EmbeddedResources.GetImage("throughput.png"); - Text = "Throughput"; - break; - case SensorType.TimeSpan: - Image = Utilities.EmbeddedResources.GetImage("time.png"); - Text = "Times"; - break; - case SensorType.Timing: - Image = Utilities.EmbeddedResources.GetImage("time.png"); - Text = "Timings"; - break; - case SensorType.Noise: - Image = Utilities.EmbeddedResources.GetImage("loudspeaker.png"); - Text = "Noise Levels"; - break; - case SensorType.Conductivity: - Image = Utilities.EmbeddedResources.GetImage("voltage.png"); - Text = "Conductivities"; - break; - case SensorType.Humidity: - Image = Utilities.EmbeddedResources.GetImage("humidity.png"); - Text = "Humidity Levels"; - break; - } - - NodeAdded += TypeNode_NodeAdded; - NodeRemoved += TypeNode_NodeRemoved; - _expanded = settings.GetValue(_expandedIdentifier, true); - } - - private void TypeNode_NodeRemoved(Node node) - { - node.IsVisibleChanged -= Node_IsVisibleChanged; - Node_IsVisibleChanged(null); - } - - private void TypeNode_NodeAdded(Node node) - { - node.IsVisibleChanged += Node_IsVisibleChanged; - Node_IsVisibleChanged(null); - } - - private void Node_IsVisibleChanged(Node node) - { - foreach (Node n in Nodes) - { - if (n.IsVisible) - { - IsVisible = true; - return; - } - } - IsVisible = false; - } - - public SensorType SensorType { get; } - - public bool Expanded - { - get => _expanded; - set - { - _expanded = value; - _settings.SetValue(_expandedIdentifier, _expanded); - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/UnitManager.cs b/LibreHardwareMonitor.Windows.Forms/UI/UnitManager.cs deleted file mode 100644 index 7c8bc96..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/UnitManager.cs +++ /dev/null @@ -1,43 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using LibreHardwareMonitor.Windows.Forms.Utilities; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public enum TemperatureUnit -{ - Celsius = 0, - Fahrenheit = 1 -} - -public class UnitManager -{ - - private readonly PersistentSettings _settings; - private TemperatureUnit _temperatureUnit; - - public UnitManager(PersistentSettings settings) - { - _settings = settings; - _temperatureUnit = (TemperatureUnit)settings.GetValue("TemperatureUnit", (int)TemperatureUnit.Celsius); - } - - public TemperatureUnit TemperatureUnit - { - get { return _temperatureUnit; } - set - { - _temperatureUnit = value; - _settings.SetValue("TemperatureUnit", (int)_temperatureUnit); - } - } - - public static float? CelsiusToFahrenheit(float? valueInCelsius) - { - return valueInCelsius * 1.8f + 32; - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/UpdateVisitor.cs b/LibreHardwareMonitor.Windows.Forms/UI/UpdateVisitor.cs deleted file mode 100644 index 65b93aa..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/UpdateVisitor.cs +++ /dev/null @@ -1,28 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using LibreHardwareMonitor.Hardware; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class UpdateVisitor : IVisitor -{ - public void VisitComputer(IComputer computer) - { - computer.Traverse(this); - } - - public void VisitHardware(IHardware hardware) - { - hardware.Update(); - foreach (IHardware subHardware in hardware.SubHardware) - subHardware.Accept(this); - } - - public void VisitSensor(ISensor sensor) { } - - public void VisitParameter(IParameter parameter) { } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/UI/UserOption.cs b/LibreHardwareMonitor.Windows.Forms/UI/UserOption.cs deleted file mode 100644 index c3a9420..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/UserOption.cs +++ /dev/null @@ -1,64 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Windows.Forms; -using LibreHardwareMonitor.Windows.Forms.Utilities; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class UserOption -{ - private readonly string _name; - private bool _value; - private readonly ToolStripMenuItem _menuItem; - private event EventHandler _changed; - private readonly PersistentSettings _settings; - - public UserOption(string name, bool value, ToolStripMenuItem menuItem, PersistentSettings settings) - { - _settings = settings; - _name = name; - _value = name != null ? settings.GetValue(name, value) : value; - _menuItem = menuItem; - _menuItem.Checked = _value; - _menuItem.Click += MenuItem_Click; - } - - private void MenuItem_Click(object sender, EventArgs e) - { - Value = !Value; - } - - public bool Value - { - get { return _value; } - set - { - if (_value != value) - { - _value = value; - if (_name != null) - _settings.SetValue(_name, value); - _menuItem.Checked = value; - _changed?.Invoke(this, null); - } - } - } - - public event EventHandler Changed - { - add - { - _changed += value; - _changed?.Invoke(this, null); - } - remove - { - _changed -= value; - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/UI/UserRadioGroup.cs b/LibreHardwareMonitor.Windows.Forms/UI/UserRadioGroup.cs deleted file mode 100644 index b4a6271..0000000 --- a/LibreHardwareMonitor.Windows.Forms/UI/UserRadioGroup.cs +++ /dev/null @@ -1,69 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Windows.Forms; -using LibreHardwareMonitor.Windows.Forms.Utilities; - -namespace LibreHardwareMonitor.Windows.Forms.UI; - -public class UserRadioGroup -{ - private readonly string _name; - private int _value; - private readonly ToolStripMenuItem[] _menuItems; - private event EventHandler _changed; - private readonly PersistentSettings _settings; - - public UserRadioGroup(string name, int value, ToolStripMenuItem[] menuItems, PersistentSettings settings) - { - _settings = settings; - _name = name; - _value = name != null ? settings.GetValue(name, value) : value; - _menuItems = menuItems; - _value = Math.Max(Math.Min(_value, menuItems.Length - 1), 0); - - for (int i = 0; i < _menuItems.Length; i++) - { - _menuItems[i].Checked = i == _value; - int index = i; - _menuItems[i].Click += delegate - { - Value = index; - }; - } - } - - public int Value - { - get { return _value; } - set - { - if (_value != value) - { - _value = value; - if (_name != null) - _settings.SetValue(_name, value); - for (int i = 0; i < _menuItems.Length; i++) - _menuItems[i].Checked = i == value; - _changed?.Invoke(this, null); - } - } - } - - public event EventHandler Changed - { - add - { - _changed += value; - _changed?.Invoke(this, null); - } - remove - { - _changed -= value; - } - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/Utilities/EmbeddedResources.cs b/LibreHardwareMonitor.Windows.Forms/Utilities/EmbeddedResources.cs deleted file mode 100644 index 9996784..0000000 --- a/LibreHardwareMonitor.Windows.Forms/Utilities/EmbeddedResources.cs +++ /dev/null @@ -1,61 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System.Drawing; -using System.IO; -using System.Reflection; - -namespace LibreHardwareMonitor.Windows.Forms.Utilities; - -public class EmbeddedResources -{ - const string ResourceNamespace = $"LibreHardwareMonitor.Windows.Forms.Resources"; - - public static Image GetImage(string name) - { - name = $"{ResourceNamespace}." + name; - string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames(); - - for (int i = 0; i < names.Length; i++) - { - if (names[i].Replace('\\', '.') == name) - { - using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(names[i])) - { - // "You must keep the stream open for the lifetime of the Image." - Image image = Image.FromStream(stream); - - // so we just create a copy of the image - Bitmap bitmap = new Bitmap(image); - - // and dispose it right here - image.Dispose(); - - return bitmap; - } - } - } - return new Bitmap(1, 1); - } - - public static Icon GetIcon(string name) - { - name = $"{ResourceNamespace}." + name; - string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames(); - for (int i = 0; i < names.Length; i++) - { - if (names[i].Replace('\\', '.') == name) - { - using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(names[i])) - { - return new Icon(stream); - } - } - } - return null; - } - -} diff --git a/LibreHardwareMonitor.Windows.Forms/Utilities/HttpServer.cs b/LibreHardwareMonitor.Windows.Forms/Utilities/HttpServer.cs deleted file mode 100644 index 76e291d..0000000 --- a/LibreHardwareMonitor.Windows.Forms/Utilities/HttpServer.cs +++ /dev/null @@ -1,974 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Drawing; -using System.Drawing.Imaging; -using System.Globalization; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Security.Cryptography; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Web; -using LibreHardwareMonitor.Hardware; -using LibreHardwareMonitor.Windows.Forms.UI; - -namespace LibreHardwareMonitor.Windows.Forms.Utilities; - -public class HttpServer -{ - private readonly HttpListener _listener; - private readonly Node _root; - private readonly IElement _rootElement; - private readonly Version _version = typeof(HttpServer).Assembly.GetName().Version; - - private Task _listenerTask; - private CancellationTokenSource _cts; - - public HttpServer(Node node, IElement rootElement, string ip, int port, bool authEnabled = false, string userName = "", string passwordSHA256 = "") - { - _root = node; - _rootElement = rootElement; - ListenerIp = ip; - ListenerPort = port; - AuthEnabled = authEnabled; - UserName = userName; - PasswordSHA256 = passwordSHA256; - - try - { - _listener = new HttpListener { IgnoreWriteExceptions = true }; - } - catch (PlatformNotSupportedException) - { - _listener = null; - } - } - - ~HttpServer() - { - if (PlatformNotSupported) - return; - - StopHttpListener(); - try - { - _listener?.Abort(); - } - catch { } - } - - public bool AuthEnabled { get; set; } - - public string ListenerIp { get; set; } - - public int ListenerPort { get; set; } - - public void SetPassword(string plainPassword) - { - PasswordSHA256 = ComputeSHA256(plainPassword); - } - - public bool PlatformNotSupported - { - get { return _listener == null; } - } - - public string UserName { get; set; } - - public string PasswordSHA256 { get; set; } - - public bool StartHttpListener() - { - if (PlatformNotSupported) - return false; - - try - { - if (_listener.IsListening) - return true; - - // validate that the selected IP exists (it could have been previously selected before switching networks) - IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); - bool ipFound = false; - foreach (IPAddress ip in host.AddressList) - { - if (ListenerIp == ip.ToString()) - { - ipFound = true; - break; - } - } - - if (!ipFound) - { - // default to behavior of previous version if we don't know what interface to use. - ListenerIp = "+"; - } - - string prefix = "http://" + ListenerIp + ":" + ListenerPort + "/"; - - _listener.Prefixes.Clear(); - _listener.Prefixes.Add(prefix); - _listener.Realm = "Libre Hardware Monitor"; - _listener.AuthenticationSchemes = AuthEnabled ? AuthenticationSchemes.Basic : AuthenticationSchemes.Anonymous; - _listener.Start(); - - _cts = new CancellationTokenSource(); - _listenerTask = Task.Run(() => ProcessRequestsAsync(_cts.Token)); - } - catch (Exception) - { - return false; - } - - return true; - } - - public bool StopHttpListener() - { - if (PlatformNotSupported) - return false; - - try - { - _cts?.Cancel(); - _listenerTask?.Wait(TimeSpan.FromSeconds(5)); // Graceful wait - _listener?.Stop(); - _cts?.Dispose(); - } - catch (HttpListenerException) - { } - catch (OperationCanceledException) - { } - catch (NullReferenceException) - { } - catch (Exception) - { } - - return true; - } - - private async Task ProcessRequestsAsync(CancellationToken cancellationToken) - { - while (_listener.IsListening && !cancellationToken.IsCancellationRequested) - { - try - { - var context = await _listener.GetContextAsync(); - _ = Task.Run(() => HandleContextAsync(context), cancellationToken); - } - catch (HttpListenerException ex) when (ex.ErrorCode == 50) - { - // Handle Windows update bug (e.g., 2025-10 Cumulative Update): retry after delay - System.Diagnostics.Debug.WriteLine($"HttpListener error (code {ex.ErrorCode}): {ex.Message}. Retrying in 5 seconds."); - await Task.Delay(5000, cancellationToken); - } - catch (ObjectDisposedException) - { - break; // Listener stopped - } - catch (OperationCanceledException) - { - break; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"Unexpected HttpListener error: {ex.Message}"); - } - } - } - - public static IDictionary ToDictionary(NameValueCollection col) - { - IDictionary dict = new Dictionary(); - foreach (string k in col.AllKeys) - { - dict.Add(k, col[k]); - } - - return dict; - } - - public SensorNode FindSensor(Node node, string id) - { - if (node is SensorNode sNode) - { - if (sNode.Sensor.Identifier.ToString() == id) - return sNode; - } - - foreach (Node child in node.Nodes) - { - SensorNode s = FindSensor(child, id); - if (s != null) - { - return s; - } - } - - return null; - } - public void SetSensorControlValue(SensorNode sNode, string value) - { - if (sNode.Sensor.Control == null) - { - throw new ArgumentException("Specified sensor '" + sNode.Sensor.Identifier + "' can not be set"); - } - - if (value == "null") - { - sNode.Sensor.Control.SetDefault(); - } - else - { - sNode.Sensor.Control.SetSoftware(float.Parse(value, CultureInfo.InvariantCulture)); - } - } - - //Handles "/Sensor" requests. - //Parameters are taken from the query part of the URL. - //Get: - //http://localhost:8085/Sensor?action=Get&id=/some/node/path/0 - //The output is either: - //{"result":"fail","message":"Some error message"} - //or: - //{"result":"ok","value":42.0, "format":"{0:F2} RPM"} - // - //Set: - //http://localhost:8085/Sensor?action=Set&id=/some/node/path/0&value=42.0 - //http://localhost:8085/Sensor?action=Set&id=/some/node/path/0&value=null - //The output is either: - //{"result":"fail","message":"Some error message"} - //or: - //{"result":"ok"} - private void HandleSensorRequest(HttpListenerRequest request, Dictionary result) - { - IDictionary dict = ToDictionary(HttpUtility.ParseQueryString(request.Url.Query)); - - if (dict.ContainsKey("action")) - { - if (dict.ContainsKey("id")) - { - SensorNode sNode = FindSensor(_root, dict["id"]); - - if (sNode == null) - { - throw new ArgumentException("Unknown id " + dict["id"] + " specified"); - } - - if (dict["action"] == "ResetMinMax") - { - // Reset Min/Max, then return Sensor values... - sNode.Sensor.ResetMin(); - sNode.Sensor.ResetMax(); - dict["action"] = "Get"; - } - - switch (dict["action"]) - { - case "Set" when dict.ContainsKey("value"): - SetSensorControlValue(sNode, dict["value"]); - break; - case "Set": - throw new ArgumentNullException("No value provided"); - case "Get": - result["value"] = sNode.Sensor.Value; - result["min"] = sNode.Sensor.Min; - result["max"] = sNode.Sensor.Max; - result["format"] = sNode.Format; - break; - default: - throw new ArgumentException("Unknown action type " + dict["action"]); - } - } - else - { - throw new ArgumentNullException("No id provided"); - } - } - else - { - throw new ArgumentNullException("No action provided"); - } - } - - //Handles http POST requests in a REST like manner. - //Currently the only supported base URL is http://localhost:8085/Sensor. - private string HandlePostRequest(HttpListenerRequest request) - { - var result = new Dictionary { ["result"] = "ok" }; - - try - { - if (request.Url.Segments.Length == 2) - { - if (request.Url.Segments[1] == "Sensor") - { - HandleSensorRequest(request, result); - } - else - { - throw new ArgumentException("Invalid URL ('" + request.Url.Segments[1] + "'), possible values: ['Sensor']"); - } - } - else - throw new ArgumentException("Empty URL, possible values: ['Sensor']"); - } - catch (Exception e) - { - result["result"] = "fail"; - result["message"] = e.ToString(); - } - return System.Text.Json.JsonSerializer.Serialize(result); - } - - private async Task HandleContextAsync(HttpListenerContext context) - { - HttpListenerRequest request = context.Request; - bool authenticated = true; - - if (AuthEnabled) - { - try - { - HttpListenerBasicIdentity identity = (HttpListenerBasicIdentity)context.User.Identity; - authenticated = (identity.Name == UserName) && (ComputeSHA256(identity.Password) == PasswordSHA256); - } - catch - { - authenticated = false; - } - } - - if (authenticated) - { - switch (request.HttpMethod) - { - case "POST": - { - string postResult = HandlePostRequest(request); - await SendResponseAsync(context.Response, postResult, "application/json"); - break; - } - case "GET": - { - string requestedFile = request.RawUrl.Substring(1); - - if (requestedFile == "data.json") - { - await SendJsonAsync(context.Response, request); - return; - } - - if (requestedFile.Contains("images_icon")) - { - await ServeResourceImageAsync(context.Response, requestedFile.Replace("images_icon/", string.Empty)); - return; - } - - if (requestedFile.StartsWith("metrics?") || requestedFile == "metrics") - { - await SendPrometheusAsync(context.Response, request); - return; - } - - if (requestedFile.Contains("Sensor")) - { - var sensorResult = new Dictionary(); - HandleSensorRequest(request, sensorResult); - await SendJsonSensorAsync(context.Response, sensorResult); - return; - } - - if (requestedFile.Contains("ResetAllMinMax")) - { - _rootElement.Accept(new SensorVisitor(delegate (ISensor sensor) - { - sensor.ResetMin(); - sensor.ResetMax(); - })); - await SendJsonAsync(context.Response, request); - return; - } - - // default file to be served - if (string.IsNullOrEmpty(requestedFile)) - requestedFile = "index.html"; - - string[] splits = requestedFile.Split('.'); - string ext = splits[splits.Length - 1]; - await ServeResourceFileAsync(context.Response, "Web." + requestedFile.Replace('/', '.'), ext); - break; - } - default: - { - context.Response.StatusCode = 404; - break; - } - } - } - else - { - context.Response.StatusCode = 401; - } - - if (context.Response.StatusCode == 401) - { - const string responseString = @"401 Unauthorized -

401 Unauthorized

- Authorization required. "; - - await SendResponseAsync(context.Response, responseString, "text/html"); - } - - try - { - context.Response.Close(); - } - catch - { - // client closed connection before the content was sent - } - } - private async Task ServeResourceFileAsync(HttpListenerResponse response, string name, string ext) - { - // resource names do not support the hyphen - name = Assembly.GetExecutingAssembly().GetName().Name + ".Resources." + - name.Replace("custom-theme", "custom_theme"); - - string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames(); - - for (int i = 0; i < names.Length; i++) - { - if (names[i].Replace('\\', '.') == name) - { - using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(names[i]); - - response.ContentType = GetContentType("." + ext); - response.ContentLength64 = stream.Length; - byte[] buffer = new byte[512 * 1024]; - try - { - int len; - while ((len = await stream.ReadAsync(buffer, 0, buffer.Length)) > 0) - { - await response.OutputStream.WriteAsync(buffer, 0, len); - } - - await response.OutputStream.FlushAsync(); - response.OutputStream.Close(); - response.Close(); - } - catch (HttpListenerException) - { } - catch (InvalidOperationException) - { } - - return; - } - } - - response.StatusCode = 404; - response.Close(); - } - - private async Task ServeResourceImageAsync(HttpListenerResponse response, string name) - { - name = Assembly.GetExecutingAssembly().GetName().Name + ".Resources." + name; - - string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames(); - - for (int i = 0; i < names.Length; i++) - { - if (names[i].Replace('\\', '.') == name) - { - using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(names[i]); - - using Image image = Image.FromStream(stream); - response.ContentType = "image/png"; - try - { - using var ms = new MemoryStream(); - image.Save(ms, ImageFormat.Png); - byte[] buffer = ms.ToArray(); - await response.OutputStream.WriteAsync(buffer, 0, buffer.Length); - response.OutputStream.Close(); - } - catch (HttpListenerException) - { } - - response.Close(); - return; - } - } - - response.StatusCode = 404; - response.Close(); - } - - private async Task SendJsonAsync(HttpListenerResponse response, HttpListenerRequest request = null) - { - Dictionary json = new(); - - int nodeIndex = 0; - - json["id"] = nodeIndex++; - json["Version"] = $"{_version.Major}.{_version.Minor}.{_version.Build}"; - json["Text"] = "Sensor"; - json["Min"] = "Min"; - json["Value"] = "Value"; - json["Max"] = "Max"; - json["ImageURL"] = string.Empty; - - json["Children"] = new List { GenerateJsonForNode(_root, ref nodeIndex) }; - - byte[] buffer = Encoding.UTF8.GetBytes(System.Text.Json.JsonSerializer.Serialize( - json, - new System.Text.Json.JsonSerializerOptions - { - NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals, // Allow "NaN" - } - )); - - bool acceptGzip; - try - { - acceptGzip = (request != null) && (request.Headers["Accept-Encoding"].IndexOf("gzip", StringComparison.OrdinalIgnoreCase) >= 0); - } - catch - { - acceptGzip = false; - } - - response.AddHeader("Cache-Control", "no-cache"); - response.AddHeader("Access-Control-Allow-Origin", "*"); - response.ContentType = "application/json"; - - try - { - if (acceptGzip) - { - response.AddHeader("Content-Encoding", "gzip"); - using var ms = new MemoryStream(); - using (var zip = new GZipStream(ms, CompressionMode.Compress, true)) - await zip.WriteAsync(buffer, 0, buffer.Length); - - buffer = ms.ToArray(); - } - - response.ContentLength64 = buffer.Length; - await response.OutputStream.WriteAsync(buffer, 0, buffer.Length); - response.OutputStream.Close(); - } - catch (HttpListenerException) - { } - - response.Close(); - } - - private string GeneratePrometheusResponse(Node node, Dictionary prometheusSettings) - { - string responseStr = ""; - string lastTagName = ""; - - /// Dictionary to convert all data to base units for OpenMetrics - /// SensorType, Item1 suffix, Item2 factor - var units = new Dictionary - { - { SensorType.Clock, ("hertz", 1000000)}, //originally megahertz - { SensorType.Conductivity, ("seconds_per_centimeter", 0.000001) }, //originally microseconds per centimeter - { SensorType.Control, ("percent", 1) }, - { SensorType.Current, ("amperes", 1) }, - { SensorType.Data, ("bytes", 1000000000) }, //originally GB - { SensorType.Energy, ("watthour", 0.001) }, - { SensorType.Factor, ("", 1) }, - { SensorType.Fan, ("rpm", 1) }, - { SensorType.Flow, ("liters_per_hour", 1) }, - { SensorType.Frequency, ("hertz", 1) }, - { SensorType.Humidity, ("percent", 1) }, - { SensorType.Level, ("percent", 1) }, - { SensorType.Load, ("percent", 1) }, - { SensorType.Noise, ("decibels", 1) }, - { SensorType.Power, ("watts", 1) }, - { SensorType.SmallData, ("bytes", 1024*1024) }, //originally MiB - { SensorType.Temperature, ("celsius", 1) }, - { SensorType.Throughput, ("bytes_per_second", 1) }, - { SensorType.TimeSpan, ("seconds", 1) }, - { SensorType.Timing, ("seconds", 0.000000001 ) }, //originally nanoseconds - { SensorType.Voltage, ("volts", 1) }, - }; - - for (int i = 0; i < node.Nodes.Count; i++) - { - if (node.Nodes[i].GetType().Name == "HardwareNode") - { - responseStr += GeneratePrometheusResponse(node.Nodes[i], prometheusSettings); - } - - if (node.Nodes[i].GetType().Name == "TypeNode") - { - string tagHardware = ""; - string valueHardwareName = ""; - string valueHardwareId = ((HardwareNode)node).Hardware.Identifier.ToString(); - - if (((HardwareNode)node).Hardware.Parent != null) - { - tagHardware = ((HardwareNode)node).Hardware.Parent.HardwareType.ToString(); - valueHardwareName = ((HardwareNode)node).Hardware.Parent.Name; - } - else - { - tagHardware = ((HardwareNode)node).Hardware.HardwareType.ToString(); - valueHardwareName = node.Text; - } - - string valueHardwareAlias = $"{valueHardwareName} ({valueHardwareId})"; - - foreach (SensorNode sensor in node.Nodes[i].Nodes) - { - string valueSensorName = sensor.Text.Replace("#", String.Empty); - - // Variables needed in dictionary lookup and error message - string tagSensorType = sensor.Sensor.SensorType.ToString(); - - double factor = 1; - string tagSensorUnits = ""; - - // Get factor and unit suffix from dictionary ... - if (units.ContainsKey(sensor.Sensor.SensorType)) - { - factor = units[sensor.Sensor.SensorType].Item2; - tagSensorUnits = (units[sensor.Sensor.SensorType].Item1.Length == 0 ? String.Empty : "_" + units[sensor.Sensor.SensorType].Item1); - } - // ... or print an error message - else - { - responseStr += $"# HELP {tagHardware}_{tagSensorType}:{valueSensorName} This Sensor type is not defined in the prometheus adapter [{sensor.Sensor.SensorType}]\n"; - } - - // Creating the tag name for prometheus - string tagName = $"lhm_{tagHardware}_{tagSensorType}{tagSensorUnits}"; - tagName = tagName.ToLower(); - - // Preparing the labels for all data and uniqueness - string valueSensorId = sensor.Sensor.Identifier.ToString().Substring(valueHardwareId.Length); - string valueSensorAlias = $"{valueSensorName} ({valueSensorId})"; - string valueHost = _root.Text; - - // Creates the tag with labels - string tagLine = $$"""{{tagName}} {"sensorName"="{{valueSensorName}}", "sensorAlias"="{{valueSensorAlias}}", "hardwareName"="{{valueHardwareName}}", "hardwareAlias"="{{valueHardwareAlias}}", "sensorId"="{{valueSensorId}}", "hardwareId"="{{valueHardwareId}}", "host"="{{valueHost}}"}"""; - - if (lastTagName != tagName) - { - responseStr += $"# TYPE {tagName} gauge\n"; - lastTagName = tagName; - } - - int counter = 0; - foreach (SensorValue val in sensor.Sensor.Values.Reverse()) - { - if (counter++ > prometheusSettings["archivelength"]) - break; - - if (float.IsNaN(val.Value)) - { - // Print a help line saying what tag had an invalid value - responseStr += $"# HELP {tagLine} has an invalid value and was skipped.\n"; - } - else - { - if (counter == 1 && prometheusSettings["lastvalue"] == 0) - continue; // skip the first value in the list - - if (prometheusSettings["timestamps"] == 1) - { - responseStr += $"{tagLine} {(val.Value * factor).ToString(CultureInfo.InvariantCulture)} {((DateTimeOffset)val.Time).ToUnixTimeMilliseconds()}\n"; - } - else - { - responseStr += $"{tagLine} {(val.Value * factor).ToString(CultureInfo.InvariantCulture)}\n"; - } - } - } - } - } - } - return responseStr; - } - - private async Task SendPrometheusAsync(HttpListenerResponse response, HttpListenerRequest request = null) - { - Dictionary prometheusSettings = new Dictionary(); - //Default values: archivelength=0, timestamps=0, lastvalue=1 - prometheusSettings["archivelength"] = 0; - prometheusSettings["timestamps"] = 0; - prometheusSettings["lastvalue"] = 1; - - if (request != null && request.QueryString != null && request.QueryString.Count > 0) - { - int archive = 0, timestamps = 0, lastvalue = 1; - - foreach (string key in request.QueryString.AllKeys) - { - switch (key) - { - case "timestamps": - int.TryParse(request.QueryString[key], out timestamps); - - if (timestamps < 0 || timestamps > 1) - timestamps = 0; // Enforce boolean range 0 to 1 - - if (archive > 0) - timestamps = 1; // If archive is requested, timestamps must be enabled - - break; - case "archivelength": - int.TryParse(request.QueryString[key], out archive); - archive = Math.Min(10, archive); // Enforce max 10 - archive = Math.Max(0, archive); // Enforce min 0 - - if (archive == 0 && lastvalue == 0) - archive = 1; // If lastvalue was not requested then return at least 1 archived value - - if (archive > 0) - timestamps = 1; // If archive is requested, timestamps must be enabled - - break; - case "lastvalue": - int.TryParse(request.QueryString[key], out lastvalue); - - if (lastvalue < 0 || lastvalue > 1) - lastvalue = 1; // Enforce boolean range 0 to 1 - - if (lastvalue == 0 && archive == 0) - { - archive = 1; - timestamps = 1; - } - - break; - default: - break; - } - } - - prometheusSettings["archivelength"] = archive; - prometheusSettings["timestamps"] = timestamps; - prometheusSettings["lastvalue"] = lastvalue; - } - - string responseContent = GeneratePrometheusResponse(_root, prometheusSettings); - response.AddHeader("Cache-Control", "no-cache"); - response.AddHeader("Access-Control-Allow-Origin", "*"); - - // Add custom headers to inform the user what settings are in effect - response.AddHeader("X-archivelength", prometheusSettings["archivelength"].ToString()); - response.AddHeader("X-timestamps", prometheusSettings["timestamps"].ToString()); - response.AddHeader("X-lastvalue", prometheusSettings["lastvalue"].ToString()); - - await SendResponseAsync(response, responseContent, "text/plain"); - } - - private async Task SendJsonSensorAsync(HttpListenerResponse response, Dictionary sensorData) - { - // Convert the JObject to a JSON string - string responseContent = System.Text.Json.JsonSerializer.Serialize(sensorData); - response.AddHeader("Cache-Control", "no-cache"); - response.AddHeader("Access-Control-Allow-Origin", "*"); - await SendResponseAsync(response, responseContent, "application/json"); - } - - private Dictionary GenerateJsonForNode(Node n, ref int nodeIndex) - { - Dictionary jsonNode = new() - { - ["id"] = nodeIndex++, - ["Text"] = n.Text, - ["Min"] = string.Empty, - ["Value"] = string.Empty, - ["Max"] = string.Empty - }; - - switch (n) - { - case SensorNode sensorNode: - jsonNode["SensorId"] = sensorNode.Sensor.Identifier.ToString(); - jsonNode["Type"] = sensorNode.Sensor.SensorType.ToString(); - - // Formatted values, e.g. Throughput will be measured in KB/s or MB/s depending on the value - jsonNode["Min"] = sensorNode.Min; - jsonNode["Value"] = sensorNode.Value; - jsonNode["Max"] = sensorNode.Max; - - // Unformatted values for external systems to have consistent readings, e.g. Throughput will always be measured in B/s - jsonNode["RawMin"] = sensorNode.Sensor.Min; - jsonNode["RawValue"] = sensorNode.Sensor.Value; - jsonNode["RawMax"] = sensorNode.Sensor.Max; - - jsonNode["ImageURL"] = "images/transparent.png"; - break; - case HardwareNode hardwareNode: - jsonNode["HardwareId"] = hardwareNode.Hardware.Identifier.ToString(); - jsonNode["ImageURL"] = "images_icon/" + GetHardwareImageFile(hardwareNode); - break; - case TypeNode typeNode: - jsonNode["ImageURL"] = "images_icon/" + GetTypeImageFile(typeNode); - break; - default: - jsonNode["ImageURL"] = "images_icon/computer.png"; - break; - } - - List children = new(); - foreach (Node child in n.Nodes) - { - children.Add(GenerateJsonForNode(child, ref nodeIndex)); - } - - jsonNode["Children"] = children; - - return jsonNode; - } - - private static string GetContentType(string extension) - { - switch (extension) - { - case ".avi": return "video/x-msvideo"; - case ".css": return "text/css"; - case ".doc": return "application/msword"; - case ".gif": return "image/gif"; - case ".htm": - case ".html": return "text/html"; - case ".jpg": - case ".jpeg": return "image/jpeg"; - case ".js": return "application/x-javascript"; - case ".mp3": return "audio/mpeg"; - case ".png": return "image/png"; - case ".pdf": return "application/pdf"; - case ".ppt": return "application/vnd.ms-powerpoint"; - case ".zip": return "application/zip"; - case ".txt": return "text/plain"; - default: return "application/octet-stream"; - } - } - private static string GetHardwareImageFile(HardwareNode hn) - { - switch (hn.Hardware.HardwareType) - { - case HardwareType.Cpu: - return "cpu.png"; - case HardwareType.GpuNvidia: - return "nvidia.png"; - case HardwareType.GpuAmd: - return "ati.png"; - case HardwareType.GpuIntel: - return "intel.png"; - case HardwareType.Storage: - return "hdd.png"; - case HardwareType.Motherboard: - return "mainboard.png"; - case HardwareType.SuperIO: - return "chip.png"; - case HardwareType.Memory: - return "ram.png"; - case HardwareType.Cooler: - return "fan.png"; - case HardwareType.Network: - return "nic.png"; - case HardwareType.Psu: - return "power-supply.png"; - case HardwareType.Battery: - return "battery.png"; - case HardwareType.PowerMonitor: - return "powermonitor.png"; - default: - return "cpu.png"; - } - } - - private static string GetTypeImageFile(TypeNode tn) - { - switch (tn.SensorType) - { - case SensorType.Voltage: - case SensorType.Current: - return "voltage.png"; - case SensorType.Clock: - case SensorType.Timing: - return "clock.png"; - case SensorType.Load: - return "load.png"; - case SensorType.Temperature: - return "temperature.png"; - case SensorType.Fan: - return "fan.png"; - case SensorType.Flow: - return "flow.png"; - case SensorType.Control: - return "control.png"; - case SensorType.Level: - return "level.png"; - case SensorType.Power: - return "power.png"; - case SensorType.Noise: - return "loudspeaker.png"; - case SensorType.Conductivity: - return "voltage.png"; - case SensorType.Throughput: - return "throughput.png"; - case SensorType.Humidity: - return "flow.png"; - default: - return "power.png"; - } - } - - private string ComputeSHA256(string text) - { - using SHA256 hash = SHA256.Create(); - return string.Concat(hash - .ComputeHash(Encoding.UTF8.GetBytes(text)) - .Select(item => item.ToString("x2"))); - } - - public void Quit() - { - if (PlatformNotSupported) - return; - - StopHttpListener(); - try - { - _listener?.Abort(); - } - catch { } - } - - private static async Task SendResponseAsync(HttpListenerResponse response, string content, string contentType) - { - byte[] buffer = Encoding.UTF8.GetBytes(content); - response.ContentType = contentType; - response.ContentLength64 = buffer.Length; - - try - { - await response.OutputStream.WriteAsync(buffer, 0, buffer.Length); - response.OutputStream.Close(); - } - catch (HttpListenerException) - { } - } - -} diff --git a/LibreHardwareMonitor.Windows.Forms/Utilities/IconFactory.cs b/LibreHardwareMonitor.Windows.Forms/Utilities/IconFactory.cs deleted file mode 100644 index c3b49f5..0000000 --- a/LibreHardwareMonitor.Windows.Forms/Utilities/IconFactory.cs +++ /dev/null @@ -1,197 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Drawing; -using System.Drawing.Imaging; -using System.IO; -using System.Runtime.InteropServices; - -namespace LibreHardwareMonitor.Windows.Forms.Utilities; - -public static class IconFactory -{ - private struct BITMAPINFOHEADER - { - public readonly uint Size; - public readonly int Width; - public readonly int Height; - public readonly ushort Planes; - public readonly ushort BitCount; - public readonly uint Compression; - public readonly uint SizeImage; - public readonly int XPelsPerMeter; - public readonly int YPelsPerMeter; - public readonly uint ClrUsed; - public readonly uint ClrImportant; - - public BITMAPINFOHEADER(int width, int height, int bitCount) - { - Size = 40; - Width = width; - Height = height; - Planes = 1; - BitCount = (ushort)bitCount; - Compression = 0; - SizeImage = 0; - XPelsPerMeter = 0; - YPelsPerMeter = 0; - ClrUsed = 0; - ClrImportant = 0; - } - - public void Write(BinaryWriter bw) - { - bw.Write(Size); - bw.Write(Width); - bw.Write(Height); - bw.Write(Planes); - bw.Write(BitCount); - bw.Write(Compression); - bw.Write(SizeImage); - bw.Write(XPelsPerMeter); - bw.Write(YPelsPerMeter); - bw.Write(ClrUsed); - bw.Write(ClrImportant); - } - } - - private struct ICONIMAGE - { - public BITMAPINFOHEADER Header; - public readonly byte[] Colors; - public readonly int MaskSize; - - public ICONIMAGE(int width, int height, byte[] colors) - { - Header = new BITMAPINFOHEADER(width, height << 1, (8 * colors.Length) / (width * height)); - Colors = colors; - MaskSize = (width * height) >> 3; - } - - public void Write(BinaryWriter bw) - { - Header.Write(bw); - int stride = Header.Width << 2; - for (int i = (Header.Height >> 1) - 1; i >= 0; i--) - bw.Write(Colors, i * stride, stride); - for (int i = 0; i < 2 * MaskSize; i++) - bw.Write((byte)0); - } - } - - private struct ICONDIRENTRY - { - public readonly byte Width; - public readonly byte Height; - public readonly byte ColorCount; - public readonly byte Reserved; - public readonly ushort Planes; - public readonly ushort BitCount; - public readonly uint BytesInRes; - public uint ImageOffset; - - public ICONDIRENTRY(ICONIMAGE image, int imageOffset) - { - Width = (byte)image.Header.Width; - Height = (byte)(image.Header.Height >> 1); - ColorCount = 0; - Reserved = 0; - Planes = image.Header.Planes; - BitCount = image.Header.BitCount; - BytesInRes = (uint)(image.Header.Size + image.Colors.Length + image.MaskSize + image.MaskSize); - ImageOffset = (uint)imageOffset; - } - - public void Write(BinaryWriter bw) - { - bw.Write(Width); - bw.Write(Height); - bw.Write(ColorCount); - bw.Write(Reserved); - bw.Write(Planes); - bw.Write(BitCount); - bw.Write(BytesInRes); - bw.Write(ImageOffset); - } - - public uint Size - { - get { return 16; } - } - } - - private struct ICONDIR - { - public readonly ushort Reserved; - public readonly ushort Type; - public readonly ushort Count; - public readonly ICONDIRENTRY[] Entries; - - public ICONDIR(ICONDIRENTRY[] entries) - { - Reserved = 0; - Type = 1; - Count = (ushort)entries.Length; - Entries = entries; - } - - public void Write(BinaryWriter bw) - { - bw.Write(Reserved); - bw.Write(Type); - bw.Write(Count); - for (int i = 0; i < Entries.Length; i++) - Entries[i].Write(bw); - } - - public uint Size - { - get - { - return (uint)(6 + Entries.Length * (Entries.Length > 0 ? Entries[0].Size : 0)); - } - } - } - - private static readonly BinaryWriter BinaryWriter = new BinaryWriter(new MemoryStream()); - - public static Icon Create(byte[] colors, int width, int height, PixelFormat format) - { - if (format != PixelFormat.Format32bppArgb) - throw new NotImplementedException(); - - ICONIMAGE image = new ICONIMAGE(width, height, colors); - ICONDIR dir = new ICONDIR(new[] { new ICONDIRENTRY(image, 0) }); - dir.Entries[0].ImageOffset = dir.Size; - - BinaryWriter.BaseStream.Position = 0; - dir.Write(BinaryWriter); - image.Write(BinaryWriter); - - BinaryWriter.BaseStream.Position = 0; - Icon icon = new Icon(BinaryWriter.BaseStream); - - return icon; - } - - [DllImport("user32", SetLastError = true)] - static extern bool DestroyIcon(IntPtr handle); - - public static Icon Create(Bitmap bitmap) - { - IntPtr hIcon = bitmap.GetHicon(); - Icon icon = Icon.FromHandle(hIcon); - - return icon; - } - - public static void Destroy(this Icon icon) - { - DestroyIcon(icon.Handle); - icon.Dispose(); - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/Utilities/Logger.cs b/LibreHardwareMonitor.Windows.Forms/Utilities/Logger.cs deleted file mode 100644 index 84f8e0f..0000000 --- a/LibreHardwareMonitor.Windows.Forms/Utilities/Logger.cs +++ /dev/null @@ -1,254 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using LibreHardwareMonitor.Hardware; - -namespace LibreHardwareMonitor.Windows.Forms.Utilities; - -public class Logger -{ - private const string FileNameFormat = "LibreHardwareMonitorLog-{0:yyyy-MM-dd}{1}.csv"; - - private readonly IComputer _computer; - - private DateTime _day = DateTime.MinValue; - private string _fileName; - private string[] _identifiers; - private ISensor[] _sensors; - private DateTime _lastLoggedTime = DateTime.MinValue; - // Guards the _sensors/_identifiers pair: when a defer env var is set, Computer.HardwareAdded can now fire on a - // background thread, so SensorAdded/SensorRemoved can run concurrently with the timer thread's rotation. Mirrors - // the WinUI Logger fix. - private readonly object _sync = new object(); - - public LoggerFileRotation FileRotationMethod = LoggerFileRotation.PerSession; - - public Logger(IComputer computer) - { - _computer = computer; - _computer.HardwareAdded += HardwareAdded; - _computer.HardwareRemoved += HardwareRemoved; - } - - private void HardwareRemoved(IHardware hardware) - { - hardware.SensorAdded -= SensorAdded; - hardware.SensorRemoved -= SensorRemoved; - - foreach (ISensor sensor in hardware.Sensors) - SensorRemoved(sensor); - - foreach (IHardware subHardware in hardware.SubHardware) - HardwareRemoved(subHardware); - } - - private void HardwareAdded(IHardware hardware) - { - foreach (ISensor sensor in hardware.Sensors) - SensorAdded(sensor); - - hardware.SensorAdded += SensorAdded; - hardware.SensorRemoved += SensorRemoved; - - foreach (IHardware subHardware in hardware.SubHardware) - HardwareAdded(subHardware); - } - - private void SensorAdded(ISensor sensor) - { - lock (_sync) - { - if (_sensors == null) - return; - - for (int i = 0; i < _sensors.Length; i++) - { - if (sensor.Identifier.ToString() == _identifiers[i]) - _sensors[i] = sensor; - } - } - } - - private void SensorRemoved(ISensor sensor) - { - lock (_sync) - { - if (_sensors == null) - return; - - for (int i = 0; i < _sensors.Length; i++) - { - if (sensor == _sensors[i]) - _sensors[i] = null; - } - } - } - - private static string GetFileName(DateTime date, uint sessionNumber = 0) - { - return AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar - + string.Format(FileNameFormat, date, sessionNumber == 0 ? "" : "-" + sessionNumber); - } - - private bool OpenExistingLogFile() - { - if (!File.Exists(_fileName)) - return false; - - string[] identifiers; - try - { - string line; - using (StreamReader reader = new StreamReader(_fileName)) - line = reader.ReadLine(); - - if (string.IsNullOrEmpty(line)) - return false; - - identifiers = line.Split(',').Skip(1).ToArray(); - } - catch - { - return false; - } - - if (identifiers.Length == 0) - return false; - - ISensor[] sensors = new ISensor[identifiers.Length]; - SensorVisitor visitor = new SensorVisitor(sensor => - { - for (int i = 0; i < identifiers.Length; i++) - if (sensor.Identifier.ToString() == identifiers[i]) - sensors[i] = sensor; - }); - visitor.VisitComputer(_computer); - - lock (_sync) - { - _identifiers = identifiers; - _sensors = sensors; - } - - return true; - } - - private void CreateNewLogFile() - { - IList list = new List(); - SensorVisitor visitor = new SensorVisitor(sensor => - { - list.Add(sensor); - }); - visitor.VisitComputer(_computer); - ISensor[] sensors = list.ToArray(); - string[] identifiers = sensors.Select(s => s.Identifier.ToString()).ToArray(); - - lock (_sync) - { - _sensors = sensors; - _identifiers = identifiers; - } - - using (StreamWriter writer = new StreamWriter(_fileName, false)) - { - writer.Write(","); - for (int i = 0; i < sensors.Length; i++) - { - writer.Write(sensors[i].Identifier); - if (i < sensors.Length - 1) - writer.Write(","); - else - writer.WriteLine(); - } - - writer.Write("Time,"); - for (int i = 0; i < sensors.Length; i++) - { - writer.Write('"'); - writer.Write(sensors[i].Name); - writer.Write('"'); - if (i < sensors.Length - 1) - writer.Write(","); - else - writer.WriteLine(); - } - } - } - - public TimeSpan LoggingInterval { get; set; } - - public void Log() - { - DateTime now = DateTime.Now; - - if (_lastLoggedTime + LoggingInterval - new TimeSpan(5000000) > now) - return; - - switch (FileRotationMethod) - { - case LoggerFileRotation.PerSession: - // Create file if it does not exist or the logging interval has passed (+ some margin) - if (!File.Exists(_fileName) || now - _lastLoggedTime > (LoggingInterval + TimeSpan.FromMilliseconds(100))) - { - uint sessionNumber = 1; - do { - _fileName = GetFileName(DateTime.Now, sessionNumber); - sessionNumber++; - } while (File.Exists(_fileName)); - CreateNewLogFile(); - } - break; - case LoggerFileRotation.Daily: - // Create a new file if the day has changed or the file does not exist - if (_day != now.Date || !File.Exists(_fileName)) - { - _day = now.Date; - _fileName = GetFileName(_day); - if (!OpenExistingLogFile()) - CreateNewLogFile(); - } - break; - } - - ISensor[] sensors; - lock (_sync) - sensors = _sensors; - - try - { - using (StreamWriter writer = new StreamWriter(new FileStream(_fileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))) - { - writer.Write(now.ToString("G", CultureInfo.InvariantCulture)); - writer.Write(","); - if (sensors != null) - { - for (int i = 0; i < sensors.Length; i++) - { - if (sensors[i] != null) - { - float? value = sensors[i].Value; - if (value.HasValue) - writer.Write(value.Value.ToString("R", CultureInfo.InvariantCulture)); - } - if (i < sensors.Length - 1) - writer.Write(","); - else - writer.WriteLine(); - } - } - } - } - catch (IOException) { } - - _lastLoggedTime = now; - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.Forms/Utilities/LoggerFileRotation.cs b/LibreHardwareMonitor.Windows.Forms/Utilities/LoggerFileRotation.cs deleted file mode 100644 index 17f00df..0000000 --- a/LibreHardwareMonitor.Windows.Forms/Utilities/LoggerFileRotation.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace LibreHardwareMonitor.Windows.Forms.Utilities -{ - public enum LoggerFileRotation - { - // Keep the same file for the entire record session - PerSession = 0, - - // Create a new file every day - Daily, - } -} diff --git a/LibreHardwareMonitor.Windows.Forms/Utilities/PersistentSettings.cs b/LibreHardwareMonitor.Windows.Forms/Utilities/PersistentSettings.cs deleted file mode 100644 index 59c004e..0000000 --- a/LibreHardwareMonitor.Windows.Forms/Utilities/PersistentSettings.cs +++ /dev/null @@ -1,230 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Text; -using System.Xml; -using LibreHardwareMonitor.Hardware; - -namespace LibreHardwareMonitor.Windows.Forms.Utilities; - -public class PersistentSettings : ISettings -{ - private readonly IDictionary _settings = new Dictionary(); - - public void Load(string fileName) - { - XmlDocument doc = new XmlDocument(); - try - { - doc.Load(fileName); - } - catch - { - try - { - File.Delete(fileName); - } - catch { } - - string backupFileName = fileName + ".backup"; - try - { - doc.Load(backupFileName); - } - catch - { - try - { - File.Delete(backupFileName); - } - catch { } - - return; - } - } - - XmlNodeList list = doc.GetElementsByTagName("appSettings"); - foreach (XmlNode node in list) - { - XmlNode parent = node.ParentNode; - if (parent != null && parent.Name == "configuration" && parent.ParentNode is XmlDocument) - { - foreach (XmlNode child in node.ChildNodes) - { - if (child.Name == "add") - { - XmlAttributeCollection attributes = child.Attributes; - XmlAttribute keyAttribute = attributes["key"]; - XmlAttribute valueAttribute = attributes["value"]; - if (keyAttribute != null && valueAttribute != null && keyAttribute.Value != null) - { - _settings.Add(keyAttribute.Value, valueAttribute.Value); - } - } - } - } - } - } - - public void Save(string fileName) - { - XmlDocument doc = new XmlDocument(); - doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null)); - XmlElement configuration = doc.CreateElement("configuration"); - doc.AppendChild(configuration); - XmlElement appSettings = doc.CreateElement("appSettings"); - configuration.AppendChild(appSettings); - foreach (KeyValuePair keyValuePair in _settings) - { - XmlElement add = doc.CreateElement("add"); - add.SetAttribute("key", keyValuePair.Key); - add.SetAttribute("value", keyValuePair.Value); - appSettings.AppendChild(add); - } - - byte[] file; - using (var memory = new MemoryStream()) - { - using (var writer = new StreamWriter(memory, Encoding.UTF8)) - { - doc.Save(writer); - } - file = memory.ToArray(); - } - - string backupFileName = fileName + ".backup"; - if (File.Exists(fileName)) - { - try - { - File.Delete(backupFileName); - } - catch { } - try - { - File.Move(fileName, backupFileName); - } - catch { } - } - - using (var stream = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - stream.Write(file, 0, file.Length); - } - - try - { - File.Delete(backupFileName); - } - catch { } - } - - public bool Contains(string name) - { - return _settings.ContainsKey(name); - } - - public void SetValue(string name, string value) - { - _settings[name] = value; - } - - public string GetValue(string name, string value) - { - if (_settings.TryGetValue(name, out string result)) - return result; - - - return value; - } - - public void Remove(string name) - { - _settings.Remove(name); - } - - public void SetValue(string name, int value) - { - _settings[name] = value.ToString(); - } - - public int GetValue(string name, int value) - { - if (_settings.TryGetValue(name, out string str)) - { - if (int.TryParse(str, out int parsedValue)) - return parsedValue; - - - return value; - } - - return value; - } - - public void SetValue(string name, float value) - { - _settings[name] = value.ToString(CultureInfo.InvariantCulture); - } - - public float GetValue(string name, float value) - { - if (_settings.TryGetValue(name, out string str)) - { - if (float.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out float parsedValue)) - return parsedValue; - } - - return value; - - } - - public double GetValue(string name, double value) - { - if (_settings.TryGetValue(name, out string str)) - { - if (double.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out double parsedValue)) - return parsedValue; - } - - return value; - } - - public void SetValue(string name, bool value) - { - _settings[name] = value ? "true" : "false"; - } - - public bool GetValue(string name, bool value) - { - if (_settings.TryGetValue(name, out string str)) - { - return str == "true"; - } - - return value; - } - - public void SetValue(string name, Color color) - { - _settings[name] = color.ToArgb().ToString("X8"); - } - - public Color GetValue(string name, Color value) - { - if (_settings.TryGetValue(name, out string str)) - { - if (int.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int parsedValue)) - return Color.FromArgb(parsedValue); - } - - return value; - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor.Windows.WinUI/LibreHardwareMonitor.Windows.WinUI.csproj b/LibreHardwareMonitor.Windows.WinUI/LibreHardwareMonitor.Windows.WinUI.csproj index e779a1e..2368dd9 100644 --- a/LibreHardwareMonitor.Windows.WinUI/LibreHardwareMonitor.Windows.WinUI.csproj +++ b/LibreHardwareMonitor.Windows.WinUI/LibreHardwareMonitor.Windows.WinUI.csproj @@ -8,7 +8,7 @@ LibreHardwareMonitor.Windows.WinUI Libre Hardware Monitor LibreHardwareMonitor.Windows.WinUI - ..\LibreHardwareMonitor.Windows.Forms\Resources\icon.ico + Resources\icon.ico app.manifest true None @@ -34,9 +34,9 @@ - - - - + + + + diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/PawnIO_setup.exe b/LibreHardwareMonitor.Windows.WinUI/Resources/PawnIO_setup.exe similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/PawnIO_setup.exe rename to LibreHardwareMonitor.Windows.WinUI/Resources/PawnIO_setup.exe diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_flat_0_aaaaaa_40x100.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_flat_0_aaaaaa_40x100.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_flat_0_aaaaaa_40x100.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_flat_0_aaaaaa_40x100.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_55_fbf9ee_1x400.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_55_fbf9ee_1x400.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_55_fbf9ee_1x400.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_55_fbf9ee_1x400.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_65_ffffff_1x400.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_65_ffffff_1x400.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_65_ffffff_1x400.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_65_ffffff_1x400.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_75_dadada_1x400.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_75_dadada_1x400.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_75_dadada_1x400.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_75_dadada_1x400.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_75_e6e6e6_1x400.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_75_e6e6e6_1x400.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_75_e6e6e6_1x400.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_75_e6e6e6_1x400.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_75_ffffff_1x400.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_75_ffffff_1x400.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_glass_75_ffffff_1x400.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_glass_75_ffffff_1x400.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_highlight-soft_75_cccccc_1x100.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_highlight-soft_75_cccccc_1x100.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_highlight-soft_75_cccccc_1x100.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_inset-soft_95_fef1ec_1x100.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_inset-soft_95_fef1ec_1x100.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-bg_inset-soft_95_fef1ec_1x100.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-bg_inset-soft_95_fef1ec_1x100.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_222222_256x240.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_222222_256x240.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_222222_256x240.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_222222_256x240.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_2e83ff_256x240.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_2e83ff_256x240.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_2e83ff_256x240.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_2e83ff_256x240.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_454545_256x240.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_454545_256x240.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_454545_256x240.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_454545_256x240.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_888888_256x240.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_888888_256x240.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_888888_256x240.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_888888_256x240.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_cd0a0a_256x240.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_cd0a0a_256x240.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/images/ui-icons_cd0a0a_256x240.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/images/ui-icons_cd0a0a_256x240.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/jquery-ui-1.8.16.custom.css b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/jquery-ui-1.8.16.custom.css similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/custom-theme/jquery-ui-1.8.16.custom.css rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/custom-theme/jquery-ui-1.8.16.custom.css diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/jquery.treeTable.css b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/jquery.treeTable.css similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/jquery.treeTable.css rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/jquery.treeTable.css diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/css/ohm_web.css b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/ohm_web.css similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/css/ohm_web.css rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/css/ohm_web.css diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/favicon.ico b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/favicon.ico similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/favicon.ico rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/favicon.ico diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/images/toggle-collapse-dark.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/toggle-collapse-dark.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/images/toggle-collapse-dark.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/toggle-collapse-dark.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/images/toggle-collapse-light.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/toggle-collapse-light.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/images/toggle-collapse-light.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/toggle-collapse-light.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/images/toggle-expand-dark.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/toggle-expand-dark.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/images/toggle-expand-dark.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/toggle-expand-dark.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/images/toggle-expand-light.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/toggle-expand-light.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/images/toggle-expand-light.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/toggle-expand-light.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/images/transparent.png b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/transparent.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/images/transparent.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/images/transparent.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/index.html b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/index.html similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/index.html rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/index.html diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery-1.7.2.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery-1.7.2.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery-1.7.2.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery-1.7.2.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery-1.7.2.min.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery-1.7.2.min.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery-1.7.2.min.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery-1.7.2.min.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery-ui-1.8.16.custom.min.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery-ui-1.8.16.custom.min.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery-ui-1.8.16.custom.min.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery-ui-1.8.16.custom.min.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery.tmpl.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery.tmpl.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery.tmpl.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery.tmpl.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery.tmpl.min.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery.tmpl.min.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery.tmpl.min.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery.tmpl.min.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery.treeTable.min.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery.treeTable.min.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/jquery.treeTable.min.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/jquery.treeTable.min.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/knockout-2.1.0.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/knockout-2.1.0.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/knockout-2.1.0.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/knockout-2.1.0.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/knockout-2.1.0.min.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/knockout-2.1.0.min.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/knockout-2.1.0.min.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/knockout-2.1.0.min.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/knockout.mapping-latest.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/knockout.mapping-latest.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/knockout.mapping-latest.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/knockout.mapping-latest.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/knockout.mapping-latest.min.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/knockout.mapping-latest.min.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/knockout.mapping-latest.min.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/knockout.mapping-latest.min.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/Web/js/ohm_web.js b/LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/ohm_web.js similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/Web/js/ohm_web.js rename to LibreHardwareMonitor.Windows.WinUI/Resources/Web/js/ohm_web.js diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/amd.png b/LibreHardwareMonitor.Windows.WinUI/Resources/amd.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/amd.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/amd.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/app.manifest b/LibreHardwareMonitor.Windows.WinUI/Resources/app.manifest similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/app.manifest rename to LibreHardwareMonitor.Windows.WinUI/Resources/app.manifest diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/ati.png b/LibreHardwareMonitor.Windows.WinUI/Resources/ati.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/ati.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/ati.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/bar.png b/LibreHardwareMonitor.Windows.WinUI/Resources/bar.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/bar.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/bar.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/barback.png b/LibreHardwareMonitor.Windows.WinUI/Resources/barback.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/barback.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/barback.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/battery.png b/LibreHardwareMonitor.Windows.WinUI/Resources/battery.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/battery.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/battery.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/chip.png b/LibreHardwareMonitor.Windows.WinUI/Resources/chip.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/chip.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/chip.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/clock.png b/LibreHardwareMonitor.Windows.WinUI/Resources/clock.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/clock.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/clock.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/computer.png b/LibreHardwareMonitor.Windows.WinUI/Resources/computer.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/computer.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/computer.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/control.png b/LibreHardwareMonitor.Windows.WinUI/Resources/control.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/control.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/control.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/cpu.png b/LibreHardwareMonitor.Windows.WinUI/Resources/cpu.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/cpu.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/cpu.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/current.png b/LibreHardwareMonitor.Windows.WinUI/Resources/current.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/current.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/current.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/data.png b/LibreHardwareMonitor.Windows.WinUI/Resources/data.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/data.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/data.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/factor.png b/LibreHardwareMonitor.Windows.WinUI/Resources/factor.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/factor.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/factor.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/fan.png b/LibreHardwareMonitor.Windows.WinUI/Resources/fan.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/fan.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/fan.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/flow.png b/LibreHardwareMonitor.Windows.WinUI/Resources/flow.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/flow.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/flow.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/gadget.png b/LibreHardwareMonitor.Windows.WinUI/Resources/gadget.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/gadget.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/gadget.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/gadget.xcf b/LibreHardwareMonitor.Windows.WinUI/Resources/gadget.xcf similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/gadget.xcf rename to LibreHardwareMonitor.Windows.WinUI/Resources/gadget.xcf diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/hdd.png b/LibreHardwareMonitor.Windows.WinUI/Resources/hdd.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/hdd.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/hdd.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/humidity.png b/LibreHardwareMonitor.Windows.WinUI/Resources/humidity.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/humidity.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/humidity.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/icon.ico b/LibreHardwareMonitor.Windows.WinUI/Resources/icon.ico similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/icon.ico rename to LibreHardwareMonitor.Windows.WinUI/Resources/icon.ico diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/icon.xcf b/LibreHardwareMonitor.Windows.WinUI/Resources/icon.xcf similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/icon.xcf rename to LibreHardwareMonitor.Windows.WinUI/Resources/icon.xcf diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/intel.png b/LibreHardwareMonitor.Windows.WinUI/Resources/intel.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/intel.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/intel.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/level.png b/LibreHardwareMonitor.Windows.WinUI/Resources/level.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/level.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/level.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/load.png b/LibreHardwareMonitor.Windows.WinUI/Resources/load.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/load.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/load.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/loudspeaker.png b/LibreHardwareMonitor.Windows.WinUI/Resources/loudspeaker.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/loudspeaker.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/loudspeaker.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/mainboard.png b/LibreHardwareMonitor.Windows.WinUI/Resources/mainboard.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/mainboard.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/mainboard.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/nic.png b/LibreHardwareMonitor.Windows.WinUI/Resources/nic.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/nic.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/nic.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/nvidia.png b/LibreHardwareMonitor.Windows.WinUI/Resources/nvidia.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/nvidia.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/nvidia.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/power-supply.png b/LibreHardwareMonitor.Windows.WinUI/Resources/power-supply.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/power-supply.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/power-supply.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/power.png b/LibreHardwareMonitor.Windows.WinUI/Resources/power.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/power.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/power.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/powermonitor.png b/LibreHardwareMonitor.Windows.WinUI/Resources/powermonitor.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/powermonitor.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/powermonitor.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/ram.png b/LibreHardwareMonitor.Windows.WinUI/Resources/ram.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/ram.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/ram.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/smallicon.ico b/LibreHardwareMonitor.Windows.WinUI/Resources/smallicon.ico similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/smallicon.ico rename to LibreHardwareMonitor.Windows.WinUI/Resources/smallicon.ico diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/temperature.png b/LibreHardwareMonitor.Windows.WinUI/Resources/temperature.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/temperature.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/temperature.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/throughput.png b/LibreHardwareMonitor.Windows.WinUI/Resources/throughput.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/throughput.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/throughput.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/time.png b/LibreHardwareMonitor.Windows.WinUI/Resources/time.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/time.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/time.png diff --git a/LibreHardwareMonitor.Windows.Forms/Resources/voltage.png b/LibreHardwareMonitor.Windows.WinUI/Resources/voltage.png similarity index 100% rename from LibreHardwareMonitor.Windows.Forms/Resources/voltage.png rename to LibreHardwareMonitor.Windows.WinUI/Resources/voltage.png diff --git a/LibreHardwareMonitor.sln b/LibreHardwareMonitor.sln index 3d7aacc..7ff6e5d 100644 --- a/LibreHardwareMonitor.sln +++ b/LibreHardwareMonitor.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 18 VisualStudioVersion = 18.0.11018.127 @@ -7,12 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibreHardwareMonitor.Window EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibreHardwareMonitorLib", "LibreHardwareMonitorLib\LibreHardwareMonitorLib.csproj", "{B0397530-545A-471D-BB74-027AE456DF1A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibreHardwareMonitor.Windows.Forms", "LibreHardwareMonitor.Windows.Forms\LibreHardwareMonitor.Windows.Forms.csproj", "{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aga.Controls", "Aga.Controls\Aga.Controls.csproj", "{E73BB233-D88B-44A7-A98F-D71EE158381D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Controls", "Controls", "{23F54DBD-8998-4E22-A4E4-60F4F77F9B65}" -EndProject + Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BAEC1DFE-5D1E-4CDB-8264-6C85B229D812}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig @@ -65,38 +60,7 @@ Global {B0397530-545A-471D-BB74-027AE456DF1A}.Release|x86.Build.0 = Release|x86 {B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.Build.0 = Release|Any CPU - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|ARM64.Build.0 = Debug|ARM64 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|x64.ActiveCfg = Debug|x64 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|x64.Build.0 = Debug|x64 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|x86.ActiveCfg = Debug|x86 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|x86.Build.0 = Debug|x86 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|ARM64.ActiveCfg = Release|ARM64 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|ARM64.Build.0 = Release|ARM64 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|x64.ActiveCfg = Release|x64 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|x64.Build.0 = Release|x64 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|x86.ActiveCfg = Release|x86 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|x86.Build.0 = Release|x86 - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.Build.0 = Release|Any CPU - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|ARM64.Build.0 = Debug|ARM64 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|x64.ActiveCfg = Debug|x64 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|x64.Build.0 = Debug|x64 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|x86.ActiveCfg = Debug|x86 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|x86.Build.0 = Debug|x86 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|ARM64.ActiveCfg = Release|ARM64 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|ARM64.Build.0 = Release|ARM64 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|x64.ActiveCfg = Release|x64 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|x64.Build.0 = Release|x64 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|x86.ActiveCfg = Release|x86 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|x86.Build.0 = Release|x86 - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.Build.0 = Release|Any CPU + {AF286D81-C1D0-47B2-AD60-9F60CAE602F9}.Debug|ARM64.ActiveCfg = Debug|Any CPU {AF286D81-C1D0-47B2-AD60-9F60CAE602F9}.Debug|ARM64.Build.0 = Debug|Any CPU {AF286D81-C1D0-47B2-AD60-9F60CAE602F9}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -117,9 +81,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {E73BB233-D88B-44A7-A98F-D71EE158381D} = {23F54DBD-8998-4E22-A4E4-60F4F77F9B65} - EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6A8EF661-2BD7-498F-8FB9-28182B3B0BE5} EndGlobalSection diff --git a/LibreHardwareMonitorLib/Hardware/Computer.cs b/LibreHardwareMonitorLib/Hardware/Computer.cs index 29f571d..deb3ab3 100644 --- a/LibreHardwareMonitorLib/Hardware/Computer.cs +++ b/LibreHardwareMonitorLib/Hardware/Computer.cs @@ -629,10 +629,10 @@ public class Computer : IComputer cancellationToken.ThrowIfCancellationRequested(); _smbios = Measure(startupTrace, "SMBios", () => new SMBios()); - if (Software.OperatingSystem.IsWindows8OrGreater) + if (!Software.OperatingSystem.IsUnix) Measure(startupTrace, "Mutexes.Open", Mutexes.Open); else - startupTrace?.Skip("Mutexes.Open", "Operating system is older than Windows 8."); + startupTrace?.Skip("Mutexes.Open", "Operating system is not Windows."); cancellationToken.ThrowIfCancellationRequested(); Measure(startupTrace, "OpCode.Open", OpCode.Open); diff --git a/LibreHardwareMonitorLib/Hardware/Mutexes.cs b/LibreHardwareMonitorLib/Hardware/Mutexes.cs index 3fdd5b8..1f3724e 100644 --- a/LibreHardwareMonitorLib/Hardware/Mutexes.cs +++ b/LibreHardwareMonitorLib/Hardware/Mutexes.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Security.AccessControl; using System.Security.Principal; using System.Threading; @@ -32,11 +32,7 @@ internal static class Mutexes var mutexSecurity = new MutexSecurity(); mutexSecurity.AddAccessRule(worldRule); -#if NETFRAMEWORK - return new Mutex(false, name, out _, mutexSecurity); -#else return MutexAcl.Create(false, name, out _, mutexSecurity); -#endif } catch (UnauthorizedAccessException) { diff --git a/LibreHardwareMonitorLib/Hardware/OpCode.cs b/LibreHardwareMonitorLib/Hardware/OpCode.cs index 64bbc77..c48e7a8 100644 --- a/LibreHardwareMonitorLib/Hardware/OpCode.cs +++ b/LibreHardwareMonitorLib/Hardware/OpCode.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. // Copyright (C) LibreHardwareMonitor and Contributors. // Partial Copyright (C) Michael Möller and Contributors. @@ -7,11 +7,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -#if !NETFRAMEWORK using Mono.Unix.Native; -#else -using System.Reflection; -#endif using Windows.Win32; using Windows.Win32.System.Memory; @@ -234,30 +230,9 @@ internal static class OpCode if (Software.OperatingSystem.IsUnix) { -#if NETFRAMEWORK - Assembly assembly = Assembly.Load("Mono.Posix, Version=2.0.0.0, Culture=neutral, " + "PublicKeyToken=0738eb9f132ed756"); - - Type sysCall = assembly.GetType("Mono.Unix.Native.Syscall"); - MethodInfo mmap = sysCall.GetMethod("mmap"); - - Type mmapProts = assembly.GetType("Mono.Unix.Native.MmapProts"); - object mmapProtsParam = Enum.ToObject(mmapProts, - (int)mmapProts.GetField("PROT_READ").GetValue(null) | - (int)mmapProts.GetField("PROT_WRITE").GetValue(null) | - (int)mmapProts.GetField("PROT_EXEC").GetValue(null)); - - Type mmapFlags = assembly.GetType("Mono.Unix.Native.MmapFlags"); - object mmapFlagsParam = Enum.ToObject(mmapFlags, - (int)mmapFlags.GetField("MAP_ANONYMOUS").GetValue(null) | - (int)mmapFlags.GetField("MAP_PRIVATE").GetValue(null)); - - if (mmap != null) - _codeBuffer = (IntPtr)mmap.Invoke(null, [IntPtr.Zero, _size, mmapProtsParam, mmapFlagsParam, -1, 0]); -#else _codeBuffer = Syscall.mmap(IntPtr.Zero, _size, MmapProts.PROT_READ | MmapProts.PROT_WRITE | MmapProts.PROT_EXEC, MmapFlags.MAP_ANONYMOUS | MmapFlags.MAP_PRIVATE, -1, 0); -#endif } else { @@ -281,15 +256,7 @@ internal static class OpCode if (Software.OperatingSystem.IsUnix) { -#if NETFRAMEWORK - Assembly assembly = Assembly.Load("Mono.Posix, Version=2.0.0.0, Culture=neutral, " + "PublicKeyToken=0738eb9f132ed756"); - - Type sysCall = assembly.GetType("Mono.Unix.Native.Syscall"); - MethodInfo method = sysCall.GetMethod("munmap"); - method?.Invoke(null, [_codeBuffer, _size]); -#else Syscall.munmap(_codeBuffer, _size); -#endif } else { diff --git a/LibreHardwareMonitorLib/Hardware/PowerMonitor/WireViewPro2.cs b/LibreHardwareMonitorLib/Hardware/PowerMonitor/WireViewPro2.cs index 1728a3a..ed48f6b 100644 --- a/LibreHardwareMonitorLib/Hardware/PowerMonitor/WireViewPro2.cs +++ b/LibreHardwareMonitorLib/Hardware/PowerMonitor/WireViewPro2.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. // Copyright (C) Florian K. (Blacktempel) // All Rights Reserved. @@ -74,7 +74,7 @@ public sealed class WireViewPro2 : Hardware, IPowerMonitor { var devices = new List(); - if (!Software.OperatingSystem.IsWindows8OrGreater) + if (Software.OperatingSystem.IsUnix) { return devices; //No Linux implementation yet } diff --git a/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj b/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj index 6e0e989..0b25028 100644 --- a/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj +++ b/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj @@ -1,6 +1,6 @@ - + - net472;netstandard2.0;net8.0;net9.0;net10.0 + netstandard2.0;net8.0;net9.0;net10.0 x64;x86;ARM64 win-x64;win-x86;win-arm64;linux-x64;linux-arm64 LibreHardwareMonitorLib @@ -89,7 +89,6 @@ - diff --git a/LibreHardwareMonitorLib/Software/OperatingSystem.cs b/LibreHardwareMonitorLib/Software/OperatingSystem.cs index 4c16bb7..e30eeb8 100644 --- a/LibreHardwareMonitorLib/Software/OperatingSystem.cs +++ b/LibreHardwareMonitorLib/Software/OperatingSystem.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. // Copyright (C) LibreHardwareMonitor and Contributors. // Partial Copyright (C) Michael Möller and Contributors. @@ -20,13 +20,10 @@ public static class OperatingSystem { // The operating system doesn't change during execution so let's query it just one time. PlatformID platform = Environment.OSVersion.Platform; - Version version = Environment.OSVersion.Version; IsUnix = platform is PlatformID.Unix or PlatformID.MacOSX; if (Environment.Is64BitOperatingSystem) Is64Bit = true; - - IsWindows8OrGreater = !IsUnix && ((version.Major == 6 && version.Minor >= 2) || version.Major > 6); } /// @@ -38,9 +35,4 @@ public static class OperatingSystem /// Gets information about whether the current system is Unix based. /// public static bool IsUnix { get; } - - /// - /// Returns true if the current system is Windows 8 or a more recent Windows version - /// - public static bool IsWindows8OrGreater { get; } }