mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
* [Workspaces] PWA: first steps: implement PWA app searcher, add basic controls to the editor * spell checker * Snapshot tool: adding command line args for edge * PWA: add icon handling, add launch of PWA * Impllement Aumid getters and comparison to connect PWA windows and processes. Update LauncherUI, Launcher * Minor fixes, simplifications * Spell checker * Removing manual PWA selection, spell checker * Fix merge conflict * Trying to convince spell checker, that "PEB" is a correct word. * XAML format fix * Extending snapshot tool by logs for better testablility * spell checker fix * extending logs * extending logs * Removing some logs, modifying search criteria for pwa helper process search * extending PWA detection for the case the directory with the app-id is missing * Fix issue when pwaAppId is null * fix missing pwa-app-id handling in the editor. Removed unused property (code cleaning) and updating json parser in Launcher * Code cleaning: Moving duplicate code to a common project * Fix issue: adding new Guid as app id if it is empty * Code cleanup: moving Pwa related code from snapshotUtils to PwaHelper * Code cleaning * Code cleanup: Move common Application model to Csharp Library * code cleanup * modifying package name * Ading project reference to Common.UI * Code cleaning, fixing references --------- Co-authored-by: donlaci <donlaci@yahoo.com>
99 lines
3.1 KiB
C#
99 lines
3.1 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
|
|
using ManagedCommon;
|
|
using WorkspacesCsharpLibrary;
|
|
using WorkspacesLauncherUI.Data;
|
|
using WorkspacesLauncherUI.Models;
|
|
using WorkspacesLauncherUI.Utils;
|
|
|
|
namespace WorkspacesLauncherUI.ViewModels
|
|
{
|
|
public class MainViewModel : INotifyPropertyChanged, IDisposable
|
|
{
|
|
public ObservableCollection<AppLaunching> AppsListed { get; set; } = new ObservableCollection<AppLaunching>();
|
|
|
|
private StatusWindow _snapshotWindow;
|
|
private int launcherProcessID;
|
|
private PwaHelper _pwaHelper;
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
public void OnPropertyChanged(PropertyChangedEventArgs e)
|
|
{
|
|
PropertyChanged?.Invoke(this, e);
|
|
}
|
|
|
|
public MainViewModel()
|
|
{
|
|
_pwaHelper = new PwaHelper();
|
|
|
|
// receive IPC Message
|
|
App.IPCMessageReceivedCallback = (string msg) =>
|
|
{
|
|
try
|
|
{
|
|
AppLaunchData parser = new AppLaunchData();
|
|
AppLaunchData.AppLaunchDataWrapper appLaunchData = parser.Deserialize(msg);
|
|
HandleAppLaunchingState(appLaunchData);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.LogError(ex.Message);
|
|
}
|
|
};
|
|
}
|
|
|
|
private void HandleAppLaunchingState(AppLaunchData.AppLaunchDataWrapper appLaunchData)
|
|
{
|
|
launcherProcessID = appLaunchData.LauncherProcessID;
|
|
List<AppLaunching> appLaunchingList = new List<AppLaunching>();
|
|
foreach (var app in appLaunchData.AppLaunchInfos.AppLaunchInfoList)
|
|
{
|
|
appLaunchingList.Add(new AppLaunching()
|
|
{
|
|
Name = app.Application.Application,
|
|
AppPath = app.Application.ApplicationPath,
|
|
PackagedName = app.Application.PackageFullName,
|
|
Aumid = app.Application.AppUserModelId,
|
|
PwaAppId = app.Application.PwaAppId,
|
|
LaunchState = app.State,
|
|
});
|
|
}
|
|
|
|
AppsListed = new ObservableCollection<AppLaunching>(appLaunchingList);
|
|
OnPropertyChanged(new PropertyChangedEventArgs(nameof(AppsListed)));
|
|
}
|
|
|
|
private void SelfDestroy(object source, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
_snapshotWindow.Dispatcher.Invoke(() =>
|
|
{
|
|
_snapshotWindow.Close();
|
|
});
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
internal void SetSnapshotWindow(StatusWindow snapshotWindow)
|
|
{
|
|
_snapshotWindow = snapshotWindow;
|
|
}
|
|
|
|
internal void CancelLaunch()
|
|
{
|
|
App.SendIPCMessage("cancel");
|
|
}
|
|
}
|
|
}
|