Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Major changes in management for com objects. - Add support moving the window of another process.
- Loading branch information
Showing
17 changed files
with
497 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
using System.Reflection; | ||
using System.Resources; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Windows; | ||
|
||
[assembly: AssemblyTitle("VirtualDesktop.Showcase")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("VirtualDesktop.Showcase")] | ||
[assembly: AssemblyCopyright("Copyright © 2015")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: AssemblyCompany("grabacr.net")] | ||
[assembly: AssemblyProduct("VirtualDesktop")] | ||
[assembly: AssemblyDescription("C# wrapper for IVirtualDesktopManager on Windows 10.")] | ||
[assembly: AssemblyCopyright("Copyright © 2015 Manato KAMEYA")] | ||
|
||
[assembly: ComVisible(false)] | ||
[assembly: Guid("5B4544B8-3EF0-4E9F-8D60-DD605AD99725")] | ||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] | ||
|
||
[assembly: AssemblyVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
|
||
namespace WindowsDesktop.Internal | ||
{ | ||
public class Disposable | ||
{ | ||
public static IDisposable Create(Action dispose) | ||
{ | ||
return new AnonymousDisposable(dispose); | ||
} | ||
|
||
private class AnonymousDisposable : IDisposable | ||
{ | ||
private bool _isDisposed; | ||
private readonly Action _dispose; | ||
|
||
public AnonymousDisposable(Action dispose) | ||
{ | ||
this._dispose = dispose; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (this._isDisposed) return; | ||
|
||
this._isDisposed = true; | ||
this._dispose(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace WindowsDesktop.Interop | ||
{ | ||
public static class ComObjects | ||
{ | ||
private static IDisposable _listener; | ||
private static readonly ConcurrentDictionary<Guid, IVirtualDesktop> _virtualDesktops = new ConcurrentDictionary<Guid, IVirtualDesktop>(); | ||
|
||
internal static IVirtualDesktopManager VirtualDesktopManager { get; private set; } | ||
internal static VirtualDesktopManagerInternal VirtualDesktopManagerInternal { get; private set; } | ||
internal static IVirtualDesktopNotificationService VirtualDesktopNotificationService { get; private set; } | ||
internal static IVirtualDesktopPinnedApps VirtualDesktopPinnedApps { get; private set; } | ||
internal static IApplicationViewCollection ApplicationViewCollection { get; private set; } | ||
|
||
internal static void Initialize() | ||
{ | ||
VirtualDesktopManager = GetVirtualDesktopManager(); | ||
VirtualDesktopManagerInternal = VirtualDesktopManagerInternal.GetInstance(); | ||
VirtualDesktopNotificationService = GetVirtualDesktopNotificationService(); | ||
VirtualDesktopPinnedApps = GetVirtualDesktopPinnedApps(); | ||
ApplicationViewCollection = GetApplicationViewCollection(); | ||
|
||
_virtualDesktops.Clear(); | ||
_listener = VirtualDesktop.RegisterListener(); | ||
} | ||
|
||
internal static void Register(IVirtualDesktop vd) | ||
{ | ||
_virtualDesktops.AddOrUpdate(vd.GetID(), vd, (guid, desktop) => vd); | ||
} | ||
|
||
internal static IVirtualDesktop GetVirtualDesktop(Guid id) | ||
{ | ||
return _virtualDesktops.GetOrAdd(id, x => VirtualDesktopManagerInternal.FindDesktop(ref x)); | ||
} | ||
|
||
internal static void Terminate() | ||
{ | ||
_listener?.Dispose(); | ||
} | ||
|
||
|
||
#region public methods | ||
|
||
public static IVirtualDesktopManager GetVirtualDesktopManager() | ||
{ | ||
var vdmType = Type.GetTypeFromCLSID(CLSID.VirtualDesktopManager); | ||
var instance = Activator.CreateInstance(vdmType); | ||
|
||
return (IVirtualDesktopManager)instance; | ||
} | ||
|
||
public static IVirtualDesktopNotificationService GetVirtualDesktopNotificationService() | ||
{ | ||
var shellType = Type.GetTypeFromCLSID(CLSID.ImmersiveShell); | ||
var shell = (IServiceProvider)Activator.CreateInstance(shellType); | ||
|
||
object ppvObject; | ||
shell.QueryService(CLSID.VirtualDesktopNotificationService, typeof(IVirtualDesktopNotificationService).GUID, out ppvObject); | ||
|
||
return (IVirtualDesktopNotificationService)ppvObject; | ||
} | ||
|
||
public static IVirtualDesktopPinnedApps GetVirtualDesktopPinnedApps() | ||
{ | ||
var shellType = Type.GetTypeFromCLSID(CLSID.ImmersiveShell); | ||
var shell = (IServiceProvider)Activator.CreateInstance(shellType); | ||
|
||
object ppvObject; | ||
shell.QueryService(CLSID.VirtualDesktopPinnedApps, typeof(IVirtualDesktopPinnedApps).GUID, out ppvObject); | ||
|
||
return (IVirtualDesktopPinnedApps)ppvObject; | ||
} | ||
|
||
public static IApplicationViewCollection GetApplicationViewCollection() | ||
{ | ||
var shellType = Type.GetTypeFromCLSID(CLSID.ImmersiveShell); | ||
var shell = (IServiceProvider)Activator.CreateInstance(shellType); | ||
|
||
object ppvObject; | ||
shell.QueryService(typeof(IApplicationViewCollection).GUID, typeof(IApplicationViewCollection).GUID, out ppvObject); | ||
|
||
return (IApplicationViewCollection)ppvObject; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
source/VirtualDesktop/Interop/VirtualDesktopInteropHelper.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.