Esempio n. 1
0
        public static void CollectAndShowReleaseNotes()
        {
            Task.Run(() =>
            {
                try
                {
                    var json = DownloadJson("https://api.github.com/repos/xupefei/QuickLook/releases");

                    var notes = string.Empty;

                    foreach (var item in json)
                    {
                        notes += $"# {item["name"]}\r\n\r\n";
                        notes += item["body"] + "\r\n\r\n";
                    }

                    var changeLogPath = Path.GetTempFileName() + ".md";
                    File.WriteAllText(changeLogPath, notes);

                    PipeServerManager.SendMessage(PipeMessages.Invoke, changeLogPath);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    Application.Current.Dispatcher.Invoke(
                        () => TrayIconManager.ShowNotification("",
                                                               string.Format(TranslationHelper.GetString("Update_Error"), e.Message)));
                }
            });
        }
Esempio n. 2
0
        public void View(string path, ContextObject context)
        {
            _viewer = new SlideshowPanel();

            context.ViewerContent = _viewer;
            context.Title         = $"{Path.GetFileName(path)}";

            _entries = new List <string>(
                Directory.GetFiles(path, "*.*", SearchOption.AllDirectories));
            _viewer.ShowEntriesFound(_entries);

            _viewer.StartSlideshow += () =>
            {
                var cts   = new CancellationTokenSource();
                var token = cts.Token;

                int numberOfSeconds = _viewer.NumberOfSeconds * 1000;
                Task.Run(async() =>
                {
                    foreach (var entry in _entries)
                    {
                        if (token.IsCancellationRequested)
                        {
                            break;
                        }
                        PipeServerManager.SendMessage(
                            PipeMessages.Switch, entry);

                        await Task.Delay(numberOfSeconds);
                    }
                    ;
                });

                Task.Run(() =>
                {
                    var PipeName = "QuickLook.App.Pipe." + WindowsIdentity.GetCurrent().User?.Value;

                    var _server = new NamedPipeServerStream(PipeName, PipeDirection.In, 2);

                    using (var reader = new StreamReader(_server))
                    {
                        while (true)
                        {
                            _server.WaitForConnection();
                            var msg = reader.ReadLine();

                            _server.Disconnect();
                            if (msg.IndexOf("Close") > -1)
                            {
                                _server.Dispose();
                                cts.Cancel();
                                break;
                            }
                        }
                    }
                });
            };

            context.IsBusy = false;
        }
Esempio n. 3
0
        internal static string GetCurrentSelection()
        {
            StringBuilder sb = null;

            try
            {
                // communicate with COM in a separate thread
                Task.Run(() =>
                {
                    sb = new StringBuilder(MaxPath);

                    //edit by gh
                    GetCurrentSelectionNative_64(sb);

                    /*
                     * if (App.Is64Bit)
                     *  GetCurrentSelectionNative_64(sb);
                     * else
                     *  GetCurrentSelectionNative_32(sb);
                     */
                    //---------//
                }).Wait();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            //add by gh
            var str = sb.ToString();

            sb = new StringBuilder(PipeServerManager.ResolveShortcut(str));
            //-----------//

            return(sb?.ToString() ?? string.Empty);
        }
Esempio n. 4
0
 protected override void OnDisabled(DisabledEventArgs e)
 {
     PipeServerManager.Forget(phrase, PhraseHeard);
 }
Esempio n. 5
0
 protected override void OnEnabling(EnablingEventArgs e)
 {
     PipeServerManager.Listen(phrase, PhraseHeard);
 }