예제 #1
0
 private void btnAddNew_Click(object sender, RoutedEventArgs e)
 {
     Project newProject = new Project();
     newProject.Setup("Project Name", null, "", true, null, true);
     Messenger.Default.Send(new Message.M_EditTile(newProject, this));
     //Messenger.Default.Send<Project>(newProject);
     //vm.AddNewTile();
 }
예제 #2
0
 public M_EditTile(Project selectedTile, object sender)
 {
     SelectedTile = selectedTile;
     Sender = sender;
 }
예제 #3
0
 public M_UpdateSelectedTile(Project selectedProject, object sender)
 {
     SelectedProject = selectedProject;
     Sender = sender;
 }
예제 #4
0
        private void TileClicked(Message.M_UpdateSelectedTile msg)
        {
            // Try to cast the item as a Project
            Project project = msg.SelectedProject as Project;

            if (project != null)
            {
                if (project.SubItems.Any())
                {
                    // Reset the active tile collection and add all subitems of the selected tile
                    ActiveTileCollection = new ObservableCollection<SwitcherItem>(project.SubItems);
                }

                SelectedTile = project;

                GetAssociatedApplications();
            }
            else
            {
                // Selected tile must be an application. Send a message to the main view model containing the selected application
                Messenger.Default.Send<GenericMessage<TopApplication>>(new GenericMessage<TopApplication>(this, msg.SelectedApplication));
            }
        }
예제 #5
0
 private void RefreshTiles(Project project)
 {
     if (project != null)
     {
         if (project.SubItems.Any())
         {
             // Reset the active tile collection and add all subitems of the selected tile
             ActiveTileCollection = new ObservableCollection<SwitcherItem>(project.SubItems);
         }
     }
     else
     {
         ActiveTileCollection = new ObservableCollection<SwitcherItem>(ProjectsCollection);
     }
 }
예제 #6
0
        /// <summary>
        /// Reads the project details from the xml file and populates the projects listview.
        /// </summary>
        /// <param name="xmlDoc">The XML document.</param>
        private void PopulateProjects(ObservableCollection<Project> msg)
        {
            try
            {
                ProjectsCollection = msg;

                CreateTiles();

                // Send a message to the App.xaml.cs to retrieve the pre-Selected Project name (as
                // selected from the jumplist menu)
                Messenger.Default.Send(new NotificationMessageAction<string>("", (preSelectedProject) =>
                {
                    if (preSelectedProject != "")
                    {
                        // Search through all the projects to find the one with the same name
                        foreach (var proj in ProjectsCollection)
                        {
                            SelectedTile = proj.FindSubProjectByName(proj, preSelectedProject);

                            if (SelectedTile != null) { break; }
                        }
                    }
                }));

                // Select the project if it's been pre-selected or just show the tiles tab
                if (SelectedTile != null)
                {
                    Messenger.Default.Send(new Message.M_UpdateSelectedTile(SelectedTile, this));
                }
                else
                {
                    Messenger.Default.Send<Message.M_ChangeView>(new Message.M_ChangeView(Message.M_ChangeView.ViewToSelect.DisplayTilesTab));
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Errooooooooorrrrrr");
                throw;
            }
        }
예제 #7
0
 private void DeleteProject(Project project)
 {
     if (SelectedTile != null)
     {
         // There is a tile selected so remove this new project from it's collection of sub projects
         SelectedTile.SubItems.Remove(project);
     }
     else
     {
         // No selected tile so project must be top level
         ProjectsCollection.Remove(project);
     }
 }
예제 #8
0
 private void AddNewProject(Project project)
 {
     if (SelectedTile != null)
     {
         // There is a tile selected so add this new project to it's collection of sub projects
         SelectedTile.SubItems.Add(project);
     }
     else
     {
         // No selected tile so project must be top level
         ProjectsCollection.Add(project);
     }
 }
예제 #9
0
        /// <summary>
        /// Changes the tile collection to the selected item from the title bar.
        /// </summary>
        /// <param name="msg">Message containing the selected item.</param>
        public void GoBackToParent(GenericMessage<SwitcherItem> msg)
        {
            if (msg.Sender is App | msg.Sender is MainWindow)
            {
                DisplayTileTab();

                Project switcherItem = msg.Content as Project;

                if (switcherItem == null)
                {
                    // Selected item has no parent. Reset active tile collection to all projects
                    ActiveTileCollection = new ObservableCollection<SwitcherItem>(ProjectsCollection);
                    SelectedTile = null;
                }
                else
                {
                    if (switcherItem.SubItems.Any())
                    {
                        // TODO Sure this can be done in the better way. Think you can link a class to a control template so I wouldn't have to create a new tile object each time.
                        ActiveTileCollection = new ObservableCollection<SwitcherItem>(switcherItem.SubItems);

                        SelectedTile = switcherItem;

                        // Send a message to the main view to update the breadcrumb
                        Messenger.Default.Send(new Message.M_UpdateSelectedTile(SelectedTile, this));
                    }
                }
            }
        }
예제 #10
0
        private static void AddSelectedProjectToJumpList(Project selectedProject)
        {
            JumpTask task = new JumpTask
            {
                Title = selectedProject.Name,
                Arguments = selectedProject.Name,
                Description = "Open with " + selectedProject.Name + " selected",
                IconResourcePath = InstallDirectory + "SwitcherIcon_w1.ico", //Assembly.GetEntryAssembly().CodeBase,
                ApplicationPath = Assembly.GetEntryAssembly().CodeBase
            };

            JumpList jl = JumpList.GetJumpList(App.Current);

            if (jl == null)
            {
                jl = new JumpList();
            }

            //jl.JumpItems.Add(task);
            //JumpList.SetJumpList(App.Current, jl);
            JumpList.AddToRecentCategory(task);
            jl.Apply();
        }
예제 #11
0
        public Project FindSubProjectByName(Project parentProject, string name)
        {
            if (parentProject.Name == name)
            {
                return parentProject;
            }
            else
            {
                foreach (var subProject in parentProject.SubItems)
                {
                    if (subProject.Name == name)
                    {
                        return subProject;
                    }

                    if (subProject.SubItems.Any())
                    {
                        FindSubProjectByName(subProject, name);
                    }
                }
            }

            return null;
        }
예제 #12
0
 public void GetAssociations(Project project, XElement xmlSettings)
 {
     Association association;
     foreach (XElement xmlAssociation in xmlSettings.Elements("ASSOCIATIONS").Elements("ASSOCIATION"))
     {
         if (xmlAssociation.Attribute("PROJECTNAME").Value == project.Name)
         {
             //association = new Association(xmlAssociation.Attribute("PROJECTNAME").Value, xmlAssociation.Attribute("APPLICATIONNAME").Value,
             //                                                xmlAssociation.Elements("PARAMETERS").Elements("PARAMETER"), xmlAssociation.Elements("CONTEXTMENUS").Elements("CONTEXTMENU"));
             association = new Association();
             //association.Setup(xmlAssociation.Attribute("PROJECTNAME").Value, xmlAssociation.Attribute("APPLICATIONNAME").Value,
                                                             //xmlAssociation.Elements("PARAMETERS").Elements("PARAMETER"), xmlAssociation.Elements("CONTEXTMENUS").Elements("CONTEXTMENU"));
             project.Associations.Add(association);
         }
     }
 }