Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 85636cd

Browse files
author
squidly
committed
Switch to Grabacr07/VirtualDesktop#57 commit c0f93aea77129850dc3f4442bc37900ece3d7131
--HG-- branch : Win11
1 parent f7a3323 commit 85636cd

File tree

68 files changed

+3092
-2063
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3092
-2063
lines changed

VirtualDesktop-master/CREDIT.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

VirtualDesktop-master/appveyor.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# .NET Desktop
2+
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
3+
# Add steps that publish symbols, save build artifacts, and more:
4+
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
5+
6+
pool:
7+
vmImage: 'windows-latest'
8+
9+
variables:
10+
solution: 'source/VirtualDesktop.sln'
11+
buildPlatform: 'Any CPU'
12+
buildConfiguration: 'Release'
13+
14+
steps:
15+
- task: DotNetCoreCLI@2
16+
displayName: 'dotnet build'
17+
inputs:
18+
command: 'build'
19+
projects: '$(solution)'
20+
arguments: '-c $(buildConfiguration)'
21+
22+
- task: DotNetCoreCLI@2
23+
displayName: 'dotnet pack'
24+
inputs:
25+
command: pack
26+
packagesToPack: '$(solution)'
27+
packDirectory: '$(Build.ArtifactStagingDirectory)'
28+
nobuild: true
29+
versioningScheme: 'off'
30+
arguments: '-c $(buildConfiguration)'
31+
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/release'))
32+
33+
- task: PublishBuildArtifacts@1
34+
displayName: 'publish artifact: drop'
35+
inputs:
36+
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
37+
ArtifactName: 'drop'
38+
publishLocation: 'Container'
39+
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/release'))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*
2+
!/.gitignore
3+
!/*.bat
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dotnet build ..\source\VirtualDesktop.sln -c Release
2+
dotnet pack ..\source\VirtualDesktop.sln -c Release --no-build -o %CD%

VirtualDesktop-master/samples/VirtualDesktop.Showcase/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

VirtualDesktop-master/samples/VirtualDesktop.Showcase/MainWindow.xaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
<Setter Property="BorderThickness"
2323
Value="0.99" />
2424
</Style>
25+
<Style TargetType="{x:Type TextBox}">
26+
<Setter Property="Padding"
27+
Value="18,4" />
28+
<Setter Property="HorizontalContentAlignment"
29+
Value="Left" />
30+
<Setter Property="Margin"
31+
Value="8" />
32+
<Setter Property="BorderThickness"
33+
Value="0.99" />
34+
</Style>
2535
</Panel.Resources>
2636
<StackPanel Margin="8">
2737
<RadioButton x:Name="ThisWindowMenu"
@@ -56,6 +66,21 @@
5666
Click="PinApp" />
5767
<Button Content="Remove"
5868
Click="Remove" />
69+
<Button Content="Get name"
70+
Click="GetName" />
71+
<TextBox x:Name="NameTextBlock"
72+
Margin="8,8,8,0"
73+
Text="Desktop name" />
74+
<Button Grid.Column="1"
75+
Content="Set name"
76+
Click="SetName"
77+
Margin="8,0,8,8" />
78+
<Button Content="Get wallpaper path"
79+
Click="GetWallpaperPath" />
80+
<Button Content="Move to previous"
81+
Click="MovePrevious" />
82+
<Button Content="Move to next"
83+
Click="MoveNext" />
5984
</StackPanel>
6085
</ScrollViewer>
6186
</Window>

VirtualDesktop-master/samples/VirtualDesktop.Showcase/MainWindow.xaml.cs

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ private static async void InitializeComObjects()
2222
{
2323
try
2424
{
25-
await VirtualDesktopProvider.Default.Initialize();
25+
await VirtualDesktopProvider.Default.Initialize(TaskScheduler.FromCurrentSynchronizationContext());
2626
}
2727
catch (Exception ex)
2828
{
2929
MessageBox.Show(ex.Message, "Failed to initialize.");
3030
}
3131

3232
VirtualDesktop.CurrentChanged += (sender, args) => System.Diagnostics.Debug.WriteLine($"Desktop changed: {args.NewDesktop.Id}");
33+
VirtualDesktop.Moved += (sender, args) => System.Diagnostics.Debug.WriteLine($"Desktop moved: {args.OldIndex} -> {args.NewIndex} ({args.Source.Id})");
34+
VirtualDesktop.Renamed += (sender, args) => System.Diagnostics.Debug.WriteLine($"Desktop renamed: {args.OldName} -> {args.NewName} ({args.Source.Id})");
3335
}
3436

3537
private void CreateNew(object sender, RoutedEventArgs e)
@@ -124,7 +126,7 @@ private async void PinApp(object sender, RoutedEventArgs e)
124126
{
125127
await Task.Delay(_delay);
126128
var appId = ApplicationHelper.GetAppId(GetForegroundWindow());
127-
(VirtualDesktop.IsPinnedApplication(appId) ? VirtualDesktop.UnpinApplication : (Action<string>)VirtualDesktop.PinApplication)(appId);
129+
if (appId != null) (VirtualDesktop.IsPinnedApplication(appId) ? VirtualDesktop.UnpinApplication : (Action<string>)VirtualDesktop.PinApplication)(appId);
128130
}
129131
}
130132

@@ -141,6 +143,79 @@ private async void Remove(object sender, RoutedEventArgs e)
141143
}
142144
}
143145

146+
private async void GetName(object sender, RoutedEventArgs e)
147+
{
148+
if (this.ThisWindowMenu.IsChecked ?? false)
149+
{
150+
var name = this.GetCurrentDesktop().Name;
151+
MessageBox.Show(name, "Current desktop name");
152+
}
153+
else
154+
{
155+
await Task.Delay(_delay);
156+
var name = this.GetCurrentDesktop().Name;
157+
MessageBox.Show(name, "Current desktop name");
158+
}
159+
}
160+
161+
private async void SetName(object sender, RoutedEventArgs e)
162+
{
163+
if (this.ThisWindowMenu.IsChecked ?? false)
164+
{
165+
try
166+
{
167+
this.GetCurrentDesktop().Name = this.NameTextBlock.Text;
168+
}
169+
catch (PlatformNotSupportedException ex)
170+
{
171+
MessageBox.Show(ex.Message, "Error");
172+
}
173+
}
174+
else
175+
{
176+
await Task.Delay(_delay);
177+
try
178+
{
179+
this.GetCurrentDesktop().Name = this.NameTextBlock.Text;
180+
}
181+
catch (PlatformNotSupportedException ex)
182+
{
183+
MessageBox.Show(ex.Message, "Error");
184+
}
185+
}
186+
}
187+
188+
private async void GetWallpaperPath(object sender, RoutedEventArgs e)
189+
{
190+
if (this.ThisWindowMenu.IsChecked ?? false)
191+
{
192+
var name = this.GetCurrentDesktop().WallpaperPath;
193+
MessageBox.Show(name, "Current wallpaper path");
194+
}
195+
else
196+
{
197+
await Task.Delay(_delay);
198+
var name = this.GetCurrentDesktop().WallpaperPath;
199+
MessageBox.Show(name, "Current wallpaper path");
200+
}
201+
}
202+
203+
private void MovePrevious(object sender, RoutedEventArgs e)
204+
{
205+
var desktop = this.GetCurrentDesktop();
206+
if (desktop == null) return;
207+
208+
desktop.Move(desktop.Index - 1);
209+
}
210+
211+
private void MoveNext(object sender, RoutedEventArgs e)
212+
{
213+
var desktop = this.GetCurrentDesktop();
214+
if (desktop == null) return;
215+
216+
desktop.Move(desktop.Index + 1);
217+
}
218+
144219

145220
[DllImport("user32.dll")]
146221
private static extern IntPtr GetForegroundWindow();
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
using System.Reflection;
2-
using System.Runtime.InteropServices;
1+
using System.Runtime.InteropServices;
32
using System.Windows;
43

5-
[assembly: AssemblyTitle("VirtualDesktop.Showcase")]
6-
[assembly: AssemblyCompany("grabacr.net")]
7-
[assembly: AssemblyProduct("VirtualDesktop")]
8-
[assembly: AssemblyDescription("C# wrapper for IVirtualDesktopManager on Windows 10.")]
9-
[assembly: AssemblyCopyright("Copyright © 2015 Manato KAMEYA")]
10-
114
[assembly: ComVisible(false)]
125
[assembly: Guid("5B4544B8-3EF0-4E9F-8D60-DD605AD99725")]
136
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
14-
15-
[assembly: AssemblyVersion("1.0.0.0")]

VirtualDesktop-master/samples/VirtualDesktop.Showcase/Properties/Resources.Designer.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)