Exemplo n.º 1
0
        private void CreateJumpList()
        {
            this._jumpList = new JumpList();

            JumpList.SetJumpList(Current, this._jumpList);
            JumpTask helloTask = new JumpTask
                                 {
                                     Title = "Say Hello",
                                     Description = "Shows a Hello World message.",
                                     ApplicationPath = Assembly.GetEntryAssembly().Location,
                                     Arguments = "/hello",
                                 };
            this._jumpList.JumpItems.Add(helloTask);

            JumpTask goodbyeTask = new JumpTask
                                   {
                                       Title = "Say Goodbye",
                                       Description = "Shows a goodbye message.",
                                       ApplicationPath = Assembly.GetEntryAssembly().Location,
                                       Arguments = "/goodbye"
                                   };

            this._jumpList.JumpItems.Add(goodbyeTask);

            this._jumpList.Apply();
        }
Exemplo n.º 2
0
        private void CreateJumpList()
        {
            JumpList jumpList = new JumpList();
            //jumpList.ShowRecentCategory = true;
            JumpList.SetJumpList(Application.Current, jumpList);

            string[] projects = Gibbo.Editor.WPF.Properties.Settings.Default.LastLoadedProjects.Split('|');

            int c = 0;

            foreach (string path in projects)
            {
                if (path.Trim() != string.Empty && File.Exists(path))
                {
                    JumpTask task = new JumpTask();
                    task.CustomCategory = "Recent";

                    task.Title = System.IO.Path.GetFileNameWithoutExtension(path);
                    task.Description = task.Title + " (" + path.Split('.')[0] + ")";
                    task.ApplicationPath = path;

                    jumpList.JumpItems.Add(task);
                    //JumpList.AddToRecentCategory(task);
                    c++;
                    if (c == 8)
                        break;
                }
            }

            jumpList.Apply();
        }
Exemplo n.º 3
0
        public static void CreateJumpList()
        {
            JumpTask update = new JumpTask()
            {
                Title = "Check for Updates",
                Arguments = "/update",
                Description = "Cheks for Software Updates",
                CustomCategory = "Actions",
                IconResourcePath = Assembly.GetEntryAssembly().CodeBase,
                ApplicationPath = Assembly.GetEntryAssembly().CodeBase
            };
            JumpTask restart = new JumpTask()
            {
                Title = "Restart on default monitor",
                Arguments = "/firstmonitor",
                Description = "Restarts the application on the first monitor",
                CustomCategory = "Actions",
                IconResourcePath = Assembly.GetEntryAssembly().CodeBase,
                ApplicationPath = Assembly.GetEntryAssembly().CodeBase
            };

            var appmenu = new JumpList();
            appmenu.JumpItems.Add(update);
            appmenu.JumpItems.Add(restart);
            appmenu.ShowFrequentCategory = false;
            appmenu.ShowRecentCategory = false;

            JumpList.SetJumpList(Application.Current, appmenu);
        }
Exemplo n.º 4
0
        private static JumpItem GetJumpItemForShellObject(object shellObject)
        {
            var shellItem = shellObject as IShellItem2;
            var shellLink = shellObject as IShellLinkW;

            if (shellItem != null)
            {
                JumpPath path = new JumpPath
                {
                    Path = shellItem.GetDisplayName(SIGDN.DESKTOPABSOLUTEPARSING),
                };
                return(path);
            }

            if (shellLink != null)
            {
                var pathBuilder = new StringBuilder(Win32Constant.MAX_PATH);
                shellLink.GetPath(pathBuilder, pathBuilder.Capacity, null, SLGP.RAWPATH);
                var argsBuilder = new StringBuilder(Win32Constant.INFOTIPSIZE);
                shellLink.GetArguments(argsBuilder, argsBuilder.Capacity);
                var descBuilder = new StringBuilder(Win32Constant.INFOTIPSIZE);
                shellLink.GetDescription(descBuilder, descBuilder.Capacity);
                var iconBuilder = new StringBuilder(Win32Constant.MAX_PATH);
                int iconIndex;
                shellLink.GetIconLocation(iconBuilder, iconBuilder.Capacity, out iconIndex);
                var dirBuilder = new StringBuilder(Win32Constant.MAX_PATH);
                shellLink.GetWorkingDirectory(dirBuilder, dirBuilder.Capacity);

                JumpTask task = new JumpTask
                {
                    // Set ApplicationPath and IconResources, even if they're from the current application.
                    // This means that equivalent JumpTasks won't necessarily compare property-for-property.
                    ApplicationPath   = pathBuilder.ToString(),
                    Arguments         = argsBuilder.ToString(),
                    Description       = descBuilder.ToString(),
                    IconResourceIndex = iconIndex,
                    IconResourcePath  = iconBuilder.ToString(),
                    WorkingDirectory  = dirBuilder.ToString(),
                };

                using (PROPVARIANT pv = new PROPVARIANT())
                {
                    var  propStore = (IPropertyStore)shellLink;
                    PKEY pkeyTitle = PKEY.Title;

                    propStore.GetValue(ref pkeyTitle, pv);

                    // PKEY_Title should be an LPWSTR if it's not empty.
                    task.Title = pv.GetValue() ?? "";
                }

                return(task);
            }

            // Unsupported type?
            Debug.Assert(false);
            return(null);
        }
Exemplo n.º 5
0
		public static void UpdateJumplists()
		{
			var iconLibraryPath = ExtractIconLibrary();

			var jump = new JumpList();
			JumpList.SetJumpList(Application.Current, jump);

			if (App.AssemblyStorage.AssemblySettings.ApplicationRecents != null)
			{
				for (int i = 0; i < 10; i++)
				{
					if (i > App.AssemblyStorage.AssemblySettings.ApplicationRecents.Count - 1)
						break;

					var task = new JumpTask();
					int iconIndex = -200;
					switch (App.AssemblyStorage.AssemblySettings.ApplicationRecents[i].FileType)
					{
						case Settings.RecentFileType.Blf:
							iconIndex = -200;
							break;
						case Settings.RecentFileType.Cache:
							iconIndex = -201;
							break;
						case Settings.RecentFileType.MapInfo:
							iconIndex = -202;
							break;
					}

					task.ApplicationPath = VariousFunctions.GetApplicationAssemblyLocation();
					task.Arguments = string.Format("assembly://open \"{0}\"",
						App.AssemblyStorage.AssemblySettings.ApplicationRecents[i].FilePath);
					task.WorkingDirectory = VariousFunctions.GetApplicationLocation();

					task.IconResourcePath = iconLibraryPath;
					task.IconResourceIndex = iconIndex;

					task.CustomCategory = "Recent";
					task.Title = App.AssemblyStorage.AssemblySettings.ApplicationRecents[i].FileName + " - " +
					             App.AssemblyStorage.AssemblySettings.ApplicationRecents[i].FileGame;
					task.Description = string.Format("Open {0} in Assembly. ({1})",
						App.AssemblyStorage.AssemblySettings.ApplicationRecents[i].FileName,
						App.AssemblyStorage.AssemblySettings.ApplicationRecents[i].FilePath);

					jump.JumpItems.Add(task);
				}
			}

			// Show Recent and Frequent categories :D
			jump.ShowFrequentCategory = false;
			jump.ShowRecentCategory = false;

			// Send to the Windows Shell
			jump.Apply();
		}
Exemplo n.º 6
0
 public static JumpTask createJumpTask(string title, string description, string commandArg, int iconIndex)
 {
     var task = new JumpTask();
     task.Title = title;
     task.Description = description;
     task.ApplicationPath = Assembly.GetEntryAssembly().Location;
     task.Arguments = commandArg;
     task.IconResourcePath = task.ApplicationPath;
     task.IconResourceIndex = iconIndex;
     return task;
 }
Exemplo n.º 7
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {

            var di = new DirectoryInfo("C://");
            var jt = new JumpTask
            {
                ApplicationPath = "C:\\Windows\\notepad.exe",
                Arguments = "C://",
                Description = "Run at " + "C://",
                Title = di.Name,
                CustomCategory = "Hello World"
            };

            JumpList.AddToRecentCategory(jt);
        }
        private static object GetShellObjectForJumpItem(JumpItem jumpItem)
        {
            JumpPath jumpPath = jumpItem as JumpPath;
            JumpTask jumpTask = jumpItem as JumpTask;

            if (jumpPath != null)
            {
                return(JumpList.CreateItemFromJumpPath(jumpPath));
            }
            if (jumpTask != null)
            {
                return(JumpList.CreateLinkFromJumpTask(jumpTask, true));
            }
            return(null);
        }
Exemplo n.º 9
0
        private static void InitialiseJumpList()
        {
            var entryAssembly = Assembly.GetEntryAssembly();
            var applicationPath = entryAssembly.Location;
            var jumpList = new JumpList();

            // "I am... Working"
            var workModeSwitchTask = new JumpTask();
            workModeSwitchTask.Title = "Working";
            workModeSwitchTask.Description = "Switch to 'Work' mode";
            workModeSwitchTask.IconResourceIndex = -1;
            workModeSwitchTask.CustomCategory = "I am...";
            workModeSwitchTask.ApplicationPath = applicationPath;
            workModeSwitchTask.Arguments = CommandLineCodes.IAmWorking;
            jumpList.JumpItems.Add(workModeSwitchTask);

            // "I am... Resting"
            var restModeSwitchTask = new JumpTask();
            restModeSwitchTask.Title = "Resting";
            restModeSwitchTask.Description = "Switch to 'Rest' mode";
            restModeSwitchTask.IconResourceIndex = -1;
            restModeSwitchTask.CustomCategory = "I am...";
            restModeSwitchTask.ApplicationPath = applicationPath;
            restModeSwitchTask.Arguments = CommandLineCodes.IAmResting;
            jumpList.JumpItems.Add(restModeSwitchTask);

            // "I am... Playing"
            var playModeSwitchTask = new JumpTask();
            playModeSwitchTask.Title = "Playing";
            playModeSwitchTask.Description = "Switch to 'Play' mode";
            playModeSwitchTask.IconResourceIndex = -1;
            playModeSwitchTask.CustomCategory = "I am...";
            playModeSwitchTask.ApplicationPath = applicationPath;
            playModeSwitchTask.Arguments = CommandLineCodes.IAmPlaying;
            jumpList.JumpItems.Add(playModeSwitchTask);

            // "Exit"
            var exitTask = new JumpTask();
            exitTask.Title = "Exit";
            exitTask.Description = "Exit Lazybones";
            exitTask.IconResourceIndex = -1;
            exitTask.ApplicationPath = applicationPath;
            exitTask.Arguments = "/q";
            jumpList.JumpItems.Add(exitTask);

            jumpList.Apply();
            JumpList.SetJumpList(Application.Current, jumpList);
        }
Exemplo n.º 10
0
        private static JumpItem GetJumpItemForShellObject(object shellObject)
        {
            IShellItem2 shellItem  = shellObject as IShellItem2;
            IShellLinkW shellLinkW = shellObject as IShellLinkW;

            if (shellItem != null)
            {
                return(new JumpPath
                {
                    Path = shellItem.GetDisplayName((SIGDN)2147647488U)
                });
            }
            if (shellLinkW != null)
            {
                StringBuilder stringBuilder = new StringBuilder(260);
                shellLinkW.GetPath(stringBuilder, stringBuilder.Capacity, null, SLGP.RAWPATH);
                StringBuilder stringBuilder2 = new StringBuilder(1024);
                shellLinkW.GetArguments(stringBuilder2, stringBuilder2.Capacity);
                StringBuilder stringBuilder3 = new StringBuilder(1024);
                shellLinkW.GetDescription(stringBuilder3, stringBuilder3.Capacity);
                StringBuilder stringBuilder4 = new StringBuilder(260);
                int           iconResourceIndex;
                shellLinkW.GetIconLocation(stringBuilder4, stringBuilder4.Capacity, out iconResourceIndex);
                StringBuilder stringBuilder5 = new StringBuilder(260);
                shellLinkW.GetWorkingDirectory(stringBuilder5, stringBuilder5.Capacity);
                JumpTask jumpTask = new JumpTask
                {
                    ApplicationPath   = stringBuilder.ToString(),
                    Arguments         = stringBuilder2.ToString(),
                    Description       = stringBuilder3.ToString(),
                    IconResourceIndex = iconResourceIndex,
                    IconResourcePath  = stringBuilder4.ToString(),
                    WorkingDirectory  = stringBuilder5.ToString()
                };
                using (PROPVARIANT propvariant = new PROPVARIANT())
                {
                    IPropertyStore propertyStore = (IPropertyStore)shellLinkW;
                    PKEY           title         = PKEY.Title;
                    propertyStore.GetValue(ref title, propvariant);
                    jumpTask.Title = (propvariant.GetValue() ?? "");
                }
                return(jumpTask);
            }
            return(null);
        }
Exemplo n.º 11
0
 public static void AddToRecentCategory(JumpTask jumpTask)
 {
     Verify.IsNotNull <JumpTask>(jumpTask, "jumpTask");
     if (Utilities.IsOSWindows7OrNewer)
     {
         IShellLinkW shellLinkW = JumpList.CreateLinkFromJumpTask(jumpTask, false);
         try
         {
             if (shellLinkW != null)
             {
                 NativeMethods2.SHAddToRecentDocs(shellLinkW);
             }
         }
         finally
         {
             Utilities.SafeRelease <IShellLinkW>(ref shellLinkW);
         }
     }
 }
Exemplo n.º 12
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var task = new JumpTask
            {
                Title = "Configure",
                Arguments = "-configure",
                Description = "Open program settings",
                CustomCategory = "Actions",
                IconResourcePath = Assembly.GetEntryAssembly().CodeBase,
                ApplicationPath = Assembly.GetEntryAssembly().CodeBase
            };

            var jumpList = new JumpList();
            jumpList.JumpItems.Add(task);
            jumpList.ShowFrequentCategory = false;
            jumpList.ShowRecentCategory = false;

            JumpList.SetJumpList(Application.Current, jumpList);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates a JumpTask
        /// </summary>
        /// <param name="game"></param>
        /// <returns></returns>
        private JumpTask CreateJumpTask(Game game)
        {
            JumpTask jumpTask1 = new JumpTask();
            jumpTask1.ApplicationPath = Settings.Default.MAME_EXE;
            jumpTask1.WorkingDirectory = Path.GetDirectoryName(Settings.Default.MAME_EXE);
            jumpTask1.Arguments = game.Name;

            string iconPath = game.IsParent
                                  ? Settings.Default.icons_directory + game.Name + ".ico"
                                  : Settings.Default.icons_directory + game.ParentSet + ".ico";
            if (!File.Exists(iconPath))
                jumpTask1.IconResourcePath = Application.ExecutablePath;
            else
                jumpTask1.IconResourcePath = iconPath;
            jumpTask1.Title = game.Description;
            jumpTask1.Description = game.Year + " " + game.Manufacturer;
            jumpTask1.CustomCategory = "Recently Played Games";

            return jumpTask1;
        }
Exemplo n.º 14
0
		/// <summary>
		/// add an item to the W7+ jumplist
		/// </summary>
		/// <param name="fullpath">fully qualified path, can include '|' character for archives</param>
		public static void AddRecentItem(string fullpath)
		{
			string title;
			if (fullpath.Contains('|'))
				title = fullpath.Split('|')[1];
			else
				title = Path.GetFileName(fullpath);

			string exepath = Assembly.GetEntryAssembly().Location;

			var ji = new JumpTask
			{
				ApplicationPath = exepath,
				Arguments = '"' + fullpath + '"',
				Title = title,
				// for some reason, this doesn't work
				WorkingDirectory = Path.GetDirectoryName(exepath)
			};
			JumpList.AddToRecentCategory(ji);
		}
Exemplo n.º 15
0
        private static void setupJumpList()
        {
            #region Jumplist stuff
            // Jumplist setup
            JumpList masgau_jump_list = JumpList.GetJumpList(Application.Current);
            if (masgau_jump_list == null) {
                masgau_jump_list = new JumpList();
                JumpList.SetJumpList(Application.Current, masgau_jump_list);
            } else {
                masgau_jump_list.JumpItems.Clear();
                masgau_jump_list.ShowFrequentCategory = false;
                masgau_jump_list.ShowRecentCategory = false;

            }

            JumpTask masgau_jump = new JumpTask();
            masgau_jump.ApplicationPath = Core.ExecutableName;
            masgau_jump.IconResourcePath = Core.ExecutableName;
            masgau_jump.IconResourceIndex = 0;
            masgau_jump.WorkingDirectory = Core.ExecutablePath;
            masgau_jump.Title = Strings.GetLabelString("JumpMainProgram");
            masgau_jump.Description = Strings.GetToolTipString("JumpMainProgram");
            masgau_jump.CustomCategory = "MASGAU";
            masgau_jump_list.JumpItems.Add(masgau_jump);

            masgau_jump = new JumpTask();
            masgau_jump.ApplicationPath = Core.ExecutableName;
            masgau_jump.IconResourcePath = Core.ExecutableName;
            masgau_jump.IconResourceIndex = 0;
            masgau_jump.WorkingDirectory = Core.ExecutablePath;
            masgau_jump.Title = Strings.GetLabelString("JumpMainProgramAllUsers");
            masgau_jump.Description = Strings.GetToolTipString("JumpMainProgramAllUsers");
            masgau_jump.Arguments = "-allusers";
            masgau_jump.CustomCategory = "MASGAU";
            masgau_jump_list.JumpItems.Add(masgau_jump);

            masgau_jump_list.Apply();
            #endregion
        }
Exemplo n.º 16
0
        public void AddJumpTask(NetworkConfiguration nc)
        {
            JumpTask jumpTask1 = new JumpTask();

            string appPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;

            jumpTask1.ApplicationPath = appPath;
            jumpTask1.IconResourcePath = appPath;
            jumpTask1.Arguments = "/activate " + nc.Id.ToString();
            jumpTask1.Title = nc.Name;
            jumpTask1.Description = string.Empty;
            jumpTask1.CustomCategory = LanguageResources.Networks_Label;

            JumpList jumpList = JumpList.GetJumpList(this.currentApp);
            if (jumpList == null)
            {
                jumpList = new JumpList();
                JumpList.SetJumpList(this.currentApp, jumpList);
            }

            jumpList.JumpItems.Add(jumpTask1);
        }
Exemplo n.º 17
0
        private void AddTask(object sender, RoutedEventArgs e)
        {
            if (_applicationName != string.Empty && _applicationPath != string.Empty)
            {
                const string desc = "Open {0}.";
                var jumpTask = new JumpTask
                {
                    ApplicationPath = _applicationPath,
                    IconResourcePath = _applicationPath,
                    Title = _applicationName,
                    Description = string.Format(desc, _applicationName)
                };

                CurrentJumpList.JumpItems.Add(jumpTask);
                CurrentJumpList.JumpItemsRemovedByUser += CurrentJumpListOnJumpItemsRemovedByUser;
                JumpList.SetJumpList(Application.Current, CurrentJumpList);
                FooterTextBlock.Text = $"Task {_applicationName} has been added.";
            }
            else
            {
                FooterTextBlock.Text = "Make sure the you have select an item and named it.";
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Add the task at the specified file path to the application's JumpList's recent items.
        /// </summary>
        /// <remarks>
        /// This makes the item eligible for inclusion in the special Recent and Frequent categories.
        /// </remarks>
        public static void AddToRecentCategory(JumpTask jumpTask)
        {
            Verify.IsNotNull(jumpTask, "jumpTask");

            // SHAddToRecentDocs only allows IShellLinks in Windows 7 and later.
            // Silently fail this if that's not the case.
            // We don't give feedback on success here, so this is okay.
            if (Utilities.IsOSWindows7OrNewer)
            {
                IShellLinkW shellLink = CreateLinkFromJumpTask(jumpTask, false);
                try
                {
                    if (shellLink != null)
                    {
                        NativeMethods2.SHAddToRecentDocs(shellLink);
                    }
                }
                finally
                {
                    Utilities.SafeRelease(ref shellLink);
                }
            }
        }
Exemplo n.º 19
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     // Retrieve the current jump list.
     JumpList jumpList = new JumpList();
     JumpList.SetJumpList(Application.Current, jumpList);
                 
     // Add a new JumpPath for a file in the application folder.
     string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
     path = Path.Combine(path, "readme.txt");
     if (File.Exists(path))
     {
         JumpTask jumpTask = new JumpTask();
         jumpTask.CustomCategory = "Documentation";
         jumpTask.Title = "Read the readme.txt";
         jumpTask.ApplicationPath = @"c:\windows\notepad.exe";
         jumpTask.IconResourcePath = @"c:\windows\notepad.exe";
         jumpTask.Arguments = path;
         jumpList.JumpItems.Add(jumpTask);
     }
     
     // Update the jump list.
     jumpList.Apply();
 }
Exemplo n.º 20
0
        protected override void OnStartup(System.Windows.StartupEventArgs e)
        {
            base.OnStartup(e);

            // Retrieve the current jump list.
            JumpList jumpList = new JumpList();
            JumpList.SetJumpList(Application.Current, jumpList);

            // Add a new JumpPath for an application task.            
            JumpTask jumpTask = new JumpTask();
            jumpTask.CustomCategory = "Tasks";
            jumpTask.Title = "Do Something";
            jumpTask.ApplicationPath = Assembly.GetExecutingAssembly().Location;
            jumpTask.IconResourcePath = jumpTask.ApplicationPath;
            jumpTask.Arguments = "@#StartOrder";
            jumpList.JumpItems.Add(jumpTask);         

            // Update the jump list.
            jumpList.Apply();

            // Load the main window.
            Window1 win = new Window1();
            win.Show();
        }               
Exemplo n.º 21
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var jt = new JumpTask
            {
                ApplicationPath = "C:\\Windows\\notepad.exe",
                Arguments = "readme.txt",
                Title = "Recent Entry for Notepad",
                CustomCategory = "Dummy"
            };

            JumpList.AddToRecentCategory(jt);

            var jt2 = new JumpTask
            {
                ApplicationPath = "C:\\Windows\\notepad.exe",
                Arguments = "readme.txt",
                Title = "Code Entry for Notepad",
                CustomCategory = "Dummy"
            };

            var currentJumplist = JumpList.GetJumpList(App.Current);
            currentJumplist.JumpItems.Add(jt2);
            currentJumplist.Apply();
        }
 public static void AddToRecentCategory(JumpTask jumpTask)
 {
 }
Exemplo n.º 23
0
        private static IShellLinkW CreateLinkFromJumpTask(JumpTask jumpTask, bool allowSeparators)
        {
            if (string.IsNullOrEmpty(jumpTask.Title) && (!allowSeparators || !string.IsNullOrEmpty(jumpTask.CustomCategory)))
            {
                return(null);
            }
            IShellLinkW shellLinkW = (IShellLinkW)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("00021401-0000-0000-C000-000000000046")));
            IShellLinkW result;

            try
            {
                string path = JumpList._FullName;
                if (!string.IsNullOrEmpty(jumpTask.ApplicationPath))
                {
                    path = jumpTask.ApplicationPath;
                }
                shellLinkW.SetPath(path);
                if (!string.IsNullOrEmpty(jumpTask.WorkingDirectory))
                {
                    shellLinkW.SetWorkingDirectory(jumpTask.WorkingDirectory);
                }
                if (!string.IsNullOrEmpty(jumpTask.Arguments))
                {
                    shellLinkW.SetArguments(jumpTask.Arguments);
                }
                if (jumpTask.IconResourceIndex != -1)
                {
                    string pszIconPath = JumpList._FullName;
                    if (!string.IsNullOrEmpty(jumpTask.IconResourcePath))
                    {
                        if (jumpTask.IconResourcePath.Length >= 260)
                        {
                            return(null);
                        }
                        pszIconPath = jumpTask.IconResourcePath;
                    }
                    shellLinkW.SetIconLocation(pszIconPath, jumpTask.IconResourceIndex);
                }
                if (!string.IsNullOrEmpty(jumpTask.Description))
                {
                    shellLinkW.SetDescription(jumpTask.Description);
                }
                IPropertyStore propertyStore = (IPropertyStore)shellLinkW;
                PROPVARIANT    propvariant   = new PROPVARIANT();
                try
                {
                    PKEY pkey = default(PKEY);
                    if (!string.IsNullOrEmpty(jumpTask.Title))
                    {
                        propvariant.SetValue(jumpTask.Title);
                        pkey = PKEY.Title;
                    }
                    else
                    {
                        propvariant.SetValue(true);
                        pkey = PKEY.AppUserModel_IsDestListSeparator;
                    }
                    propertyStore.SetValue(ref pkey, propvariant);
                }
                finally
                {
                    Utilities.SafeDispose <PROPVARIANT>(ref propvariant);
                }
                propertyStore.Commit();
                IShellLinkW shellLinkW2 = shellLinkW;
                shellLinkW = null;
                result     = shellLinkW2;
            }
            catch (Exception)
            {
                result = null;
            }
            finally
            {
                Utilities.SafeRelease <IShellLinkW>(ref shellLinkW);
            }
            return(result);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Initializes the GUI
        /// </summary>
        private void InitGUI()
        {
            // create glass effect
            RefreshGlassEffect();

            #region Events handlers

            NavigationPane.GotFocus += new RoutedEventHandler(NavigationPane_GotFocus);

            SettingsManager.QueueTracks.CollectionChanged += new NotifyCollectionChangedEventHandler(QueueTracks_CollectionChanged);
            SettingsManager.HistoryTracks.CollectionChanged += new NotifyCollectionChangedEventHandler(HistoryTracks_CollectionChanged);
            SettingsManager.FileTracks.CollectionChanged += new NotifyCollectionChangedEventHandler(LibraryTracks_CollectionChanged);
            SettingsManager.RadioTracks.CollectionChanged += new NotifyCollectionChangedEventHandler(RadioTracks_CollectionChanged);
            if (SettingsManager.FileListConfig != null)
                SettingsManager.FileListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged);
            if (SettingsManager.YouTubeListConfig != null)
                SettingsManager.YouTubeListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged);
            if (SettingsManager.SoundCloudListConfig != null)
                SettingsManager.SoundCloudListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged);
            if (SettingsManager.RadioListConfig != null)
                SettingsManager.RadioListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged);
            if (SettingsManager.JamendoListConfig != null)
                SettingsManager.JamendoListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged);
            if (SettingsManager.QueueListConfig != null)
                SettingsManager.QueueListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged);
            if (SettingsManager.HistoryListConfig != null)
                SettingsManager.HistoryListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged);

            FilesystemManager.SourceModified += new SourceModifiedEventHandler(FilesystemManager_SourceModified);
            FilesystemManager.TrackModified += new PropertyChangedEventHandler(FilesystemManager_TrackModified);
            FilesystemManager.PathModified += new PathModifiedEventHandler(FilesystemManager_PathModified);
            FilesystemManager.PathRenamed += new RenamedEventHandler(FilesystemManager_PathRenamed);
            FilesystemManager.ProgressChanged += new ProgressChangedEventHandler(FilesystemManager_ProgressChanged);
            FilesystemManager.SourceAdded += new SourcesModifiedEventHandler(FilesystemManager_SourceAdded);
            FilesystemManager.SourceRemoved += new SourcesModifiedEventHandler(FilesystemManager_SourceRemoved);

            MediaManager.TrackSwitched += new TrackSwitchedEventHandler(MediaManager_TrackSwitched);
            MediaManager.LoadedTrack += new LoadedTrackDelegate(MediaManager_LoadedTrack);
            MediaManager.Started += new EventHandler(MediaManager_Started);
            MediaManager.SearchMatch = TrackList_SearchMatch;

            UpgradeManager.Checked += new EventHandler(UpgradeManager_Checked);
            UpgradeManager.ErrorOccured += new Core.ErrorEventHandler(UpgradeManager_ErrorOccured);
            UpgradeManager.ProgressChanged += new ProgressChangedEventHandler(UpgradeManager_ProgressChanged);
            UpgradeManager.Upgraded += new EventHandler(UpgradeManager_Upgraded);
            UpgradeManager.UpgradeFound += new EventHandler(UpgradeManager_UpgradeFound);

            PluginManager.RefreshVisualizerSelector += new EventHandler(PluginManager_RefreshVisualizerSelector);
            PluginManager.Installed += new EventHandler<PluginEventArgs>(PluginManager_Installed);
            PluginManager.Uninstalled += new EventHandler<PluginEventArgs>(PluginManager_Uninstalled);
            PluginManager.Initialize();

            SettingsManager.PropertyChanged += new PropertyChangedWithValuesEventHandler(SettingsManager_PropertyChanged);
            ServiceManager.ModifyTracks += new EventHandler<ModifiedEventArgs>(ServiceManager_ModifyTracks);

            NavigationPane.CreateNewPlaylistETB.EnteredEditMode += new EventHandler(EditableTextBlock_EnteredEditMode);
            SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);

            resortDelay.Interval = new TimeSpan(0, 0, 0, 0, 500);
            resortDelay.Tick += new EventHandler(ResortDelay_Tick);

            sourceModifiedDelay.Tick += new EventHandler(SourceModifiedDelay_Tick);
            sourceModifiedDelay.Interval = new TimeSpan(0, 0, 0, 1, 500);

            #endregion

            #region Tray icon

            // create system tray icon
            trayIcon = (TaskbarIcon)FindResource("NotifyIcon");
            trayIcon.TrayToolTip = new TrayToolTip(this);
            trayIcon.TrayLeftMouseUp += TaskbarClicked;
            trayMenu = new ContextMenu();
            trayMenuShow = new MenuItem();
            trayMenuExit = new MenuItem();
            trayMenuPlay = new MenuItem();
            trayMenuNext = new MenuItem();
            trayMenuPrev = new MenuItem();
            trayMenuShow.Header = U.T("TrayShow");
            trayMenuExit.Header = U.T("TrayExit");
            trayMenuPlay.Header = U.T("TrayPlay");
            trayMenuNext.Header = U.T("TrayNext");
            trayMenuPrev.Header = U.T("TrayPrev");
            trayMenuShow.Click += TrayShow_Clicked;
            trayMenuExit.Click += TrayExit_Clicked;
            trayMenuPlay.Click += TrayPlayPause_Clicked;
            trayMenuNext.Click += TrayNext_Clicked;
            trayMenuPrev.Click += TrayPrevious_Clicked;
            trayMenu.Items.Add(trayMenuShow);
            trayMenu.Items.Add(new Separator());
            trayMenu.Items.Add(trayMenuPlay);
            trayMenu.Items.Add(trayMenuNext);
            trayMenu.Items.Add(trayMenuPrev);
            trayMenu.Items.Add(new Separator());
            trayMenu.Items.Add(trayMenuExit);
            trayIcon.ContextMenu = trayMenu;

            #endregion

            #region Thumbnail buttons

            //// create thumbnail buttons
            taskbarPrev = new ThumbnailToolbarButton(Properties.Resources.Previous, U.T("TaskbarPrev"));
            taskbarPrev.Enabled = true;
            taskbarPrev.Click += TaskbarPrevious_Clicked;
            taskbarPlay = new ThumbnailToolbarButton(Properties.Resources.Play, U.T("TaskbarPlay"));
            taskbarPlay.Enabled = true;
            taskbarPlay.Click += TaskbarPlayPause_Clicked;
            taskbarNext = new ThumbnailToolbarButton(Properties.Resources.Next, U.T("TaskbarNext"));
            taskbarNext.Enabled = true;
            taskbarNext.Click += TaskbarNext_Clicked;
            TaskbarManager.Instance.ThumbnailToolbars.AddButtons(
                new WindowInteropHelper(this).Handle,
                new ThumbnailToolbarButton[] { taskbarPrev, taskbarPlay, taskbarNext }
            );

            #endregion

            #region Jump lists

            jumpTaskPlay = new JumpTask()
            {
                Title = U.T("JumpPlay", "Title"),
                Arguments = "/play",
                Description = U.T("JumpPlay", "Description"),
                IconResourceIndex = -1,
                ApplicationPath = Assembly.GetEntryAssembly().CodeBase,
            };

            jumpTaskNext = new JumpTask()
            {
                Title = U.T("JumpNext", "Title"),
                Arguments = "/next",
                Description = U.T("JumpNext", "Description"),
                IconResourceIndex = -1,
                ApplicationPath = Assembly.GetEntryAssembly().CodeBase,
            };

            jumpTaskPrev = new JumpTask()
            {
                Title = U.T("JumpPrev", "Title"),
                Arguments = "/previous",
                Description = U.T("JumpPrev", "Description"),
                IconResourceIndex = -1,
                ApplicationPath = Assembly.GetEntryAssembly().CodeBase,
            };

            jumpList = new System.Windows.Shell.JumpList();
            jumpList.JumpItems.Add(jumpTaskPlay);
            jumpList.JumpItems.Add(jumpTaskNext);
            jumpList.JumpItems.Add(jumpTaskPrev);
            jumpList.ShowRecentCategory = true;
            jumpList.ShowFrequentCategory = true;
            System.Windows.Shell.JumpList.SetJumpList(Application.Current, jumpList);

            #endregion

            #region Style

            Utilities.DefaultAlbumArt = "/Platform/Windows 7/GUI/Images/AlbumArt/Default.jpg";

            // rough detection of aero vs classic
            // you'll se a lot more of these around the code
            if (System.Windows.Forms.VisualStyles.VisualStyleInformation.DisplayName == "")
            {
                // applying classic theme
                SolidColorBrush scb = (SolidColorBrush)FindResource("DetailsPaneKey");
                scb.Color = SystemColors.ControlTextColor;
                scb = (SolidColorBrush)FindResource("DetailsPaneValue");
                scb.Color = SystemColors.ControlTextColor;
                scb = (SolidColorBrush)FindResource("InfoPaneTitle");
                scb.Color = SystemColors.ControlTextColor;
                scb = (SolidColorBrush)FindResource("InfoPaneText");
                scb.Color = SystemColors.ControlTextColor;

                MainFrame.BorderBrush = SystemColors.ControlBrush;
                MainFrame.Background = SystemColors.ControlBrush;
                MainContainer.Background = SystemColors.ControlBrush;
                InfoPane.Background = SystemColors.WindowBrush;
                VerticalSplitter.Background = SystemColors.ControlBrush;

                TopToolbar.Style = null;
                DetailsPane.Style = (Style)FindResource("ClassicDetailsPaneStyle");

                OuterBottomRight.BorderBrush = SystemColors.ControlLightLightBrush;
                OuterTopLeft.BorderBrush = SystemColors.ControlDarkBrush;
                InnerBottomRight.BorderBrush = SystemColors.ControlDarkBrush;
                InnerTopLeft.BorderBrush = SystemColors.ControlLightLightBrush;

                ControlPanel.AboutTitle.Style = (Style)FindResource("ClassicControlPanelTitleStyle");
                ControlPanel.ShortcutTitle.Style = (Style)FindResource("ClassicControlPanelTitleStyle");
                ControlPanel.GeneralTitle.Style = (Style)FindResource("ClassicControlPanelTitleStyle");
                Utilities.DefaultAlbumArt = "/Platform/Windows 7/GUI/Images/AlbumArt/Classic.jpg";
            }

            #endregion

            VisualizerList.ItemsSource = PluginManager.VisualizerSelector;

            LibraryTime = 0;
            QueueTime = 0;
            HistoryTime = 0;
            if (SettingsManager.FileTracks != null)
                foreach (TrackData track in SettingsManager.FileTracks)
                    LibraryTime += track.Length;
            if (SettingsManager.QueueTracks != null)
                foreach (TrackData track in SettingsManager.QueueTracks)
                    QueueTime += track.Length;
            if (SettingsManager.HistoryTracks != null)
                foreach (TrackData track in SettingsManager.HistoryTracks)
                    HistoryTime += track.Length;

            NavigationColumn.Width = new GridLength(SettingsManager.NavigationPaneWidth);
            double h = SettingsManager.DetailsPaneHeight;
            DetailsRow.Height = new GridLength(h);

            UpdateVisibility("menubar");
            UpdateVisibility("details");

            RefreshStrings();
            U.ListenForShortcut = true;

            FilesystemManager.AddSystemFolders(true);

            #region Create playlists

            foreach (PlaylistData playlist in SettingsManager.Playlists)
                CreatePlaylist(playlist, false);

            PlaylistManager.PlaylistModified += new ModifiedEventHandler(PlaylistManager_PlaylistModified);
            PlaylistManager.PlaylistRenamed += new RenamedEventHandler(PlaylistManager_PlaylistRenamed);

            if (SettingsManager.CurrentSelectedNavigation == "YouTube")
                NavigationPane.Youtube.Focus();
            else if (SettingsManager.CurrentSelectedNavigation == "SoundCloud")
                NavigationPane.SoundCloud.Focus();
            else if (SettingsManager.CurrentSelectedNavigation == "Radio")
                NavigationPane.Radio.Focus();
            else if (SettingsManager.CurrentSelectedNavigation == "Jamendo")
                NavigationPane.Jamendo.Focus();
            else if (SettingsManager.CurrentSelectedNavigation == "Queue")
                NavigationPane.Queue.Focus();
            else if (SettingsManager.CurrentSelectedNavigation == "History")
                NavigationPane.History.Focus();
            else if (SettingsManager.CurrentSelectedNavigation == "Video")
                NavigationPane.Video.Focus();
            else if (SettingsManager.CurrentSelectedNavigation == "Visualizer")
                NavigationPane.Visualizer.Focus();
            else if (!SettingsManager.CurrentSelectedNavigation.StartsWith("Playlist:"))
                NavigationPane.Files.Focus();
            else
            {
                string name = SettingsManager.CurrentSelectedNavigation.Split(new[] { ':' }, 2)[1];
                foreach (TreeViewItem tvi in NavigationPane.Playlists.Items)
                {
                    if ((string)tvi.Tag == name)
                    {
                        tvi.Focus();
                        break;
                    }
                }
            }

            #endregion

            #region Load track lists

            U.L(LogLevel.Debug, "main", "Initialize track lists");
            switch (SettingsManager.CurrentActiveNavigation)
            {
                case "Queue":
                    if (FileTracks == null)
                        FileTracks = InitTrackList(new ViewDetails(), SettingsManager.FileListConfig, SettingsManager.FileTracks);
                    break;

                case "Radio":
                    if (RadioTracks == null)
                        RadioTracks = InitTrackList(new ViewDetails(), SettingsManager.RadioListConfig, SettingsManager.RadioTracks);
                    break;

                case "YouTube":
                    if (YouTubeTracks == null)
                        YouTubeTracks = (YouTubeTracks)InitTrackList(new YouTubeTracks(), SettingsManager.YouTubeListConfig);
                    break;

                case "SoundCloud":
                    if (SoundCloudTracks == null)
                        SoundCloudTracks = (SoundCloudTracks)InitTrackList(new SoundCloudTracks(), SettingsManager.SoundCloudListConfig);
                    break;

                case "Jamendo":
                    if (JamendoTracks == null)
                        JamendoTracks = (JamendoTracks)InitTrackList(new JamendoTracks(), SettingsManager.JamendoListConfig);
                    break;

                default:
                    if (SettingsManager.CurrentActiveNavigation.StartsWith("Playlist:"))
                    {
                        string pname = SettingsManager.CurrentActiveNavigation.Split(new[] { ':' }, 2)[1];
                        PlaylistData p = PlaylistManager.FindPlaylist(pname);
                        if (p != null)
                        {
                            ViewDetails vd = (ViewDetails)PlaylistTrackLists[pname];
                            if (vd == null)
                                vd = InitTrackList(new ViewDetails(), p.ListConfig, p.Tracks);
                        }
                    }
                    break;
            }
            if (FileTracks == null)
                FileTracks = InitTrackList(new ViewDetails(), SettingsManager.FileListConfig, SettingsManager.FileTracks);

            #endregion

            #region File association prompt

            if (SettingsManager.FirstRun)
            {
                Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate()
                {
                    // Show welcome dialog
                    TaskDialogResult tdr = Welcome.Show(new WindowInteropHelper(this).Handle);
                    Associations a = new Associations();

                    ProcessStartInfo assProcInfo = new ProcessStartInfo();
                    assProcInfo.FileName = U.FullPath;
                    assProcInfo.Verb = "runas";
                    string assProcArgs = "--associate {0}";

                    try
                    {
                        switch (tdr)
                        {
                            case TaskDialogResult.Yes:
                                assProcInfo.Arguments = String.Format(assProcArgs,
                                    string.Join(",", a.FullFileList.ToArray()));
                                Process.Start(assProcInfo);
                                break;

                            case TaskDialogResult.CustomButtonClicked:
                                a.ShowDialog();
                                assProcInfo.Arguments = String.Format(assProcArgs,
                                    string.Join(",", a.FileList.ToArray()));
                                Process.Start(assProcInfo);
                                break;

                            case TaskDialogResult.Cancel:
                                break;
                        }
                    }
                    catch (Exception e)
                    {
                        U.L(LogLevel.Warning, "MAIN", "Could not set associations: " + e.Message);
                    }
                }));

                SettingsManager.FirstRun = false;
            }

            #endregion

            #region Commented
            //System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal);
            #endregion
        }
Exemplo n.º 25
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool exitApp = false;
            try
            {
                if (WindowsAPI.getOSInfo() == WindowsAPI.OsVersionInfo.Windows8)
                {
                    TheStatusBar.Visibility = System.Windows.Visibility.Collapsed;
                    rStatusbar.Height = new GridLength(0);
                }



                Handle = new WindowInteropHelper(Application.Current.MainWindow).Handle;
                //Itmpop = new ItemPopup();
                //Itmpop.Visibility = System.Windows.Visibility.Hidden;
                //Itmpop.Owner = this;
                //Itmpop.Show();

                //'sets up FileSystemWatcher for Favorites folder
                String FavPath = "";
                try
                {
                    FavPath = KnownFolders.Links.ParsingName;
                    FileSystemWatcher fsw = new FileSystemWatcher(FavPath);
                    fsw.Created += new FileSystemEventHandler(fsw_Created);
                    fsw.Deleted += new FileSystemEventHandler(fsw_Deleted);
                    fsw.Renamed += new RenamedEventHandler(fsw_Renamed);
                    fsw.EnableRaisingEvents = true;
                }
                catch
                {

                    FavPath = "";
                }

                //' set up breadcrumb bar
                breadcrumbBarControl1.SetDragHandlers(new DragEventHandler(bbi_DragEnter), new DragEventHandler(bbi_DragLeave), new DragEventHandler(bbi_DragOver), new DragEventHandler(bbi_Drop));

                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                 (ThreadStart)(() =>
                                 {
                                     //PicturePreview = new PreviewMedia();

                                     //'set up Favorites menu (note that BetterExplorer does not support links to a Control Panel. lol -JaykeBird)
                                     //'I will probably use a modification to this code in the new breadcrumbbar
                                     if (FavPath != "")
                                     {
                                         DirectoryInfo FavInfo = new DirectoryInfo(FavPath);
                                         FileInfo[] FavFiles = FavInfo.GetFiles();
                                         foreach (FileInfo item in FavFiles)
                                         {
                                             if (Path.GetExtension(item.FullName).ToLowerInvariant() == ".lnk")
                                             {
                                                 try
                                                 {
                                                     ShellObject so = ShellObject.FromParsingName(item.FullName);
                                                     MenuItem mi = new MenuItem();
                                                     mi.Header = so.GetDisplayName(DisplayNameType.Default);
                                                     ShellLink lnk = new ShellLink(so.ParsingName);
                                                     string Target = lnk.Target;
                                                     if (Target.Contains("::"))
                                                     {
                                                         Target = "shell:" + Target;
                                                     }
                                                     if (item.Name.ToLowerInvariant() == "recentplaces.lnk")
                                                     {
                                                         Target = "shell:::{22877a6d-37a1-461a-91b0-dbda5aaebc99}";
                                                     }
                                                     mi.Tag = Target;
                                                     lnk.Dispose();
                                                     so.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
                                                     so.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
                                                     ImageSource icon = so.Thumbnail.BitmapSource;
                                                     mi.Focusable = false;
                                                     mi.Icon = icon;
                                                     mi.Click += new RoutedEventHandler(mif_Click);
                                                     so.Dispose();
                                                     btnFavorites.Items.Add(mi);
                                                 }
                                                 catch
                                                 {


                                                 }
                                             }
                                         }
                                     }
                                     else
                                     {
                                         btnFavorites.Visibility = System.Windows.Visibility.Collapsed;
                                     }

                                     //'set up Explorer control
                                     Explorer.SelectionChanged += new EventHandler(ExplorerBrowserControl_SelectionChanged);
                                     Explorer.NavigationComplete += new EventHandler<NavigationCompleteEventArgs>(ExplorerBrowserControl_NavigationComplete);
                                     Explorer.ViewEnumerationComplete += new EventHandler(ExplorerBrowserControl_ViewEnumerationComplete);
                                     Explorer.NavigationPending += new EventHandler<NavigationPendingEventArgs>(Explorer_NavigationPending);
                                     Explorer.GotFocus += new EventHandler(Explorer_GotFocus);
                                     Explorer.ExplorerGotFocus += new EventHandler(Explorer_ExplorerGotFocus);
                                     //Explorer.ExplorerGotFocus += new EventHandler(Explorer_ExplorerGotFocus);
                                     Explorer.RenameFinished += new EventHandler(Explorer_RenameFinished);
                                     Explorer.KeyUP += new EventHandler<ExplorerKeyUPEventArgs>(Explorer_KeyUP);
                                     Explorer.KeyUp += new System.Windows.Forms.KeyEventHandler(explorerBrowser1_KeyUp);
                                     Explorer.LostFocus += new EventHandler(Explorer_LostFocus);

                                     Explorer.NavigationOptions.PaneVisibility.Commands = PaneVisibilityState.Hide;
                                     Explorer.NavigationOptions.PaneVisibility.CommandsOrganize = PaneVisibilityState.Hide;
                                     Explorer.NavigationOptions.PaneVisibility.CommandsView = PaneVisibilityState.Hide;
                                     Explorer.ItemsChanged += new EventHandler(Explorer_ItemsChanged);
                                     Explorer.ContentOptions.FullRowSelect = true;
                                     //Explorer.ContentOptions.CheckSelect = false;
                                     Explorer.ClientSizeChanged += new EventHandler(ExplorerBrowserControl_ClientSizeChanged);
                                     Explorer.Paint += new System.Windows.Forms.PaintEventHandler(ExplorerBrowserControl_Paint);
                                     Explorer.ViewChanged += new EventHandler<ViewChangedEventArgs>(Explorer_ViewChanged);
                                     //Explorer.ItemHot += new EventHandler<ExplorerAUItemEventArgs>(Explorer_ItemHot);
                                     Explorer.ExplorerBrowserMouseLeave += new EventHandler(Explorer_ExplorerBrowserMouseLeave);
                                     Explorer.MouseMove += new System.Windows.Forms.MouseEventHandler(Explorer_MouseMove);
                                     IsCalledFromLoading = true;
                                     WindowsAPI.SHELLSTATE state = new WindowsAPI.SHELLSTATE();
                                     WindowsAPI.SHGetSetSettings(ref state, WindowsAPI.SSF.SSF_SHOWALLOBJECTS | WindowsAPI.SSF.SSF_SHOWEXTENSIONS, false);
                                     chkHiddenFiles.IsChecked = (state.fShowAllObjects == 1);
                                     chkExtensions.IsChecked = (state.fShowExtensions == 1);
                                     IsCalledFromLoading = false;
                                     isOnLoad = true;
                                     //'load from Registry
                                     RegistryKey rk = Registry.CurrentUser;
                                     RegistryKey rks = rk.CreateSubKey(@"Software\BExplorer");

                                     switch (Convert.ToString(rks.GetValue(@"CurrentTheme", "Blue")))
                                     {
                                         case "Blue":
                                             btnBlue.IsChecked = true;
                                             break;
                                         case "Silver":
                                             btnSilver.IsChecked = true;
                                             break;
                                         case "Black":
                                             btnBlack.IsChecked = true;
                                             break;
                                         case "Green":
                                             btnGreen.IsChecked = true;
                                             break;
                                         default:
                                             btnBlue.IsChecked = true;
                                             break;
                                     }
                                     int HFlyoutEnabled = (int)rks.GetValue(@"HFlyoutEnabled", 0);

                                     IsHFlyoutEnabled = (HFlyoutEnabled == 1);
                                     chkIsFlyout.IsChecked = IsHFlyoutEnabled;

                                     int InfoPaneEnabled = (int)rks.GetValue(@"InfoPaneEnabled", 0);

                                     IsInfoPaneEnabled = (InfoPaneEnabled == 1);
                                     btnInfoPane.IsChecked = IsInfoPaneEnabled;

                                     int PreviewPaneEnabled = (int)rks.GetValue(@"PreviewPaneEnabled", 0);

                                     IsPreviewPaneEnabled = (PreviewPaneEnabled == 1);
                                     btnPreviewPane.IsChecked = IsPreviewPaneEnabled;

                                     int NavigationPaneEnabled = (int)rks.GetValue(@"NavigationPaneEnabled", 1);

                                     IsNavigationPaneEnabled = (NavigationPaneEnabled == 1);
                                     btnNavigationPane.IsChecked = IsNavigationPaneEnabled;

                                     int CheckBoxesEnabled = (int)rks.GetValue(@"CheckModeEnabled", 0);

                                     isCheckModeEnabled = (CheckBoxesEnabled == 1);
                                     chkShowCheckBoxes.IsChecked = isCheckModeEnabled;

                                     int ExFileOpEnabled = (int)rks.GetValue(@"FileOpExEnabled", 0);

                                     IsExtendedFileOpEnabled = (ExFileOpEnabled == 1);
                                     Explorer.IsExFileOpEnabled = IsExtendedFileOpEnabled;
                                     chkIsTerraCopyEnabled.IsChecked = IsExtendedFileOpEnabled;

                                     int CompartibleRename = (int)rks.GetValue(@"CompartibleRename", 1);

                                     IsCompartibleRename = (CompartibleRename == 1);

                                     //chkIsCompartibleRename.IsChecked = IsCompartibleRename;

                                     int RestoreTabs = (int)rks.GetValue(@"IsRestoreTabs", 1);

                                     IsrestoreTabs = (RestoreTabs == 1);

                                     chkIsRestoreTabs.IsChecked = IsrestoreTabs;

                                     int LogActions = (int)rks.GetValue(@"EnableActionLog", 0);

                                     canlogactions = (LogActions == 1);
                                     chkLogHistory.IsChecked = canlogactions;

                                     // load settings for auto-switch to contextual tab
                                     asFolder = ((int)rks.GetValue(@"AutoSwitchFolderTools", 0) == 1);
                                     asArchive = ((int)rks.GetValue(@"AutoSwitchArchiveTools", 1) == 1);
                                     asImage = ((int)rks.GetValue(@"AutoSwitchImageTools", 1) == 1);
                                     asApplication = ((int)rks.GetValue(@"AutoSwitchApplicationTools", 0) == 1);
                                     asLibrary = ((int)rks.GetValue(@"AutoSwitchLibraryTools", 1) == 1);
                                     asDrive = ((int)rks.GetValue(@"AutoSwitchDriveTools", 0) == 1);

                                     chkFolder.IsChecked = asFolder;
                                     chkArchive.IsChecked = asArchive;
                                     chkImage.IsChecked = asImage;
                                     chkApp.IsChecked = asApplication;
                                     chkLibrary.IsChecked = asLibrary;
                                     chkDrive.IsChecked = asDrive;

                                     // load OverwriteOnImages setting (default is false)
                                     int oor = (int)rks.GetValue(@"OverwriteImageWhileEditing", 0);
                                     OverwriteOnRotate = (oor == 1);
                                     chkOverwriteImages.IsChecked = (oor == 1);

                                     // set up history on breadcrumb bar (currently missing try-catch statement in order to catch error)
                                     try
                                     {
                                         breadcrumbBarControl1.ClearHistory();
                                         breadcrumbBarControl1.HistoryItems = ReadHistoryFromFile(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\history.txt");
                                     }
                                     catch (FileNotFoundException)
                                     {
                                       logger.Warn(String.Format("History file not found at location:{0}\\history.txt", Environment.SpecialFolder.LocalApplicationData));
                                     }

                                     AddToLog("Session Began");

                                     StartUpLocation =
                                          rks.GetValue(@"StartUpLoc", KnownFolders.Libraries.ParsingName).ToString();

                                     if (StartUpLocation == "")
                                     {
                                         rks.SetValue(@"StartUpLoc", KnownFolders.Libraries.ParsingName);
                                         StartUpLocation = KnownFolders.Libraries.ParsingName;
                                     }
                                     char[] delimiters = new char[] { ';' };
                                     string LastOpenedTabs = rks.GetValue(@"OpenedTabs", "").ToString();
                                     string[] Tabs = LastOpenedTabs.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                                     rks.Close();
                                     rk.Close();

                                     try
                                     {
                                         RegistryKey rkbe = Registry.ClassesRoot;
                                         RegistryKey rksbe = rkbe.OpenSubKey(@"Folder\shell", RegistryKeyPermissionCheck.ReadSubTree);
                                         bool IsThereDefault = rksbe.GetValue("", "-1").ToString() != "";
                                         chkIsDefault.IsChecked = IsThereDefault;
                                         chkIsDefault.IsEnabled = true;
                                         rksbe.Close();
                                         rkbe.Close();
                                     }
                                     catch (Exception)
                                     {
                                         chkIsDefault.IsChecked = false;
                                         chkIsDefault.IsEnabled = false;
                                     }

                                     RegistryKey rkfe = Registry.CurrentUser;
                                     RegistryKey rksfe = rk.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", RegistryKeyPermissionCheck.ReadSubTree);
                                     chkTreeExpand.IsChecked = (int)rksfe.GetValue("NavPaneExpandToCurrentFolder", 0) == 1;
                                     rksfe.Close();
                                     rkfe.Close();

                                     isOnLoad = false;


                                     //'Rest of the setup of Explorer control. We have to set up that here after 
                                     //the initialization of registry settings
                                     Explorer.NavigationOptions.PaneVisibility.Preview =
                                         IsPreviewPaneEnabled ? PaneVisibilityState.Show : PaneVisibilityState.Hide;
                                     Explorer.NavigationOptions.PaneVisibility.Details =
                                         IsInfoPaneEnabled ? PaneVisibilityState.Show : PaneVisibilityState.Hide;

                                     Explorer.NavigationOptions.PaneVisibility.Navigation =
                                         IsNavigationPaneEnabled ? PaneVisibilityState.Show : PaneVisibilityState.Hide;



                                     Explorer.ContentOptions.CheckSelect = isCheckModeEnabled;

                                     if (StartUpLocation.IndexOf("::") == 0 && StartUpLocation.IndexOf(@"\") == -1)
                                     {
                                         btnSetCurrentasStartup.Header =
                                            ShellObject.FromParsingName("Shell:" + StartUpLocation).GetDisplayName(DisplayNameType.Default);
                                         btnSetCurrentasStartup.Icon = ShellObject.FromParsingName("Shell:" + StartUpLocation).Thumbnail.BitmapSource;
                                     }
                                     else
                                     {
                                         try
                                         {
                                             btnSetCurrentasStartup.Header =
                                                  ShellObject.FromParsingName(StartUpLocation).GetDisplayName(DisplayNameType.Default);

                                             btnSetCurrentasStartup.Icon = ShellObject.FromParsingName(StartUpLocation).Thumbnail.BitmapSource;
                                         }
                                         catch 
                                         {
                                             
                                            
                                         }
                                     }

                                     //'set StartUp location
                                     if (Application.Current.Properties["cmd"] != null)
                                     {

                                         String cmd = Application.Current.Properties["cmd"].ToString();

                                         if (cmd.IndexOf("::") == 0)
                                         {

                                             Explorer.Navigate(ShellObject.FromParsingName("shell:" + cmd));
                                         }
                                         else
                                             Explorer.Navigate(ShellObject.FromParsingName(cmd.Replace("\"", "")));

                                         
                                         CloseableTabItem cti = new CloseableTabItem();
                                         CreateTabbarRKMenu(cti);
                                         Explorer.NavigationLog.CurrentLocation.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
                                         cti.TabIcon = Explorer.NavigationLog.CurrentLocation.Thumbnail.BitmapSource;
                                         cti.Header = Explorer.NavigationLog.CurrentLocation.GetDisplayName(DisplayNameType.Default);
                                         cti.Path = Explorer.NavigationLog.CurrentLocation;
                                         cti.Index = 0;
                                         cti.log.CurrentLocation = Explorer.NavigationLog.CurrentLocation;
                                         cti.CloseTab += new RoutedEventHandler(cti_CloseTab);
                                         tabControl1.Items.Add(cti);
                                         //tabControl1.SelectedIndex = 0;
                                         //CurrentTabIndex = tabControl1.SelectedIndex;
                                     }
                                     else
                                     {
                                         if (Tabs.Length == 0 || !IsrestoreTabs)
                                         {
                                             if (StartUpLocation.IndexOf("::") == 0 && StartUpLocation.IndexOf(@"\") == -1)
                                                 Explorer.Navigate(ShellObject.FromParsingName("shell:" + StartUpLocation));
                                             else
                                                 try
                                                 {
                                                     Explorer.Navigate(ShellObject.FromParsingName(StartUpLocation));
                                                 }
                                                 catch
                                                 {
                                                     Explorer.Navigate((ShellObject)KnownFolders.Libraries);
                                                 }
                                         }
                                         if (IsrestoreTabs)
                                         {
                                             isOnLoad = true;
                                             int i = 0;
                                             foreach (string str in Tabs)
                                             {
                                                 try
                                                 {
                                                     i++;
                                                     if (i == Tabs.Length)
                                                     {
                                                         NewTab(str, true);
                                                     }
                                                     else
                                                     {
                                                         NewTab(str, false);
                                                     }
                                                     if (i == Tabs.Count())
                                                     {
                                                         if (str.IndexOf("::") == 0)
                                                         {

                                                             Explorer.Navigate(ShellObject.FromParsingName("shell:" + str));
                                                         }
                                                         else
                                                             Explorer.Navigate(ShellObject.FromParsingName(str.Replace("\"", "")));
                                                         (tabControl1.SelectedItem as CloseableTabItem).Path = Explorer.NavigationLog.CurrentLocation;
                                                     }
                                                 }
                                                 catch
                                                 {
                                                     //AddToLog(String.Format("Unable to load {0} into a tab!", str));
                                                     MessageBox.Show("BetterExplorer is unable to load one of the tabs from your last session. Your other tabs are perfectly okay though! \r\n\r\nThis location was unable to be loaded: " + str, "Unable to Create New Tab", MessageBoxButton.OK, MessageBoxImage.Error);
                                                     //NewTab();
                                                 }

                                             }
                                             if (tabControl1.Items.Count == 0) { 
                                                 NewTab();
                                                 if (StartUpLocation.IndexOf("::") == 0)
                                                 {

                                                     Explorer.Navigate(ShellObject.FromParsingName("shell:" + StartUpLocation));
                                                 }
                                                 else
                                                     Explorer.Navigate(ShellObject.FromParsingName(StartUpLocation.Replace("\"", "")));
                                                 (tabControl1.SelectedItem as CloseableTabItem).Path = Explorer.NavigationLog.CurrentLocation;
                                             };
                                             isOnLoad = false;

                                         }
                                     }

                                     //sets up Jump List
                                     AppJL.ShowRecentCategory = true;
                                     AppJL.ShowFrequentCategory = true;
                                     JumpList.SetJumpList(Application.Current, AppJL);
                                     JumpTask newTab = new JumpTask();
                                     newTab.ApplicationPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                                     newTab.Arguments = "t";
                                     newTab.Title = "Open Tab";
                                     newTab.Description = "Opens new tab with default location";

                                     JumpTask newWindow = new JumpTask();
                                     newWindow.ApplicationPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                                     newWindow.Arguments = "/nw";
                                     newWindow.Title = "New Window";
                                     newWindow.Description = "Creates a new window with default location";

                                     AppJL.JumpItems.Add(newTab);
                                     AppJL.JumpItems.Add(newWindow); 
                                     AppJL.Apply();


                                     //Setup Clipboard monitor
                                     cbm.ClipboardChanged += new EventHandler<ClipboardChangedEventArgs>(cbm_ClipboardChanged);

                                   #region unneeded code
                                   //if (Tabs.Length == 0 || !IsrestoreTabs)
                                   //{
                                   //    CloseableTabItem cti = new CloseableTabItem();
                                   //    CreateTabbarRKMenu(cti);
                                   //    Explorer.NavigationLog.CurrentLocation.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
                                   //    cti.TabIcon = Explorer.NavigationLog.CurrentLocation.Thumbnail.BitmapSource;
                                   //    cti.Header = Explorer.NavigationLog.CurrentLocation.GetDisplayName(DisplayNameType.Default);
                                   //    cti.Path = Explorer.NavigationLog.CurrentLocation;
                                   //    cti.Index = 0;
                                   //    cti.log.CurrentLocation = Explorer.NavigationLog.CurrentLocation;
                                   //    cti.CloseTab += new RoutedEventHandler(cti_CloseTab);
                                   //    tabControl1.Items.Add(cti);
                                   //    tabControl1.SelectedIndex = 0;
                                   //    CurrentTabIndex = tabControl1.SelectedIndex;
                                   //} 
                                   #endregion
                                     


                                 }
               ));

                if (exitApp)
                {

                    Application.Current.Shutdown();
                    return;
                }

                try
                {

                    Updater = UpdateManager.Instance;
                    Updater.UpdateFeedReader = new NAppUpdate.Framework.FeedReaders.NauXmlFeedReader();
                    Updater.UpdateExecutableName = "Web Update.exe";
                    Updater.UpdateSource = new NAppUpdate.Framework.Sources.SimpleWebSource("http://better-explorer.com/onlineupdate/update.xml");
                    //TODO: reeable updates when there is site ready
                    //CheckForUpdate(false);
                }
                catch (IOException)
                {
                    this.stiUpdate.Content = "Switch to another BetterExplorer window or restart to check for updates.";
                    this.btnUpdateCheck.IsEnabled = false;
                }

                verNumber.Content = "Version " + (System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false).FirstOrDefault() as AssemblyInformationalVersionAttribute).InformationalVersion;
                lblArchitecture.Content = Is64bitProcess(Process.GetCurrentProcess()) ? "64-bit version" : "32-bit version";
                if (!TheRibbon.IsMinimized)
                {
                    TheRibbon.SelectedTabItem = HomeTab;
                    this.TheRibbon.SelectedTabIndex = 0;
                }


                //MessageBox.Show(TheRibbon.SelectedTabIndex.ToString(), "SelectedTabIndex Should be 0", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception exe)
            {
                MessageBox.Show("An error occurred while loading the window. Please report this issue at http://bexplorer.codeplex.com/. \r\n\r\n Here is some information about the error: \r\n\r\n" + exe.Message + "\r\n\r\n" + exe.ToString(), "Error While Loading", MessageBoxButton.OK, MessageBoxImage.Error);
            }

        }
 public static void AddToRecentCategory(JumpTask jumpTask)
 {
 }
Exemplo n.º 27
0
        private static IShellLinkW CreateLinkFromJumpTask(JumpTask jumpTask, bool allowSeparators)
        {
            Debug.Assert(jumpTask != null);

            // Title is generally required.  If it's missing we need to treat this like a separator.
            // Everything else can still appear on separator elements,
            // but separators can only exist in the Tasks category.
            if (string.IsNullOrEmpty(jumpTask.Title))
            {
                if (!allowSeparators || !string.IsNullOrEmpty(jumpTask.CustomCategory))
                {
                    // Just treat this situation as an InvalidItem.
                    return(null);
                }
            }

            var link = (IShellLinkW)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(CLSID.ShellLink)));

            try
            {
                string appPath = _FullName;
                if (!string.IsNullOrEmpty(jumpTask.ApplicationPath))
                {
                    appPath = jumpTask.ApplicationPath;
                }

                link.SetPath(appPath);

                // This is optional.  Don't set it if the app hasn't explicitly requested it.
                if (!string.IsNullOrEmpty(jumpTask.WorkingDirectory))
                {
                    // Don't verify this.  It's possible that the directory doesn't exist now, but it will later.
                    // Shell handles this fine when we try to set an improperly formatted path.
                    link.SetWorkingDirectory(jumpTask.WorkingDirectory);
                }

                if (!string.IsNullOrEmpty(jumpTask.Arguments))
                {
                    link.SetArguments(jumpTask.Arguments);
                }

                // -1 is a sentinel value indicating not to use the icon.
                if (jumpTask.IconResourceIndex != -1)
                {
                    string resourcePath = _FullName;
                    if (!string.IsNullOrEmpty(jumpTask.IconResourcePath))
                    {
                        // Shell bug (Windows 7 595770): IShellLink doesn't correctly limit icon location path to MAX_PATH.
                        // It's really too bad we have to enforce this here.  When the shortcut gets
                        // serialized it streams the full string.  On deserialization it only retrieves
                        // MAX_PATH for this field leaving junk behind for subsequent gets, leading to data corruption.
                        // Because we don't want to allow the app to do create something that we know may
                        // be corrupt we have to enforce this ourselves.  If Shell fixes this later then
                        // we need to remove this check to let them handle this as they see fit.
                        // If they fix it by supporting longer paths, then we're artificially constraining this value...
                        if (jumpTask.IconResourcePath.Length >= Win32Constant.MAX_PATH)
                        {
                            // we could throw the exception here, but we're already globally catching everything.
                            return(null);
                        }
                        resourcePath = jumpTask.IconResourcePath;
                    }
                    link.SetIconLocation(resourcePath, jumpTask.IconResourceIndex);
                }

                if (!string.IsNullOrEmpty(jumpTask.Description))
                {
                    link.SetDescription(jumpTask.Description);
                }

                IPropertyStore propStore = (IPropertyStore)link;
                var            pv        = new PROPVARIANT();
                try
                {
                    PKEY pkey = default(PKEY);

                    if (!string.IsNullOrEmpty(jumpTask.Title))
                    {
                        pv.SetValue(jumpTask.Title);
                        pkey = PKEY.Title;
                    }
                    else
                    {
                        pv.SetValue(true);
                        pkey = PKEY.AppUserModel_IsDestListSeparator;
                    }

                    propStore.SetValue(ref pkey, pv);
                }
                finally
                {
                    Utilities.SafeDispose(ref pv);
                }

                propStore.Commit();

                IShellLinkW retLink = link;
                link = null;
                return(retLink);
            }
            catch (Exception)
            {
                // IShellLinkW::Set* methods tend to return E_FAIL when trying to set invalid data.
                // The create methods don't explicitly check for these kinds of errors.

                // If we aren't able to create the item for any reason just return null to indicate an invalid item.
                return(null);
            }
            finally
            {
                Utilities.SafeRelease(ref link);
            }
        }
Exemplo n.º 28
0
        private void updateJumpList()
        {
            JumpList myJumpList = JumpList.GetJumpList(Application.Current);

            if (myJumpList == null)
            {
                myJumpList = new JumpList();
                JumpList.SetJumpList(Application.Current, myJumpList);
            }

            myJumpList.JumpItems.Clear();
            if (RecentFileList != null && RecentFileList.RecentFiles != null)
            {
                foreach (string item in RecentFileList.RecentFiles)
                {
                    try
                    {
                        JumpTask myJumpTask = new JumpTask();
                        myJumpTask.CustomCategory = Resources.MainWindowVM_updateJumpList_CustomCategoryName;
                        myJumpTask.Title = Path.GetFileName(item);
                        //myJumpTask.Description = "";
                        myJumpTask.ApplicationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, System.AppDomain.CurrentDomain.FriendlyName);
                        myJumpTask.Arguments = item;
                        myJumpList.JumpItems.Add(myJumpTask);
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }
            }
            myJumpList.Apply();
        }
Exemplo n.º 29
0
 private async void FileOpenCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (!await IsConfigNotSavedAsync())
     {
         OpenFileDialog dlg = new OpenFileDialog();
         dlg.Filter = Program.ConfigFileFilter;
         if (dlg.ShowDialog() == true)
         {
             LoadConfig(dlg.FileName);
             JumpTask jumpTask = new JumpTask()
             {
                 Title = Path.GetFileNameWithoutExtension(dlg.FileName),
                 ApplicationPath = Assembly.GetAssembly(this.GetType()).Location,
                 Arguments = dlg.FileName
             };
             JumpList.AddToRecentCategory(jumpTask);
             RecentFileList.InsertFile(dlg.FileName);
         }
     }
 }
Exemplo n.º 30
0
        /// <summary>
        /// Invoked after a short delay when a track is switched to.
        /// </summary>
        /// <param name="e">The event data</param>
        private void MediaManager_TrackSwitchedDelayed(TrackSwitchedEventArgs e)
        {
            if (trackSwitchDelay != null)
                trackSwitchDelay.Stop();

            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
            {
                if (trayIcon != null) ((TrayToolTip)trayIcon.TrayToolTip).SetTrack(e.NewTrack);

                if (SettingsManager.ShowOSD)
                {
                    TrayNotification notification = new TrayNotification(e.NewTrack, this);
                    if (trayIcon != null)
                        trayIcon.ShowCustomBalloon(notification, System.Windows.Controls.Primitives.PopupAnimation.Fade, 4000);
                }

                JumpTask jumpTask = new JumpTask()
                {
                    Title = e.NewTrack.Artist + " - " + e.NewTrack.Title,
                    Arguments = e.NewTrack.Path,
                    Description = e.NewTrack.Artist + " - " + e.NewTrack.Title,
                    IconResourcePath = "C:\\Windows\\System32\\imageres.dll",
                    IconResourceIndex = 190,
                    ApplicationPath = Assembly.GetEntryAssembly().CodeBase,
                };

                System.Windows.Shell.JumpList.AddToRecentCategory(jumpTask);
            }));
        }
Exemplo n.º 31
0
 private JumpTask CreateProjectJumpItem(ProjectInfo pInfo)
 {
     JumpTask goToProject = new JumpTask();
     goToProject.CustomCategory = ScrumFactory.Windows.Properties.Resources.Recent_projects;
     goToProject.Title = pInfo.ProjectName + " - " + pInfo.ClientName + " [" + pInfo.ProjectNumber + "]";
     goToProject.Description = String.Format(ScrumFactory.Windows.Properties.Resources.Go_to_project_N, pInfo.ProjectNumber);
     goToProject.ApplicationPath = Assembly.GetEntryAssembly().Location;
     goToProject.IconResourcePath = goToProject.ApplicationPath;
     goToProject.Arguments = "projectNumber=" + pInfo.ProjectNumber;
     return goToProject;
 }
Exemplo n.º 32
0
        /// <summary>Edit the selected project or update.</summary>
        internal static void EditItem()
        {
            ResetPages();
            IsNewProject = false;

            if (File.Exists(Path.Combine(App.UserStore, Projects[AppIndex].ApplicationName + ".sua")))
            {
                AppInfo =
                    Utilities.Deserialize<Sua>(Path.Combine(App.UserStore, Projects[AppIndex].ApplicationName + ".sua"));
            }
            else
            {
                AppInfo = null;
                UpdateInfo = null;
                ShowMessage(
                    string.Format(
                        CultureInfo.CurrentUICulture,
                        Resources.FileLoadError,
                        Path.Combine(App.UserStore, Projects[AppIndex].ApplicationName + ".sua")),
                    TaskDialogStandardIcon.Error);
                return;
            }

            if (UpdateIndex < 0)
            {
                MainWindow.NavService.Navigate(AppInfoPage);
                return;
            }

            if (File.Exists(Path.Combine(App.UserStore, Projects[AppIndex].ApplicationName + @".sui")))
            {
                UpdateInfo =
                    Utilities.Deserialize<Collection<Update>>(
                        Path.Combine(App.UserStore, Projects[AppIndex].ApplicationName + ".sui"))[UpdateIndex];
            }
            else
            {
                AppInfo = null;
                UpdateInfo = null;
                ShowMessage(
                    string.Format(
                        CultureInfo.CurrentUICulture,
                        Resources.FileLoadError,
                        Path.Combine(App.UserStore, Projects[AppIndex].ApplicationName + ".sui")),
                    TaskDialogStandardIcon.Error);
                return;
            }

            var jumpTask = new JumpTask
                {
                    IconResourcePath =
                        Path.Combine(Directory.GetParent(Utilities.AppDir).FullName, "Shared", @"SevenUpdate.Base.dll"),
                    IconResourceIndex = 8,
                    Title = Utilities.GetLocaleString(UpdateInfo.Name),
                    Arguments = @"-edit " + AppIndex + " " + UpdateIndex
                };

            JumpList.AddToRecentCategory(jumpTask);

            MainWindow.NavService.Navigate(UpdateInfoPage);
        }
Exemplo n.º 33
0
 public static void RebuildJumpList()
 {
     JumpList myJumpList = new JumpList();
     foreach (string project in Options.General.RecentProjects)
     {
         JumpTask task = new JumpTask();
         task.ApplicationPath = Application.ExecutablePath;
         task.Arguments = "-open \"" + project + "\"";
         task.Title = project;
         task.CustomCategory = "Recent Projects";
         task.IconResourcePath = Path.Combine(Application.StartupPath, "icon.ico");
         task.WorkingDirectory = Application.StartupPath;
         myJumpList.JumpItems.Add(task);
     }
     System.Windows.Application app = System.Windows.Application.Current ?? new System.Windows.Application();
     JumpList.SetJumpList(app, myJumpList);
 }
Exemplo n.º 34
0
 public JumpTask asJumpTask()
 {
     var task = new JumpTask();
     task.Title = Name;
     task.Description = "Play station " + Name;
     task.ApplicationPath = Assembly.GetEntryAssembly().Location;
     task.Arguments = "--station=" + ID;
     return task;
 }
Exemplo n.º 35
0
        /// <summary>
        /// 添加到跳转列表
        /// </summary>
        /// <param name="title"></param>
        /// <param name="arguments"></param>
        private void AddKeyToJumpList(JumpListEventArgs args)
        {
            JumpList jumpList = JumpList.GetJumpList(App.Current);

            if (jumpList == null) jumpList = new JumpList();
            //jumpList.ShowRecentCategory = false;
            //jumpList.ShowFrequentCategory = true;
            foreach (JumpTask jumpItem in jumpList.JumpItems)
            {
                if (jumpItem.Title == args.Title) return;
            }
            JumpTask jumpTask = new JumpTask();
            jumpTask.Title = args.Title;
            jumpTask.Description = jumpTask.Title;
            jumpTask.Arguments = args.Arguments;
            jumpTask.CustomCategory = args.Category;
            jumpTask.WorkingDirectory = Directory.GetCurrentDirectory();
            jumpTask.ApplicationPath = Assembly.GetExecutingAssembly().Location;
            jumpList.JumpItems.Insert(0, jumpTask);
            if (jumpList.JumpItems.Count > 20)
            {
                jumpList.JumpItems.RemoveAt(20);
            }
            //jumpList.JumpItems.RemoveRange(10, 10);
            JumpList.AddToRecentCategory(jumpTask);

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                JumpList.SetJumpList(App.Current, jumpList);
            }));
        }
        private void UpdateJumpList()
        {
            var jumpList = JumpList.GetJumpList(Application.Current) ?? new JumpList();
            jumpList.ShowRecentCategory = true;

            // Remove JumpTasks for folders,which are not in the MRU list anymore
            //jumpList.JumpItems.RemoveAll(item => item is JumpTask && !_folders.Any(path => String.Equals(path, ((JumpTask)item).Title, StringComparison.OrdinalIgnoreCase)));

            // add JumpTasks for folders, which do not exist already
            foreach (var folder in _folders.Where(f => !jumpList.JumpItems.OfType<JumpTask>().Any(item => String.Equals(f, item.Title, StringComparison.OrdinalIgnoreCase)))) {
                var jumpTask = new JumpTask {
                    ApplicationPath = Assembly.GetExecutingAssembly().Location,
                    Arguments = folder,
                    IconResourcePath = @"C:\Windows\System32\shell32.dll",
                    IconResourceIndex = 3,
                    Title = folder,
                    CustomCategory = "Recent folders"
                };
                JumpList.AddToRecentCategory(jumpTask);
            }

            jumpList.Apply();
        }
Exemplo n.º 37
0
        void Explorer_NavigationPending(object sender, NavigationPendingEventArgs e)
        {

            if (fsw_AC != null)
                fsw_AC.Dispose();

            e.Cancel = IsCancel;
            if (IsAfterRename)
                breadcrumbBarControl1.ExitEditMode();

            try
            {
            
                this.Title = "Better Explorer - " + e.PendingLocation.GetDisplayName(DisplayNameType.Default);



                Dispatcher.BeginInvoke(DispatcherPriority.Render, (ThreadStart)(() =>
                                    {
                                        ConstructMoveToCopyToMenu();
                                        if (e.PendingLocation.IsFileSystemObject || e.PendingLocation.IsNetDrive || e.PendingLocation.ParsingName.StartsWith(@"\\"))
                                        {

                                            try
                                            {
                                                fsw_AC = new FileSystemWatcher(e.PendingLocation.ParsingName);
                                                fsw_AC.EnableRaisingEvents = true;
                                                fsw_AC.Created += new FileSystemEventHandler(fsw_AC_Created);
                                                fsw_AC.Deleted += new FileSystemEventHandler(fsw_AC_Deleted);
                                            }
                                            catch
                                            {

                                            }
                                        }

                                        if (e.PendingLocation.IsFileSystemObject)
	                                    {
		                                    btnSizeChart.IsEnabled = true;
	                                    }
                                        else
	                                    {
                                            btnSizeChart.IsEnabled = false;
	                                    }

                                        this.breadcrumbBarControl1.LoadDirectory(e.PendingLocation);
                                        this.breadcrumbBarControl1.LastPath = e.PendingLocation.ParsingName;
                                        IntPtr pIDL = IntPtr.Zero;

                                        try
                                        {
                                            uint iAttribute;
                                            SHParseDisplayName(e.PendingLocation.ParsingName,
                                                IntPtr.Zero, out pIDL, (uint)0, out iAttribute);

                                            WindowsAPI.SHFILEINFO sfi = new WindowsAPI.SHFILEINFO();
                                            IntPtr Res = IntPtr.Zero;
                                            if (pIDL != IntPtr.Zero)
                                            {
                                                if (!e.PendingLocation.IsFileSystemObject)
                                                {
                                                    Res = WindowsAPI.SHGetFileInfo(pIDL, 0, ref sfi, (uint)Marshal.SizeOf(sfi), WindowsAPI.SHGFI.IconLocation | WindowsAPI.SHGFI.SmallIcon | WindowsAPI.SHGFI.PIDL);
                                                }

                                            }

                                            if (e.PendingLocation.IsFileSystemObject)
                                            {
                                                WindowsAPI.SHGetFileInfo(e.PendingLocation.ParsingName, 0, ref sfi, (uint)Marshal.SizeOf(sfi), (uint)WindowsAPI.SHGFI.IconLocation | (uint)WindowsAPI.SHGFI.SmallIcon);

                                            }
                                            JumpTask JTask = new JumpTask();
                                            JTask.ApplicationPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                                            JTask.Arguments = "\"" + e.PendingLocation.ParsingName + "\"";
                                            JTask.Title = e.PendingLocation.GetDisplayName(DisplayNameType.Default);
                                            JTask.IconResourcePath = sfi.szDisplayName;
                                            JTask.IconResourceIndex = sfi.iIcon;
                                            JumpList.AddToRecentCategory(JTask);
                                            AppJL.Apply();

                                        }
                                        finally
                                        {

                                            if (pIDL != IntPtr.Zero)
                                                Marshal.FreeCoTaskMem(pIDL);
                                        }

                                        try
                                        {

                                            //CloseableTabItem it = new CloseableTabItem();
                                            //CreateTabbarRKMenu(it);
                                            e.PendingLocation.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
                                            e.PendingLocation.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
                                            (tabControl1.SelectedItem as CloseableTabItem).Header = e.PendingLocation.GetDisplayName(DisplayNameType.Default);
                                            (tabControl1.SelectedItem as CloseableTabItem).TabIcon = e.PendingLocation.Thumbnail.BitmapSource;
                                            (tabControl1.SelectedItem as CloseableTabItem).Path = e.PendingLocation;
                                            if (!isGoingBackOrForward)
                                            {
                                                (tabControl1.SelectedItem as CloseableTabItem).log.CurrentLocation = e.PendingLocation;
                                            }

                                            isGoingBackOrForward = false;

                                            leftNavBut.IsEnabled = (tabControl1.SelectedItem as CloseableTabItem).log.CanNavigateBackwards;
                                            rightNavBut.IsEnabled = (tabControl1.SelectedItem as CloseableTabItem).log.CanNavigateForwards;

                                            //(tabControl1.Items[CurrentTabIndex] as CloseableTabItem).DragEnter += new DragEventHandler(newt_DragEnter);
                                            //(tabControl1.Items[CurrentTabIndex] as CloseableTabItem).DragLeave += new DragEventHandler(newt_DragLeave);
                                            //(tabControl1.Items[CurrentTabIndex] as CloseableTabItem).DragOver += new DragEventHandler(newt_DragOver);
                                            //(tabControl1.Items[CurrentTabIndex] as CloseableTabItem).Drop += new DragEventHandler(newt_Drop);
                                            //(tabControl1.Items[CurrentTabIndex] as CloseableTabItem).AllowDrop = true;
                                            //(tabControl1.Items[CurrentTabIndex] as CloseableTabItem).Index = CurrentTabIndex;
                                            //(tabControl1.Items[CurrentTabIndex] as CloseableTabItem).CloseTab += new RoutedEventHandler(cti_CloseTab);
                                            //tabControl1.Items[CurrentTabIndex] = it;
                                            //tabControl1.SelectedIndex = CurrentTabIndex;


                                        }
                                        catch (Exception)
                                        {

                                        }
                                        bool isinLibraries = false;
                                        if (e.PendingLocation.Parent != null)
                                        {
                                            if (e.PendingLocation.Parent.ParsingName ==
                                                  KnownFolders.Libraries.ParsingName)
                                            {
                                                isinLibraries = true;
                                            }
                                            else
                                            {
                                                isinLibraries = false;
                                            }
                                        }

                                        btnCreateFolder.IsEnabled = e.PendingLocation.IsFileSystemObject ||
                                            (e.PendingLocation.ParsingName == KnownFolders.Libraries.ParsingName) ||
                                            (isinLibraries);

                                        if (e.PendingLocation.ParsingName == KnownFolders.Libraries.ParsingName)
                                        {
                                            btnCreateFolder.Header = FindResource("btnNewLibraryCP");  //"New Library";
                                            stNewFolder.Title = FindResource("btnNewLibraryCP").ToString();//"New Library";
                                            stNewFolder.Text = "Creates a new library in the current folder.";
                                            stNewFolder.Image = new BitmapImage(new Uri(@"/BetterExplorer;component/Images/newlib32.png", UriKind.Relative));
                                            btnCreateFolder.LargeIcon = @"..\Images\newlib32.png";
                                            btnCreateFolder.Icon = @"..\Images\newlib16.png";
                                        }
                                        else
                                        {
                                            btnCreateFolder.Header = FindResource("btnNewFolderCP");//"New Folder";
                                            stNewFolder.Title = FindResource("btnNewFolderCP").ToString(); //"New Folder";
                                            stNewFolder.Text = "Creates a new folder in the current folder";
                                            stNewFolder.Image = new BitmapImage(new Uri(@"/BetterExplorer;component/Images/folder_new32.png", UriKind.Relative));
                                            btnCreateFolder.LargeIcon = @"..\Images\folder_new32.png";
                                            btnCreateFolder.Icon = @"..\Images\folder_new16.png";
                                        }
                                        if (e.PendingLocation.IsFolder && !e.PendingLocation.IsDrive &&
                                            !e.PendingLocation.IsSearchFolder)
                                        {
                                            //ctgFolderTools.Visibility = Visibility.Visible;
                                        }

                                        if (e.PendingLocation.ParsingName.Contains(KnownFolders.Libraries.ParsingName) &&
                                            e.PendingLocation.ParsingName != KnownFolders.Libraries.ParsingName)
                                        {
                                            ctgLibraries.Visibility = System.Windows.Visibility.Visible;
                                            ctgFolderTools.Visibility = System.Windows.Visibility.Collapsed;
                                            ctgImage.Visibility = System.Windows.Visibility.Collapsed;
                                            ctgArchive.Visibility = System.Windows.Visibility.Collapsed;
                                            ctgExe.Visibility = System.Windows.Visibility.Collapsed;
                                            inLibrary = true;

                                            try
                                            {
                                                ShellLibrary lib =
                                                    ShellLibrary.Load(e.PendingLocation.GetDisplayName(DisplayNameType.Default), false);
                                                IsFromSelectionOrNavigation = true;
                                                chkPinNav.IsChecked = lib.IsPinnedToNavigationPane;
                                                IsFromSelectionOrNavigation = false;
                                                foreach (ShellObject item in lib)
                                                {
                                                    MenuItem miItem = new MenuItem();
                                                    miItem.Header = item.GetDisplayName(DisplayNameType.Default);
                                                    miItem.Tag = item;
                                                    item.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
                                                    item.Thumbnail.CurrentSize = new System.Windows.Size(16, 16);
                                                    miItem.Icon = item.Thumbnail.BitmapSource;
                                                    miItem.GroupName = "GRDS1";
                                                    miItem.IsCheckable = true;
                                                    miItem.IsChecked = (item.ParsingName == lib.DefaultSaveFolder);
                                                    miItem.Click += new RoutedEventHandler(miItem_Click);
                                                    btnDefSave.Items.Add(miItem);
                                                }

                                                btnDefSave.IsEnabled = !(lib.Count == 0);
                                                lib.Close();
                                            }
                                            catch
                                            {

                                            }
                                        }
                                        else
                                        {
                                            if (!e.PendingLocation.ParsingName.ToLowerInvariant().EndsWith("library-ms"))
                                            {
                                                btnDefSave.Items.Clear();
                                                ctgLibraries.Visibility = System.Windows.Visibility.Collapsed;
                                                inLibrary = false;
                                            }
                                            //MessageBox.Show("Not in Library");
                                        }
                                        if (e.PendingLocation.IsDrive)
                                        {
                                            ctgDrive.Visibility = System.Windows.Visibility.Visible;
                                            inDrive = true;
                                            //MessageBox.Show("In Drive");
                                        }
                                        else
                                        {
                                            ctgDrive.Visibility = System.Windows.Visibility.Collapsed;
                                            inDrive = false;
                                            //MessageBox.Show("Not In Drive");
                                        }
                                        if (isinLibraries)
                                        {
                                            ctgFolderTools.Visibility = Visibility.Collapsed;
                                        }

                                    }
                                ));

                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
            catch (Exception exe)
            {
                ShellObject ne = e.PendingLocation;
                bool isinLibraries = false;
                bool itisLibraries = false;

                if (ne.Parent.ParsingName == KnownFolders.Libraries.ParsingName)
                {
                    isinLibraries = true;
                }
                else
                {
                    isinLibraries = false;
                }

                if (ne.ParsingName == KnownFolders.Libraries.ParsingName)
                {
                    itisLibraries = true;
                }
                else
                {
                    itisLibraries = false;
                }

                //if (MessageBox.Show("An error occurred while loading a folder. Please report this issue at http://bexplorer.codeplex.com/. \r\n\r\nHere is some information about the folder being loaded:\r\n\r\nName: " + ne.GetDisplayName(DisplayNameType.Default) + "\r\nLocation: " + ne.ParsingName +
                //    "\r\n\r\nFolder, Drive, or Library: " + GetYesNoFromBoolean(ne.IsFolder) + "\r\nDrive: " + GetYesNoFromBoolean(ne.IsDrive) + "\r\nNetwork Drive: " + GetYesNoFromBoolean(ne.IsNetDrive) + "\r\nRemovable: " + GetYesNoFromBoolean(ne.IsRemovable) +
                //    "\r\nSearch Folder: " + GetYesNoFromBoolean(ne.IsSearchFolder) + "\r\nShared: " + GetYesNoFromBoolean(ne.IsShared) + "\r\nShortcut: " + GetYesNoFromBoolean(ne.IsLink) + "\r\nLibrary: " + GetYesNoFromBoolean(isinLibraries) + "\r\nLibraries Folder: " + GetYesNoFromBoolean(itisLibraries) +
                //    "\r\n\r\n Would you like to see additional information? Click No to try continuing the program.", "Error Occurred on Completing Navigation", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes)
                //{
                //    MessageBox.Show("An error occurred while loading a folder. Please report this issue at http://bexplorer.codeplex.com/. \r\n\r\nHere is additional information about the error: \r\n\r\n" + exe.Message + "\r\n\r\n" + exe.ToString(), "Additional Error Data", MessageBoxButton.OK, MessageBoxImage.Error);
                //}
            }

            Explorer.ExplorerSetFocus();

            //if (Itmpop.Visibility == System.Windows.Visibility.Visible)
            //{
            //    Itmpop.Visibility = System.Windows.Visibility.Hidden;
            //}
        }
Exemplo n.º 38
0
		/// <summary>
		/// Updates the portion of the JumpList which shows new/unread email.
		/// </summary>
		internal void UpdateJumpList() {

			UpdateTrayList();

			if(!_config.RecentDocsTracked) { // if the user doesn't have recent docs turned on, this will method throw errors.
				return;
			}

			_jumpList.RemoveCustomCategories();

			String iconPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Resources\\Icons\\Mail.ico");
			String inboxFormat = "{0} ({1})";

			foreach(Notifier notifier in _instances.Values) {

				Account account = notifier.Account;
				String category = String.Format(inboxFormat, account.FullAddress, notifier.Unread);

				foreach(Email email in notifier.Emails) {

					JumpTask task = new JumpTask() {
						ApplicationPath = account.Browser != null ? account.Browser.Path : email.Url,
						Arguments = email.Url,
						IconResourceIndex = 0,
						IconResourcePath = iconPath,
						Title = email.Title,
						CustomCategory = category
					};

					_jumpList.JumpItems.Add(task);
				}

			}

			_jumpList.Apply(); // refreshes

		}