protected override void OnStartup(StartupEventArgs e) { Stopwatch.Debug("Startup Time", () => { base.OnStartup(e); WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(); RegisterUnhandledException(); ThreadPool.SetMaxThreads(30, 10); ThreadPool.SetMinThreads(10, 5); ThreadPool.QueueUserWorkItem(_ => { ImageLoader.ImageLoader.PreloadImages(); }); PluginManager.Initialize(); UserSettingStorage settings = UserSettingStorage.Instance; // happlebao temp fix for instance code logic HttpProxy.Instance.Settings = settings; InternationalizationManager.Instance.Settings = settings; ThemeManager.Instance.Settings = settings; MainViewModel mainVM = new MainViewModel(settings); API = new PublicAPIInstance(mainVM, settings); PluginManager.InitializePlugins(API); Window = new MainWindow(settings, mainVM); NotifyIconManager notifyIconManager = new NotifyIconManager(API); CommandArgsFactory.Execute(e.Args.ToList()); }); }
public static void PreloadImages() { //ImageCacheStroage.Instance.TopUsedImages can be changed during foreach, so we need to make a copy var imageList = new Dictionary <string, int>(ImageCacheStroage.Instance.TopUsedImages); Stopwatch.Debug($"Preload {imageList.Count} images", () => { foreach (var image in imageList) { if (!imageCache.ContainsKey(image.Key)) { ImageSource img = Load(image.Key, false); if (img != null) { img.Freeze(); //to make it copy to UI thread if (!imageCache.ContainsKey(image.Key)) { KeyValuePair <string, int> copyedImg = image; imageCache.Add(copyedImg.Key, img); } } } } }); }
public void Init(PluginInitContext context) { _context = context; Stopwatch.Debug("Preload programs", () => { _programs = _cache.Programs; }); Log.Info($"Preload {_programs.Count} programs from cache"); Stopwatch.Debug("Program Index", IndexPrograms); }
public void Init(PluginInitContext context) { this.context = context; this.context.API.ResultItemDropEvent += API_ResultItemDropEvent; Stopwatch.Debug("Preload programs", () => { programs = ProgramCacheStorage.Instance.Programs; }); Log.Info($"Preload {programs.Count} programs from cache"); Stopwatch.Debug("Program Index", IndexPrograms); }
public void Init(PluginInitContext context) { this._context = context; Stopwatch.Debug("Preload programs", () => { programs = _cache.Programs; }); Log.Info($"Preload {programs.Count} programs from cache"); // happlebao todo fix this //Stopwatch.Debug("Program Index", IndexPrograms); IndexPrograms(); }
protected override void OnStartup(StartupEventArgs e) { Stopwatch.Debug("Startup Time", () => { base.OnStartup(e); WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(); RegisterUnhandledException(); ThreadPool.QueueUserWorkItem(o => { ImageLoader.ImageLoader.PreloadImages(); }); Window = new MainWindow(); PluginManager.Init(Window); CommandArgsFactory.Execute(e.Args.ToList()); }); }
public Main() { _settingsStorage = new PluginJsonStorage <Settings>(); _settings = _settingsStorage.Load(); Stopwatch.Debug("Preload programs", () => { _cacheStorage = new BinaryStorage <ProgramIndexCache>(); _cache = _cacheStorage.Load(); _win32s = _cache.Programs; }); Log.Info($"Preload {_win32s.Length} programs from cache"); Stopwatch.Debug("Program Index", IndexPrograms); }
public static ImageSource Load(string path, bool addToCache = true) { if (string.IsNullOrEmpty(path)) { return(null); } ImageSource img = null; Stopwatch.Debug($"Loading image path: {path}", () => { if (addToCache) { ImageCacheStroage.Instance.Add(path); } if (imageCache.ContainsKey(path)) { img = imageCache[path]; } else { string ext = Path.GetExtension(path).ToLower(); if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase)) { img = new BitmapImage(new Uri(path)); } else if (selfExts.Contains(ext) && File.Exists(path)) { img = GetIcon(path); } else if (!string.IsNullOrEmpty(path) && imageExts.Contains(ext) && File.Exists(path)) { img = new BitmapImage(new Uri(path)); } if (img != null && addToCache) { if (!imageCache.ContainsKey(path)) { imageCache.Add(path, img); } } } }); return(img); }
protected override void OnStartup(StartupEventArgs e) { Stopwatch.Debug("Startup Time", () => { base.OnStartup(e); WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(); RegisterUnhandledException(); ThreadPool.SetMaxThreads(30, 10); ThreadPool.SetMinThreads(10, 5); ThreadPool.QueueUserWorkItem(_ => { ImageLoader.ImageLoader.PreloadImages(); }); MainViewModel mainVM = new MainViewModel(); API = new PublicAPIInstance(mainVM); Window = new MainWindow { DataContext = mainVM }; NotifyIconManager notifyIconManager = new NotifyIconManager(API); PluginManager.Init(API); CommandArgsFactory.Execute(e.Args.ToList()); }); }