/// <summary> /// Move window and maximize on double click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> internal static void Move(object sender, MouseButtonEventArgs e) { if (e.ChangedButton != MouseButton.Left) { return; } if (LoadWindows.GetMainWindow.TitleText.InnerTextBox.IsFocused) { if (e.ClickCount == 2) { Fullscreen_Restore(true); } return; } if (e.ClickCount == 2) { Fullscreen_Restore(true); } else { if (e.LeftButton == MouseButtonState.Pressed) { LoadWindows.GetMainWindow.DragMove(); } // Update info for possible new screen, needs more engineering // Seems to work MonitorInfo = MonitorSize.GetMonitorSize(); } }
public override string ToString() { var sb = new StringBuilder(); sb.AppendFormat(CultureInfo.InvariantCulture, "MonitorName: {0}{1}", MonitorName, Environment.NewLine); sb.AppendFormat(CultureInfo.InvariantCulture, "Virtual desktop: {0}{1}", VirtualDesktopId, Environment.NewLine); sb.AppendFormat(CultureInfo.InvariantCulture, "DPI: {0}{1}", Dpi, Environment.NewLine); string monitorSize = MonitorSize.ToString(CultureInfo.InvariantCulture); string workArea = string.Format(CultureInfo.InvariantCulture, "({0}, {1}, {2}, {3})", WorkAreaRect.X, WorkAreaRect.Y, WorkAreaRect.Width, WorkAreaRect.Height); sb.AppendFormat(CultureInfo.InvariantCulture, "Monitor size: {0}{1}", monitorSize, Environment.NewLine); sb.AppendFormat(CultureInfo.InvariantCulture, "Work area: {0}{1}", workArea, Environment.NewLine); return(sb.ToString()); }
public void LoadSettingData(SettingData settingAsset) { defaultZoomDist = settingAsset.defaultZoomDist; faceZoomDist = settingAsset.faceZoomDist; zoomStepDist = settingAsset.zoomStepDist; isGammaCorrection = settingAsset.isGammaCorrection; monitorBgColor = settingAsset.monitorBgColor; avatarMonitorField.SetAvatarCamBgColor(monitorBgColor); sizeType = settingAsset.monitorSizeType; if (settingAsset.monitorSizeType != MonitorSize.Custom) { monitorSize = (int)settingAsset.monitorSizeType; } else { monitorSize = (int)settingAsset.monitorSize; } avatarMonitorField.SetZoomParameters(defaultZoomDist, faceZoomDist, zoomStepDist); }
public void DrawSettingsGUI() { EditorGUILayout.LabelField("AvatarMonitor", EditorStyles.boldLabel); using (var check = new EditorGUI.ChangeCheckScope()) { defaultZoomDist = EditorGUILayout.FloatField(LocalizeText.instance.langPair.defaultCameraDistanceLabel, defaultZoomDist); faceZoomDist = EditorGUILayout.FloatField(LocalizeText.instance.langPair.faceCameraDistanceLabel, faceZoomDist); zoomStepDist = EditorGUILayout.FloatField(LocalizeText.instance.langPair.cameraZoomStepDistanceLabel, zoomStepDist); if (check.changed) { avatarMonitorField.SetZoomParameters(defaultZoomDist, faceZoomDist, zoomStepDist); } } EditorGUILayout.Space(); isGammaCorrection = EditorGUILayout.ToggleLeft(LocalizeText.instance.langPair.gammaCorrectionLabel, isGammaCorrection); using (var check = new EditorGUI.ChangeCheckScope()) { monitorBgColor = EditorGUILayout.ColorField(LocalizeText.instance.langPair.monitorBackgroundColorLabel, monitorBgColor); if (check.changed) { avatarMonitorField.SetAvatarCamBgColor(monitorBgColor); } } using (var check = new EditorGUI.ChangeCheckScope()) { sizeType = (MonitorSize)EditorGUILayout.EnumPopup(LocalizeText.instance.langPair.monitorSizeTypeLabel, sizeType); if (check.changed && sizeType != MonitorSize.Custom) { monitorSize = (int)sizeType; } } using (new EditorGUI.DisabledGroupScope(sizeType != MonitorSize.Custom)) { monitorSize = EditorGUILayout.IntField(LocalizeText.instance.langPair.monitorSizeLabel, monitorSize); } }
public ReturnResult <MonitorSize> GetById(int id) { DbProvider dbProvider = new DbProvider(); string outCode = String.Empty; string outMessage = String.Empty; MonitorSize monitorSize = null; StoredProcedureConfigs <MonitorSize> storedProcedureConfigs = new StoredProcedureConfigs <MonitorSize>(); dbProvider.SetQuery(storedProcedureConfigs._GET_SINGLE_STORED_PROCEDURE, CommandType.StoredProcedure) .SetParameter("Id", SqlDbType.Int, id, ParameterDirection.Input) .SetParameter("ERROR_CODE", SqlDbType.NVarChar, DBNull.Value, 100, ParameterDirection.Output) .SetParameter("ERROR_MESSAGE", SqlDbType.NVarChar, DBNull.Value, 400, ParameterDirection.Output) .GetSingle <MonitorSize>(out monitorSize) .Complete(); dbProvider.GetOutValue("ERROR_CODE", out outCode) .GetOutValue("ERROR_MESSAGE", out outMessage); return(new ReturnResult <MonitorSize>() { Item = monitorSize, ErrorCode = outCode, ErrorMessage = outMessage, }); }
internal static void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e) { // Update size when screen resulution changes MonitorInfo = MonitorSize.GetMonitorSize(); TryFitImage(); }
internal static void Start() { #if DEBUG Trace.WriteLine("ContentRendered started"); #endif ConfigureSettings.ConfigColors.UpdateColor(); #region Add dictionaries Application.Current.Resources.MergedDictionaries.Add( new ResourceDictionary { Source = new Uri(@"/PicView;component/Themes/Styles/Menu.xaml", UriKind.Relative) } ); Application.Current.Resources.MergedDictionaries.Add( new ResourceDictionary { Source = new Uri(@"/PicView;component/Themes/Styles/ToolTip.xaml", UriKind.Relative) } ); Application.Current.Resources.MergedDictionaries.Add( new ResourceDictionary { Source = new Uri(@"/PicView;component/Themes/Styles/Slider.xaml", UriKind.Relative) } ); #endregion Add dictionaries MonitorInfo = MonitorSize.GetMonitorSize(); AutoFitWindow = Properties.Settings.Default.AutoFitWindow; IsScrollEnabled = Properties.Settings.Default.ScrollEnabled; Pics = new List <string>(); // Load image if possible var arg = Application.Current.Properties["ArbitraryArgName"]; if (arg == null) { Unload(); // Reset PicGallery and don't allow it to run, // if only 1 image Properties.Settings.Default.PicGallery = 1; // Don't start it in fullscreen with no image Properties.Settings.Default.Fullscreen = false; } else { // Determine prefered UI for startup if (Properties.Settings.Default.Fullscreen) { Fullscreen_Restore(true); } else if (Properties.Settings.Default.PicGallery == 2) { GalleryToggle.OpenFullscreenGallery(true); } else if (AutoFitWindow) { ScaleImage.TryFitImage(arg.ToString()); } else if (Properties.Settings.Default.Width != 0) { LoadWindows.GetMainWindow.Top = Properties.Settings.Default.Top; LoadWindows.GetMainWindow.Left = Properties.Settings.Default.Left; LoadWindows.GetMainWindow.Width = Properties.Settings.Default.Width; LoadWindows.GetMainWindow.Height = Properties.Settings.Default.Height; } Pic(arg.ToString()); } // Load UI and events AddUIElementsAndUpdateValues(); #if DEBUG Trace.WriteLine("Start Completed "); #endif }
internal static void PreStart() { #if DEBUG Trace.Listeners.Add(new TextWriterTraceListener("Debug.log")); Trace.Unindent(); Trace.WriteLine(SetTitle.AppName + " started at " + DateTime.Now); #endif // theese two line have to be exactly onload HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(ConfigureWindows.GetMainWindow).Handle); source.AddHook(new HwndSourceHook(NativeMethods.WndProc)); if (!Properties.Settings.Default.ShowInterface) { ConfigureWindows.GetMainWindow.TitleBar.Visibility = ConfigureWindows.GetMainWindow.LowerBar.Visibility = Visibility.Collapsed; } FreshStartup = true; Pics = new List <string>(); // Load sizing properties MonitorInfo = MonitorSize.GetMonitorSize(); AutoFitWindow = Properties.Settings.Default.AutoFitWindow; IsScrollEnabled = Properties.Settings.Default.ScrollEnabled; // Set min size to DPI scaling ConfigureWindows.GetMainWindow.MinWidth *= MonitorInfo.DpiScaling; ConfigureWindows.GetMainWindow.MinHeight *= MonitorInfo.DpiScaling; // Load image if possible var arg = Application.Current.Properties["ArbitraryArgName"]; if (arg == null) { Unload(); // Reset PicGallery and don't allow it to run, // if only 1 image Properties.Settings.Default.PicGallery = 1; // Don't start it in fullscreen with no image Properties.Settings.Default.Fullscreen = false; // Determine proper startup size if (Properties.Settings.Default.Width != 0) { SetLastWindowSize(); } else { ConfigureWindows.GetMainWindow.Width = 750 * MonitorInfo.DpiScaling; ConfigureWindows.GetMainWindow.MinHeight = 700 * MonitorInfo.DpiScaling; } } else if (File.Exists(arg.ToString())) { var file = arg.ToString(); // Determine prefered UI for startup if (Properties.Settings.Default.Fullscreen) { ConfigureWindows.Fullscreen_Restore(true); } else if (Properties.Settings.Default.PicGallery == 2) { GalleryToggle.OpenFullscreenGallery(true); } else if (AutoFitWindow) { ScaleImage.TryFitImage(file); } else if (Properties.Settings.Default.Width != 0) { SetLastWindowSize(); } Pic(file); } else { // Set file associations var process = Process.GetCurrentProcess(); var args = arg.ToString().Split(','); foreach (var item in args) { NativeMethods.SetAssociation(item, process.Id.ToString(CultureInfo.InvariantCulture), item, process.MainModule.FileName); } Environment.Exit(0); } if (Properties.Settings.Default.UserLanguage != "en") { try { Application.Current.Resources.MergedDictionaries[0] = new ResourceDictionary { Source = new Uri(@"/PicView;component/Translations/" + Properties.Settings.Default.UserLanguage + ".xaml", UriKind.Relative) }; } catch (Exception) { Application.Current.Resources.MergedDictionaries[0] = new ResourceDictionary { Source = new Uri(@"/PicView;component/Translations/en.xaml", UriKind.Relative) }; } } }
internal static void LoadedEvemt() { #if DEBUG Trace.Listeners.Add(new TextWriterTraceListener("Debug.log")); Trace.Unindent(); Trace.WriteLine(SetTitle.AppName + " started at " + DateTime.Now); #endif // theese two line have to be exactly onload HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(ConfigureWindows.GetMainWindow).Handle); source.AddHook(new HwndSourceHook(NativeMethods.WndProc)); LoadLanguage.DetermineLanguage(); if (!Properties.Settings.Default.ShowInterface) { ConfigureWindows.GetMainWindow.TitleBar.Visibility = ConfigureWindows.GetMainWindow.LowerBar.Visibility = Visibility.Collapsed; } FreshStartup = true; Pics = new List <string>(); // Load sizing properties MonitorInfo = MonitorSize.GetMonitorSize(); AutoFitWindow = Properties.Settings.Default.AutoFitWindow; IsScrollEnabled = Properties.Settings.Default.ScrollEnabled; // Set min size to DPI scaling ConfigureWindows.GetMainWindow.MinWidth *= MonitorInfo.DpiScaling; ConfigureWindows.GetMainWindow.MinHeight *= MonitorInfo.DpiScaling; // Load image if possible var arg = Application.Current.Properties["ArbitraryArgName"]; if (arg == null) { Unload(); // Reset PicGallery and don't allow it to run, // if only 1 image Properties.Settings.Default.FullscreenGallery = false; // Don't start it in fullscreen with no image Properties.Settings.Default.Fullscreen = false; // Determine proper startup size if (Properties.Settings.Default.Width != 0) { SetLastWindowSize(); } else { ConfigureWindows.GetMainWindow.Width = ConfigureWindows.GetMainWindow.MinWidth; ConfigureWindows.GetMainWindow.Height = ConfigureWindows.GetMainWindow.MinHeight; } } else if (arg.ToString().StartsWith('.')) { // Set file associations var process = Process.GetCurrentProcess(); if (arg.ToString() == ".remove") { var removestring = ".jpeg,.jpe,.jpg,.png,.bmp,.ico,.gif,.webp,.jfif,.tiff,.wbmp,.psd,.psb,.svg,.3fr,.arw,.cr2,.crw,.dcr,.dng,.erf,.kdc,.mef,.mdc,.mos,.mrw,.nef,.nrw,.orf,.pef,.raf,.raw,.rw2,.srf,.x3f,.cut,.exr,.emf,.dds,.dib,.hdr,.heic,.tga,.pcx,.pgm,.wmf,.wpg,.xbm,.xcf.xpm"; var rmArgs = removestring.Split(','); foreach (var item in rmArgs) { NativeMethods.DeleteAssociation(item, process.Id.ToString(CultureInfo.InvariantCulture), process.MainModule.FileName); } } else { var args = arg.ToString().Split(','); foreach (var item in args) { NativeMethods.SetAssociation(item, process.Id.ToString(CultureInfo.InvariantCulture)); } } Environment.Exit(0); } else { var file = arg.ToString(); // Determine prefered UI for startup if (Properties.Settings.Default.Fullscreen) { ConfigureWindows.Fullscreen_Restore(true); } else if (Properties.Settings.Default.FullscreenGallery) { GalleryToggle.OpenFullscreenGallery(true); } else if (AutoFitWindow) { ScaleImage.TryFitImage(file); } else if (Properties.Settings.Default.Width != 0) { SetLastWindowSize(); } _ = LoadPiFrom(file); } }