コード例 #1
0
ファイル: TrayIconManager.cs プロジェクト: zyhh/QuickLook
        private TrayIconManager()
        {
            _icon = new NotifyIcon
            {
                Text = string.Format(TranslationHelper.GetString("Icon_ToolTip"),
                                     Application.ProductVersion),
                Icon        = Resources.app,
                Visible     = true,
                ContextMenu = new ContextMenu(new[]
                {
                    new MenuItem($"v{Application.ProductVersion}{(App.IsUWP ? " (UWP)" : "")}")
                    {
                        Enabled = false
                    },
                    new MenuItem("-"),
                    new MenuItem(TranslationHelper.GetString("Icon_CheckUpdate"),
                                 (sender, e) => Updater.CheckForUpdates())
                    {
                        Enabled = !App.IsUWP
                    },
                    _itemAutorun,
                    new MenuItem(TranslationHelper.GetString("Icon_Quit"),
                                 (sender, e) => System.Windows.Application.Current.Shutdown())
                })
            };

            _icon.ContextMenu.Popup += (sender, e) => { _itemAutorun.Checked = AutoStartupHelper.IsAutorun(); };
        }
コード例 #2
0
        private TrayIconManager()
        {
            _icon = new NotifyIcon
            {
                Text = string.Format(TranslationHelper.Get("Icon_ToolTip"),
                                     Application.ProductVersion),
                Icon        = GetTrayIconByDPI(),
                Visible     = true,
                ContextMenu = new ContextMenu(new[]
                {
                    new MenuItem($"v{Application.ProductVersion}{(App.IsUWP ? " (UWP)" : "")}")
                    {
                        Enabled = false
                    },
                    new MenuItem("-"),
                    new MenuItem(TranslationHelper.Get("Icon_CheckUpdate"), (sender, e) => Updater.CheckForUpdates()),
                    new MenuItem(TranslationHelper.Get("Icon_GetPlugin"),
                                 (sender, e) => Process.Start("https://github.com/QL-Win/QuickLook/wiki/Available-Plugins")),
                    new MenuItem(TranslationHelper.Get("Icon_ManagePlugin"), (sender, e) => Process.Start(Environment.CurrentDirectory + @"\QuickLook.Plugin")),
                    _itemAutorun,
                    new MenuItem(TranslationHelper.Get("Icon_Quit"),
                                 (sender, e) => System.Windows.Application.Current.Shutdown())
                })
            };

            _icon.ContextMenu.Popup += (sender, e) => { _itemAutorun.Checked = AutoStartupHelper.IsAutorun(); };
        }
コード例 #3
0
        public static async Task Initlize()
        {
            //开机启动
#if UWP
            AutoStartupHelper.Initlize(AutoStartupType.Store, "LiveWallpaper");
#else
            AutoStartupHelper.Initlize(AutoStartupType.Win32, "LiveWallpaper");
#endif

            //多语言
            Xaml.CustomMaps.Add(typeof(TaskbarIcon), TaskbarIcon.ToolTipTextProperty);
            //不能用Environment.CurrentDirectory,开机启动目录会出错
            ApptEntryDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            string path = Path.Combine(ApptEntryDir, "Res\\Languages");
            LanService.Init(new JsonDB(path), true, "zh");

            //配置相关
            var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            AppDataDir        = $"{appData}\\LiveWallpaper";
            UWPRealAppDataDir = Path.Combine(ApplicationData.Current.LocalCacheFolder.Path, "Roaming\\LiveWallpaper");
            SettingPath       = $"{AppDataDir}\\Config\\setting.json";
            //LocalWallpaperDir = $"{AppDataDir}\\Wallpapers";
            //因为uwp store权限问题所以改为 %userprofile%\videos\LivewallpaperCache
            //string videoDir = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
            //LocalWallpaperDir = $"{videoDir}\\LivewallpaperCache";

            AppDataPath      = $"{AppDataDir}\\appData.json";
            PurchaseDataPath = $"{AppDataDir}\\purchaseData.json";

            await CheckDefaultSetting();

            //应用程序数据
            AppData = await JsonHelper.JsonDeserializeFromFileAsync <AppData>(AppDataPath);

            if (AppData == null)
            {
                AppData = new AppData();
                await ApplyAppDataAsync();
            }

            //加载壁纸
            await Task.Run(() =>
            {
                RefreshLocalWallpapers();
                //if (AppData.Wallpaper != null)
                //{
                WallpaperManager.MaximizedEvent += WallpaperManager_MaximizedEvent;
                var current = Wallpapers.FirstOrDefault(m => m.AbsolutePath == AppData.Wallpaper);
                if (current != null)
                {
                    WallpaperManager.VideoAspect = Setting.Wallpaper.VideoAspect;
                    WallpaperManager.Show(current);
                }
                WallpaperManager.MonitorMaxiemized(true);
                //}
            });
        }
コード例 #4
0
        /* comment by gh
         * private void CheckUpdate()
         * {
         *  if (DateTime.Now.Ticks - SettingHelper.Get<long>("LastUpdateTicks") < TimeSpan.FromDays(7).Ticks)
         *      return;
         *
         *  Task.Delay(120 * 1000).ContinueWith(_ => Updater.CheckForUpdates(true));
         *  SettingHelper.Set("LastUpdateTicks", DateTime.Now.Ticks);
         * }
         *///----------//


        private void RunListener(StartupEventArgs e)
        {
            //comment by gh - 启动不显示启动提示
            //TrayIconManager.GetInstance();
            //if (!e.Args.Contains("/autorun") && !IsUWP)
            //TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START"));
            //if (e.Args.Contains("/first"))
            //AutoStartupHelper.CreateAutorunShortcut();
            //----------//

            //add by gh - 自动启动隐藏后台图标
            if (SettingHelper.Get("Visible", true))
            {
                TrayIconManager.GetInstance();
                if (!e.Args.Contains("/autorun") && !IsUWP)
                {
                    TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START"));
                }
            }
            else if (e.Args.Contains("/setvisible"))
            {
                SettingHelper.Set("Visible", true);
                TrayIconManager.GetInstance();
                if (!IsUWP)
                {
                    TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START"));
                }
            }
            //自己添加的功能,与quick look无关
            if (SettingHelper.Get("Watcher", false))
            {
                DesktopWatcher.GetInstance().WatcherStart();
            }

            if (e.Args.Contains("/first"))
            {
                AutoStartupHelper.CreateAutorunShortcut();
            }
            //----------//

            NativeMethods.QuickLook.Init();

            PluginManager.GetInstance();
            ViewWindowManager.GetInstance();
            KeystrokeDispatcher.GetInstance();
            PipeServerManager.GetInstance();
        }
コード例 #5
0
ファイル: App.xaml.cs プロジェクト: psy5lyer/QuickLook
        private void RunListener(StartupEventArgs e)
        {
            TrayIconManager.GetInstance();
            if (!e.Args.Contains("/autorun") && !IsUWP)
            {
                TrayIconManager.ShowNotification("", TranslationHelper.GetString("APP_START"));
            }
            if (e.Args.Contains("/first"))
            {
                AutoStartupHelper.CreateAutorunShortcut();
            }

            NativeMethods.QuickLook.Init();

            PluginManager.GetInstance();
            ViewWindowManager.GetInstance();
            BackgroundListener.GetInstance();
            PipeServerManager.GetInstance();
        }
コード例 #6
0
        //----------//

        private TrayIconManager()
        {
            _icon = new NotifyIcon
            {
                Text = string.Format(TranslationHelper.Get("Icon_ToolTip"),
                                     Application.ProductVersion),
                Icon        = GetTrayIconByDPI(),
                Visible     = true,
                ContextMenu = new ContextMenu(new[]
                {
                    //comment by gh
                    //new MenuItem($"v{Application.ProductVersion}{(App.IsUWP ? " (UWP)" : "")}") {Enabled = false},
                    //----------//

                    //add by gh
                    new MenuItem($"v{Application.ProductVersion}{(App.IsUWP ? " (UWP)" : "")}",
                                 (sender, e) => { ShowNotification(TranslationHelper.Get("Icon_VersionMessageTitle"),
                                                                   string.Format(TranslationHelper.Get("Icon_VersionMessage"), Application.ProductVersion)); }),
                    //----------//

                    new MenuItem("-"),
                    new MenuItem(TranslationHelper.Get("Icon_CheckUpdate"), (sender, e) => Updater.CheckForUpdates()),
                    new MenuItem(TranslationHelper.Get("Icon_GetPlugin"),
                                 (sender, e) => Process.Start("https://github.com/QL-Win/QuickLook/wiki/Available-Plugins")),
                    _itemAutorun,

                    //add by gh - 添加隐藏选项
                    _visible,
                    _watcher,
                    //----------//

                    new MenuItem(TranslationHelper.Get("Icon_Quit"),
                                 (sender, e) => System.Windows.Application.Current.Shutdown())
                })
            };

            _icon.ContextMenu.Popup += (sender, e) => { _itemAutorun.Checked = AutoStartupHelper.IsAutorun();
                                                        //add by gh
                                                        _watcher.Checked = SettingHelper.Get("Watcher", false);
                                                        //----------------//
            };
        }
コード例 #7
0
ファイル: App.xaml.cs プロジェクト: Milly/QuickLook
        private void RunListener(StartupEventArgs e)
        {
            TrayIconManager.GetInstance();
            if (!e.Args.Contains("/autorun"))
            {
                TrayIconManager.GetInstance().ShowNotification("", "QuickLook is running in the background.");
            }
            if (e.Args.Contains("/first"))
            {
                AutoStartupHelper.CreateAutorunShortcut();
            }

            NativeMethods.QuickLook.Init();

            PluginManager.GetInstance();
            BackgroundListener.GetInstance();
            PipeServerManager.GetInstance().MessageReceived +=
                (msg, ea) => Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().InvokeViewer(msg as string, closeIfSame: true)),
                    DispatcherPriority.ApplicationIdle);
        }
コード例 #8
0
ファイル: TrayIconManager.cs プロジェクト: Milly/QuickLook
        private TrayIconManager()
        {
            _icon = new NotifyIcon
            {
                Text        = $"QuickLook v{Application.ProductVersion}",
                Icon        = Resources.app,
                Visible     = true,
                ContextMenu = new ContextMenu(new[]
                {
                    new MenuItem($"v{Application.ProductVersion}")
                    {
                        Enabled = false
                    },
                    new MenuItem("-"),
                    new MenuItem("Check for &Updates...",
                                 (sender, e) => Updater.CheckForUpdates()),
                    _itemAutorun,
                    new MenuItem("&Quit", (sender, e) => System.Windows.Application.Current.Shutdown())
                })
            };

            _icon.ContextMenu.Popup += (sender, e) => { _itemAutorun.Checked = AutoStartupHelper.IsAutorun(); };
        }
コード例 #9
0
        public static async void InitlizeSetting()
        {
            if (SettingInitialized)
            {
                return;
            }

            //开机启动
            AutoStartupHelper.Initlize(AutoStartupType.Store, "LiveWallpaper");

            //配置相关
            SettingDefaultFile = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Res\\setting.default.json");
            SettingDescFile    = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Res\\setting.desc.json");

            var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            AppDataDir       = $"{appData}\\LiveWallpaper";
            SettingPath      = $"{AppDataDir}\\Config\\setting.json";
            AppDataPath      = $"{AppDataDir}\\appData.json";
            PurchaseDataPath = $"{AppDataDir}\\purchaseData.json";

            await CheckDefaultSetting();

            //应用程序数据
            AppData = await JsonHelper.JsonDeserializeFromFileAsync <AppData>(AppDataPath);

            if (AppData == null)
            {
                AppData = new AppData();
                await ApplyAppDataAsync();
            }

            Setting = await JsonHelper.JsonDeserializeFromFileAsync <SettingObject>(SettingPath);

            LocalWallpaperDir  = Setting.General.WallpaperSaveDir;
            SettingInitialized = true;
        }