Add project files.
This commit is contained in:
parent
e5a279a1fd
commit
f0b02be1a5
43
ControlMyMonitorManagement.sln
Normal file
43
ControlMyMonitorManagement.sln
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32505.426
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlMyMonitorManagement", "ControlMyMonitorManagement\ControlMyMonitorManagement.csproj", "{DBD5D7D8-9261-40F2-AA31-20DC2E6D2176}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library", "Library\Library.csproj", "{1281FEF8-86AF-4479-A58A-05E0F212FECC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Language", "Language\Language.csproj", "{AAED30CF-DEB6-4D06-B24C-C9B5E2113B88}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tester", "Tester\Tester.csproj", "{0D34DD73-3282-40EB-8F59-DF190944BF12}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DBD5D7D8-9261-40F2-AA31-20DC2E6D2176}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DBD5D7D8-9261-40F2-AA31-20DC2E6D2176}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DBD5D7D8-9261-40F2-AA31-20DC2E6D2176}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DBD5D7D8-9261-40F2-AA31-20DC2E6D2176}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1281FEF8-86AF-4479-A58A-05E0F212FECC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1281FEF8-86AF-4479-A58A-05E0F212FECC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1281FEF8-86AF-4479-A58A-05E0F212FECC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1281FEF8-86AF-4479-A58A-05E0F212FECC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AAED30CF-DEB6-4D06-B24C-C9B5E2113B88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AAED30CF-DEB6-4D06-B24C-C9B5E2113B88}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AAED30CF-DEB6-4D06-B24C-C9B5E2113B88}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AAED30CF-DEB6-4D06-B24C-C9B5E2113B88}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0D34DD73-3282-40EB-8F59-DF190944BF12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0D34DD73-3282-40EB-8F59-DF190944BF12}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0D34DD73-3282-40EB-8F59-DF190944BF12}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0D34DD73-3282-40EB-8F59-DF190944BF12}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {88781872-23CA-43AF-ABEA-F36438B6CB58}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
20
ControlMyMonitorManagement/App.xaml
Normal file
20
ControlMyMonitorManagement/App.xaml
Normal file
@ -0,0 +1,20 @@
|
||||
<Application x:Class="CMM.Management.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:CMM.Management"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Style/Color.xaml"/>
|
||||
<ResourceDictionary Source="Images/icons.xaml"/>
|
||||
<ResourceDictionary Source="Style/Slider.xaml"/>
|
||||
<ResourceDictionary Source="Style/Btn.xaml"/>
|
||||
<ResourceDictionary Source="Style/Main.xaml"/>
|
||||
<ResourceDictionary Source="Style/MonCtrlStyle.xaml"/>
|
||||
<ResourceDictionary Source="Style/MonitorsControlStyle.xaml"/>
|
||||
<ResourceDictionary Source="/Language;component/StringResources.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
34
ControlMyMonitorManagement/App.xaml.cs
Normal file
34
ControlMyMonitorManagement/App.xaml.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using CMM.Library.Config;
|
||||
using CMM.Library.Method;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace CMM.Management
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
internal static XConfig cfg { get; private set; }
|
||||
internal static CMMMgr CMMMgr { get; private set; }
|
||||
|
||||
public App()
|
||||
{
|
||||
//cfg = new();
|
||||
//cfg.Load();
|
||||
CMMMgr = new CMMMgr();
|
||||
Startup += async (s, e) => await App_Startup(s, e);
|
||||
}
|
||||
|
||||
private async Task App_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
await CMMMgr.Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
10
ControlMyMonitorManagement/AssemblyInfo.cs
Normal file
10
ControlMyMonitorManagement/AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
137
ControlMyMonitorManagement/Control/Loading.xaml
Normal file
137
ControlMyMonitorManagement/Control/Loading.xaml
Normal file
@ -0,0 +1,137 @@
|
||||
<UserControl x:Class="CMM.Management.Control.Loading"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CMM.Management.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<Color x:Key="FilledColor" A="255" B="155" R="155" G="155"/>
|
||||
<Color x:Key="UnfilledColor" A="0" B="155" R="155" G="155"/>
|
||||
<Style x:Key="BusyAnimationStyle" TargetType="Control">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Control">
|
||||
<ControlTemplate.Resources>
|
||||
<Storyboard x:Key="Animation0" BeginTime="00:00:00.0" RepeatBehavior="Forever">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
|
||||
<SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
|
||||
<SplineColorKeyFrame KeyTime="00:00:01.6" Value="{StaticResource UnfilledColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
|
||||
<Storyboard x:Key="Animation1" BeginTime="00:00:00.2" RepeatBehavior="Forever">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ellipse1" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
|
||||
<SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
|
||||
<SplineColorKeyFrame KeyTime="00:00:01.6" Value="{StaticResource UnfilledColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
|
||||
<Storyboard x:Key="Animation2" BeginTime="00:00:00.4" RepeatBehavior="Forever">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ellipse2" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
|
||||
<SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
|
||||
<SplineColorKeyFrame KeyTime="00:00:01.6" Value="{StaticResource UnfilledColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
|
||||
<Storyboard x:Key="Animation3" BeginTime="00:00:00.6" RepeatBehavior="Forever">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ellipse3" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
|
||||
<SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
|
||||
<SplineColorKeyFrame KeyTime="00:00:01.6" Value="{StaticResource UnfilledColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
|
||||
<Storyboard x:Key="Animation4" BeginTime="00:00:00.8" RepeatBehavior="Forever">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ellipse4" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
|
||||
<SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
|
||||
<SplineColorKeyFrame KeyTime="00:00:01.6" Value="{StaticResource UnfilledColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
|
||||
<Storyboard x:Key="Animation5" BeginTime="00:00:01.0" RepeatBehavior="Forever">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ellipse5" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
|
||||
<SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
|
||||
<SplineColorKeyFrame KeyTime="00:00:01.6" Value="{StaticResource UnfilledColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
|
||||
<Storyboard x:Key="Animation6" BeginTime="00:00:01.2" RepeatBehavior="Forever">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ellipse6" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
|
||||
<SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
|
||||
<SplineColorKeyFrame KeyTime="00:00:01.6" Value="{StaticResource UnfilledColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
|
||||
<Storyboard x:Key="Animation7" BeginTime="00:00:01.4" RepeatBehavior="Forever">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ellipse7" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
|
||||
<SplineColorKeyFrame KeyTime="00:00:00.0" Value="{StaticResource FilledColor}"/>
|
||||
<SplineColorKeyFrame KeyTime="00:00:01.6" Value="{StaticResource UnfilledColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</ControlTemplate.Resources>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsVisible" Value="True">
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource Animation0}" x:Name="Storyboard0" />
|
||||
<BeginStoryboard Storyboard="{StaticResource Animation1}" x:Name="Storyboard1"/>
|
||||
<BeginStoryboard Storyboard="{StaticResource Animation2}" x:Name="Storyboard2"/>
|
||||
<BeginStoryboard Storyboard="{StaticResource Animation3}" x:Name="Storyboard3"/>
|
||||
<BeginStoryboard Storyboard="{StaticResource Animation4}" x:Name="Storyboard4"/>
|
||||
<BeginStoryboard Storyboard="{StaticResource Animation5}" x:Name="Storyboard5"/>
|
||||
<BeginStoryboard Storyboard="{StaticResource Animation6}" x:Name="Storyboard6"/>
|
||||
<BeginStoryboard Storyboard="{StaticResource Animation7}" x:Name="Storyboard7"/>
|
||||
</Trigger.EnterActions>
|
||||
|
||||
<Trigger.ExitActions>
|
||||
<StopStoryboard BeginStoryboardName="Storyboard0"/>
|
||||
<StopStoryboard BeginStoryboardName="Storyboard1"/>
|
||||
<StopStoryboard BeginStoryboardName="Storyboard2"/>
|
||||
<StopStoryboard BeginStoryboardName="Storyboard3"/>
|
||||
<StopStoryboard BeginStoryboardName="Storyboard4"/>
|
||||
<StopStoryboard BeginStoryboardName="Storyboard5"/>
|
||||
<StopStoryboard BeginStoryboardName="Storyboard6"/>
|
||||
<StopStoryboard BeginStoryboardName="Storyboard7"/>
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||
<Grid>
|
||||
<Canvas Height="60" Width="60">
|
||||
<Canvas.Resources>
|
||||
<Style TargetType="Ellipse">
|
||||
<Setter Property="Width" Value="15"/>
|
||||
<Setter Property="Height" Value="15" />
|
||||
<Setter Property="Fill" Value="#009B9B9B" />
|
||||
</Style>
|
||||
</Canvas.Resources>
|
||||
|
||||
<Ellipse x:Name="ellipse0" Canvas.Left="1.75" Canvas.Top="21"/>
|
||||
<Ellipse x:Name="ellipse1" Canvas.Top="7" Canvas.Left="6.5"/>
|
||||
<Ellipse x:Name="ellipse2" Canvas.Left="20.5" Canvas.Top="0.75"/>
|
||||
<Ellipse x:Name="ellipse3" Canvas.Left="34.75" Canvas.Top="6.75"/>
|
||||
<Ellipse x:Name="ellipse4" Canvas.Left="40.5" Canvas.Top="20.75" />
|
||||
<Ellipse x:Name="ellipse5" Canvas.Left="34.75" Canvas.Top="34.5"/>
|
||||
<Ellipse x:Name="ellipse6" Canvas.Left="20.75" Canvas.Top="39.75"/>
|
||||
<Ellipse x:Name="ellipse7" Canvas.Top="34.25" Canvas.Left="7" />
|
||||
<Ellipse Width="39.5" Height="39.5" Canvas.Left="8.75" Canvas.Top="8" Visibility="Hidden"/>
|
||||
</Canvas>
|
||||
<Label Content="{Binding Path=Text}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Control Style="{StaticResource BusyAnimationStyle}"/>
|
||||
<Border Background="#AA424242">
|
||||
<Border.Effect>
|
||||
<BlurEffect Radius="50" KernelType="Gaussian" RenderingBias="Quality"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
ControlMyMonitorManagement/Control/Loading.xaml.cs
Normal file
28
ControlMyMonitorManagement/Control/Loading.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace CMM.Management.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Loading.xaml
|
||||
/// </summary>
|
||||
public partial class Loading : UserControl
|
||||
{
|
||||
public Loading()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
55
ControlMyMonitorManagement/Control/MonCtrl.cs
Normal file
55
ControlMyMonitorManagement/Control/MonCtrl.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
using CMM.Library.ViewModel;
|
||||
using CMM.Library.Base;
|
||||
using CMM.Library.Method;
|
||||
using System.Windows.Data;
|
||||
using System;
|
||||
|
||||
namespace CMM.Management.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// 單一顆螢幕
|
||||
/// </summary>
|
||||
internal class MonCtrl : System.Windows.Controls.Control
|
||||
{
|
||||
public readonly static DependencyProperty MonProperty;
|
||||
private StackPanel _sp;
|
||||
|
||||
static MonCtrl()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MonCtrl), new FrameworkPropertyMetadata(typeof(MonCtrl)));
|
||||
|
||||
MonProperty = DependencyProperty.Register(
|
||||
"Monitor",
|
||||
typeof(XMonitor),
|
||||
typeof(MonCtrl),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnMonChangedCallback));
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
_sp = Template.FindName("sp", this) as StackPanel;
|
||||
}
|
||||
|
||||
public XMonitor Mon
|
||||
{
|
||||
get => (XMonitor)GetValue(MonProperty);
|
||||
set => SetValue(MonProperty, value);
|
||||
}
|
||||
|
||||
static void OnMonChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var me = sender as MonCtrl;
|
||||
if (me != null)
|
||||
{
|
||||
me.OnMonChanged((XMonitor)args.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnMonChanged(XMonitor value)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
61
ControlMyMonitorManagement/Control/MonitorsControl.cs
Normal file
61
ControlMyMonitorManagement/Control/MonitorsControl.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
using CMM.Library.ViewModel;
|
||||
using CMM.Library.Base;
|
||||
using CMM.Library.Method;
|
||||
using System.Windows.Data;
|
||||
using System;
|
||||
|
||||
namespace CMM.Management.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// 全部螢幕
|
||||
/// </summary>
|
||||
internal class MonitorsControl : System.Windows.Controls.Control
|
||||
{
|
||||
public readonly static DependencyProperty MonitorsProperty;
|
||||
private StackPanel _sp;
|
||||
|
||||
static MonitorsControl()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MonitorsControl), new FrameworkPropertyMetadata(typeof(MonitorsControl)));
|
||||
|
||||
MonitorsProperty = DependencyProperty.Register(
|
||||
"Monitors",
|
||||
typeof(ObservableRangeCollection<XMonitor>),
|
||||
typeof(MonitorsControl),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnMonitorsChangedCallback));
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
_sp = Template.FindName("sp", this) as StackPanel;
|
||||
}
|
||||
|
||||
public ObservableRangeCollection<XMonitor> Monitors
|
||||
{
|
||||
get => (ObservableRangeCollection<XMonitor>)GetValue(MonitorsProperty);
|
||||
set => SetValue(MonitorsProperty, value);
|
||||
}
|
||||
|
||||
static void OnMonitorsChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var me = sender as MonitorsControl;
|
||||
if (me != null)
|
||||
{
|
||||
me.OnMonitorsChanged((ObservableRangeCollection<XMonitor>)args.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnMonitorsChanged(ObservableRangeCollection<XMonitor> value)
|
||||
{
|
||||
foreach (var mon in value)
|
||||
{
|
||||
var monCtrl = new MonCtrl();
|
||||
monCtrl.Mon = mon;
|
||||
|
||||
_sp.Children.Add(monCtrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
66
ControlMyMonitorManagement/ControlMyMonitorManagement.csproj
Normal file
66
ControlMyMonitorManagement/ControlMyMonitorManagement.csproj
Normal file
@ -0,0 +1,66 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<RootNamespace>CMM.Management</RootNamespace>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Copyright>Copyright © DangWang $([System.DateTime]::Now.ToString(yyyy))</Copyright>
|
||||
<Company>Dang</Company>
|
||||
<Product>ControlMyMonitorManagement</Product>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Resource\**" />
|
||||
<EmbeddedResource Remove="Resource\**" />
|
||||
<None Remove="Resource\**" />
|
||||
<Page Remove="Resource\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Language\Language.csproj" />
|
||||
<ProjectReference Include="..\Library\Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Converter\" />
|
||||
<Folder Include="Form\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="Images\icons.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Style\Btn.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Style\Color.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Style\Main.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Style\Slider.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||
<Major>1</Major>
|
||||
<Minor>0</Minor>
|
||||
<ProjectStartedDate>$([System.DateTime]::op_Subtraction($([System.DateTime]::get_Now().get_Date()),$([System.DateTime]::new(2017,9,17))).get_TotalDays())</ProjectStartedDate>
|
||||
<DaysSinceProjectStarted>$([System.DateTime]::Now.ToString(Hmm))</DaysSinceProjectStarted>
|
||||
<DateTimeSuffix>$([System.DateTime]::Now.ToString(yyyyMMdd))</DateTimeSuffix>
|
||||
<VersionSuffix>$(Major).$(Minor).$(ProjectStartedDate).$(DaysSinceProjectStarted)</VersionSuffix>
|
||||
<AssemblyVersion Condition=" '$(DateTimeSuffix)' == '' ">0.0.0.1</AssemblyVersion>
|
||||
<AssemblyVersion Condition=" '$(DateTimeSuffix)' != '' ">$(VersionSuffix)</AssemblyVersion>
|
||||
<Version Condition=" '$(DateTimeSuffix)' == '' ">0.0.0.1</Version>
|
||||
<Version Condition=" '$(DateTimeSuffix)' != '' ">$(DateTimeSuffix)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
64
ControlMyMonitorManagement/Images/icons.xaml
Normal file
64
ControlMyMonitorManagement/Images/icons.xaml
Normal file
@ -0,0 +1,64 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="PathFill" TargetType="Path">
|
||||
<Setter Property="Stretch" Value="Uniform"/>
|
||||
<Setter Property="Fill" Value="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Clear-->
|
||||
<Style x:Key="PathClear" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512.262,512.262z M0,0z M507.736,4.394C501.879,-1.464,492.381,-1.464,486.523,4.394L289.873,201.044C253.003,171.95,199.405,174.084,164.993,207.448L6.44799999999995,319.984C-1.14300000000005,325.372,-2.02300000000005,336.276,4.52399999999995,342.822L169.573,507.871C176.308,514.607,187.552,513.432,192.749,505.45L299.494,341.53C330.826,309.012,334.421,259.504,310.24,223.103L507.736,25.6070000000001C513.594,19.7490000000001,513.594,10.2520000000001,507.736,4.39400000000006z M231.09,210.647C281.881,210.647,313.086,266.533,286.424,309.767L196.958,220.301C207.115,214.011,218.844,210.647,231.09,210.647z M177.704,473.576L153.344,449.216 196.61,384.321C201.206,377.428 199.343,368.115 192.45,363.52 185.559,358.924 176.245,360.787 171.649,367.68L131.711,427.584 38.295,334.168 172.874,238.644 268.453,334.223z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Unlock-->
|
||||
<Style x:Key="PathUnlock" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M438.533,438.533z M0,0z M375.721,227.259C370.39,221.928,363.921,219.267,356.304,219.267L146.176,219.267 146.176,127.907C146.176,107.728 153.315,90.505 167.591,76.229 181.868,61.956 199.092,54.818 219.269,54.818 239.444,54.818 256.671,61.955 270.942,76.229 285.219,90.505 292.358,107.729 292.358,127.907 292.358,132.854 294.165,137.136 297.778,140.752 301.399,144.369 305.683,146.178 310.625,146.178L328.906,146.178C333.851,146.178 338.133,144.369 341.754,140.752 345.36,137.136 347.174,132.854 347.174,127.907 347.174,92.691 334.659,62.576 309.633,37.545 284.603,12.513 254.48,0 219.269,0 184.055,0 153.935,12.513 128.903,37.544 103.875,62.572 91.361,92.69 91.361,127.906L91.361,219.266 82.226,219.266C74.615,219.266 68.142,221.933 62.812,227.258 57.482,232.583 54.818,239.058 54.818,246.672L54.818,411.124C54.818,418.741 57.483,425.213 62.812,430.541 68.142,435.866 74.615,438.532 82.226,438.532L356.304,438.532C363.921,438.532 370.396,435.866 375.721,430.541 381.046,425.213 383.715,418.741 383.715,411.124L383.715,246.673C383.719,239.059,381.053,232.591,375.721,227.259z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Lock-->
|
||||
<Style x:Key="PathLock" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M384,512z M0,0z M174.95,0L209.07,0C224.28,2.59 239.57,5.85 253.68,12.31 300.63,34.12 336.58,80.78 340.89,132.98 340.88,138.35 341.93,143.64 342.03,149 341.97,184.67 342,220.33 342.01,256 349.9,256.34 358.3,254.71 365.7,258.28 374.66,262.65 381.66,271.03 384,280.78L384,487.24C381.12,499.22,371.21,509.14,359.22,512L24.76,512C12.78,509.12,2.87,499.21,0,487.22L0,280.76C2.35,271.02 9.34,262.65 18.3,258.28 25.7,254.71 34.09,256.34 41.99,256 41.99,220.33 42.03,184.67 41.97,149 42.07,143.64 43.12,138.35 43.11,132.97 47.42,80.78 83.37,34.12 130.32,12.31 144.43,5.85 159.73,2.59 174.95,0 M107.18,144.03C106.76,181.33 107.12,218.67 107.01,255.99 163.67,256.01 220.33,256 276.99,255.99 277.02,221.33 276.97,186.66 277.02,152 277.29,133.15 271.81,113.9 260.01,99 244.53,77.81 218.55,63.57 192,65.01 148.56,62.76 109.21,101.17 107.18,144.03z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Log-->
|
||||
<Style x:Key="PathLog1" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M551.13,551.13z M0,0z M275.531,172.228L275.481,292.721C275.481,297.296,277.297,301.669,280.527,304.898L366.725,391.079 391.079,366.725 309.926,285.589 309.976,172.228z"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PathLog2" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M551.13,551.13z M0,0z M310.011,34.445C188.781,34.445,88.448,124.478,71.644,241.119L2.8421709430404E-14,241.119 86.114,327.233 172.228,241.119 106.448,241.119C122.925,143.53 207.803,68.891 310.011,68.891 423.977,68.891 516.685,161.598 516.685,275.565 516.685,389.532 423.978,482.239 310.011,482.239 245.947,482.239 186.542,453.243 147.033,402.684L119.887,423.876C165.971,482.844 235.266,516.684 310.011,516.684 442.966,516.684 551.13,408.503 551.13,275.565 551.13,142.627 442.966,34.4460000000001 310.011,34.4450000000001z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path General-->
|
||||
<Style x:Key="PathGeneral" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M452,36L60,36C26.916,36,0,62.916,0,96L0,336C0,369.084,26.916,396,60,396L236,396 236,436 132,436 132,476 380,476 380,436 276,436 276,396 452,396C485.084,396,512,369.084,512,336L512,96C512,62.916,485.084,36,452,36z M472,336C472,347.028,463.028,356,452,356L60,356C48.972,356,40,347.028,40,336L40,96C40,84.972,48.972,76,60,76L452,76C463.028,76,472,84.972,472,96L472,336z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Setting-->
|
||||
<Style x:Key="PathSetting" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Stretch" Value="UniformToFill"/>
|
||||
<Setter Property="Data" Value="F1 M24,24z M0,0z M22.683,9.394L20.803,9.155C20.648,8.678,20.457,8.218,20.234,7.781L21.395,6.286C21.865,5.681,21.81,4.827,21.273,4.307L19.698,2.732C19.173,2.19,18.319,2.136,17.713,2.605L16.22,3.766C15.783,3.543,15.323,3.352,14.845,3.197L14.606,1.32C14.516,0.566999999999999,13.877,-1.33226762955019E-15,13.12,-1.33226762955019E-15L10.88,-1.33226762955019E-15C10.123,-1.33226762955019E-15,9.48400000000001,0.566999999999999,9.394,1.317L9.155,3.197C8.677,3.352,8.217,3.542,7.78,3.766L6.286,2.605C5.682,2.136,4.828,2.19,4.307,2.727L2.732,4.301C2.19,4.827,2.135,5.681,2.605,6.287L3.766,7.781C3.542,8.218,3.352,8.678,3.197,9.155L1.32,9.394C0.567000000000003,9.484,3.10862446895044E-15,10.123,3.10862446895044E-15,10.88L3.10862446895044E-15,13.12C3.10862446895044E-15,13.877,0.567000000000003,14.516,1.317,14.606L3.197,14.845C3.352,15.322,3.543,15.782,3.766,16.219L2.605,17.714C2.135,18.319,2.19,19.173,2.727,19.693L4.302,21.268C4.828,21.809,5.681,21.863,6.287,21.394L7.781,20.233C8.218,20.457,8.678,20.648,9.155,20.802L9.394,22.678C9.484,23.433,10.123,24,10.88,24L13.12,24C13.877,24,14.516,23.433,14.606,22.683L14.845,20.803C15.322,20.648,15.782,20.457,16.219,20.234L17.714,21.395C18.319,21.865,19.173,21.81,19.693,21.273L21.268,19.698C21.81,19.172,21.865,18.319,21.395,17.713L20.234,16.219C20.458,15.782,20.649,15.322,20.803,14.845L22.679,14.606C23.432,14.516,23.999,13.877,23.999,13.12L23.999,10.88C24,10.123,23.433,9.484,22.683,9.394z M12,17C9.243,17 7,14.757 7,12 7,9.243 9.243,7 12,7 14.757,7 17,9.243 17,12 17,14.757 14.757,17 12,17z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Frame-->
|
||||
<Style x:Key="PathFrame" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M94.22,0L417.79,0C441.21,0.19 464.38,9.46 481.47,25.48 500.23,42.75 511.5,67.76 512,93.26L512,420.97C510.85,442.12 502.78,462.87 488.82,478.86 471.32,499.41 444.76,511.82 417.76,512L94.27,512C73.21,511.75 52.27,504.36 35.88,491.09 14,473.85 0.5,446.62 0,418.76L0,93.25C0.49,68.71 10.9,44.57 28.49,27.46 45.77,10.27 69.85,0.21 94.22,0 M85.61,30.72C68.33,33.24 52.3,43.14 42.24,57.39 34.1,68.48 29.86,82.28 30,96 30,202.67 30,309.34 30,416.01 29.89,427.61 32.9,439.23 38.74,449.26 48.08,465.41 64.52,477.36 82.9,480.79 90.5,482.38 98.29,481.94 105.99,482 209.31,482 312.63,482 415.95,482 422.69,482.03 429.44,481.08 435.89,479.11 457.54,472.56 475.05,454 480.17,431.95 482.47,423.13 481.96,413.95 482,404.92 481.99,301.59 482.02,198.26 481.99,94.93 481.99,76.98 474.07,59.28 460.78,47.24 449.05,36.27 433.08,30.04 417.03,30.01 310.01,29.99 202.99,30.01 95.97,30 92.5,30 89.03,30.22 85.61,30.72z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Cancel-->
|
||||
<Style x:Key="PathCancel" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M140.12,139.14C143.16,135.89 148.82,135.93 151.84,139.19 186.95,174.18 221.94,209.28 257.01,244.31 292.08,209.28 327.09,174.2 362.17,139.18 365.35,135.72 371.42,135.97 374.34,139.64 377.33,142.99 376.7,148.52 373.32,151.38 338.46,186.26 303.57,221.12 268.71,256 302.75,290.06 336.8,324.1 370.86,358.15 372.76,360.13 375.18,361.97 375.82,364.8 376.9,368.58 374.74,372.93 371.1,374.4 367.94,375.84 364.03,374.92 361.71,372.38 326.81,337.48 291.93,302.57 257.01,267.69 222.11,302.57 187.25,337.49 152.32,372.35 149.49,375.62 144.11,376.17 140.81,373.3 137.14,370.45 136.79,364.43 140.16,361.21 175.17,326.1 210.28,291.08 245.32,256 210.29,220.92 175.2,185.9 140.18,150.82 136.94,147.81 136.9,142.18 140.12,139.14z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Minimized-->
|
||||
<Style x:Key="PathMinimized" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M107.38,241.56C108.86,241.12 110.41,241.03 111.95,241 207.98,241 304.01,241 400.05,241 407.85,240.59 415.24,247.15 415.52,255.01 416.16,261.91 411.26,268.64 404.62,270.43 401.48,271.29 398.2,270.94 395,271.01 300.65,270.99 206.3,271.01 111.95,271 104.15,271.4 96.76,264.84 96.48,256.99 95.83,250.08 100.74,243.35 107.38,241.56z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Tick-->
|
||||
<Style x:Key="PathTick" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M467.87,75.93C474.86,68.5 486.42,65.9 495.87,69.83 504.86,73.26 511.2,82.14 512,91.67L512,94.74C511.77,102.86 507.06,109.91 501.13,115.11 394.1,222.11 287.11,329.15 180.07,436.14 173.06,443.53 161.52,446.07 152.09,442.16 147.71,440.52 144.16,437.35 140.99,434.01 96.51,389.49 51.98,345.02 7.5,300.49 3.03,296.06 0.4,289.97 0,283.71L0,281.25C0.38,270.52 8.2,260.69 18.52,257.82 27.27,255.24 37.31,257.78 43.69,264.32 83.02,303.59 122.28,342.92 161.6,382.19 263.7,280.11 365.77,178.01 467.87,75.93z"/>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
38
ControlMyMonitorManagement/MainWindow.xaml
Normal file
38
ControlMyMonitorManagement/MainWindow.xaml
Normal file
@ -0,0 +1,38 @@
|
||||
<Window x:Class="CMM.Management.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ctrl="clr-namespace:CMM.Management.Control"
|
||||
xmlns:local="clr-namespace:CMM.Management"
|
||||
mc:Ignorable="d"
|
||||
Title="ControlMyMonitor Management"
|
||||
Background="#666C6161"
|
||||
AllowsTransparency="True"
|
||||
ResizeMode="CanResizeWithGrip"
|
||||
WindowStyle="None"
|
||||
BorderThickness="3"
|
||||
BorderBrush="Gray"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Loaded="Window_Loaded" Closing="Window_Closing" MaxWidth="800" ScrollViewer.VerticalScrollBarVisibility="Disabled" UseLayoutRounding="False" MinWidth="550" MinHeight="310">
|
||||
|
||||
<Grid x:Name="MianGrid">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Background="#33000000" Grid.Row="2"/>
|
||||
<Border MouseLeftButtonDown="move" Background="#00000000" Grid.RowSpan="3"/>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
|
||||
<Button Click="Btn_Click" Tag="Minimized" Style="{StaticResource MinimizedButton}"/>
|
||||
<Button Click="Btn_Click" Tag="Exit" Style="{StaticResource CancelButton}"/>
|
||||
</StackPanel>
|
||||
<ctrl:MonitorsControl Monitors="{Binding Monitors}" Grid.Row="1"/>
|
||||
|
||||
<!--最下層Loading頁面阻擋-->
|
||||
<Border x:Name="loading" Background="#00000000" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.RowSpan="3" Visibility="Hidden">
|
||||
<ctrl:Loading />
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
87
ControlMyMonitorManagement/MainWindow.xaml.cs
Normal file
87
ControlMyMonitorManagement/MainWindow.xaml.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using CMM.Library.WinAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace CMM.Management
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EnableBlur();
|
||||
this.DataContext = App.CMMMgr;
|
||||
}
|
||||
|
||||
#region 透明背景
|
||||
private void EnableBlur()
|
||||
{
|
||||
var windowHelper = new WindowInteropHelper(this);
|
||||
var accent = new AccentPolicy();
|
||||
accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
|
||||
var accentStructSize = Marshal.SizeOf(accent);
|
||||
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
|
||||
Marshal.StructureToPtr(accent, accentPtr, false);
|
||||
var data = new WindowCompositionAttributeData();
|
||||
data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY;
|
||||
data.SizeOfData = accentStructSize;
|
||||
data.Data = accentPtr;
|
||||
|
||||
Win32.SetWindowCompositionAttribute(windowHelper.Handle, ref data);
|
||||
|
||||
Marshal.FreeHGlobal(accentPtr);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void move(object sender, MouseButtonEventArgs e) => DragMove();
|
||||
|
||||
private void Btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var tag = (sender as FrameworkElement).Tag.ToString();
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case "Exit":
|
||||
Deconstruct();
|
||||
break;
|
||||
case "Minimized":
|
||||
this.WindowState = WindowState.Minimized;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Deconstruct()
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
59
ControlMyMonitorManagement/Style/Btn.xaml
Normal file
59
ControlMyMonitorManagement/Style/Btn.xaml
Normal file
@ -0,0 +1,59 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="ImageButton" TargetType="{x:Type ButtonBase}" BasedOn="{x:Null}">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="GeometryButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource ImageButton}">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{StaticResource H1}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!--Btn Cancel-->
|
||||
<Style x:Key="CancelButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource GeometryButton}">
|
||||
<Setter Property="Margin" Value="3,0,0,0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border>
|
||||
<Grid Background="{StaticResource AlphaBrush}">
|
||||
<Path Style="{StaticResource PathCancel}"/>
|
||||
<Path Style="{StaticResource PathFrame}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--Btn Minimized-->
|
||||
<Style x:Key="MinimizedButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource GeometryButton}">
|
||||
<Setter Property="Margin" Value="3,0,0,0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border>
|
||||
<Grid Background="{StaticResource AlphaBrush}">
|
||||
<Path Style="{StaticResource PathMinimized}"/>
|
||||
<Path Style="{StaticResource PathFrame}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
39
ControlMyMonitorManagement/Style/Color.xaml
Normal file
39
ControlMyMonitorManagement/Style/Color.xaml
Normal file
@ -0,0 +1,39 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Color x:Key="H1Color">#C1272C</Color>
|
||||
<Color x:Key="H2Color">#66424242</Color>
|
||||
<Color x:Key="H3Color">#535353</Color>
|
||||
|
||||
<Color x:Key="F1Color">#232323</Color>
|
||||
<Color x:Key="F2Color">#8A3D40</Color>
|
||||
<Color x:Key="F3Color">#FFFFFF</Color>
|
||||
|
||||
<Color x:Key="DisableColor">#B2626262</Color>
|
||||
<Color x:Key="DisableH2Color">#CCADADAD</Color>
|
||||
|
||||
<Color x:Key="NormalGray">#FF686868</Color>
|
||||
|
||||
<SolidColorBrush x:Key="NormalForeground" Color="White" />
|
||||
<SolidColorBrush x:Key="Unexplainable" Color="{StaticResource F2Color}" />
|
||||
<SolidColorBrush x:Key="Unnecessary" Color="#a08b72" />
|
||||
<SolidColorBrush x:Key="Selected" Color="{StaticResource H2Color}" />
|
||||
|
||||
<SolidColorBrush x:Key="Title" Color="White" />
|
||||
|
||||
<SolidColorBrush x:Key="H1" Color="{StaticResource H1Color}" />
|
||||
<SolidColorBrush x:Key="H2" Color="{StaticResource H2Color}" />
|
||||
<SolidColorBrush x:Key="H3" Color="{StaticResource H3Color}" />
|
||||
|
||||
<SolidColorBrush x:Key="F1" Color="{StaticResource F1Color}" />
|
||||
<SolidColorBrush x:Key="F2" Color="{StaticResource F2Color}" />
|
||||
<SolidColorBrush x:Key="F3" Color="{StaticResource F3Color}" />
|
||||
|
||||
<SolidColorBrush x:Key="BlurBrush" Color="#CC6C6161" />
|
||||
<SolidColorBrush x:Key="AlphaBrush" Color="#00FFFFFF" />
|
||||
|
||||
<SolidColorBrush x:Key="NormalBrush" Color="{StaticResource NormalGray}" />
|
||||
|
||||
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="{StaticResource DisableColor}" />
|
||||
|
||||
</ResourceDictionary>
|
||||
4
ControlMyMonitorManagement/Style/Main.xaml
Normal file
4
ControlMyMonitorManagement/Style/Main.xaml
Normal file
@ -0,0 +1,4 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
</ResourceDictionary>
|
||||
18
ControlMyMonitorManagement/Style/MonCtrlStyle.xaml
Normal file
18
ControlMyMonitorManagement/Style/MonCtrlStyle.xaml
Normal file
@ -0,0 +1,18 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:CMM.Management.Control">
|
||||
|
||||
<Style TargetType="{x:Type local:MonCtrl}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type local:MonCtrl}">
|
||||
<StackPanel x:Name="sp" Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Text="{Binding Mon.MonitorName, Mode=OneWay, NotifyOnSourceUpdated=True, NotifyOnValidationError=True,
|
||||
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:MonCtrl}}}"/>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
17
ControlMyMonitorManagement/Style/MonitorsControlStyle.xaml
Normal file
17
ControlMyMonitorManagement/Style/MonitorsControlStyle.xaml
Normal file
@ -0,0 +1,17 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:CMM.Management.Control">
|
||||
|
||||
<Style TargetType="{x:Type local:MonitorsControl}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type local:MonitorsControl}">
|
||||
<StackPanel x:Name="sp" Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
278
ControlMyMonitorManagement/Style/Slider.xaml
Normal file
278
ControlMyMonitorManagement/Style/Slider.xaml
Normal file
@ -0,0 +1,278 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="SliderRepeatButton" TargetType="RepeatButton">
|
||||
<Setter Property="SnapsToDevicePixels" Value="true" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="true" />
|
||||
<Setter Property="IsTabStop" Value="false" />
|
||||
<Setter Property="Focusable" Value="false" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="RepeatButton">
|
||||
<Border BorderThickness="1" BorderBrush="{x:Null}" Background="#CCB9B6B6" Height="4"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SliderRepeatButton1" TargetType="RepeatButton">
|
||||
<Setter Property="SnapsToDevicePixels" Value="true" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="true" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="RepeatButton">
|
||||
<Border SnapsToDevicePixels="True" BorderThickness="1" Height="4">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="{DynamicResource H2Color}"/>
|
||||
<GradientStop Color="{DynamicResource H3Color}" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SliderThumb" TargetType="Thumb">
|
||||
<Setter Property="SnapsToDevicePixels" Value="true" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="true" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Thumb">
|
||||
<Ellipse Height="12" Width="12" Fill="#99FFFFFF"></Ellipse>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="Slider" TargetType="Slider">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Track Grid.Row="1" x:Name="PART_Track">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource SliderRepeatButton1}" Command="Slider.DecreaseLarge" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{StaticResource SliderThumb}"/>
|
||||
</Track.Thumb>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource SliderRepeatButton}" Command="Slider.IncreaseLarge" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
</Track>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="Horizontal_Slider" TargetType="Slider">
|
||||
<Setter Property="Focusable" Value="False"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="true"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Width" Value="205"/>
|
||||
<Setter Property="Height" Value="21"/>
|
||||
<Setter Property="Foreground" Value="{x:Null}"/>
|
||||
<Setter Property="FontSize" Value="8"/>
|
||||
<Setter Property="Margin" Value="5,0,10,0"/>
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Orientation" Value="Horizontal">
|
||||
<Setter Property="MinHeight" Value="21"/>
|
||||
<Setter Property="MinWidth" Value="104"/>
|
||||
<Setter Property="Template" Value="{StaticResource Slider}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
|
||||
</Style>
|
||||
|
||||
<LinearGradientBrush x:Key="ListBoxBackgroundBrush" StartPoint="0,0" EndPoint="1,0.001">
|
||||
<GradientBrush.GradientStops>
|
||||
<GradientStopCollection>
|
||||
<GradientStop Color="White" Offset="0.0"/>
|
||||
<GradientStop Color="White" Offset="0.6"/>
|
||||
<GradientStop Color="#DDDDDD" Offset="1.2"/>
|
||||
</GradientStopCollection>
|
||||
</GradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<LinearGradientBrush x:Key="StandardBrush" StartPoint="0,0" EndPoint="0,1">
|
||||
<GradientBrush.GradientStops>
|
||||
<GradientStopCollection>
|
||||
<GradientStop Color="#FFF" Offset="0.0"/>
|
||||
<GradientStop Color="#CCC" Offset="1.0"/>
|
||||
</GradientStopCollection>
|
||||
</GradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
|
||||
<GradientBrush.GradientStops>
|
||||
<GradientStopCollection>
|
||||
<GradientStop Color="#BBB" Offset="0.0"/>
|
||||
<GradientStop Color="#EEE" Offset="0.1"/>
|
||||
<GradientStop Color="#EEE" Offset="0.9"/>
|
||||
<GradientStop Color="#FFF" Offset="1.0"/>
|
||||
</GradientStopCollection>
|
||||
</GradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<Style x:Key="ScrollBarBackground" TargetType="{x:Type Border}">
|
||||
<Setter Property="Margin" Value="2"/>
|
||||
<Setter Property="CornerRadius" Value="6"/>
|
||||
<Setter Property="Background" Value="{DynamicResource H2}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Background" Value="{x:Null}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
|
||||
<!--上下按鈕 不顯示-->
|
||||
<Setter Property="Visibility" Value="Hidden"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type RepeatButton}">
|
||||
<Border Name="Border" Margin="1" CornerRadius="2" Background="{DynamicResource H2}" BorderBrush="{DynamicResource H2}" BorderThickness="1">
|
||||
<Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{DynamicResource H2}" Data="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="{StaticResource PressedBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type RepeatButton}">
|
||||
<Border Background="{x:Null}" Margin="1"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Border CornerRadius="4" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Width="7"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MaxHeight="5"/>
|
||||
<RowDefinition Height="0.00001*"/>
|
||||
<RowDefinition MaxHeight="5"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!--直向拉竿背景-->
|
||||
<Border Grid.RowSpan="4" Style="{StaticResource ScrollBarBackground}"/>
|
||||
<!--往上按鈕 ※隱藏-->
|
||||
<RepeatButton Grid.Row="0" Style="{StaticResource ScrollBarLineButton}" Height="18" Command="ScrollBar.LineUpCommand" Content="M 0 4 L 8 4 L 4 0 Z" />
|
||||
<Track Name="PART_Track" Grid.Row="1" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}" >
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="1,0,1,0" Background="{DynamicResource H3}" BorderBrush="{DynamicResource H3}" />
|
||||
</Track.Thumb>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageDownCommand" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
</Track>
|
||||
<!--往下按鈕 ※隱藏-->
|
||||
<RepeatButton Grid.Row="3" Style="{StaticResource ScrollBarLineButton}" Height="18" Command="ScrollBar.LineDownCommand" Content="M 0 0 L 4 4 L 8 0 Z"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition MaxWidth="18"/>
|
||||
<ColumnDefinition Width="0.00001*"/>
|
||||
<ColumnDefinition MaxWidth="18"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--橫向拉竿背景-->
|
||||
<Border Grid.ColumnSpan="3" CornerRadius="2" Background="{x:Null}"/>
|
||||
<RepeatButton Grid.Column="0" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineLeftCommand" Content="M 4 0 L 4 8 L 0 4 Z" />
|
||||
<Track Name="PART_Track" Grid.Column="1" IsDirectionReversed="False">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageLeftCommand" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="0,1,0,1" Background="{DynamicResource H3}" BorderBrush="{DynamicResource H3}" />
|
||||
</Track.Thumb>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageRightCommand" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
</Track>
|
||||
<RepeatButton Grid.Column="3" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineRightCommand" Content="M 0 0 L 4 4 L 0 8 Z"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Orientation" Value="Horizontal">
|
||||
<Setter Property="Width" Value="Auto"/>
|
||||
<Setter Property="Height" Value="18" />
|
||||
<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
|
||||
</Trigger>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="Width" Value="18"/>
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="FavsScrollViewer" TargetType="{x:Type ScrollViewer}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ScrollViewer}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollContentPresenter Grid.Column="1"/>
|
||||
<ScrollBar Name="PART_VerticalScrollBar" Value="{TemplateBinding VerticalOffset}" Maximum="{TemplateBinding ScrollableHeight}" ViewportSize="{TemplateBinding ViewportHeight}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
|
||||
<ScrollBar Name="PART_HorizontalScrollBar" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Value="{TemplateBinding HorizontalOffset}" Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
32
Display/Display.csproj
Normal file
32
Display/Display.csproj
Normal file
@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>CMM.Display</RootNamespace>
|
||||
<Product>ControlMyMonitorManagement</Product>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Company>Dang</Company>
|
||||
<Copyright>Copyright © DangWang $([System.DateTime]::Now.ToString(yyyy))</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||
<Major>1</Major>
|
||||
<Minor>0</Minor>
|
||||
<ProjectStartedDate>$([System.DateTime]::op_Subtraction($([System.DateTime]::get_Now().get_Date()),$([System.DateTime]::new(2017,9,17))).get_TotalDays())</ProjectStartedDate>
|
||||
<DaysSinceProjectStarted>$([System.DateTime]::Now.ToString(Hmm))</DaysSinceProjectStarted>
|
||||
<DateTimeSuffix>$([System.DateTime]::Now.ToString(yyyyMMdd))</DateTimeSuffix>
|
||||
<VersionSuffix>$(Major).$(Minor).$(ProjectStartedDate).$(DaysSinceProjectStarted)</VersionSuffix>
|
||||
<AssemblyVersion Condition=" '$(DateTimeSuffix)' == '' ">0.0.0.1</AssemblyVersion>
|
||||
<AssemblyVersion Condition=" '$(DateTimeSuffix)' != '' ">$(VersionSuffix)</AssemblyVersion>
|
||||
<Version Condition=" '$(DateTimeSuffix)' == '' ">0.0.0.1</Version>
|
||||
<Version Condition=" '$(DateTimeSuffix)' != '' ">$(DateTimeSuffix)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Converter\" />
|
||||
<Folder Include="Form\" />
|
||||
<Folder Include="View\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
71
Display/Images/icons.xaml
Normal file
71
Display/Images/icons.xaml
Normal file
@ -0,0 +1,71 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
|
||||
|
||||
<Style x:Key="PathFill" TargetType="Path">
|
||||
<Setter Property="Stretch" Value="Uniform"/>
|
||||
<Setter Property="Fill" Value="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Frame-->
|
||||
<Style x:Key="PathFrame" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M94.22,0L417.79,0C441.21,0.19 464.38,9.46 481.47,25.48 500.23,42.75 511.5,67.76 512,93.26L512,420.97C510.85,442.12 502.78,462.87 488.82,478.86 471.32,499.41 444.76,511.82 417.76,512L94.27,512C73.21,511.75 52.27,504.36 35.88,491.09 14,473.85 0.5,446.62 0,418.76L0,93.25C0.49,68.71 10.9,44.57 28.49,27.46 45.77,10.27 69.85,0.21 94.22,0 M85.61,30.72C68.33,33.24 52.3,43.14 42.24,57.39 34.1,68.48 29.86,82.28 30,96 30,202.67 30,309.34 30,416.01 29.89,427.61 32.9,439.23 38.74,449.26 48.08,465.41 64.52,477.36 82.9,480.79 90.5,482.38 98.29,481.94 105.99,482 209.31,482 312.63,482 415.95,482 422.69,482.03 429.44,481.08 435.89,479.11 457.54,472.56 475.05,454 480.17,431.95 482.47,423.13 481.96,413.95 482,404.92 481.99,301.59 482.02,198.26 481.99,94.93 481.99,76.98 474.07,59.28 460.78,47.24 449.05,36.27 433.08,30.04 417.03,30.01 310.01,29.99 202.99,30.01 95.97,30 92.5,30 89.03,30.22 85.61,30.72z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Clear-->
|
||||
<Style x:Key="PathClear" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512.262,512.262z M0,0z M507.736,4.394C501.879,-1.464,492.381,-1.464,486.523,4.394L289.873,201.044C253.003,171.95,199.405,174.084,164.993,207.448L6.44799999999995,319.984C-1.14300000000005,325.372,-2.02300000000005,336.276,4.52399999999995,342.822L169.573,507.871C176.308,514.607,187.552,513.432,192.749,505.45L299.494,341.53C330.826,309.012,334.421,259.504,310.24,223.103L507.736,25.6070000000001C513.594,19.7490000000001,513.594,10.2520000000001,507.736,4.39400000000006z M231.09,210.647C281.881,210.647,313.086,266.533,286.424,309.767L196.958,220.301C207.115,214.011,218.844,210.647,231.09,210.647z M177.704,473.576L153.344,449.216 196.61,384.321C201.206,377.428 199.343,368.115 192.45,363.52 185.559,358.924 176.245,360.787 171.649,367.68L131.711,427.584 38.295,334.168 172.874,238.644 268.453,334.223z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Unlock-->
|
||||
<Style x:Key="PathUnlock" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M438.533,438.533z M0,0z M375.721,227.259C370.39,221.928,363.921,219.267,356.304,219.267L146.176,219.267 146.176,127.907C146.176,107.728 153.315,90.505 167.591,76.229 181.868,61.956 199.092,54.818 219.269,54.818 239.444,54.818 256.671,61.955 270.942,76.229 285.219,90.505 292.358,107.729 292.358,127.907 292.358,132.854 294.165,137.136 297.778,140.752 301.399,144.369 305.683,146.178 310.625,146.178L328.906,146.178C333.851,146.178 338.133,144.369 341.754,140.752 345.36,137.136 347.174,132.854 347.174,127.907 347.174,92.691 334.659,62.576 309.633,37.545 284.603,12.513 254.48,0 219.269,0 184.055,0 153.935,12.513 128.903,37.544 103.875,62.572 91.361,92.69 91.361,127.906L91.361,219.266 82.226,219.266C74.615,219.266 68.142,221.933 62.812,227.258 57.482,232.583 54.818,239.058 54.818,246.672L54.818,411.124C54.818,418.741 57.483,425.213 62.812,430.541 68.142,435.866 74.615,438.532 82.226,438.532L356.304,438.532C363.921,438.532 370.396,435.866 375.721,430.541 381.046,425.213 383.715,418.741 383.715,411.124L383.715,246.673C383.719,239.059,381.053,232.591,375.721,227.259z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Lock-->
|
||||
<Style x:Key="PathLock" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M384,512z M0,0z M174.95,0L209.07,0C224.28,2.59 239.57,5.85 253.68,12.31 300.63,34.12 336.58,80.78 340.89,132.98 340.88,138.35 341.93,143.64 342.03,149 341.97,184.67 342,220.33 342.01,256 349.9,256.34 358.3,254.71 365.7,258.28 374.66,262.65 381.66,271.03 384,280.78L384,487.24C381.12,499.22,371.21,509.14,359.22,512L24.76,512C12.78,509.12,2.87,499.21,0,487.22L0,280.76C2.35,271.02 9.34,262.65 18.3,258.28 25.7,254.71 34.09,256.34 41.99,256 41.99,220.33 42.03,184.67 41.97,149 42.07,143.64 43.12,138.35 43.11,132.97 47.42,80.78 83.37,34.12 130.32,12.31 144.43,5.85 159.73,2.59 174.95,0 M107.18,144.03C106.76,181.33 107.12,218.67 107.01,255.99 163.67,256.01 220.33,256 276.99,255.99 277.02,221.33 276.97,186.66 277.02,152 277.29,133.15 271.81,113.9 260.01,99 244.53,77.81 218.55,63.57 192,65.01 148.56,62.76 109.21,101.17 107.18,144.03z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Log-->
|
||||
<Style x:Key="PathLog1" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M551.13,551.13z M0,0z M275.531,172.228L275.481,292.721C275.481,297.296,277.297,301.669,280.527,304.898L366.725,391.079 391.079,366.725 309.926,285.589 309.976,172.228z"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PathLog2" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M551.13,551.13z M0,0z M310.011,34.445C188.781,34.445,88.448,124.478,71.644,241.119L2.8421709430404E-14,241.119 86.114,327.233 172.228,241.119 106.448,241.119C122.925,143.53 207.803,68.891 310.011,68.891 423.977,68.891 516.685,161.598 516.685,275.565 516.685,389.532 423.978,482.239 310.011,482.239 245.947,482.239 186.542,453.243 147.033,402.684L119.887,423.876C165.971,482.844 235.266,516.684 310.011,516.684 442.966,516.684 551.13,408.503 551.13,275.565 551.13,142.627 442.966,34.4460000000001 310.011,34.4450000000001z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path General-->
|
||||
<Style x:Key="PathGeneral" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M452,36L60,36C26.916,36,0,62.916,0,96L0,336C0,369.084,26.916,396,60,396L236,396 236,436 132,436 132,476 380,476 380,436 276,436 276,396 452,396C485.084,396,512,369.084,512,336L512,96C512,62.916,485.084,36,452,36z M472,336C472,347.028,463.028,356,452,356L60,356C48.972,356,40,347.028,40,336L40,96C40,84.972,48.972,76,60,76L452,76C463.028,76,472,84.972,472,96L472,336z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Setting-->
|
||||
<Style x:Key="PathSetting" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Stretch" Value="UniformToFill"/>
|
||||
<Setter Property="Data" Value="F1 M24,24z M0,0z M22.683,9.394L20.803,9.155C20.648,8.678,20.457,8.218,20.234,7.781L21.395,6.286C21.865,5.681,21.81,4.827,21.273,4.307L19.698,2.732C19.173,2.19,18.319,2.136,17.713,2.605L16.22,3.766C15.783,3.543,15.323,3.352,14.845,3.197L14.606,1.32C14.516,0.566999999999999,13.877,-1.33226762955019E-15,13.12,-1.33226762955019E-15L10.88,-1.33226762955019E-15C10.123,-1.33226762955019E-15,9.48400000000001,0.566999999999999,9.394,1.317L9.155,3.197C8.677,3.352,8.217,3.542,7.78,3.766L6.286,2.605C5.682,2.136,4.828,2.19,4.307,2.727L2.732,4.301C2.19,4.827,2.135,5.681,2.605,6.287L3.766,7.781C3.542,8.218,3.352,8.678,3.197,9.155L1.32,9.394C0.567000000000003,9.484,3.10862446895044E-15,10.123,3.10862446895044E-15,10.88L3.10862446895044E-15,13.12C3.10862446895044E-15,13.877,0.567000000000003,14.516,1.317,14.606L3.197,14.845C3.352,15.322,3.543,15.782,3.766,16.219L2.605,17.714C2.135,18.319,2.19,19.173,2.727,19.693L4.302,21.268C4.828,21.809,5.681,21.863,6.287,21.394L7.781,20.233C8.218,20.457,8.678,20.648,9.155,20.802L9.394,22.678C9.484,23.433,10.123,24,10.88,24L13.12,24C13.877,24,14.516,23.433,14.606,22.683L14.845,20.803C15.322,20.648,15.782,20.457,16.219,20.234L17.714,21.395C18.319,21.865,19.173,21.81,19.693,21.273L21.268,19.698C21.81,19.172,21.865,18.319,21.395,17.713L20.234,16.219C20.458,15.782,20.649,15.322,20.803,14.845L22.679,14.606C23.432,14.516,23.999,13.877,23.999,13.12L23.999,10.88C24,10.123,23.433,9.484,22.683,9.394z M12,17C9.243,17 7,14.757 7,12 7,9.243 9.243,7 12,7 14.757,7 17,9.243 17,12 17,14.757 14.757,17 12,17z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Frame-->
|
||||
<Style x:Key="PathFrame" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M94.22,0L417.79,0C441.21,0.19 464.38,9.46 481.47,25.48 500.23,42.75 511.5,67.76 512,93.26L512,420.97C510.85,442.12 502.78,462.87 488.82,478.86 471.32,499.41 444.76,511.82 417.76,512L94.27,512C73.21,511.75 52.27,504.36 35.88,491.09 14,473.85 0.5,446.62 0,418.76L0,93.25C0.49,68.71 10.9,44.57 28.49,27.46 45.77,10.27 69.85,0.21 94.22,0 M85.61,30.72C68.33,33.24 52.3,43.14 42.24,57.39 34.1,68.48 29.86,82.28 30,96 30,202.67 30,309.34 30,416.01 29.89,427.61 32.9,439.23 38.74,449.26 48.08,465.41 64.52,477.36 82.9,480.79 90.5,482.38 98.29,481.94 105.99,482 209.31,482 312.63,482 415.95,482 422.69,482.03 429.44,481.08 435.89,479.11 457.54,472.56 475.05,454 480.17,431.95 482.47,423.13 481.96,413.95 482,404.92 481.99,301.59 482.02,198.26 481.99,94.93 481.99,76.98 474.07,59.28 460.78,47.24 449.05,36.27 433.08,30.04 417.03,30.01 310.01,29.99 202.99,30.01 95.97,30 92.5,30 89.03,30.22 85.61,30.72z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Cancel-->
|
||||
<Style x:Key="PathCancel" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M140.12,139.14C143.16,135.89 148.82,135.93 151.84,139.19 186.95,174.18 221.94,209.28 257.01,244.31 292.08,209.28 327.09,174.2 362.17,139.18 365.35,135.72 371.42,135.97 374.34,139.64 377.33,142.99 376.7,148.52 373.32,151.38 338.46,186.26 303.57,221.12 268.71,256 302.75,290.06 336.8,324.1 370.86,358.15 372.76,360.13 375.18,361.97 375.82,364.8 376.9,368.58 374.74,372.93 371.1,374.4 367.94,375.84 364.03,374.92 361.71,372.38 326.81,337.48 291.93,302.57 257.01,267.69 222.11,302.57 187.25,337.49 152.32,372.35 149.49,375.62 144.11,376.17 140.81,373.3 137.14,370.45 136.79,364.43 140.16,361.21 175.17,326.1 210.28,291.08 245.32,256 210.29,220.92 175.2,185.9 140.18,150.82 136.94,147.81 136.9,142.18 140.12,139.14z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Minimized-->
|
||||
<Style x:Key="PathMinimized" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M107.38,241.56C108.86,241.12 110.41,241.03 111.95,241 207.98,241 304.01,241 400.05,241 407.85,240.59 415.24,247.15 415.52,255.01 416.16,261.91 411.26,268.64 404.62,270.43 401.48,271.29 398.2,270.94 395,271.01 300.65,270.99 206.3,271.01 111.95,271 104.15,271.4 96.76,264.84 96.48,256.99 95.83,250.08 100.74,243.35 107.38,241.56z"/>
|
||||
</Style>
|
||||
|
||||
<!--Path Tick-->
|
||||
<Style x:Key="PathTick" TargetType="Path" BasedOn="{StaticResource PathFill}">
|
||||
<Setter Property="Data" Value="F1 M512,512z M0,0z M467.87,75.93C474.86,68.5 486.42,65.9 495.87,69.83 504.86,73.26 511.2,82.14 512,91.67L512,94.74C511.77,102.86 507.06,109.91 501.13,115.11 394.1,222.11 287.11,329.15 180.07,436.14 173.06,443.53 161.52,446.07 152.09,442.16 147.71,440.52 144.16,437.35 140.99,434.01 96.51,389.49 51.98,345.02 7.5,300.49 3.03,296.06 0.4,289.97 0,283.71L0,281.25C0.38,270.52 8.2,260.69 18.52,257.82 27.27,255.24 37.31,257.78 43.69,264.32 83.02,303.59 122.28,342.92 161.6,382.19 263.7,280.11 365.77,178.01 467.87,75.93z"/>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
59
Display/Style/Btn.xaml
Normal file
59
Display/Style/Btn.xaml
Normal file
@ -0,0 +1,59 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<!--<Style x:Key="ImageButton" TargetType="{x:Type ButtonBase}" BasedOn="{x:Null}">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>-->
|
||||
|
||||
<!--<Style x:Key="GeometryButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource ImageButton}">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{StaticResource H1}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
--><!--Btn Cancel--><!--
|
||||
<Style x:Key="CancelButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource GeometryButton}">
|
||||
<Setter Property="Margin" Value="3,0,0,0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border>
|
||||
<Grid Background="{StaticResource AlphaBrush}">
|
||||
<Path Style="{StaticResource PathCancel}"/>
|
||||
<Path Style="{StaticResource PathFrame}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
--><!--Btn Minimized--><!--
|
||||
<Style x:Key="MinimizedButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource GeometryButton}">
|
||||
<Setter Property="Margin" Value="3,0,0,0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border>
|
||||
<Grid Background="{StaticResource AlphaBrush}">
|
||||
<Path Style="{StaticResource PathMinimized}"/>
|
||||
<Path Style="{StaticResource PathFrame}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>-->
|
||||
|
||||
</ResourceDictionary>
|
||||
39
Display/Style/Color.xaml
Normal file
39
Display/Style/Color.xaml
Normal file
@ -0,0 +1,39 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Color x:Key="H1Color">#C1272C</Color>
|
||||
<Color x:Key="H2Color">#66424242</Color>
|
||||
<Color x:Key="H3Color">#535353</Color>
|
||||
|
||||
<Color x:Key="F1Color">#232323</Color>
|
||||
<Color x:Key="F2Color">#8A3D40</Color>
|
||||
<Color x:Key="F3Color">#FFFFFF</Color>
|
||||
|
||||
<Color x:Key="DisableColor">#B2626262</Color>
|
||||
<Color x:Key="DisableH2Color">#CCADADAD</Color>
|
||||
|
||||
<Color x:Key="NormalGray">#FF686868</Color>
|
||||
|
||||
<SolidColorBrush x:Key="NormalForeground" Color="White" />
|
||||
<SolidColorBrush x:Key="Unexplainable" Color="{StaticResource F2Color}" />
|
||||
<SolidColorBrush x:Key="Unnecessary" Color="#a08b72" />
|
||||
<SolidColorBrush x:Key="Selected" Color="{StaticResource H2Color}" />
|
||||
|
||||
<SolidColorBrush x:Key="Title" Color="White" />
|
||||
|
||||
<SolidColorBrush x:Key="H1" Color="{StaticResource H1Color}" />
|
||||
<SolidColorBrush x:Key="H2" Color="{StaticResource H2Color}" />
|
||||
<SolidColorBrush x:Key="H3" Color="{StaticResource H3Color}" />
|
||||
|
||||
<SolidColorBrush x:Key="F1" Color="{StaticResource F1Color}" />
|
||||
<SolidColorBrush x:Key="F2" Color="{StaticResource F2Color}" />
|
||||
<SolidColorBrush x:Key="F3" Color="{StaticResource F3Color}" />
|
||||
|
||||
<SolidColorBrush x:Key="BlurBrush" Color="#CC6C6161" />
|
||||
<SolidColorBrush x:Key="AlphaBrush" Color="#00FFFFFF" />
|
||||
|
||||
<SolidColorBrush x:Key="NormalBrush" Color="{StaticResource NormalGray}" />
|
||||
|
||||
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="{StaticResource DisableColor}" />
|
||||
|
||||
</ResourceDictionary>
|
||||
4
Display/Style/Main.xaml
Normal file
4
Display/Style/Main.xaml
Normal file
@ -0,0 +1,4 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
</ResourceDictionary>
|
||||
278
Display/Style/Slider.xaml
Normal file
278
Display/Style/Slider.xaml
Normal file
@ -0,0 +1,278 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<!--<Style x:Key="SliderRepeatButton" TargetType="RepeatButton">
|
||||
<Setter Property="SnapsToDevicePixels" Value="true" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="true" />
|
||||
<Setter Property="IsTabStop" Value="false" />
|
||||
<Setter Property="Focusable" Value="false" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="RepeatButton">
|
||||
<Border BorderThickness="1" BorderBrush="{x:Null}" Background="#CCB9B6B6" Height="4"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SliderRepeatButton1" TargetType="RepeatButton">
|
||||
<Setter Property="SnapsToDevicePixels" Value="true" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="true" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="RepeatButton">
|
||||
<Border SnapsToDevicePixels="True" BorderThickness="1" Height="4">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="{DynamicResource H2Color}"/>
|
||||
<GradientStop Color="{DynamicResource H3Color}" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SliderThumb" TargetType="Thumb">
|
||||
<Setter Property="SnapsToDevicePixels" Value="true" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="true" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Thumb">
|
||||
<Ellipse Height="12" Width="12" Fill="#99FFFFFF"></Ellipse>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="Slider" TargetType="Slider">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Track Grid.Row="1" x:Name="PART_Track">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource SliderRepeatButton1}" Command="Slider.DecreaseLarge" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{StaticResource SliderThumb}"/>
|
||||
</Track.Thumb>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource SliderRepeatButton}" Command="Slider.IncreaseLarge" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
</Track>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="Horizontal_Slider" TargetType="Slider">
|
||||
<Setter Property="Focusable" Value="False"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="true"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Width" Value="205"/>
|
||||
<Setter Property="Height" Value="21"/>
|
||||
<Setter Property="Foreground" Value="{x:Null}"/>
|
||||
<Setter Property="FontSize" Value="8"/>
|
||||
<Setter Property="Margin" Value="5,0,10,0"/>
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Orientation" Value="Horizontal">
|
||||
<Setter Property="MinHeight" Value="21"/>
|
||||
<Setter Property="MinWidth" Value="104"/>
|
||||
<Setter Property="Template" Value="{StaticResource Slider}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
|
||||
</Style>
|
||||
|
||||
<LinearGradientBrush x:Key="ListBoxBackgroundBrush" StartPoint="0,0" EndPoint="1,0.001">
|
||||
<GradientBrush.GradientStops>
|
||||
<GradientStopCollection>
|
||||
<GradientStop Color="White" Offset="0.0"/>
|
||||
<GradientStop Color="White" Offset="0.6"/>
|
||||
<GradientStop Color="#DDDDDD" Offset="1.2"/>
|
||||
</GradientStopCollection>
|
||||
</GradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<LinearGradientBrush x:Key="StandardBrush" StartPoint="0,0" EndPoint="0,1">
|
||||
<GradientBrush.GradientStops>
|
||||
<GradientStopCollection>
|
||||
<GradientStop Color="#FFF" Offset="0.0"/>
|
||||
<GradientStop Color="#CCC" Offset="1.0"/>
|
||||
</GradientStopCollection>
|
||||
</GradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
|
||||
<GradientBrush.GradientStops>
|
||||
<GradientStopCollection>
|
||||
<GradientStop Color="#BBB" Offset="0.0"/>
|
||||
<GradientStop Color="#EEE" Offset="0.1"/>
|
||||
<GradientStop Color="#EEE" Offset="0.9"/>
|
||||
<GradientStop Color="#FFF" Offset="1.0"/>
|
||||
</GradientStopCollection>
|
||||
</GradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<Style x:Key="ScrollBarBackground" TargetType="{x:Type Border}">
|
||||
<Setter Property="Margin" Value="2"/>
|
||||
<Setter Property="CornerRadius" Value="6"/>
|
||||
<Setter Property="Background" Value="{DynamicResource H2}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Background" Value="{x:Null}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
|
||||
--><!--上下按鈕 不顯示--><!--
|
||||
<Setter Property="Visibility" Value="Hidden"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type RepeatButton}">
|
||||
<Border Name="Border" Margin="1" CornerRadius="2" Background="{DynamicResource H2}" BorderBrush="{DynamicResource H2}" BorderThickness="1">
|
||||
<Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{DynamicResource H2}" Data="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="{StaticResource PressedBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type RepeatButton}">
|
||||
<Border Background="{x:Null}" Margin="1"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Border CornerRadius="4" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Width="7"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MaxHeight="5"/>
|
||||
<RowDefinition Height="0.00001*"/>
|
||||
<RowDefinition MaxHeight="5"/>
|
||||
</Grid.RowDefinitions>
|
||||
--><!--直向拉竿背景--><!--
|
||||
<Border Grid.RowSpan="4" Style="{StaticResource ScrollBarBackground}"/>
|
||||
--><!--往上按鈕 ※隱藏--><!--
|
||||
<RepeatButton Grid.Row="0" Style="{StaticResource ScrollBarLineButton}" Height="18" Command="ScrollBar.LineUpCommand" Content="M 0 4 L 8 4 L 4 0 Z" />
|
||||
<Track Name="PART_Track" Grid.Row="1" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}" >
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="1,0,1,0" Background="{DynamicResource H3}" BorderBrush="{DynamicResource H3}" />
|
||||
</Track.Thumb>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageDownCommand" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
</Track>
|
||||
--><!--往下按鈕 ※隱藏--><!--
|
||||
<RepeatButton Grid.Row="3" Style="{StaticResource ScrollBarLineButton}" Height="18" Command="ScrollBar.LineDownCommand" Content="M 0 0 L 4 4 L 8 0 Z"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition MaxWidth="18"/>
|
||||
<ColumnDefinition Width="0.00001*"/>
|
||||
<ColumnDefinition MaxWidth="18"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
--><!--橫向拉竿背景--><!--
|
||||
<Border Grid.ColumnSpan="3" CornerRadius="2" Background="{x:Null}"/>
|
||||
<RepeatButton Grid.Column="0" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineLeftCommand" Content="M 4 0 L 4 8 L 0 4 Z" />
|
||||
<Track Name="PART_Track" Grid.Column="1" IsDirectionReversed="False">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageLeftCommand" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="0,1,0,1" Background="{DynamicResource H3}" BorderBrush="{DynamicResource H3}" />
|
||||
</Track.Thumb>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageRightCommand" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
</Track>
|
||||
<RepeatButton Grid.Column="3" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineRightCommand" Content="M 0 0 L 4 4 L 0 8 Z"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Orientation" Value="Horizontal">
|
||||
<Setter Property="Width" Value="Auto"/>
|
||||
<Setter Property="Height" Value="18" />
|
||||
<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
|
||||
</Trigger>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="Width" Value="18"/>
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="FavsScrollViewer" TargetType="{x:Type ScrollViewer}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ScrollViewer}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollContentPresenter Grid.Column="1"/>
|
||||
<ScrollBar Name="PART_VerticalScrollBar" Value="{TemplateBinding VerticalOffset}" Maximum="{TemplateBinding ScrollableHeight}" ViewportSize="{TemplateBinding ViewportHeight}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
|
||||
<ScrollBar Name="PART_HorizontalScrollBar" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Value="{TemplateBinding HorizontalOffset}" Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>-->
|
||||
</ResourceDictionary>
|
||||
115
Language/CulturesHelper.cs
Normal file
115
Language/CulturesHelper.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace CMM.Language
|
||||
{
|
||||
public class CulturesHelper
|
||||
{
|
||||
private bool _isFoundInstalledCultures = false;
|
||||
|
||||
const string LanguageFolder = "/Language;component";
|
||||
const string ResourceLocalPath = "pack://application:,," + LanguageFolder;
|
||||
const string LanguageFileName = "StringResources";
|
||||
|
||||
public List<CultureInfo> SupportedCultures { get; private set; } = new List<CultureInfo>();
|
||||
|
||||
public CulturesHelper() => Init();
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (!_isFoundInstalledCultures)
|
||||
{
|
||||
var cultureInfo = new CultureInfo("");
|
||||
|
||||
var Languages = GetAllLanguageResource();
|
||||
|
||||
GetAllLanguageResource().ForEach(file =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string cultureName = file.Substring(file.IndexOf(".") + 1).Replace(".xaml", "");
|
||||
|
||||
cultureInfo = CultureInfo.GetCultureInfo(cultureName);
|
||||
|
||||
if (cultureInfo != null)
|
||||
{
|
||||
SupportedCultures.Add(cultureInfo);
|
||||
}
|
||||
}
|
||||
catch (ArgumentException) { }
|
||||
});
|
||||
|
||||
_isFoundInstalledCultures = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加Language的XMAL檔
|
||||
/// </summary>
|
||||
private static List<string> GetAllLanguageResource()
|
||||
{
|
||||
var Languages = new List<string>();
|
||||
string uriPath = ResourceLocalPath + "/" + LanguageFileName;
|
||||
|
||||
Languages.Add(uriPath + ".en-US.xaml");
|
||||
Languages.Add(uriPath + ".zh-TW.xaml");
|
||||
|
||||
return Languages;
|
||||
}
|
||||
|
||||
public void ChangeCulture(string cultureName)
|
||||
{
|
||||
var cultureInfo = CultureInfo.GetCultureInfo(cultureName);
|
||||
|
||||
if (cultureInfo != null)
|
||||
{
|
||||
ChangeCulture(cultureInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切換語系
|
||||
/// </summary>
|
||||
public void ChangeCulture(CultureInfo culture)
|
||||
{
|
||||
if (SupportedCultures.Contains(culture))
|
||||
{
|
||||
var existsRD = Application.Current.Resources.MergedDictionaries
|
||||
.Where(x => x.Source.OriginalString.StartsWith(ResourceLocalPath, StringComparison.CurrentCultureIgnoreCase) ||
|
||||
x.Source.OriginalString.StartsWith(LanguageFolder, StringComparison.CurrentCultureIgnoreCase))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (existsRD == null) return;
|
||||
|
||||
var resourceFile = $"{ResourceLocalPath}/{LanguageFileName}.{culture.Name}.xaml";
|
||||
var res = new ResourceDictionary()
|
||||
{
|
||||
Source = new Uri(resourceFile, UriKind.Absolute)
|
||||
};
|
||||
|
||||
Application.Current.Resources.MergedDictionaries.Remove(existsRD);
|
||||
Application.Current.Resources.MergedDictionaries.Add(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Lang
|
||||
{
|
||||
public static string Find(string key)
|
||||
{
|
||||
if (Application.Current == null) return null;
|
||||
|
||||
try
|
||||
{
|
||||
return (string)Application.Current.FindResource(key);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Language/Language.csproj
Normal file
35
Language/Language.csproj
Normal file
@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<RootNamespace>CMM.Language</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Product>ControlMyMonitorManagement</Product>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||
<Major>1</Major>
|
||||
<Minor>0</Minor>
|
||||
<ProjectStartedDate>$([System.DateTime]::op_Subtraction($([System.DateTime]::get_Now().get_Date()),$([System.DateTime]::new(2017,9,17))).get_TotalDays())</ProjectStartedDate>
|
||||
<DaysSinceProjectStarted>$([System.DateTime]::Now.ToString(Hmm))</DaysSinceProjectStarted>
|
||||
<DateTimeSuffix>$([System.DateTime]::Now.ToString(yyyyMMdd))</DateTimeSuffix>
|
||||
<VersionSuffix>$(Major).$(Minor).$(ProjectStartedDate).$(DaysSinceProjectStarted)</VersionSuffix>
|
||||
<AssemblyVersion Condition=" '$(DateTimeSuffix)' == '' ">0.0.0.1</AssemblyVersion>
|
||||
<AssemblyVersion Condition=" '$(DateTimeSuffix)' != '' ">$(VersionSuffix)</AssemblyVersion>
|
||||
<Version Condition=" '$(DateTimeSuffix)' == '' ">0.0.0.1</Version>
|
||||
<Version Condition=" '$(DateTimeSuffix)' != '' ">$(DateTimeSuffix)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="StringResources.en-US.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</None>
|
||||
<None Update="StringResources.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</None>
|
||||
<None Update="StringResources.zh-TW.xam">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
5
Language/StringResources.en-US.xaml
Normal file
5
Language/StringResources.en-US.xaml
Normal file
@ -0,0 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
</ResourceDictionary>
|
||||
5
Language/StringResources.xaml
Normal file
5
Language/StringResources.xaml
Normal file
@ -0,0 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
</ResourceDictionary>
|
||||
5
Language/StringResources.zh-TW.xam
Normal file
5
Language/StringResources.zh-TW.xam
Normal file
@ -0,0 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
</ResourceDictionary>
|
||||
70
Library/Base/ObservableRangeCollection.cs
Normal file
70
Library/Base/ObservableRangeCollection.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace CMM.Library.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class ObservableRangeCollection<T> : ObservableCollection<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds the elements of the specified collection to the end of the ObservableCollection(Of T).
|
||||
/// </summary>
|
||||
public void AddRange(IEnumerable<T> collection)
|
||||
{
|
||||
if (collection == null) throw new ArgumentNullException("collection");
|
||||
|
||||
foreach (var i in collection) Items.Add(i);
|
||||
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurence of each item in the specified collection from ObservableCollection(Of T).
|
||||
/// </summary>
|
||||
public void RemoveRange(IEnumerable<T> collection)
|
||||
{
|
||||
if (collection == null) throw new ArgumentNullException("collection");
|
||||
|
||||
foreach (var i in collection) Items.Remove(i);
|
||||
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the current collection and replaces it with the specified item.
|
||||
/// </summary>
|
||||
public void Replace(T item)
|
||||
{
|
||||
ReplaceRange(new T[] { item });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the current collection and replaces it with the specified collection.
|
||||
/// </summary>
|
||||
public void ReplaceRange(IEnumerable<T> collection)
|
||||
{
|
||||
if (collection == null) throw new ArgumentNullException("collection");
|
||||
|
||||
Items.Clear();
|
||||
foreach (var i in collection) Items.Add(i);
|
||||
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class.
|
||||
/// </summary>
|
||||
public ObservableRangeCollection()
|
||||
: base() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class that contains elements copied from the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="collection">collection: The collection from which the elements are copied.</param>
|
||||
/// <exception cref="System.ArgumentNullException">The collection parameter cannot be null.</exception>
|
||||
public ObservableRangeCollection(IEnumerable<T> collection)
|
||||
: base(collection) { }
|
||||
}
|
||||
}
|
||||
31
Library/Base/PropertyBase.cs
Normal file
31
Library/Base/PropertyBase.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace CMM.Library.Base
|
||||
{
|
||||
public class PropertyBase : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
virtual internal protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (this.PropertyChanged != null)
|
||||
{
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
protected void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
protected void SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
||||
{
|
||||
if (object.Equals(storage, value)) return;
|
||||
|
||||
storage = value;
|
||||
this.OnPropertyChanged(propertyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Library/Config/Config.cs
Normal file
76
Library/Config/Config.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using CMM.Language;
|
||||
using CMM.Library.Base;
|
||||
using CMM.Library.Helpers;
|
||||
using CMM.Library.Method;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace CMM.Library.Config
|
||||
{
|
||||
public class XConfig : PropertyBase
|
||||
{
|
||||
[JsonIgnore]
|
||||
public string Version { get; private set; }
|
||||
|
||||
public static string ConfigFileName => Path.Combine(AssemblyData.Path, "Config.cfg");
|
||||
|
||||
#region Language
|
||||
[JsonIgnore]
|
||||
public CultureInfo Culture
|
||||
{
|
||||
get => _Culture;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _Culture, value);
|
||||
LoadCultures();
|
||||
}
|
||||
}
|
||||
CultureInfo _Culture;
|
||||
public string Language { get; set; } = null;
|
||||
CulturesHelper CulturesHelper { get; init; } = new();
|
||||
public void LoadCultures()
|
||||
{
|
||||
if (CulturesHelper == null) return;
|
||||
|
||||
CulturesHelper.ChangeCulture(Culture);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public virtual void Load()
|
||||
{
|
||||
XConfig _base = null;
|
||||
if (new FileInfo(ConfigFileName).Exists)
|
||||
{
|
||||
try
|
||||
{
|
||||
_base = ConfigFileName.JsonFormFile<XConfig>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"{Lang.Find("LoadConfigErr")}{ex.Message}", "failed", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
this.Culture = _base?.Culture ?? new CultureInfo(_base?.Language ?? "en-US", false);
|
||||
this.Version = $"{AssemblyData.AppName} {AssemblyData.AppVersion}";
|
||||
}
|
||||
|
||||
public virtual void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.FileToJson(ConfigFileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"{Lang.Find("SaveConfigErr")}{ex.Message}", "failed", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Library/Extensions/MonitorExtension.cs
Normal file
13
Library/Extensions/MonitorExtension.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.Extensions
|
||||
{
|
||||
public static class MonitorExtension
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
71
Library/Helpers/ConsoleHelper.cs
Normal file
71
Library/Helpers/ConsoleHelper.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.Helpers
|
||||
{
|
||||
internal class ConsoleHelper
|
||||
{
|
||||
const string cmdFileName = "cmd.exe";
|
||||
private static Process CreatProcess(string fileName) =>
|
||||
new Process()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true,
|
||||
}
|
||||
};
|
||||
|
||||
public static async Task<string> CmdCommandAsync(params string[] cmds) =>
|
||||
await CommandAsync(cmdFileName, cmds);
|
||||
|
||||
public static string CmdCommand(params string[] cmds) =>
|
||||
Command(cmdFileName, cmds);
|
||||
|
||||
public static async Task<string> CommandAsync(string fileName, params string[] cmds)
|
||||
{
|
||||
var p = CreatProcess(fileName);
|
||||
p.Start();
|
||||
foreach (var cmd in cmds)
|
||||
{
|
||||
p.StandardInput.WriteLine(cmd);
|
||||
}
|
||||
p.StandardInput.WriteLine("exit");
|
||||
var result = await p.StandardOutput.ReadToEndAsync();
|
||||
var error = await p.StandardError.ReadToEndAsync();
|
||||
if (!string.IsNullOrWhiteSpace(error))
|
||||
result = result + "\r\n<Error Message>:\r\n" + error;
|
||||
await p.WaitForExitAsync();
|
||||
p.Close();
|
||||
Debug.WriteLine(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string Command(string fileName, params string[] cmds)
|
||||
{
|
||||
var p = CreatProcess(fileName);
|
||||
p.Start();
|
||||
foreach (var cmd in cmds)
|
||||
{
|
||||
p.StandardInput.WriteLine(cmd);
|
||||
}
|
||||
p.StandardInput.WriteLine("exit");
|
||||
var result = p.StandardOutput.ReadToEnd();
|
||||
var error = p.StandardError.ReadToEnd();
|
||||
if (!string.IsNullOrWhiteSpace(error))
|
||||
result = result + "\r\n<Error Message>:\r\n" + error;
|
||||
p.WaitForExit();
|
||||
p.Close();
|
||||
Debug.WriteLine(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Library/Helpers/FileHelper.cs
Normal file
29
Library/Helpers/FileHelper.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.Helpers
|
||||
{
|
||||
internal static class FileHelper
|
||||
{
|
||||
public static byte[] ResourceToByteArray(this string fileName)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var resourceName =
|
||||
assembly.GetManifestResourceNames().
|
||||
Where(str => str.Contains(fileName)).FirstOrDefault();
|
||||
if (resourceName == null) return null;
|
||||
|
||||
using (var stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
stream.CopyTo(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
131
Library/Helpers/JsonHelper.cs
Normal file
131
Library/Helpers/JsonHelper.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.Helpers
|
||||
{
|
||||
static class JsonSerializerExtensions
|
||||
{
|
||||
public static JsonSerializerOptions defaultSettings = new JsonSerializerOptions()
|
||||
{
|
||||
WriteIndented = true,
|
||||
IgnoreNullValues = true,
|
||||
PropertyNamingPolicy = null,
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
};
|
||||
}
|
||||
|
||||
internal static class JsonHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 複製整個obj全部結構
|
||||
/// </summary>
|
||||
public static T DeepCopy<T>(T RealObject) =>
|
||||
JsonSerializer.Deserialize<T>(JsonSerializer.Serialize(RealObject, JsonSerializerExtensions.defaultSettings));
|
||||
|
||||
public static string JsonFormResource(this string fileName)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var resourceName =
|
||||
assembly.GetManifestResourceNames().
|
||||
Where(str => str.Contains(fileName)).FirstOrDefault();
|
||||
if (resourceName == null) return "";
|
||||
|
||||
using (var stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (var reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public static T JsonFormResource<T>(this string fileName) =>
|
||||
JsonFormString<T>(JsonFormResource(fileName));
|
||||
|
||||
public static T JsonFormFile<T>(this string fileName) =>
|
||||
JsonFormString<T>(Load(fileName));
|
||||
|
||||
public static T JsonFormString<T>(this string json) =>
|
||||
JsonSerializer.Deserialize<T>(json);
|
||||
|
||||
public static void FileToJson<T>(this T payload, string savePath) =>
|
||||
Save(savePath, payload.ToJson());
|
||||
|
||||
public static string ToJson<T>(this T payload) =>
|
||||
JsonSerializer.Serialize(payload, JsonSerializerExtensions.defaultSettings);
|
||||
|
||||
/// <summary>
|
||||
/// 從Embedded resource讀string
|
||||
/// </summary>
|
||||
/// <param name="aFileName">resource位置,不含副檔名</param>
|
||||
public static string GetResource(this Assembly assembly, string aFileName)
|
||||
{
|
||||
var resourceName = assembly
|
||||
.GetManifestResourceNames()
|
||||
.Where(str => str.Contains(aFileName))
|
||||
.FirstOrDefault();
|
||||
if (resourceName == null) return "";
|
||||
|
||||
using (var stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (var sr = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
return sr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public static string Load(string aFileName) =>
|
||||
Load(new FileInfo(aFileName));
|
||||
|
||||
public static string Load(FileInfo aFi)
|
||||
{
|
||||
if (aFi.Exists)
|
||||
{
|
||||
string _Json = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
var sr = new StreamReader(aFi.FullName);
|
||||
_Json = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
}
|
||||
catch (IOException) { throw; }
|
||||
catch (Exception) { throw; }
|
||||
|
||||
return _Json;
|
||||
}
|
||||
|
||||
throw new Exception("開檔失敗。");
|
||||
}
|
||||
|
||||
public static void Save(string filePath, string content) =>
|
||||
Save(new FileInfo(filePath), content);
|
||||
|
||||
public static void Save(FileInfo aFi, string aContent)
|
||||
{
|
||||
if (!aFi.Directory.Exists)
|
||||
{
|
||||
aFi.Directory.Create();
|
||||
}
|
||||
|
||||
if (aFi.Exists)
|
||||
{
|
||||
aFi.Delete();
|
||||
}
|
||||
|
||||
aFi.Refresh();
|
||||
if (aFi.Exists) throw new Exception("寫檔失敗,檔案已存在或已開啟。");
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllText(aFi.FullName, aContent);
|
||||
}
|
||||
catch (IOException) { throw; }
|
||||
catch (Exception) { throw; }
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Library/Helpers/UAC.cs
Normal file
18
Library/Helpers/UAC.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace CMM.Library.Helpers
|
||||
{
|
||||
public class UAC
|
||||
{
|
||||
public static void Check()
|
||||
{
|
||||
var identity = WindowsIdentity.GetCurrent();
|
||||
var principal = new WindowsPrincipal(identity);
|
||||
if (!principal.IsInRole(WindowsBuiltInRole.Administrator))
|
||||
throw new Exception($"Cannot delete task with your current identity '{identity.Name}' permissions level." +
|
||||
"You likely need to run this application 'as administrator' even if you are using an administrator account.");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Library/Library.csproj
Normal file
40
Library/Library.csproj
Normal file
@ -0,0 +1,40 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>CMM.Library</RootNamespace>
|
||||
<Product>ControlMyMonitorManagement</Product>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Company>Dang</Company>
|
||||
<Copyright>Copyright © DangWang $([System.DateTime]::Now.ToString(yyyy))</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||
<Major>1</Major>
|
||||
<Minor>0</Minor>
|
||||
<ProjectStartedDate>$([System.DateTime]::op_Subtraction($([System.DateTime]::get_Now().get_Date()),$([System.DateTime]::new(2017,9,17))).get_TotalDays())</ProjectStartedDate>
|
||||
<DaysSinceProjectStarted>$([System.DateTime]::Now.ToString(Hmm))</DaysSinceProjectStarted>
|
||||
<DateTimeSuffix>$([System.DateTime]::Now.ToString(yyyyMMdd))</DateTimeSuffix>
|
||||
<VersionSuffix>$(Major).$(Minor).$(ProjectStartedDate).$(DaysSinceProjectStarted)</VersionSuffix>
|
||||
<AssemblyVersion Condition=" '$(DateTimeSuffix)' == '' ">0.0.0.1</AssemblyVersion>
|
||||
<AssemblyVersion Condition=" '$(DateTimeSuffix)' != '' ">$(VersionSuffix)</AssemblyVersion>
|
||||
<Version Condition=" '$(DateTimeSuffix)' == '' ">0.0.0.1</Version>
|
||||
<Version Condition=" '$(DateTimeSuffix)' != '' ">$(DateTimeSuffix)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Resource\ControlMyMonitor.exe" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resource\ControlMyMonitor.exe">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Language\Language.csproj" />
|
||||
<ProjectReference Include="..\Tester\Tester.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
48
Library/Method/AssemblyData.cs
Normal file
48
Library/Method/AssemblyData.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.Method
|
||||
{
|
||||
public static class AssemblyData
|
||||
{
|
||||
/// <summary>
|
||||
/// 當下Assembly名稱
|
||||
/// </summary>
|
||||
public static string AssemblyName => System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
|
||||
|
||||
public static string AppName => AppDomain.CurrentDomain.FriendlyName;
|
||||
|
||||
/// <summary>
|
||||
/// 程式根目錄,無視工作目錄
|
||||
/// </summary>
|
||||
public static string Path => AppDomain.CurrentDomain.BaseDirectory;
|
||||
/// <summary>
|
||||
/// 版本
|
||||
/// </summary>
|
||||
public static string AssemblyVersion => GetAssemblyVersion();
|
||||
public static string AppVersion => GetFileVersion(Process.GetCurrentProcess().MainModule.FileName);
|
||||
/// <summary>
|
||||
/// CCM 輸出
|
||||
/// </summary>
|
||||
public static string smonitors => System.IO.Path.Combine(Path, "smonitors.tmp");
|
||||
|
||||
static string GetAssemblyVersion()
|
||||
{
|
||||
var fi = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.Replace(@"file:///", "");
|
||||
return GetFileVersion(fi);
|
||||
}
|
||||
|
||||
public static string GetFileVersion(string filePath)
|
||||
{
|
||||
var fvi = FileVersionInfo.GetVersionInfo(filePath);
|
||||
return $"{fvi.FileMajorPart}." +
|
||||
$"{fvi.FileMinorPart}." +
|
||||
$"{fvi.FileBuildPart}." +
|
||||
$"{fvi.FilePrivatePart}";
|
||||
}
|
||||
}
|
||||
}
|
||||
177
Library/Method/CMMCommand.cs
Normal file
177
Library/Method/CMMCommand.cs
Normal file
@ -0,0 +1,177 @@
|
||||
using CMM.Library.Base;
|
||||
using CMM.Library.Helpers;
|
||||
using CMM.Library.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.Method
|
||||
{
|
||||
/// <summary>
|
||||
/// Control My Monitor Management Command
|
||||
/// </summary>
|
||||
public static class CMMCommand
|
||||
{
|
||||
static readonly string CMMTmpFolder = Path.Combine(Path.GetTempPath(), $"CMM");
|
||||
static readonly string CMMexe = Path.Combine(CMMTmpFolder, "ControlMyMonitor.exe");
|
||||
static readonly string CMMsMonitors = Path.Combine(CMMTmpFolder, "smonitors.tmp");
|
||||
static readonly string CMMcfg = Path.Combine(CMMTmpFolder, "ControlMyMonitor.cfg");
|
||||
|
||||
public static async Task ScanMonitor()
|
||||
{
|
||||
await BytesToFileAsync(new(CMMexe));
|
||||
await ConsoleHelper.CmdCommandAsync($"{CMMexe} /smonitors {CMMsMonitors}");
|
||||
}
|
||||
|
||||
public static async Task ScanMonitorInterfaces(IEnumerable<XMonitor> monitors)
|
||||
{
|
||||
var taskList = new List<Task>();
|
||||
foreach (var mon in monitors)
|
||||
{
|
||||
taskList.Add(Task.Run(async () => await
|
||||
ScanMonitorInterfaces($"{CMMTmpFolder}\\{mon.SerialNumber}.tmp", mon)));
|
||||
}
|
||||
|
||||
await Task.WhenAll(taskList.ToArray());
|
||||
}
|
||||
|
||||
static async Task ScanMonitorInterfaces(string savePath, XMonitor mon)
|
||||
{
|
||||
//await ConsoleHelper.CmdCommandAsync($"{CMMexe} /scomma {savePath} {mon.MonitorID}");
|
||||
await mon.ReadMonitorStatus(savePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得螢幕狀態
|
||||
/// </summary>
|
||||
public static async Task ReadMonitorStatus(this XMonitor @this, string filePath)
|
||||
{
|
||||
var statusColle = new ObservableRangeCollection<XMonitorStatus>();
|
||||
|
||||
if (!File.Exists(filePath)) return;
|
||||
|
||||
foreach (var line in await File.ReadAllLinesAsync(filePath))
|
||||
{
|
||||
var sp = line.Split(",");
|
||||
if (sp.Length < 6) continue;
|
||||
|
||||
statusColle.Add(new XMonitorStatus
|
||||
{
|
||||
VCP_Code = StrTrim(sp[0]),
|
||||
VCPCodeName = StrTrim(sp[1]),
|
||||
Read_Write = StrTrim(sp[2]),
|
||||
CurrentValue = TryGetInt(sp[3]),
|
||||
MaximumValue = TryGetInt(sp[4]),
|
||||
PossibleValues = TryGetArrStr(sp),
|
||||
});
|
||||
}
|
||||
|
||||
@this.Status = statusColle;
|
||||
|
||||
string StrTrim(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str)) return null;
|
||||
return str;
|
||||
}
|
||||
|
||||
string TryGetArrStr(string[] strArr)
|
||||
{
|
||||
if (strArr.Length < 7) return null;
|
||||
|
||||
var outStr = string.Join(",", strArr[5..]);
|
||||
outStr = outStr.Substring(1, outStr.Length - 2);
|
||||
return outStr;
|
||||
}
|
||||
|
||||
int? TryGetInt(string str)
|
||||
{
|
||||
if (int.TryParse(str, out var value)) return value;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得螢幕清單
|
||||
/// </summary>
|
||||
public static async Task<IEnumerable<XMonitor>> ReadMonitorsData()
|
||||
{
|
||||
var monitors = new List<XMonitor>();
|
||||
|
||||
if (!File.Exists(CMMsMonitors)) return monitors;
|
||||
|
||||
XMonitor mon = null;
|
||||
string context;
|
||||
foreach (var line in await File.ReadAllLinesAsync(CMMsMonitors))
|
||||
{
|
||||
var sp = line.Split(":", StringSplitOptions.RemoveEmptyEntries);
|
||||
try
|
||||
{
|
||||
if (sp.Length != 2 || string.IsNullOrEmpty(sp[1])) continue;
|
||||
|
||||
context = sp[1].Substring(2, sp[1].Length - 3);
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sp[0].StartsWith("Monitor Device Name"))
|
||||
{
|
||||
mon = new XMonitor();
|
||||
mon.MonitorDeviceName = context;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sp[0].StartsWith("Monitor Name"))
|
||||
{
|
||||
mon.MonitorName = context;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sp[0].StartsWith("Serial Number"))
|
||||
{
|
||||
mon.SerialNumber = context;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sp[0].StartsWith("Adapter Name"))
|
||||
{
|
||||
mon.AdapterName = context;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sp[0].StartsWith("Monitor ID"))
|
||||
{
|
||||
mon.MonitorID = context;
|
||||
monitors.Add(mon);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return monitors;
|
||||
}
|
||||
|
||||
static void BytesToFile(FileInfo fi)
|
||||
{
|
||||
fi.Refresh();
|
||||
if (fi.Exists) return;
|
||||
if (!fi.Directory.Exists) fi.Directory.Create();
|
||||
|
||||
File.WriteAllBytes(fi.FullName, fi.Name.ResourceToByteArray());
|
||||
}
|
||||
|
||||
static async Task BytesToFileAsync(FileInfo fi)
|
||||
{
|
||||
fi.Refresh();
|
||||
if (fi.Exists) return;
|
||||
if (!fi.Directory.Exists) fi.Directory.Create();
|
||||
|
||||
await File.WriteAllBytesAsync(fi.FullName, fi.Name.ResourceToByteArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
29
Library/Method/CMMMgr.cs
Normal file
29
Library/Method/CMMMgr.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using CMM.Library.Base;
|
||||
using CMM.Library.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.Method
|
||||
{
|
||||
public class CMMMgr : PropertyBase
|
||||
{
|
||||
public ObservableRangeCollection<XMonitor> Monitors
|
||||
{
|
||||
get => _Monitors;
|
||||
set { SetProperty(ref _Monitors, value); }
|
||||
}
|
||||
ObservableRangeCollection<XMonitor> _Monitors = new ();
|
||||
|
||||
public async Task Init()
|
||||
{
|
||||
await CMMCommand.ScanMonitor();
|
||||
var monColle = new ObservableRangeCollection<XMonitor>();
|
||||
monColle.AddRange(await CMMCommand.ReadMonitorsData());
|
||||
Monitors = monColle;
|
||||
await CMMCommand.ScanMonitorInterfaces(monColle);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Library/Resource/ControlMyMonitor.chm
Normal file
BIN
Library/Resource/ControlMyMonitor.chm
Normal file
Binary file not shown.
BIN
Library/Resource/ControlMyMonitor.exe
Normal file
BIN
Library/Resource/ControlMyMonitor.exe
Normal file
Binary file not shown.
393
Library/Resource/readme.txt
Normal file
393
Library/Resource/readme.txt
Normal file
@ -0,0 +1,393 @@
|
||||
|
||||
|
||||
|
||||
ControlMyMonitor v1.35
|
||||
Copyright (c) 2017 - 2022 Nir Sofer
|
||||
Web site: https://www.nirsoft.net
|
||||
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
|
||||
ControlMyMonitor allows you view and modify the settings of your monitor
|
||||
(Also known as 'VCP Features'), like brightness, contrast, sharpness,
|
||||
red/green/blue color balance, OSD Language, Input Port (VGA , DVI , HDMI
|
||||
) and more... You can modify the monitor settings from the GUI and from
|
||||
command-line. You can also export all settings of your monitor into a
|
||||
configuration file and then later load the same configuration back into
|
||||
your monitor.
|
||||
|
||||
|
||||
|
||||
System Requirements
|
||||
===================
|
||||
|
||||
|
||||
* Any version of Windows, starting from Windows Vista and up to Windows
|
||||
11.
|
||||
* Hardware that supports DDC/CI.
|
||||
|
||||
|
||||
|
||||
Versions History
|
||||
================
|
||||
|
||||
|
||||
* Version 1.35:
|
||||
o Added 4 display filter options: Display Read+Write, Display Read
|
||||
Only, Display Write Only, Display Manufacturer Specific.
|
||||
|
||||
* Version 1.31:
|
||||
o you can now use 'Secondary' as the monitor string in all
|
||||
command-line options in order to specify the secondary monitor.
|
||||
|
||||
* Version 1.30:
|
||||
o When there is a DDC/CI error (Error codes like 0xC0262582,
|
||||
0xC0262583), the error description is now displayed in the status bar
|
||||
in addition to the error code.
|
||||
o You can also click the error code with the mouse in order to copy
|
||||
the error code and error description to the clipboard.
|
||||
|
||||
* Version 1.29:
|
||||
o Added option to choose another font (name and size) to display in
|
||||
the main window.
|
||||
|
||||
* Version 1.28:
|
||||
o Fixed some display issues in high DPI mode (Toolbar and status
|
||||
bar).
|
||||
|
||||
* Version 1.27:
|
||||
o Added /TurnOff command-line option to turn off the specified
|
||||
monitor.
|
||||
o Added /TurnOn command-line option to turn on the specified
|
||||
monitor.
|
||||
o Added /SwitchOffOn command-line option to switch the specified
|
||||
monitor between on and off state.
|
||||
|
||||
* Version 1.26:
|
||||
o When ControlMyMonitor fails to get the current monitor settings,
|
||||
error code is now displayed in the status bar.
|
||||
|
||||
* Version 1.25:
|
||||
o Added 'Put Icon On Tray' option.
|
||||
|
||||
* Version 1.20:
|
||||
o Added /SwitchValue command-line option, which allows you to
|
||||
switch between multiple values.
|
||||
o For example, in order to switch the monitor off when it's turned
|
||||
on and switch it on when it's turned off, use the following command:
|
||||
(On some monitors you should use 4 instead of 5)
|
||||
ControlMyMonitor.exe /SwitchValue "\\.\DISPLAY1\Monitor0" D6 1 5
|
||||
|
||||
* Version 1.17:
|
||||
o When pressing F5 (Refresh) the refresh process is smoother,
|
||||
keeping the last selected item.
|
||||
o Added 'Load Selected Monitor On Start' option.
|
||||
|
||||
* Version 1.16:
|
||||
o Added /GetValue command-line option, which returns the current
|
||||
value of the specified VCP Code, for example:
|
||||
ControlMyMonitor.exe /GetValue "\\.\DISPLAY1\Monitor0" 10
|
||||
echo %errorlevel%
|
||||
|
||||
* Version 1.15:
|
||||
o Added /SetValueIfNeeded command-line option, which sets a value
|
||||
only if the current value is different from the value you want to set.
|
||||
|
||||
* Version 1.12:
|
||||
o Added 'Add Header Line To CSV/Tab-Delimited File' option (Turned
|
||||
on by default).
|
||||
|
||||
* Version 1.11:
|
||||
o Added /smonitors command-line option to save the monitors list
|
||||
into a text file.
|
||||
o Added 'Save All Items' option (Shift+Ctrl+S).
|
||||
|
||||
* Version 1.10:
|
||||
o Added save command-line options (/scomma, /stab , /shtml, and so
|
||||
on...) to export the current monitor settings into a file.
|
||||
o Added support for JSON file in 'Save Selected Items' option.
|
||||
|
||||
* Version 1.05:
|
||||
o Added 'Refresh Monitors List' option (Ctrl+F5).
|
||||
|
||||
* Version 1.00 - First release.
|
||||
|
||||
|
||||
|
||||
Start Using ControlMyMonitor
|
||||
============================
|
||||
|
||||
ControlMyMonitor doesn't require any installation process or additional
|
||||
DLL files. In order to start using it simply run the executable file -
|
||||
ControlMyMonitor.exe
|
||||
|
||||
After running ControlMyMonitor, the current settings of your monitor are
|
||||
displayed in the main window. If you have multiple monitors, you can
|
||||
choose another monitor from the monitor combo-box below the toolbar.
|
||||
In order to modify a single item, select the item that you want to
|
||||
change, and then double click the item (or press the F6 key). You can
|
||||
also increase or decrease the current value by using the 'Increase Value'
|
||||
or 'Decrease Value' options (Under the Action menu). You can also
|
||||
increase/decrease values by using the mouse wheel, according to the
|
||||
selected option in Options -> Change Value With Mouse Wheel. By default,
|
||||
the mouse wheel feature is active when you hold down the Ctrl key.
|
||||
|
||||
|
||||
|
||||
Restore Factory Defaults
|
||||
========================
|
||||
|
||||
There are some write-only items that allow you to restore the factory
|
||||
defaults of the monitor. In order to activate these items, you have to
|
||||
set the value to 1.
|
||||
|
||||
|
||||
|
||||
Save/Load Config
|
||||
================
|
||||
|
||||
ControlMyMonitor allows you to export all read/write properties into a
|
||||
simple text file and then later load these properties back to the
|
||||
monitor. You can find the save/load config feature under the File menu
|
||||
('Save Monitor Config' and 'Load Monitor Config').
|
||||
|
||||
|
||||
|
||||
Error 0xc0262582, 0xc0262583 and similar codes
|
||||
==============================================
|
||||
|
||||
If you get error 0xc0262582 (or similar codes) and the main window of
|
||||
ControlMyMonitor is empty, it means that Windows operating system cannot
|
||||
connect your monitor using DDC/CI.
|
||||
Here's what you can do in order to try to solve the problem:
|
||||
* Update the driver of your graphics card.
|
||||
* Try to plug your monitor using different type of cable/connector
|
||||
(VGA, DVI, HDMI, DisplayPort).
|
||||
* If you use a KVM switch, try to plug your monitor directly to the
|
||||
computer, without the KVM switch.
|
||||
|
||||
|
||||
|
||||
|
||||
Before you report a bug...
|
||||
==========================
|
||||
|
||||
Be aware that if you have a specific setting that ControlMyMonitor fails
|
||||
to set properly or ControlMyMonitor fails to connect your monitor
|
||||
completely with error code (usually begins with 0xc02625 ), It's not a
|
||||
bug or problem in ControlMyMonitor tool, but in your hardware.
|
||||
It might be a bug with the chip of your monitor or with the driver of
|
||||
your graphics card or a problem with the cable/connector you use. As a
|
||||
programmer of ControlMyMonitor, I cannot help you to debug or fix these
|
||||
hardware problems. You can try to contact the manufacturers of your
|
||||
hardware and ask them to solve the problem.
|
||||
|
||||
|
||||
|
||||
Command-Line Options
|
||||
====================
|
||||
|
||||
You can use 'Primary' as your monitor string in all command-line options
|
||||
in order to specify the primary monitor. You can also use 'Secondary' as
|
||||
your monitor string in all command-line options in order to specify the
|
||||
secondary monitor.
|
||||
If you have multiple monitors, you have to find a string that uniquely
|
||||
identifies your monitor. Open ControlMyMonitor , select the desired
|
||||
monitor and then press Ctrl+M (Copy Monitor Settings). Paste the string
|
||||
from the clipboard into notepad or other text editor. You'll see
|
||||
something like this:
|
||||
|
||||
Monitor Device Name: "\\.\DISPLAY1\Monitor0"
|
||||
Monitor Name: "22EA53"
|
||||
Serial Number: "402CFEZE1200"
|
||||
Adapter Name: "Intel(R) HD Graphics"
|
||||
Monitor ID: "MONITOR\GSM59A4\{4d36e96e-e325-11ce-bfc1-08002be10318}\0012"
|
||||
|
||||
You can use any string from this list as long as the other monitors on
|
||||
your system have different values for the same property.
|
||||
|
||||
|
||||
|
||||
/SetValue <Monitor String> <VCP Code> <Value>
|
||||
Sets the value of the specified VCP Code for the specified monitor.
|
||||
|
||||
Here's some examples:
|
||||
|
||||
Set the brightness of primary monitor to 70:
|
||||
ControlMyMonitor.exe /SetValue Primary 10 70
|
||||
|
||||
Set the contrast of the monitor with serial number 102ABC335 to 65:
|
||||
ControlMyMonitor.exe /SetValue "102ABC335" 12 65
|
||||
|
||||
Restore factory defaults to the \\.\DISPLAY1\Monitor0 monitor:
|
||||
ControlMyMonitor.exe /SetValue "\\.\DISPLAY1\Monitor0" 04 1
|
||||
|
||||
Turn on the \\.\DISPLAY2\Monitor0 monitor:
|
||||
ControlMyMonitor.exe /SetValue "\\.\DISPLAY2\Monitor0" D6 1
|
||||
|
||||
Turn off the \\.\DISPLAY2\Monitor0 monitor: (On some monitors you should
|
||||
set the value to 4 instead of 5)
|
||||
ControlMyMonitor.exe /SetValue "\\.\DISPLAY2\Monitor0" D6 5
|
||||
|
||||
Change the input source of \\.\DISPLAY3\Monitor0 monitor:
|
||||
ControlMyMonitor.exe /SetValue "\\.\DISPLAY3\Monitor0" 60 3
|
||||
|
||||
/SetValueIfNeeded <Monitor String> <VCP Code> <Value>
|
||||
This command is similar to /SetValue , but it actually sets the value
|
||||
only if the current value is different from the specified value.
|
||||
|
||||
/ChangeValue <Monitor String> <VCP Code> <Value>
|
||||
Increases/decreases the value of the specified VCP Code for the specified
|
||||
monitor.
|
||||
|
||||
Here's some examples:
|
||||
|
||||
Increase the brightness of the secondary monitor by 5%:
|
||||
ControlMyMonitor.exe /ChangeValue Secondary 10 5
|
||||
|
||||
Decrease the contrast of the \\.\DISPLAY1\Monitor0 monitor by 5%:
|
||||
ControlMyMonitor.exe /ChangeValue "\\.\DISPLAY1\Monitor0" 12 -5
|
||||
|
||||
/SwitchValue <Monitor String> <VCP Code> <Value1> <Value2> <Value3>...
|
||||
Switch between the specified 2 or more values.
|
||||
|
||||
For example, this command switches the monitor between off (5) and on (1)
|
||||
state:
|
||||
ControlMyMonitor.exe /SwitchValue "\\.\DISPLAY1\Monitor0" D6 1 5
|
||||
|
||||
The following command switches between 3 brightness values - 30%, 50%,
|
||||
90% :
|
||||
ControlMyMonitor.exe /SwitchValue "\\.\DISPLAY1\Monitor0" 10 30 50 90
|
||||
|
||||
/GetValue <Monitor String> <VCP Code>
|
||||
Return the value of the specified VCP Code for the specified monitor.
|
||||
|
||||
Example for batch file:
|
||||
ControlMyMonitor.exe /GetValue "\\.\DISPLAY1\Monitor0" 10
|
||||
echo %errorlevel%
|
||||
|
||||
/TurnOff <Monitor String>
|
||||
Turn off the specified monitor.
|
||||
|
||||
Example:
|
||||
ControlMyMonitor.exe /TurnOff "\\.\DISPLAY3\Monitor0"
|
||||
|
||||
/TurnOn <Monitor String>
|
||||
Turn on the specified monitor.
|
||||
|
||||
Example:
|
||||
ControlMyMonitor.exe /TurnOn "\\.\DISPLAY1\Monitor0"
|
||||
|
||||
/SwitchOffOn <Monitor String>
|
||||
Switch the specified monitor between on and off state.
|
||||
|
||||
Example:
|
||||
ControlMyMonitor.exe /SwitchOffOn "\\.\DISPLAY2\Monitor0"
|
||||
|
||||
/SaveConfig <Filename> <Monitor String>
|
||||
Saves all read+write values of the specified monitor into a file.
|
||||
For example:
|
||||
ControlMyMonitor.exe /SaveConfig "c:\temp\mon1.cfg" Primary
|
||||
ControlMyMonitor.exe /SaveConfig "c:\temp\mon1.cfg"
|
||||
"\\.\DISPLAY2\Monitor0"
|
||||
|
||||
/LoadConfig <Filename> <Monitor String>
|
||||
Loads all values stored in configuration file into the specified monitor.
|
||||
For example:
|
||||
ControlMyMonitor.exe /LoadConfig "c:\temp\mon1.cfg" Primary
|
||||
ControlMyMonitor.exe /LoadConfig "c:\temp\mon1.cfg"
|
||||
"\\.\DISPLAY2\Monitor0"
|
||||
|
||||
/stext <Filename> <Monitor String>
|
||||
Save the current monitor settings into a simple text file.
|
||||
|
||||
/stab <Filename> <Monitor String>
|
||||
Save the current monitor settings into a tab-delimited text file.
|
||||
|
||||
/scomma <Filename> <Monitor String>
|
||||
Save the current monitor settings into a comma-delimited text file (csv).
|
||||
|
||||
/shtml <Filename> <Monitor String>
|
||||
Save the current monitor settings into HTML file (Horizontal).
|
||||
|
||||
/sverhtml <Filename> <Monitor String>
|
||||
Save the current monitor settings into HTML file (Vertical).
|
||||
|
||||
/sxml <Filename> <Monitor String>
|
||||
Save the current monitor settings into XML file.
|
||||
|
||||
/sjson <Filename> <Monitor String>
|
||||
Save the current monitor settings into JSON file.
|
||||
|
||||
/smonitors <Filename>
|
||||
Save the current monitors list into a simple text file.
|
||||
|
||||
For all save command-line options, you can specify empty filename in
|
||||
order to send the data to stdout, for example:
|
||||
ControlMyMonitor.exe /scomma "" | more
|
||||
|
||||
|
||||
|
||||
Get value of the specified VCP Code using GetNir tool
|
||||
=====================================================
|
||||
|
||||
There is also an option to get the current value of the specified VCP
|
||||
Code with GetNir tool. The value is sent to stdout.
|
||||
For example, the following command sends the current monitor brightness
|
||||
to stdout:
|
||||
ControlMyMonitor.exe /stab "" | GetNir "Current Value" "VCPCode=10"
|
||||
|
||||
|
||||
|
||||
Translating ControlMyMonitor to other languages
|
||||
===============================================
|
||||
|
||||
In order to translate ControlMyMonitor to other language, follow the
|
||||
instructions below:
|
||||
1. Run ControlMyMonitor with /savelangfile parameter:
|
||||
ControlMyMonitor.exe /savelangfile
|
||||
A file named ControlMyMonitor_lng.ini will be created in the folder of
|
||||
ControlMyMonitor utility.
|
||||
2. Open the created language file in Notepad or in any other text
|
||||
editor.
|
||||
3. Translate all string entries to the desired language. Optionally,
|
||||
you can also add your name and/or a link to your Web site.
|
||||
(TranslatorName and TranslatorURL values) If you add this information,
|
||||
it'll be used in the 'About' window.
|
||||
4. After you finish the translation, Run ControlMyMonitor, and all
|
||||
translated strings will be loaded from the language file.
|
||||
If you want to run ControlMyMonitor without the translation, simply
|
||||
rename the language file, or move it to another folder.
|
||||
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This utility is released as freeware. You are allowed to freely
|
||||
distribute this utility via floppy disk, CD-ROM, Internet, or in any
|
||||
other way, as long as you don't charge anything for this and you don't
|
||||
sell it or distribute it as a part of commercial product. If you
|
||||
distribute this utility, you must include all files in the distribution
|
||||
package, without any modification !
|
||||
|
||||
|
||||
|
||||
Disclaimer
|
||||
==========
|
||||
|
||||
The software is provided "AS IS" without any warranty, either expressed
|
||||
or implied, including, but not limited to, the implied warranties of
|
||||
merchantability and fitness for a particular purpose. The author will not
|
||||
be liable for any special, incidental, consequential or indirect damages
|
||||
due to loss of data or any other reason.
|
||||
|
||||
|
||||
|
||||
Feedback
|
||||
========
|
||||
|
||||
If you have any problem, suggestion, comment, or you found a bug in my
|
||||
utility, you can send a message to nirsofer@yahoo.com
|
||||
72
Library/ViewModel/XMonitor.cs
Normal file
72
Library/ViewModel/XMonitor.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using CMM.Library.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.ViewModel
|
||||
{
|
||||
public class XMonitor : PropertyBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 裝置路徑
|
||||
/// </summary>
|
||||
public string MonitorDeviceName
|
||||
{
|
||||
get => _MonitorDeviceName;
|
||||
set { SetProperty(ref _MonitorDeviceName, value); }
|
||||
}
|
||||
string _MonitorDeviceName;
|
||||
|
||||
/// <summary>
|
||||
/// 裝置名稱
|
||||
/// </summary>
|
||||
public string MonitorName
|
||||
{
|
||||
get => _MonitorName;
|
||||
set { SetProperty(ref _MonitorName, value); }
|
||||
}
|
||||
string _MonitorName;
|
||||
|
||||
/// <summary>
|
||||
/// 裝置序號
|
||||
/// </summary>
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _SerialNumber;
|
||||
set { SetProperty(ref _SerialNumber, value); }
|
||||
}
|
||||
string _SerialNumber;
|
||||
|
||||
/// <summary>
|
||||
/// 訊號裝置
|
||||
/// </summary>
|
||||
public string AdapterName
|
||||
{
|
||||
get => _AdapterName;
|
||||
set { SetProperty(ref _AdapterName, value); }
|
||||
}
|
||||
string _AdapterName;
|
||||
|
||||
/// <summary>
|
||||
/// 裝置識別碼
|
||||
/// </summary>
|
||||
public string MonitorID
|
||||
{
|
||||
get => _MonitorID;
|
||||
set { SetProperty(ref _MonitorID, value); }
|
||||
}
|
||||
string _MonitorID;
|
||||
|
||||
/// <summary>
|
||||
/// 狀態
|
||||
/// </summary>
|
||||
public ObservableRangeCollection<XMonitorStatus> Status
|
||||
{
|
||||
get => _Status;
|
||||
set { SetProperty(ref _Status, value); }
|
||||
}
|
||||
ObservableRangeCollection<XMonitorStatus> _Status = new();
|
||||
}
|
||||
}
|
||||
54
Library/ViewModel/XMonitorStatus.cs
Normal file
54
Library/ViewModel/XMonitorStatus.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using CMM.Library.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.ViewModel
|
||||
{
|
||||
public class XMonitorStatus : PropertyBase
|
||||
{
|
||||
public string VCP_Code
|
||||
{
|
||||
get => _VCP_Code;
|
||||
set { SetProperty(ref _VCP_Code, value); }
|
||||
}
|
||||
string _VCP_Code;
|
||||
|
||||
public string VCPCodeName
|
||||
{
|
||||
get => _VCPCodeName;
|
||||
set { SetProperty(ref _VCPCodeName, value); }
|
||||
}
|
||||
string _VCPCodeName;
|
||||
|
||||
public string Read_Write
|
||||
{
|
||||
get => _Read_Write;
|
||||
set { SetProperty(ref _Read_Write, value); }
|
||||
}
|
||||
string _Read_Write;
|
||||
|
||||
public int? CurrentValue
|
||||
{
|
||||
get => _CurrentValue;
|
||||
set { SetProperty(ref _CurrentValue, value); }
|
||||
}
|
||||
int? _CurrentValue;
|
||||
|
||||
public int? MaximumValue
|
||||
{
|
||||
get => _MaximumValue;
|
||||
set { SetProperty(ref _MaximumValue, value); }
|
||||
}
|
||||
int? _MaximumValue;
|
||||
|
||||
public string PossibleValues
|
||||
{
|
||||
get => _PossibleValues;
|
||||
set { SetProperty(ref _PossibleValues, value); }
|
||||
}
|
||||
string _PossibleValues;
|
||||
}
|
||||
}
|
||||
44
Library/WinAPI/Blur.cs
Normal file
44
Library/WinAPI/Blur.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.WinAPI
|
||||
{
|
||||
#region 透明背景
|
||||
public enum AccentState
|
||||
{
|
||||
ACCENT_DISABLED = 0,
|
||||
ACCENT_ENABLE_GRADIENT = 1,
|
||||
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
|
||||
ACCENT_ENABLE_BLURBEHIND = 3,
|
||||
ACCENT_INVALID_STATE = 4
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct AccentPolicy
|
||||
{
|
||||
public AccentState AccentState;
|
||||
public int AccentFlags;
|
||||
public int GradientColor;
|
||||
public int AnimationId;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct WindowCompositionAttributeData
|
||||
{
|
||||
public WindowCompositionAttribute Attribute;
|
||||
public IntPtr Data;
|
||||
public int SizeOfData;
|
||||
}
|
||||
|
||||
public enum WindowCompositionAttribute
|
||||
{
|
||||
// ...
|
||||
WCA_ACCENT_POLICY = 19
|
||||
// ...
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
50
Library/WinAPI/Win32Api.cs
Normal file
50
Library/WinAPI/Win32Api.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace CMM.Library.WinAPI
|
||||
{
|
||||
public static class Win32
|
||||
{
|
||||
public const int WM_SETTEXT = 0x000C;
|
||||
public const int WM_CLICK = 0x00F5;
|
||||
public const int CHILDID_SELF = 0;
|
||||
public const int CHILDID_1 = 1;
|
||||
public const int OBJID_CLIENT = -4;
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowText", CharSet = CharSet.Unicode)]
|
||||
public static extern int GetWindowText(IntPtr hwnd, StringBuilder lpString, int cch);
|
||||
[DllImport("user32.dll", EntryPoint = "FindWindowEx", CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, StringBuilder lParam);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool BRePaint);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int GetWindowRect(IntPtr hwnd, out Rectangle lpRect);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
|
||||
|
||||
public static bool IsUAC()
|
||||
{
|
||||
var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Tester/Tester.csproj
Normal file
21
Tester/Tester.csproj
Normal file
@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>CMM.Tester</RootNamespace>
|
||||
<Product>ControlMyMonitorManagement</Product>
|
||||
<Company>Dang</Company>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Copyright>Copyright © DangWang $([System.DateTime]::Now.ToString(yyyy))</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
16
Tester/UnitTest1.cs
Normal file
16
Tester/UnitTest1.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace CMM.Tester
|
||||
{
|
||||
public class Tests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test1()
|
||||
{
|
||||
Assert.Pass();
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Tester/Usings.cs
Normal file
1
Tester/Usings.cs
Normal file
@ -0,0 +1 @@
|
||||
global using NUnit.Framework;
|
||||
Loading…
Reference in New Issue
Block a user