コード例 #1
0
        /// <summary>
        /// Closes the applications.
        /// </summary>
        /// <returns></returns>
        public bool CloseApplications(TopApplication application)
        {
            if (application == null)
            {
                application = _selectedApplication;
            }

            if (application != null)
            {
                foreach (SubApplication subApplication in application.SubItems)
                {
                    Process[] procs = Process.GetProcessesByName(subApplication.Exe.Replace(".exe", ""));

                    if (procs.Length > 0)
                    {
                        for (var i = 0; i < procs.Length; i++)
                        {
                            procs[i].CloseMainWindow();
                        }
                    }

                    if (subApplication.SubItems.Any())
                    {
                        CloseApplications(subApplication);
                    }
                }
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Opens the applications.
        /// </summary>
        /// <param name="p">The p.</param>
        /// <returns></returns>
        private bool OpenApplications(TopApplication application, int count)
        {
            try
            {
                foreach (SubApplication subApplication in application.SubItems)
                {
                    if (subApplication.IsSelected == true && subApplication.Exe != "")
                    {
                        LaunchApplication(ref count, subApplication);
                    }

                    if (subApplication.SubItems.Any())
                    {
                        OpenApplications(subApplication, count);
                    }
                }
                System.Threading.Thread.Sleep(2000 * count);

                return(true);
            }
            catch (Exception)
            {
                MessageBox.Show("Executable is missing from install directory.\n\nCheck the executable paths in the configuration XML file.", "Executable Missing", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
                //throw;
            }
        }
コード例 #3
0
ファイル: VM_Tiles.cs プロジェクト: OZ10/ProjectSwitcher
        private void GetAssociatedApplications()
        {
            // Only get associated applications if they haven't already been gathered (i.e. the selected tiles application collection is empty)
            // Update 17/07/15: Always gather applications incase application details have been edited
            //if (SelectedTile.Applications.Any() == false)
            //{
            // Get all the associations associated with the selected item
            Messenger.Default.Send(new Message.M_GetAssociatedApplications(SelectedTile));
            //}

            if (SelectedTile.Applications.Any())
            {
                if (SelectedTile.Applications.Count == 1)
                {
                    // Only one application is associated with the selected item. Pass the application details to the applications tab for display.
                    TopApplication application = SelectedTile.Applications[0] as TopApplication;
                    Messenger.Default.Send <GenericMessage <TopApplication> >(new GenericMessage <TopApplication>(application));
                }
                else
                {
                    DisplayTileTab();
                    DisplayApplicationsAsTiles();
                }
            }
            else
            {
                DisplayTileTab();
            }
        }
コード例 #4
0
        private void UpdateApplicationsCollection(GenericMessage <TopApplication> message)
        {
            DisplayApplicationsTab();

            SelectedApplication = message.Content;

            ActiveApplicationCollection = new ObservableCollection <TopApplication>(message.Content.SubItems);
        }
コード例 #5
0
ファイル: V_Tiles.xaml.cs プロジェクト: OZ10/ProjectSwitcher
        private void btnTileMain_Click(object sender, RoutedEventArgs e)
        {
            Button  btn             = (Button)sender;
            Project selectedProject = btn.DataContext as Project;

            if (selectedProject != null)
            {
                Messenger.Default.Send(new Message.M_ChangeSelectedTile(selectedProject, this));
            }
            else
            {
                TopApplication selectedApplication = btn.DataContext as TopApplication;
                Messenger.Default.Send(new Message.M_ChangeSelectedTile(selectedApplication, this));
            }
        }
コード例 #6
0
        private void UpdateSelectedApplication(GenericMessage <TopApplication> message)
        {
            _selectedApplication = message.Content;

            // If the select application only has one subapplication, & that subapplication only has one executable application, launch it
            if (_selectedApplication.SubItems.Count == 1)
            {
                SubApplication subApplication = _selectedApplication.SubItems[0];

                if (subApplication.SubItems.Count == 1)
                {
                    CloseOpenApplications();
                }
            }

            Messenger.Default.Send(new Message.M_ChangeView(Message.M_ChangeView.ViewToSelect.DisplayApplicationsTab));
        }
コード例 #7
0
 public void AddNewApplication()
 {
     if (SelectedApplication != null)
     {
         Class.SubApplication subApp = new SubApplication();
         subApp.Setup("New App", "<path>", "<exe>", false, true, true, SelectedApplication.Name);
         SelectedApplication.SubItems.Add(subApp);
         SelectedApplication = subApp;
     }
     else
     {
         Class.TopApplication topApp = new TopApplication();
         topApp.Setup("New Top App", true);
         ApplicationsCollection.Add(topApp);
         SelectedApplication = topApp;
     }
 }
コード例 #8
0
ファイル: VM_Tiles.cs プロジェクト: OZ10/ProjectSwitcher
        /// <summary>
        /// Displays the context menus. Triggered by a right-click on a tile.
        /// </summary>
        /// <param name="msg">Message containing the grid control contained within tile that has been clicked.</param>
        public void DisplayContextMenus(Grid grid)
        {
            Project project = grid.DataContext as Project;

            if (project != null)
            {
                grid.ContextMenu.ItemsSource = project.CombinedContextMenuCollection;
            }
            else
            {
                TopApplication application = grid.DataContext as TopApplication;

                if (application != null)
                {
                    grid.ContextMenu.ItemsSource = application.ContextMenuCollection;
                }
            }
        }
コード例 #9
0
ファイル: V_Tiles.xaml.cs プロジェクト: OZ10/ProjectSwitcher
        // Edit button click on tile
        private void btnTileEdit_Click(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;

            Project selectedProject = btn.DataContext as Project;

            if (selectedProject != null)
            {
                Messenger.Default.Send(new Message.M_EditTile(selectedProject, this));
            }
            else
            {
                TopApplication selectedApplication = btn.DataContext as TopApplication;

                if (selectedApplication != null)
                {
                    Messenger.Default.Send(new Message.M_ChangeView(Message.M_ChangeView.ViewToSelect.DisplayEditApplicationsTab));
                }
            }
        }
コード例 #10
0
 public M_ChangeSelectedTile(TopApplication selectedApplication, object sender, bool resetBreadcrumb = false)
 {
     SelectedApplication = selectedApplication;
     Sender          = sender;
     ResetBreadcrumb = resetBreadcrumb;
 }