Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BarRaider committed Nov 22, 2021
2 parents c982f63 + 9ec5c60 commit e0f11fb
Show file tree
Hide file tree
Showing 22 changed files with 478 additions and 660 deletions.
6 changes: 6 additions & 0 deletions WindowsMover.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29009.5
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsMover", "streamdeck-windowsmover\WindowsMover.csproj", "{CC12FB78-BDB5-44A2-9694-3E604BDCAFE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsMoverRunner", "WindowsMoverRunner\WindowsMoverRunner.csproj", "{CC421BF3-C776-45FD-8FEB-D39773552FCD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{CC12FB78-BDB5-44A2-9694-3E604BDCAFE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC12FB78-BDB5-44A2-9694-3E604BDCAFE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC12FB78-BDB5-44A2-9694-3E604BDCAFE0}.Release|Any CPU.Build.0 = Release|Any CPU
{CC421BF3-C776-45FD-8FEB-D39773552FCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC421BF3-C776-45FD-8FEB-D39773552FCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC421BF3-C776-45FD-8FEB-D39773552FCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC421BF3-C776-45FD-8FEB-D39773552FCD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 18 additions & 0 deletions WindowsMoverRunner/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing.Common" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
47 changes: 47 additions & 0 deletions WindowsMoverRunner/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using BarRaider.SdTools;
using BarRaider.WindowsMover.Internal;
using BarRaider.WindowsMover.Wrappers;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsMoverRunner
{
class Program
{
private static string WINDOWS_MOVER_RUNNER_CONFIG = "WindowsMoverRunner.cfg";

static void Main(string[] args)
{
if (!File.Exists(WINDOWS_MOVER_RUNNER_CONFIG))
{

Logger.Instance.LogMessage(TracingLevel.ERROR, $"WindowsMoverRunner missing configuration file");
return;
}

string data = String.Empty;
try
{
data = File.ReadAllText(WINDOWS_MOVER_RUNNER_CONFIG);
MoveProcessSettings settings = JsonConvert.DeserializeObject<MoveProcessSettings>(data);
if (settings == null)
{
Logger.Instance.LogMessage(TracingLevel.ERROR, $"WindowsMoverRunner Invalid configuration data: {data}");
return;
}
Logger.Instance.LogMessage(TracingLevel.INFO, $"WindowsMoverRunner moving app: {settings.Name}");
WindowPosition.MoveProcess(settings);
}
catch (Exception ex)
{
Logger.Instance.LogMessage(TracingLevel.ERROR, $"WindowsMoverRunner exception: {ex}\nArguments: {data}");
}
}
}
}
36 changes: 36 additions & 0 deletions WindowsMoverRunner/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WindowsMoverRunner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WindowsMoverRunner")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("cc421bf3-c776-45fd-8feb-d39773552fcd")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
95 changes: 95 additions & 0 deletions WindowsMoverRunner/WindowsMoverRunner.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CC421BF3-C776-45FD-8FEB-D39773552FCD}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>WindowsMoverRunner</RootNamespace>
<AssemblyName>WindowsMoverRunner</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine, Version=2.8.0.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.12\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="streamdeck-client-csharp, Version=4.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\streamdeck-client-csharp.4.3.0\lib\netstandard2.0\streamdeck-client-csharp.dll</HintPath>
</Reference>
<Reference Include="StreamDeckTools, Version=3.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\StreamDeck-Tools.3.2.0\lib\net472\StreamDeckTools.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.6.0.0\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\streamdeck-windowsmover\Internal\ScreenFinder.cs">
<Link>ScreenFinder.cs</Link>
</Compile>
<Compile Include="..\streamdeck-windowsmover\Internal\WindowPosition.cs">
<Link>WindowPosition.cs</Link>
</Compile>
<Compile Include="..\streamdeck-windowsmover\Wrappers\MoveProcessSettings.cs">
<Link>MoveProcessSettings.cs</Link>
</Compile>
<Compile Include="..\streamdeck-windowsmover\Wrappers\WindowSize.cs">
<Link>WindowSize.cs</Link>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="app.manifest" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
79 changes: 79 additions & 0 deletions WindowsMoverRunner/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->

</assembly>
9 changes: 9 additions & 0 deletions WindowsMoverRunner/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="2.8.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
<package id="NLog" version="4.7.12" targetFramework="net48" />
<package id="streamdeck-client-csharp" version="4.3.0" targetFramework="net48" />
<package id="StreamDeck-Tools" version="3.2.0" targetFramework="net48" />
<package id="System.Drawing.Common" version="6.0.0" targetFramework="net48" />
</packages>
6 changes: 3 additions & 3 deletions streamdeck-windowsmover/Actions/VirtualDesktopMoverAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
using BarRaider.WindowsMover.Internal;
using BarRaider.WindowsMover.MonitorWrapper;
using BarRaider.WindowsMover.Wrappers;
using BarRaiderVirtualDesktop.VirtualDesktop;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using VirtualDesktop;

namespace BarRaider.WindowsMover
{
Expand Down Expand Up @@ -221,9 +221,9 @@ private void FetchAllVirtualDesktops()
Settings.Desktops = new List<VirtualDesktopInfo>();
try
{
for (int currDesktop = 0; currDesktop < Desktop.Count; currDesktop++)
for (int currDesktop = 0; currDesktop < VirtualDesktopManager.Instance.Count(); currDesktop++)
{
Settings.Desktops.Add(new VirtualDesktopInfo() { Name = Desktop.DesktopNameFromIndex(currDesktop) });
Settings.Desktops.Add(new VirtualDesktopInfo() { Name = VirtualDesktopManager.Instance.DesktopNameFromIndex(currDesktop) });
}
}
catch (Exception ex)
Expand Down
8 changes: 4 additions & 4 deletions streamdeck-windowsmover/Actions/VirtualDesktopPinAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BarRaider.WindowsMover.Internal;
using BarRaider.WindowsMover.MonitorWrapper;
using BarRaider.WindowsMover.Wrappers;
using BarRaiderVirtualDesktop.VirtualDesktop;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
Expand All @@ -11,7 +12,6 @@
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
using VirtualDesktop;

namespace BarRaider.WindowsMover
{
Expand Down Expand Up @@ -274,16 +274,16 @@ private void HandleWindowPin(IntPtr hwnd)
bool shouldPin = Settings.ModePin;
if (Settings.ModePinToggle)
{
shouldPin = !Desktop.IsApplicationPinned(hwnd);
shouldPin = !VirtualDesktopManager.Instance.IsApplicationPinned(hwnd);
}

if (shouldPin)
{
Desktop.PinApplication(hwnd);
VirtualDesktopManager.Instance.PinApplication(hwnd);
}
else
{
Desktop.UnpinApplication(hwnd);
VirtualDesktopManager.Instance.UnpinApplication(hwnd);
}
}
catch (Exception ex)
Expand Down
1 change: 0 additions & 1 deletion streamdeck-windowsmover/Actions/WindowsActionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using VirtualDesktop;

namespace BarRaider.WindowsMover
{
Expand Down
Loading

0 comments on commit e0f11fb

Please sign in to comment.