public async Task <string> LoadLayout(LoadLayoutRequest request)
        {
            Console.WriteLine("__________________");
            Console.WriteLine($"New layout loading({request.Layout.Name})");

            if (request.OnlyThisLayout)
            {
                ProcessManager.CloseAllVisibleProcesses(GetAppsNames(request.Layout.Apps));
            }

            List <Task> layoutTasks = new List <Task>();


            OpenApps(request.Layout.Apps);

            AppsPosition.ResetWindows();
            foreach (AppModel app in request.Layout.Apps)
            {
                layoutTasks.Add(Task.Run(() => LoadApp(request, app)));
            }

            await Task.WhenAll(layoutTasks);

            return("All done");
        }
 private static AppModel CreateAppModel(string startingFile, string name, IntPtr window)
 {
     Console.WriteLine("Making appModel");
     return(new AppModel
     {
         FilePath = startingFile,
         Name = name,
         Position = AppsPosition.GetAppPosition(window)
     });
 }
Esempio n. 3
0
        private List <AppModel> GetAppModels(List <ListBoxAppModel> listboxApps)
        {
            List <AppModel> output = new List <AppModel>();

            foreach (var listBoxApp in listboxApps)
            {
                AppModel app = listBoxApp.App;
                app.Position = AppsPosition.GetAppPosition(listBoxApp.Window);
                output.Add(app);
            }
            return(output);
        }
 private bool LoadApp(LoadLayoutRequest request, AppModel app)
 {
     if (IsPositionZero(app))
     {
         app.Position = AppsPosition.GetAppPosition(app.Name);
         FilesWriter.EditAppModel(app);
     }
     if (request.MoveApps && !AppsPosition.IsAppOnCorrectPosition(app))
     {
         AppsPosition.SetAppPosition(app);
     }
     AppsPosition.BringWindowForward(app);
     return(true);
 }