コード例 #1
0
        /// <summary>
        /// Pins the jump lists.
        /// </summary>
        private void PinJumpLists()
        {
            // this is init section
            JumpList jumpList1 = JumpList.GetJumpList(App.Current);

            jumpList1.JumpItems.Clear();

            // get the config section from app.config file
            var csvConfigSection = ConfigurationManager.GetSection(StringSplitConfigDataSection.SectionName) as StringSplitConfigDataSection;

            if (csvConfigSection != null && csvConfigSection.CsvConfigCollection.Count > 0)
            {
                foreach (var item in csvConfigSection.CsvConfigCollection)
                {
                    CSVConfigItem configItem = item as CSVConfigItem;
                    string        name       = configItem.Name;

                    string fieldArgument = this.GetConcatenatedString(configItem);
                    this.AddJumpListTask(configItem.Name, string.Empty, fieldArgument);
                }
            }

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

            jumpList2.Apply();
        }
コード例 #2
0
ファイル: mainwindow.xaml.cs プロジェクト: zhimaqiao51/docs
        // </snippet240>
        // <snippet230>
        private void ClearJumpList(object sender, RoutedEventArgs e)
        {
            JumpList jumpList1 = JumpList.GetJumpList(App.Current);

            jumpList1.JumpItems.Clear();
            jumpList1.Apply();
        }
コード例 #3
0
        public static void Update(IEnumerable <Data.LiftItem> entries)
        {
            // save to task bar
            var  thisJumpList = JumpList.GetJumpList(System.Windows.Application.Current);
            bool newJumpList  = false;

            if (thisJumpList == null)
            {
                newJumpList  = true;
                thisJumpList = new JumpList();
            }

            thisJumpList.ShowFrequentCategory = false;
            thisJumpList.ShowRecentCategory   = false;
            thisJumpList.JumpItems.Clear();

            foreach (var entry in entries)
            {
                var task = CreateJumpTaskItem(entry);
                thisJumpList.JumpItems.Add(task);
            }

            thisJumpList.Apply();
            if (newJumpList)
            {
                JumpList.SetJumpList(System.Windows.Application.Current, thisJumpList);
            }
        }
コード例 #4
0
        private static JumpList GetJumpList()
        {
            // check for Windows7
            var os = Environment.OSVersion.Version;

            if (os.Major < 6)
            {
                return(null);
            }
            if (os.Minor < 1)
            {
                return(null);
            }

            var list = JumpList.GetJumpList(Application.Current);

            if (list != null)
            {
                return(list);
            }

            list = new JumpList {
                ShowFrequentCategory = false, ShowRecentCategory = false
            };

            JumpList.SetJumpList(Application.Current, list);
            return(list);
        }
コード例 #5
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();
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        private static void UpdateJumpList()
        {
            var jumpList = JumpList.GetJumpList(Application.Current);

            if (jumpList == null)
            {
                return;
            }
            jumpList.JumpItems.Clear();
            if (SavedLogs != null)
            {
                var applicationPath = Environment.GetCommandLineArgs()[0];
                foreach (var log in SavedLogs.Select(log => log.FileName))
                {
                    jumpList.JumpItems.Add(new JumpTask
                    {
                        Title           = log,
                        ApplicationPath = applicationPath,
                        Arguments       = '"' + log + '"',
                        CustomCategory  = Resources.SavedLogsTitle,
                    });
                }
            }
            jumpList.Apply();
        }
コード例 #8
0
        public static void Initialize()
        {
            var devenv = Process.GetCurrentProcess().MainModule.FileName;

            var presentationMode = new JumpTask
            {
                ApplicationPath  = devenv,
                IconResourcePath = devenv,
                Title            = "Presentation Mode",
                Description      = "Starts a separate Visual Studio instance with its own settings, layout, extensions, and more...",
                Arguments        = "/RootSuffix Demo"
            };

            var safeMode = new JumpTask
            {
                ApplicationPath  = devenv,
                IconResourcePath = devenv,
                Title            = "Safe Mode",
                Description      = "Starts Visual Studio in limited functionality mode where all extensions are disabled.",
                Arguments        = "/safemode"
            };

            JumpList list = JumpList.GetJumpList(Application.Current) ?? new JumpList();

            list.JumpItems.Add(presentationMode);
            list.JumpItems.Add(safeMode);
            list.Apply();
        }
コード例 #9
0
        internal void SwitchToMainMode()
        {
            Dispatcher.VerifyAccess();

            ExitSlideShow();

            if (_viewMode == _WindowMode.Normal)
            {
                return;
            }
            _viewMode = _WindowMode.Normal;

            _minimodeWindow.Hide();
            _mainWindow.Show();

            if (_mainWindow.WindowState == WindowState.Minimized)
            {
                _mainWindow.WindowState = WindowState.Normal;
            }

            _mainWindow.Activate();

            var      mainJumpList    = (JumpList)Resources["MainModeJumpList"];
            JumpList currentJumpList = JumpList.GetJumpList(this);

            // Remove and replace all tasks.
            currentJumpList.JumpItems.RemoveAll(item => item.CustomCategory == null);
            currentJumpList.JumpItems.AddRange(mainJumpList.JumpItems);

            currentJumpList.Apply();
        }
コード例 #10
0
 private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
 {
     if (JumpList.GetJumpList(Application.Current) != null)
     {
         CurrentJumpList = JumpList.GetJumpList(Application.Current);
     }
 }
コード例 #11
0
        private void _OnNotificationsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (ServiceProvider.ViewManager == null || ServiceProvider.ViewManager.Notifications == null)
            {
                return;
            }

            _currentNotifications.Clear();
            var notificationTaskList = new List <JumpItem>();

            foreach (Notification notification in from n in ServiceProvider.ViewManager.Notifications orderby n.Created ascending select n)
            {
                _currentNotifications.Add(notification);

                string argument = null;

                // Get the default URL from the notification.
                var htc = new HyperlinkTextContent {
                    Text = notification.Title
                };
                Uri notifyUri = htc.DefaultUri;
                if (notifyUri != null)
                {
                    argument = "-uri:" + notifyUri.OriginalString;
                }

                string title = _GetFirstLine(notification.TitleText);

                if (title != null)
                {
                    notificationTaskList.Add(new JumpTask
                    {
                        Arguments      = argument,
                        CustomCategory = notification is FriendRequestNotification ? "Friend Requests" : "Notifications",
                        // Shell silently fails to accept multi-line JumpTasks so we need to trim the strings ourselves.
                        Description = _GetFirstLine(notification.DescriptionText),
                        Title       = title,
                    });
                }
            }

            JumpList jumpList = JumpList.GetJumpList(Application.Current);

            Assert.IsNotNull(jumpList);
            jumpList.JumpItems.RemoveAll(item => item.CustomCategory == "Notifications");
            jumpList.JumpItems.RemoveAll(item => item.CustomCategory == "Friend Requests");
            jumpList.JumpItems.AddRange(notificationTaskList);

            try
            {
                jumpList.JumpItemsRemovedByUser += _OnJumpItemsRemovedByUser;
                jumpList.Apply();
            }
            finally
            {
                jumpList.JumpItemsRemovedByUser -= _OnJumpItemsRemovedByUser;
            }
        }
コード例 #12
0
        public static void ClearJumpList()
        {
            var jumpList = JumpList.GetJumpList(System.Windows.Application.Current);

            if (jumpList != null)
            {
                jumpList.JumpItems.Clear();
                jumpList.Apply();
            }
        }
コード例 #13
0
        private void JumpList_Clear(object sender, RoutedEventArgs e)
        {
            var jl = JumpList.GetJumpList(Application.Current);

            jl.JumpItems.Clear();
            if (!DeferApply)
            {
                jl.Apply();
            }
        }
コード例 #14
0
        private void RemoveButton_OnClick(object sender, RoutedEventArgs e)
        {
            var selectedItemIndexes =
                (from object o in TaskList.SelectedItems select TaskList.Items.IndexOf(o)).ToList();


            foreach (var item in selectedItemIndexes)
            {
                JumpList.GetJumpList(Application.Current).JumpItems.RemoveAt(item);
            }
        }
コード例 #15
0
ファイル: GitApp.xaml.cs プロジェクト: akrisiun/FolderGit
        void App_Startup(object sender, StartupEventArgs e)
        {
            JumpList jumpList1 = JumpList.GetJumpList(GitApp.Current);

            var window = new FolderWindowGit();   // NoBorder

            Folder.CsApp.FolderWindow = window;

            window.AllowsTransparency = false;
            window.Show();
        }
コード例 #16
0
        public void ApplyUpdates()
        {
            JumpList jumpList = JumpList.GetJumpList(this.currentApp);

            if (jumpList == null)
            {
                return;
            }

            jumpList.Apply();
        }
コード例 #17
0
        private void JumpPath_AddToCategory(object sender, RoutedEventArgs e)
        {
            JumpPath jp = GenerateJumpPath();
            var      jl = JumpList.GetJumpList(Application.Current);

            jl.JumpItems.Add(jp);
            if (!DeferApply)
            {
                jl.Apply();
            }
        }
コード例 #18
0
        public void ClearJumpList()
        {
            JumpList jumpList = JumpList.GetJumpList(this.currentApp);

            if (jumpList == null)
            {
                return;
            }

            jumpList.JumpItems.Clear();
            jumpList.Apply();
        }
コード例 #19
0
ファイル: App.xaml.cs プロジェクト: weishig/Project-19004
        private void ApplicationStartup(object sender, StartupEventArgs e)
        {
            DoHandleUnexpectedExceptions = true;
            try
            {
                //#if DEBUG
                //#else
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
                //#endif

                FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

                CommonUserSettings.InitializeCommonSettings(ELLO.Properties.Settings.Default);
                // setup the JumpList features before testing for single application as otherwise the JumpList can be reset
                JumpList jumpList = JumpList.GetJumpList(Current);

                JumpTask jt = new JumpTask
                {
                    Title            = "Edit application settings",
                    ApplicationPath  = SettingPath(ApplicationName + ".Config", App.ApplicationName),
                    IconResourcePath = @"c:\windows\notepad.exe",
                    Description      = "Edit the application configuration file to customise settings",
                    CustomCategory   = "Customise"
                };
                jumpList.JumpItems.Add(jt);

                jt = new JumpTask
                {
                    Arguments        = LogPath(ApplicationName + ".Log"),
                    Title            = "Open MotionControlManager log",
                    ApplicationPath  = @"c:\windows\notepad.exe",
                    IconResourcePath = @"c:\windows\notepad.exe",
                    Description      = "Open the diagnostics log",
                    CustomCategory   = "Logging"
                };
                jumpList.JumpItems.Add(jt);

                jumpList.Apply();

                // Create the View Model for the Main Window
                _mainWindowViewModel = new MainWindowViewModel(e.Args);

                // Set it as the DataContext for Binding and Commanding
                _mainWindow = new MainWindow(_mainWindowViewModel);

                _mainWindow.Show();
                Thread.Sleep(500);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Caught exception: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #20
0
        public static void ClearJumplist()
        {
            if (!Win7.IsWin7)
            {
                return;
            }

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

            jumpList.JumpItems.Clear();
            jumpList.Apply();
        }
コード例 #21
0
        private void UpdateKnownCategories(object sender, RoutedEventArgs e)
        {
            bool showRecent   = _showRecentButton.IsChecked ?? false;
            bool showFrequent = _showFrequentButton.IsChecked ?? false;
            var  jl           = JumpList.GetJumpList(Application.Current);

            jl.ShowRecentCategory   = showRecent;
            jl.ShowFrequentCategory = showFrequent;

            if (!DeferApply)
            {
                jl.Apply();
            }
        }
コード例 #22
0
 private void RemoveAllTask(object sender, RoutedEventArgs e)
 {
     if (CurrentJumpList.JumpItems.Count > 0 && CurrentJumpList != null)
     {
         var jumpList = JumpList.GetJumpList(Application.Current);
         jumpList?.JumpItems.Clear();
         jumpList?.Apply();
         CurrentJumpList.JumpItems.Clear();
         FooterTextBlock.Text = "All tasks have been cleared.";
     }
     else
     {
         FooterTextBlock.Text = "Looks like there's nothing in the JumpList.";
     }
 }
コード例 #23
0
        public MainWindow()
        {
            this.InitializeComponent();

            var jumpList = JumpList.GetJumpList(Application.Current);

            jumpList.JumpItemsRejected      += JumpList_JumpItemsRejected;
            jumpList.JumpItemsRemovedByUser += JumpList_JumpItemsRemovedByUser;
            jumpList.Apply();

            if (App.StartupPackage != null)
            {
                this.OpenFile(App.StartupPackage);
            }
        }
コード例 #24
0
        void App_Startup(object sender, StartupEventArgs e)
        {
            JumpList jumpList1 = JumpList.GetJumpList(CsApp.Current);

            MainWindow window = new MainWindow();   // NoBorder

            window.AllowsTransparency = false;
            window.Load(null);
            window.Show();

            if (FoxCmd.Attach())
            {
                FoxCmd.AssignForm(window);
            }
        }
コード例 #25
0
        private void InitializeJumpList()
        {
            if (App.RunningOnWin7)
            {
                JumpList jl = JumpList.GetJumpList(nRoute.ApplicationServices.Application.Current);

                if (jl == null)
                {
                    jl = new JumpList();
                    JumpList.SetJumpList(nRoute.ApplicationServices.Application.Current, jl);
                }

                jl.Apply();
            }
        }
コード例 #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="applicationContext"></param>
        /// <param name="logger"></param>
        /// <param name="assembly"></param>
        /// <param name="jumpItemsFunc"></param>
        /// <param name="jumpItemsRemovedByUserSubscription"></param>
        /// <param name="jumpItemsRejectedSubscription"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static JumpListHelper GetInstance(
            Application applicationContext,
            ILogger <JumpListHelper> logger,
            Assembly assembly,
            Func <string, IEnumerable <JumpItem> > jumpItemsFunc,
            Action <EventPattern <JumpItemsRemovedEventArgs> > jumpItemsRemovedByUserSubscription,
            Action <EventPattern <JumpItemsRejectedEventArgs> > jumpItemsRejectedSubscription)
        {
            if (applicationContext == null)
            {
                throw new ArgumentNullException(nameof(applicationContext));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            if (jumpItemsFunc == null)
            {
                throw new ArgumentNullException(nameof(jumpItemsFunc));
            }

            var cmdPath   = assembly.Location;
            var jumpItems = jumpItemsFunc(cmdPath);

            var jumpList = JumpList.GetJumpList(applicationContext);

            if (jumpList == null)
            {
#pragma warning disable CA1848 // Use the LoggerMessage delegates
                logger.LogInformation("No jump list registered. Creating a new one");
#pragma warning restore CA1848 // Use the LoggerMessage delegates
                jumpList = new JumpList(jumpItems, true, true);

                JumpList.SetJumpList(applicationContext, jumpList);
            }
            else
            {
            }

            return(new JumpListHelper(jumpList, logger, jumpItemsRemovedByUserSubscription, jumpItemsRejectedSubscription));
        }
コード例 #27
0
        /// <summary>
        /// Adds the jump list task for the specified task name
        /// </summary>
        /// <param name="taskName">Name of the task.</param>
        /// <param name="description">The description.</param>
        /// <param name="argument">The argument.</param>
        private void AddJumpListTask(string taskName, string description, string argument)
        {
            // Configure a new JumpTask.
            JumpTask jumpTask1 = new JumpTask();
            string   path      = System.Reflection.Assembly.GetExecutingAssembly().Location;

            jumpTask1.ApplicationPath = path;
            jumpTask1.Title           = taskName;
            jumpTask1.Description     = description;
            jumpTask1.Arguments       = argument;
            JumpList jumpList1 = JumpList.GetJumpList(App.Current);

            jumpList1.JumpItems.Add(jumpTask1);
            JumpList.AddToRecentCategory(jumpTask1);
            jumpList1.Apply();
        }
コード例 #28
0
ファイル: ShellViewModel.cs プロジェクト: evan-zang/Chronosv2
        private void CreateRecentNavigationEntry(NavigatedInfo value)
        {
            if (value.Request.NavigationMode == NavigateMode.New)
            {
                this.Dispatcher.BeginInvoke(
                    (Action) delegate
                {
                    if (App.RunningOnWin7)
                    {
                        JumpList jl = JumpList.GetJumpList(Application.Current);

                        if (jl != null)
                        {
                            if (jl.JumpItems.Count >= 10)
                            {
                                jl.JumpItems.Clear();
                            }

                            var q = jl.JumpItems.OfType <JumpTask>().Where(t => t.Arguments.Equals(value.Request.RequestUrl));

                            if (q.Count() == 0)
                            {
                                jl.JumpItems.Add
                                (
                                    new JumpTask
                                {
                                    CustomCategory    = "Recent",
                                    Title             = value.Title,
                                    Arguments         = value.Request.RequestUrl,
                                    IconResourcePath  = null,
                                    IconResourceIndex = -1,
                                    Description       = null,
                                    WorkingDirectory  =
                                        Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
                                }
                                );

                                jl.Apply();
                            }
                        }
                    }
                }, DispatcherPriority.Background);
            }
        }
コード例 #29
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //register file extension
            RegisterHandler();

            //get jump list
            JumpList jumpList = JumpList.GetJumpList(Application.Current);

            JumpTask jumpTaskBaidu = new JumpTask();

            jumpTaskBaidu.ApplicationPath   = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "");
            jumpTaskBaidu.Description       = "Open baidu in new window";
            jumpTaskBaidu.Title             = "Baidu";
            jumpTaskBaidu.WorkingDirectory  = Environment.CurrentDirectory;
            jumpTaskBaidu.Arguments         = "baidu";
            jumpTaskBaidu.IconResourcePath  = jumpTaskBaidu.ApplicationPath;
            jumpTaskBaidu.IconResourceIndex = 0;
            jumpList.JumpItems.Add(jumpTaskBaidu);

            JumpTask jumpTaskGoogle = new JumpTask();

            jumpTaskGoogle.ApplicationPath  = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "");
            jumpTaskGoogle.Description      = "Open google in new window";
            jumpTaskGoogle.Title            = "Google";
            jumpTaskGoogle.WorkingDirectory = Environment.CurrentDirectory;
            jumpTaskGoogle.Arguments        = "google";
            jumpTaskBaidu.IconResourcePath  = jumpTaskBaidu.ApplicationPath;
            jumpTaskBaidu.IconResourceIndex = 0;
            jumpList.JumpItems.Add(jumpTaskGoogle);

            JumpPath jumpPathGithub = new JumpPath();

            jumpPathGithub.CustomCategory = "Common";
            jumpPathGithub.Path           = Environment.CurrentDirectory + "\\github.zturl";
            jumpList.JumpItems.Add(jumpPathGithub);

            JumpList.SetJumpList(Application.Current, jumpList);

            JumplistDemo.MainWindow mainWindow = new MainWindow(e.Args);
            Application.Current.MainWindow = mainWindow;
            mainWindow.ShowActivated       = true;
            mainWindow.Show();
        }
コード例 #30
0
        public override void SaveDocumentAs(ITypeFactory factory)
        {
            XmlSerializer  seri = new XmlSerializer(new SerializationManager(), new DataContractSerializerFactory(), new XmlNamespaceManager(), factory, new ObjectAdapter());
            SaveFileDialog dlg  = new SaveFileDialog
            {
                Filter     = "Rodska Note Documents (.rndml)|*.rndml",
                FileName   = "Dialogue",
                DefaultExt = ".rndml"
            };
            bool?result = dlg.ShowDialog();

            if (result == true)
            {
                FileStream stream = new FileStream(dlg.FileName, FileMode.Create);
                seri.Serialize(this, stream);
                stream.Close();
                JumpList jl         = JumpList.GetJumpList(RodskaApplication.Current);
                bool     jpExisting = false;
                foreach (JumpItem item in jl.JumpItems)
                {
                    if (item is JumpPath)
                    {
                        JumpPath p = item as JumpPath;
                        if (p.Path == dlg.FileName)
                        {
                            jpExisting = true;
                            break;
                        }
                    }
                }
                if (!jpExisting)
                {
                    JumpPath jp = new JumpPath
                    {
                        Path           = dlg.FileName,
                        CustomCategory = Type
                    };
                    jl.JumpItems.Add(jp);
                    JumpList.AddToRecentCategory(jp);
                    jl.Apply();
                }
            }
        }