From 22a229eda1b278ea286e5c22d90e8451a81316a7 Mon Sep 17 00:00:00 2001
From: Phyxion <7643972+Phyxion@users.noreply.github.com>
Date: Fri, 13 Sep 2019 15:34:42 +0200
Subject: [PATCH] Code style #125
---
.editorconfig | 194 +-
.travis.yml | 2 +-
GUI/AboutBox.Designer.cs | 248 +--
GUI/AboutBox.cs | 61 +-
GUI/AboutBox.resx | 125 +-
GUI/CrashForm.Designer.cs | 253 ---
GUI/CrashForm.cs | 91 -
GUI/CrashForm.resx | 120 --
GUI/Gadget.cs | 303 +--
GUI/GadgetWindow.cs | 1107 +++++-----
GUI/HardwareNode.cs | 192 +-
GUI/HardwareTypeImage.cs | 122 +-
GUI/MainForm.Designer.cs | 1384 ++++++-------
GUI/MainForm.cs | 1842 +++++++++--------
GUI/MainForm.resx | 14 +-
GUI/Node.cs | 303 ++-
GUI/NotifyIconAdv.cs | 1645 ++++++++-------
GUI/ParameterForm.Designer.cs | 10 +-
GUI/ParameterForm.cs | 205 +-
GUI/PlotPanel.cs | 552 +++--
GUI/PortForm.Designer.cs | 8 +-
GUI/PortForm.cs | 124 +-
GUI/ReportForm.Designer.cs | 246 ---
GUI/ReportForm.cs | 77 -
GUI/ReportForm.resx | 120 --
GUI/SensorGadget.cs | 1331 ++++++------
GUI/SensorNode.cs | 348 ++--
GUI/SensorNotifyIcon.cs | 569 +++--
GUI/ShowDesktop.cs | 257 ++-
GUI/SplitContainerAdv.cs | 223 +-
GUI/StartupManager.cs | 381 ++--
GUI/SystemTray.cs | 327 +--
GUI/TaskScheduler.cs | 1759 ++++++++--------
GUI/TreeModel.cs | 208 +-
GUI/TypeNode.cs | 198 +-
GUI/UnitManager.cs | 72 +-
GUI/UpdateVisitor.cs | 49 +-
GUI/UserOption.cs | 111 +-
GUI/UserRadioGroup.cs | 117 +-
...itor.csproj => LibreHardwareMonitor.csproj | 18 -
...areMonitor.sln => LibreHardwareMonitor.sln | 18 +-
Program.cs | 146 +-
Properties/AssemblyInfo.cs | 23 +-
Properties/AssemblyLibInfo.cs | 17 +-
Properties/AssemblyVersion.cs | 17 +-
Utilities/EmbeddedResources.cs | 98 +-
Utilities/HttpServer.cs | 1024 ++++-----
Utilities/IconFactory.cs | 335 +--
Utilities/Logger.cs | 345 +--
Utilities/PersistentSettings.cs | 378 ++--
WMI/Hardware.cs | 57 +-
WMI/IWmiObject.cs | 31 +-
WMI/Sensor.cs | 81 +-
WMI/WmiProvider.cs | 240 ++-
appveyor.yml | 4 +-
55 files changed, 8818 insertions(+), 9312 deletions(-)
delete mode 100644 GUI/CrashForm.Designer.cs
delete mode 100644 GUI/CrashForm.cs
delete mode 100644 GUI/CrashForm.resx
delete mode 100644 GUI/ReportForm.Designer.cs
delete mode 100644 GUI/ReportForm.cs
delete mode 100644 GUI/ReportForm.resx
rename OpenHardwareMonitor.csproj => LibreHardwareMonitor.csproj (93%)
rename OpenHardwareMonitor.sln => LibreHardwareMonitor.sln (79%)
diff --git a/.editorconfig b/.editorconfig
index 1e9f5e4..0055396 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,27 +1,189 @@
-#
-# Documentation: http://EditorConfig.org
-# VS15 plug-in: http://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328
-# Natively supported in VS17
-#
-# Configure editor for this project to match original project indentation scheme.
+# editorconfig.org
# top-most EditorConfig file
root = true
+# Default settings:
+# A newline ending every file
+# Use 4 spaces as indentation
[*]
-trim_trailing_whitespace = true
-
-[*.{cs,vb}]
+insert_final_newline = true
indent_style = space
-indent_size = 2
-dotnet_style_object_initializer = true:suggestion
-csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
+indent_size = 4
+[project.json]
+indent_size = 2
+
+# C# files
+[*.{cs,vb}]
# New line preferences
-csharp_new_line_before_open_brace = none
-csharp_new_line_before_else = false
-csharp_new_line_before_catch = false
-csharp_new_line_before_finally = false
+csharp_new_line_before_open_brace = all
+csharp_new_line_before_else = true
+csharp_new_line_before_catch = true
+csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
+
+# Indentation preferences
+csharp_indent_block_contents = true
+csharp_indent_braces = false
+csharp_indent_case_contents = true
+csharp_indent_case_contents_when_block = true
+csharp_indent_switch_labels = true
+csharp_indent_labels = one_less_than_current
+
+# Modifier preferences
+csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
+
+# avoid this. unless absolutely necessary
+dotnet_style_qualification_for_field = false:suggestion
+dotnet_style_qualification_for_property = false:suggestion
+dotnet_style_qualification_for_method = false:suggestion
+dotnet_style_qualification_for_event = false:suggestion
+
+# Types: use keywords instead of BCL types, and permit var only when the type is clear
+csharp_style_var_for_built_in_types = false:suggestion
+csharp_style_var_when_type_is_apparent = false:none
+csharp_style_var_elsewhere = false:suggestion
+dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
+dotnet_style_predefined_type_for_member_access = true:suggestion
+
+# methods
+dotnet_naming_rule.methods_must_be_capitalized.severity = error #suggestion
+dotnet_naming_rule.methods_must_be_capitalized.symbols = methods_symbols
+dotnet_naming_rule.methods_must_be_capitalized.style = methods_case_style
+dotnet_naming_symbols.methods_symbols.applicable_kinds = method
+dotnet_naming_symbols.methods_symbols.applicable_accessibilities = public, private, protected, internal
+dotnet_naming_style.methods_case_style.capitalization = pascal_case
+
+# public fields
+dotnet_naming_rule.public_members_must_be_capitalized.severity = error #suggestion
+dotnet_naming_rule.public_members_must_be_capitalized.symbols = public_symbols
+dotnet_naming_rule.public_members_must_be_capitalized.style = public_case_style
+dotnet_naming_symbols.public_symbols.applicable_kinds = property,field,event,delegate
+dotnet_naming_symbols.public_symbols.applicable_accessibilities = public
+dotnet_naming_style.public_case_style.capitalization = pascal_case
+
+# name all constant fields using PascalCase
+dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = error #suggestion
+dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
+dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
+dotnet_naming_symbols.constant_fields.applicable_kinds = field
+dotnet_naming_symbols.constant_fields.required_modifiers = const
+dotnet_naming_style.pascal_case_style.capitalization = pascal_case
+
+# internal and private fields should be _camelCase
+dotnet_naming_rule.camel_case_for_private_internal_fields.severity = error #suggestion
+dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
+dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
+dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
+dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
+dotnet_naming_style.camel_case_underscore_style.required_prefix = _
+dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
+
+# Code style defaults
+csharp_using_directive_placement = outside_namespace:suggestion
+dotnet_sort_system_directives_first = true:suggestion
+csharp_prefer_braces = when_multiline:suggestion
+csharp_preserve_single_line_blocks = true:none
+csharp_preserve_single_line_statements = false:none
+csharp_prefer_static_local_function = true:suggestion
+csharp_prefer_simple_using_statement = false:none
+csharp_style_prefer_switch_expression = true:suggestion
+
+# Code quality
+dotnet_style_readonly_field = true:suggestion
+dotnet_code_quality_unused_parameters = non_public:suggestion
+
+# Expression-level preferences
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_collection_initializer = true:suggestion
+dotnet_style_explicit_tuple_names = true:suggestion
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_null_propagation = true:suggestion
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
+dotnet_style_prefer_inferred_tuple_names = true:suggestion
+dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
+dotnet_style_prefer_auto_properties = true:suggestion
+dotnet_style_prefer_conditional_expression_over_assignment = true:refactoring
+dotnet_style_prefer_conditional_expression_over_return = true:refactoring
+csharp_prefer_simple_default_expression = true:suggestion
+
+# Expression-bodied members
+csharp_style_expression_bodied_methods = true:refactoring
+csharp_style_expression_bodied_constructors = true:refactoring
+csharp_style_expression_bodied_operators = true:refactoring
+csharp_style_expression_bodied_properties = true:refactoring
+csharp_style_expression_bodied_indexers = true:refactoring
+csharp_style_expression_bodied_accessors = true:refactoring
+csharp_style_expression_bodied_lambdas = true:refactoring
+csharp_style_expression_bodied_local_functions = true:refactoring
+
+# Pattern matching
+csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
+csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
+csharp_style_inlined_variable_declaration = true:suggestion
+
+# Null checking preferences
+csharp_style_throw_expression = true:suggestion
+csharp_style_conditional_delegate_call = true:suggestion
+
+# Other features
+csharp_style_prefer_index_operator = false:none
+csharp_style_prefer_range_operator = false:none
+csharp_style_pattern_local_over_anonymous_function = false:none
+
+# Space preferences
+csharp_space_after_cast = false
+csharp_space_after_colon_in_inheritance_clause = true
+csharp_space_after_comma = true
+csharp_space_after_dot = false
+csharp_space_after_keywords_in_control_flow_statements = true
+csharp_space_after_semicolon_in_for_statement = true
+csharp_space_around_binary_operators = before_and_after
+csharp_space_around_declaration_statements = do_not_ignore
+csharp_space_before_colon_in_inheritance_clause = true
+csharp_space_before_comma = false
+csharp_space_before_dot = false
+csharp_space_before_open_square_brackets = false
+csharp_space_before_semicolon_in_for_statement = false
+csharp_space_between_empty_square_brackets = false
+csharp_space_between_method_call_empty_parameter_list_parentheses = false
+csharp_space_between_method_call_name_and_opening_parenthesis = false
+csharp_space_between_method_call_parameter_list_parentheses = false
+csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
+csharp_space_between_method_declaration_name_and_open_parenthesis = false
+csharp_space_between_method_declaration_parameter_list_parentheses = false
+csharp_space_between_parentheses = false
+csharp_space_between_square_brackets = false
+
+# Analyzers
+dotnet_code_quality.ca1802.api_surface = private, internal
+
+# C++ Files
+[*.{cpp,h,in}]
+curly_bracket_next_line = true
+indent_brace_style = Allman
+
+# Xml project files
+[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
+indent_size = 2
+
+# Xml build files
+[*.builds]
+indent_size = 2
+
+# Xml files
+[*.{xml,stylecop,resx,ruleset}]
+indent_size = 2
+
+# Xml config files
+[*.{props,targets,config,nuspec}]
+indent_size = 2
+
+# Shell scripts
+[*.sh]
+end_of_line = lf
+[*.{cmd, bat}]
+end_of_line = crlf
diff --git a/.travis.yml b/.travis.yml
index 6e22587..4ede0d4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,2 +1,2 @@
language: csharp
-solution: OpenHardwareMonitor.sln
+solution: LibreHardwareMonitor.sln
diff --git a/GUI/AboutBox.Designer.cs b/GUI/AboutBox.Designer.cs
index 55fc9ee..bd5e25a 100644
--- a/GUI/AboutBox.Designer.cs
+++ b/GUI/AboutBox.Designer.cs
@@ -9,7 +9,7 @@
*/
namespace OpenHardwareMonitor.GUI {
- partial class AboutBox {
+ sealed partial class AboutBox {
///
/// Required designer variable.
///
@@ -33,128 +33,128 @@ namespace OpenHardwareMonitor.GUI {
/// 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(120, 13);
- this.label1.TabIndex = 2;
- this.label1.Text = "Open 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(273, 13);
- this.label2.TabIndex = 3;
- this.label2.Text = "Copyright © 2009-2017 Michael Möller 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, 0, 0, 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, 0, 0, 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();
+ 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();
}
@@ -169,4 +169,4 @@ namespace OpenHardwareMonitor.GUI {
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.LinkLabel licenseLinkLabel;
}
-}
\ No newline at end of file
+}
diff --git a/GUI/AboutBox.cs b/GUI/AboutBox.cs
index 46f3540..4fafd36 100644
--- a/GUI/AboutBox.cs
+++ b/GUI/AboutBox.cs
@@ -1,43 +1,34 @@
-/*
-
- 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) 2009-2010 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
-using System.Collections.Generic;
-using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
-namespace OpenHardwareMonitor.GUI {
- public partial class AboutBox : Form {
- public AboutBox() {
- InitializeComponent();
- this.Font = SystemFonts.MessageBoxFont;
- this.label3.Text = "Version " +
- System.Windows.Forms.Application.ProductVersion;
+namespace OpenHardwareMonitor.GUI
+{
+ 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://github.com/LibreHardwareMonitor/LibreHardwareMonitor/blob/master/LICENSE");
+ }
- projectLinkLabel.Links.Remove(projectLinkLabel.Links[0]);
- projectLinkLabel.Links.Add(0, projectLinkLabel.Text.Length,
- "http://openhardwaremonitor.org");
-
- licenseLinkLabel.Links.Remove(licenseLinkLabel.Links[0]);
- licenseLinkLabel.Links.Add(0, licenseLinkLabel.Text.Length,
- "License.html");
+ private void LinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ {
+ try
+ {
+ Process.Start(new ProcessStartInfo(e.Link.LinkData.ToString()));
+ }
+ catch { }
+ }
}
-
- private void linkLabel_LinkClicked(object sender,
- LinkLabelLinkClickedEventArgs e) {
- try {
- Process.Start(new ProcessStartInfo(e.Link.LinkData.ToString()));
- } catch { }
- }
-
- }
}
diff --git a/GUI/AboutBox.resx b/GUI/AboutBox.resx
index 0557782..b11c861 100644
--- a/GUI/AboutBox.resx
+++ b/GUI/AboutBox.resx
@@ -112,74 +112,73 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
- iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
- YQUAAAAJcEhZcwAADrwAAA68AZW8ckkAAA2KSURBVGhD7VnpU9RXFp2ZL6kkxiSVVBIVWRvoZhUVUUBA
- FBdQgbCq4BKVycQyxl1UFsV9QRQQxIgR9wX33YiJOlHjxESjpmKSqtF8yX9x55z7fr+mUSfprvliTcWq
- V02VSt9z77nn3nfeX/7y558/M/BnBv7/MtDYuFW2bKnH2SKb6jbJxo0bZe3atbJq9WpZuXKl1CxfLlXV
- VbJ0aYWUly+WBQsWyLx582TOnDky65NPZMaMGfLhhx/K9LLpMnXaVJkyZYpMmjhRSkpKpLi4WAryC+T9
- 9/MkJydHxowZI1lZWTJy5EgZOmyoDBkyRFJTUyV5cLIMGjRIBgwYIH379pW4uDhBpv9qnd9POgMvKMjH
- KdDPvLw8fOH7kpubK9nZ2TJ27Fj94tGjR+PLM2XUqCycURrEiOHDJSMjQ4YOtYNJk5SUFBmcMliSk5Ml
- MTFRAxs4cKAG169/P4lDgH369JHY2FiJiYmR6OhoPS5XpISFucQRGq5/h6i743TDeQnnb/8VRX19vRQV
- FSFb46QIGePPhYWFCsgAyXkGSGamATFixAgZDhDDMoZJenq6pFkZTUFWBw8miCQFoQASEiS+f3/p168f
- shwnsRaI6OgYiYqKFicAHKp9T0IBgIBeeeWVvq+++mrUyy+/3NMC8XwMBMDgx48fL+PGjdOyFwJEPgCw
- GqxETrYNwqqEBYBVUADDCMCjCqkpkuIBgFVIGJgg/ePj3QDsKhBAY/W74gyPRgUiJdThlMjISEHwRa+9
- 9tpogrAqQUo9+4cUYvATJkzQz2KA0CoUFEp+fr7kogoE4EmlzMxMGTkKFLIroABQgbQ05bTSCACSkpI6
- KYQK9HdXoJNGUVGxEhkRI+HOaK1AWLhTXE6XdOvWbVr37t2LXn/99b4WnZ4PoG5THYIvlZLSUgXhrgJo
- lJePCgAAe2EMeiFrdJZo8Mr/EZIxDPxH4OmgzvOCT7T4nwD+x7uzb5o0tk+scj06OlYrEO6MQvAuCUUf
- hIeHE0AZAIwDgH6/C6C2tlZKJpbIRCqHXQX2AgHkMfixkgnlYLYNVexMI8toVGY5Gefpho3vHy/9+xnO
- M2CbMnbz6mcsmxg9AM47IyJl6zIACXOCSmHeA9iwYYOUlk40AErsKkD+AIC0KSwqlP3798vevXtlz549
- 0tbWJp999pl8+umn0tzcLOyhTZtqVXpXrlgp1dXVsnTJEpXb2XNmy8yZM6Ws7O/ywQcf4HtKlaYEFRUd
- JdGeKhRhKuAICxeHw+E9gPXr18vESZNUu/kFpBGbmvwvRi/wz6+//irff/+9fPvtt/L111/LjRv/lKtf
- filXOq7IhQsX5MyZM3L8+HE50n5EDuzbpyBbd7TKtm3bpKG+Qerq6oTfs2rVKlm2bBlmylJQKE6ikPWo
- qChVoQiPCgQHB3sPgJmbPHmyTAIIVsEAKNbBc/DgQfntt9/k4cOHAHBPAdy+fVu++uoruXr1qnR0dCiA
- 06dPK4DDR47IPlSrrW2X7Nixw12hWqtCK1askOqqKlmCCmWhl5xOozgEQQARrgjw3yUBAQHeA1izZs0z
- AIqKirVpSZ3Hjx/Lox8fyYMHD+S7776Tb775Rm7cvCnXrl2TK1c65OLFi6YCJ45LOyqw/wABoAKtVgUa
- SLFNsm7dOjfFKioqVX7DwsM06IhIc1wul4Ly9+/tPYDVq1d2BQCOsoE5efeBDo+fPJaffvpJq3D37l0F
- cAsArl+/DgBX5NKlS3Lm7Bk5ceIEALTLgQMHZPfu3R4AGjoBYDVhj1RUVqgYsFkZMAOPiOgE4Ofn5z0A
- lrULhQCAk5g7Cxv3yZMn8vPPP8vDHwDg3l25c4cAbimAL74AgIuX5OyZs24A+wGg7SkAdVqB9ditVimA
- yspKyG4qpm4o5NMAcHkA6NWrly8AatwAqEZUCa4RWZi2BoCpwAOPCtxkBZRCV+TiJUOhrhXwpJBdAQKw
- K1CpuxLVhprfBQAGWc8ePbwHsBzbJlWIDVwKGR033ihQ5qhMBfBv9sCjH+W+3QP/Qg/cuKE90AEVcvcA
- mlh7QJu4DU3cKs1QofqG51CookIntCMkxACwq4BKhOO89+573gNgSRm8mQMlOom5A3FZo+7/8ssvoM8P
- cu/e81Toslw4f96tQkcsFdq1y1OFtgiHJdVOVQirOSnE7dQRYipg94FWAuedd97xHkAVZI36rzOADQwJ
- 5RZqA3j06JHcv3/frUC3bpkGvnz5MrhvqMPA2bx7VP+NfPI0NTXpPWMjAKxZu0ZqamqE31eBCnAvCrEq
- 4AmAP7/11luCFcK7VaIC2WDmSyYw+2hgDC9uoNx3SCFbfe7cuYMhZs+Aa3IOmWfg+w+CMlbTkjr8Pzt3
- 7pTtLdtl69ZGqdu8WTbgkrQack26MvscZFypDYBOJSKVnC6nvPnmm94D4C8b77EDFRYW6BDj7kMKkToM
- ngOM3L9+/RrU5wsdYCdOnrSk86AGzhVj+/bt0rS1SVo4hcn/p6Yws89Bxt2IACilVCKnzgAzB9544w3v
- ASxZsljGg/fkPtfoAjRwdk62Dpq2XW1mfbiN9eEmg78uX2KF6LjcIWfPnpVjx47J4cOH3I1rD6/GxkYN
- nldV8l+HmKVATNji8kUGQLAB4ITyRBCEnnAG7z2A8vJyXR3sm5jZQA0AUoHBc3Vg5k3wl1V5Tp061cn9
- vXs6sw/ec8Ej9+s21+kdm9Pe8L9SlixeLIsWLdIbGXeeUFbAamR+hgMM1mjvASxauEgHF49eYMB/bqHD
- sOtz42Tw17D3kDaXOxA8dP/cuXO6+3BX4rRmpbj7cHmzs2+21E1dljjSh8EvWLhA7wIhwUE6zMIIAIEz
- eILwCQB/mbnQd3UPuPu3tLTo0sad5/PPP5eL4P05UIfZ59rA4HfvbpOd2HtayP0mOBwInLTZWLvRZB/y
- WVOzQtWH3Of3zZs/XwEEBRGAw/QBAg/DKs39yCcA8/HL8qH75v7Lq2O27kHcVSiD3DhJmXPnz+nEPYnG
- Zfbb24/KkUOHsX2a9VmVx2pg0ocbKNcHXaGXL4P60JYpV0tm7ty5pgJBITqNFQCDxyePTwD4C0mb3JxO
- G4WuAwGQDuchl2ew6zDr1Hw2LrN/6JChz24rePuCYysPL0qd3Lezv1D9JJ5Y3MZYAQJgHzBwfoaG+giA
- 2WDT2mc0PCAOsSFpQ7QRT582w+o4Aj969ChU57Byf+/ezsxr8NuaAbhBNkP3bXOMysMLDLlvZ/8TmGEE
- QE8o0AbAPkDgDJ494VMFZs+erU2b7WFgcYjxks6b1DGlS7teVhi4Xi8xH3bh0kLa2JlntbYgeFs2SR17
- cFF57CvmrFmzLADogcAgnQWhrAIC56fDVwC0B+m82e4bXQcOsdSUVA3GzjhvWnv27HXfiVtbdyjnuTI0
- NDRq5vnv10PzV8OWtNcG6v7ChQuV9wzeBsAeCAwKVAAOR6hSyT4+VWDmxx/LaOz+tEx4ByB9OANSU9Nk
- w/oNyn1eUOzLPIcVs76tZZtOXHJ+M/Reg8e91w6+ugqXewRP2Zw3b76QOgyen9OnT9dBxjlgAFjBY7kL
- cYT4RqEZM2aq18Nje54ZGcOVQmzkW7duaRVaQRc7eMorFUqDpykMvWfTrlu3BqbwKs2+uhMWgLkQClKV
- 3GfwY2HVUDYVAAImAALRA2XyqQIfffQPUIYuG71OZB/0ycAMoHPMS0cqbMKKJRVCuWX26EZPnzYdJsBk
- vfwUYn5QxSi9pJ75fylqJdI+Yab1gDL8jIMbocGjgbtmPwSAQlSZfAJAazwjY6Q01zgkfSiCzxihbjON
- Wpq0SYlJurvTnFI3GQ4CzVc6CXQUXBFmhzd7jJmkHEimKQ23mWXuPcx4cIhFG9BFqWNnHp9B+PvAwEDf
- AJSVlYEqw+VEUw+pXxaKDA7H6XSa6XEmJhmHOX6Abc4ae/Bpt822ywks0rrjcj0gIIcjDMGGIeuhAIOD
- z+BghzmgTWAQgg8IUkvFpwqQk2kI+vjWntLe0Evqqx3w99O1ialENGo9vf4EmLQD4gd0MWptMKSJp++v
- fg/ATCoIlNK8ACnNx8kLlBL8XJJrzoRcf5mQw9NbAvwDAMJHANOmTcMLSboca+wph7f4KYgtVQ5JSuZj
- BQAMJgDjNHv6nwkJxrD1dJyNadv5eEHPMwKWodNF6zwCtHKBTmxeJ+gSBrqEin+AQ/z8Q8Svd7D07h2g
- IHyqwNSpU5HxIXKquSeq0EsrcbKpp2xdHgyL3NjkrMCzAFAJ9EYnAJq4sM3jDAB1ntEzUwqDZVJ+kB6t
- gkcFNPOowHhkf1y2H6rgB1PLRwBTYLpSNZKSU8H1ND2DEvFzIriPo4GjB9jMXSuAFxcCeMo2j8NV0Vae
- mBja5zHoB1TBaWzDULjP7Af2QBD4T+77+wdKb57egb4DoGvMOzElsYgrtfUqw/WC3hCl0f0GBkqxGoMG
- JSp9+CDHYGOUKhG6kNFpoBT6+/uLHwyqHvB43n77bfueq/T4o+PTjcx6CexuvUkV4XMaTpnn4WPD/3ro
- MvhyvH6hsQB041sU36T4rMOXkRfgePdGZr2avYSM9yAIvknxWecFON69UloA+A7L91i+y/J99kU5f/xO
- /NS7pf06/iJ9ukP8D3GWhQo97UjxAAAAAElFTkSuQmCC
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
+ vAAADrwBlbxySQAADUJJREFUaEPtWelTVHcWzcyXVBJjkkoqCbJDd9PdNCICouyiuAAKhB3BFZhMLOO+
+ ILIoKq6AIIsYMSK474q4BEzUiRInJho1FZNUjeZL/os799zfe90NMpPumi/WVF7VrddU093n3Hvu8rvv
+ lT+vP68/r//Dq6WllZqamtmaqKGxgXbv3k3bt2+nrXV1tGXLFqrdtImqa6ppw4ZKKi9fT2vWrKFVq1bR
+ ihUraOmyZbR48WL6+OOPqbSslBaVLKIFCxbQvLlzqaioiPLz8yknO4c++iiLMjIyaNasWZSamkozZsyg
+ KVOn0OTJkykhIYFi42Jp0qRJNGHCBBo/fjyFhYURQ/uLZv/9AvCcnGy2HLlnZWXxD35EmZmZlJ6eTrNn
+ z5YfTktL4x9PoZkzU9lmCojp06ZRcnIyTZmig0mk+Ph4iouPo9jYWIqOjhZgEydOFHDhEeEUxgDHjRtH
+ oaGhNHbsWAoJCRGzWILJZLKQwRgk7zG00Wyj2F5l+yvbyFdzczPl5eWxtwoojz2G17m5uUJIEcl4gUhK
+ iiIxffp0msYkpiZPpaSkJErUPBrPFhcHEjFCQghERVFkRASFh4ezl8MoVCMREjKWbLYQMjOBE/UfkpEJ
+ gNDrr78+/o033rC99tprYxgmSIx8gQDAFxYWUkFBgYQ9l0lkMwFEA5HISNdJaJHQCCAKQmAqCDhFISGe
+ 4p0IIApRE6MoIjLSTkCPAgi01HxA5qAQjkAwGQ1mCg4OJgaf9+abb6aBBMNEJEaWEyQE8HPmzJF7PpOQ
+ KOTkUnZ2NmVyFEBgaARSaMZMlpAeASHAEUhMVBGAjJhATEyMQ0IcgQh7BBwystlCKdg6loLMIRIBU5CZ
+ LGYLjRo1qmT06NF5b7311niGCTmNTKCxoZHBF1NRcbGQsEeBZZSVzRFgAvD+LCaQmpaqwIv+p1PyVNY/
+ A09iz48EPloDH8X6j7R7XyVp6LhQLQKhEoEgs43BW8jIeRAUFAQCZUyggAmEM8z/TKC+vp6K5hbRXFQO
+ PQrIBRDIAvjZlMKVA94e6mkGyokKoLEAOyxhIyMiKSJceRyAdY/DkLxyD0UScw6w5s3WYGrdyERMZpaS
+ yXUCu3btouLiuYpAkR4FLn9MALLJzculo0ePUk9PD3V3d1NXVxd9/vnn9Nlnn1F7ezshhxoa6qX0btm8
+ hWpqamhDRYWU2+UrltOSJUuorOxvtHDhQv6dYnEQSNlCbBTiXIWsKgIGUxAZDAbXCezcuZPmzpsntRs/
+ AAJIaug/n3MB12+//UY//PADfffdd/TNN9/QnTv/oJtffUU3Bm7Q1atXqbe3l86dO0enTp+iY0eOCMnO
+ A520b98+2tu8lxobGwm/s3XrVtq4cSP3lA0soTCysddtNptUIatTBAICAlwnAM/Nnz+f5jEJREERyJfG
+ c/z4cfr999/pyZMnTOChELh37x59/fXXdPPmTRoYGBACly5dEgInT52iIxytrq5DdODAAXuE6rUIbd68
+ mWqqq6mCI5TKuWQ2q4oDEiBgtVhZ/xby9fV1ncC2bdteIJCXly9JC+k8e/aMnv70lB4/fkzff/89ffvt
+ t3Tn7l26desW3bgxQNeuXVMROH+OTnMEjh4DAY5ApxaBvZBYA+3YscMuscrKKqlepiCTgLYGK7NYLELK
+ x8fbdQJ1dVuGEmCNIoFRLo+wHJ49f0Y///yzROHBgwdCYJAJ3L59mwncoOvXr1Pv5V46f/48EzhNx44d
+ o8OHDzsR2OsgwKOJEKiqlGKAZAVgALdaHQS8vLxcJ4CwDieAEoqZBYn7/Plz+uWXX+jJj0zg4QO6fx8E
+ BoXAl18ygWvX6XLvZTuBo0ygaxiBRiGwkwlsFQJVVVVcyRK46xq5fCoCFicCnp6e7hCotRNANUKVwBiB
+ bqsIqAg8dorAXURAJHSDrl1XEhoaAWcJ6REAAT0CVTIrodqg5g8hwI1sjIeH6wQ28bSJKgTvF3MZLShU
+ FShlZooQ+Bdy4OlP9EjPgX9yDty5IzkwwFXIngOcxJIDksRdnMSd1M4EmkeSUGWl9AxDYKAioEeBLYjt
+ ww8+dJ0AvhDgYRiB0YkxA2HWQd3/9ddfWT4/0sOHI1Whfrp65Yq9Cp3SqtChQ85VqInQLO1ViEdzSAjN
+ zhCoIqDngW7vv/++6wSquayh/ksPQAJzCcUUqhN4+vQpPXr0yF6BBgdVAvf397P2lXQAHNLplvqvgMPa
+ 2trknLGbCWzbvo1qa2sJv4cIYC4K1CLgTACv3333XWLgrhGAHuH5ojnwPicwNy9MoJh3ICG9+ty/f5+b
+ mO79W9THngfwo8dZMlrSQjr4zMGDB2l/x35qbW2hxj17aBcfkuq4XEOu8D4aGSZSRcBRiSAls8VM77zz
+ jusE8GWFTjNQbm6ONDHMPogApAPwkA60f/v2La4+X0oDO3/hgpa4xwU4Roz9+/dTW2sbdegJPKwLw/to
+ ZJiNQAClFJXILN5XEXj77bddJ1BRsZ4KWffQPsboHE7g9Ix0aTRdh7rU+HCPx4e7AH+bvuIRYqB/gC5f
+ vkxnz56lkydP2BNXrzwtLS0CHkdV6N85geGw9eXrFIEARQCVxwoSYkEA7zqB8vJyNX3iDGCfQBUBSAHg
+ IRt4XoHvl8pz8eJFh/Z7uh3eZ91jfID2G/c0yhkb3V7pv4oq1q+ndevWyYkMM48REdDyAPcgJsPAXSew
+ bu06AQ6TAwzrH1PoVJ71MXEC/C2uOJBNP1cd1P2+vj6pOpiV0K0RKVQdZ++rKbXhBfkA/Jq1a2ScDgzw
+ l2ZmAgEGDvAg4RYBfJk60A/dHmD27+jokHKJmeeLL76ga6z7PpYOvA/tAzya1kGWTod4v5WaMLyxbHbX
+ 71be5/JZW7tZqg+0j99btXq1EPD3BwGDygMGbuJRGvORWwRW85dlc91X518cHdNlDsKsAjlg4oRk+q70
+ ScO6wImrmtYZOnXiJNd9NT5L5dESGPLBBIruK97ftJGrD9Yy5bKSWblypYqAf6B0YyEA8HyHuUUAXwjZ
+ ZGY41ijYOoAA5HCFy2UvzzrwOmo+EhfeP3FCyeewBl4/4OiVBwclh/Z176+VfRIslE9jiAAIIA8AHHej
+ 0U0C8AaA65bG8kETm5w4WTx56ZJqVucY+JkzZ7jqnBTt9/Q4PC/g97Uz4b20h+u+vhxD5dG1r3t/2bJl
+ QgDHSj+dAPKAgQM8XrtFYPny5eL1dDZ964AmhnMvTlJnRS6n5bAC4HK85P5wiA8tzp5HtJoYvF42IR29
+ caHy6EfMpUuXagQ4B/z8pRcYNRK4G9wlgPUggDuvTNDEEuITBIzuccw43d094nWUzM7OA6J5JZsW8Tz+
+ fyeDr6urs0sHdX8tSweRBnidAHLAz99PCBgMRomEbm4RWPLpp5TGsz9WJjgDQD7oAVhQ7dq5S7SPA4oD
+ eKd4fV/HPklYaH4P13sBzyVTB19TrZoWyuaqVatFOgCPe2lpqTQy9AFFQAPPw12gIdA9AosXLxGvw/Rt
+ W3LyNJEQEnlwcFCi0Mly0cGjvKJCCXjOE9R7JO2OHdtoa91WRUDruiCwkrUPqcLzAD87fbaUTSHAgAEe
+ RMS4MrlF4JNP/s6SwZYNu072PssnmXsA1oQ4dGD/U1lRSSi38B620aUlpXwAmi/zUy73D1QxyA/SU5+L
+ l1Ui1ifwtBhLBvewcWEKPCfwUO8HMqFAqUxuEcBqPDl5BrXXGihpCoNPni7bZixqsaSNiY6R2R3LKdkm
+ 22yyx8EmARsFi9UxBuvjABqSSkqlbXgZcw88HhCoyYblogPXve/P7/v5+blHoKysjKUyjc63eVDzRiN7
+ cBqbY9OMNWF0jNowR04Yuh6ER5GMMJDT1+UgFqwdETEegJDBYGKwJgZqZDJsfA8IMChj2fj5M3hff1mp
+ uEUAmkxk0Odax9DpvZ7UXGOguPgkSWJUIuw6nXf9UVFRNCFywpBFrU4GMtHJ6FGyMpl5OX5UnOVLxdls
+ WX5UxK+LMpXNyfShORkwb/L18WUSbhIoKSmh2LgkOtsyhk42eQmJpmoDxcQmMngmEAcC2rLWaf8ZFaUW
+ tsOJ6Ht/kMDO02q18ayP1bmVZWVhOSF5zSwXE8vFSD6+BvLyCSQv7wDy9vYVEm4RWLRoEXt8Ml1sH8NR
+ 8JRIXGgbQ62bAlg+atOMCLxIgCPBueEggCXueBoX5pAVdp8LcgNoXra/mETBKQLieY5AIXu/IN2L//Yi
+ H3cJLFi4UKpGTGwCaz1RbFI0v45m7bMJcM4BJPNwApEgMGxtHqY9vICh22L7HIwomNXa0GgySz4gB/xZ
+ /9C+j48fecO8/dwngK0xzsQoiXkYqbWnMhgvsBtCabQ/A2NJIRqTJkWLfABagIpUrDKQobqgFPr4+JCX
+ pyd5eHjQe++9p59zBdwfGf7PZQJ84Y3R2jOpPL6XsJU5G1Yc/6sBkDvGn3HtCQ1feGMUnkXhmRQ+BOYv
+ gbn2jEy7XmVPe+CfwZgt/CUw155Saheew+KfwBThelnsj58TD7sQppfNtOuVV/4NcZaFCnU4CO8AAAAA
+ SUVORK5CYII=
\ No newline at end of file
diff --git a/GUI/CrashForm.Designer.cs b/GUI/CrashForm.Designer.cs
deleted file mode 100644
index b359fcf..0000000
--- a/GUI/CrashForm.Designer.cs
+++ /dev/null
@@ -1,253 +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) 2009-2010 Michael Möller
-
-*/
-
-
-namespace OpenHardwareMonitor.GUI {
- partial class CrashForm {
- ///
- /// 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.sendButton = new System.Windows.Forms.Button();
- this.exitButton = new System.Windows.Forms.Button();
- this.commentTextBox = new System.Windows.Forms.TextBox();
- this.titleLabel = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.commentPanel = new System.Windows.Forms.Panel();
- this.reportPanel = new System.Windows.Forms.Panel();
- this.reportTextBox = new System.Windows.Forms.TextBox();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.emailTextBox = new System.Windows.Forms.TextBox();
- this.commentPanel.SuspendLayout();
- this.reportPanel.SuspendLayout();
- this.SuspendLayout();
- //
- // sendButton
- //
- this.sendButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.sendButton.Location = new System.Drawing.Point(449, 469);
- this.sendButton.Name = "sendButton";
- this.sendButton.Size = new System.Drawing.Size(75, 23);
- this.sendButton.TabIndex = 2;
- this.sendButton.Text = "Send";
- this.sendButton.UseVisualStyleBackColor = true;
- this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
- //
- // exitButton
- //
- this.exitButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.exitButton.Location = new System.Drawing.Point(530, 469);
- this.exitButton.Name = "exitButton";
- this.exitButton.Size = new System.Drawing.Size(75, 23);
- this.exitButton.TabIndex = 3;
- this.exitButton.Text = "Exit";
- this.exitButton.UseVisualStyleBackColor = true;
- //
- // commentTextBox
- //
- this.commentTextBox.AcceptsReturn = true;
- this.commentTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.commentTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.commentTextBox.Location = new System.Drawing.Point(4, 4);
- this.commentTextBox.Multiline = true;
- this.commentTextBox.Name = "commentTextBox";
- this.commentTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.commentTextBox.Size = new System.Drawing.Size(586, 77);
- this.commentTextBox.TabIndex = 1;
- //
- // titleLabel
- //
- this.titleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.titleLabel.BackColor = System.Drawing.SystemColors.Window;
- this.titleLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.titleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.titleLabel.Location = new System.Drawing.Point(-1, -1);
- this.titleLabel.Name = "titleLabel";
- this.titleLabel.Padding = new System.Windows.Forms.Padding(10);
- this.titleLabel.Size = new System.Drawing.Size(619, 52);
- this.titleLabel.TabIndex = 4;
- this.titleLabel.Text = "Open Hardware Monitor has encountered a problem and needs to close. We are sorry " +
- "for the inconvenience.";
- //
- // label3
- //
- this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.label3.AutoEllipsis = true;
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(9, 63);
- this.label3.Margin = new System.Windows.Forms.Padding(3, 12, 3, 8);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(571, 13);
- this.label3.TabIndex = 5;
- this.label3.Text = "To help diagnose and fix the problem, you can send a crash report. The following " +
- "report has been created automatically:";
- //
- // label1
- //
- this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.label1.AutoEllipsis = true;
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(9, 347);
- this.label1.Margin = new System.Windows.Forms.Padding(3, 12, 3, 8);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(279, 13);
- this.label1.TabIndex = 6;
- this.label1.Text = "You can add additional information to the report (optional):";
- //
- // commentPanel
- //
- this.commentPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.commentPanel.BackColor = System.Drawing.SystemColors.Window;
- this.commentPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.commentPanel.Controls.Add(this.commentTextBox);
- this.commentPanel.Location = new System.Drawing.Point(12, 371);
- this.commentPanel.Margin = new System.Windows.Forms.Padding(3, 3, 3, 8);
- this.commentPanel.Name = "commentPanel";
- this.commentPanel.Padding = new System.Windows.Forms.Padding(4, 4, 1, 4);
- this.commentPanel.Size = new System.Drawing.Size(593, 87);
- this.commentPanel.TabIndex = 1;
- this.commentPanel.TabStop = true;
- //
- // reportPanel
- //
- this.reportPanel.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.reportPanel.BackColor = System.Drawing.SystemColors.Window;
- this.reportPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.reportPanel.Controls.Add(this.reportTextBox);
- this.reportPanel.Controls.Add(this.textBox1);
- this.reportPanel.Location = new System.Drawing.Point(12, 87);
- this.reportPanel.Name = "reportPanel";
- this.reportPanel.Padding = new System.Windows.Forms.Padding(4, 4, 1, 4);
- this.reportPanel.Size = new System.Drawing.Size(593, 212);
- this.reportPanel.TabIndex = 8;
- //
- // reportTextBox
- //
- this.reportTextBox.BackColor = System.Drawing.SystemColors.Window;
- this.reportTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.reportTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.reportTextBox.Location = new System.Drawing.Point(4, 4);
- this.reportTextBox.Multiline = true;
- this.reportTextBox.Name = "reportTextBox";
- this.reportTextBox.ReadOnly = true;
- this.reportTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.reportTextBox.Size = new System.Drawing.Size(586, 202);
- this.reportTextBox.TabIndex = 9;
- this.reportTextBox.TabStop = false;
- //
- // textBox1
- //
- this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.textBox1.Location = new System.Drawing.Point(4, 4);
- this.textBox1.Multiline = true;
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(586, 202);
- this.textBox1.TabIndex = 2;
- //
- // label2
- //
- this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.label2.AutoEllipsis = true;
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(9, 318);
- this.label2.Margin = new System.Windows.Forms.Padding(3, 12, 3, 8);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(171, 13);
- this.label2.TabIndex = 9;
- this.label2.Text = "Enter your email address (optional):";
- //
- // emailTextBox
- //
- this.emailTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.emailTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.emailTextBox.Location = new System.Drawing.Point(188, 315);
- this.emailTextBox.Name = "emailTextBox";
- this.emailTextBox.Size = new System.Drawing.Size(417, 20);
- this.emailTextBox.TabIndex = 0;
- //
- // CrashReportForm
- //
- this.AcceptButton = this.sendButton;
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.CancelButton = this.exitButton;
- this.ClientSize = new System.Drawing.Size(617, 504);
- this.ControlBox = false;
- this.Controls.Add(this.emailTextBox);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.reportPanel);
- this.Controls.Add(this.commentPanel);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.titleLabel);
- this.Controls.Add(this.exitButton);
- this.Controls.Add(this.sendButton);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "CrashReportForm";
- this.ShowIcon = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "Open Hardware Monitor";
- this.commentPanel.ResumeLayout(false);
- this.commentPanel.PerformLayout();
- this.reportPanel.ResumeLayout(false);
- this.reportPanel.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Button sendButton;
- private System.Windows.Forms.Button exitButton;
- private System.Windows.Forms.TextBox commentTextBox;
- private System.Windows.Forms.Label titleLabel;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Panel commentPanel;
- private System.Windows.Forms.Panel reportPanel;
- private System.Windows.Forms.TextBox reportTextBox;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.TextBox emailTextBox;
- }
-}
\ No newline at end of file
diff --git a/GUI/CrashForm.cs b/GUI/CrashForm.cs
deleted file mode 100644
index 60c5aa4..0000000
--- a/GUI/CrashForm.cs
+++ /dev/null
@@ -1,91 +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) 2009-2010 Michael Möller
-
-*/
-
-
-using System;
-using System.IO;
-using System.Net;
-using System.Text;
-using System.Windows.Forms;
-
-namespace OpenHardwareMonitor.GUI {
- public partial class CrashForm : Form {
-
- private Exception exception;
-
- public CrashForm() {
- InitializeComponent();
- }
-
- public Exception Exception {
- get { return exception; }
- set {
- exception = value;
- StringBuilder s = new StringBuilder();
- Version version = typeof(CrashForm).Assembly.GetName().Version;
- s.Append("Version: "); s.AppendLine(version.ToString());
- s.AppendLine();
- s.AppendLine(exception.ToString());
- s.AppendLine();
- if (exception.InnerException != null) {
- s.AppendLine(exception.InnerException.ToString());
- s.AppendLine();
- }
- s.Append("Common Language Runtime: ");
- s.AppendLine(Environment.Version.ToString());
- s.Append("Operating System: ");
- s.AppendLine(Environment.OSVersion.ToString());
- s.Append("Process Type: ");
- s.AppendLine(IntPtr.Size == 4 ? "32-Bit" : "64-Bit");
- reportTextBox.Text = s.ToString();
- }
- }
-
- private void sendButton_Click(object sender, EventArgs e) {
- try {
- Version version = typeof(CrashForm).Assembly.GetName().Version;
- WebRequest request = WebRequest.Create(
- "http://openhardwaremonitor.org/report.php");
- request.Method = "POST";
- request.Timeout = 5000;
- request.ContentType = "application/x-www-form-urlencoded";
-
- string report =
- "type=crash&" +
- "version=" + Uri.EscapeDataString(version.ToString()) + "&" +
- "report=" + Uri.EscapeDataString(reportTextBox.Text) + "&" +
- "comment=" + Uri.EscapeDataString(commentTextBox.Text) + "&" +
- "email=" + Uri.EscapeDataString(emailTextBox.Text);
- byte[] byteArray = Encoding.UTF8.GetBytes(report);
- request.ContentLength = byteArray.Length;
-
- try {
- Stream dataStream = request.GetRequestStream();
- dataStream.Write(byteArray, 0, byteArray.Length);
- dataStream.Close();
-
- WebResponse response = request.GetResponse();
- dataStream = response.GetResponseStream();
- StreamReader reader = new StreamReader(dataStream);
- string responseFromServer = reader.ReadToEnd();
- reader.Close();
- dataStream.Close();
- response.Close();
-
- Close();
- } catch (WebException) {
- MessageBox.Show("Sending the crash report failed.", "Error",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- } catch {
- }
- }
- }
-}
diff --git a/GUI/CrashForm.resx b/GUI/CrashForm.resx
deleted file mode 100644
index ff31a6d..0000000
--- a/GUI/CrashForm.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/GUI/Gadget.cs b/GUI/Gadget.cs
index 41208bc..03d0be9 100644
--- a/GUI/Gadget.cs
+++ b/GUI/Gadget.cs
@@ -1,145 +1,178 @@
-/*
-
- 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) 2010-2011 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Drawing;
using System.Windows.Forms;
-namespace OpenHardwareMonitor.GUI {
- public abstract class Gadget : IDisposable {
+namespace OpenHardwareMonitor.GUI
+{
+ public abstract class Gadget : IDisposable
+ {
+ private readonly GadgetWindow _window;
- private GadgetWindow window;
+ public event EventHandler VisibleChanged;
- public Gadget() {
- this.window = new GadgetWindow();
- this.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 {
- this.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 ContextMenu ContextMenu {
- get {
- return window.ContextMenu;
- }
- set {
- window.ContextMenu = 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;
- if (VisibleChanged != null)
- VisibleChanged(this, EventArgs.Empty);
- if (value)
- Redraw();
+ 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 ContextMenu ContextMenu
+ {
+ get
+ {
+ return _window.ContextMenu;
+ }
+ set
+ {
+ _window.ContextMenu = 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);
}
-
- public event EventHandler VisibleChanged;
-
- public void Redraw() {
- window.Redraw();
- }
-
- protected abstract void OnPaint(PaintEventArgs e);
-
- }
}
diff --git a/GUI/GadgetWindow.cs b/GUI/GadgetWindow.cs
index ae3b0e3..3d93dec 100644
--- a/GUI/GadgetWindow.cs
+++ b/GUI/GadgetWindow.cs
@@ -1,13 +1,7 @@
-/*
-
- 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) 2010-2011 Michael Möller
- Copyright (C) 2010 Paul Werelds
-
-*/
+// Mozilla Public License 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 System;
using System.Drawing;
@@ -17,563 +11,570 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
-namespace OpenHardwareMonitor.GUI {
+namespace OpenHardwareMonitor.GUI
+{
+ 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 class GadgetWindow : NativeWindow, IDisposable {
+ public event EventHandler SizeChanged;
+ public event EventHandler LocationChanged;
+ public event HitTestEventHandler HitTest;
+ public event MouseEventHandler MouseDoubleClick;
- private bool visible = false;
- private bool lockPositionAndSize = false;
- private bool alwaysOnTop = false;
- private byte opacity = 255;
- private Point location = new Point(100, 100);
- private Size size = new Size(130, 84);
- private ContextMenu contextMenu = null;
- private MethodInfo commandDispatch;
- private IntPtr handleBitmapDC;
- private Size bufferSize;
- private Graphics graphics;
+ 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);
- public GadgetWindow() {
- Type commandType =
- typeof(Form).Assembly.GetType("System.Windows.Forms.Command");
- commandDispatch = commandType.GetMethod("DispatchID",
- BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public,
- null, new Type[]{ typeof(int) }, null);
+ CreateHandle(CreateParams);
- this.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(value));
- } 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 void ShowContextMenu(Point position) {
- NativeMethods.TrackPopupMenuEx(contextMenu.Handle,
- TPM_RIGHTBUTTON | TPM_VERTICAL, position.X,
- position.Y, Handle, IntPtr.Zero);
- }
-
- protected virtual CreateParams CreateParams {
- get {
- CreateParams cp = new CreateParams();
- cp.Width = 4096;
- cp.Height = 4096;
- cp.X = location.X;
- cp.Y = location.Y;
- cp.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: {
- if (MouseDoubleClick != null) {
- MouseDoubleClick(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: {
- if (contextMenu != null)
- ShowContextMenu(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);
- if (LocationChanged != null)
- LocationChanged(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);
- if (SizeChanged != null)
- SizeChanged(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() {
- BlendFunction blend = new BlendFunction();
- blend.BlendOp = AC_SRC_OVER;
- blend.BlendFlags = 0;
- blend.SourceConstantAlpha = opacity;
- blend.AlphaFormat = AC_SRC_ALPHA;
- return blend;
- }
-
- 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 ptr;
- IntPtr hBmp = NativeMethods.CreateDIBSection(handleBitmapDC, ref info, 0,
- out ptr, IntPtr.Zero, 0);
- IntPtr hBmpOld = NativeMethods.SelectObject(handleBitmapDC, hBmp);
- NativeMethods.DeleteObject(hBmpOld);
-
- graphics = Graphics.FromHdc(handleBitmapDC);
-
- if (Environment.OSVersion.Version.Major > 5) {
- this.graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
- this.graphics.SmoothingMode = SmoothingMode.HighQuality;
- }
- }
-
- private void DisposeBuffer() {
- graphics.Dispose();
- NativeMethods.DeleteDC(handleBitmapDC);
- }
-
- public virtual 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 {
- return lockPositionAndSize;
- }
- set {
- lockPositionAndSize = value;
- }
- }
-
- public bool AlwaysOnTop {
- get {
- return alwaysOnTop;
- }
- set {
- if (value != alwaysOnTop) {
- alwaysOnTop = value;
- if (alwaysOnTop) {
- if (visible)
- ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged;
- MoveToTopMost(Handle);
- } else {
+ // move window to the bottom
MoveToBottom(Handle);
- if (visible)
- ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged;
- }
+
+ // 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();
}
- }
- }
- 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);
- if (SizeChanged != null)
- SizeChanged(this, EventArgs.Empty);
+ private void ShowDesktopChanged(bool showDesktop)
+ {
+ if (showDesktop)
+ MoveToTopMost(Handle);
+ else
+ MoveToBottom(Handle);
}
- }
- }
- public event EventHandler SizeChanged;
-
- 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);
- if (LocationChanged != null)
- LocationChanged(this, EventArgs.Empty);
+ 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 void ShowContextMenu(Point position)
+ {
+ NativeMethods.TrackPopupMenuEx(ContextMenu.Handle, TPM_RIGHTBUTTON | TPM_VERTICAL, position.X, position.Y, Handle, IntPtr.Zero);
+ }
+
+ 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:
+ {
+ if (ContextMenu != null)
+ ShowContextMenu(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 ContextMenu ContextMenu { 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 event EventHandler LocationChanged;
+ public delegate void HitTestEventHandler(object sender, HitTestEventArgs e);
- public ContextMenu ContextMenu {
- get {
- return contextMenu;
- }
- set {
- this.contextMenu = value;
- }
+ 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 event HitTestEventHandler HitTest;
-
- public event MouseEventHandler MouseDoubleClick;
-
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- private struct BlendFunction {
- public byte BlendOp;
- public byte BlendFlags;
- public byte SourceConstantAlpha;
- public byte AlphaFormat;
+ public class HitTestEventArgs : EventArgs
+ {
+ public HitTestEventArgs(Point location, HitResult hitResult)
+ {
+ Location = location;
+ HitResult = hitResult;
+ }
+ public Point Location { get; }
+ public HitResult HitResult { get; set; }
}
-
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- private struct WindowPos {
- public IntPtr hwnd;
- public IntPtr hwndInsertAfter;
- public int x;
- public int y;
- public int cx;
- public int cy;
- public uint flags;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct BitmapInfo {
- public Int32 Size;
- public Int32 Width;
- public Int32 Height;
- public Int16 Planes;
- public Int16 BitCount;
- public Int32 Compression;
- public Int32 SizeImage;
- public Int32 XPelsPerMeter;
- public Int32 YPelsPerMeter;
- public Int32 ClrUsed;
- public Int32 ClrImportant;
- public Int32 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 UInt16 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";
- public 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 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 delegate void HitTestEventHandler(object sender, HitTestEventArgs e);
-
- public class HitTestEventArgs : EventArgs {
- public HitTestEventArgs(Point location, HitResult hitResult) {
- Location = location;
- HitResult = hitResult;
- }
- public Point Location { get; private set; }
- public HitResult HitResult { get; set; }
- }
}
diff --git a/GUI/HardwareNode.cs b/GUI/HardwareNode.cs
index a68289e..207df45 100644
--- a/GUI/HardwareNode.cs
+++ b/GUI/HardwareNode.cs
@@ -1,113 +1,119 @@
-/*
-
- 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) 2009-2012 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Collections.Generic;
-using System.Drawing;
using OpenHardwareMonitor.Hardware;
+using OpenHardwareMonitor.Utilities;
-namespace OpenHardwareMonitor.GUI {
- public class HardwareNode : Node {
-
- private PersistentSettings settings;
- private UnitManager unitManager;
- private IHardware hardware;
-
- private List typeNodes = new List();
-
- public HardwareNode(IHardware hardware, PersistentSettings settings,
- UnitManager unitManager) : base()
+namespace OpenHardwareMonitor.GUI
+{
+ public class HardwareNode : Node
{
- this.settings = settings;
- this.unitManager = unitManager;
- this.hardware = hardware;
- this.Image = HardwareTypeImage.Instance.GetImage(hardware.HardwareType);
+ private readonly PersistentSettings _settings;
+ private readonly UnitManager _unitManager;
+ private readonly List _typeNodes = new List();
- foreach (SensorType sensorType in Enum.GetValues(typeof(SensorType)))
- typeNodes.Add(new TypeNode(sensorType));
+ public event EventHandler PlotSelectionChanged;
- foreach (ISensor sensor in hardware.Sensors)
- SensorAdded(sensor);
+ public HardwareNode(IHardware hardware, PersistentSettings settings, UnitManager unitManager)
+ {
+ _settings = settings;
+ _unitManager = unitManager;
+ Hardware = hardware;
+ Image = HardwareTypeImage.Instance.GetImage(hardware.HardwareType);
- hardware.SensorAdded +=new SensorEventHandler(SensorAdded);
- hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
- }
+ foreach (SensorType sensorType in Enum.GetValues(typeof(SensorType)))
+ _typeNodes.Add(new TypeNode(sensorType));
- public override string Text {
- get { return hardware.Name; }
- set { hardware.Name = value; }
- }
+ foreach (ISensor sensor in hardware.Sensors)
+ SensorAdded(sensor);
- public IHardware Hardware {
- get { return hardware; }
- }
-
- 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);
+ hardware.SensorAdded += SensorAdded;
+ hardware.SensorRemoved += SensorRemoved;
}
- } 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) {
- SensorNode n = node as SensorNode;
- if (n != null && n.Sensor == sensor)
- sensorNode = n;
- }
- if (sensorNode != null) {
- sensorNode.PlotSelectionChanged -= SensorPlotSelectionChanged;
- typeNode.Nodes.Remove(sensorNode);
- UpdateNode(typeNode);
- }
+ public override string Text
+ {
+ get { return Hardware.Name; }
+ set { Hardware.Name = value; }
}
- if (PlotSelectionChanged != null)
- PlotSelectionChanged(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);
- }
+ public IHardware Hardware { get; }
- private void SensorPlotSelectionChanged(object sender, EventArgs e) {
- if (PlotSelectionChanged != null)
- PlotSelectionChanged(this, null);
- }
+ 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++;
- private void SensorAdded(ISensor sensor) {
- foreach (TypeNode typeNode in typeNodes)
- if (typeNode.SensorType == sensor.SensorType) {
- InsertSorted(typeNode, sensor);
- UpdateNode(typeNode);
+ Nodes.Insert(i, node);
+ }
+ }
+ else
+ {
+ if (Nodes.Contains(node))
+ Nodes.Remove(node);
+ }
}
- if (PlotSelectionChanged != null)
- PlotSelectionChanged(this, null);
- }
- public event EventHandler PlotSelectionChanged;
- }
+ 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/GUI/HardwareTypeImage.cs b/GUI/HardwareTypeImage.cs
index 1ea5ee3..7485540 100644
--- a/GUI/HardwareTypeImage.cs
+++ b/GUI/HardwareTypeImage.cs
@@ -1,77 +1,69 @@
-/*
-
- 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) 2010-2012 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Drawing;
using System.Collections.Generic;
using OpenHardwareMonitor.Hardware;
-namespace OpenHardwareMonitor.GUI {
- public class HardwareTypeImage {
- private static HardwareTypeImage instance = new HardwareTypeImage();
+namespace OpenHardwareMonitor.GUI
+{
+ public class HardwareTypeImage
+ {
+ private readonly IDictionary _images = new Dictionary();
- private IDictionary images =
- new Dictionary();
+ private HardwareTypeImage() { }
- private HardwareTypeImage() { }
+ public static HardwareTypeImage Instance { get; } = new HardwareTypeImage();
- public static HardwareTypeImage Instance {
- get { return instance; }
- }
+ public Image GetImage(HardwareType hardwareType)
+ {
+ if (_images.TryGetValue(hardwareType, out Image image))
+ return image;
- public Image GetImage(HardwareType hardwareType) {
- Image image;
- if (images.TryGetValue(hardwareType, out image)) {
- return image;
- } else {
- switch (hardwareType) {
- case HardwareType.CPU:
- image = Utilities.EmbeddedResources.GetImage("cpu.png");
- break;
- case HardwareType.GpuNvidia:
- image = Utilities.EmbeddedResources.GetImage("nvidia.png");
- break;
- case HardwareType.GpuAti:
- image = Utilities.EmbeddedResources.GetImage("ati.png");
- break;
- case HardwareType.HDD:
- image = Utilities.EmbeddedResources.GetImage("hdd.png");
- break;
- case HardwareType.Heatmaster:
- image = Utilities.EmbeddedResources.GetImage("bigng.png");
- break;
- case HardwareType.Mainboard:
- image = Utilities.EmbeddedResources.GetImage("mainboard.png");
- break;
- case HardwareType.SuperIO:
- image = Utilities.EmbeddedResources.GetImage("chip.png");
- break;
- case HardwareType.TBalancer:
- image = Utilities.EmbeddedResources.GetImage("bigng.png");
- break;
- case HardwareType.RAM:
- image = Utilities.EmbeddedResources.GetImage("ram.png");
- break;
- case HardwareType.Aquacomputer:
- image = Utilities.EmbeddedResources.GetImage("acicon.png");
- break;
- case HardwareType.NIC:
- image = Utilities.EmbeddedResources.GetImage("nic.png");
- break;
- default:
- image = new Bitmap(1, 1);
- break;
+
+ switch (hardwareType)
+ {
+ case HardwareType.CPU:
+ image = Utilities.EmbeddedResources.GetImage("cpu.png");
+ break;
+ case HardwareType.GpuNvidia:
+ image = Utilities.EmbeddedResources.GetImage("nvidia.png");
+ break;
+ case HardwareType.GpuAti:
+ image = Utilities.EmbeddedResources.GetImage("ati.png");
+ break;
+ case HardwareType.HDD:
+ image = Utilities.EmbeddedResources.GetImage("hdd.png");
+ break;
+ case HardwareType.Heatmaster:
+ image = Utilities.EmbeddedResources.GetImage("bigng.png");
+ break;
+ case HardwareType.Mainboard:
+ image = Utilities.EmbeddedResources.GetImage("mainboard.png");
+ break;
+ case HardwareType.SuperIO:
+ image = Utilities.EmbeddedResources.GetImage("chip.png");
+ break;
+ case HardwareType.TBalancer:
+ image = Utilities.EmbeddedResources.GetImage("bigng.png");
+ break;
+ case HardwareType.RAM:
+ image = Utilities.EmbeddedResources.GetImage("ram.png");
+ break;
+ case HardwareType.Aquacomputer:
+ image = Utilities.EmbeddedResources.GetImage("acicon.png");
+ break;
+ case HardwareType.NIC:
+ image = Utilities.EmbeddedResources.GetImage("nic.png");
+ break;
+ default:
+ image = new Bitmap(1, 1);
+ break;
+ }
+ _images.Add(hardwareType, image);
+ return image;
}
- images.Add(hardwareType, image);
- return image;
- }
}
- }
}
diff --git a/GUI/MainForm.Designer.cs b/GUI/MainForm.Designer.cs
index 91d6853..d51b098 100644
--- a/GUI/MainForm.Designer.cs
+++ b/GUI/MainForm.Designer.cs
@@ -9,7 +9,7 @@
*/
namespace OpenHardwareMonitor.GUI {
- partial class MainForm {
+ sealed partial class MainForm {
///
/// Required designer variable.
///
@@ -33,228 +33,221 @@ namespace OpenHardwareMonitor.GUI {
/// 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.MainMenu(this.components);
- this.fileMenuItem = new System.Windows.Forms.MenuItem();
- this.saveReportMenuItem = new System.Windows.Forms.MenuItem();
- this.sumbitReportMenuItem = new System.Windows.Forms.MenuItem();
- this.MenuItem2 = new System.Windows.Forms.MenuItem();
- this.resetMenuItem = new System.Windows.Forms.MenuItem();
- this.menuItem5 = new System.Windows.Forms.MenuItem();
- this.mainboardMenuItem = new System.Windows.Forms.MenuItem();
- this.cpuMenuItem = new System.Windows.Forms.MenuItem();
- this.ramMenuItem = new System.Windows.Forms.MenuItem();
- this.gpuMenuItem = new System.Windows.Forms.MenuItem();
- this.fanControllerMenuItem = new System.Windows.Forms.MenuItem();
- this.hddMenuItem = new System.Windows.Forms.MenuItem();
- this.menuItem6 = new System.Windows.Forms.MenuItem();
- this.exitMenuItem = new System.Windows.Forms.MenuItem();
- this.viewMenuItem = new System.Windows.Forms.MenuItem();
- this.resetMinMaxMenuItem = new System.Windows.Forms.MenuItem();
- this.MenuItem3 = new System.Windows.Forms.MenuItem();
- this.hiddenMenuItem = new System.Windows.Forms.MenuItem();
- this.plotMenuItem = new System.Windows.Forms.MenuItem();
- this.gadgetMenuItem = new System.Windows.Forms.MenuItem();
- this.MenuItem1 = new System.Windows.Forms.MenuItem();
- this.columnsMenuItem = new System.Windows.Forms.MenuItem();
- this.valueMenuItem = new System.Windows.Forms.MenuItem();
- this.minMenuItem = new System.Windows.Forms.MenuItem();
- this.maxMenuItem = new System.Windows.Forms.MenuItem();
- this.optionsMenuItem = new System.Windows.Forms.MenuItem();
- this.startMinMenuItem = new System.Windows.Forms.MenuItem();
- this.minTrayMenuItem = new System.Windows.Forms.MenuItem();
- this.minCloseMenuItem = new System.Windows.Forms.MenuItem();
- this.startupMenuItem = new System.Windows.Forms.MenuItem();
- this.separatorMenuItem = new System.Windows.Forms.MenuItem();
- this.temperatureUnitsMenuItem = new System.Windows.Forms.MenuItem();
- this.celsiusMenuItem = new System.Windows.Forms.MenuItem();
- this.fahrenheitMenuItem = new System.Windows.Forms.MenuItem();
- this.plotLocationMenuItem = new System.Windows.Forms.MenuItem();
- this.plotWindowMenuItem = new System.Windows.Forms.MenuItem();
- this.plotBottomMenuItem = new System.Windows.Forms.MenuItem();
- this.plotRightMenuItem = new System.Windows.Forms.MenuItem();
- this.webMenuItemSeparator = new System.Windows.Forms.MenuItem();
- this.webMenuItem = new System.Windows.Forms.MenuItem();
- this.runWebServerMenuItem = new System.Windows.Forms.MenuItem();
- this.serverPortMenuItem = new System.Windows.Forms.MenuItem();
- this.logSensorsMenuItem = new System.Windows.Forms.MenuItem();
- this.helpMenuItem = new System.Windows.Forms.MenuItem();
- this.aboutMenuItem = new System.Windows.Forms.MenuItem();
- this.treeContextMenu = new System.Windows.Forms.ContextMenu();
- this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
- this.timer = new System.Windows.Forms.Timer(this.components);
- this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
- this.treeView = new Aga.Controls.Tree.TreeViewAdv();
- this.nicMenuItem = new System.Windows.Forms.MenuItem();
- this.logSeparatorMenuItem = new System.Windows.Forms.MenuItem();
- this.loggingIntervalMenuItem = new System.Windows.Forms.MenuItem();
- this.log1sMenuItem = new System.Windows.Forms.MenuItem();
- this.log5sMenuItem = new System.Windows.Forms.MenuItem();
- this.log10sMenuItem = new System.Windows.Forms.MenuItem();
- this.log30sMenuItem = new System.Windows.Forms.MenuItem();
- this.log1minMenuItem = new System.Windows.Forms.MenuItem();
- this.log5minMenuItem = new System.Windows.Forms.MenuItem();
- this.log10minMenuItem = new System.Windows.Forms.MenuItem();
- this.log30minMenuItem = new System.Windows.Forms.MenuItem();
- this.log2sMenuItem = new System.Windows.Forms.MenuItem();
- this.log2minMenuItem = new System.Windows.Forms.MenuItem();
- this.log1hMenuItem = new System.Windows.Forms.MenuItem();
- this.log2hMenuItem = new System.Windows.Forms.MenuItem();
- this.log6hMenuItem = new System.Windows.Forms.MenuItem();
- this.sensorValuesTimeWindowMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow30sMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow2minMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow5minMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow10minMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow30minMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow1hMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow2hMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow6hMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow12hMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow24hMenuItem = new System.Windows.Forms.MenuItem();
- this.timeWindow1minMenuItem = new System.Windows.Forms.MenuItem();
- 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;
- //
- // value
- //
- this.value.Header = "Value";
- this.value.SortOrder = System.Windows.Forms.SortOrder.None;
- this.value.TooltipText = null;
- this.value.Width = 100;
- //
- // min
- //
- this.min.Header = "Min";
- this.min.SortOrder = System.Windows.Forms.SortOrder.None;
- this.min.TooltipText = null;
- this.min.Width = 100;
- //
- // max
- //
- this.max.Header = "Max";
- this.max.SortOrder = System.Windows.Forms.SortOrder.None;
- this.max.TooltipText = null;
- this.max.Width = 100;
- //
- // 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.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ 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.MainMenu(this.components);
+ this.fileMenuItem = new System.Windows.Forms.MenuItem();
+ this.saveReportMenuItem = new System.Windows.Forms.MenuItem();
+ this.MenuItem2 = new System.Windows.Forms.MenuItem();
+ this.resetMenuItem = new System.Windows.Forms.MenuItem();
+ this.menuItem5 = new System.Windows.Forms.MenuItem();
+ this.mainboardMenuItem = new System.Windows.Forms.MenuItem();
+ this.cpuMenuItem = new System.Windows.Forms.MenuItem();
+ this.ramMenuItem = new System.Windows.Forms.MenuItem();
+ this.gpuMenuItem = new System.Windows.Forms.MenuItem();
+ this.fanControllerMenuItem = new System.Windows.Forms.MenuItem();
+ this.hddMenuItem = new System.Windows.Forms.MenuItem();
+ this.nicMenuItem = new System.Windows.Forms.MenuItem();
+ this.menuItem6 = new System.Windows.Forms.MenuItem();
+ this.exitMenuItem = new System.Windows.Forms.MenuItem();
+ this.viewMenuItem = new System.Windows.Forms.MenuItem();
+ this.resetMinMaxMenuItem = new System.Windows.Forms.MenuItem();
+ this.MenuItem3 = new System.Windows.Forms.MenuItem();
+ this.hiddenMenuItem = new System.Windows.Forms.MenuItem();
+ this.plotMenuItem = new System.Windows.Forms.MenuItem();
+ this.gadgetMenuItem = new System.Windows.Forms.MenuItem();
+ this.MenuItem1 = new System.Windows.Forms.MenuItem();
+ this.columnsMenuItem = new System.Windows.Forms.MenuItem();
+ this.valueMenuItem = new System.Windows.Forms.MenuItem();
+ this.minMenuItem = new System.Windows.Forms.MenuItem();
+ this.maxMenuItem = new System.Windows.Forms.MenuItem();
+ this.optionsMenuItem = new System.Windows.Forms.MenuItem();
+ this.startMinMenuItem = new System.Windows.Forms.MenuItem();
+ this.minTrayMenuItem = new System.Windows.Forms.MenuItem();
+ this.minCloseMenuItem = new System.Windows.Forms.MenuItem();
+ this.startupMenuItem = new System.Windows.Forms.MenuItem();
+ this.separatorMenuItem = new System.Windows.Forms.MenuItem();
+ this.temperatureUnitsMenuItem = new System.Windows.Forms.MenuItem();
+ this.celsiusMenuItem = new System.Windows.Forms.MenuItem();
+ this.fahrenheitMenuItem = new System.Windows.Forms.MenuItem();
+ this.plotLocationMenuItem = new System.Windows.Forms.MenuItem();
+ this.plotWindowMenuItem = new System.Windows.Forms.MenuItem();
+ this.plotBottomMenuItem = new System.Windows.Forms.MenuItem();
+ this.plotRightMenuItem = new System.Windows.Forms.MenuItem();
+ this.logSeparatorMenuItem = new System.Windows.Forms.MenuItem();
+ this.logSensorsMenuItem = new System.Windows.Forms.MenuItem();
+ this.loggingIntervalMenuItem = new System.Windows.Forms.MenuItem();
+ this.log1sMenuItem = new System.Windows.Forms.MenuItem();
+ this.log2sMenuItem = new System.Windows.Forms.MenuItem();
+ this.log5sMenuItem = new System.Windows.Forms.MenuItem();
+ this.log10sMenuItem = new System.Windows.Forms.MenuItem();
+ this.log30sMenuItem = new System.Windows.Forms.MenuItem();
+ this.log1minMenuItem = new System.Windows.Forms.MenuItem();
+ this.log2minMenuItem = new System.Windows.Forms.MenuItem();
+ this.log5minMenuItem = new System.Windows.Forms.MenuItem();
+ this.log10minMenuItem = new System.Windows.Forms.MenuItem();
+ this.log30minMenuItem = new System.Windows.Forms.MenuItem();
+ this.log1hMenuItem = new System.Windows.Forms.MenuItem();
+ this.log2hMenuItem = new System.Windows.Forms.MenuItem();
+ this.log6hMenuItem = new System.Windows.Forms.MenuItem();
+ this.sensorValuesTimeWindowMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow30sMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow1minMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow2minMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow5minMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow10minMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow30minMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow1hMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow2hMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow6hMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow12hMenuItem = new System.Windows.Forms.MenuItem();
+ this.timeWindow24hMenuItem = new System.Windows.Forms.MenuItem();
+ this.webMenuItemSeparator = new System.Windows.Forms.MenuItem();
+ this.webMenuItem = new System.Windows.Forms.MenuItem();
+ this.runWebServerMenuItem = new System.Windows.Forms.MenuItem();
+ this.serverPortMenuItem = new System.Windows.Forms.MenuItem();
+ this.helpMenuItem = new System.Windows.Forms.MenuItem();
+ this.aboutMenuItem = new System.Windows.Forms.MenuItem();
+ this.treeContextMenu = new System.Windows.Forms.ContextMenu();
+ this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
+ this.timer = new System.Windows.Forms.Timer(this.components);
+ this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
+ this.treeView = new Aga.Controls.Tree.TreeViewAdv();
+ ((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;
+ //
+ // value
+ //
+ this.value.Header = "Value";
+ this.value.SortOrder = System.Windows.Forms.SortOrder.None;
+ this.value.TooltipText = null;
+ this.value.Width = 100;
+ //
+ // min
+ //
+ this.min.Header = "Min";
+ this.min.SortOrder = System.Windows.Forms.SortOrder.None;
+ this.min.TooltipText = null;
+ this.min.Width = 100;
+ //
+ // max
+ //
+ this.max.Header = "Max";
+ this.max.SortOrder = System.Windows.Forms.SortOrder.None;
+ this.max.TooltipText = null;
+ this.max.Width = 100;
+ //
+ // 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.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.fileMenuItem,
this.viewMenuItem,
this.optionsMenuItem,
this.helpMenuItem});
- //
- // fileMenuItem
- //
- this.fileMenuItem.Index = 0;
- this.fileMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ //
+ // fileMenuItem
+ //
+ this.fileMenuItem.Index = 0;
+ this.fileMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.saveReportMenuItem,
- this.sumbitReportMenuItem,
this.MenuItem2,
this.resetMenuItem,
this.menuItem5,
this.menuItem6,
this.exitMenuItem});
- this.fileMenuItem.Text = "File";
- //
- // saveReportMenuItem
- //
- this.saveReportMenuItem.Index = 0;
- this.saveReportMenuItem.Text = "Save Report...";
- this.saveReportMenuItem.Click += new System.EventHandler(this.saveReportMenuItem_Click);
- //
- // sumbitReportMenuItem
- //
- this.sumbitReportMenuItem.Index = 1;
- this.sumbitReportMenuItem.Text = "Submit Report...";
- this.sumbitReportMenuItem.Click += new System.EventHandler(this.sumbitReportMenuItem_Click);
- //
- // MenuItem2
- //
- this.MenuItem2.Index = 2;
- this.MenuItem2.Text = "-";
- //
- // resetMenuItem
- //
- this.resetMenuItem.Index = 3;
- this.resetMenuItem.Text = "Reset";
- this.resetMenuItem.Click += new System.EventHandler(this.resetClick);
- //
- // menuItem5
- //
- this.menuItem5.Index = 4;
- this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.fileMenuItem.Text = "File";
+ //
+ // saveReportMenuItem
+ //
+ this.saveReportMenuItem.Index = 0;
+ this.saveReportMenuItem.Text = "Save Report...";
+ this.saveReportMenuItem.Click += new System.EventHandler(this.SaveReportMenuItem_Click);
+ //
+ // MenuItem2
+ //
+ this.MenuItem2.Index = 1;
+ this.MenuItem2.Text = "-";
+ //
+ // resetMenuItem
+ //
+ this.resetMenuItem.Index = 2;
+ this.resetMenuItem.Text = "Reset";
+ this.resetMenuItem.Click += new System.EventHandler(this.ResetClick);
+ //
+ // menuItem5
+ //
+ this.menuItem5.Index = 3;
+ this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mainboardMenuItem,
this.cpuMenuItem,
this.ramMenuItem,
@@ -262,58 +255,58 @@ namespace OpenHardwareMonitor.GUI {
this.fanControllerMenuItem,
this.hddMenuItem,
this.nicMenuItem});
- this.menuItem5.Text = "Hardware";
- //
- // mainboardMenuItem
- //
- this.mainboardMenuItem.Index = 0;
- this.mainboardMenuItem.Text = "Mainboard";
- //
- // cpuMenuItem
- //
- this.cpuMenuItem.Index = 1;
- this.cpuMenuItem.Text = "CPU";
- //
- // ramMenuItem
- //
- this.ramMenuItem.Index = 2;
- this.ramMenuItem.Text = "RAM";
- //
- // gpuMenuItem
- //
- this.gpuMenuItem.Index = 3;
- this.gpuMenuItem.Text = "GPU";
- //
- // fanControllerMenuItem
- //
- this.fanControllerMenuItem.Index = 4;
- this.fanControllerMenuItem.Text = "Fan Controllers";
- //
- // hddMenuItem
- //
- this.hddMenuItem.Index = 5;
- this.hddMenuItem.Text = "Hard Disk Drives";
- //
- // nicItem
- //
- this.nicMenuItem.Index = 6;
- this.nicMenuItem.Text = "Network";
- //
- // menuItem6
- //
- this.menuItem6.Index = 5;
- this.menuItem6.Text = "-";
- //
- // exitMenuItem
- //
- this.exitMenuItem.Index = 6;
- this.exitMenuItem.Text = "Exit";
- this.exitMenuItem.Click += new System.EventHandler(this.exitClick);
- //
- // viewMenuItem
- //
- this.viewMenuItem.Index = 1;
- this.viewMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.menuItem5.Text = "Hardware";
+ //
+ // mainboardMenuItem
+ //
+ this.mainboardMenuItem.Index = 0;
+ this.mainboardMenuItem.Text = "Mainboard";
+ //
+ // cpuMenuItem
+ //
+ this.cpuMenuItem.Index = 1;
+ this.cpuMenuItem.Text = "CPU";
+ //
+ // ramMenuItem
+ //
+ this.ramMenuItem.Index = 2;
+ this.ramMenuItem.Text = "RAM";
+ //
+ // gpuMenuItem
+ //
+ this.gpuMenuItem.Index = 3;
+ this.gpuMenuItem.Text = "GPU";
+ //
+ // fanControllerMenuItem
+ //
+ this.fanControllerMenuItem.Index = 4;
+ this.fanControllerMenuItem.Text = "Fan Controllers";
+ //
+ // hddMenuItem
+ //
+ this.hddMenuItem.Index = 5;
+ this.hddMenuItem.Text = "Hard Disk Drives";
+ //
+ // nicMenuItem
+ //
+ this.nicMenuItem.Index = 6;
+ this.nicMenuItem.Text = "Network";
+ //
+ // menuItem6
+ //
+ this.menuItem6.Index = 4;
+ this.menuItem6.Text = "-";
+ //
+ // exitMenuItem
+ //
+ this.exitMenuItem.Index = 5;
+ this.exitMenuItem.Text = "Exit";
+ this.exitMenuItem.Click += new System.EventHandler(this.ExitClick);
+ //
+ // viewMenuItem
+ //
+ this.viewMenuItem.Index = 1;
+ this.viewMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.resetMinMaxMenuItem,
this.MenuItem3,
this.hiddenMenuItem,
@@ -321,67 +314,67 @@ namespace OpenHardwareMonitor.GUI {
this.gadgetMenuItem,
this.MenuItem1,
this.columnsMenuItem});
- this.viewMenuItem.Text = "View";
- //
- // resetMinMaxMenuItem
- //
- this.resetMinMaxMenuItem.Index = 0;
- this.resetMinMaxMenuItem.Text = "Reset Min/Max";
- this.resetMinMaxMenuItem.Click += new System.EventHandler(this.resetMinMaxMenuItem_Click);
- //
- // MenuItem3
- //
- this.MenuItem3.Index = 1;
- this.MenuItem3.Text = "-";
- //
- // hiddenMenuItem
- //
- this.hiddenMenuItem.Index = 2;
- this.hiddenMenuItem.Text = "Show Hidden Sensors";
- //
- // plotMenuItem
- //
- this.plotMenuItem.Index = 3;
- this.plotMenuItem.Text = "Show Plot";
- //
- // gadgetMenuItem
- //
- this.gadgetMenuItem.Index = 4;
- this.gadgetMenuItem.Text = "Show Gadget";
- //
- // MenuItem1
- //
- this.MenuItem1.Index = 5;
- this.MenuItem1.Text = "-";
- //
- // columnsMenuItem
- //
- this.columnsMenuItem.Index = 6;
- this.columnsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.viewMenuItem.Text = "View";
+ //
+ // resetMinMaxMenuItem
+ //
+ this.resetMinMaxMenuItem.Index = 0;
+ this.resetMinMaxMenuItem.Text = "Reset Min/Max";
+ this.resetMinMaxMenuItem.Click += new System.EventHandler(this.ResetMinMaxMenuItem_Click);
+ //
+ // MenuItem3
+ //
+ this.MenuItem3.Index = 1;
+ this.MenuItem3.Text = "-";
+ //
+ // hiddenMenuItem
+ //
+ this.hiddenMenuItem.Index = 2;
+ this.hiddenMenuItem.Text = "Show Hidden Sensors";
+ //
+ // plotMenuItem
+ //
+ this.plotMenuItem.Index = 3;
+ this.plotMenuItem.Text = "Show Plot";
+ //
+ // gadgetMenuItem
+ //
+ this.gadgetMenuItem.Index = 4;
+ this.gadgetMenuItem.Text = "Show Gadget";
+ //
+ // MenuItem1
+ //
+ this.MenuItem1.Index = 5;
+ this.MenuItem1.Text = "-";
+ //
+ // columnsMenuItem
+ //
+ this.columnsMenuItem.Index = 6;
+ this.columnsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.valueMenuItem,
this.minMenuItem,
this.maxMenuItem});
- this.columnsMenuItem.Text = "Columns";
- //
- // valueMenuItem
- //
- this.valueMenuItem.Index = 0;
- this.valueMenuItem.Text = "Value";
- //
- // minMenuItem
- //
- this.minMenuItem.Index = 1;
- this.minMenuItem.Text = "Min";
- //
- // maxMenuItem
- //
- this.maxMenuItem.Index = 2;
- this.maxMenuItem.Text = "Max";
- //
- // optionsMenuItem
- //
- this.optionsMenuItem.Index = 2;
- this.optionsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.columnsMenuItem.Text = "Columns";
+ //
+ // valueMenuItem
+ //
+ this.valueMenuItem.Index = 0;
+ this.valueMenuItem.Text = "Value";
+ //
+ // minMenuItem
+ //
+ this.minMenuItem.Index = 1;
+ this.minMenuItem.Text = "Min";
+ //
+ // maxMenuItem
+ //
+ this.maxMenuItem.Index = 2;
+ this.maxMenuItem.Text = "Max";
+ //
+ // optionsMenuItem
+ //
+ this.optionsMenuItem.Index = 2;
+ this.optionsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.startMinMenuItem,
this.minTrayMenuItem,
this.minCloseMenuItem,
@@ -395,201 +388,96 @@ namespace OpenHardwareMonitor.GUI {
this.sensorValuesTimeWindowMenuItem,
this.webMenuItemSeparator,
this.webMenuItem});
- this.optionsMenuItem.Text = "Options";
- //
- // startMinMenuItem
- //
- this.startMinMenuItem.Index = 0;
- this.startMinMenuItem.Text = "Start Minimized";
- //
- // minTrayMenuItem
- //
- this.minTrayMenuItem.Index = 1;
- this.minTrayMenuItem.Text = "Minimize To Tray";
- //
- // minCloseMenuItem
- //
- this.minCloseMenuItem.Index = 2;
- this.minCloseMenuItem.Text = "Minimize On Close";
- //
- // startupMenuItem
- //
- this.startupMenuItem.Index = 3;
- this.startupMenuItem.Text = "Run On Windows Startup";
- //
- // separatorMenuItem
- //
- this.separatorMenuItem.Index = 4;
- this.separatorMenuItem.Text = "-";
- //
- // temperatureUnitsMenuItem
- //
- this.temperatureUnitsMenuItem.Index = 5;
- this.temperatureUnitsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.optionsMenuItem.Text = "Options";
+ //
+ // startMinMenuItem
+ //
+ this.startMinMenuItem.Index = 0;
+ this.startMinMenuItem.Text = "Start Minimized";
+ //
+ // minTrayMenuItem
+ //
+ this.minTrayMenuItem.Index = 1;
+ this.minTrayMenuItem.Text = "Minimize To Tray";
+ //
+ // minCloseMenuItem
+ //
+ this.minCloseMenuItem.Index = 2;
+ this.minCloseMenuItem.Text = "Minimize On Close";
+ //
+ // startupMenuItem
+ //
+ this.startupMenuItem.Index = 3;
+ this.startupMenuItem.Text = "Run On Windows Startup";
+ //
+ // separatorMenuItem
+ //
+ this.separatorMenuItem.Index = 4;
+ this.separatorMenuItem.Text = "-";
+ //
+ // temperatureUnitsMenuItem
+ //
+ this.temperatureUnitsMenuItem.Index = 5;
+ this.temperatureUnitsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.celsiusMenuItem,
this.fahrenheitMenuItem});
- this.temperatureUnitsMenuItem.Text = "Temperature Unit";
- //
- // celsiusMenuItem
- //
- this.celsiusMenuItem.Index = 0;
- this.celsiusMenuItem.RadioCheck = true;
- this.celsiusMenuItem.Text = "Celsius";
- this.celsiusMenuItem.Click += new System.EventHandler(this.celsiusMenuItem_Click);
- //
- // fahrenheitMenuItem
- //
- this.fahrenheitMenuItem.Index = 1;
- this.fahrenheitMenuItem.RadioCheck = true;
- this.fahrenheitMenuItem.Text = "Fahrenheit";
- this.fahrenheitMenuItem.Click += new System.EventHandler(this.fahrenheitMenuItem_Click);
- //
- // plotLocationMenuItem
- //
- this.plotLocationMenuItem.Index = 6;
- this.plotLocationMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.temperatureUnitsMenuItem.Text = "Temperature Unit";
+ //
+ // celsiusMenuItem
+ //
+ this.celsiusMenuItem.Index = 0;
+ this.celsiusMenuItem.RadioCheck = true;
+ this.celsiusMenuItem.Text = "Celsius";
+ this.celsiusMenuItem.Click += new System.EventHandler(this.CelsiusMenuItem_Click);
+ //
+ // fahrenheitMenuItem
+ //
+ this.fahrenheitMenuItem.Index = 1;
+ this.fahrenheitMenuItem.RadioCheck = true;
+ this.fahrenheitMenuItem.Text = "Fahrenheit";
+ this.fahrenheitMenuItem.Click += new System.EventHandler(this.FahrenheitMenuItem_Click);
+ //
+ // plotLocationMenuItem
+ //
+ this.plotLocationMenuItem.Index = 6;
+ this.plotLocationMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.plotWindowMenuItem,
this.plotBottomMenuItem,
this.plotRightMenuItem});
- this.plotLocationMenuItem.Text = "Plot Location";
- //
- // plotWindowMenuItem
- //
- this.plotWindowMenuItem.Index = 0;
- this.plotWindowMenuItem.RadioCheck = true;
- this.plotWindowMenuItem.Text = "Window";
- //
- // plotBottomMenuItem
- //
- this.plotBottomMenuItem.Index = 1;
- this.plotBottomMenuItem.RadioCheck = true;
- this.plotBottomMenuItem.Text = "Bottom";
- //
- // plotRightMenuItem
- //
- this.plotRightMenuItem.Index = 2;
- this.plotRightMenuItem.RadioCheck = true;
- this.plotRightMenuItem.Text = "Right";
- //
- // webMenuItemSeparator
- //
- this.webMenuItemSeparator.Index = 11;
- this.webMenuItemSeparator.Text = "-";
- //
- // webMenuItem
- //
- this.webMenuItem.Index = 12;
- this.webMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.runWebServerMenuItem,
- this.serverPortMenuItem});
- this.webMenuItem.Text = "Remote Web Server";
- //
- // runWebServerMenuItem
- //
- this.runWebServerMenuItem.Index = 0;
- this.runWebServerMenuItem.Text = "Run";
- //
- // serverPortMenuItem
- //
- this.serverPortMenuItem.Index = 1;
- this.serverPortMenuItem.Text = "Port";
- this.serverPortMenuItem.Click += new System.EventHandler(this.serverPortMenuItem_Click);
- //
- // logSensorsMenuItem
- //
- this.logSensorsMenuItem.Index = 8;
- this.logSensorsMenuItem.Text = "Log Sensors";
- //
- // helpMenuItem
- //
- this.helpMenuItem.Index = 3;
- this.helpMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.aboutMenuItem});
- this.helpMenuItem.Text = "Help";
- //
- // aboutMenuItem
- //
- this.aboutMenuItem.Index = 0;
- this.aboutMenuItem.Text = "About";
- this.aboutMenuItem.Click += new System.EventHandler(this.aboutMenuItem_Click);
- //
- // saveFileDialog
- //
- this.saveFileDialog.DefaultExt = "txt";
- this.saveFileDialog.FileName = "OpenHardwareMonitor.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.Border3DStyle = System.Windows.Forms.Border3DStyle.Raised;
- this.splitContainer.Color = System.Drawing.SystemColors.Control;
- this.splitContainer.Cursor = System.Windows.Forms.Cursors.Default;
- this.splitContainer.Location = new System.Drawing.Point(12, 12);
- this.splitContainer.Name = "splitContainer";
- this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
- //
- // splitContainer.Panel1
- //
- this.splitContainer.Panel1.Controls.Add(this.treeView);
- //
- // splitContainer.Panel2
- //
- this.splitContainer.Panel2.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);
- //
- // logSeparatorMenuItem
- //
- this.logSeparatorMenuItem.Index = 7;
- this.logSeparatorMenuItem.Text = "-";
- //
- // loggingIntervalMenuItem
- //
- this.loggingIntervalMenuItem.Index = 9;
- this.loggingIntervalMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.plotLocationMenuItem.Text = "Plot Location";
+ //
+ // plotWindowMenuItem
+ //
+ this.plotWindowMenuItem.Index = 0;
+ this.plotWindowMenuItem.RadioCheck = true;
+ this.plotWindowMenuItem.Text = "Window";
+ //
+ // plotBottomMenuItem
+ //
+ this.plotBottomMenuItem.Index = 1;
+ this.plotBottomMenuItem.RadioCheck = true;
+ this.plotBottomMenuItem.Text = "Bottom";
+ //
+ // plotRightMenuItem
+ //
+ this.plotRightMenuItem.Index = 2;
+ this.plotRightMenuItem.RadioCheck = true;
+ this.plotRightMenuItem.Text = "Right";
+ //
+ // logSeparatorMenuItem
+ //
+ this.logSeparatorMenuItem.Index = 7;
+ this.logSeparatorMenuItem.Text = "-";
+ //
+ // logSensorsMenuItem
+ //
+ this.logSensorsMenuItem.Index = 8;
+ this.logSensorsMenuItem.Text = "Log Sensors";
+ //
+ // loggingIntervalMenuItem
+ //
+ this.loggingIntervalMenuItem.Index = 9;
+ this.loggingIntervalMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.log1sMenuItem,
this.log2sMenuItem,
this.log5sMenuItem,
@@ -603,188 +491,293 @@ namespace OpenHardwareMonitor.GUI {
this.log1hMenuItem,
this.log2hMenuItem,
this.log6hMenuItem});
- this.loggingIntervalMenuItem.Text = "Logging Interval";
- //
- // log1sMenuItem
- //
- this.log1sMenuItem.Index = 0;
- this.log1sMenuItem.RadioCheck = true;
- this.log1sMenuItem.Text = "1s";
- //
- // log5sMenuItem
- //
- this.log5sMenuItem.Index = 2;
- this.log5sMenuItem.RadioCheck = true;
- this.log5sMenuItem.Text = "5s";
- //
- // log10sMenuItem
- //
- this.log10sMenuItem.Index = 3;
- this.log10sMenuItem.RadioCheck = true;
- this.log10sMenuItem.Text = "10s";
- //
- // log30sMenuItem
- //
- this.log30sMenuItem.Index = 4;
- this.log30sMenuItem.RadioCheck = true;
- this.log30sMenuItem.Text = "30s";
- //
- // log1minMenuItem
- //
- this.log1minMenuItem.Index = 5;
- this.log1minMenuItem.RadioCheck = true;
- this.log1minMenuItem.Text = "1min";
- //
- // log5minMenuItem
- //
- this.log5minMenuItem.Index = 7;
- this.log5minMenuItem.RadioCheck = true;
- this.log5minMenuItem.Text = "5min";
- //
- // log10minMenuItem
- //
- this.log10minMenuItem.Index = 8;
- this.log10minMenuItem.RadioCheck = true;
- this.log10minMenuItem.Text = "10min";
- //
- // log30minMenuItem
- //
- this.log30minMenuItem.Index = 9;
- this.log30minMenuItem.RadioCheck = true;
- this.log30minMenuItem.Text = "30min";
- //
- // log2sMenuItem
- //
- this.log2sMenuItem.Index = 1;
- this.log2sMenuItem.RadioCheck = true;
- this.log2sMenuItem.Text = "2s";
- //
- // log2minMenuItem
- //
- this.log2minMenuItem.Index = 6;
- this.log2minMenuItem.RadioCheck = true;
- this.log2minMenuItem.Text = "2min";
- //
- // log1hMenuItem
- //
- this.log1hMenuItem.Index = 10;
- this.log1hMenuItem.RadioCheck = true;
- this.log1hMenuItem.Text = "1h";
- //
- // log2hMenuItem
- //
- this.log2hMenuItem.Index = 11;
- this.log2hMenuItem.RadioCheck = true;
- this.log2hMenuItem.Text = "2h";
- //
- // log6hMenuItem
- //
- this.log6hMenuItem.Index = 12;
- this.log6hMenuItem.RadioCheck = true;
- this.log6hMenuItem.Text = "6h";
- //
- //
- // sensorValuesTimeWindowMenuItem
- //
- this.sensorValuesTimeWindowMenuItem.Index = 10;
- this.sensorValuesTimeWindowMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.timeWindow30sMenuItem,
- this.timeWindow1minMenuItem,
- this.timeWindow2minMenuItem,
- this.timeWindow5minMenuItem,
- this.timeWindow10minMenuItem,
- this.timeWindow30minMenuItem,
- this.timeWindow1hMenuItem,
- this.timeWindow2hMenuItem,
- this.timeWindow6hMenuItem,
- this.timeWindow12hMenuItem,
- this.timeWindow24hMenuItem});
- this.sensorValuesTimeWindowMenuItem.Text = "Sensor Values Time Window";
- //
- // timeWindow30sMenuItem
- //
- this.timeWindow30sMenuItem.Index = 0;
- this.timeWindow30sMenuItem.RadioCheck = true;
- this.timeWindow30sMenuItem.Text = "30s";
- //
- // timeWindow2minMenuItem
- //
- this.timeWindow2minMenuItem.Index = 2;
- this.timeWindow2minMenuItem.RadioCheck = true;
- this.timeWindow2minMenuItem.Text = "2min";
- //
- // timeWindow5minMenuItem
- //
- this.timeWindow5minMenuItem.Index = 3;
- this.timeWindow5minMenuItem.RadioCheck = true;
- this.timeWindow5minMenuItem.Text = "5min";
- //
- // timeWindow10minMenuItem
- //
- this.timeWindow10minMenuItem.Index = 4;
- this.timeWindow10minMenuItem.RadioCheck = true;
- this.timeWindow10minMenuItem.Text = "10min";
- //
- // timeWindow30minMenuItem
- //
- this.timeWindow30minMenuItem.Index = 5;
- this.timeWindow30minMenuItem.RadioCheck = true;
- this.timeWindow30minMenuItem.Text = "30min";
- //
- // timeWindow1hMenuItem
- //
- this.timeWindow1hMenuItem.Index = 6;
- this.timeWindow1hMenuItem.RadioCheck = true;
- this.timeWindow1hMenuItem.Text = "1h";
- //
- // timeWindow2hMenuItem
- //
- this.timeWindow2hMenuItem.Index = 7;
- this.timeWindow2hMenuItem.RadioCheck = true;
- this.timeWindow2hMenuItem.Text = "2n";
- //
- // timeWindow6hMenuItem
- //
- this.timeWindow6hMenuItem.Index = 8;
- this.timeWindow6hMenuItem.RadioCheck = true;
- this.timeWindow6hMenuItem.Text = "6h";
- //
- // timeWindow12hMenuItem
- //
- this.timeWindow12hMenuItem.Index = 9;
- this.timeWindow12hMenuItem.RadioCheck = true;
- this.timeWindow12hMenuItem.Text = "12h";
- //
- // timeWindow24hMenuItem
- //
- this.timeWindow24hMenuItem.Index = 10;
- this.timeWindow24hMenuItem.RadioCheck = true;
- this.timeWindow24hMenuItem.Text = "24h";
- //
- // timeWindow1minMenuItem
- //
- this.timeWindow1minMenuItem.Index = 1;
- this.timeWindow1minMenuItem.RadioCheck = true;
- this.timeWindow1minMenuItem.Text = "1min";
- //
- // MainForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(418, 554);
- this.Controls.Add(this.splitContainer);
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Menu = this.mainMenu;
- this.Name = "MainForm";
- this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
- this.Text = "Open Hardware Monitor";
- this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
- 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.splitContainer.Panel1.ResumeLayout(false);
- this.splitContainer.ResumeLayout(false);
- this.ResumeLayout(false);
+ this.loggingIntervalMenuItem.Text = "Logging Interval";
+ //
+ // log1sMenuItem
+ //
+ this.log1sMenuItem.Index = 0;
+ this.log1sMenuItem.RadioCheck = true;
+ this.log1sMenuItem.Text = "1s";
+ //
+ // log2sMenuItem
+ //
+ this.log2sMenuItem.Index = 1;
+ this.log2sMenuItem.RadioCheck = true;
+ this.log2sMenuItem.Text = "2s";
+ //
+ // log5sMenuItem
+ //
+ this.log5sMenuItem.Index = 2;
+ this.log5sMenuItem.RadioCheck = true;
+ this.log5sMenuItem.Text = "5s";
+ //
+ // log10sMenuItem
+ //
+ this.log10sMenuItem.Index = 3;
+ this.log10sMenuItem.RadioCheck = true;
+ this.log10sMenuItem.Text = "10s";
+ //
+ // log30sMenuItem
+ //
+ this.log30sMenuItem.Index = 4;
+ this.log30sMenuItem.RadioCheck = true;
+ this.log30sMenuItem.Text = "30s";
+ //
+ // log1minMenuItem
+ //
+ this.log1minMenuItem.Index = 5;
+ this.log1minMenuItem.RadioCheck = true;
+ this.log1minMenuItem.Text = "1min";
+ //
+ // log2minMenuItem
+ //
+ this.log2minMenuItem.Index = 6;
+ this.log2minMenuItem.RadioCheck = true;
+ this.log2minMenuItem.Text = "2min";
+ //
+ // log5minMenuItem
+ //
+ this.log5minMenuItem.Index = 7;
+ this.log5minMenuItem.RadioCheck = true;
+ this.log5minMenuItem.Text = "5min";
+ //
+ // log10minMenuItem
+ //
+ this.log10minMenuItem.Index = 8;
+ this.log10minMenuItem.RadioCheck = true;
+ this.log10minMenuItem.Text = "10min";
+ //
+ // log30minMenuItem
+ //
+ this.log30minMenuItem.Index = 9;
+ this.log30minMenuItem.RadioCheck = true;
+ this.log30minMenuItem.Text = "30min";
+ //
+ // log1hMenuItem
+ //
+ this.log1hMenuItem.Index = 10;
+ this.log1hMenuItem.RadioCheck = true;
+ this.log1hMenuItem.Text = "1h";
+ //
+ // log2hMenuItem
+ //
+ this.log2hMenuItem.Index = 11;
+ this.log2hMenuItem.RadioCheck = true;
+ this.log2hMenuItem.Text = "2h";
+ //
+ // log6hMenuItem
+ //
+ this.log6hMenuItem.Index = 12;
+ this.log6hMenuItem.RadioCheck = true;
+ this.log6hMenuItem.Text = "6h";
+ //
+ // sensorValuesTimeWindowMenuItem
+ //
+ this.sensorValuesTimeWindowMenuItem.Index = 10;
+ this.sensorValuesTimeWindowMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.timeWindow30sMenuItem,
+ this.timeWindow1minMenuItem,
+ this.timeWindow2minMenuItem,
+ this.timeWindow5minMenuItem,
+ this.timeWindow10minMenuItem,
+ this.timeWindow30minMenuItem,
+ this.timeWindow1hMenuItem,
+ this.timeWindow2hMenuItem,
+ this.timeWindow6hMenuItem,
+ this.timeWindow12hMenuItem,
+ this.timeWindow24hMenuItem});
+ this.sensorValuesTimeWindowMenuItem.Text = "Sensor Values Time Window";
+ //
+ // timeWindow30sMenuItem
+ //
+ this.timeWindow30sMenuItem.Index = 0;
+ this.timeWindow30sMenuItem.RadioCheck = true;
+ this.timeWindow30sMenuItem.Text = "30s";
+ //
+ // timeWindow1minMenuItem
+ //
+ this.timeWindow1minMenuItem.Index = 1;
+ this.timeWindow1minMenuItem.RadioCheck = true;
+ this.timeWindow1minMenuItem.Text = "1min";
+ //
+ // timeWindow2minMenuItem
+ //
+ this.timeWindow2minMenuItem.Index = 2;
+ this.timeWindow2minMenuItem.RadioCheck = true;
+ this.timeWindow2minMenuItem.Text = "2min";
+ //
+ // timeWindow5minMenuItem
+ //
+ this.timeWindow5minMenuItem.Index = 3;
+ this.timeWindow5minMenuItem.RadioCheck = true;
+ this.timeWindow5minMenuItem.Text = "5min";
+ //
+ // timeWindow10minMenuItem
+ //
+ this.timeWindow10minMenuItem.Index = 4;
+ this.timeWindow10minMenuItem.RadioCheck = true;
+ this.timeWindow10minMenuItem.Text = "10min";
+ //
+ // timeWindow30minMenuItem
+ //
+ this.timeWindow30minMenuItem.Index = 5;
+ this.timeWindow30minMenuItem.RadioCheck = true;
+ this.timeWindow30minMenuItem.Text = "30min";
+ //
+ // timeWindow1hMenuItem
+ //
+ this.timeWindow1hMenuItem.Index = 6;
+ this.timeWindow1hMenuItem.RadioCheck = true;
+ this.timeWindow1hMenuItem.Text = "1h";
+ //
+ // timeWindow2hMenuItem
+ //
+ this.timeWindow2hMenuItem.Index = 7;
+ this.timeWindow2hMenuItem.RadioCheck = true;
+ this.timeWindow2hMenuItem.Text = "2n";
+ //
+ // timeWindow6hMenuItem
+ //
+ this.timeWindow6hMenuItem.Index = 8;
+ this.timeWindow6hMenuItem.RadioCheck = true;
+ this.timeWindow6hMenuItem.Text = "6h";
+ //
+ // timeWindow12hMenuItem
+ //
+ this.timeWindow12hMenuItem.Index = 9;
+ this.timeWindow12hMenuItem.RadioCheck = true;
+ this.timeWindow12hMenuItem.Text = "12h";
+ //
+ // timeWindow24hMenuItem
+ //
+ this.timeWindow24hMenuItem.Index = 10;
+ this.timeWindow24hMenuItem.RadioCheck = true;
+ this.timeWindow24hMenuItem.Text = "24h";
+ //
+ // webMenuItemSeparator
+ //
+ this.webMenuItemSeparator.Index = 11;
+ this.webMenuItemSeparator.Text = "-";
+ //
+ // webMenuItem
+ //
+ this.webMenuItem.Index = 12;
+ this.webMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.runWebServerMenuItem,
+ this.serverPortMenuItem});
+ this.webMenuItem.Text = "Remote Web Server";
+ //
+ // runWebServerMenuItem
+ //
+ this.runWebServerMenuItem.Index = 0;
+ this.runWebServerMenuItem.Text = "Run";
+ //
+ // serverPortMenuItem
+ //
+ this.serverPortMenuItem.Index = 1;
+ this.serverPortMenuItem.Text = "Port";
+ this.serverPortMenuItem.Click += new System.EventHandler(this.ServerPortMenuItem_Click);
+ //
+ // helpMenuItem
+ //
+ this.helpMenuItem.Index = 3;
+ this.helpMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.aboutMenuItem});
+ this.helpMenuItem.Text = "Help";
+ //
+ // aboutMenuItem
+ //
+ this.aboutMenuItem.Index = 0;
+ this.aboutMenuItem.Text = "About";
+ this.aboutMenuItem.Click += new System.EventHandler(this.AboutMenuItem_Click);
+ //
+ // saveFileDialog
+ //
+ this.saveFileDialog.DefaultExt = "txt";
+ this.saveFileDialog.FileName = "OpenHardwareMonitor.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.Border3DStyle = System.Windows.Forms.Border3DStyle.Raised;
+ this.splitContainer.Color = System.Drawing.SystemColors.Control;
+ this.splitContainer.Cursor = System.Windows.Forms.Cursors.Default;
+ this.splitContainer.Location = new System.Drawing.Point(12, 12);
+ this.splitContainer.Name = "splitContainer";
+ this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
+ //
+ // splitContainer.Panel1
+ //
+ this.splitContainer.Panel1.Controls.Add(this.treeView);
+ //
+ // splitContainer.Panel2
+ //
+ this.splitContainer.Panel2.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);
+ //
+ // 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.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.Menu = this.mainMenu;
+ this.Name = "MainForm";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
+ this.Text = "Libre Hardware Monitor";
+ this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
+ 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.splitContainer.Panel1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
+ this.splitContainer.ResumeLayout(false);
+ this.ResumeLayout(false);
}
@@ -829,7 +822,6 @@ namespace OpenHardwareMonitor.GUI {
private System.Windows.Forms.MenuItem webMenuItemSeparator;
private System.Windows.Forms.MenuItem celsiusMenuItem;
private System.Windows.Forms.MenuItem fahrenheitMenuItem;
- private System.Windows.Forms.MenuItem sumbitReportMenuItem;
private System.Windows.Forms.MenuItem MenuItem2;
private System.Windows.Forms.MenuItem resetMinMaxMenuItem;
private System.Windows.Forms.MenuItem MenuItem3;
diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs
index af993ff..47d5db4 100644
--- a/GUI/MainForm.cs
+++ b/GUI/MainForm.cs
@@ -1,14 +1,7 @@
-/*
-
- 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) 2009-2013 Michael Möller
- Copyright (C) 2010 Paul Werelds
- Copyright (C) 2012 Prince Samuel
-
-*/
+// Mozilla Public License 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 System;
using System.Collections.Generic;
@@ -24,937 +17,974 @@ using OpenHardwareMonitor.Hardware;
using OpenHardwareMonitor.WMI;
using OpenHardwareMonitor.Utilities;
-namespace OpenHardwareMonitor.GUI {
- public partial class MainForm : Form {
+namespace OpenHardwareMonitor.GUI
+{
+ public sealed partial class MainForm : Form
+ {
+ private int _delayCount;
+ private readonly PersistentSettings _settings;
+ private readonly UnitManager _unitManager;
+ private readonly Computer _computer;
+ private readonly Node _root;
+ private IDictionary _sensorPlotColors = new Dictionary();
+ private readonly Color[] _plotColorPalette;
+ private readonly SystemTray _systemTray;
+ private readonly StartupManager _startupManager = new StartupManager();
+ private readonly UpdateVisitor _updateVisitor = new UpdateVisitor();
+ private readonly SensorGadget _gadget;
+ private Form _plotForm;
+ private readonly PlotPanel _plotPanel;
- private PersistentSettings settings;
- private UnitManager unitManager;
- private Computer computer;
- private Node root;
- private TreeModel treeModel;
- private IDictionary sensorPlotColors =
- new Dictionary();
- private Color[] plotColorPalette;
- private SystemTray systemTray;
- private StartupManager startupManager = new StartupManager();
- private UpdateVisitor updateVisitor = new UpdateVisitor();
- private SensorGadget gadget;
- private Form plotForm;
- private PlotPanel plotPanel;
+ private UserOption _showPlot;
+ private readonly UserOption _minimizeToTray;
+ private readonly UserOption _minimizeOnClose;
+ private readonly UserOption _autoStart;
- private UserOption showHiddenSensors;
- private UserOption showPlot;
- private UserOption showValue;
- private UserOption showMin;
- private UserOption showMax;
- private UserOption startMinimized;
- private UserOption minimizeToTray;
- private UserOption minimizeOnClose;
- private UserOption autoStart;
+ private readonly UserOption _readMainboardSensors;
+ private readonly UserOption _readCpuSensors;
+ private readonly UserOption _readRamSensors;
+ private readonly UserOption _readGpuSensors;
+ private readonly UserOption _readFanControllersSensors;
+ private readonly UserOption _readHddSensors;
+ private readonly UserOption _readNicSensors;
- private UserOption readMainboardSensors;
- private UserOption readCpuSensors;
- private UserOption readRamSensors;
- private UserOption readGpuSensors;
- private UserOption readFanControllersSensors;
- private UserOption readHddSensors;
- private UserOption readNicSensors;
+ private readonly UserOption _showGadget;
+ private UserRadioGroup _plotLocation;
+ private readonly WmiProvider _wmiProvider;
- private UserOption showGadget;
- private UserRadioGroup plotLocation;
- private WmiProvider wmiProvider;
+ private readonly UserOption _runWebServer;
+ private readonly UserOption _logSensors;
+ private readonly UserRadioGroup _loggingInterval;
+ private readonly UserRadioGroup _sensorValuesTimeWindow;
+ private readonly Logger _logger;
- private UserOption runWebServer;
- private HttpServer server;
+ private bool _selectionDragging;
- private UserOption logSensors;
- private UserRadioGroup loggingInterval;
- private UserRadioGroup sensorValuesTimeWindow;
- private Logger logger;
+ public MainForm()
+ {
+ InitializeComponent();
- private bool selectionDragging = false;
+ // check if the OpenHardwareMonitorLib assembly has the correct version
+ if (Assembly.GetAssembly(typeof(Computer)).GetName().Version != Assembly.GetExecutingAssembly().GetName().Version)
+ {
+ MessageBox.Show("The version of the file OpenHardwareMonitorLib.dll is incompatible.",
+ "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ Environment.Exit(0);
+ }
- public MainForm() {
- InitializeComponent();
+ _settings = new PersistentSettings();
+ _settings.Load(Path.ChangeExtension(Application.ExecutablePath, ".config"));
- // check if the OpenHardwareMonitorLib assembly has the correct version
- if (Assembly.GetAssembly(typeof(Computer)).GetName().Version !=
- Assembly.GetExecutingAssembly().GetName().Version) {
- MessageBox.Show(
- "The version of the file OpenHardwareMonitorLib.dll is incompatible.",
- "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- Environment.Exit(0);
- }
+ _unitManager = new UnitManager(_settings);
- this.settings = new PersistentSettings();
- this.settings.Load(Path.ChangeExtension(
- Application.ExecutablePath, ".config"));
+ // make sure the buffers used for double buffering are not disposed
+ // after each draw call
+ BufferedGraphicsManager.Current.MaximumBuffer = Screen.PrimaryScreen.Bounds.Size;
- this.unitManager = new UnitManager(settings);
+ // set the DockStyle here, to avoid conflicts with the MainMenu
+ splitContainer.Dock = DockStyle.Fill;
- // make sure the buffers used for double buffering are not disposed
- // after each draw call
- BufferedGraphicsManager.Current.MaximumBuffer =
- Screen.PrimaryScreen.Bounds.Size;
+ Font = SystemFonts.MessageBoxFont;
+ treeView.Font = SystemFonts.MessageBoxFont;
- // set the DockStyle here, to avoid conflicts with the MainMenu
- this.splitContainer.Dock = DockStyle.Fill;
+ // 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)
+ };
+
+ _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;
+
+ foreach (TreeColumn column in treeView.Columns)
+ column.Width = Math.Max(20, Math.Min(400, _settings.GetValue("treeView.Columns." + column.Header + ".Width", column.Width)));
+
+ TreeModel treeModel = new TreeModel();
+ _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;
+
+ int p = (int)Environment.OSVersion.Platform;
+ if ((p == 4) || (p == 128))
+ { // Unix
+ treeView.RowHeight = Math.Max(treeView.RowHeight, 18);
+ splitContainer.BorderStyle = BorderStyle.None;
+ splitContainer.Border3DStyle = Border3DStyle.Adjust;
+ 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;
+ _wmiProvider = new WmiProvider(_computer);
+ }
+
+ _logger = new Logger(_computer);
+
+ _plotColorPalette = new Color[13];
+ _plotColorPalette[0] = Color.Blue;
+ _plotColorPalette[1] = Color.OrangeRed;
+ _plotColorPalette[2] = Color.Green;
+ _plotColorPalette[3] = Color.LightSeaGreen;
+ _plotColorPalette[4] = Color.Goldenrod;
+ _plotColorPalette[5] = Color.DarkViolet;
+ _plotColorPalette[6] = Color.YellowGreen;
+ _plotColorPalette[7] = Color.SaddleBrown;
+ _plotColorPalette[8] = Color.RoyalBlue;
+ _plotColorPalette[9] = Color.DeepPink;
+ _plotColorPalette[10] = Color.MediumSeaGreen;
+ _plotColorPalette[11] = Color.Olive;
+ _plotColorPalette[12] = Color.Firebrick;
+
+ _computer.HardwareAdded += HardwareAdded;
+ _computer.HardwareRemoved += HardwareRemoved;
+ _computer.Open();
+
+ timer.Enabled = true;
+
+ UserOption showHiddenSensors = new UserOption("hiddenMenuItem", false, hiddenMenuItem, _settings);
+ showHiddenSensors.Changed += delegate
+ {
+ treeModel.ForceVisible = showHiddenSensors.Value;
+ };
+
+ UserOption showValue = new UserOption("valueMenuItem", true, valueMenuItem, _settings);
+ showValue.Changed += delegate
+ {
+ treeView.Columns[1].IsVisible = showValue.Value;
+ };
+
+ UserOption showMin = new UserOption("minMenuItem", false, minMenuItem, _settings);
+ showMin.Changed += delegate
+ {
+ treeView.Columns[2].IsVisible = showMin.Value;
+ };
+
+ UserOption showMax = new UserOption("maxMenuItem", true, maxMenuItem, _settings);
+ showMax.Changed += delegate
+ {
+ treeView.Columns[3].IsVisible = showMax.Value;
+ };
+
+ var _ = 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.MainboardEnabled = _readMainboardSensors.Value;
+ };
+
+ _readCpuSensors = new UserOption("cpuMenuItem", true, cpuMenuItem, _settings);
+ _readCpuSensors.Changed += delegate
+ {
+ _computer.CPUEnabled = _readCpuSensors.Value;
+ };
+
+ _readRamSensors = new UserOption("ramMenuItem", true, ramMenuItem, _settings);
+ _readRamSensors.Changed += delegate
+ {
+ _computer.RAMEnabled = _readRamSensors.Value;
+ };
+
+ _readGpuSensors = new UserOption("gpuMenuItem", true, gpuMenuItem, _settings);
+ _readGpuSensors.Changed += delegate
+ {
+ _computer.GPUEnabled = _readGpuSensors.Value;
+ };
+
+ _readFanControllersSensors = new UserOption("fanControllerMenuItem", true, fanControllerMenuItem, _settings);
+ _readFanControllersSensors.Changed += delegate
+ {
+ _computer.FanControllerEnabled = _readFanControllersSensors.Value;
+ };
+
+ _readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem, _settings);
+ _readHddSensors.Changed += delegate
+ {
+ _computer.HDDEnabled = _readHddSensors.Value;
+ };
+
+ _readNicSensors = new UserOption("nicMenuItem", true, nicMenuItem, _settings);
+ _readNicSensors.Changed += delegate
+ {
+ _computer.NICEnabled = _readNicSensors.Value;
+ };
+
+ _showGadget = new UserOption("gadgetMenuItem", false, gadgetMenuItem, _settings);
+ _showGadget.Changed += delegate
+ {
+ if (_gadget != null)
+ _gadget.Visible = _showGadget.Value;
+ };
+
+ celsiusMenuItem.Checked = _unitManager.TemperatureUnit == TemperatureUnit.Celsius;
+ fahrenheitMenuItem.Checked = !celsiusMenuItem.Checked;
+
+ Server = new HttpServer(_root, _settings.GetValue("listenerPort", 8085));
+ 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();
+ };
+
+ _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;
+ }
+ };
+
+ _sensorValuesTimeWindow = new UserRadioGroup("sensorValuesTimeWindow", 10,
+ new[] { timeWindow30sMenuItem, timeWindow1minMenuItem, timeWindow2minMenuItem,
+ timeWindow5minMenuItem, timeWindow10minMenuItem, timeWindow30minMenuItem,
+ timeWindow1hMenuItem, timeWindow2hMenuItem, timeWindow6hMenuItem,
+ timeWindow12hMenuItem, timeWindow24hMenuItem}, _settings);
+ _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;
+ }));
+ };
+
+ 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();
+ };
+ }
+
+ 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);
+
+ _showPlot.Changed += delegate
+ {
+ if (_plotLocation.Value == 0)
+ {
+ if (_showPlot.Value && Visible)
+ _plotForm.Show();
+ else
+ _plotForm.Hide();
+ }
+ else
+ {
+ splitContainer.Panel2Collapsed = !_showPlot.Value;
+ }
+ treeView.Invalidate();
+ };
+ _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;
+ }
+ };
+
+ _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);
+ }
+ }
- this.Font = SystemFonts.MessageBoxFont;
- treeView.Font = SystemFonts.MessageBoxFont;
+ _plotForm.Move += MoveOrResizePlotForm;
+ _plotForm.Resize += MoveOrResizePlotForm;
- // Set the bounds immediately, so that our child components can be
- // properly placed.
- this.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)
- };
+ _plotForm.VisibleChanged += delegate
+ {
+ Rectangle bounds = new Rectangle(_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);
+ }
+ };
- plotPanel = new PlotPanel(settings, unitManager);
- plotPanel.Font = SystemFonts.MessageBoxFont;
- plotPanel.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;
-
- foreach (TreeColumn column in treeView.Columns)
- column.Width = Math.Max(20, Math.Min(400,
- settings.GetValue("treeView.Columns." + column.Header + ".Width",
- column.Width)));
-
- treeModel = new TreeModel();
- root = new Node(System.Environment.MachineName);
- root.Image = Utilities.EmbeddedResources.GetImage("computer.png");
-
- treeModel.Nodes.Add(root);
- treeView.Model = treeModel;
-
- this.computer = new Computer(settings);
-
- systemTray = new SystemTray(computer, settings, unitManager);
- systemTray.HideShowCommand += hideShowClick;
- systemTray.ExitCommand += exitClick;
-
- int p = (int)Environment.OSVersion.Platform;
- if ((p == 4) || (p == 128)) { // Unix
- treeView.RowHeight = Math.Max(treeView.RowHeight, 18);
- splitContainer.BorderStyle = BorderStyle.None;
- splitContainer.Border3DStyle = Border3DStyle.Adjust;
- 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;
-
- wmiProvider = new WmiProvider(computer);
- }
-
- logger = new Logger(computer);
-
- plotColorPalette = new Color[13];
- plotColorPalette[0] = Color.Blue;
- plotColorPalette[1] = Color.OrangeRed;
- plotColorPalette[2] = Color.Green;
- plotColorPalette[3] = Color.LightSeaGreen;
- plotColorPalette[4] = Color.Goldenrod;
- plotColorPalette[5] = Color.DarkViolet;
- plotColorPalette[6] = Color.YellowGreen;
- plotColorPalette[7] = Color.SaddleBrown;
- plotColorPalette[8] = Color.RoyalBlue;
- plotColorPalette[9] = Color.DeepPink;
- plotColorPalette[10] = Color.MediumSeaGreen;
- plotColorPalette[11] = Color.Olive;
- plotColorPalette[12] = Color.Firebrick;
-
- computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
- computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
-
- computer.Open();
-
- timer.Enabled = true;
-
- showHiddenSensors = new UserOption("hiddenMenuItem", false,
- hiddenMenuItem, settings);
- showHiddenSensors.Changed += delegate(object sender, EventArgs e) {
- treeModel.ForceVisible = showHiddenSensors.Value;
- };
-
- showValue = new UserOption("valueMenuItem", true, valueMenuItem,
- settings);
- showValue.Changed += delegate(object sender, EventArgs e) {
- treeView.Columns[1].IsVisible = showValue.Value;
- };
-
- showMin = new UserOption("minMenuItem", false, minMenuItem, settings);
- showMin.Changed += delegate(object sender, EventArgs e) {
- treeView.Columns[2].IsVisible = showMin.Value;
- };
-
- showMax = new UserOption("maxMenuItem", true, maxMenuItem, settings);
- showMax.Changed += delegate(object sender, EventArgs e) {
- treeView.Columns[3].IsVisible = showMax.Value;
- };
-
- startMinimized = new UserOption("startMinMenuItem", false,
- startMinMenuItem, settings);
-
- minimizeToTray = new UserOption("minTrayMenuItem", true,
- minTrayMenuItem, settings);
- minimizeToTray.Changed += delegate(object sender, EventArgs e) {
- systemTray.IsMainIconEnabled = minimizeToTray.Value;
- };
-
- minimizeOnClose = new UserOption("minCloseMenuItem", false,
- minCloseMenuItem, settings);
-
- autoStart = new UserOption(null, startupManager.Startup,
- startupMenuItem, settings);
- autoStart.Changed += delegate(object sender, EventArgs e) {
- 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(object sender, EventArgs e) {
- computer.MainboardEnabled = readMainboardSensors.Value;
- };
-
- readCpuSensors = new UserOption("cpuMenuItem", true,
- cpuMenuItem, settings);
- readCpuSensors.Changed += delegate(object sender, EventArgs e) {
- computer.CPUEnabled = readCpuSensors.Value;
- };
-
- readRamSensors = new UserOption("ramMenuItem", true,
- ramMenuItem, settings);
- readRamSensors.Changed += delegate(object sender, EventArgs e) {
- computer.RAMEnabled = readRamSensors.Value;
- };
-
- readGpuSensors = new UserOption("gpuMenuItem", true,
- gpuMenuItem, settings);
- readGpuSensors.Changed += delegate(object sender, EventArgs e) {
- computer.GPUEnabled = readGpuSensors.Value;
- };
-
- readFanControllersSensors = new UserOption("fanControllerMenuItem", true,
- fanControllerMenuItem, settings);
- readFanControllersSensors.Changed += delegate(object sender, EventArgs e) {
- computer.FanControllerEnabled = readFanControllersSensors.Value;
- };
-
- readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem,
- settings);
- readHddSensors.Changed += delegate(object sender, EventArgs e) {
- computer.HDDEnabled = readHddSensors.Value;
- };
-
- readNicSensors = new UserOption("nicMenuItem", true, nicMenuItem,
- settings);
- readNicSensors.Changed += delegate(object sender, EventArgs e) {
- computer.NICEnabled = readNicSensors.Value;
- };
-
- showGadget = new UserOption("gadgetMenuItem", false, gadgetMenuItem,
- settings);
- showGadget.Changed += delegate(object sender, EventArgs e) {
- if (gadget != null)
- gadget.Visible = showGadget.Value;
- };
-
- celsiusMenuItem.Checked =
- unitManager.TemperatureUnit == TemperatureUnit.Celsius;
- fahrenheitMenuItem.Checked = !celsiusMenuItem.Checked;
-
- server = new HttpServer(root, this.settings.GetValue("listenerPort", 8085));
- if (server.PlatformNotSupported) {
- webMenuItemSeparator.Visible = false;
- webMenuItem.Visible = false;
- }
-
- runWebServer = new UserOption("runWebServerMenuItem", false,
- runWebServerMenuItem, settings);
- runWebServer.Changed += delegate(object sender, EventArgs e) {
- if (runWebServer.Value)
- server.StartHTTPListener();
- else
- server.StopHTTPListener();
- };
-
- 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;
- }
- };
-
- sensorValuesTimeWindow = new UserRadioGroup("sensorValuesTimeWindow", 10,
- new[] { timeWindow30sMenuItem, timeWindow1minMenuItem, timeWindow2minMenuItem,
- timeWindow5minMenuItem, timeWindow10minMenuItem, timeWindow30minMenuItem,
- timeWindow1hMenuItem, timeWindow2hMenuItem, timeWindow6hMenuItem,
- timeWindow12hMenuItem, timeWindow24hMenuItem},
- settings);
- 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;
+ VisibleChanged += delegate
+ {
+ if (Visible && _showPlot.Value && _plotLocation.Value == 0)
+ _plotForm.Show();
+ else
+ _plotForm.Hide();
+ };
}
- computer.Accept(new SensorVisitor(delegate(ISensor sensor) {
- sensor.ValuesTimeWindow = timeWindow;
- }));
- };
+ 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++;
- InitializePlotForm();
- InitializeSplitter();
-
- startupMenuItem.Visible = startupManager.IsAvailable;
-
- if (startMinMenuItem.Checked) {
- if (!minTrayMenuItem.Checked) {
- WindowState = FormWindowState.Minimized;
- Show();
+ nodes.Insert(i, node);
}
- } else {
- Show();
- }
- // Create a handle, otherwise calling Close() does not fire FormClosed
- IntPtr handle = Handle;
-
- // Make sure the settings are saved when the user logs off
- Microsoft.Win32.SystemEvents.SessionEnded += delegate {
- computer.Close();
- SaveConfiguration();
- if (runWebServer.Value)
- server.Quit();
- };
- }
-
- private void InitializeSplitter() {
- splitContainer.SplitterDistance = settings.GetValue("splitContainer.SplitterDistance", 400);
- splitContainer.SplitterMoved += delegate (object sender, System.Windows.Forms.SplitterEventArgs e) {
- settings.SetValue("splitContainer.SplitterDistance", splitContainer.SplitterDistance);
- };
- }
-
- private void InitializePlotForm() {
- plotForm = new Form();
- plotForm.FormBorderStyle = FormBorderStyle.SizableToolWindow;
- plotForm.ShowInTaskbar = false;
- plotForm.StartPosition = FormStartPosition.Manual;
- this.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);
-
- showPlot.Changed += delegate(object sender, EventArgs e) {
- if (plotLocation.Value == 0) {
- if (showPlot.Value && this.Visible)
- plotForm.Show();
- else
- plotForm.Hide();
- } else {
- splitContainer.Panel2Collapsed = !showPlot.Value;
+ private void SubHardwareAdded(IHardware hardware, Node node)
+ {
+ HardwareNode hardwareNode = new HardwareNode(hardware, _settings, _unitManager);
+ hardwareNode.PlotSelectionChanged += PlotSelectionChanged;
+ InsertSorted(node.Nodes, hardwareNode);
+ foreach (IHardware subHardware in hardware.SubHardware)
+ SubHardwareAdded(subHardware, hardwareNode);
}
- treeView.Invalidate();
- };
- plotLocation.Changed += delegate(object sender, EventArgs e) {
- switch (plotLocation.Value) {
- case 0:
- splitContainer.Panel2.Controls.Clear();
- splitContainer.Panel2Collapsed = true;
- plotForm.Controls.Add(plotPanel);
- if (showPlot.Value && this.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;
+
+ private void HardwareAdded(IHardware hardware)
+ {
+ SubHardwareAdded(hardware, _root);
+ PlotSelectionChanged(this, null);
}
- };
- 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;
- }
- };
-
- EventHandler moveOrResizePlotForm = delegate(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(object sender, EventArgs e) {
- Rectangle bounds = new Rectangle(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);
- }
- };
-
- this.VisibleChanged += delegate(object sender, EventArgs e) {
- if (this.Visible && showPlot.Value && plotLocation.Value == 0)
- plotForm.Show();
- else
- plotForm.Hide();
- };
- }
-
- private void InsertSorted(Collection 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 HardwareNode(hardware, settings, unitManager);
- hardwareNode.PlotSelectionChanged += PlotSelectionChanged;
-
- InsertSorted(node.Nodes, hardwareNode);
-
- foreach (IHardware subHardware in hardware.SubHardware)
- SubHardwareAdded(subHardware, hardwareNode);
- }
-
- private void HardwareAdded(IHardware hardware) {
- SubHardwareAdded(hardware, root);
- PlotSelectionChanged(this, null);
- }
-
- private void HardwareRemoved(IHardware hardware) {
- List nodesToRemove = new List();
- foreach (Node node in root.Nodes) {
- HardwareNode hardwareNode = node as HardwareNode;
- if (hardwareNode != null && 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) {
- Node node = e.Node.Tag as Node;
- if (node != null) {
- Color color;
- if (node.IsVisible) {
- SensorNode sensorNode = node as SensorNode;
- if (plotMenuItem.Checked && sensorNode != null &&
- sensorPlotColors.TryGetValue(sensorNode.Sensor, out color))
- e.TextColor = color;
- } else {
- e.TextColor = Color.DarkGray;
- }
- }
- }
-
- private void PlotSelectionChanged(object sender, EventArgs e) {
- List selected = new List();
- IDictionary colors = new Dictionary();
- int colorIndex = 0;
- foreach (TreeNodeAdv node in treeView.AllNodes) {
- SensorNode sensorNode = node.Tag as SensorNode;
- if (sensorNode != null) {
- if (sensorNode.Plot) {
- if (!sensorNode.PenColor.HasValue) {
- colors.Add(sensorNode.Sensor,
- plotColorPalette[colorIndex % plotColorPalette.Length]);
+ private void HardwareRemoved(IHardware hardware)
+ {
+ List nodesToRemove = new List();
+ foreach (Node node in _root.Nodes)
+ {
+ if (node is HardwareNode hardwareNode && hardwareNode.Hardware == hardware)
+ nodesToRemove.Add(hardwareNode);
}
- 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 (var curSelectedSensor in selected) {
- if (!colors.ContainsKey(curSelectedSensor)) continue;
- var curColor = colors[curSelectedSensor];
- if (usedColors.Contains(curColor)) {
- foreach (var potentialNewColor in plotColorPalette) {
- if (!colors.Values.Contains(potentialNewColor)) {
- colors[curSelectedSensor] = potentialNewColor;
- usedColors.Add(potentialNewColor);
- break;
+ foreach (HardwareNode hardwareNode in nodesToRemove)
+ {
+ _root.Nodes.Remove(hardwareNode);
+ hardwareNode.PlotSelectionChanged -= PlotSelectionChanged;
}
- }
- } else {
- usedColors.Add(curColor);
+ PlotSelectionChanged(this, null);
}
- }
- foreach (TreeNodeAdv node in treeView.AllNodes) {
- SensorNode sensorNode = node.Tag as SensorNode;
- if (sensorNode != null && sensorNode.Plot && sensorNode.PenColor.HasValue)
- colors.Add(sensorNode.Sensor, sensorNode.PenColor.Value);
- }
-
- sensorPlotColors = colors;
- plotPanel.SetSensors(selected, colors);
- }
-
- 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) {
- SensorNode node = e.Node.Tag as SensorNode;
- e.Value = (node != null) && plotMenuItem.Checked;
- }
-
- private void exitClick(object sender, EventArgs e) {
- Close();
- }
-
- private int delayCount = 0;
- private void timer_Tick(object sender, EventArgs e) {
- computer.Accept(updateVisitor);
- treeView.Invalidate();
- plotPanel.InvalidatePlot();
- systemTray.Redraw();
- if (gadget != null)
- gadget.Redraw();
-
- if (wmiProvider != null)
- wmiProvider.Update();
-
-
- if (logSensors != null && logSensors.Value && delayCount >= 4)
- logger.Log();
-
- if (delayCount < 4)
- delayCount++;
- }
-
- private void SaveConfiguration() {
- plotPanel.SetCurrentSettings();
- foreach (TreeColumn column in treeView.Columns)
- settings.SetValue("treeView.Columns." + column.Header + ".Width",
- column.Width);
-
- this.settings.SetValue("listenerPort", server.ListenerPort);
-
- string fileName = Path.ChangeExtension(
- System.Windows.Forms.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 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)
- };
-
- Rectangle fullWorkingArea = new Rectangle(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);
- }
-
- this.Bounds = newBounds;
- }
-
- private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
- Visible = false;
- systemTray.IsMainIconEnabled = false;
- timer.Enabled = false;
- computer.Close();
- SaveConfiguration();
- if (runWebServer.Value)
- server.Quit();
- systemTray.Dispose();
- }
-
- private void aboutMenuItem_Click(object sender, EventArgs e) {
- new AboutBox().ShowDialog();
- }
-
- private void treeView_Click(object sender, EventArgs e) {
-
- MouseEventArgs m = e as MouseEventArgs;
- if (m == null || m.Button != MouseButtons.Right)
- return;
-
- NodeControlInfo info = treeView.GetNodeControlInfoAt(
- new Point(m.X, m.Y)
- );
- treeView.SelectedNode = info.Node;
- if (info.Node != null) {
- SensorNode node = info.Node.Tag as SensorNode;
- if (node != null && node.Sensor != null) {
- treeContextMenu.MenuItems.Clear();
- if (node.Sensor.Parameters.Count > 0) {
- MenuItem item = new MenuItem("Parameters...");
- item.Click += delegate(object obj, EventArgs args) {
- ShowParameterForm(node.Sensor);
- };
- treeContextMenu.MenuItems.Add(item);
- }
- if (nodeTextBoxText.EditEnabled) {
- MenuItem item = new MenuItem("Rename");
- item.Click += delegate(object obj, EventArgs args) {
- nodeTextBoxText.BeginEdit();
- };
- treeContextMenu.MenuItems.Add(item);
- }
- if (node.IsVisible) {
- MenuItem item = new MenuItem("Hide");
- item.Click += delegate(object obj, EventArgs args) {
- node.IsVisible = false;
- };
- treeContextMenu.MenuItems.Add(item);
- } else {
- MenuItem item = new MenuItem("Unhide");
- item.Click += delegate(object obj, EventArgs args) {
- node.IsVisible = true;
- };
- treeContextMenu.MenuItems.Add(item);
- }
- treeContextMenu.MenuItems.Add(new MenuItem("-"));
- {
- MenuItem item = new MenuItem("Pen Color...");
- item.Click += delegate(object obj, EventArgs args) {
- ColorDialog dialog = new ColorDialog();
- dialog.Color = node.PenColor.GetValueOrDefault();
- if (dialog.ShowDialog() == DialogResult.OK)
- node.PenColor = dialog.Color;
- };
- treeContextMenu.MenuItems.Add(item);
- }
- {
- MenuItem item = new MenuItem("Reset Pen Color");
- item.Click += delegate(object obj, EventArgs args) {
- node.PenColor = null;
- };
- treeContextMenu.MenuItems.Add(item);
- }
- treeContextMenu.MenuItems.Add(new MenuItem("-"));
- {
- MenuItem item = new MenuItem("Show in Tray");
- item.Checked = systemTray.Contains(node.Sensor);
- item.Click += delegate(object obj, EventArgs args) {
- if (item.Checked)
- systemTray.Remove(node.Sensor);
- else
- systemTray.Add(node.Sensor, true);
- };
- treeContextMenu.MenuItems.Add(item);
- }
- if (gadget != null) {
- MenuItem item = new MenuItem("Show in Gadget");
- item.Checked = gadget.Contains(node.Sensor);
- item.Click += delegate(object obj, EventArgs args) {
- if (item.Checked) {
- gadget.Remove(node.Sensor);
- } else {
- gadget.Add(node.Sensor);
- }
- };
- treeContextMenu.MenuItems.Add(item);
- }
- if (node.Sensor.Control != null) {
- treeContextMenu.MenuItems.Add(new MenuItem("-"));
- IControl control = node.Sensor.Control;
- MenuItem controlItem = new MenuItem("Control");
- MenuItem defaultItem = new MenuItem("Default");
- defaultItem.Checked = control.ControlMode == ControlMode.Default;
- controlItem.MenuItems.Add(defaultItem);
- defaultItem.Click += delegate(object obj, EventArgs args) {
- control.SetDefault();
- };
- MenuItem manualItem = new MenuItem("Manual");
- controlItem.MenuItems.Add(manualItem);
- manualItem.Checked = control.ControlMode == ControlMode.Software;
- for (int i = 0; i <= 100; i += 5) {
- if (i <= control.MaxSoftwareValue &&
- i >= control.MinSoftwareValue) {
- MenuItem item = new MenuItem(i + " %");
- item.RadioCheck = true;
- manualItem.MenuItems.Add(item);
- item.Checked = control.ControlMode == ControlMode.Software &&
- Math.Round(control.SoftwareValue) == i;
- int softwareValue = i;
- item.Click += delegate(object obj, EventArgs args) {
- control.SetSoftware(softwareValue);
- };
- }
+ 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;
}
- treeContextMenu.MenuItems.Add(controlItem);
- }
-
- treeContextMenu.Show(treeView, new Point(m.X, m.Y));
}
- HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
- if (hardwareNode != null && hardwareNode.Hardware != null) {
- treeContextMenu.MenuItems.Clear();
+ private void PlotSelectionChanged(object sender, EventArgs e)
+ {
+ List selected = new List();
+ IDictionary colors = new Dictionary();
+ int colorIndex = 0;
- if (nodeTextBoxText.EditEnabled) {
- MenuItem item = new MenuItem("Rename");
- item.Click += delegate(object obj, EventArgs args) {
- nodeTextBoxText.BeginEdit();
+ foreach (TreeNodeAdv node in treeView.AllNodes)
+ {
+ if (node.Tag is SensorNode sensorNode)
+ {
+ if (sensorNode.Plot)
+ {
+ if (!sensorNode.PenColor.HasValue)
+ {
+ colors.Add(sensorNode.Sensor,
+ _plotColorPalette[colorIndex % _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 _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);
+ }
+
+ 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 node) && plotMenuItem.Checked;
+ }
+
+ private void ExitClick(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private void Timer_Tick(object sender, EventArgs e)
+ {
+ _computer.Accept(_updateVisitor);
+ treeView.Invalidate();
+ _plotPanel.InvalidatePlot();
+ _systemTray.Redraw();
+ _gadget?.Redraw();
+ _wmiProvider?.Update();
+
+ if (_logSensors != null && _logSensors.Value && _delayCount >= 4)
+ _logger.Log();
+
+ if (_delayCount < 4)
+ _delayCount++;
+ }
+
+ private void SaveConfiguration()
+ {
+ _plotPanel.SetCurrentSettings();
+
+ foreach (TreeColumn column in treeView.Columns)
+ _settings.SetValue("treeView.Columns." + column.Header + ".Width", column.Width);
+
+ _settings.SetValue("listenerPort", Server.ListenerPort);
+
+ 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 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)
};
- treeContextMenu.MenuItems.Add(item);
- }
- treeContextMenu.Show(treeView, new Point(m.X, m.Y));
+ Rectangle fullWorkingArea = new Rectangle(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;
}
- }
- }
- 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 MainForm_FormClosed(object sender, FormClosedEventArgs e)
+ {
+ Visible = false;
+ _systemTray.IsMainIconEnabled = false;
+ timer.Enabled = false;
+ _computer.Close();
+ SaveConfiguration();
+ if (_runWebServer.Value)
+ Server.Quit();
+ _systemTray.Dispose();
}
- }
+
+ 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.Right)
+ return;
+
+ NodeControlInfo info = treeView.GetNodeControlInfoAt(new Point(m.X, m.Y));
+ treeView.SelectedNode = info.Node;
+ if (info.Node != null)
+ {
+ if (info.Node.Tag is SensorNode node && node.Sensor != null)
+ {
+ treeContextMenu.MenuItems.Clear();
+ if (node.Sensor.Parameters.Count > 0)
+ {
+ MenuItem item = new MenuItem("Parameters...");
+ item.Click += delegate
+ {
+ ShowParameterForm(node.Sensor);
+ };
+ treeContextMenu.MenuItems.Add(item);
+ }
+ if (nodeTextBoxText.EditEnabled)
+ {
+ MenuItem item = new MenuItem("Rename");
+ item.Click += delegate
+ {
+ nodeTextBoxText.BeginEdit();
+ };
+ treeContextMenu.MenuItems.Add(item);
+ }
+ if (node.IsVisible)
+ {
+ MenuItem item = new MenuItem("Hide");
+ item.Click += delegate
+ {
+ node.IsVisible = false;
+ };
+ treeContextMenu.MenuItems.Add(item);
+ }
+ else
+ {
+ MenuItem item = new MenuItem("Unhide");
+ item.Click += delegate
+ {
+ node.IsVisible = true;
+ };
+ treeContextMenu.MenuItems.Add(item);
+ }
+ treeContextMenu.MenuItems.Add(new MenuItem("-"));
+ {
+ MenuItem item = new MenuItem("Pen Color...");
+ item.Click += delegate
+ {
+ ColorDialog dialog = new ColorDialog { Color = node.PenColor.GetValueOrDefault() };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ node.PenColor = dialog.Color;
+ };
+ treeContextMenu.MenuItems.Add(item);
+ }
+ {
+ MenuItem item = new MenuItem("Reset Pen Color");
+ item.Click += delegate
+ {
+ node.PenColor = null;
+ };
+ treeContextMenu.MenuItems.Add(item);
+ }
+ treeContextMenu.MenuItems.Add(new MenuItem("-"));
+ {
+ MenuItem item = new MenuItem("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.MenuItems.Add(item);
+ }
+ if (_gadget != null)
+ {
+ MenuItem item = new MenuItem("Show in Gadget") { Checked = _gadget.Contains(node.Sensor) };
+ item.Click += delegate
+ {
+ if (item.Checked)
+ {
+ _gadget.Remove(node.Sensor);
+ }
+ else
+ {
+ _gadget.Add(node.Sensor);
+ }
+ };
+ treeContextMenu.MenuItems.Add(item);
+ }
+ if (node.Sensor.Control != null)
+ {
+ treeContextMenu.MenuItems.Add(new MenuItem("-"));
+ IControl control = node.Sensor.Control;
+ MenuItem controlItem = new MenuItem("Control");
+ MenuItem defaultItem = new MenuItem("Default") { Checked = control.ControlMode == ControlMode.Default };
+ controlItem.MenuItems.Add(defaultItem);
+ defaultItem.Click += delegate
+ {
+ control.SetDefault();
+ };
+ MenuItem manualItem = new MenuItem("Manual");
+ controlItem.MenuItems.Add(manualItem);
+ manualItem.Checked = control.ControlMode == ControlMode.Software;
+ for (int i = 0; i <= 100; i += 5)
+ {
+ if (i <= control.MaxSoftwareValue &&
+ i >= control.MinSoftwareValue)
+ {
+ MenuItem item = new MenuItem(i + " %") { RadioCheck = true };
+ manualItem.MenuItems.Add(item);
+ item.Checked = control.ControlMode == ControlMode.Software && Math.Round(control.SoftwareValue) == i;
+ int softwareValue = i;
+ item.Click += delegate
+ {
+ control.SetSoftware(softwareValue);
+ };
+ }
+ }
+ treeContextMenu.MenuItems.Add(controlItem);
+ }
+
+ treeContextMenu.Show(treeView, new Point(m.X, m.Y));
+ }
+
+ if (info.Node.Tag is HardwareNode hardwareNode && hardwareNode.Hardware != null)
+ {
+ treeContextMenu.MenuItems.Clear();
+
+ if (nodeTextBoxText.EditEnabled)
+ {
+ MenuItem item = new MenuItem("Rename");
+ item.Click += delegate
+ {
+ nodeTextBoxText.BeginEdit();
+ };
+ treeContextMenu.MenuItems.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 SC_MINIMIZE = 0xF020;
+ const int SC_CLOSE = 0xF060;
+
+ if (_minimizeToTray.Value && m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_MINIMIZE)
+ {
+ SysTrayHideShow();
+ }
+ 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 ParameterForm { 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 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.Close();
+ _computer.Open();
+ // 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 ServerPortMenuItem_Click(object sender, EventArgs e)
+ {
+ new PortForm(this).ShowDialog();
+ }
+
+ public HttpServer Server { get; }
}
-
- private void SysTrayHideShow() {
- Visible = !Visible;
- if (Visible)
- Activate();
- }
-
- protected override void WndProc(ref Message m) {
- const int WM_SYSCOMMAND = 0x112;
- 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 (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 sensor) {
- ParameterForm form = new ParameterForm();
- form.Parameters = sensor.Parameters;
- form.captionLabel.Text = sensor.Name;
- form.ShowDialog();
- }
-
- private void treeView_NodeMouseDoubleClick(object sender,
- TreeNodeAdvMouseEventArgs e) {
- SensorNode node = e.Node.Tag as SensorNode;
- if (node != null && 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 sumbitReportMenuItem_Click(object sender, EventArgs e)
- {
- ReportForm form = new ReportForm();
- form.Report = computer.GetReport();
- form.ShowDialog();
- }
-
- private void resetMinMaxMenuItem_Click(object sender, EventArgs e) {
- computer.Accept(new SensorVisitor(delegate(ISensor sensor) {
- sensor.ResetMin();
- sensor.ResetMax();
- }));
- }
-
- 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.Close();
- computer.Open();
- // restore the MainIcon setting
- systemTray.IsMainIconEnabled = minimizeToTray.Value;
- }
-
- private void treeView_MouseMove(object sender, MouseEventArgs e) {
- selectionDragging = 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 serverPortMenuItem_Click(object sender, EventArgs e) {
- new PortForm(this).ShowDialog();
- }
-
- public HttpServer Server {
- get { return server; }
- }
-
- }
}
diff --git a/GUI/MainForm.resx b/GUI/MainForm.resx
index 9cb27cf..68d32bd 100644
--- a/GUI/MainForm.resx
+++ b/GUI/MainForm.resx
@@ -112,24 +112,24 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
373, 17
-
+
17, 17
-
+
164, 17
-
+
293, 17
-
+
AAABAAMAEBAAAAEAIABoBAAANgAAACAgAAABACAAqBAAAJ4EAAAwMAAAAQAgAKglAABGFQAAKAAAABAA
diff --git a/GUI/Node.cs b/GUI/Node.cs
index 02750c6..cd92b84 100644
--- a/GUI/Node.cs
+++ b/GUI/Node.cs
@@ -1,173 +1,166 @@
-/*
-
- 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) 2009-2010 Michael Möller
-
-*/
-
+// Mozilla Public License 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 System;
-using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
-using Aga.Controls.Tree;
-namespace OpenHardwareMonitor.GUI {
- public class Node {
+namespace OpenHardwareMonitor.GUI
+{
+ public class Node
+ {
+ private Node _parent;
+ private readonly NodeCollection _nodes;
+ private string _text;
+ private bool _visible;
- private TreeModel treeModel;
- private Node parent;
- private NodeCollection nodes;
+ public delegate void NodeEventHandler(Node node);
+ public event NodeEventHandler IsVisibleChanged;
+ public event NodeEventHandler NodeAdded;
+ public event NodeEventHandler NodeRemoved;
- private string text;
- private Image image;
- private bool visible;
-
- 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) {
- this.text = text;
- this.nodes = new NodeCollection(this);
- this.visible = true;
- }
-
- public TreeModel Model {
- get { return treeModel; }
- set { treeModel = value; }
- }
-
- public Node Parent {
- get { return parent; }
- set {
- if (value != parent) {
- if (parent != null)
- parent.nodes.Remove(this);
- if (value != null)
- value.nodes.Add(this);
- }
- }
- }
-
- public Collection Nodes {
- get { return nodes; }
- }
-
- public virtual string Text {
- get { return text; }
- set {
- if (text != value) {
- text = value;
- }
- }
- }
-
- public Image Image {
- get { return image; }
- set {
- if (image != value) {
- image = value;
- }
- }
- }
-
- 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++;
+ private TreeModel RootTreeModel()
+ {
+ Node node = this;
+ while (node != null)
+ {
+ if (node.Model != null)
+ return node.Model;
+ node = node._parent;
}
- if (model.ForceVisible) {
- model.OnNodeChanged(parent, index, this);
- } else {
- if (value)
- model.OnNodeInserted(parent, index, this);
- else
- model.OnNodeRemoved(parent, index, this);
+ 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);
+ }
}
- }
- if (IsVisibleChanged != null)
- IsVisibleChanged(this);
}
- }
- }
- public delegate void NodeEventHandler(Node node);
-
- public event NodeEventHandler IsVisibleChanged;
- public event NodeEventHandler NodeAdded;
- public event NodeEventHandler NodeRemoved;
-
- private class NodeCollection : Collection {
- private Node owner;
-
- public NodeCollection(Node owner) {
- this.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;
- base.InsertItem(index, item);
-
- TreeModel model = owner.RootTreeModel();
- if (model != null)
- model.OnStructureChanged(owner);
- if (owner.NodeAdded != null)
- owner.NodeAdded(item);
+ public Collection Nodes
+ {
+ get { return _nodes; }
}
- }
- protected override void RemoveItem(int index) {
- Node item = this[index];
- item.parent = null;
- base.RemoveItem(index);
+ public virtual string Text
+ {
+ get { return _text; }
+ set
+ {
+ _text = value;
+ }
+ }
- TreeModel model = owner.RootTreeModel();
- if (model != null)
- model.OnStructureChanged(owner);
- if (owner.NodeRemoved != null)
- owner.NodeRemoved(item);
- }
+ public Image Image { get; set; }
- protected override void SetItem(int index, Node item) {
- if (item == null)
- throw new ArgumentNullException("item");
+ 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);
+ }
+ }
+ }
- RemoveAt(index);
- InsertItem(index, item);
- }
+ 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);
+ }
+ }
}
- }
}
diff --git a/GUI/NotifyIconAdv.cs b/GUI/NotifyIconAdv.cs
index e40782d..a726c90 100644
--- a/GUI/NotifyIconAdv.cs
+++ b/GUI/NotifyIconAdv.cs
@@ -1,12 +1,7 @@
-/*
-
- 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) 2012 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.ComponentModel;
@@ -15,793 +10,889 @@ using System.Runtime.InteropServices;
using System.Reflection;
using System.Windows.Forms;
-namespace OpenHardwareMonitor.GUI {
+namespace OpenHardwareMonitor.GUI
+{
+ public class NotifyIconAdv : IDisposable
+ {
+ private readonly NotifyIcon _genericNotifyIcon;
+ private readonly NotifyIconWindowsImplementation _windowsNotifyIcon;
- public class NotifyIconAdv : IDisposable {
-
- private NotifyIcon genericNotifyIcon;
- private NotifyIconWindowsImplementation windowsNotifyIcon;
-
- public NotifyIconAdv() {
- int p = (int)Environment.OSVersion.Platform;
- if ((p == 4) || (p == 128)) { // Unix
- genericNotifyIcon = new NotifyIcon();
- } else { // Windows
- 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;
- else
- return windowsNotifyIcon.BalloonTipText;
- }
- set {
- if (genericNotifyIcon != null)
- genericNotifyIcon.BalloonTipText = value;
- else
- windowsNotifyIcon.BalloonTipText = value;
- }
- }
-
- public ToolTipIcon BalloonTipIcon {
- get {
- if (genericNotifyIcon != null)
- return genericNotifyIcon.BalloonTipIcon;
- else
- return windowsNotifyIcon.BalloonTipIcon;
- }
- set {
- if (genericNotifyIcon != null)
- genericNotifyIcon.BalloonTipIcon = value;
- else
- windowsNotifyIcon.BalloonTipIcon = value;
- }
- }
-
- public string BalloonTipTitle {
- get {
- if (genericNotifyIcon != null)
- return genericNotifyIcon.BalloonTipTitle;
- else
- return windowsNotifyIcon.BalloonTipTitle;
- }
- set {
- if (genericNotifyIcon != null)
- genericNotifyIcon.BalloonTipTitle = value;
- else
- windowsNotifyIcon.BalloonTipTitle = value;
- }
- }
-
- public ContextMenu ContextMenu {
- get {
- if (genericNotifyIcon != null)
- return genericNotifyIcon.ContextMenu;
- else
- return windowsNotifyIcon.ContextMenu;
- }
- set {
- if (genericNotifyIcon != null)
- genericNotifyIcon.ContextMenu = value;
- else
- windowsNotifyIcon.ContextMenu = value;
- }
- }
-
- public ContextMenuStrip ContextMenuStrip {
- get {
- if (genericNotifyIcon != null)
- return genericNotifyIcon.ContextMenuStrip;
- else
- 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;
- else
- return windowsNotifyIcon.Icon;
- }
- set {
- if (genericNotifyIcon != null)
- genericNotifyIcon.Icon = value;
- else
- windowsNotifyIcon.Icon = value;
- }
- }
-
- public string Text {
- get {
- if (genericNotifyIcon != null)
- return genericNotifyIcon.Text;
- else
- return windowsNotifyIcon.Text;
- }
- set {
- if (genericNotifyIcon != null)
- genericNotifyIcon.Text = value;
- else
- windowsNotifyIcon.Text = value;
- }
- }
-
- public bool Visible {
- get {
- if (genericNotifyIcon != null)
- return genericNotifyIcon.Visible;
- else
- 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 = 0;
-
- private object syncObj = new object();
- private Icon icon;
- private string text = "";
- private int id;
- private bool created;
- private NotifyIconNativeWindow window;
- private bool doubleClickDown;
- private bool visible;
- private 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 ContextMenu ContextMenu { get; set; }
- public ContextMenuStrip ContextMenuStrip { get; set; }
- public object Tag { 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 Type[] { typeof(int) }, null);
-
- id = ++NotifyIconWindowsImplementation.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;
- ContextMenu = 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("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 (ContextMenu == null && ContextMenuStrip == null)
- return;
-
- NativeMethods.Point p = new NativeMethods.Point();
- NativeMethods.GetCursorPos(ref p);
- NativeMethods.SetForegroundWindow(
- new HandleRef(window, window.Handle));
-
- if (ContextMenu != null) {
- ContextMenu.GetType().InvokeMember("OnPopup",
- BindingFlags.NonPublic | BindingFlags.InvokeMethod |
- BindingFlags.Instance, null, ContextMenu,
- new Object[] { System.EventArgs.Empty });
-
- NativeMethods.TrackPopupMenuEx(
- new HandleRef(ContextMenu, ContextMenu.Handle), 72,
- p.x, p.y, new HandleRef(window, window.Handle),
- IntPtr.Zero);
-
- NativeMethods.PostMessage(
- new HandleRef(window, window.Handle), WM_NULL, 0, 0);
- return;
+ public NotifyIconAdv()
+ {
+ int p = (int)Environment.OSVersion.Platform;
+ if ((p == 4) || (p == 128))
+ { // Unix
+ _genericNotifyIcon = new NotifyIcon();
+ }
+ else
+ { // Windows
+ _windowsNotifyIcon = new NotifyIconWindowsImplementation();
+ }
}
- if (ContextMenuStrip != null)
- ContextMenuStrip.GetType().InvokeMember("ShowInTaskbar",
- BindingFlags.NonPublic | BindingFlags.InvokeMethod |
- BindingFlags.Instance, null, ContextMenuStrip,
- new Object[] { p.x, p.y });
- }
+ 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;
+ }
+ }
- private void UpdateNotifyIcon(bool showNotifyIcon) {
- if (DesignMode)
- return;
+ 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;
+ }
+ }
- lock (syncObj) {
- window.LockReference(showNotifyIcon);
+ 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;
+ }
+ }
- NativeMethods.NotifyIconData data = new NativeMethods.NotifyIconData();
- data.CallbackMessage = WM_TRAYMOUSEMESSAGE;
- data.Flags = NativeMethods.NotifyIconDataFlags.Message;
+ 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;
+ }
+ }
- if (showNotifyIcon && window.Handle == IntPtr.Zero)
- window.CreateHandle(new CreateParams());
+ 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;
+ }
+ }
- data.Window = window.Handle;
- data.ID = id;
+ 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;
+ }
+ }
- if (icon != null) {
- data.Flags |= NativeMethods.NotifyIconDataFlags.Icon;
- data.Icon = icon.Handle;
- }
+ 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;
+ }
+ }
- data.Flags |= NativeMethods.NotifyIconDataFlags.Tip;
- data.Tip = text;
+ 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;
+ }
+ }
- if (showNotifyIcon && icon != null) {
- if (!created) {
- int i = 0;
- do {
- created = NativeMethods.Shell_NotifyIcon(
- NativeMethods.NotifyIconMessage.Add, data);
- if (!created) {
- System.Threading.Thread.Sleep(200);
- i++;
+ 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 ContextMenu ContextMenu
+ {
+ get
+ {
+ if (_genericNotifyIcon != null)
+ return _genericNotifyIcon.ContextMenu;
+
+
+ return _windowsNotifyIcon.ContextMenu;
+ }
+ set
+ {
+ if (_genericNotifyIcon != null)
+ _genericNotifyIcon.ContextMenu = value;
+ else
+ _windowsNotifyIcon.ContextMenu = 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 ContextMenu ContextMenu { get; set; }
+ public ContextMenuStrip ContextMenuStrip { get; set; }
+
+ public Icon Icon
+ {
+ get
+ {
+ return _icon;
}
- } while (!created && i < 40);
- } else {
- NativeMethods.Shell_NotifyIcon(
- NativeMethods.NotifyIconMessage.Modify, data);
- }
- } else {
- if (created) {
- int i = 0;
- bool deleted = false;
- do {
- deleted = NativeMethods.Shell_NotifyIcon(
- NativeMethods.NotifyIconMessage.Delete, data);
- if (!deleted) {
- System.Threading.Thread.Sleep(200);
- i++;
+ set
+ {
+ if (_icon != value)
+ {
+ _icon = value;
+ UpdateNotifyIcon(_visible);
+ }
}
- } while (!deleted && i < 40);
- created = false;
}
- }
- }
- }
- private void ProcessMouseDown(ref Message message, MouseButtons button,
- bool doubleClick) {
- if (doubleClick) {
- if (DoubleClick != null)
- DoubleClick(this, new MouseEventArgs(button, 2, 0, 0, 0));
+ public string Text
+ {
+ get
+ {
+ return _text;
+ }
+ set
+ {
+ if (value == null)
+ value = "";
- if (MouseDoubleClick != null)
- MouseDoubleClick(this, new MouseEventArgs(button, 2, 0, 0, 0));
+ if (value.Length > 63)
+ throw new ArgumentOutOfRangeException();
- doubleClickDown = true;
- }
-
- if (MouseDown != null)
- MouseDown(this,
- new MouseEventArgs(button, doubleClick ? 2 : 1, 0, 0, 0));
- }
-
- private void ProcessMouseUp(ref Message message, MouseButtons button) {
- if (MouseUp != null)
- MouseUp(this, new MouseEventArgs(button, 0, 0, 0, 0));
-
- if (!doubleClickDown) {
- if (Click != null)
- Click(this, new MouseEventArgs(button, 0, 0, 0, 0));
-
- if (MouseClick != null)
- MouseClick(this, new MouseEventArgs(button, 0, 0, 0, 0));
- }
- doubleClickDown = false;
- }
-
- private void ProcessInitMenuPopup(ref Message message) {
- if (ContextMenu != null &&
- (bool)ContextMenu.GetType().InvokeMember("ProcessInitMenuPopup",
- BindingFlags.NonPublic | BindingFlags.InvokeMethod |
- BindingFlags.Instance, null, ContextMenu,
- new Object[] { message.WParam })) {
- return;
- }
- 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;
+ if (!value.Equals(_text))
+ {
+ _text = value;
+ if (_visible)
+ UpdateNotifyIcon(_visible);
+ }
+ }
}
- 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:
- if (MouseMove != null)
- MouseMove(this,
- new MouseEventArgs(Control.MouseButtons, 0, 0, 0, 0));
- return;
- case WM_LBUTTONDOWN:
- ProcessMouseDown(ref message, MouseButtons.Left, false);
- return;
- case WM_LBUTTONUP:
- ProcessMouseUp(ref message, MouseButtons.Left);
- return;
- case WM_LBUTTONDBLCLK:
- ProcessMouseDown(ref message, MouseButtons.Left, true);
- return;
- case WM_RBUTTONDOWN:
- ProcessMouseDown(ref message, MouseButtons.Right, false);
- return;
- case WM_RBUTTONUP:
- if (ContextMenu != null || ContextMenuStrip != null)
- ShowContextMenu();
- ProcessMouseUp(ref message, MouseButtons.Right);
- return;
- case WM_RBUTTONDBLCLK:
- ProcessMouseDown(ref message, MouseButtons.Right, true);
- return;
- case WM_MBUTTONDOWN:
- ProcessMouseDown(ref message, MouseButtons.Middle, false);
- return;
- case WM_MBUTTONUP:
- ProcessMouseUp(ref message, MouseButtons.Middle);
- return;
- case WM_MBUTTONDBLCLK:
- ProcessMouseDown(ref message, MouseButtons.Middle, true);
- return;
- case NIN_BALLOONSHOW:
- if (BalloonTipShown != null)
- BalloonTipShown(this, EventArgs.Empty);
- return;
- case NIN_BALLOONHIDE:
- case NIN_BALLOONTIMEOUT:
- if (BalloonTipClosed != null)
- BalloonTipClosed(this, EventArgs.Empty);
- return;
- case NIN_BALLOONUSERCLICK:
- if (BalloonTipClicked != null)
- BalloonTipClicked(this, EventArgs.Empty);
- return;
- default:
- return;
+
+ 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;
+ ContextMenu = 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 (ContextMenu == null && ContextMenuStrip == null)
+ return;
+
+ NativeMethods.Point p = new NativeMethods.Point();
+ NativeMethods.GetCursorPos(ref p);
+ NativeMethods.SetForegroundWindow(new HandleRef(_window, _window.Handle));
+
+ if (ContextMenu != null)
+ {
+ ContextMenu.GetType().InvokeMember("OnPopup",
+ BindingFlags.NonPublic | BindingFlags.InvokeMethod |
+ BindingFlags.Instance, null, ContextMenu,
+ new object[] { EventArgs.Empty });
+
+ NativeMethods.TrackPopupMenuEx(new HandleRef(ContextMenu, ContextMenu.Handle), 72, p.X, p.Y, new HandleRef(_window, _window.Handle), IntPtr.Zero);
+ NativeMethods.PostMessage(new HandleRef(_window, _window.Handle), WM_NULL, 0, 0);
+ return;
+ }
+
+ 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)
+ {
+ 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)
+ {
+ if (ContextMenu != null &&
+ (bool)ContextMenu.GetType().InvokeMember("ProcessInitMenuPopup", BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance, null, ContextMenu, new object[] { message.WParam }))
+ {
+ return;
+ }
+
+ _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 (ContextMenu != null || 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);
}
}
-
- if (message.Msg == NotifyIconWindowsImplementation.WM_TASKBARCREATED) {
- lock (syncObj) {
- created = false;
- }
- UpdateNotifyIcon(visible);
- }
-
- window.DefWndProc(ref message);
- }
-
- private class NotifyIconNativeWindow : NativeWindow {
- private NotifyIconWindowsImplementation reference;
- private GCHandle referenceHandle;
-
- internal NotifyIconNativeWindow(NotifyIconWindowsImplementation component) {
- this.reference = component;
- }
-
- ~NotifyIconNativeWindow() {
- if (base.Handle != IntPtr.Zero)
- NativeMethods.PostMessage(
- new HandleRef(this, base.Handle), WM_CLOSE, 0, 0);
- }
-
- public void LockReference(bool locked) {
- if (locked) {
- if (!referenceHandle.IsAllocated) {
- referenceHandle = GCHandle.Alloc(reference, GCHandleType.Normal);
- return;
- }
- } 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 int WM_TASKBARCREATED =
- NativeMethods.RegisterWindowMessage("TaskbarCreated");
-
- private static class NativeMethods {
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- public static extern IntPtr PostMessage(HandleRef hwnd, int msg,
- int wparam, int lparam);
-
- [DllImport("user32.dll", 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("shell32.dll", CharSet = CharSet.Auto)]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool Shell_NotifyIcon(NotifyIconMessage message,
- NotifyIconData pnid);
-
- [DllImport("user32.dll", 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 int x;
- public int y;
- }
-
- [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
- public static extern bool GetCursorPos(ref Point point);
-
- [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
- public static extern bool SetForegroundWindow(HandleRef hWnd);
- }
}
- }
}
diff --git a/GUI/ParameterForm.Designer.cs b/GUI/ParameterForm.Designer.cs
index b57f35c..1b225ae 100644
--- a/GUI/ParameterForm.Designer.cs
+++ b/GUI/ParameterForm.Designer.cs
@@ -58,7 +58,7 @@ namespace OpenHardwareMonitor.GUI {
this.okButton.TabIndex = 2;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
- this.okButton.Click += new System.EventHandler(this.okButton_Click);
+ this.okButton.Click += new System.EventHandler(this.OkButton_Click);
//
// cancelButton
//
@@ -115,10 +115,10 @@ namespace OpenHardwareMonitor.GUI {
this.dataGridView.ShowRowErrors = false;
this.dataGridView.Size = new System.Drawing.Size(327, 121);
this.dataGridView.TabIndex = 0;
- this.dataGridView.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_RowEnter);
- this.dataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.dataGridView_CellValidating);
- this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit);
- this.dataGridView.CurrentCellDirtyStateChanged += new System.EventHandler(this.dataGridView_CurrentCellDirtyStateChanged);
+ this.dataGridView.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_RowEnter);
+ this.dataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.DataGridView_CellValidating);
+ this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellEndEdit);
+ this.dataGridView.CurrentCellDirtyStateChanged += new System.EventHandler(this.DataGridView_CurrentCellDirtyStateChanged);
//
// NameColumn
//
diff --git a/GUI/ParameterForm.cs b/GUI/ParameterForm.cs
index 4a3cb8b..e6442fe 100644
--- a/GUI/ParameterForm.cs
+++ b/GUI/ParameterForm.cs
@@ -1,132 +1,99 @@
-/*
-
- 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) 2009-2010 Michael Möller
-
-*/
-
+// Mozilla Public License 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 System;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Text;
using System.Windows.Forms;
using OpenHardwareMonitor.Hardware;
-namespace OpenHardwareMonitor.GUI {
- 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 IParameter parameter;
- private float value;
- public bool isDefault;
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- private void NotifyPropertyChanged(String propertyName) {
- if (PropertyChanged != null) {
- PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- }
-
- public ParameterRow(IParameter parameter){
- this.parameter = parameter;
- this.value = parameter.Value;
- this.isDefault = parameter.IsDefault;
- }
-
- public string Name {
- get { return parameter.Name; }
- }
-
- public float Value {
- get { return value; }
- set {
- this.isDefault = false;
- this.value = value;
- NotifyPropertyChanged("Default");
- NotifyPropertyChanged("Value");
- }
- }
-
- public bool Default {
- get { return isDefault; }
- set {
- isDefault = value;
- if (value)
- this.value = parameter.DefaultValue;
- NotifyPropertyChanged("Default");
- NotifyPropertyChanged("Value");
- }
- }
- }
-
- private void dataGridView_RowEnter(object sender,
- DataGridViewCellEventArgs e)
+namespace OpenHardwareMonitor.GUI
+{
+ public partial class ParameterForm : Form
{
- if (e.RowIndex >= 0 && e.RowIndex < parameters.Count)
- descriptionLabel.Text = parameters[e.RowIndex].Description;
- else
- descriptionLabel.Text = "";
- }
+ private IReadOnlyList _parameters;
+ private BindingList _parameterRows;
- private void dataGridView_CellValidating(object sender,
- DataGridViewCellValidatingEventArgs e)
- {
- float value;
- if (e.ColumnIndex == 2 &&
- !float.TryParse(e.FormattedValue.ToString(), out value)) {
- 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 = "";
- }
-
- 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;
+ public ParameterForm()
+ {
+ InitializeComponent();
}
- }
- }
- private void dataGridView_CurrentCellDirtyStateChanged(object sender,
- EventArgs e) {
- if (dataGridView.CurrentCell is DataGridViewCheckBoxCell ||
- dataGridView.CurrentCell is DataGridViewComboBoxCell)
- {
- dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
- }
+ 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;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public ParameterRow(IParameter parameter)
+ {
+ Parameter = parameter;
+ Value = parameter.Value;
+ Default = parameter.IsDefault;
+ }
+
+ public float Value { get; }
+
+ public bool Default { get; }
+ }
+
+ 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 = "";
+ }
+
+ 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 = "";
+ }
+
+ 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);
+ }
}
- }
}
diff --git a/GUI/PlotPanel.cs b/GUI/PlotPanel.cs
index 998724b..ec5f7d2 100644
--- a/GUI/PlotPanel.cs
+++ b/GUI/PlotPanel.cs
@@ -1,12 +1,7 @@
-/*
-
- 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) 2009-2013 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Collections.Generic;
@@ -14,287 +9,290 @@ using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using OpenHardwareMonitor.Hardware;
+using OpenHardwareMonitor.Utilities;
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.WindowsForms;
using OxyPlot.Series;
-namespace OpenHardwareMonitor.GUI {
- public class PlotPanel : UserControl {
+namespace OpenHardwareMonitor.GUI
+{
+ public class PlotPanel : UserControl
+ {
+ private readonly PersistentSettings _settings;
+ private readonly UnitManager _unitManager;
+ private readonly Plot _plot;
+ private readonly PlotModel _model;
+ private readonly TimeSpanAxis _timeAxis = new TimeSpanAxis();
+ private readonly SortedDictionary _axes = new SortedDictionary();
+ private UserOption _stackedAxes;
+ private DateTime _now;
+ private float _dpiX;
+ private float _dpiY;
+ private double _dpiXScale = 1;
+ private double _dpiYScale = 1;
- private readonly PersistentSettings settings;
- private readonly UnitManager unitManager;
-
- private readonly Plot plot;
- private readonly PlotModel model;
- private readonly TimeSpanAxis timeAxis = new TimeSpanAxis();
- private readonly SortedDictionary axes =
- new SortedDictionary();
-
- private UserOption stackedAxes;
-
- private DateTime now;
- private float dpiX;
- private float dpiY;
- private double dpiXscale = 1;
- private double dpiYscale = 1;
-
- public PlotPanel(PersistentSettings settings, UnitManager unitManager) {
- this.settings = settings;
- this.unitManager = unitManager;
-
- this.SetDPI();
- this.model = CreatePlotModel();
-
- this.plot = new Plot();
- this.plot.Dock = DockStyle.Fill;
- this.plot.Model = model;
- this.plot.BackColor = Color.White;
- this.plot.ContextMenu = CreateMenu();
-
- UpdateAxesPosition();
-
- this.SuspendLayout();
- this.Controls.Add(plot);
- this.ResumeLayout(true);
- }
-
- public void SetCurrentSettings() {
- settings.SetValue("plotPanel.MinTimeSpan", (float)timeAxis.ViewMinimum);
- settings.SetValue("plotPanel.MaxTimeSpan", (float)timeAxis.ViewMaximum);
-
- foreach (var axis in axes.Values) {
- settings.SetValue("plotPanel.Min" + axis.Key, (float)axis.ViewMinimum);
- settings.SetValue("plotPanel.Max" + axis.Key, (float)axis.ViewMaximum);
- }
- }
-
- private ContextMenu CreateMenu() {
- ContextMenu menu = new ContextMenu();
-
- MenuItem stackedAxesMenuItem = new MenuItem("Stacked Axes");
- stackedAxes = new UserOption("stackedAxes", true,
- stackedAxesMenuItem, settings);
- stackedAxes.Changed += (sender, e) => {
- UpdateAxesPosition();
- InvalidatePlot();
- };
- menu.MenuItems.Add(stackedAxesMenuItem);
-
- MenuItem timeWindow = new MenuItem("Time Window");
- MenuItem[] timeWindowMenuItems =
- { new MenuItem("Auto",
- (s, e) => { timeAxis.Zoom(0, double.NaN); InvalidatePlot(); }),
- new MenuItem("5 min",
- (s, e) => { timeAxis.Zoom(0, 5 * 60); InvalidatePlot(); }),
- new MenuItem("10 min",
- (s, e) => { timeAxis.Zoom(0, 10 * 60); InvalidatePlot(); }),
- new MenuItem("20 min",
- (s, e) => { timeAxis.Zoom(0, 20 * 60); InvalidatePlot(); }),
- new MenuItem("30 min",
- (s, e) => { timeAxis.Zoom(0, 30 * 60); InvalidatePlot(); }),
- new MenuItem("45 min",
- (s, e) => { timeAxis.Zoom(0, 45 * 60); InvalidatePlot(); }),
- new MenuItem("1 h",
- (s, e) => { timeAxis.Zoom(0, 60 * 60); InvalidatePlot(); }),
- new MenuItem("1.5 h",
- (s, e) => { timeAxis.Zoom(0, 1.5 * 60 * 60); InvalidatePlot(); }),
- new MenuItem("2 h",
- (s, e) => { timeAxis.Zoom(0, 2 * 60 * 60); InvalidatePlot(); }),
- new MenuItem("3 h",
- (s, e) => { timeAxis.Zoom(0, 3 * 60 * 60); InvalidatePlot(); }),
- new MenuItem("6 h",
- (s, e) => { timeAxis.Zoom(0, 6 * 60 * 60); InvalidatePlot(); }),
- new MenuItem("12 h",
- (s, e) => { timeAxis.Zoom(0, 12 * 60 * 60); InvalidatePlot(); }),
- new MenuItem("24 h",
- (s, e) => { timeAxis.Zoom(0, 24 * 60 * 60); InvalidatePlot(); }) };
- foreach (MenuItem mi in timeWindowMenuItems)
- timeWindow.MenuItems.Add(mi);
- menu.MenuItems.Add(timeWindow);
-
- 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();
- units.Add(SensorType.Voltage, "V");
- units.Add(SensorType.Clock, "MHz");
- units.Add(SensorType.Temperature, "°C");
- units.Add(SensorType.Load, "%");
- units.Add(SensorType.Fan, "RPM");
- units.Add(SensorType.Flow, "L/h");
- units.Add(SensorType.Control, "%");
- units.Add(SensorType.Level, "%");
- units.Add(SensorType.Factor, "1");
- units.Add(SensorType.Power, "W");
- units.Add(SensorType.Data, "GB");
- units.Add(SensorType.Frequency, "Hz");
-
- foreach (SensorType type in Enum.GetValues(typeof(SensorType))) {
- var axis = new LinearAxis();
- axis.Position = AxisPosition.Left;
- axis.MajorGridlineStyle = LineStyle.Solid;
- axis.MajorGridlineThickness = 1;
- axis.MajorGridlineColor = timeAxis.MajorGridlineColor;
- axis.MinorGridlineStyle = LineStyle.Solid;
- axis.MinorGridlineThickness = 1;
- axis.MinorGridlineColor = timeAxis.MinorGridlineColor;
- axis.AxislineStyle = LineStyle.Solid;
- axis.Title = type.ToString();
- axis.Key = type.ToString();
-
- 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);
- }
-
- var model = new PlotModel(this.dpiXscale, this.dpiYscale);
- model.Axes.Add(timeAxis);
- foreach (var axis in axes.Values)
- model.Axes.Add(axis);
- model.PlotMargins = new OxyThickness(0);
- model.IsLegendVisible = false;
-
- return model;
- }
-
- private 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
+ public PlotPanel(PersistentSettings settings, UnitManager unitManager)
{
- this.dpiX = g.DpiX;
- this.dpiY = g.DpiY;
+ _settings = settings;
+ _unitManager = unitManager;
+
+ SetDpi();
+ _model = CreatePlotModel();
+
+ _plot = new Plot { Dock = DockStyle.Fill, Model = _model, BackColor = Color.White, ContextMenu = CreateMenu() };
+
+ UpdateAxesPosition();
+
+ SuspendLayout();
+ Controls.Add(_plot);
+ ResumeLayout(true);
}
- finally
+
+ public void SetCurrentSettings()
{
- g.Dispose();
+ _settings.SetValue("plotPanel.MinTimeSpan", (float)_timeAxis.ViewMinimum);
+ _settings.SetValue("plotPanel.MaxTimeSpan", (float)_timeAxis.ViewMaximum);
+ foreach (LinearAxis axis in _axes.Values)
+ {
+ _settings.SetValue("plotPanel.Min" + axis.Key, (float)axis.ViewMinimum);
+ _settings.SetValue("plotPanel.Max" + axis.Key, (float)axis.ViewMaximum);
+ }
}
- if (dpiX > 0)
+
+ private ContextMenu CreateMenu()
{
- this.dpiXscale = dpiX / _default_dpi;
+ ContextMenu menu = new ContextMenu();
+
+ MenuItem stackedAxesMenuItem = new MenuItem("Stacked Axes");
+ _stackedAxes = new UserOption("stackedAxes", true, stackedAxesMenuItem, _settings);
+ _stackedAxes.Changed += (sender, e) =>
+ {
+ UpdateAxesPosition();
+ InvalidatePlot();
+ };
+ menu.MenuItems.Add(stackedAxesMenuItem);
+
+ MenuItem timeWindow = new MenuItem("Time Window");
+ MenuItem[] timeWindowMenuItems =
+ { new MenuItem("Auto", (s, e) => { _timeAxis.Zoom(0, double.NaN); InvalidatePlot(); }),
+ new MenuItem("5 min", (s, e) => { _timeAxis.Zoom(0, 5 * 60); InvalidatePlot(); }),
+ new MenuItem("10 min", (s, e) => { _timeAxis.Zoom(0, 10 * 60); InvalidatePlot(); }),
+ new MenuItem("20 min", (s, e) => { _timeAxis.Zoom(0, 20 * 60); InvalidatePlot(); }),
+ new MenuItem("30 min", (s, e) => { _timeAxis.Zoom(0, 30 * 60); InvalidatePlot(); }),
+ new MenuItem("45 min", (s, e) => { _timeAxis.Zoom(0, 45 * 60); InvalidatePlot(); }),
+ new MenuItem("1 h", (s, e) => { _timeAxis.Zoom(0, 60 * 60); InvalidatePlot(); }),
+ new MenuItem("1.5 h", (s, e) => { _timeAxis.Zoom(0, 1.5 * 60 * 60); InvalidatePlot(); }),
+ new MenuItem("2 h", (s, e) => { _timeAxis.Zoom(0, 2 * 60 * 60); InvalidatePlot(); }),
+ new MenuItem("3 h", (s, e) => { _timeAxis.Zoom(0, 3 * 60 * 60); InvalidatePlot(); }),
+ new MenuItem("6 h", (s, e) => { _timeAxis.Zoom(0, 6 * 60 * 60); InvalidatePlot(); }),
+ new MenuItem("12 h", (s, e) => { _timeAxis.Zoom(0, 12 * 60 * 60); InvalidatePlot(); }),
+ new MenuItem("24 h", (s, e) => { _timeAxis.Zoom(0, 24 * 60 * 60); InvalidatePlot(); }) };
+ foreach (MenuItem mi in timeWindowMenuItems)
+ timeWindow.MenuItems.Add(mi);
+ menu.MenuItems.Add(timeWindow);
+ return menu;
}
- if (dpiY > 0)
+
+ private PlotModel CreatePlotModel()
{
- this.dpiYscale = dpiY / _default_dpi;
+ _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.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" }
+ };
+
+ foreach (SensorType type in Enum.GetValues(typeof(SensorType)))
+ {
+ 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 = type.ToString(),
+ Key = type.ToString()
+ };
+
+ 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);
+ }
+
+ var model = new PlotModel(_dpiXScale, _dpiYScale);
+ model.Axes.Add(_timeAxis);
+ foreach (LinearAxis axis in _axes.Values)
+ model.Axes.Add(axis);
+ model.PlotMargins = new OxyThickness(0);
+ 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)
+ {
+ _model.Series.Clear();
+ var types = new System.Collections.Generic.HashSet();
+
+ foreach (ISensor sensor in sensors)
+ {
+ var series = new LineSeries();
+ if (sensor.SensorType == SensorType.Temperature)
+ {
+ series.ItemsSource = sensor.Values.Select(value => new DataPoint
+ {
+ X = (_now - value.Time).TotalSeconds,
+ Y = _unitManager.TemperatureUnit == TemperatureUnit.Celsius ?
+ value.Value : UnitManager.CelsiusToFahrenheit(value.Value).Value
+ });
+ }
+ else
+ {
+ series.ItemsSource = sensor.Values.Select(value => new DataPoint
+ {
+ X = (_now - value.Time).TotalSeconds,
+ Y = value.Value
+ });
+ }
+ series.Color = colors[sensor].ToOxyColor();
+ series.StrokeThickness = 1;
+ series.YAxisKey = _axes[sensor.SensorType].Key;
+ series.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();
+ }
+
+ 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;
+ }
+ }
+ 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;
+ }
+ }
+
+ }
+
+ 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";
+ }
+ }
+
+ _plot?.InvalidatePlot(true);
}
}
-
- public void SetSensors(List sensors,
- IDictionary colors) {
- this.model.Series.Clear();
-
- var types = new System.Collections.Generic.HashSet();
-
- foreach (ISensor sensor in sensors) {
- var series = new LineSeries();
- if (sensor.SensorType == SensorType.Temperature) {
- series.ItemsSource = sensor.Values.Select(value => new DataPoint {
- X = (now - value.Time).TotalSeconds,
- Y = unitManager.TemperatureUnit == TemperatureUnit.Celsius ?
- value.Value : UnitManager.CelsiusToFahrenheit(value.Value).Value
- });
- } else {
- series.ItemsSource = sensor.Values.Select(value => new DataPoint {
- X = (now - value.Time).TotalSeconds, Y = value.Value
- });
- }
- series.Color = colors[sensor].ToOxyColor();
- series.StrokeThickness = 1;
- series.YAxisKey = axes[sensor.SensorType].Key;
- series.Title = sensor.Hardware.Name + " " + sensor.Name;
- this.model.Series.Add(series);
-
- types.Add(sensor.SensorType);
- }
-
- foreach (var pair in axes.Reverse()) {
- var axis = pair.Value;
- var type = pair.Key;
- axis.IsAxisVisible = types.Contains(type);
- }
-
- UpdateAxesPosition();
- InvalidatePlot();
- }
-
- private void UpdateAxesPosition() {
- if (stackedAxes.Value) {
- var count = axes.Values.Count(axis => axis.IsAxisVisible);
- var start = 0.0;
- foreach (var pair in axes.Reverse()) {
- var axis = pair.Value;
- var type = pair.Key;
- axis.StartPosition = start;
- var delta = axis.IsAxisVisible ? 1.0 / count : 0;
- start += delta;
- axis.EndPosition = start;
- axis.PositionTier = 0;
- axis.MajorGridlineStyle = LineStyle.Solid;
- axis.MinorGridlineStyle = LineStyle.Solid;
- }
- } else {
- var tier = 0;
- foreach (var pair in axes.Reverse()) {
- var axis = pair.Value;
- var type = pair.Key;
- 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;
- }
- }
-
- }
-
- public void InvalidatePlot() {
- this.now = DateTime.UtcNow;
-
- foreach (var pair in axes) {
- var axis = pair.Value;
- var type = pair.Key;
- if (type == SensorType.Temperature)
- axis.Unit = unitManager.TemperatureUnit == TemperatureUnit.Celsius ?
- "°C" : "°F";
- }
-
- this.plot.InvalidatePlot(true);
- }
-
- }
}
diff --git a/GUI/PortForm.Designer.cs b/GUI/PortForm.Designer.cs
index 68a791b..f349844 100644
--- a/GUI/PortForm.Designer.cs
+++ b/GUI/PortForm.Designer.cs
@@ -43,7 +43,7 @@
this.portOKButton.TabIndex = 0;
this.portOKButton.Text = "OK";
this.portOKButton.UseVisualStyleBackColor = true;
- this.portOKButton.Click += new System.EventHandler(this.portOKButton_Click);
+ this.portOKButton.Click += new System.EventHandler(this.PortOKButton_Click);
//
// portCancelButton
//
@@ -54,7 +54,7 @@
this.portCancelButton.TabIndex = 1;
this.portCancelButton.Text = "Cancel";
this.portCancelButton.UseVisualStyleBackColor = true;
- this.portCancelButton.Click += new System.EventHandler(this.portCancelButton_Click);
+ this.portCancelButton.Click += new System.EventHandler(this.PortCancelButton_Click);
//
// label1
//
@@ -103,7 +103,7 @@
this.webServerLinkLabel.TabIndex = 7;
this.webServerLinkLabel.TabStop = true;
this.webServerLinkLabel.Text = "linkLabel1";
- this.webServerLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.webServerLinkLabel_LinkClicked);
+ this.webServerLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.WebServerLinkLabel_LinkClicked);
//
// portNumericUpDn
//
@@ -126,7 +126,7 @@
0,
0,
0});
- this.portNumericUpDn.ValueChanged += new System.EventHandler(this.portNumericUpDn_ValueChanged);
+ this.portNumericUpDn.ValueChanged += new System.EventHandler(this.PortNumericUpDn_ValueChanged);
//
// label5
//
diff --git a/GUI/PortForm.cs b/GUI/PortForm.cs
index 9357408..76a00d0 100644
--- a/GUI/PortForm.cs
+++ b/GUI/PortForm.cs
@@ -1,76 +1,78 @@
-/*
-
- 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) 2012 Prince Samuel
-
-*/
+// Mozilla Public License 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 System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
-namespace OpenHardwareMonitor.GUI {
- public partial class PortForm : Form {
- private MainForm parent;
- private string localIP;
- public PortForm(MainForm m) {
- InitializeComponent();
- parent = m;
-
- localIP = getLocalIP();
- }
-
- private void portTextBox_TextChanged(object sender, EventArgs e) {
-
- }
-
- private string getLocalIP() {
- IPHostEntry host;
- string localIP = "?";
- host = Dns.GetHostEntry(Dns.GetHostName());
- foreach (IPAddress ip in host.AddressList) {
- if (ip.AddressFamily == AddressFamily.InterNetwork) {
- localIP = ip.ToString();
+namespace OpenHardwareMonitor.GUI
+{
+ public partial class PortForm : Form
+ {
+ private readonly MainForm _parent;
+ private readonly string _localIP;
+ public PortForm(MainForm m)
+ {
+ InitializeComponent();
+ _parent = m;
+ _localIP = GetLocalIP();
}
- }
- return localIP;
- }
- 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 PortTextBox_TextChanged(object sender, EventArgs e)
+ {
- private void portOKButton_Click(object sender, EventArgs e) {
- parent.Server.ListenerPort = (int)portNumericUpDn.Value;
- this.Close();
- }
+ }
- private void portCancelButton_Click(object sender, EventArgs e) {
- this.Close();
- }
+ private string GetLocalIP()
+ {
+ IPHostEntry host;
+ string localIP = "?";
+ host = Dns.GetHostEntry(Dns.GetHostName());
+ foreach (IPAddress ip in host.AddressList)
+ {
+ if (ip.AddressFamily == AddressFamily.InterNetwork)
+ localIP = ip.ToString();
+ }
+ return localIP;
+ }
- private void PortForm_Load(object sender, EventArgs e) {
- portNumericUpDn.Value = parent.Server.ListenerPort;
- portNumericUpDn_ValueChanged(null, null);
- }
+ 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 webServerLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
- try {
- Process.Start(new ProcessStartInfo(e.Link.LinkData.ToString()));
- } catch { }
- }
+ private void PortOKButton_Click(object sender, EventArgs e)
+ {
+ _parent.Server.ListenerPort = (int)portNumericUpDn.Value;
+ Close();
+ }
- }
+ private void PortCancelButton_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private void PortForm_Load(object sender, EventArgs e)
+ {
+ 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 { }
+ }
+
+ }
}
diff --git a/GUI/ReportForm.Designer.cs b/GUI/ReportForm.Designer.cs
deleted file mode 100644
index 2a91893..0000000
--- a/GUI/ReportForm.Designer.cs
+++ /dev/null
@@ -1,246 +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) 2009-2010 Michael Möller
-
-*/
-
-namespace OpenHardwareMonitor.GUI {
- partial class ReportForm {
- ///
- /// 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.sendButton = new System.Windows.Forms.Button();
- this.exitButton = new System.Windows.Forms.Button();
- this.commentTextBox = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.commentPanel = new System.Windows.Forms.Panel();
- this.reportPanel = new System.Windows.Forms.Panel();
- this.reportTextBox = new System.Windows.Forms.TextBox();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.emailTextBox = new System.Windows.Forms.TextBox();
- this.titleLabel = new System.Windows.Forms.Label();
- this.commentPanel.SuspendLayout();
- this.reportPanel.SuspendLayout();
- this.SuspendLayout();
- //
- // sendButton
- //
- this.sendButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.sendButton.Location = new System.Drawing.Point(472, 627);
- this.sendButton.Name = "sendButton";
- this.sendButton.Size = new System.Drawing.Size(75, 23);
- this.sendButton.TabIndex = 2;
- this.sendButton.Text = "Send";
- this.sendButton.UseVisualStyleBackColor = true;
- this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
- //
- // exitButton
- //
- this.exitButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.exitButton.Location = new System.Drawing.Point(553, 627);
- this.exitButton.Name = "exitButton";
- this.exitButton.Size = new System.Drawing.Size(75, 23);
- this.exitButton.TabIndex = 3;
- this.exitButton.Text = "Cancel";
- this.exitButton.UseVisualStyleBackColor = true;
- //
- // commentTextBox
- //
- this.commentTextBox.AcceptsReturn = true;
- this.commentTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.commentTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.commentTextBox.Location = new System.Drawing.Point(4, 4);
- this.commentTextBox.Multiline = true;
- this.commentTextBox.Name = "commentTextBox";
- this.commentTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.commentTextBox.Size = new System.Drawing.Size(609, 77);
- this.commentTextBox.TabIndex = 1;
- //
- // label3
- //
- this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.label3.AutoEllipsis = true;
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(9, 39);
- this.label3.Margin = new System.Windows.Forms.Padding(3, 12, 3, 8);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(253, 13);
- this.label3.TabIndex = 5;
- this.label3.Text = "The following report has been created automatically:";
- //
- // label1
- //
- this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.label1.AutoEllipsis = true;
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(9, 505);
- this.label1.Margin = new System.Windows.Forms.Padding(3, 12, 3, 8);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(279, 13);
- this.label1.TabIndex = 6;
- this.label1.Text = "You can add additional information to the report (optional):";
- //
- // commentPanel
- //
- this.commentPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.commentPanel.BackColor = System.Drawing.SystemColors.Window;
- this.commentPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.commentPanel.Controls.Add(this.commentTextBox);
- this.commentPanel.Location = new System.Drawing.Point(12, 529);
- this.commentPanel.Margin = new System.Windows.Forms.Padding(3, 3, 3, 8);
- this.commentPanel.Name = "commentPanel";
- this.commentPanel.Padding = new System.Windows.Forms.Padding(4, 4, 1, 4);
- this.commentPanel.Size = new System.Drawing.Size(616, 87);
- this.commentPanel.TabIndex = 1;
- this.commentPanel.TabStop = true;
- //
- // reportPanel
- //
- this.reportPanel.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.reportPanel.BackColor = System.Drawing.SystemColors.Window;
- this.reportPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.reportPanel.Controls.Add(this.reportTextBox);
- this.reportPanel.Controls.Add(this.textBox1);
- this.reportPanel.Location = new System.Drawing.Point(12, 63);
- this.reportPanel.Name = "reportPanel";
- this.reportPanel.Padding = new System.Windows.Forms.Padding(4, 4, 1, 4);
- this.reportPanel.Size = new System.Drawing.Size(616, 394);
- this.reportPanel.TabIndex = 8;
- //
- // reportTextBox
- //
- this.reportTextBox.BackColor = System.Drawing.SystemColors.Window;
- this.reportTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.reportTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.reportTextBox.Location = new System.Drawing.Point(4, 4);
- this.reportTextBox.Multiline = true;
- this.reportTextBox.Name = "reportTextBox";
- this.reportTextBox.ReadOnly = true;
- this.reportTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.reportTextBox.Size = new System.Drawing.Size(609, 384);
- this.reportTextBox.TabIndex = 9;
- this.reportTextBox.TabStop = false;
- //
- // textBox1
- //
- this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.textBox1.Location = new System.Drawing.Point(4, 4);
- this.textBox1.Multiline = true;
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(609, 384);
- this.textBox1.TabIndex = 2;
- //
- // label2
- //
- this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.label2.AutoEllipsis = true;
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(9, 476);
- this.label2.Margin = new System.Windows.Forms.Padding(3, 12, 3, 8);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(171, 13);
- this.label2.TabIndex = 9;
- this.label2.Text = "Enter your email address (optional):";
- //
- // emailTextBox
- //
- this.emailTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.emailTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.emailTextBox.Location = new System.Drawing.Point(188, 473);
- this.emailTextBox.Name = "emailTextBox";
- this.emailTextBox.Size = new System.Drawing.Size(440, 20);
- this.emailTextBox.TabIndex = 0;
- //
- // titleLabel
- //
- this.titleLabel.AutoSize = true;
- this.titleLabel.Location = new System.Drawing.Point(9, 14);
- this.titleLabel.Name = "titleLabel";
- this.titleLabel.Size = new System.Drawing.Size(409, 13);
- this.titleLabel.TabIndex = 10;
- this.titleLabel.Text = "Help improve the Open Hardware Monitor by submitting a report about your hardware" +
- ".";
- //
- // ReportForm
- //
- this.AcceptButton = this.sendButton;
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.CancelButton = this.exitButton;
- this.ClientSize = new System.Drawing.Size(640, 662);
- this.ControlBox = false;
- this.Controls.Add(this.titleLabel);
- this.Controls.Add(this.emailTextBox);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.reportPanel);
- this.Controls.Add(this.commentPanel);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.exitButton);
- this.Controls.Add(this.sendButton);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "ReportForm";
- this.ShowIcon = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "Open Hardware Monitor";
- this.commentPanel.ResumeLayout(false);
- this.commentPanel.PerformLayout();
- this.reportPanel.ResumeLayout(false);
- this.reportPanel.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Button sendButton;
- private System.Windows.Forms.Button exitButton;
- private System.Windows.Forms.TextBox commentTextBox;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Panel commentPanel;
- private System.Windows.Forms.Panel reportPanel;
- private System.Windows.Forms.TextBox reportTextBox;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.TextBox emailTextBox;
- private System.Windows.Forms.Label titleLabel;
- }
-}
\ No newline at end of file
diff --git a/GUI/ReportForm.cs b/GUI/ReportForm.cs
deleted file mode 100644
index e61c053..0000000
--- a/GUI/ReportForm.cs
+++ /dev/null
@@ -1,77 +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) 2009-2010 Michael Möller
-
-*/
-
-using System;
-using System.Drawing;
-using System.IO;
-using System.Net;
-using System.Text;
-using System.Windows.Forms;
-
-namespace OpenHardwareMonitor.GUI {
- public partial class ReportForm : Form {
-
- private string report;
-
- public ReportForm() {
- InitializeComponent();
- try {
- titleLabel.Font = new Font(SystemFonts.DefaultFont, FontStyle.Bold);
- reportTextBox.Font = new Font(FontFamily.GenericMonospace,
- SystemFonts.DefaultFont.Size);
- } catch { }
- }
-
- public string Report {
- get { return report; }
- set {
- report = value;
- reportTextBox.Text = report;
- }
- }
-
- private void sendButton_Click(object sender, EventArgs e) {
- Version version = typeof(CrashForm).Assembly.GetName().Version;
- WebRequest request = WebRequest.Create(
- "http://openhardwaremonitor.org/report.php");
- request.Method = "POST";
- request.Timeout = 5000;
- request.ContentType = "application/x-www-form-urlencoded";
-
- string report =
- "type=hardware&" +
- "version=" + Uri.EscapeDataString(version.ToString()) + "&" +
- "report=" + Uri.EscapeDataString(reportTextBox.Text) + "&" +
- "comment=" + Uri.EscapeDataString(commentTextBox.Text) + "&" +
- "email=" + Uri.EscapeDataString(emailTextBox.Text);
- byte[] byteArray = Encoding.UTF8.GetBytes(report);
- request.ContentLength = byteArray.Length;
-
- try {
- Stream dataStream = request.GetRequestStream();
- dataStream.Write(byteArray, 0, byteArray.Length);
- dataStream.Close();
-
- WebResponse response = request.GetResponse();
- dataStream = response.GetResponseStream();
- StreamReader reader = new StreamReader(dataStream);
- string responseFromServer = reader.ReadToEnd();
- reader.Close();
- dataStream.Close();
- response.Close();
-
- Close();
- } catch (WebException) {
- MessageBox.Show("Sending the hardware report failed.", "Error",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
-}
diff --git a/GUI/ReportForm.resx b/GUI/ReportForm.resx
deleted file mode 100644
index ff31a6d..0000000
--- a/GUI/ReportForm.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/GUI/SensorGadget.cs b/GUI/SensorGadget.cs
index e7e8cd4..8558183 100644
--- a/GUI/SensorGadget.cs
+++ b/GUI/SensorGadget.cs
@@ -1,12 +1,7 @@
-/*
-
- 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) 2010-2012 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Collections.Generic;
@@ -14,663 +9,701 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.IO;
+using System.Linq;
using OpenHardwareMonitor.Hardware;
+using OpenHardwareMonitor.Utilities;
-namespace OpenHardwareMonitor.GUI {
- public class SensorGadget : Gadget {
-
- private UnitManager unitManager;
-
- private Image back = Utilities.EmbeddedResources.GetImage("gadget.png");
- private Image image = null;
- private Image fore = null;
- private Image barBack = Utilities.EmbeddedResources.GetImage("barback.png");
- private Image barFore = Utilities.EmbeddedResources.GetImage("barblue.png");
- private const int topBorder = 6;
- private const int bottomBorder = 7;
- private const int leftBorder = 6;
- private const int rightBorder = 7;
- private Image background = new Bitmap(1, 1);
-
- 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 IDictionary> sensors =
- new SortedDictionary>(new HardwareComparer());
-
- private PersistentSettings settings;
- private UserOption hardwareNames;
- private UserOption alwaysOnTop;
- private UserOption lockPositionAndSize;
-
- private Font largeFont;
- private Font smallFont;
- private Brush darkWhite;
- private StringFormat stringFormat;
- private StringFormat trimStringFormat;
- private StringFormat alignRightStringFormat;
-
- public SensorGadget(IComputer computer, PersistentSettings settings,
- UnitManager unitManager)
+namespace OpenHardwareMonitor.GUI
+{
+ public class SensorGadget : Gadget
{
- this.unitManager = unitManager;
- this.settings = settings;
- computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
- computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
+ private const int TopBorder = 6;
+ private const int BottomBorder = 7;
+ private const int LeftBorder = 6;
+ private const int RightBorder = 7;
- this.darkWhite = new SolidBrush(Color.FromArgb(0xF0, 0xF0, 0xF0));
+ 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("barblue.png");
+ private Image _background = new Bitmap(1, 1);
+ 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;
- this.stringFormat = new StringFormat();
- this.stringFormat.FormatFlags = StringFormatFlags.NoWrap;
+ private readonly IDictionary> _sensors = new SortedDictionary>(new HardwareComparer());
+ private readonly PersistentSettings _settings;
+ private readonly UserOption _hardwareNames;
- this.trimStringFormat = new StringFormat();
- this.trimStringFormat.Trimming = StringTrimming.EllipsisCharacter;
- this.trimStringFormat.FormatFlags = StringFormatFlags.NoWrap;
+ private Font _largeFont;
+ private Font _smallFont;
+ private Brush _darkWhite;
+ private StringFormat _stringFormat;
+ private StringFormat _trimStringFormat;
+ private StringFormat _alignRightStringFormat;
- this.alignRightStringFormat = new StringFormat();
- this.alignRightStringFormat.Alignment = StringAlignment.Far;
- this.alignRightStringFormat.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;
- } catch { }
- }
-
- if (File.Exists("gadget_bar_foreground.png")) {
- try {
- Image newBarColor = new Bitmap("gadget_bar_foreground.png");
- barFore.Dispose();
- barFore = newBarColor;
- } catch { }
- }
-
- this.Location = new Point(
- settings.GetValue("sensorGadget.Location.X", 100),
- settings.GetValue("sensorGadget.Location.Y", 100));
- LocationChanged += delegate(object sender, EventArgs e) {
- 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));
-
- ContextMenu contextMenu = new ContextMenu();
- MenuItem hardwareNamesItem = new MenuItem("Hardware Names");
- contextMenu.MenuItems.Add(hardwareNamesItem);
- MenuItem fontSizeMenu = new MenuItem("Font Size");
- for (int i = 0; i < 4; 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;
- default: throw new NotImplementedException();
- }
- MenuItem item = new MenuItem(name);
- item.Checked = fontSize == size;
- item.Click += delegate(object sender, EventArgs e) {
- SetFontSize(size);
- settings.SetValue("sensorGadget.FontSize", size);
- foreach (MenuItem mi in fontSizeMenu.MenuItems)
- mi.Checked = mi == item;
- };
- fontSizeMenu.MenuItems.Add(item);
- }
- contextMenu.MenuItems.Add(fontSizeMenu);
- contextMenu.MenuItems.Add(new MenuItem("-"));
- MenuItem lockItem = new MenuItem("Lock Position and Size");
- contextMenu.MenuItems.Add(lockItem);
- contextMenu.MenuItems.Add(new MenuItem("-"));
- MenuItem alwaysOnTopItem = new MenuItem("Always on Top");
- contextMenu.MenuItems.Add(alwaysOnTopItem);
- MenuItem opacityMenu = new MenuItem("Opacity");
- contextMenu.MenuItems.Add(opacityMenu);
- Opacity = (byte)settings.GetValue("sensorGadget.Opacity", 255);
- for (int i = 0; i < 5; i++) {
- MenuItem item = new MenuItem((20 * (i + 1)).ToString() + " %");
- byte o = (byte)(51 * (i + 1));
- item.Checked = Opacity == o;
- item.Click += delegate(object sender, EventArgs e) {
- Opacity = o;
- settings.SetValue("sensorGadget.Opacity", Opacity);
- foreach (MenuItem mi in opacityMenu.MenuItems)
- mi.Checked = mi == item;
- };
- opacityMenu.MenuItems.Add(item);
- }
- this.ContextMenu = contextMenu;
-
- hardwareNames = new UserOption("sensorGadget.Hardwarenames", true,
- hardwareNamesItem, settings);
- hardwareNames.Changed += delegate(object sender, EventArgs e) {
- Resize();
- };
-
- alwaysOnTop = new UserOption("sensorGadget.AlwaysOnTop", false,
- alwaysOnTopItem, settings);
- alwaysOnTop.Changed += delegate(object sender, EventArgs e) {
- this.AlwaysOnTop = alwaysOnTop.Value;
- };
- lockPositionAndSize = new UserOption("sensorGadget.LockPositionAndSize",
- false, lockItem, settings);
- lockPositionAndSize.Changed += delegate(object sender, EventArgs e) {
- this.LockPositionAndSize = lockPositionAndSize.Value;
- };
-
- 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;
- return;
- }
- };
-
- SizeChanged += delegate(object sender, EventArgs e) {
- settings.SetValue("sensorGadget.Width", Size.Width);
- Redraw();
- };
-
- VisibleChanged += delegate(object sender, EventArgs e) {
- 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))
+ public SensorGadget(IComputer computer, PersistentSettings settings, UnitManager unitManager)
{
- Location = new Point(
- screen.WorkingArea.Width / 2 - bounds.Width / 2,
- screen.WorkingArea.Height / 2 - bounds.Height / 2);
- }
- };
+ _unitManager = unitManager;
+ _settings = settings;
+ computer.HardwareAdded += HardwareAdded;
+ computer.HardwareRemoved += HardwareRemoved;
- MouseDoubleClick += delegate(object obj, MouseEventArgs args) {
- SendHideShowCommand();
- };
- }
+ _darkWhite = new SolidBrush(Color.FromArgb(0xF0, 0xF0, 0xF0));
+ _stringFormat = new StringFormat { FormatFlags = StringFormatFlags.NoWrap };
+ _trimStringFormat = new StringFormat { Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap };
+ _alignRightStringFormat = new StringFormat { Alignment = StringAlignment.Far, FormatFlags = StringFormatFlags.NoWrap };
- public override void Dispose() {
-
- largeFont.Dispose();
- largeFont = null;
-
- smallFont.Dispose();
- smallFont = null;
-
- darkWhite.Dispose();
- darkWhite = 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;
-
- 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) {
- hardware.SensorAdded -= new SensorEventHandler(SensorAdded);
- hardware.SensorRemoved -= new SensorEventHandler(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 += new SensorEventHandler(SensorAdded);
- hardware.SensorRemoved += new SensorEventHandler(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) {
- foreach (IList list in sensors.Values)
- if (list.Contains(sensor))
- return true;
- return false;
- }
-
- public void Add(ISensor sensor) {
- if (Contains(sensor)) {
- return;
- } else {
- // get the right hardware
- IHardware hardware = sensor.Hardware;
- while (hardware.Parent != null)
- hardware = hardware.Parent;
-
- // get the sensor list associated with the hardware
- IList list;
- if (!sensors.TryGetValue(hardware, out 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() {
- if (HideShowCommand != null)
- HideShowCommand(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 Resize() {
- Resize(this.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;
- this.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 (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, 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));
- }
- }
- }
-
- g.DrawImageUnscaled(background, 0, 0);
- }
-
- private void DrawProgress(Graphics g, float x, float y,
- float width, float height, float progress)
- {
- 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) {
- 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, Brushes.White,
- 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, Brushes.White,
- 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.Value.HasValue)
- {
- string formatted;
-
- if (sensor.Value.HasValue) {
- string format = "";
- switch (sensor.SensorType) {
- case SensorType.Voltage:
- format = "{0:F3} V";
- 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;
- }
-
- if (sensor.SensorType == SensorType.Temperature &&
- unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
- formatted = string.Format("{0:F1} °F",
- UnitManager.CelsiusToFahrenheit(sensor.Value));
- } 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 = string.Format("{0:F0} bps", sensor.Value);
- else if(sensor.Value < 1048576)
- result = string.Format("{0:F1} Kbps", sensor.Value / 1024);
- else if(sensor.Value < 1073741824)
- result = string.Format("{0:F1} Mbps", sensor.Value / 1048576);
- else
- result = string.Format("{0:F1} Gbps", sensor.Value / 1073741824);
- }
- break;
- }
- }
- break;
- default:{
- if (sensor.Value < 1048576)
- result = string.Format("{0:F1} KB/s", sensor.Value / 1024);
- else
- result = string.Format("{0:F1} MB/s", sensor.Value / 1048576);
- }
- break;
+ if (File.Exists("gadget_background.png"))
+ {
+ try
+ {
+ Image newBack = new Bitmap("gadget_background.png");
+ _back.Dispose();
+ _back = newBack;
}
- formatted = result;
- } else {
- formatted = string.Format(format, sensor.Value);
- }
- } else {
- formatted = "-";
+ catch { }
}
- g.DrawString(formatted, smallFont, darkWhite,
- new RectangleF(-1, y - 1, w - rightMargin + 3, 0),
- alignRightStringFormat);
+ if (File.Exists("gadget_image.png"))
+ {
+ try
+ {
+ _image = new Bitmap("gadget_image.png");
+ }
+ catch { }
+ }
- 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);
+ if (File.Exists("gadget_foreground.png"))
+ {
+ try
+ {
+ _fore = new Bitmap("gadget_foreground.png");
+ }
+ catch { }
+ }
- remainingWidth = w - progressWidth - rightMargin;
- }
-
- remainingWidth -= leftMargin + 2;
- if (remainingWidth > 0) {
- g.DrawString(sensor.Name, smallFont, darkWhite,
- new RectangleF(leftMargin - 1, y - 1, remainingWidth, 0),
- trimStringFormat);
- }
+ if (File.Exists("gadget_bar_background.png"))
+ {
+ try
+ {
+ Image newBarBack = new Bitmap("gadget_bar_background.png");
+ _barBack.Dispose();
+ _barBack = newBarBack;
+ }
+ catch { }
+ }
- y += sensorLineHeight;
+ if (File.Exists("gadget_bar_foreground.png"))
+ {
+ try
+ {
+ Image newBarColor = new Bitmap("gadget_bar_foreground.png");
+ _barFore.Dispose();
+ _barFore = newBarColor;
+ }
+ 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));
+
+ ContextMenu contextMenu = new ContextMenu();
+ MenuItem hardwareNamesItem = new MenuItem("Hardware Names");
+ contextMenu.MenuItems.Add(hardwareNamesItem);
+ MenuItem fontSizeMenu = new MenuItem("Font Size");
+ for (int i = 0; i < 4; 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;
+ default: throw new NotImplementedException();
+ }
+
+ MenuItem item = new MenuItem(name) { Checked = _fontSize == size };
+ item.Click += delegate
+ {
+ SetFontSize(size);
+ settings.SetValue("sensorGadget.FontSize", size);
+ foreach (MenuItem mi in fontSizeMenu.MenuItems)
+ mi.Checked = mi == item;
+ };
+ fontSizeMenu.MenuItems.Add(item);
+ }
+ contextMenu.MenuItems.Add(fontSizeMenu);
+ contextMenu.MenuItems.Add(new MenuItem("-"));
+ MenuItem lockItem = new MenuItem("Lock Position and Size");
+ contextMenu.MenuItems.Add(lockItem);
+ contextMenu.MenuItems.Add(new MenuItem("-"));
+ MenuItem alwaysOnTopItem = new MenuItem("Always on Top");
+ contextMenu.MenuItems.Add(alwaysOnTopItem);
+ MenuItem opacityMenu = new MenuItem("Opacity");
+ contextMenu.MenuItems.Add(opacityMenu);
+ Opacity = (byte)settings.GetValue("sensorGadget.Opacity", 255);
+
+ for (int i = 0; i < 5; i++)
+ {
+ MenuItem item = new MenuItem((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 (MenuItem mi in opacityMenu.MenuItems)
+ mi.Checked = mi == item;
+ };
+ opacityMenu.MenuItems.Add(item);
+ }
+ ContextMenu = contextMenu;
+
+ _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;
+ };
+
+ 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;
+
+ _darkWhite.Dispose();
+ _darkWhite = 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;
+
+ _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)
+ {
+ 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)
+ {
+ 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 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 (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, _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));
+ }
+ }
+ }
+
+ g.DrawImageUnscaled(_background, 0, 0);
+ }
+
+ private void DrawProgress(Graphics g, float x, float y, float width, float height, float progress)
+ {
+ 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)
+ {
+ 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, Brushes.White,
+ 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, Brushes.White, 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.Value.HasValue)
+ {
+ string formatted;
+
+ if (sensor.Value.HasValue)
+ {
+ string format = "";
+ switch (sensor.SensorType)
+ {
+ case SensorType.Voltage:
+ format = "{0:F3} V";
+ 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;
+ }
+
+ 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
+ {
+ formatted = string.Format(format, sensor.Value);
+ }
+ }
+ else
+ {
+ formatted = "-";
+ }
+
+ g.DrawString(formatted, _smallFont, _darkWhite, 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, _darkWhite, new RectangleF(_leftMargin - 1, y - 1, remainingWidth, 0), _trimStringFormat);
+ }
+ y += _sensorLineHeight;
+ }
+ }
+ }
+
+ 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);
+ }
}
- }
}
-
- private class HardwareComparer : IComparer {
- public int Compare(IHardware x, IHardware y) {
- if (x == null && y == null)
- return 0;
- if (x == 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/GUI/SensorNode.cs b/GUI/SensorNode.cs
index 5c5927e..4c777e4 100644
--- a/GUI/SensorNode.cs
+++ b/GUI/SensorNode.cs
@@ -1,180 +1,190 @@
-/*
-
- 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) 2009-2016 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Drawing;
-using System.Collections.Generic;
using OpenHardwareMonitor.Hardware;
using OpenHardwareMonitor.Utilities;
-namespace OpenHardwareMonitor.GUI {
- public class SensorNode : Node {
-
- private ISensor sensor;
- private PersistentSettings settings;
- private UnitManager unitManager;
- public string format;
- private bool plot = false;
- private Color? penColor = null;
+namespace OpenHardwareMonitor.GUI
+{
+ public class SensorNode : Node
+ {
+ private readonly PersistentSettings _settings;
+ private readonly UnitManager _unitManager;
+ private bool _plot;
+ private Color? _penColor;
+ public string Format { get; set; } = "";
- public string ValueToString(float? value) {
- if (value.HasValue) {
- if (sensor.SensorType == SensorType.Temperature &&
- unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
- return string.Format("{0:F1} °F", value * 1.8 + 32);
- } else if(sensor.SensorType == 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 = string.Format("{0:F0} bps", value);
- else if (value < 1048576)
- result = string.Format("{0:F1} Kbps",value/1024);
- else if (value < 1073741824)
- result = string.Format("{0:F1} Mbps",value/1048576);
- else
- result = string.Format("{0:F1} Gbps",value/ 1073741824);
- } break;
- }
+ 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:
+ {
+ if (value < 1048576)
+ result = $"{value / 1024:F1} KB/s";
+ else
+ result = $"{value / 1048576:F1} MB/s";
+ }
+ break;
+ }
+ return result;
+ }
+ default:
+ return string.Format(Format, value);
+ }
}
- break;
- default:{
- if (value<1048576)
- result = string.Format("{0:F1} KB/s",value/1024);
- else
- result = string.Format("{0:F1} MB/s",value/1048576);
+
+ return "-";
+ }
+
+ 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.Clock: Format = "{0:F0} 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:F0} 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;
}
- break;
- }
- return result;
- } else {
- return string.Format(format, value);
- }
- } else
- return "-";
+
+ 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 override string Text
+ {
+ get { return Sensor.Name; }
+ set { Sensor.Name = value; }
+ }
+
+ public override bool IsVisible
+ {
+ get { return base.IsVisible; }
+ set
+ {
+ base.IsVisible = value;
+ _settings.SetValue(new Identifier(Sensor.Identifier, "hidden").ToString(), !value);
+ }
+ }
+
+ 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 event EventHandler PlotSelectionChanged;
+
+ public ISensor Sensor { get; }
+
+ public string Value
+ {
+ get { return ValueToString(Sensor.Value); }
+ }
+
+ public string Min
+ {
+ get { return ValueToString(Sensor.Min); }
+ }
+
+ public string Max
+ {
+ get { return ValueToString(Sensor.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();
+ }
}
-
- public SensorNode(ISensor sensor, PersistentSettings settings,
- UnitManager unitManager) : base() {
- this.sensor = sensor;
- this.settings = settings;
- this.unitManager = unitManager;
- switch (sensor.SensorType) {
- case SensorType.Voltage: format = "{0:F3} V"; break;
- case SensorType.Clock: format = "{0:F0} 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:F0} 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;
- }
-
- bool hidden = settings.GetValue(new Identifier(sensor.Identifier,
- "hidden").ToString(), sensor.IsDefaultHidden);
- base.IsVisible = !hidden;
-
- this.Plot = settings.GetValue(new Identifier(sensor.Identifier,
- "plot").ToString(), false);
-
- string id = new Identifier(sensor.Identifier, "penColor").ToString();
- if (settings.Contains(id))
- this.PenColor = settings.GetValue(id, Color.Black);
- }
-
- public override string Text {
- get { return sensor.Name; }
- set { sensor.Name = value; }
- }
-
- public override bool IsVisible {
- get { return base.IsVisible; }
- set {
- base.IsVisible = value;
- settings.SetValue(new Identifier(sensor.Identifier,
- "hidden").ToString(), !value);
- }
- }
-
- 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);
-
- if (PlotSelectionChanged != null)
- PlotSelectionChanged(this, null);
- }
- }
-
- public bool Plot {
- get { return plot; }
- set {
- plot = value;
- settings.SetValue(new Identifier(sensor.Identifier, "plot").ToString(),
- value);
- if (PlotSelectionChanged != null)
- PlotSelectionChanged(this, null);
- }
- }
-
- public event EventHandler PlotSelectionChanged;
-
- public ISensor Sensor {
- get { return sensor; }
- }
-
- public string Value {
- get { return ValueToString(sensor.Value); }
- }
-
- public string Min {
- get { return ValueToString(sensor.Min); }
- }
-
- public string Max {
- get { return ValueToString(sensor.Max); }
- }
-
- public override bool Equals(System.Object obj) {
- if (obj == null)
- return false;
-
- SensorNode s = obj as SensorNode;
- if (s == null)
- return false;
-
- return (sensor == s.sensor);
- }
-
- public override int GetHashCode() {
- return sensor.GetHashCode();
- }
-
- }
}
diff --git a/GUI/SensorNotifyIcon.cs b/GUI/SensorNotifyIcon.cs
index 2466f5c..a720c3a 100644
--- a/GUI/SensorNotifyIcon.cs
+++ b/GUI/SensorNotifyIcon.cs
@@ -1,12 +1,7 @@
-/*
-
- 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) 2009-2012 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Drawing;
@@ -18,302 +13,286 @@ using System.Windows.Forms;
using OpenHardwareMonitor.Hardware;
using OpenHardwareMonitor.Utilities;
-namespace OpenHardwareMonitor.GUI {
- public class SensorNotifyIcon : IDisposable {
-
- private UnitManager unitManager;
-
- private ISensor sensor;
- private NotifyIconAdv notifyIcon;
- private Bitmap bitmap;
- private Graphics graphics;
- private Color color;
- private Color darkColor;
- private Brush brush;
- private Brush darkBrush;
- private Pen pen;
- private Font font;
- private Font smallFont;
-
- public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
- bool balloonTip, PersistentSettings settings, UnitManager unitManager)
+namespace OpenHardwareMonitor.GUI
+{
+ public class SensorNotifyIcon : IDisposable
{
- this.unitManager = unitManager;
- this.sensor = sensor;
- this.notifyIcon = new NotifyIconAdv();
+ 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;
- 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);
-
- this.pen = new Pen(Color.FromArgb(96, Color.Black));
+ public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor, PersistentSettings settings, UnitManager unitManager)
+ {
+ _unitManager = unitManager;
+ Sensor = sensor;
+ _notifyIcon = new NotifyIconAdv();
- ContextMenu contextMenu = new ContextMenu();
- MenuItem hideShowItem = new MenuItem("Hide/Show");
- hideShowItem.Click += delegate(object obj, EventArgs args) {
- sensorSystemTray.SendHideShowCommand();
- };
- contextMenu.MenuItems.Add(hideShowItem);
- contextMenu.MenuItems.Add(new MenuItem("-"));
- MenuItem removeItem = new MenuItem("Remove Sensor");
- removeItem.Click += delegate(object obj, EventArgs args) {
- sensorSystemTray.Remove(this.sensor);
- };
- contextMenu.MenuItems.Add(removeItem);
- MenuItem colorItem = new MenuItem("Change Color...");
- colorItem.Click += delegate(object obj, EventArgs args) {
- ColorDialog dialog = new ColorDialog();
- dialog.Color = Color;
- if (dialog.ShowDialog() == DialogResult.OK) {
- Color = dialog.Color;
- settings.SetValue(new Identifier(sensor.Identifier,
- "traycolor").ToString(), Color);
+ 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));
+ ContextMenu contextMenu = new ContextMenu();
+ MenuItem hideShowItem = new MenuItem("Hide/Show");
+ hideShowItem.Click += delegate
+ {
+ sensorSystemTray.SendHideShowCommand();
+ };
+ contextMenu.MenuItems.Add(hideShowItem);
+ contextMenu.MenuItems.Add(new MenuItem("-"));
+ MenuItem removeItem = new MenuItem("Remove Sensor");
+ removeItem.Click += delegate
+ {
+ sensorSystemTray.Remove(Sensor);
+ };
+ contextMenu.MenuItems.Add(removeItem);
+ MenuItem colorItem = new MenuItem("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);
+ }
+ };
+ contextMenu.MenuItems.Add(colorItem);
+ contextMenu.MenuItems.Add(new MenuItem("-"));
+ MenuItem exitItem = new MenuItem("Exit");
+ exitItem.Click += delegate
+ {
+ sensorSystemTray.SendExitCommand();
+ };
+ contextMenu.MenuItems.Add(exitItem);
+ _notifyIcon.ContextMenu = contextMenu;
+ _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;
+ }
}
- };
- contextMenu.MenuItems.Add(colorItem);
- contextMenu.MenuItems.Add(new MenuItem("-"));
- MenuItem exitItem = new MenuItem("Exit");
- exitItem.Click += delegate(object obj, EventArgs args) {
- sensorSystemTray.SendExitCommand();
- };
- contextMenu.MenuItems.Add(exitItem);
- this.notifyIcon.ContextMenu = contextMenu;
- this.notifyIcon.DoubleClick += delegate(object obj, EventArgs args) {
- 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;
- }
+ public ISensor Sensor { get; }
- // 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);
+ 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();
+ }
+ }
- // make sure it does never get smaller than 16x16
- width = width < 16 ? 16 : width;
- height = height < 16 ? 16 : height;
+ public void Dispose()
+ {
+ Icon icon = _notifyIcon.Icon;
+ _notifyIcon.Icon = null;
+ icon?.Dispose();
+ _notifyIcon.Dispose();
- // 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;
- }
+ _brush?.Dispose();
+ _darkBrush?.Dispose();
+ _pen.Dispose();
+ _graphics.Dispose();
+ _bitmap.Dispose();
+ _font.Dispose();
+ _smallFont.Dispose();
+ }
- this.font = new Font(family,
- baseSize * width / 16.0f, GraphicsUnit.Pixel);
- this.smallFont = new Font(family,
- 0.75f * baseSize * width / 16.0f, GraphicsUnit.Pixel);
+ private string GetString()
+ {
+ if (!Sensor.Value.HasValue)
+ return "-";
- this.bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
- this.graphics = Graphics.FromImage(this.bitmap);
+ switch (Sensor.SensorType)
+ {
+ case SensorType.Voltage:
+ return $"{Sensor.Value:F1}";
+ case SensorType.Clock:
+ return $"{1e-3f * Sensor.Value:F1}";
+ case SensorType.Load:
+ return $"{Sensor.Value:F0}";
+ case SensorType.Temperature:
+ return _unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit ? $"{UnitManager.CelsiusToFahrenheit(Sensor.Value):F0}" : $"{Sensor.Value:F0}";
+ case SensorType.Fan:
+ return $"{1e-3f * Sensor.Value:F1}";
+ case SensorType.Flow:
+ return $"{1e-3f * Sensor.Value:F1}";
+ case SensorType.Control:
+ return $"{Sensor.Value:F0}";
+ case SensorType.Level:
+ return $"{Sensor.Value:F0}";
+ case SensorType.Power:
+ return $"{Sensor.Value:F0}";
+ case SensorType.Data:
+ return $"{Sensor.Value:F0}";
+ case SensorType.Factor:
+ return $"{Sensor.Value:F1}";
+ }
+ return "-";
+ }
- if (Environment.OSVersion.Version.Major > 5) {
- this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
- this.graphics.SmoothingMode = SmoothingMode.HighQuality;
- }
+ 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);
+ TextRenderer.DrawText(_graphics, text, small ? _smallFont : _font, new Point(-2, small ? 1 : 0), Color.White, Color.Black);
+ 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);
+
+ for (int i = 0; i < bytes.Length; i += 4)
+ {
+ byte blue = bytes[i];
+ byte green = bytes[i + 1];
+ byte 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 = 0.16f * (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);
+
+ BitmapData data = _bitmap.LockBits(new Rectangle(0, 0, _bitmap.Width, _bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
+ byte[] bytes = new byte[_bitmap.Width * _bitmap.Height * 4];
+ Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);
+ _bitmap.UnlockBits(data);
+
+ return IconFactory.Create(bytes, _bitmap.Width, _bitmap.Height, PixelFormat.Format32bppArgb);
+ }
+
+ 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?.Dispose();
+
+ string format = "";
+ switch (Sensor.SensorType)
+ {
+ case SensorType.Voltage: format = "\n{0}: {1:F2} V"; 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;
+ }
+ 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;
+ }
}
-
- public ISensor Sensor {
- get { return sensor; }
- }
-
- public Color Color {
- get { return color; }
- set {
- this.color = value;
- this.darkColor = Color.FromArgb(255,
- this.color.R / 3,
- this.color.G / 3,
- this.color.B / 3);
- Brush brush = this.brush;
- this.brush = new SolidBrush(this.color);
- if (brush != null)
- brush.Dispose();
- Brush darkBrush = this.darkBrush;
- this.darkBrush = new SolidBrush(this.darkColor);
- if (darkBrush != null)
- darkBrush.Dispose();
- }
- }
-
- public void Dispose() {
- Icon icon = notifyIcon.Icon;
- notifyIcon.Icon = null;
- if (icon != null)
- icon.Dispose();
- notifyIcon.Dispose();
-
- if (brush != null)
- brush.Dispose();
- if (darkBrush != null)
- 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.Voltage:
- return string.Format("{0:F1}", sensor.Value);
- case SensorType.Clock:
- return string.Format("{0:F1}", 1e-3f * sensor.Value);
- case SensorType.Load:
- return string.Format("{0:F0}", sensor.Value);
- case SensorType.Temperature:
- if (unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit)
- return string.Format("{0:F0}",
- UnitManager.CelsiusToFahrenheit(sensor.Value));
- else
- return string.Format("{0:F0}", sensor.Value);
- case SensorType.Fan:
- return string.Format("{0:F1}", 1e-3f * sensor.Value);
- case SensorType.Flow:
- return string.Format("{0:F1}", 1e-3f * sensor.Value);
- case SensorType.Control:
- return string.Format("{0:F0}", sensor.Value);
- case SensorType.Level:
- return string.Format("{0:F0}", sensor.Value);
- case SensorType.Power:
- return string.Format("{0:F0}", sensor.Value);
- case SensorType.Data:
- return string.Format("{0:F0}", sensor.Value);
- case SensorType.Factor:
- return string.Format("{0:F1}", sensor.Value);
- }
- 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);
- TextRenderer.DrawText(graphics, text, small ? smallFont : font,
- new Point(-2, small ? 1 : 0), Color.White, Color.Black);
-
- 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 = 0.16f * (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);
-
- BitmapData data = bitmap.LockBits(
- new Rectangle(0, 0, bitmap.Width, bitmap.Height),
- ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
- byte[] bytes = new byte[bitmap.Width * bitmap.Height * 4];
- Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);
- bitmap.UnlockBits(data);
-
- return IconFactory.Create(bytes, bitmap.Width, bitmap.Height,
- PixelFormat.Format32bppArgb);
- }
-
- 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;
- }
-
- if (icon != null)
- icon.Dispose();
-
- string format = "";
- switch (sensor.SensorType) {
- case SensorType.Voltage: format = "\n{0}: {1:F2} V"; 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;
- }
- 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/GUI/ShowDesktop.cs b/GUI/ShowDesktop.cs
index bdec90e..3b04b4f 100644
--- a/GUI/ShowDesktop.cs
+++ b/GUI/ShowDesktop.cs
@@ -1,145 +1,136 @@
-/*
-
- 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) 2010 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
-namespace OpenHardwareMonitor.GUI {
- public class ShowDesktop {
- private static ShowDesktop instance = new ShowDesktop();
+namespace OpenHardwareMonitor.GUI
+{
+ public class ShowDesktop
+ {
+ public delegate void ShowDesktopChangedEventHandler(bool showDesktop);
+ private event ShowDesktopChangedEventHandler ShowDesktopChangedEvent;
+ private readonly System.Threading.Timer _timer;
+ private bool _showDesktop;
+ private readonly string _referenceWindowCaption = "OpenHardwareMonitorShowDesktopReferenceWindow";
- public delegate void ShowDesktopChangedEventHandler(bool showDesktop);
-
- private event ShowDesktopChangedEventHandler ShowDesktopChangedEvent;
+ private ShowDesktop()
+ {
+ // create a reference window to detect show desktop
+ NativeWindow 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);
- private System.Threading.Timer timer;
- private bool showDesktop = false;
- private NativeWindow referenceWindow;
- private string referenceWindowCaption =
- "OpenHardwareMonitorShowDesktopReferenceWindow";
-
- private ShowDesktop() {
- // create a reference window to detect show desktop
- referenceWindow = new NativeWindow();
- CreateParams cp = new CreateParams();
- cp.ExStyle = GadgetWindow.WS_EX_TOOLWINDOW;
- cp.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);
- }
-
- 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;
-
- int shellId;
- NativeMethods.GetWindowThreadProcessId(shellWindow, out shellId);
-
- IntPtr workerWindow = IntPtr.Zero;
- while ((workerWindow = NativeMethods.FindWindowEx(
- IntPtr.Zero, workerWindow, "WorkerW", null)) != IntPtr.Zero) {
-
- int workerId;
- NativeMethods.GetWindowThreadProcessId(workerWindow, out 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;
- }
+ // start a repeated timer to detect "Show Desktop" events
+ _timer = new System.Threading.Timer(OnTimer, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
}
- }
- 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;
- if (ShowDesktopChangedEvent != null) {
- ShowDesktopChangedEvent(showDesktop);
+ 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);
+ }
+ }
+
+ public static ShowDesktop Instance { get; } = new ShowDesktop();
+
+ // 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();
+ }
+ }
+
+ 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);
}
- }
}
-
- public static ShowDesktop Instance {
- get { return instance; }
- }
-
- // 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();
- }
- }
-
- 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);
- }
- }
}
diff --git a/GUI/SplitContainerAdv.cs b/GUI/SplitContainerAdv.cs
index 2eb5c9e..1cfedde 100644
--- a/GUI/SplitContainerAdv.cs
+++ b/GUI/SplitContainerAdv.cs
@@ -1,123 +1,138 @@
-/*
-
- 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) 2009-2010 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
-using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
-namespace OpenHardwareMonitor.GUI {
- public class SplitContainerAdv : SplitContainer {
+namespace OpenHardwareMonitor.GUI
+{
+ public class SplitContainerAdv : SplitContainer
+ {
+ private int _delta;
+ private Border3DStyle _border3DStyle = Border3DStyle.Raised;
+ private Color _bgColor = SystemColors.Control;
- private int delta = 0;
- private Border3DStyle border3DStyle = Border3DStyle.Raised;
- private Color color = SystemColors.Control;
-
- public SplitContainerAdv()
- : base() {
- SetStyle(ControlStyles.ResizeRedraw, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- SetStyle(ControlStyles.ContainerControl, true);
- UpdateStyles();
- }
-
- protected override void OnPaint(PaintEventArgs e) {
- base.OnPaint(e);
-
- Graphics g = e.Graphics;
- Rectangle r = SplitterRectangle;
- using (SolidBrush brush = new SolidBrush(color))
- g.FillRectangle(brush, r);
- ControlPaint.DrawBorder3D(g, r, border3DStyle);
- }
-
- protected override void OnKeyDown(KeyEventArgs e) {
- if (!base.IsSplitterFixed) {
- if (e.KeyData == Keys.Right || e.KeyData == Keys.Down) {
- SplitterDistance += SplitterIncrement;
- } else if (e.KeyData == Keys.Left || e.KeyData == Keys.Up) {
- SplitterDistance -= SplitterIncrement;
+ public SplitContainerAdv()
+ {
+ SetStyle(ControlStyles.ResizeRedraw, true);
+ SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle(ControlStyles.UserPaint, true);
+ SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
+ SetStyle(ControlStyles.ContainerControl, true);
+ UpdateStyles();
}
- Invalidate();
- }
- }
- protected override void OnMouseDown(MouseEventArgs e) {
- if (Orientation == Orientation.Vertical) {
- delta = this.SplitterDistance - e.X;
- Cursor.Current = Cursors.VSplit;
- } else {
- delta = this.SplitterDistance - e.Y;
- Cursor.Current = Cursors.HSplit;
- }
- base.IsSplitterFixed = true;
- }
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ base.OnPaint(e);
+ Graphics g = e.Graphics;
+ Rectangle r = SplitterRectangle;
- protected override void OnMouseMove(MouseEventArgs e) {
- if (base.IsSplitterFixed) {
- if (e.Button == MouseButtons.Left) {
- if (Orientation == Orientation.Vertical) {
- if (e.X > 0 && e.X < Width) {
- SplitterDistance = e.X + delta < 0 ? 0 : e.X + delta;
+ using (SolidBrush brush = new SolidBrush(_bgColor))
+ g.FillRectangle(brush, r);
+
+ ControlPaint.DrawBorder3D(g, r, _border3DStyle);
+ }
+
+ 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();
}
- } else {
- if (e.Y > 0 && e.Y < Height) {
- SplitterDistance = e.Y + delta < 0 ? 0 : e.Y + delta;
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ if (Orientation == Orientation.Vertical)
+ {
+ _delta = SplitterDistance - e.X;
+ Cursor.Current = Cursors.VSplit;
}
- }
- } else {
- base.IsSplitterFixed = false;
+ else
+ {
+ _delta = SplitterDistance - e.Y;
+ Cursor.Current = Cursors.HSplit;
+ }
+ IsSplitterFixed = true;
}
- Invalidate();
- } else {
- if (SplitterRectangle.Contains(e.Location)) {
- Cursor = Orientation == Orientation.Vertical ?
- Cursors.VSplit : Cursors.HSplit;
+
+ 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;
- }
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+ Cursor = Cursors.Default;
+ }
- protected override void OnMouseUp(MouseEventArgs e) {
- delta = 0;
- base.IsSplitterFixed = false;
- Cursor.Current = Cursors.Default;
- }
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ _delta = 0;
+ IsSplitterFixed = false;
+ Cursor.Current = Cursors.Default;
+ }
- public Border3DStyle Border3DStyle {
- get { return border3DStyle; }
- set {
- border3DStyle = value;
- Invalidate(false);
- }
- }
+ public Border3DStyle Border3DStyle
+ {
+ get { return _border3DStyle; }
+ set
+ {
+ _border3DStyle = value;
+ Invalidate(false);
+ }
+ }
- public Color Color {
- get { return color; }
- set {
- color = value;
- Invalidate(false);
- }
+ public Color Color
+ {
+ get { return _bgColor; }
+ set
+ {
+ _bgColor = value;
+ Invalidate(false);
+ }
+ }
}
-
- public new bool IsSplitterFixed {
- get {
- return false;
- }
- }
-
- }
}
diff --git a/GUI/StartupManager.cs b/GUI/StartupManager.cs
index f645f16..0ba07c7 100644
--- a/GUI/StartupManager.cs
+++ b/GUI/StartupManager.cs
@@ -1,15 +1,9 @@
-/*
-
- 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) 2009-2010 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
-using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
@@ -18,178 +12,205 @@ using System.Windows.Forms;
using Microsoft.Win32;
using OpenHardwareMonitor.TaskScheduler;
-namespace OpenHardwareMonitor.GUI {
- public class StartupManager {
+namespace OpenHardwareMonitor.GUI
+{
+ public class StartupManager
+ {
+ private readonly TaskSchedulerClass _scheduler;
+ private bool _startup;
+ private const string REGISTRY_RUN = @"Software\Microsoft\Windows\CurrentVersion\Run";
- private TaskSchedulerClass scheduler;
- private bool startup;
- private bool isAvailable;
-
- private const string REGISTRY_RUN =
- @"Software\Microsoft\Windows\CurrentVersion\Run";
-
- private bool IsAdministrator() {
- try {
- WindowsIdentity identity = WindowsIdentity.GetCurrent();
- WindowsPrincipal principal = new WindowsPrincipal(identity);
- return principal.IsInRole(WindowsBuiltInRole.Administrator);
- } catch {
- return false;
- }
- }
-
- public StartupManager() {
- int p = (int)System.Environment.OSVersion.Platform;
- if ((p == 4) || (p == 128)) {
- scheduler = null;
- isAvailable = false;
- return;
- }
-
- if (IsAdministrator()) {
- try {
- scheduler = new TaskSchedulerClass();
- scheduler.Connect(null, null, null, null);
- } catch {
- scheduler = null;
- }
-
- if (scheduler != null) {
- try {
- // check if the taskscheduler is running
- IRunningTaskCollection collection = scheduler.GetRunningTasks(0);
-
- ITaskFolder folder = scheduler.GetFolder("\\Open Hardware Monitor");
- IRegisteredTask task = folder.GetTask("Startup");
- startup = (task != null) &&
- (task.Definition.Triggers.Count > 0) &&
- (task.Definition.Triggers[1].Type ==
- TASK_TRIGGER_TYPE2.TASK_TRIGGER_LOGON) &&
- (task.Definition.Actions.Count > 0) &&
- (task.Definition.Actions[1].Type ==
- TASK_ACTION_TYPE.TASK_ACTION_EXEC) &&
- (task.Definition.Actions[1] as IExecAction != null) &&
- ((task.Definition.Actions[1] as IExecAction).Path ==
- Application.ExecutablePath);
-
- } catch (IOException) {
- startup = false;
- } catch (UnauthorizedAccessException) {
- scheduler = null;
- } catch (COMException) {
- scheduler = null;
- }
- }
- } else {
- scheduler = null;
- }
-
- if (scheduler == null) {
- try {
- using (RegistryKey key =
- Registry.CurrentUser.OpenSubKey(REGISTRY_RUN)) {
- startup = false;
- if (key != null) {
- string value = (string)key.GetValue("OpenHardwareMonitor");
- if (value != null)
- startup = value == Application.ExecutablePath;
- }
- }
- isAvailable = true;
- } catch (SecurityException) {
- isAvailable = false;
- }
- } else {
- isAvailable = true;
- }
- }
-
- private void CreateSchedulerTask() {
- ITaskDefinition definition = scheduler.NewTask(0);
- definition.RegistrationInfo.Description =
- "This task starts the Open Hardware Monitor on Windows startup.";
- definition.Principal.RunLevel =
- TASK_RUNLEVEL.TASK_RUNLEVEL_HIGHEST;
- definition.Settings.DisallowStartIfOnBatteries = false;
- definition.Settings.StopIfGoingOnBatteries = false;
- definition.Settings.ExecutionTimeLimit = "PT0S";
-
- ILogonTrigger trigger = (ILogonTrigger)definition.Triggers.Create(
- TASK_TRIGGER_TYPE2.TASK_TRIGGER_LOGON);
-
- IExecAction action = (IExecAction)definition.Actions.Create(
- TASK_ACTION_TYPE.TASK_ACTION_EXEC);
- action.Path = Application.ExecutablePath;
- action.WorkingDirectory =
- Path.GetDirectoryName(Application.ExecutablePath);
-
- ITaskFolder root = scheduler.GetFolder("\\");
- ITaskFolder folder;
- try {
- folder = root.GetFolder("Open Hardware Monitor");
- } catch (IOException) {
- folder = root.CreateFolder("Open Hardware Monitor", "");
- }
- folder.RegisterTaskDefinition("Startup", definition,
- (int)TASK_CREATION.TASK_CREATE_OR_UPDATE, null, null,
- TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN, "");
- }
-
- private void DeleteSchedulerTask() {
- ITaskFolder root = scheduler.GetFolder("\\");
- try {
- ITaskFolder folder = root.GetFolder("Open Hardware Monitor");
- folder.DeleteTask("Startup", 0);
- } catch (IOException) { }
- try {
- root.DeleteFolder("Open Hardware Monitor", 0);
- } catch (IOException) { }
- }
-
- private void CreateRegistryRun() {
- RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN);
- key.SetValue("OpenHardwareMonitor", Application.ExecutablePath);
- }
-
- private void DeleteRegistryRun() {
- RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN);
- key.DeleteValue("OpenHardwareMonitor");
- }
-
- public bool IsAvailable {
- get { return isAvailable; }
- }
-
- public bool Startup {
- get {
- return startup;
- }
- set {
- if (startup != value) {
- if (isAvailable) {
- if (scheduler != null) {
- if (value)
- CreateSchedulerTask();
- else
- DeleteSchedulerTask();
- startup = value;
- } else {
- try {
- if (value)
- CreateRegistryRun();
- else
- DeleteRegistryRun();
- startup = value;
- } catch (UnauthorizedAccessException) {
- throw new InvalidOperationException();
- }
+ private bool IsAdministrator()
+ {
+ try
+ {
+ WindowsIdentity identity = WindowsIdentity.GetCurrent();
+ WindowsPrincipal principal = new WindowsPrincipal(identity);
+ return principal.IsInRole(WindowsBuiltInRole.Administrator);
+ }
+ catch
+ {
+ return false;
}
- } else {
- throw new InvalidOperationException();
- }
}
- }
- }
- }
+ public StartupManager()
+ {
+ int p = (int)Environment.OSVersion.Platform;
+ if ((p == 4) || (p == 128))
+ {
+ _scheduler = null;
+ IsAvailable = false;
+ return;
+ }
+
+ if (IsAdministrator())
+ {
+ try
+ {
+ _scheduler = new TaskSchedulerClass();
+ _scheduler.Connect(null, null, null, null);
+ }
+ catch
+ {
+ _scheduler = null;
+ }
+
+ if (_scheduler != null)
+ {
+ try
+ {
+ // check if the taskscheduler is running
+ IRunningTaskCollection _ = _scheduler.GetRunningTasks(0);
+ ITaskFolder folder = _scheduler.GetFolder("\\Open Hardware Monitor");
+ IRegisteredTask task = folder.GetTask("Startup");
+ _startup = (task != null) && (task.Definition.Triggers.Count > 0) &&
+ (task.Definition.Triggers[1].Type == TASK_TRIGGER_TYPE2.TASK_TRIGGER_LOGON) &&
+ (task.Definition.Actions.Count > 0) &&
+ (task.Definition.Actions[1].Type == TASK_ACTION_TYPE.TASK_ACTION_EXEC) &&
+ (task.Definition.Actions[1] is IExecAction) && (((IExecAction) task.Definition.Actions[1]).Path == Application.ExecutablePath);
+ }
+ catch (IOException)
+ {
+ _startup = false;
+ }
+ catch (UnauthorizedAccessException)
+ {
+ _scheduler = null;
+ }
+ catch (COMException)
+ {
+ _scheduler = null;
+ }
+ }
+ }
+ else
+ {
+ _scheduler = null;
+ }
+
+ if (_scheduler == null)
+ {
+ try
+ {
+ using (RegistryKey key = Registry.CurrentUser.OpenSubKey(REGISTRY_RUN))
+ {
+ _startup = false;
+ string value = (string) key?.GetValue("OpenHardwareMonitor");
+
+ if (value != null)
+ _startup = value == Application.ExecutablePath;
+ }
+ IsAvailable = true;
+ }
+ catch (SecurityException)
+ {
+ IsAvailable = false;
+ }
+ }
+ else
+ {
+ IsAvailable = true;
+ }
+ }
+
+ private void CreateSchedulerTask()
+ {
+ ITaskDefinition definition = _scheduler.NewTask(0);
+ definition.RegistrationInfo.Description = "This task starts the Open Hardware Monitor on Windows startup.";
+ definition.Principal.RunLevel = TASK_RUNLEVEL.TASK_RUNLEVEL_HIGHEST;
+ definition.Settings.DisallowStartIfOnBatteries = false;
+ definition.Settings.StopIfGoingOnBatteries = false;
+ definition.Settings.ExecutionTimeLimit = "PT0S";
+ IExecAction action = (IExecAction)definition.Actions.Create(TASK_ACTION_TYPE.TASK_ACTION_EXEC);
+ action.Path = Application.ExecutablePath;
+ action.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
+
+ ITaskFolder root = _scheduler.GetFolder("\\");
+ ITaskFolder folder;
+ try
+ {
+ folder = root.GetFolder("Open Hardware Monitor");
+ }
+ catch (IOException)
+ {
+ folder = root.CreateFolder("Open Hardware Monitor", "");
+ }
+ folder.RegisterTaskDefinition("Startup", definition, (int)TASK_CREATION.TASK_CREATE_OR_UPDATE, null, null, TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN, "");
+ }
+
+ private void DeleteSchedulerTask()
+ {
+ ITaskFolder root = _scheduler.GetFolder("\\");
+ try
+ {
+ ITaskFolder folder = root.GetFolder("Open Hardware Monitor");
+ folder.DeleteTask("Startup", 0);
+ }
+ catch (IOException) { }
+ try
+ {
+ root.DeleteFolder("Open Hardware Monitor", 0);
+ }
+ catch (IOException) { }
+ }
+
+ private void CreateRegistryRun()
+ {
+ RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN);
+ key.SetValue("OpenHardwareMonitor", Application.ExecutablePath);
+ }
+
+ private void DeleteRegistryRun()
+ {
+ RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN);
+ key.DeleteValue("OpenHardwareMonitor");
+ }
+
+ public bool IsAvailable { get; }
+
+ public bool Startup
+ {
+ get
+ {
+ return _startup;
+ }
+ set
+ {
+ if (_startup != value)
+ {
+ if (IsAvailable)
+ {
+ if (_scheduler != null)
+ {
+ if (value)
+ CreateSchedulerTask();
+ else
+ DeleteSchedulerTask();
+ _startup = value;
+ }
+ else
+ {
+ try
+ {
+ if (value)
+ CreateRegistryRun();
+ else
+ DeleteRegistryRun();
+ _startup = value;
+ }
+ catch (UnauthorizedAccessException)
+ {
+ throw new InvalidOperationException();
+ }
+ }
+ }
+ else
+ {
+ throw new InvalidOperationException();
+ }
+ }
+ }
+ }
+ }
}
diff --git a/GUI/SystemTray.cs b/GUI/SystemTray.cs
index f1c1f4e..a134af7 100644
--- a/GUI/SystemTray.cs
+++ b/GUI/SystemTray.cs
@@ -1,170 +1,185 @@
-/*
-
- 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) 2009-2012 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Collections.Generic;
-using System.Drawing;
-using System.Text;
using System.Windows.Forms;
using OpenHardwareMonitor.Hardware;
using OpenHardwareMonitor.Utilities;
-namespace OpenHardwareMonitor.GUI {
- public class SystemTray : IDisposable {
- private IComputer computer;
- private PersistentSettings settings;
- private UnitManager unitManager;
- private List list = new List();
- private bool mainIconEnabled = false;
- private NotifyIconAdv mainIcon;
-
- public SystemTray(IComputer computer, PersistentSettings settings,
- UnitManager unitManager)
+namespace OpenHardwareMonitor.GUI
+{
+ public class SystemTray : IDisposable
{
- this.computer = computer;
- this.settings = settings;
- this.unitManager = unitManager;
- computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
- computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
+ private IComputer _computer;
+ private readonly PersistentSettings _settings;
+ private readonly UnitManager _unitManager;
+ private readonly List _sensorList = new List();
+ private bool _mainIconEnabled;
+ private readonly NotifyIconAdv _mainIcon;
- this.mainIcon = new NotifyIconAdv();
+ public SystemTray(IComputer computer, PersistentSettings settings, UnitManager unitManager)
+ {
+ _computer = computer;
+ _settings = settings;
+ _unitManager = unitManager;
+ computer.HardwareAdded += HardwareAdded;
+ computer.HardwareRemoved += HardwareRemoved;
- ContextMenu contextMenu = new ContextMenu();
- MenuItem hideShowItem = new MenuItem("Hide/Show");
- hideShowItem.Click += delegate(object obj, EventArgs args) {
- SendHideShowCommand();
- };
- contextMenu.MenuItems.Add(hideShowItem);
- contextMenu.MenuItems.Add(new MenuItem("-"));
- MenuItem exitItem = new MenuItem("Exit");
- exitItem.Click += delegate(object obj, EventArgs args) {
- SendExitCommand();
- };
- contextMenu.MenuItems.Add(exitItem);
- this.mainIcon.ContextMenu = contextMenu;
- this.mainIcon.DoubleClick += delegate(object obj, EventArgs args) {
- SendHideShowCommand();
- };
- this.mainIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico");
- this.mainIcon.Text = "Open Hardware Monitor";
- }
+ _mainIcon = new NotifyIconAdv();
- private void HardwareRemoved(IHardware hardware) {
- hardware.SensorAdded -= new SensorEventHandler(SensorAdded);
- hardware.SensorRemoved -= new SensorEventHandler(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 += new SensorEventHandler(SensorAdded);
- hardware.SensorRemoved += new SensorEventHandler(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 list)
- icon.Dispose();
- mainIcon.Dispose();
- }
-
- public void Redraw() {
- foreach (SensorNotifyIcon icon in list)
- icon.Update();
- }
-
- public bool Contains(ISensor sensor) {
- foreach (SensorNotifyIcon icon in list)
- if (icon.Sensor == sensor)
- return true;
- return false;
- }
-
- public void Add(ISensor sensor, bool balloonTip) {
- if (Contains(sensor)) {
- return;
- } else {
- list.Add(new SensorNotifyIcon(this, sensor, balloonTip, settings, unitManager));
- UpdateMainIconVisibilty();
- 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 list)
- if (icon.Sensor == sensor)
- instance = icon;
- if (instance != null) {
- list.Remove(instance);
- UpdateMainIconVisibilty();
- instance.Dispose();
- }
- }
-
- public event EventHandler HideShowCommand;
-
- public void SendHideShowCommand() {
- if (HideShowCommand != null)
- HideShowCommand(this, null);
- }
-
- public event EventHandler ExitCommand;
-
- public void SendExitCommand() {
- if (ExitCommand != null)
- ExitCommand(this, null);
- }
-
- private void UpdateMainIconVisibilty() {
- if (mainIconEnabled) {
- mainIcon.Visible = list.Count == 0;
- } else {
- mainIcon.Visible = false;
- }
- }
-
- public bool IsMainIconEnabled {
- get { return mainIconEnabled; }
- set {
- if (mainIconEnabled != value) {
- mainIconEnabled = value;
- UpdateMainIconVisibilty();
+ ContextMenu contextMenu = new ContextMenu();
+ MenuItem hideShowItem = new MenuItem("Hide/Show");
+ hideShowItem.Click += delegate
+ {
+ SendHideShowCommand();
+ };
+ contextMenu.MenuItems.Add(hideShowItem);
+ contextMenu.MenuItems.Add(new MenuItem("-"));
+ MenuItem exitItem = new MenuItem("Exit");
+ exitItem.Click += delegate
+ {
+ SendExitCommand();
+ };
+ contextMenu.MenuItems.Add(exitItem);
+ _mainIcon.ContextMenu = contextMenu;
+ _mainIcon.DoubleClick += delegate
+ {
+ SendHideShowCommand();
+ };
+ _mainIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico");
+ _mainIcon.Text = "Open Hardware Monitor";
+ }
+
+ 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)
+ {
+ 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/GUI/TaskScheduler.cs b/GUI/TaskScheduler.cs
index daa7c16..eafdfb6 100644
--- a/GUI/TaskScheduler.cs
+++ b/GUI/TaskScheduler.cs
@@ -1,12 +1,7 @@
-/*
-
- 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) 2009-2010 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Collections;
@@ -14,908 +9,966 @@ using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-namespace OpenHardwareMonitor.TaskScheduler {
+namespace OpenHardwareMonitor.TaskScheduler
+{
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct SYSTEMTIME {
- public ushort wYear;
- public ushort wMonth;
- public ushort wDayOfWeek;
- public ushort wDay;
- public ushort wHour;
- public ushort wMinute;
- public ushort wSecond;
- public ushort wMilliseconds;
- }
+ [StructLayout(LayoutKind.Sequential, Pack = 2)]
+ public struct SYSTEMTIME
+ {
+ public ushort wYear;
+ public ushort wMonth;
+ public ushort wDayOfWeek;
+ public ushort wDay;
+ public ushort wHour;
+ public ushort wMinute;
+ public ushort wSecond;
+ public ushort wMilliseconds;
+ }
- public enum TASK_ACTION_TYPE {
- TASK_ACTION_COM_HANDLER = 5,
- TASK_ACTION_EXEC = 0,
- TASK_ACTION_SEND_EMAIL = 6,
- TASK_ACTION_SHOW_MESSAGE = 7
- }
+ public enum TASK_ACTION_TYPE
+ {
+ TASK_ACTION_COM_HANDLER = 5,
+ TASK_ACTION_EXEC = 0,
+ TASK_ACTION_SEND_EMAIL = 6,
+ TASK_ACTION_SHOW_MESSAGE = 7
+ }
- public enum TASK_COMPATIBILITY {
- TASK_COMPATIBILITY_AT,
- TASK_COMPATIBILITY_V1,
- TASK_COMPATIBILITY_V2,
- TASK_COMPATIBILITY_V2_1
- }
+ public enum TASK_COMPATIBILITY
+ {
+ TASK_COMPATIBILITY_AT,
+ TASK_COMPATIBILITY_V1,
+ TASK_COMPATIBILITY_V2,
+ TASK_COMPATIBILITY_V2_1
+ }
- public enum TASK_CREATION {
- TASK_CREATE = 2,
- TASK_CREATE_OR_UPDATE = 6,
- TASK_DISABLE = 8,
- TASK_DONT_ADD_PRINCIPAL_ACE = 0x10,
- TASK_IGNORE_REGISTRATION_TRIGGERS = 0x20,
- TASK_UPDATE = 4,
- TASK_VALIDATE_ONLY = 1
- }
+ public enum TASK_CREATION
+ {
+ TASK_CREATE = 2,
+ TASK_CREATE_OR_UPDATE = 6,
+ TASK_DISABLE = 8,
+ TASK_DONT_ADD_PRINCIPAL_ACE = 0x10,
+ TASK_IGNORE_REGISTRATION_TRIGGERS = 0x20,
+ TASK_UPDATE = 4,
+ TASK_VALIDATE_ONLY = 1
+ }
- public enum TASK_ENUM_FLAGS {
- TASK_ENUM_HIDDEN = 1
- }
+ public enum TASK_ENUM_FLAGS
+ {
+ TASK_ENUM_HIDDEN = 1
+ }
- public enum TASK_INSTANCES_POLICY {
- TASK_INSTANCES_PARALLEL,
- TASK_INSTANCES_QUEUE,
- TASK_INSTANCES_IGNORE_NEW,
- TASK_INSTANCES_STOP_EXISTING
- }
+ public enum TASK_INSTANCES_POLICY
+ {
+ TASK_INSTANCES_PARALLEL,
+ TASK_INSTANCES_QUEUE,
+ TASK_INSTANCES_IGNORE_NEW,
+ TASK_INSTANCES_STOP_EXISTING
+ }
- public enum TASK_LOGON_TYPE {
- TASK_LOGON_NONE,
- TASK_LOGON_PASSWORD,
- TASK_LOGON_S4U,
- TASK_LOGON_INTERACTIVE_TOKEN,
- TASK_LOGON_GROUP,
- TASK_LOGON_SERVICE_ACCOUNT,
- TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD
- }
+ public enum TASK_LOGON_TYPE
+ {
+ TASK_LOGON_NONE,
+ TASK_LOGON_PASSWORD,
+ TASK_LOGON_S4U,
+ TASK_LOGON_INTERACTIVE_TOKEN,
+ TASK_LOGON_GROUP,
+ TASK_LOGON_SERVICE_ACCOUNT,
+ TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD
+ }
- public enum TASK_RUN_FLAGS {
- TASK_RUN_AS_SELF = 1,
- TASK_RUN_IGNORE_CONSTRAINTS = 2,
- TASK_RUN_NO_FLAGS = 0,
- TASK_RUN_USE_SESSION_ID = 4,
- TASK_RUN_USER_SID = 8
- }
+ public enum TASK_RUN_FLAGS
+ {
+ TASK_RUN_AS_SELF = 1,
+ TASK_RUN_IGNORE_CONSTRAINTS = 2,
+ TASK_RUN_NO_FLAGS = 0,
+ TASK_RUN_USE_SESSION_ID = 4,
+ TASK_RUN_USER_SID = 8
+ }
- public enum TASK_RUNLEVEL {
- TASK_RUNLEVEL_LUA,
- TASK_RUNLEVEL_HIGHEST
- }
+ public enum TASK_RUNLEVEL
+ {
+ TASK_RUNLEVEL_LUA,
+ TASK_RUNLEVEL_HIGHEST
+ }
- public enum TASK_SESSION_STATE_CHANGE_TYPE {
- TASK_CONSOLE_CONNECT = 1,
- TASK_CONSOLE_DISCONNECT = 2,
- TASK_REMOTE_CONNECT = 3,
- TASK_REMOTE_DISCONNECT = 4,
- TASK_SESSION_LOCK = 7,
- TASK_SESSION_UNLOCK = 8
- }
+ public enum TASK_SESSION_STATE_CHANGE_TYPE
+ {
+ TASK_CONSOLE_CONNECT = 1,
+ TASK_CONSOLE_DISCONNECT = 2,
+ TASK_REMOTE_CONNECT = 3,
+ TASK_REMOTE_DISCONNECT = 4,
+ TASK_SESSION_LOCK = 7,
+ TASK_SESSION_UNLOCK = 8
+ }
- public enum TASK_STATE {
- TASK_STATE_UNKNOWN,
- TASK_STATE_DISABLED,
- TASK_STATE_QUEUED,
- TASK_STATE_READY,
- TASK_STATE_RUNNING
- }
+ public enum TASK_STATE
+ {
+ TASK_STATE_UNKNOWN,
+ TASK_STATE_DISABLED,
+ TASK_STATE_QUEUED,
+ TASK_STATE_READY,
+ TASK_STATE_RUNNING
+ }
- public enum TASK_TRIGGER_TYPE2 {
- TASK_TRIGGER_BOOT = 8,
- TASK_TRIGGER_DAILY = 2,
- TASK_TRIGGER_EVENT = 0,
- TASK_TRIGGER_IDLE = 6,
- TASK_TRIGGER_LOGON = 9,
- TASK_TRIGGER_MONTHLY = 4,
- TASK_TRIGGER_MONTHLYDOW = 5,
- TASK_TRIGGER_REGISTRATION = 7,
- TASK_TRIGGER_SESSION_STATE_CHANGE = 11,
- TASK_TRIGGER_TIME = 1,
- TASK_TRIGGER_WEEKLY = 3
- }
+ public enum TASK_TRIGGER_TYPE2
+ {
+ TASK_TRIGGER_BOOT = 8,
+ TASK_TRIGGER_DAILY = 2,
+ TASK_TRIGGER_EVENT = 0,
+ TASK_TRIGGER_IDLE = 6,
+ TASK_TRIGGER_LOGON = 9,
+ TASK_TRIGGER_MONTHLY = 4,
+ TASK_TRIGGER_MONTHLYDOW = 5,
+ TASK_TRIGGER_REGISTRATION = 7,
+ TASK_TRIGGER_SESSION_STATE_CHANGE = 11,
+ TASK_TRIGGER_TIME = 1,
+ TASK_TRIGGER_WEEKLY = 3
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("BAE54997-48B1-4CBE-9965-D6BE263EBEA4")]
- public interface IAction {
- [DispId(1)]
- string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("BAE54997-48B1-4CBE-9965-D6BE263EBEA4")]
+ public interface IAction
+ {
+ [DispId(1)]
+ string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("02820E19-7B98-4ED2-B2E8-FDCCCEFF619B")]
- public interface IActionCollection : IEnumerable {
- [DispId(1)]
- int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(0)]
- IAction this[int index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
- new IEnumerator GetEnumerator();
- [DispId(2)]
- string XmlText { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
- IAction Create([In] TASK_ACTION_TYPE Type);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
- void Remove([In, MarshalAs(UnmanagedType.Struct)] object index);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
- void Clear();
- [DispId(6)]
- string Context { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("02820E19-7B98-4ED2-B2E8-FDCCCEFF619B")]
+ public interface IActionCollection : IEnumerable
+ {
+ [DispId(1)]
+ int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(0)]
+ IAction this[int index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
+ new IEnumerator GetEnumerator();
+ [DispId(2)]
+ string XmlText { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
+ IAction Create([In] TASK_ACTION_TYPE Type);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
+ void Remove([In, MarshalAs(UnmanagedType.Struct)] object index);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
+ void Clear();
+ [DispId(6)]
+ string Context { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ }
- [ComImport, Guid("2A9C35DA-D357-41F4-BBC1-207AC1B1F3CB"), TypeLibType((short)0x10c0)]
- public interface IBootTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(20)]
- string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- }
+ [ComImport, Guid("2A9C35DA-D357-41F4-BBC1-207AC1B1F3CB"), TypeLibType((short)0x10c0)]
+ public interface IBootTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(20)]
+ string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("6D2FD252-75C5-4F66-90BA-2A7D8CC3039F")]
- public interface IComHandlerAction : IAction {
- [DispId(1)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- new TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
- [DispId(10)]
- string ClassId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
- [DispId(11)]
- string Data { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("6D2FD252-75C5-4F66-90BA-2A7D8CC3039F")]
+ public interface IComHandlerAction : IAction
+ {
+ [DispId(1)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ new TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
+ [DispId(10)]
+ string ClassId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
+ [DispId(11)]
+ string Data { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("126C5CD8-B288-41D5-8DBF-E491446ADC5C")]
- public interface IDailyTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(0x19)]
- short DaysInterval { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] set; }
- [DispId(20)]
- string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("126C5CD8-B288-41D5-8DBF-E491446ADC5C")]
+ public interface IDailyTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(0x19)]
+ short DaysInterval { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] set; }
+ [DispId(20)]
+ string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("10F62C64-7E16-4314-A0C2-0C3683F99D40")]
- public interface IEmailAction : IAction {
- [DispId(1)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- new TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
- [DispId(10)]
- string Server { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
- [DispId(11)]
- string Subject { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
- [DispId(12)]
- string To { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
- [DispId(13)]
- string Cc { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] set; }
- [DispId(14)]
- string Bcc { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] set; }
- [DispId(15)]
- string ReplyTo { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)] set; }
- [DispId(0x10)]
- string From { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)] set; }
- [DispId(0x11)]
- ITaskNamedValueCollection HeaderFields { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)] set; }
- [DispId(0x12)]
- string Body { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x12)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x12)] set; }
- [DispId(0x13)]
- Array Attachments { [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x13)] get; [param: In, MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x13)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("10F62C64-7E16-4314-A0C2-0C3683F99D40")]
+ public interface IEmailAction : IAction
+ {
+ [DispId(1)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ new TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
+ [DispId(10)]
+ string Server { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
+ [DispId(11)]
+ string Subject { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
+ [DispId(12)]
+ string To { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
+ [DispId(13)]
+ string Cc { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] set; }
+ [DispId(14)]
+ string Bcc { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] set; }
+ [DispId(15)]
+ string ReplyTo { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)] set; }
+ [DispId(0x10)]
+ string From { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)] set; }
+ [DispId(0x11)]
+ ITaskNamedValueCollection HeaderFields { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)] set; }
+ [DispId(0x12)]
+ string Body { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x12)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x12)] set; }
+ [DispId(0x13)]
+ Array Attachments { [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x13)] get; [param: In, MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x13)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("D45B0167-9653-4EEF-B94F-0732CA7AF251")]
- public interface IEventTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(20)]
- string Subscription { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- [DispId(0x15)]
- string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] set; }
- [DispId(0x16)]
- ITaskNamedValueCollection ValueQueries { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("D45B0167-9653-4EEF-B94F-0732CA7AF251")]
+ public interface IEventTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(20)]
+ string Subscription { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ [DispId(0x15)]
+ string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] set; }
+ [DispId(0x16)]
+ ITaskNamedValueCollection ValueQueries { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] set; }
+ }
- [ComImport, Guid("4C3D624D-FD6B-49A3-B9B7-09CB3CD3F047"), TypeLibType((short)0x10c0)]
- public interface IExecAction : IAction {
- [DispId(1)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- new TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
- [DispId(10)]
- string Path { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
- [DispId(11)]
- string Arguments { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
- [DispId(12)]
- string WorkingDirectory { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
- }
+ [ComImport, Guid("4C3D624D-FD6B-49A3-B9B7-09CB3CD3F047"), TypeLibType((short)0x10c0)]
+ public interface IExecAction : IAction
+ {
+ [DispId(1)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ new TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
+ [DispId(10)]
+ string Path { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
+ [DispId(11)]
+ string Arguments { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
+ [DispId(12)]
+ string WorkingDirectory { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
+ }
- [ComImport, Guid("84594461-0053-4342-A8FD-088FABF11F32"), TypeLibType((short)0x10c0)]
- public interface IIdleSettings {
- [DispId(1)]
- string IdleDuration { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- string WaitTimeout { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- bool StopOnIdleEnd { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- bool RestartOnIdle { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- }
+ [ComImport, Guid("84594461-0053-4342-A8FD-088FABF11F32"), TypeLibType((short)0x10c0)]
+ public interface IIdleSettings
+ {
+ [DispId(1)]
+ string IdleDuration { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ string WaitTimeout { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ bool StopOnIdleEnd { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ bool RestartOnIdle { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ }
- [ComImport, Guid("D537D2B0-9FB3-4D34-9739-1FF5CE7B1EF3"), TypeLibType((short)0x10c0)]
- public interface IIdleTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- }
+ [ComImport, Guid("D537D2B0-9FB3-4D34-9739-1FF5CE7B1EF3"), TypeLibType((short)0x10c0)]
+ public interface IIdleTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ }
- [ComImport, Guid("72DADE38-FAE4-4B3E-BAF4-5D009AF02B1C"), TypeLibType((short)0x10c0)]
- public interface ILogonTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(20)]
- string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- [DispId(0x15)]
- string UserId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] set; }
- }
+ [ComImport, Guid("72DADE38-FAE4-4B3E-BAF4-5D009AF02B1C"), TypeLibType((short)0x10c0)]
+ public interface ILogonTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(20)]
+ string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ [DispId(0x15)]
+ string UserId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] set; }
+ }
- [ComImport, Guid("77D025A3-90FA-43AA-B52E-CDA5499B946A"), TypeLibType((short)0x10c0)]
- public interface IMonthlyDOWTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(0x19)]
- short DaysOfWeek { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] set; }
- [DispId(0x1a)]
- short WeeksOfMonth { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] set; }
- [DispId(0x1b)]
- short MonthsOfYear { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1b)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1b)] set; }
- [DispId(0x1c)]
- bool RunOnLastWeekOfMonth { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1c)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1c)] set; }
- [DispId(20)]
- string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- }
+ [ComImport, Guid("77D025A3-90FA-43AA-B52E-CDA5499B946A"), TypeLibType((short)0x10c0)]
+ public interface IMonthlyDOWTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(0x19)]
+ short DaysOfWeek { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] set; }
+ [DispId(0x1a)]
+ short WeeksOfMonth { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] set; }
+ [DispId(0x1b)]
+ short MonthsOfYear { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1b)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1b)] set; }
+ [DispId(0x1c)]
+ bool RunOnLastWeekOfMonth { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1c)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1c)] set; }
+ [DispId(20)]
+ string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ }
- [ComImport, Guid("97C45EF1-6B02-4A1A-9C0E-1EBFBA1500AC"), TypeLibType((short)0x10c0)]
- public interface IMonthlyTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(0x19)]
- int DaysOfMonth { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] set; }
- [DispId(0x1a)]
- short MonthsOfYear { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] set; }
- [DispId(0x1b)]
- bool RunOnLastDayOfMonth { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1b)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1b)] set; }
- [DispId(20)]
- string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- }
+ [ComImport, Guid("97C45EF1-6B02-4A1A-9C0E-1EBFBA1500AC"), TypeLibType((short)0x10c0)]
+ public interface IMonthlyTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(0x19)]
+ int DaysOfMonth { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] set; }
+ [DispId(0x1a)]
+ short MonthsOfYear { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] set; }
+ [DispId(0x1b)]
+ bool RunOnLastDayOfMonth { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1b)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1b)] set; }
+ [DispId(20)]
+ string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ }
- [ComImport, Guid("9F7DEA84-C30B-4245-80B6-00E9F646F1B4"), TypeLibType((short)0x10c0)]
- public interface INetworkSettings {
- [DispId(1)]
- string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- }
+ [ComImport, Guid("9F7DEA84-C30B-4245-80B6-00E9F646F1B4"), TypeLibType((short)0x10c0)]
+ public interface INetworkSettings
+ {
+ [DispId(1)]
+ string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ }
- [ComImport, Guid("D98D51E5-C9B4-496A-A9C1-18980261CF0F"), TypeLibType((short)0x10c0)]
- public interface IPrincipal {
- [DispId(1)]
- string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- string DisplayName { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- string UserId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- TASK_LOGON_TYPE LogonType { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- string GroupId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- TASK_RUNLEVEL RunLevel { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- }
+ [ComImport, Guid("D98D51E5-C9B4-496A-A9C1-18980261CF0F"), TypeLibType((short)0x10c0)]
+ public interface IPrincipal
+ {
+ [DispId(1)]
+ string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ string DisplayName { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ string UserId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ TASK_LOGON_TYPE LogonType { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ string GroupId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ TASK_RUNLEVEL RunLevel { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ }
- [ComImport, DefaultMember("Path"), Guid("9C86F320-DEE3-4DD1-B972-A303F26B061E"), TypeLibType((short)0x10c0), ComConversionLoss]
- public interface IRegisteredTask {
- [DispId(1)]
- string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(0)]
- string Path { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [DispId(2)]
- TASK_STATE State { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
- [DispId(3)]
- bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
- IRunningTask Run([In, MarshalAs(UnmanagedType.Struct)] object parameters);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)]
- IRunningTask RunEx([In, MarshalAs(UnmanagedType.Struct)] object parameters, [In] int flags, [In] int sessionID, [In, MarshalAs(UnmanagedType.BStr)] string user);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)]
- IRunningTaskCollection GetInstances([In] int flags);
- [DispId(8)]
- DateTime LastRunTime { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] get; }
- [DispId(9)]
- int LastTaskResult { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] get; }
- [DispId(11)]
- int NumberOfMissedRuns { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; }
- [DispId(12)]
- DateTime NextRunTime { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; }
- [DispId(13)]
- ITaskDefinition Definition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] get; }
- [DispId(14)]
- string Xml { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] get; }
- [return: MarshalAs(UnmanagedType.BStr)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)]
- string GetSecurityDescriptor([In] int securityInformation);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)]
- void SetSecurityDescriptor([In, MarshalAs(UnmanagedType.BStr)] string sddl, [In] int flags);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)]
- void Stop([In] int flags);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), TypeLibFunc((short)0x41), DispId(0x60020011)]
- void GetRunTimes([In] ref SYSTEMTIME pstStart, [In] ref SYSTEMTIME pstEnd, [In, Out] ref uint pCount, [Out] IntPtr pRunTimes);
- }
+ [ComImport, DefaultMember("Path"), Guid("9C86F320-DEE3-4DD1-B972-A303F26B061E"), TypeLibType((short)0x10c0), ComConversionLoss]
+ public interface IRegisteredTask
+ {
+ [DispId(1)]
+ string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(0)]
+ string Path { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [DispId(2)]
+ TASK_STATE State { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
+ [DispId(3)]
+ bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
+ IRunningTask Run([In, MarshalAs(UnmanagedType.Struct)] object parameters);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)]
+ IRunningTask RunEx([In, MarshalAs(UnmanagedType.Struct)] object parameters, [In] int flags, [In] int sessionID, [In, MarshalAs(UnmanagedType.BStr)] string user);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)]
+ IRunningTaskCollection GetInstances([In] int flags);
+ [DispId(8)]
+ DateTime LastRunTime { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] get; }
+ [DispId(9)]
+ int LastTaskResult { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] get; }
+ [DispId(11)]
+ int NumberOfMissedRuns { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; }
+ [DispId(12)]
+ DateTime NextRunTime { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; }
+ [DispId(13)]
+ ITaskDefinition Definition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] get; }
+ [DispId(14)]
+ string Xml { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] get; }
+ [return: MarshalAs(UnmanagedType.BStr)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)]
+ string GetSecurityDescriptor([In] int securityInformation);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)]
+ void SetSecurityDescriptor([In, MarshalAs(UnmanagedType.BStr)] string sddl, [In] int flags);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)]
+ void Stop([In] int flags);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), TypeLibFunc((short)0x41), DispId(0x60020011)]
+ void GetRunTimes([In] ref SYSTEMTIME pstStart, [In] ref SYSTEMTIME pstEnd, [In, Out] ref uint pCount, [Out] IntPtr pRunTimes);
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("86627EB4-42A7-41E4-A4D9-AC33A72F2D52")]
- public interface IRegisteredTaskCollection : IEnumerable {
- [DispId(0x60020000)]
- int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x60020000)] get; }
- [DispId(0)]
- IRegisteredTask this[object index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
- new IEnumerator GetEnumerator();
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("86627EB4-42A7-41E4-A4D9-AC33A72F2D52")]
+ public interface IRegisteredTaskCollection : IEnumerable
+ {
+ [DispId(0x60020000)]
+ int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x60020000)] get; }
+ [DispId(0)]
+ IRegisteredTask this[object index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
+ new IEnumerator GetEnumerator();
+ }
- [ComImport, Guid("416D8B73-CB41-4EA1-805C-9BE9A5AC4A74"), TypeLibType((short)0x10c0)]
- public interface IRegistrationInfo {
- [DispId(1)]
- string Description { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- string Author { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(4)]
- string Version { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- string Date { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- string Documentation { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(9)]
- string XmlText { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] set; }
- [DispId(10)]
- string URI { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
- [DispId(11)]
- object SecurityDescriptor { [return: MarshalAs(UnmanagedType.Struct)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.Struct)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
- [DispId(12)]
- string Source { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
- }
+ [ComImport, Guid("416D8B73-CB41-4EA1-805C-9BE9A5AC4A74"), TypeLibType((short)0x10c0)]
+ public interface IRegistrationInfo
+ {
+ [DispId(1)]
+ string Description { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ string Author { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(4)]
+ string Version { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ string Date { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ string Documentation { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(9)]
+ string XmlText { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] set; }
+ [DispId(10)]
+ string URI { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
+ [DispId(11)]
+ object SecurityDescriptor { [return: MarshalAs(UnmanagedType.Struct)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.Struct)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
+ [DispId(12)]
+ string Source { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
+ }
- [ComImport, Guid("4C8FEC3A-C218-4E0C-B23D-629024DB91A2"), TypeLibType((short)0x10c0)]
- public interface IRegistrationTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(20)]
- string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- }
+ [ComImport, Guid("4C8FEC3A-C218-4E0C-B23D-629024DB91A2"), TypeLibType((short)0x10c0)]
+ public interface IRegistrationTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(20)]
+ string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("7FB9ACF1-26BE-400E-85B5-294B9C75DFD6")]
- public interface IRepetitionPattern {
- [DispId(1)]
- string Interval { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- string Duration { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- bool StopAtDurationEnd { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("7FB9ACF1-26BE-400E-85B5-294B9C75DFD6")]
+ public interface IRepetitionPattern
+ {
+ [DispId(1)]
+ string Interval { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ string Duration { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ bool StopAtDurationEnd { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ }
- [ComImport, Guid("653758FB-7B9A-4F1E-A471-BEEB8E9B834E"), TypeLibType((short)0x10c0), DefaultMember("InstanceGuid")]
- public interface IRunningTask {
- [DispId(1)]
- string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(0)]
- string InstanceGuid { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [DispId(2)]
- string Path { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
- [DispId(3)]
- TASK_STATE State { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; }
- [DispId(4)]
- string CurrentAction { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; }
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
- void Stop();
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)]
- void Refresh();
- [DispId(7)]
- uint EnginePID { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; }
- }
+ [ComImport, Guid("653758FB-7B9A-4F1E-A471-BEEB8E9B834E"), TypeLibType((short)0x10c0), DefaultMember("InstanceGuid")]
+ public interface IRunningTask
+ {
+ [DispId(1)]
+ string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(0)]
+ string InstanceGuid { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [DispId(2)]
+ string Path { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
+ [DispId(3)]
+ TASK_STATE State { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; }
+ [DispId(4)]
+ string CurrentAction { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; }
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
+ void Stop();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)]
+ void Refresh();
+ [DispId(7)]
+ uint EnginePID { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; }
+ }
- [ComImport, Guid("6A67614B-6828-4FEC-AA54-6D52E8F1F2DB"), TypeLibType((short)0x10c0)]
- public interface IRunningTaskCollection : IEnumerable {
- [DispId(1)]
- int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(0)]
- IRunningTask this[object index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
- new IEnumerator GetEnumerator();
- }
+ [ComImport, Guid("6A67614B-6828-4FEC-AA54-6D52E8F1F2DB"), TypeLibType((short)0x10c0)]
+ public interface IRunningTaskCollection : IEnumerable
+ {
+ [DispId(1)]
+ int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(0)]
+ IRunningTask this[object index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
+ new IEnumerator GetEnumerator();
+ }
- [ComImport, Guid("754DA71B-4385-4475-9DD9-598294FA3641"), TypeLibType((short)0x10c0)]
- public interface ISessionStateChangeTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(20)]
- string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- [DispId(0x15)]
- string UserId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] set; }
- [DispId(0x16)]
- TASK_SESSION_STATE_CHANGE_TYPE StateChange { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] set; }
- }
+ [ComImport, Guid("754DA71B-4385-4475-9DD9-598294FA3641"), TypeLibType((short)0x10c0)]
+ public interface ISessionStateChangeTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(20)]
+ string Delay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ [DispId(0x15)]
+ string UserId { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] set; }
+ [DispId(0x16)]
+ TASK_SESSION_STATE_CHANGE_TYPE StateChange { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("505E9E68-AF89-46B8-A30F-56162A83D537")]
- public interface IShowMessageAction : IAction {
- [DispId(1)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- new TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
- [DispId(10)]
- string Title { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
- [DispId(11)]
- string MessageBody { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("505E9E68-AF89-46B8-A30F-56162A83D537")]
+ public interface IShowMessageAction : IAction
+ {
+ [DispId(1)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ new TASK_ACTION_TYPE Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; }
+ [DispId(10)]
+ string Title { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
+ [DispId(11)]
+ string MessageBody { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("F5BC8FC5-536D-4F77-B852-FBC1356FDEB6")]
- public interface ITaskDefinition {
- [DispId(1)]
- IRegistrationInfo RegistrationInfo { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- [DispId(2)]
- ITriggerCollection Triggers { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(7)]
- ITaskSettings Settings { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(11)]
- string Data { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
- [DispId(12)]
- IPrincipal Principal { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
- [DispId(13)]
- IActionCollection Actions { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] set; }
- [DispId(14)]
- string XmlText { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("F5BC8FC5-536D-4F77-B852-FBC1356FDEB6")]
+ public interface ITaskDefinition
+ {
+ [DispId(1)]
+ IRegistrationInfo RegistrationInfo { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ [DispId(2)]
+ ITriggerCollection Triggers { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(7)]
+ ITaskSettings Settings { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(11)]
+ string Data { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
+ [DispId(12)]
+ IPrincipal Principal { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
+ [DispId(13)]
+ IActionCollection Actions { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] set; }
+ [DispId(14)]
+ string XmlText { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] set; }
+ }
- [ComImport, DefaultMember("Path"), Guid("8CFAC062-A080-4C15-9A88-AA7C2AF80DFC"), TypeLibType((short)0x10c0)]
- public interface ITaskFolder {
- [DispId(1)]
- string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(0)]
- string Path { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
- ITaskFolder GetFolder([MarshalAs(UnmanagedType.BStr)] string Path);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
- ITaskFolderCollection GetFolders([In] int flags);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
- ITaskFolder CreateFolder([In, MarshalAs(UnmanagedType.BStr)] string subFolderName, [In, Optional, MarshalAs(UnmanagedType.Struct)] object sddl);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)]
- void DeleteFolder([MarshalAs(UnmanagedType.BStr)] string subFolderName, [In] int flags);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)]
- IRegisteredTask GetTask([In, MarshalAs(UnmanagedType.BStr)] string Path);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)]
- IRegisteredTaskCollection GetTasks([In] int flags);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)]
- void DeleteTask([In, MarshalAs(UnmanagedType.BStr)] string Name, [In] int flags);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)]
- IRegisteredTask RegisterTask([In, MarshalAs(UnmanagedType.BStr)] string Path, [In, MarshalAs(UnmanagedType.BStr)] string XmlText, [In] int flags, [In, MarshalAs(UnmanagedType.Struct)] object UserId, [In, MarshalAs(UnmanagedType.Struct)] object password, [In] TASK_LOGON_TYPE LogonType, [In, Optional, MarshalAs(UnmanagedType.Struct)] object sddl);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)]
- IRegisteredTask RegisterTaskDefinition([In, MarshalAs(UnmanagedType.BStr)] string Path, [In, MarshalAs(UnmanagedType.Interface)] ITaskDefinition pDefinition, [In] int flags, [In, MarshalAs(UnmanagedType.Struct)] object UserId, [In, MarshalAs(UnmanagedType.Struct)] object password, [In] TASK_LOGON_TYPE LogonType, [In, Optional, MarshalAs(UnmanagedType.Struct)] object sddl);
- [return: MarshalAs(UnmanagedType.BStr)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)]
- string GetSecurityDescriptor(int securityInformation);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)]
- void SetSecurityDescriptor([In, MarshalAs(UnmanagedType.BStr)] string sddl, [In] int flags);
- }
+ [ComImport, DefaultMember("Path"), Guid("8CFAC062-A080-4C15-9A88-AA7C2AF80DFC"), TypeLibType((short)0x10c0)]
+ public interface ITaskFolder
+ {
+ [DispId(1)]
+ string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(0)]
+ string Path { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
+ ITaskFolder GetFolder([MarshalAs(UnmanagedType.BStr)] string Path);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
+ ITaskFolderCollection GetFolders([In] int flags);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
+ ITaskFolder CreateFolder([In, MarshalAs(UnmanagedType.BStr)] string subFolderName, [In, Optional, MarshalAs(UnmanagedType.Struct)] object sddl);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)]
+ void DeleteFolder([MarshalAs(UnmanagedType.BStr)] string subFolderName, [In] int flags);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)]
+ IRegisteredTask GetTask([In, MarshalAs(UnmanagedType.BStr)] string Path);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)]
+ IRegisteredTaskCollection GetTasks([In] int flags);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)]
+ void DeleteTask([In, MarshalAs(UnmanagedType.BStr)] string Name, [In] int flags);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)]
+ IRegisteredTask RegisterTask([In, MarshalAs(UnmanagedType.BStr)] string Path, [In, MarshalAs(UnmanagedType.BStr)] string XmlText, [In] int flags, [In, MarshalAs(UnmanagedType.Struct)] object UserId, [In, MarshalAs(UnmanagedType.Struct)] object password, [In] TASK_LOGON_TYPE LogonType, [In, Optional, MarshalAs(UnmanagedType.Struct)] object sddl);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)]
+ IRegisteredTask RegisterTaskDefinition([In, MarshalAs(UnmanagedType.BStr)] string Path, [In, MarshalAs(UnmanagedType.Interface)] ITaskDefinition pDefinition, [In] int flags, [In, MarshalAs(UnmanagedType.Struct)] object UserId, [In, MarshalAs(UnmanagedType.Struct)] object password, [In] TASK_LOGON_TYPE LogonType, [In, Optional, MarshalAs(UnmanagedType.Struct)] object sddl);
+ [return: MarshalAs(UnmanagedType.BStr)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)]
+ string GetSecurityDescriptor(int securityInformation);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)]
+ void SetSecurityDescriptor([In, MarshalAs(UnmanagedType.BStr)] string sddl, [In] int flags);
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("79184A66-8664-423F-97F1-637356A5D812")]
- public interface ITaskFolderCollection : IEnumerable {
- [DispId(0x60020000)]
- int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x60020000)] get; }
- [DispId(0)]
- ITaskFolder this[object index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
- new IEnumerator GetEnumerator();
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("79184A66-8664-423F-97F1-637356A5D812")]
+ public interface ITaskFolderCollection : IEnumerable
+ {
+ [DispId(0x60020000)]
+ int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x60020000)] get; }
+ [DispId(0)]
+ ITaskFolder this[object index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
+ new IEnumerator GetEnumerator();
+ }
- [ComImport, Guid("839D7762-5121-4009-9234-4F0D19394F04"), InterfaceType((short)1)]
- public interface ITaskHandler {
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void Start([In, MarshalAs(UnmanagedType.IUnknown)] object pHandlerServices, [In, MarshalAs(UnmanagedType.BStr)] string Data);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void Stop([MarshalAs(UnmanagedType.Error)] out int pRetCode);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void Pause();
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void Resume();
- }
+ [ComImport, Guid("839D7762-5121-4009-9234-4F0D19394F04"), InterfaceType((short)1)]
+ public interface ITaskHandler
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void Start([In, MarshalAs(UnmanagedType.IUnknown)] object pHandlerServices, [In, MarshalAs(UnmanagedType.BStr)] string Data);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void Stop([MarshalAs(UnmanagedType.Error)] out int pRetCode);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void Pause();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void Resume();
+ }
- [ComImport, Guid("EAEC7A8F-27A0-4DDC-8675-14726A01A38A"), InterfaceType((short)1)]
- public interface ITaskHandlerStatus {
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void UpdateStatus([In] short percentComplete, [In, MarshalAs(UnmanagedType.BStr)] string statusMessage);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void TaskCompleted([In, MarshalAs(UnmanagedType.Error)] int taskErrCode);
- }
+ [ComImport, Guid("EAEC7A8F-27A0-4DDC-8675-14726A01A38A"), InterfaceType((short)1)]
+ public interface ITaskHandlerStatus
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void UpdateStatus([In] short percentComplete, [In, MarshalAs(UnmanagedType.BStr)] string statusMessage);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void TaskCompleted([In, MarshalAs(UnmanagedType.Error)] int taskErrCode);
+ }
- [ComImport, Guid("B4EF826B-63C3-46E4-A504-EF69E4F7EA4D"), TypeLibType((short)0x10c0)]
- public interface ITaskNamedValueCollection : IEnumerable {
- [DispId(1)]
- int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(0)]
- ITaskNamedValuePair this[int index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
- new IEnumerator GetEnumerator();
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
- ITaskNamedValuePair Create([In, MarshalAs(UnmanagedType.BStr)] string Name, [In, MarshalAs(UnmanagedType.BStr)] string Value);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
- void Remove([In] int index);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
- void Clear();
- }
+ [ComImport, Guid("B4EF826B-63C3-46E4-A504-EF69E4F7EA4D"), TypeLibType((short)0x10c0)]
+ public interface ITaskNamedValueCollection : IEnumerable
+ {
+ [DispId(1)]
+ int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(0)]
+ ITaskNamedValuePair this[int index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
+ new IEnumerator GetEnumerator();
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
+ ITaskNamedValuePair Create([In, MarshalAs(UnmanagedType.BStr)] string Name, [In, MarshalAs(UnmanagedType.BStr)] string Value);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
+ void Remove([In] int index);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
+ void Clear();
+ }
- [ComImport, TypeLibType((short)0x10c0), DefaultMember("Name"), Guid("39038068-2B46-4AFD-8662-7BB6F868D221")]
- public interface ITaskNamedValuePair {
- [DispId(0)]
- string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] set; }
- [DispId(1)]
- string Value { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), DefaultMember("Name"), Guid("39038068-2B46-4AFD-8662-7BB6F868D221")]
+ public interface ITaskNamedValuePair
+ {
+ [DispId(0)]
+ string Name { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] set; }
+ [DispId(1)]
+ string Value { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), DefaultMember("TargetServer"), Guid("2FABA4C7-4DA9-4013-9697-20CC3FD40F85")]
- public interface ITaskService {
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)]
- ITaskFolder GetFolder([In, MarshalAs(UnmanagedType.BStr)] string Path);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
- IRunningTaskCollection GetRunningTasks([In] int flags);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
- ITaskDefinition NewTask([In] uint flags);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
- void Connect([In, Optional, MarshalAs(UnmanagedType.Struct)] object serverName, [In, Optional, MarshalAs(UnmanagedType.Struct)] object user, [In, Optional, MarshalAs(UnmanagedType.Struct)] object domain, [In, Optional, MarshalAs(UnmanagedType.Struct)] object password);
- [DispId(5)]
- bool Connected { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; }
- [DispId(0)]
- string TargetServer { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [DispId(6)]
- string ConnectedUser { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; }
- [DispId(7)]
- string ConnectedDomain { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; }
- [DispId(8)]
- uint HighestVersion { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] get; }
- }
+ [ComImport, TypeLibType((short)0x10c0), DefaultMember("TargetServer"), Guid("2FABA4C7-4DA9-4013-9697-20CC3FD40F85")]
+ public interface ITaskService
+ {
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)]
+ ITaskFolder GetFolder([In, MarshalAs(UnmanagedType.BStr)] string Path);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
+ IRunningTaskCollection GetRunningTasks([In] int flags);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
+ ITaskDefinition NewTask([In] uint flags);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
+ void Connect([In, Optional, MarshalAs(UnmanagedType.Struct)] object serverName, [In, Optional, MarshalAs(UnmanagedType.Struct)] object user, [In, Optional, MarshalAs(UnmanagedType.Struct)] object domain, [In, Optional, MarshalAs(UnmanagedType.Struct)] object password);
+ [DispId(5)]
+ bool Connected { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; }
+ [DispId(0)]
+ string TargetServer { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [DispId(6)]
+ string ConnectedUser { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; }
+ [DispId(7)]
+ string ConnectedDomain { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; }
+ [DispId(8)]
+ uint HighestVersion { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] get; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("8FD4711D-2D02-4C8C-87E3-EFF699DE127E")]
- public interface ITaskSettings {
- [DispId(3)]
- bool AllowDemandStart { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- string RestartInterval { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- int RestartCount { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- TASK_INSTANCES_POLICY MultipleInstances { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- bool StopIfGoingOnBatteries { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(8)]
- bool DisallowStartIfOnBatteries { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] set; }
- [DispId(9)]
- bool AllowHardTerminate { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] set; }
- [DispId(10)]
- bool StartWhenAvailable { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
- [DispId(11)]
- string XmlText { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
- [DispId(12)]
- bool RunOnlyIfNetworkAvailable { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
- [DispId(13)]
- string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] set; }
- [DispId(14)]
- bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] set; }
- [DispId(15)]
- string DeleteExpiredTaskAfter { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)] set; }
- [DispId(0x10)]
- int Priority { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)] set; }
- [DispId(0x11)]
- TASK_COMPATIBILITY Compatibility { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)] set; }
- [DispId(0x12)]
- bool Hidden { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x12)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x12)] set; }
- [DispId(0x13)]
- IIdleSettings IdleSettings { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x13)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x13)] set; }
- [DispId(20)]
- bool RunOnlyIfIdle { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- [DispId(0x15)]
- bool WakeToRun { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] set; }
- [DispId(0x16)]
- INetworkSettings NetworkSettings { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("8FD4711D-2D02-4C8C-87E3-EFF699DE127E")]
+ public interface ITaskSettings
+ {
+ [DispId(3)]
+ bool AllowDemandStart { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ string RestartInterval { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ int RestartCount { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ TASK_INSTANCES_POLICY MultipleInstances { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ bool StopIfGoingOnBatteries { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(8)]
+ bool DisallowStartIfOnBatteries { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] set; }
+ [DispId(9)]
+ bool AllowHardTerminate { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)] set; }
+ [DispId(10)]
+ bool StartWhenAvailable { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)] set; }
+ [DispId(11)]
+ string XmlText { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)] set; }
+ [DispId(12)]
+ bool RunOnlyIfNetworkAvailable { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)] set; }
+ [DispId(13)]
+ string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)] set; }
+ [DispId(14)]
+ bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)] set; }
+ [DispId(15)]
+ string DeleteExpiredTaskAfter { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)] set; }
+ [DispId(0x10)]
+ int Priority { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)] set; }
+ [DispId(0x11)]
+ TASK_COMPATIBILITY Compatibility { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)] set; }
+ [DispId(0x12)]
+ bool Hidden { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x12)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x12)] set; }
+ [DispId(0x13)]
+ IIdleSettings IdleSettings { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x13)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x13)] set; }
+ [DispId(20)]
+ bool RunOnlyIfIdle { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ [DispId(0x15)]
+ bool WakeToRun { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)] set; }
+ [DispId(0x16)]
+ INetworkSettings NetworkSettings { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)] set; }
+ }
- [ComImport, Guid("2C05C3F0-6EED-4C05-A15F-ED7D7A98A369"), TypeLibType((short)0x10c0)]
- public interface ITaskSettings2 {
- [DispId(30)]
- bool DisallowStartOnRemoteAppSession { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(30)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(30)] set; }
- [DispId(0x1f)]
- bool UseUnifiedSchedulingEngine { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1f)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1f)] set; }
- }
+ [ComImport, Guid("2C05C3F0-6EED-4C05-A15F-ED7D7A98A369"), TypeLibType((short)0x10c0)]
+ public interface ITaskSettings2
+ {
+ [DispId(30)]
+ bool DisallowStartOnRemoteAppSession { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(30)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(30)] set; }
+ [DispId(0x1f)]
+ bool UseUnifiedSchedulingEngine { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1f)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1f)] set; }
+ }
- [ComImport, Guid("3E4C9351-D966-4B8B-BB87-CEBA68BB0107"), InterfaceType((short)1)]
- public interface ITaskVariables {
- [return: MarshalAs(UnmanagedType.BStr)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- string GetInput();
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void SetOutput([In, MarshalAs(UnmanagedType.BStr)] string input);
- [return: MarshalAs(UnmanagedType.BStr)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- string GetContext();
- }
+ [ComImport, Guid("3E4C9351-D966-4B8B-BB87-CEBA68BB0107"), InterfaceType((short)1)]
+ public interface ITaskVariables
+ {
+ [return: MarshalAs(UnmanagedType.BStr)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ string GetInput();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void SetOutput([In, MarshalAs(UnmanagedType.BStr)] string input);
+ [return: MarshalAs(UnmanagedType.BStr)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ string GetContext();
+ }
- [ComImport, Guid("B45747E0-EBA7-4276-9F29-85C5BB300006"), TypeLibType((short)0x10c0)]
- public interface ITimeTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(20)]
- string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- }
+ [ComImport, Guid("B45747E0-EBA7-4276-9F29-85C5BB300006"), TypeLibType((short)0x10c0)]
+ public interface ITimeTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(20)]
+ string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("09941815-EA89-4B5B-89E0-2A773801FAC3")]
- public interface ITrigger {
- [DispId(1)]
- TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("09941815-EA89-4B5B-89E0-2A773801FAC3")]
+ public interface ITrigger
+ {
+ [DispId(1)]
+ TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ }
- [ComImport, TypeLibType((short)0x10c0), Guid("85DF5081-1B24-4F32-878A-D9D14DF4CB77")]
- public interface ITriggerCollection : IEnumerable {
- [DispId(1)]
- int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(0)]
- ITrigger this[int index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
- new IEnumerator GetEnumerator();
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
- ITrigger Create([In] TASK_TRIGGER_TYPE2 Type);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
- void Remove([In, MarshalAs(UnmanagedType.Struct)] object index);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
- void Clear();
- }
+ [ComImport, TypeLibType((short)0x10c0), Guid("85DF5081-1B24-4F32-878A-D9D14DF4CB77")]
+ public interface ITriggerCollection : IEnumerable
+ {
+ [DispId(1)]
+ int Count { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(0)]
+ ITrigger this[int index] { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-4)]
+ new IEnumerator GetEnumerator();
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
+ ITrigger Create([In] TASK_TRIGGER_TYPE2 Type);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
+ void Remove([In, MarshalAs(UnmanagedType.Struct)] object index);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
+ void Clear();
+ }
- [ComImport, Guid("5038FC98-82FF-436D-8728-A512A57C9DC1"), TypeLibType((short)0x10c0)]
- public interface IWeeklyTrigger : ITrigger {
- [DispId(1)]
- new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
- [DispId(2)]
- new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
- [DispId(3)]
- new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
- [DispId(4)]
- new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
- [DispId(5)]
- new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
- [DispId(6)]
- new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
- [DispId(7)]
- new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
- [DispId(0x19)]
- short DaysOfWeek { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] set; }
- [DispId(0x1a)]
- short WeeksInterval { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] set; }
- [DispId(20)]
- string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
- }
+ [ComImport, Guid("5038FC98-82FF-436D-8728-A512A57C9DC1"), TypeLibType((short)0x10c0)]
+ public interface IWeeklyTrigger : ITrigger
+ {
+ [DispId(1)]
+ new TASK_TRIGGER_TYPE2 Type { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; }
+ [DispId(2)]
+ new string Id { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
+ [DispId(3)]
+ new IRepetitionPattern Repetition { [return: MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [param: In, MarshalAs(UnmanagedType.Interface)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
+ [DispId(4)]
+ new string ExecutionTimeLimit { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
+ [DispId(5)]
+ new string StartBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] set; }
+ [DispId(6)]
+ new string EndBoundary { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] set; }
+ [DispId(7)]
+ new bool Enabled { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] set; }
+ [DispId(0x19)]
+ short DaysOfWeek { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)] set; }
+ [DispId(0x1a)]
+ short WeeksInterval { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] get; [param: In] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)] set; }
+ [DispId(20)]
+ string RandomDelay { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)] set; }
+ }
- [ComImport, Guid("839D7762-5121-4009-9234-4F0D19394F04"), CoClass(typeof(TaskHandlerPSClass))]
- public interface TaskHandlerPS : ITaskHandler {
- }
+ [ComImport, Guid("839D7762-5121-4009-9234-4F0D19394F04"), CoClass(typeof(TaskHandlerPSClass))]
+ public interface TaskHandlerPS : ITaskHandler
+ {
+ }
- [ComImport, TypeLibType((short)2), ClassInterface((short)0), Guid("F2A69DB7-DA2C-4352-9066-86FEE6DACAC9")]
- public class TaskHandlerPSClass : ITaskHandler, TaskHandlerPS {
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- public virtual extern void Pause();
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- public virtual extern void Resume();
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- public virtual extern void Start([In, MarshalAs(UnmanagedType.IUnknown)] object pHandlerServices, [In, MarshalAs(UnmanagedType.BStr)] string Data);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- public virtual extern void Stop([MarshalAs(UnmanagedType.Error)] out int pRetCode);
- }
+ [ComImport, TypeLibType((short)2), ClassInterface((short)0), Guid("F2A69DB7-DA2C-4352-9066-86FEE6DACAC9")]
+ public class TaskHandlerPSClass : ITaskHandler, TaskHandlerPS
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern void Pause();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern void Resume();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern void Start([In, MarshalAs(UnmanagedType.IUnknown)] object pHandlerServices, [In, MarshalAs(UnmanagedType.BStr)] string Data);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern void Stop([MarshalAs(UnmanagedType.Error)] out int pRetCode);
+ }
- [ComImport, Guid("EAEC7A8F-27A0-4DDC-8675-14726A01A38A"), CoClass(typeof(TaskHandlerStatusPSClass))]
- public interface TaskHandlerStatusPS : ITaskHandlerStatus {
- }
+ [ComImport, Guid("EAEC7A8F-27A0-4DDC-8675-14726A01A38A"), CoClass(typeof(TaskHandlerStatusPSClass))]
+ public interface TaskHandlerStatusPS : ITaskHandlerStatus
+ {
+ }
- [ComImport, ClassInterface((short)0), Guid("9F15266D-D7BA-48F0-93C1-E6895F6FE5AC"), TypeLibType((short)2)]
- public class TaskHandlerStatusPSClass : ITaskHandlerStatus, TaskHandlerStatusPS, ITaskVariables {
- [return: MarshalAs(UnmanagedType.BStr)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- public virtual extern string GetContext();
- [return: MarshalAs(UnmanagedType.BStr)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- public virtual extern string GetInput();
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- public virtual extern void SetOutput([In, MarshalAs(UnmanagedType.BStr)] string input);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- public virtual extern void TaskCompleted([In, MarshalAs(UnmanagedType.Error)] int taskErrCode);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- public virtual extern void UpdateStatus([In] short percentComplete, [In, MarshalAs(UnmanagedType.BStr)] string statusMessage);
- }
+ [ComImport, ClassInterface((short)0), Guid("9F15266D-D7BA-48F0-93C1-E6895F6FE5AC"), TypeLibType((short)2)]
+ public class TaskHandlerStatusPSClass : ITaskHandlerStatus, TaskHandlerStatusPS, ITaskVariables
+ {
+ [return: MarshalAs(UnmanagedType.BStr)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern string GetContext();
+ [return: MarshalAs(UnmanagedType.BStr)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern string GetInput();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern void SetOutput([In, MarshalAs(UnmanagedType.BStr)] string input);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern void TaskCompleted([In, MarshalAs(UnmanagedType.Error)] int taskErrCode);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern void UpdateStatus([In] short percentComplete, [In, MarshalAs(UnmanagedType.BStr)] string statusMessage);
+ }
- [ComImport, CoClass(typeof(TaskSchedulerClass)), Guid("2FABA4C7-4DA9-4013-9697-20CC3FD40F85")]
- public interface TaskScheduler : ITaskService {
- }
+ [ComImport, CoClass(typeof(TaskSchedulerClass)), Guid("2FABA4C7-4DA9-4013-9697-20CC3FD40F85")]
+ public interface TaskScheduler : ITaskService
+ {
+ }
- [ComImport, ClassInterface((short)0), DefaultMember("TargetServer"), Guid("0F87369F-A4E5-4CFC-BD3E-73E6154572DD"), TypeLibType((short)2)]
- public class TaskSchedulerClass : ITaskService, TaskScheduler {
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
- public virtual extern void Connect([In, Optional, MarshalAs(UnmanagedType.Struct)] object serverName, [In, Optional, MarshalAs(UnmanagedType.Struct)] object user, [In, Optional, MarshalAs(UnmanagedType.Struct)] object domain, [In, Optional, MarshalAs(UnmanagedType.Struct)] object password);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)]
- public virtual extern ITaskFolder GetFolder([In, MarshalAs(UnmanagedType.BStr)] string Path);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
- public virtual extern IRunningTaskCollection GetRunningTasks([In] int flags);
- [return: MarshalAs(UnmanagedType.Interface)]
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
- public virtual extern ITaskDefinition NewTask([In] uint flags);
+ [ComImport, ClassInterface((short)0), DefaultMember("TargetServer"), Guid("0F87369F-A4E5-4CFC-BD3E-73E6154572DD"), TypeLibType((short)2)]
+ public class TaskSchedulerClass : ITaskService, TaskScheduler
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
+ public virtual extern void Connect([In, Optional, MarshalAs(UnmanagedType.Struct)] object serverName, [In, Optional, MarshalAs(UnmanagedType.Struct)] object user, [In, Optional, MarshalAs(UnmanagedType.Struct)] object domain, [In, Optional, MarshalAs(UnmanagedType.Struct)] object password);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)]
+ public virtual extern ITaskFolder GetFolder([In, MarshalAs(UnmanagedType.BStr)] string Path);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
+ public virtual extern IRunningTaskCollection GetRunningTasks([In] int flags);
+ [return: MarshalAs(UnmanagedType.Interface)]
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
+ public virtual extern ITaskDefinition NewTask([In] uint flags);
- [DispId(5)]
- public virtual extern bool Connected { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; }
- [DispId(7)]
- public virtual extern string ConnectedDomain { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; }
- [DispId(6)]
- public virtual extern string ConnectedUser { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; }
- [DispId(8)]
- public virtual extern uint HighestVersion { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] get; }
- [DispId(0)]
- public virtual extern string TargetServer { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
- }
+ [DispId(5)]
+ public virtual extern bool Connected { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)] get; }
+ [DispId(7)]
+ public virtual extern string ConnectedDomain { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)] get; }
+ [DispId(6)]
+ public virtual extern string ConnectedUser { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)] get; }
+ [DispId(8)]
+ public virtual extern uint HighestVersion { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)] get; }
+ [DispId(0)]
+ public virtual extern string TargetServer { [return: MarshalAs(UnmanagedType.BStr)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0)] get; }
+ }
}
diff --git a/GUI/TreeModel.cs b/GUI/TreeModel.cs
index fa83a0f..4b7c288 100644
--- a/GUI/TreeModel.cs
+++ b/GUI/TreeModel.cs
@@ -1,12 +1,7 @@
-/*
-
- 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) 2009-2010 Michael Möller
-
-*/
+// Mozilla Public License 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 System;
using System.Collections;
@@ -14,110 +9,117 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using Aga.Controls.Tree;
-namespace OpenHardwareMonitor.GUI {
- public class TreeModel : ITreeModel {
+namespace OpenHardwareMonitor.GUI
+{
+ public class TreeModel : ITreeModel
+ {
+ private readonly Node _root;
+ private bool _forceVisible;
- private Node root;
- private bool forceVisible = false;
-
- public TreeModel() {
- root = new Node();
- root.Model = this;
- }
-
- public TreePath GetPath(Node node) {
- if (node == root)
- return TreePath.Empty;
- else {
- Stack