mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[MWB][Enterprise] Add new policies and improve settings UI for the Transfer File setting (#33571)
## Summary of the Pull Request ### Improve settings page for TransferFile setting The TransferFile setting depends on ShareClipboard setting. This is now visually shown. **Before the change:**  **After the change**  ### New policies are added for MWB Name | Supported states | Id | Behavior ------------ | ------------- | ------------ | ------------- Clipboard sharing enabled | disabled | MwbClipboardSharingEnabled | Disables the feature if set to disabled. File transfer enabled | disabled | MwbFileTransferEnabled | Disables the feature if set to disabled. Original user interface enabled | disabled | MwbUseOriginalUserInterface | Disables the feature if set to disabled. | Disallow blocking screensaver on other machines | enabled | MwbDisallowBlockingScreensaver | Disables the feature if set to enabled. | Connect only in same subnet | enabled & disabled | MwbSameSubnetOnly | Enables the feature if set to enabled.<br />Disables the feature if set to disabled. | Validate remote machine IP Address | enabled & disabled | MwbValidateRemoteIp | Enables the feature if set to enabled.<br />Disables the feature if set to disabled. Disable user defined IP Address mapping rules | enabled | MwbDisableUserDefinedIpMappingRules | If enabled the user can't define IP Address mapping rules. Predefined IP Address mappings | enabled with multi-line text value | MwbPolicyDefinedIpMappingRules | Allows admins to force define IP Address mapping rules. #### User Interface screenshots   
This commit is contained in:
@@ -12,8 +12,10 @@ using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
||||
|
||||
@@ -259,6 +261,11 @@ namespace MouseWithoutBorders.Class
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GPOWrapper.GetConfiguredMwbClipboardSharingEnabledValue() == GpoRuleConfigured.Disabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
return _properties.ShareClipboard;
|
||||
@@ -267,6 +274,11 @@ namespace MouseWithoutBorders.Class
|
||||
|
||||
set
|
||||
{
|
||||
if (ShareClipboardIsGpoConfigured)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
_properties.ShareClipboard = value;
|
||||
@@ -274,10 +286,19 @@ namespace MouseWithoutBorders.Class
|
||||
}
|
||||
}
|
||||
|
||||
[CmdConfigureIgnore]
|
||||
[JsonIgnore]
|
||||
internal bool ShareClipboardIsGpoConfigured => GPOWrapper.GetConfiguredMwbClipboardSharingEnabledValue() == GpoRuleConfigured.Disabled;
|
||||
|
||||
internal bool TransferFile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GPOWrapper.GetConfiguredMwbFileTransferEnabledValue() == GpoRuleConfigured.Disabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
return _properties.TransferFile;
|
||||
@@ -286,10 +307,19 @@ namespace MouseWithoutBorders.Class
|
||||
|
||||
set
|
||||
{
|
||||
if (TransferFileIsGpoConfigured)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_properties.TransferFile = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CmdConfigureIgnore]
|
||||
[JsonIgnore]
|
||||
internal bool TransferFileIsGpoConfigured => GPOWrapper.GetConfiguredMwbFileTransferEnabledValue() == GpoRuleConfigured.Disabled;
|
||||
|
||||
internal bool MatrixOneRow
|
||||
{
|
||||
get
|
||||
@@ -491,6 +521,11 @@ namespace MouseWithoutBorders.Class
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GPOWrapper.GetConfiguredMwbDisallowBlockingScreensaverValue() == GpoRuleConfigured.Enabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
return _properties.BlockScreenSaverOnOtherMachines;
|
||||
@@ -499,6 +534,11 @@ namespace MouseWithoutBorders.Class
|
||||
|
||||
set
|
||||
{
|
||||
if (BlockScreenSaverIsGpoConfigured)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
_properties.BlockScreenSaverOnOtherMachines = value;
|
||||
@@ -506,6 +546,10 @@ namespace MouseWithoutBorders.Class
|
||||
}
|
||||
}
|
||||
|
||||
[CmdConfigureIgnore]
|
||||
[JsonIgnore]
|
||||
internal bool BlockScreenSaverIsGpoConfigured => GPOWrapper.GetConfiguredMwbDisallowBlockingScreensaverValue() == GpoRuleConfigured.Enabled;
|
||||
|
||||
internal bool MoveMouseRelatively
|
||||
{
|
||||
get
|
||||
@@ -795,6 +839,15 @@ namespace MouseWithoutBorders.Class
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GPOWrapper.GetConfiguredMwbValidateRemoteIpValue() == GpoRuleConfigured.Enabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (GPOWrapper.GetConfiguredMwbValidateRemoteIpValue() == GpoRuleConfigured.Disabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
return _properties.ValidateRemoteMachineIP;
|
||||
@@ -803,6 +856,11 @@ namespace MouseWithoutBorders.Class
|
||||
|
||||
set
|
||||
{
|
||||
if (ReverseLookupIsGpoConfigured)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
_properties.ValidateRemoteMachineIP = value;
|
||||
@@ -810,10 +868,23 @@ namespace MouseWithoutBorders.Class
|
||||
}
|
||||
}
|
||||
|
||||
[CmdConfigureIgnore]
|
||||
[JsonIgnore]
|
||||
internal bool ReverseLookupIsGpoConfigured => GPOWrapper.GetConfiguredMwbValidateRemoteIpValue() == GpoRuleConfigured.Enabled || GPOWrapper.GetConfiguredMwbValidateRemoteIpValue() == GpoRuleConfigured.Disabled;
|
||||
|
||||
internal bool SameSubNetOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GPOWrapper.GetConfiguredMwbSameSubnetOnlyValue() == GpoRuleConfigured.Enabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (GPOWrapper.GetConfiguredMwbSameSubnetOnlyValue() == GpoRuleConfigured.Disabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
return _properties.SameSubnetOnly;
|
||||
@@ -822,6 +893,11 @@ namespace MouseWithoutBorders.Class
|
||||
|
||||
set
|
||||
{
|
||||
if (SameSubNetOnlyIsGpoConfigured)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
_properties.SameSubnetOnly = value;
|
||||
@@ -829,10 +905,19 @@ namespace MouseWithoutBorders.Class
|
||||
}
|
||||
}
|
||||
|
||||
[CmdConfigureIgnore]
|
||||
[JsonIgnore]
|
||||
internal bool SameSubNetOnlyIsGpoConfigured => GPOWrapper.GetConfiguredMwbSameSubnetOnlyValue() == GpoRuleConfigured.Enabled || GPOWrapper.GetConfiguredMwbSameSubnetOnlyValue() == GpoRuleConfigured.Disabled;
|
||||
|
||||
internal string Name2IP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GPOWrapper.GetConfiguredMwbDisableUserDefinedIpMappingRulesValue() == GpoRuleConfigured.Enabled)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
return _properties.Name2IP.Value;
|
||||
@@ -841,6 +926,11 @@ namespace MouseWithoutBorders.Class
|
||||
|
||||
set
|
||||
{
|
||||
if (Name2IpIsGpoConfigured)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
_properties.Name2IP.Value = value;
|
||||
@@ -848,6 +938,18 @@ namespace MouseWithoutBorders.Class
|
||||
}
|
||||
}
|
||||
|
||||
[CmdConfigureIgnore]
|
||||
[JsonIgnore]
|
||||
internal bool Name2IpIsGpoConfigured => GPOWrapper.GetConfiguredMwbDisableUserDefinedIpMappingRulesValue() == GpoRuleConfigured.Enabled;
|
||||
|
||||
[CmdConfigureIgnore]
|
||||
[JsonIgnore]
|
||||
internal string Name2IpPolicyList => GPOWrapper.GetConfiguredMwbPolicyDefinedIpMappingRules();
|
||||
|
||||
[CmdConfigureIgnore]
|
||||
[JsonIgnore]
|
||||
internal bool Name2IpPolicyListIsGpoConfigured => !string.IsNullOrWhiteSpace(Name2IpPolicyList);
|
||||
|
||||
internal bool FirstCtrlShiftS
|
||||
{
|
||||
get
|
||||
@@ -954,6 +1056,11 @@ namespace MouseWithoutBorders.Class
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GPOWrapper.GetConfiguredMwbUseOriginalUserInterfaceValue() == GpoRuleConfigured.Disabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
return _properties.ShowOriginalUI;
|
||||
@@ -962,6 +1069,11 @@ namespace MouseWithoutBorders.Class
|
||||
|
||||
set
|
||||
{
|
||||
if (GPOWrapper.GetConfiguredMwbUseOriginalUserInterfaceValue() == GpoRuleConfigured.Disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
_properties.ShowOriginalUI = value;
|
||||
|
||||
@@ -887,7 +887,8 @@ namespace MouseWithoutBorders.Class
|
||||
|
||||
if (!string.IsNullOrEmpty(Setting.Values.Name2IP))
|
||||
{
|
||||
string[] name2ip = Setting.Values.Name2IP.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
string combinedName2ipList = Setting.Values.Name2IpPolicyList + Separator + Setting.Values.Name2IP;
|
||||
string[] name2ip = combinedName2ipList.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] nameNip;
|
||||
|
||||
if (name2ip != null)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using Windows.UI.Notifications;
|
||||
|
||||
namespace MouseWithoutBorders
|
||||
{
|
||||
@@ -88,6 +89,8 @@ namespace MouseWithoutBorders
|
||||
this.linkLabelReConfigure = new System.Windows.Forms.LinkLabel();
|
||||
this.tabControlSetting = new System.Windows.Forms.TabControl();
|
||||
this.tabPageAdvancedSettings = new System.Windows.Forms.TabPage();
|
||||
this.groupBoxName2IPPolicyList = new System.Windows.Forms.GroupBox();
|
||||
this.textBoxMachineName2IPPolicyList = new System.Windows.Forms.TextBox();
|
||||
this.pictureBoxMouseWithoutBorders = new System.Windows.Forms.PictureBox();
|
||||
this.groupBoxDNS = new System.Windows.Forms.GroupBox();
|
||||
this.textBoxMachineName2IP = new System.Windows.Forms.TextBox();
|
||||
@@ -103,6 +106,7 @@ namespace MouseWithoutBorders
|
||||
this.groupBoxMachineMatrix.SuspendLayout();
|
||||
this.tabControlSetting.SuspendLayout();
|
||||
this.tabPageAdvancedSettings.SuspendLayout();
|
||||
this.groupBoxName2IPPolicyList.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxMouseWithoutBorders)).BeginInit();
|
||||
this.groupBoxDNS.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@@ -977,6 +981,7 @@ namespace MouseWithoutBorders
|
||||
// tabPageAdvancedSettings
|
||||
//
|
||||
this.tabPageAdvancedSettings.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(246)))), ((int)(((byte)(245)))), ((int)(((byte)(242)))));
|
||||
this.tabPageAdvancedSettings.Controls.Add(this.groupBoxName2IPPolicyList);
|
||||
this.tabPageAdvancedSettings.Controls.Add(this.pictureBoxMouseWithoutBorders);
|
||||
this.tabPageAdvancedSettings.Controls.Add(this.groupBoxDNS);
|
||||
this.tabPageAdvancedSettings.Controls.Add(this.textBoxDNS);
|
||||
@@ -986,6 +991,33 @@ namespace MouseWithoutBorders
|
||||
this.tabPageAdvancedSettings.Size = new System.Drawing.Size(563, 362);
|
||||
this.tabPageAdvancedSettings.TabIndex = 2;
|
||||
this.tabPageAdvancedSettings.Text = "IP Mappings";
|
||||
//
|
||||
// groupBoxName2IPPolicyList
|
||||
//
|
||||
this.groupBoxName2IPPolicyList.Controls.Add(this.textBoxMachineName2IPPolicyList);
|
||||
this.groupBoxName2IPPolicyList.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.groupBoxName2IPPolicyList.Location = new System.Drawing.Point(3, 241);
|
||||
this.groupBoxName2IPPolicyList.Name = "groupBoxName2IPPolicyList";
|
||||
this.groupBoxName2IPPolicyList.Size = new System.Drawing.Size(357, 150);
|
||||
this.groupBoxName2IPPolicyList.TabIndex = 1;
|
||||
this.groupBoxName2IPPolicyList.TabStop = false;
|
||||
this.groupBoxName2IPPolicyList.Text = " Policy defined machine name to IP address mappings [Managed]";
|
||||
this.groupBoxName2IPPolicyList.ForeColor = Color.DimGray;
|
||||
this.groupBoxName2IPPolicyList.Visible = false;
|
||||
//
|
||||
// textBoxMachineName2IPPolicyList
|
||||
//
|
||||
this.textBoxMachineName2IPPolicyList.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.textBoxMachineName2IPPolicyList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.textBoxMachineName2IPPolicyList.Location = new System.Drawing.Point(3, 172); // 3,172
|
||||
this.textBoxMachineName2IPPolicyList.MaxLength = 1024;
|
||||
this.textBoxMachineName2IPPolicyList.Multiline = true;
|
||||
this.textBoxMachineName2IPPolicyList.Name = "textBoxMachineName2IPPolicyList";
|
||||
this.textBoxMachineName2IPPolicyList.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.textBoxMachineName2IPPolicyList.Size = new System.Drawing.Size(351, 131);
|
||||
this.textBoxMachineName2IPPolicyList.TabIndex = 1;
|
||||
this.textBoxMachineName2IPPolicyList.ReadOnly = true;
|
||||
this.textBoxMachineName2IPPolicyList.Visible = false;
|
||||
//
|
||||
// pictureBoxMouseWithoutBorders
|
||||
//
|
||||
@@ -1098,12 +1130,13 @@ namespace MouseWithoutBorders
|
||||
this.tabControlSetting.ResumeLayout(false);
|
||||
this.tabPageAdvancedSettings.ResumeLayout(false);
|
||||
this.tabPageAdvancedSettings.PerformLayout();
|
||||
this.groupBoxName2IPPolicyList.ResumeLayout(false);
|
||||
this.groupBoxName2IPPolicyList.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxMouseWithoutBorders)).EndInit();
|
||||
this.groupBoxDNS.ResumeLayout(false);
|
||||
this.groupBoxDNS.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1140,6 +1173,8 @@ namespace MouseWithoutBorders
|
||||
private GroupBox groupBoxDNS;
|
||||
private TextBox textBoxDNS;
|
||||
private TextBox textBoxMachineName2IP;
|
||||
private GroupBox groupBoxName2IPPolicyList;
|
||||
private TextBox textBoxMachineName2IPPolicyList;
|
||||
private PictureBox pictureBoxMouseWithoutBorders;
|
||||
private GroupBox groupBoxOtherOptions;
|
||||
private CheckBox checkBoxDrawMouse;
|
||||
|
||||
@@ -853,6 +853,56 @@ namespace MouseWithoutBorders
|
||||
|
||||
comboBoxEasyMouse.Text = Setting.Values.HotKeyToggleEasyMouse == 0 ? "Disable" : new string(new char[] { (char)Setting.Values.HotKeyToggleEasyMouse });
|
||||
#endif
|
||||
|
||||
// Apply policy configuration on UI elements
|
||||
// Has to be the last action
|
||||
if (Setting.Values.ShareClipboardIsGpoConfigured)
|
||||
{
|
||||
checkBoxShareClipboard.Enabled = false;
|
||||
checkBoxShareClipboard.Text += " [Managed]";
|
||||
|
||||
// transfer file setting depends on clipboard sharing
|
||||
checkBoxTransferFile.Enabled = false;
|
||||
}
|
||||
|
||||
if (Setting.Values.TransferFileIsGpoConfigured)
|
||||
{
|
||||
checkBoxTransferFile.Enabled = false;
|
||||
checkBoxTransferFile.Text += " [Managed]";
|
||||
}
|
||||
|
||||
if (Setting.Values.BlockScreenSaverIsGpoConfigured)
|
||||
{
|
||||
checkBoxBlockScreenSaver.Enabled = false;
|
||||
checkBoxBlockScreenSaver.Text += " [Managed]";
|
||||
}
|
||||
|
||||
if (Setting.Values.SameSubNetOnlyIsGpoConfigured)
|
||||
{
|
||||
checkBoxSameSubNet.Enabled = false;
|
||||
checkBoxSameSubNet.Text += " [Managed]";
|
||||
}
|
||||
|
||||
if (Setting.Values.ReverseLookupIsGpoConfigured)
|
||||
{
|
||||
checkBoxReverseLookup.Enabled = false;
|
||||
checkBoxReverseLookup.Text += " [Managed]";
|
||||
}
|
||||
|
||||
if (Setting.Values.Name2IpIsGpoConfigured)
|
||||
{
|
||||
textBoxMachineName2IP.Enabled = false;
|
||||
groupBoxDNS.ForeColor = Color.DimGray;
|
||||
groupBoxDNS.Text += " [Managed]";
|
||||
}
|
||||
|
||||
if (Setting.Values.Name2IpPolicyListIsGpoConfigured)
|
||||
{
|
||||
pictureBoxMouseWithoutBorders.Visible = false;
|
||||
groupBoxName2IPPolicyList.Visible = true;
|
||||
textBoxMachineName2IPPolicyList.Visible = true;
|
||||
textBoxMachineName2IPPolicyList.Text = Setting.Values.Name2IpPolicyList;
|
||||
}
|
||||
}
|
||||
|
||||
private void RadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user