private void OnApplicationQuit() { SetupDesktop.appQuitting = true; SetupDesktop.UnhookHook(); foreach (SystemTray tray in trays) { tray.Dispose(); } }
private void PreviewWallpaper_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (_InProgressClosing) { e.Cancel = true; return; } //..detach wp window from this dialogue. SetupDesktop.SetParentSafe(processHWND, IntPtr.Zero); }
private void ButtonCloseAll_Click(object sender, RoutedEventArgs e) { SetupDesktop.CloseAllWallpapers(); foreach (var item in displayLBItems) { item.FileName = null; item.FilePath = null; } //displayLBItems.Clear(); //UpdateDisplayListBox(); }
/// <summary> /// Forwards the message to the required wallpaper window based on given cursor location. /// Skips if apps are in foreground. /// </summary> /// <param name="x">Cursor pos x</param> /// <param name="y">Cursor pos y</param> /// <param name="msg">window message</param> /// <param name="wParam">additional msg parameter</param> private static void ForwardMessage(int x, int y, int msg, IntPtr wParam) { //Don't forward when not on desktop. if (!SetupDesktop.IsDesktop()) { if (msg != (int)NativeMethods.WM.MOUSEMOVE || !SaveData.config.MouseInputMovAlways) { return; } } try { var display = Screen.FromPoint(new System.Drawing.Point(x, y)); var mouse = CalculateMousePos(x, y, display); foreach (var item in SetupDesktop.webProcesses) { if (item.DisplayID.Equals(display.DeviceName, StringComparison.Ordinal) || SaveData.config.WallpaperArrangement == SaveData.WallpaperArrangement.span) { //The low-order word specifies the x-coordinate of the cursor, the high-order word specifies the y-coordinate of the cursor. //ref: https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-mousemove UInt32 lParam = (uint)mouse.Y; lParam <<= 16; lParam |= (uint)mouse.X; NativeMethods.PostMessageW(item.Handle, msg, wParam, (IntPtr)lParam); } } foreach (var item in SetupDesktop.extPrograms) { if (item.Type == SetupDesktop.WallpaperType.video_stream) { continue; } if (item.DisplayID.Equals(display.DeviceName, StringComparison.Ordinal) || SaveData.config.WallpaperArrangement == SaveData.WallpaperArrangement.span) { UInt32 lParam = (uint)mouse.Y; lParam <<= 16; lParam |= (uint)mouse.X; NativeMethods.PostMessageW(item.Handle, msg, wParam, (IntPtr)lParam); } } } catch (Exception e) { Logger.Error(e.ToString()); } }
private void PreviewWallpaper_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (_InProgressClosing) { e.Cancel = true; return; } System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { App.w.LoadWallpaperFromWpDataFolder(); })); //..detach wp window from this dialogue. SetupDesktop.SetParentSafe(processHWND, IntPtr.Zero); }
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (displayLayoutSelect.SelectedIndex == -1) { return; } SaveData.config.WallpaperArrangement = (SaveData.WallpaperArrangement)displayLayoutSelect.SelectedIndex; SaveData.SaveConfig(); //close all currently running wp's & reset ui SetupDesktop.CloseAllWallpapers(); foreach (var item in displayLBItems) { item.FileName = null; item.FilePath = null; } }
private void MenuItem_Close_Click(object sender, RoutedEventArgs e) { if (DisplayLB.SelectedIndex == -1) { return; } SetupDesktop.CloseWallpaper(displayLBItems[DisplayLB.SelectedIndex].DisplayDevice); foreach (var item in displayLBItems) { if (item.DisplayDevice.Equals(displayLBItems[DisplayLB.SelectedIndex].DisplayDevice)) { item.FileName = null; item.FilePath = null; break; } } }
public void Start() { SetupDesktop.windowOffset = windowOffset; SetupDesktop.hideFromTaskbar = hideFromTaskbar; SetupDesktop.neverHide = neverHideWindow; SetupDesktop.keepBottomMost = keepBottomMost; SetupDesktop.borderless = borderless; SetupDesktop.behindIcons = behindIcons; SetupDesktop.Initialize(); SetupDesktop.AddWinProc(); if (useRainityInput) { RainityInput.Initialize(); } Application.runInBackground = true; }
public static void LateUpdate() { mouseButtonDown[0] = false; mouseButtonDown[1] = false; mouseButtonDown[2] = false; mouseButtonUp[0] = false; mouseButtonUp[1] = false; mouseButtonUp[2] = false; for (int i = 0; i < keysDown.Count; i++) { keysDown.RemoveAt(i); } for (int i = 0; i < keysUp.Count; i++) { keysUp.RemoveAt(i); } WinAPI.POINTFX mPos; WinAPI.GetCursorPos(out mPos); mousePosition = new Vector3(mPos.x, SetupDesktop.fHeight - mPos.y - 1, 0); if (Application.isEditor) { mousePosition = Input.mousePosition; } if (GetMouseDown()) { SetMouseButton(0, true); SetMouseButtonDown(0, true); } if (GetMouseUp()) { SetupDesktop.CheckForDesktopInteraction(); SetMouseButton(0, false); SetMouseButtonUp(0, true); } }
/// <summary> /// makes program child of window ui framework element. /// </summary> /// <param name="window"></param> /// <param name="pgmHandle"></param> /// <param name="element"></param> public static void SetProgramToFramework(Window window, IntPtr pgmHandle, FrameworkElement element) { IntPtr previewHwnd = new WindowInteropHelper(window).Handle; NativeMethods.RECT prct = new NativeMethods.RECT(); var reviewPanel = WindowOperations.GetAbsolutePlacement(element, true); if (!NativeMethods.SetWindowPos(pgmHandle, 1, (int)reviewPanel.Left, (int)reviewPanel.Top, (int)reviewPanel.Width, (int)reviewPanel.Height, 0 | 0x0010)) { SetupDesktop.LogWin32Error("setwindowpos(1) fail MapWallpaperToWindow(),"); } //ScreentoClient is no longer used, this supports windows mirrored mode also, calculate new relative position of window w.r.t parent. NativeMethods.MapWindowPoints(pgmHandle, previewHwnd, ref prct, 2); SetupDesktop.SetParentSafe(pgmHandle, previewHwnd); //Position the wp window relative to the new parent window(workerw). if (!NativeMethods.SetWindowPos(pgmHandle, 1, prct.Left, prct.Top, (int)reviewPanel.Width, (int)reviewPanel.Height, 0 | 0x0010)) { SetupDesktop.LogWin32Error("setwindowpos(2) fail MapWallpaperToWindow(),"); } }
private void MediaPlayer_Loaded(object sender, RoutedEventArgs e) { //ShowInTaskbar = false :- causing issue with windows10 Taskview. SetupDesktop.RemoveWindowFromTaskbar(new WindowInteropHelper(this).Handle); }
/* * public static string pathSaveData = Path.Combine(pathData, "SaveData"); * public static string pathWpTmp = Path.Combine(pathData, "SaveData", "wptmp"); * public static string pathWallpapers = Path.Combine(pathData, "wallpapers"); * public static string pathTmpData = Path.Combine(pathData, "tmpdata"); * public static string pathWpData = Path.Combine(pathData, "tmpdata", "wpdata"); */ protected override void OnStartup(StartupEventArgs e) { //delete residue tempfiles if any! FileOperations.EmptyDirectory(Path.Combine(pathData, "tmpdata")); try { //create directories if not exist Directory.CreateDirectory(Path.Combine(pathData, "SaveData")); Directory.CreateDirectory(Path.Combine(pathData, "SaveData", "wptmp")); Directory.CreateDirectory(Path.Combine(pathData, "wallpapers")); Directory.CreateDirectory(Path.Combine(pathData, "tmpdata")); Directory.CreateDirectory(Path.Combine(pathData, "tmpdata", "wpdata")); } catch (Exception ex) { //not logging here, just display & terminate. MessageBox.Show(ex.Message, Props.Resources.txtLivelyErrorMsgTitle, MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); } SaveData.LoadConfig(); #region language //CultureInfo.CurrentCulture = new CultureInfo("ru-RU", false); //not working? System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(SaveData.config.Language); //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN"); //zh-CN #endregion language if (!SaveData.config.SafeShutdown) { //clearing previous wp persisting image if any (not required, subProcess clears it). SetupDesktop.RefreshDesktop(); Directory.CreateDirectory(Path.Combine(pathData, "ErrorLogs")); string fileName = DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + ".txt"; if (File.Exists(Path.Combine(pathData, "ErrorLogs", fileName))) { fileName = Path.GetRandomFileName() + ".txt"; } try { File.Copy(Path.Combine(pathData, "logfile.txt"), Path.Combine(pathData, "ErrorLogs", fileName)); } catch (IOException e1) { System.Diagnostics.Debug.WriteLine(e1.ToString()); } var result = MessageBox.Show(Props.Resources.msgSafeModeWarning + Path.Combine(pathData, "ErrorLogs", fileName) , Props.Resources.txtLivelyErrorMsgTitle, MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { SetupDesktop.wallpapers.Clear(); SaveData.SaveWallpaperLayout(); //deleting saved wallpaper arrangements. } } SaveData.config.SafeShutdown = false; SaveData.SaveConfig(); #region theme // add custom accent and theme resource dictionaries to the ThemeManager // you should replace MahAppsMetroThemesSample with your application name // and correct place where your custom accent lives //ThemeManager.AddAccent("CustomAccent1", new Uri("pack://application:,,,/CustomAccent1.xaml")); // get the current app style (theme and accent) from the application // you can then use the current theme and custom accent instead set a new theme Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current); //white theme disabled temp: for v0.8 if (SaveData.config.Theme == 9 || SaveData.config.Theme == 10) { SaveData.config.Theme = 0; SaveData.SaveConfig(); ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(SaveData.livelyThemes[SaveData.config.Theme].Accent), ThemeManager.GetAppTheme(SaveData.livelyThemes[SaveData.config.Theme].Base)); // or appStyle.Item1 } else { // setting accent & theme ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(SaveData.livelyThemes[SaveData.config.Theme].Accent), ThemeManager.GetAppTheme(SaveData.livelyThemes[SaveData.config.Theme].Base)); // or appStyle.Item1 } // now change app style to the custom accent and current theme //ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("CustomAccent1"), ThemeManager.GetAppTheme(SaveData.livelyThemes[SaveData.config.Theme].Base)); #endregion theme base.OnStartup(e); SetupExceptionHandling(); w = new MainWindow(); if (SaveData.config.IsFirstRun) { //SaveData.config.isFirstRun = false; //only after minimizing to tray isFirstRun is set to false. SaveData.SaveConfig(); //creating disk file temp, not needed! w.Show(); w.UpdateWallpaperLibrary(); Dialogues.HelpWindow hw = new Dialogues.HelpWindow { Owner = w, WindowStartupLocation = WindowStartupLocation.CenterOwner }; hw.ShowDialog(); } if (SaveData.config.IsRestart) { SaveData.config.IsRestart = false; SaveData.SaveConfig(); w.Show(); w.UpdateWallpaperLibrary(); //w.ShowMainWindow(); w.tabControl1.SelectedIndex = 2; //settings tab //SetupDesktop.SetFocus(); //w.Activate(); } }
protected override void OnStartup(StartupEventArgs e) { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\SaveData"); //create if not exist SaveData.LoadConfig(); #region language //CultureInfo.CurrentCulture = new CultureInfo("ru-RU", false); //not working? System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(SaveData.config.Language); //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN"); //zh-CN #endregion language if (!SaveData.config.SafeShutdown) { //clearing previous wp persisting image if any. SetupDesktop.RefreshDesktop(); Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLogs\\"); string fileName = DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + ".txt"; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLogs\\" + fileName)) { fileName = Path.GetRandomFileName() + ".txt"; } try { File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\logfile.txt", AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLogs\\" + fileName); } catch (IOException e1) { System.Diagnostics.Debug.WriteLine(e1.ToString()); } var result = MessageBox.Show(Props.Resources.msgSafeModeWarning + AppDomain.CurrentDomain.BaseDirectory + "ErrorLogs\\" + fileName , Props.Resources.txtLivelyErrorMsgTitle, MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { SetupDesktop.wallpapers.Clear(); SaveData.SaveWallpaperLayout(); //deleting saved wallpaper arrangements. } } SaveData.config.SafeShutdown = false; SaveData.SaveConfig(); base.OnStartup(e); SetupExceptionHandling(); w = new MainWindow(); if (SaveData.config.IsFirstRun) { //SaveData.config.isFirstRun = false; //only after minimizing to tray isFirstRun is set to false. SaveData.SaveConfig(); //creating disk file temp, not needed! w.Show(); w.UpdateWallpaperLibrary(); HelpWindow hw = new HelpWindow { Owner = w, WindowStartupLocation = WindowStartupLocation.CenterOwner }; hw.ShowDialog(); } if (SaveData.config.IsRestart) { SaveData.config.IsRestart = false; SaveData.SaveConfig(); //w.WindowStartupLocation = WindowStartupLocation.Manual; w.Show(); w.UpdateWallpaperLibrary(); w.tabControl1.SelectedIndex = 2; //settings tab } }
private void OnApplicationQuit() { SetupDesktop.appQuitting = true; SetupDesktop.UnhookHook(); }
IEnumerator WaitAndApply() { yield return(new WaitForSeconds(0.5f)); SetupDesktop.AddWinProc(); }