Exemplo n.º 1
0
        public static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WM_SIZING)
            {
                if (WindowWasResized == false)
                {
                    // 'indicate the the user is resizing and not moving the window
                    WindowWasResized = true;
                }
            }

            if (msg == WM_EXITSIZEMOVE)
            {
                // 'check that this is the end of resize and not move operation
                if (WindowWasResized == true)
                {
                    // your stuff to do
                    ScaleImage.TryFitImage();

                    if (UILogic.UC.GetPicGallery != null)
                    {
                        if (GalleryFunctions.IsOpen)
                        {
                            UC.GetPicGallery.Width          = ConfigureWindows.GetMainWindow.ParentContainer.Width;
                            UILogic.UC.GetPicGallery.Height = ConfigureWindows.GetMainWindow.ParentContainer.Height;
                        }
                    }

                    // 'set it back to false for the next resize/move
                    WindowWasResized = false;
                }
            }

            return(IntPtr.Zero);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Rotates the image the specified degrees
        /// </summary>
        /// <param name="r"></param>
        internal static void Rotate(int r)
        {
            if (LoadWindows.GetMainWindow.MainImage.Source == null)
            {
                return;
            }

            var rt = new RotateTransform {
                Angle = Rotateint = r
            };

            ScaleImage.TryFitImage();

            // If it's flipped, keep it flipped when rotating
            if (Flipped)
            {
                var tg   = new TransformGroup();
                var flip = new ScaleTransform {
                    ScaleX = -1
                };
                tg.Children.Add(flip);
                tg.Children.Add(rt);
                LoadWindows.GetMainWindow.MainImage.LayoutTransform = tg;
            }
            else
            {
                LoadWindows.GetMainWindow.MainImage.LayoutTransform = rt;
            }
        }
Exemplo n.º 3
0
        internal static void SetScalingBehaviour(bool windowBehaviour, bool fill)
        {
            if (windowBehaviour)
            {
                WindowSizing.AutoFitWindow = true;
                UC.GetQuickSettingsMenu.SetFit.IsChecked = true;
            }
            else
            {
                WindowSizing.AutoFitWindow = false;
                UC.GetQuickSettingsMenu.SetFit.IsChecked = false;
            }

            if (fill)
            {
                Properties.Settings.Default.FillImage        = true;
                UC.GetQuickSettingsMenu.ToggleFill.IsChecked = true;
            }
            else
            {
                Properties.Settings.Default.FillImage        = false;
                UC.GetQuickSettingsMenu.ToggleFill.IsChecked = false;
            }

            ScaleImage.TryFitImage();
        }
Exemplo n.º 4
0
 public void UnloadTexture()
 {
     if (hasLocalCached)
     {
         scaleImage      = null;
         ramCachetexture = null;
         imageCache.UnloadTexture2D(texName);
     }
 }
Exemplo n.º 5
0
    public static void AddSacleImageToGroup(ScaleImage iBtn)
    {
        if (iBtn.btnNameForRemote != "" && iBtn.btnNameForRemote.Length < 33)
        {
            if (!allScaleImage.ContainsKey(iBtn.btnNameForRemote))
            {
                allScaleImage.Add(iBtn.btnNameForRemote, iBtn);
                string log = "GatherScaleImageCount:" + allScaleImage.Count;
//              Debug.Log(log);
//              GlobalDebug.Addline(log);
            }
        }
    }
Exemplo n.º 6
0
        internal static async void OpenFullscreenGallery(bool startup = false)
        {
            if (Pics.Count < 1 && !startup)
            {
                return;
            }

            Properties.Settings.Default.PicGallery = 2;
            LoadLayout();

            if (GetFakeWindow == null)
            {
                GetFakeWindow = new FakeWindow();
                GetFakeWindow.grid.Children.Add(new Views.UserControls.Gallery.PicGalleryTopButtons
                {
                    Margin = new Thickness(1, 12, 0, 0),
                });
            }

            // Switch gallery container to the correct window
            if (GetMainWindow.ParentContainer.Children.Contains(GetPicGallery))
            {
                GetMainWindow.ParentContainer.Children.Remove(GetPicGallery);
                GetFakeWindow.grid.Children.Add(GetPicGallery);
            }
            else if (!GetFakeWindow.grid.Children.Contains(GetPicGallery))
            {
                GetFakeWindow.grid.Children.Add(GetPicGallery);
            }

            GetFakeWindow.Show();
            GalleryNavigation.ScrollTo();
            GetMainWindow.Focus();

            if (!FreshStartup)
            {
                ScaleImage.TryFitImage();
            }

            // Fix not showing up opacity bug..
            VisualStateManager.GoToElementState(GetPicGallery, "Opacity", false);
            VisualStateManager.GoToElementState(GetPicGallery.Container, "Opacity", false);
            GetPicGallery.Opacity = GetPicGallery.Container.Opacity = 1;

            if (GetPicGallery.Container.Children.Count == 0)
            {
                await Load().ConfigureAwait(false);
            }
        }
Exemplo n.º 7
0
 public static void SetupRemoteGather()
 {
     if (!hasInit)
     {
         allImageButton          = new Dictionary <string, ImageButton>();
         allScaleImage           = new Dictionary <string, ScaleImage>();
         needSendAckMessages     = new List <RemoteMessage>();
         needSendBtnCtrlMessages = new List <RemoteMessage>();
         needProcessMessages     = new List <RemoteMessage>();
         currentCtrlScaleImage   = null;
         currentCameraUniversal  = null;
         RemoteMessage.globalID  = 0;
         hasInit = true;
         Debug.Log("RemoteGatherInit");
         GlobalDebug.Addline("RemoteGatherInit");
     }
 }
Exemplo n.º 8
0
    public Texture2D LoadTexture2D(ScaleImage inScaleImage = null)
    {
        if (inScaleImage != null)
        {
            scaleImage = inScaleImage;
        }

        if (ramCachetexture != null)
        {
            return(ramCachetexture);
        }

        if (hasLocalCached)
        {
            ramCachetexture = imageCache.LoadTexture2D(texName);
            return(ramCachetexture);
        }
        return(imageCache.placeHoldTex);
    }
Exemplo n.º 9
0
        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
        }
Exemplo n.º 10
0
        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)
                    };
                }
            }
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        public RemoteMessage(int inMessageType, string inCtrlBtnName = "", bool inBtnState = false, CameraUniversal c = null, ScaleImage s = null)
        {
            if (inCtrlBtnName.Length > 32)
            {
                string log = "按钮名字超过32个字符" + inCtrlBtnName;
                GlobalDebug.Addline(log);
                Debug.Log(log);
                Debug.LogWarning(log);
                Debug.LogError(log);
            }

            id = globalID;

            messageType = (byte)inMessageType;
            btnName     = inCtrlBtnName.PadLeft(32, '^');


            if (inBtnState)
            {
                btnState = 65;
            }
            else
            {
                btnState = 64;
            }


            if (c == null)
            {
                cameraStates = new float[] { 0, 0, 0, 0, 0, 0 };
            }
            else
            {
                cameraStates = c.GetCameraState();
            }

            if (s == null)
            {
                scaleImageStates = new float[] { 0, 0, 0 };
            }
            else
            {
                scaleImageStates = s.GetState();
            }


            GenBytes();

            globalID++;
        }
Exemplo n.º 13
0
 public string GetScale()
 {
     return(ScaleImage.ToString().ToLower());
 }