Esempio n. 1
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;

            try
            {
                _mediaInfo = new MediaInfo.MediaInfo(Path.Combine(
                                                         Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                                         Environment.Is64BitProcess ? "MediaInfo-x64\\" : "MediaInfo-x86\\"));
                _mediaInfo.Option("Cover_Data", "base64");

                _mediaInfo.Open(path);
            }
            catch (Exception)
            {
                _mediaInfo?.Dispose();
                _mediaInfo = null;
            }

            context.TitlebarOverlap = true;

            if (_mediaInfo == null ||
                !string.IsNullOrWhiteSpace(_mediaInfo.Get(StreamKind.General, 0, "VideoCount"))) // video
            {
                int.TryParse(_mediaInfo?.Get(StreamKind.Video, 0, "Width"), out var width);
                int.TryParse(_mediaInfo?.Get(StreamKind.Video, 0, "Height"), out var height);
                double.TryParse(_mediaInfo?.Get(StreamKind.Video, 0, "Rotation"), out var rotation);
                // Correct rotation: on some machine the value "90" becomes "90000" by some reason
                if (rotation > 360)
                {
                    rotation /= 1e3;
                }

                var windowSize = new Size
                {
                    Width  = Math.Max(100, width == 0 ? 1366 : width),
                    Height = Math.Max(100, height == 0 ? 768 : height)
                };

                if (rotation % 180 != 0)
                {
                    windowSize = new Size(windowSize.Height, windowSize.Width);
                }

                context.SetPreferredSizeFit(windowSize, 0.8);

                context.TitlebarAutoHide       = true;
                context.Theme                  = Themes.Dark;
                context.TitlebarBlurVisibility = true;
            }
            else // audio
            {
                context.PreferredSize = new Size(500, 300);

                context.CanResize                = false;
                context.TitlebarAutoHide         = false;
                context.TitlebarBlurVisibility   = false;
                context.TitlebarColourVisibility = false;
            }
        }
Esempio n. 2
0
 public void Prepare(string path, ContextObject context)
 {
     _context = context;
     context.SetPreferredSizeFit(new Size {
         Width = 1000, Height = 800
     }, 0.8);
 }
Esempio n. 3
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;

            var def = new Size(500, 300);

            var hasVideo = HasVideoStream(path, out var mediaSize);

            var windowSize = mediaSize == Size.Empty ? def : mediaSize;

            windowSize.Width  = Math.Max(def.Width, windowSize.Width);
            windowSize.Height = Math.Max(def.Height, windowSize.Height);

            context.SetPreferredSizeFit(windowSize, 0.8);
            context.TitlebarOverlap = true;
            if (!hasVideo)
            {
                context.CanResize                = false;
                context.TitlebarAutoHide         = false;
                context.TitlebarBlurVisibility   = false;
                context.TitlebarColourVisibility = false;
            }
            else
            {
                context.TitlebarAutoHide       = true;
                context.Theme                  = Themes.Dark;
                context.TitlebarBlurVisibility = true;
            }
        }
Esempio n. 4
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;

            var def = new Size(500, 300);

            probe = probe ?? new FFprobe(path);

            if (!probe.HasVideo())
            {
                context.CanResize                = false;
                context.TitlebarAutoHide         = false;
                context.TitlebarBlurVisibility   = false;
                context.TitlebarColourVisibility = false;
            }
            else
            {
                context.TitlebarAutoHide         = true;
                context.UseDarkTheme             = true;
                context.CanResize                = true;
                context.TitlebarAutoHide         = true;
                context.TitlebarBlurVisibility   = true;
                context.TitlebarColourVisibility = true;
            }

            var windowSize = probe.GetViewSize() == Size.Empty ? def : probe.GetViewSize();

            windowSize.Width  = Math.Max(def.Width, windowSize.Width);
            windowSize.Height = Math.Max(def.Height, windowSize.Height);

            context.SetPreferredSizeFit(windowSize, 0.6);
            context.TitlebarOverlap = true;
        }
Esempio n. 5
0
        public void BoundViewSize(string path, ContextObject context)
        {
            _pdfControl = new PdfViewerControl();

            var desiredSize = _pdfControl.GetDesiredControlSizeByFirstPage(path);

            context.SetPreferredSizeFit(desiredSize, 0.8);
        }
Esempio n. 6
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;
            _path    = path;

            var desiredSize = PdfViewerControl.GetDesiredControlSizeByFirstPage(path);

            context.SetPreferredSizeFit(desiredSize, 0.8);
        }
        public void Prepare(string path, ContextObject context)
        {
            _fitsImagePtr = NativeMethods.FitsImageCreate(path);
            ImageDim outputDim = NativeMethods.FitsImageGetOutputDim(_fitsImagePtr);

            var size = new Size(outputDim.nx, outputDim.ny);

            context.SetPreferredSizeFit(size, 0.8);
        }
Esempio n. 8
0
 public void Prepare(string path, ContextObject context)
 {
     //comment by gh - I need larger size
     //context.SetPreferredSizeFit(new Size {Width = 800, Height = 800}, 0.8);
     //----------------//
     context.SetPreferredSizeFit(new Size {
         Width = 1200, Height = 800
     }, 0.9);
 }
Esempio n. 9
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;
            _path    = path;

            var desiredSize = PdfViewerControl.GetDesiredControlSizeByFirstPage(path);

            context.SetPreferredSizeFit(desiredSize, 0.6);

            context.PreferredSize = new Size(context.PreferredSize.Width, context.PreferredSize.Height + 32);
        }
Esempio n. 10
0
 public void Prepare(string path, ContextObject context)
 {
     using (var element = new MediaElement {
         Source = new Uri(path)
     })
     {
         context.SetPreferredSizeFit(new Size(element.NaturalVideoWidth, element.NaturalVideoHeight), 0.6);
         context.PreferredSize = new Size(context.PreferredSize.Width,
                                          context.PreferredSize.Height + 26); // add control bar
     }
 }
Esempio n. 11
0
        public void Prepare(string path, ContextObject context)
        {
            var def = new Size(450, 450);

            _mediaSize = GetMediaSizeWithVlc(path);

            var windowSize = _mediaSize == Size.Empty ? def : _mediaSize;

            windowSize.Width  = Math.Max(def.Width, windowSize.Width);
            windowSize.Height = Math.Max(def.Height, windowSize.Height);

            context.SetPreferredSizeFit(windowSize, 0.6);
        }
Esempio n. 12
0
        public void Prepare(string path, ContextObject context)
        {
            var def = new Size(450, 450);

            _probe = new FFprobe(path);
            var mediaSize = _probe.GetViewSize();

            var windowSize = mediaSize == Size.Empty ? def : mediaSize;

            windowSize.Width  = Math.Max(def.Width, windowSize.Width);
            windowSize.Height = Math.Max(def.Height, windowSize.Height);

            context.SetPreferredSizeFit(windowSize, 0.6);
        }
Esempio n. 13
0
        public void Prepare(string path, ContextObject context)
        {
            _imageSize = ImageFileHelper.GetImageSize(path, _meta = new Meta(path));

            if (!_imageSize.IsEmpty)
            {
                context.SetPreferredSizeFit(_imageSize, 0.8);
            }
            else
            {
                context.PreferredSize = new Size(800, 600);
            }

            context.Theme = (Themes)SettingHelper.Get("LastTheme", 1);
        }
Esempio n. 14
0
        public void Prepare(string path, ContextObject context)
        {
            _imageSize = ImageFileHelper.GetImageSize(path, _meta = new Meta(path));

            if (!_imageSize.IsEmpty)
            {
                context.SetPreferredSizeFit(_imageSize, 0.8);
            }
            else
            {
                context.PreferredSize = new Size(800, 600);
            }

            context.UseDarkTheme = true;
        }
Esempio n. 15
0
        public void Prepare(string path, ContextObject context)
        {
            _imageSize = ImageFileHelper.GetImageSize(path) ?? Size.Empty;

            if (!_imageSize.IsEmpty)
            {
                context.SetPreferredSizeFit(_imageSize, 0.8);
            }
            else
            {
                context.PreferredSize = new Size(1024, 768);
            }

            Directory.SetCurrentDirectory(App.AppPath);
        }
        public MainWindow()
        {
            InitializeComponent();
            Console.WriteLine("*********************");

            Console.WriteLine(Environment.Is64BitProcess);
            //string path = "E:/temp/2020-01-02-1456_6-CapObj_0000.FIT";
            string path = "E:/temp/3ch.fit";
            //string path = "E:/temp/float.fit";

            //string path = "E:/temp/小房牛 M31-009B.fit";

            var fitsImage = NativeMethods.FitsImageCreate(path);

            var header = NativeMethods.FitsImageGetHeader(fitsImage);

            ImageDim bufferSize = NativeMethods.FitsImageGetOutputDim(fitsImage);

            byte[] img = new byte[bufferSize.nx * bufferSize.ny * bufferSize.nc];
            NativeMethods.FitsImageGetPixData(fitsImage, img);

            BitmapSource bitmapSource;
            int          rawStride = bufferSize.nx * bufferSize.nc;

            if (bufferSize.nc == 3)
            {
                bitmapSource = BitmapSource.Create(bufferSize.nx, bufferSize.ny, 96, 96, PixelFormats.Rgb24, null, img, rawStride);
            }
            else
            {
                bitmapSource = BitmapSource.Create(bufferSize.nx, bufferSize.ny, 96, 96, PixelFormats.Gray8, null, img, rawStride);
            }

            var co = new ContextObject();

            _ip = new ImagePanel(co, header);

            var size = new Size(bufferSize.nx, bufferSize.ny);

            co.SetPreferredSizeFit(size, 0.8);
            _ip.Source = bitmapSource;

            _tabUserPage = new TabItem {
                Content = _ip
            };
            MainTab.Items.Add(_tabUserPage);
            MainTab.Items.Refresh();
        }
Esempio n. 17
0
        public void Prepare(string path, ContextObject context)
        {
            // set dcraw.exe for Magick.NET
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            _imageSize = ImageFileHelper.GetImageSize(path) ?? Size.Empty;

            if (!_imageSize.IsEmpty)
            {
                context.SetPreferredSizeFit(_imageSize, 0.8);
            }
            else
            {
                context.PreferredSize = new Size(1024, 768);
            }
        }
Esempio n. 18
0
        public void Prepare(string path, ContextObject context)
        {
            string videoCodec = _mediaInfo.Get(StreamKind.Video, 0, "Format");

            if (!string.IsNullOrWhiteSpace(videoCodec)) // video
            {
                int.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Width"), out var width);
                int.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Height"), out var height);
                double.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Rotation"), out var rotation);

                // Correct rotation: on some machine the value "90" becomes "90000" by some reason
                if (rotation > 360)
                {
                    rotation /= 1e3;
                }

                var windowSize = new Size
                {
                    Width  = Math.Max(100, width == 0 ? 1366 : width),
                    Height = Math.Max(100, height == 0 ? 768 : height)
                };

                if (rotation % 180 != 0)
                {
                    windowSize = new Size(windowSize.Height, windowSize.Width);
                }

                //edit by gh
                context.SetPreferredSizeFit(windowSize, 0.9);
                //context.SetPreferredSizeFit(windowSize, 0.8);
                //--------//

                context.TitlebarAutoHide       = true;
                context.Theme                  = Themes.Dark;
                context.TitlebarBlurVisibility = true;
            }
            else // audio
            {
                context.PreferredSize = new Size(500, 300);

                context.CanResize                = false;
                context.TitlebarAutoHide         = false;
                context.TitlebarBlurVisibility   = false;
                context.TitlebarColourVisibility = false;
            }
            context.TitlebarOverlap = true;
        }
Esempio n. 19
0
        public void Prepare(string path, ContextObject context)
        {
            _meta = new MetaProvider(path);

            var size = _meta.GetSize();

            if (!size.IsEmpty)
            {
                context.SetPreferredSizeFit(size, 0.8);
            }
            else
            {
                context.PreferredSize = new Size(800, 600);
            }

            context.Theme = (Themes)SettingHelper.Get("LastTheme", 1);
        }
Esempio n. 20
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;
            _path    = path;

            var width  = 800d;
            var height = 600d;

            var pages = GhostScriptWrapper.GetPageSizes(path);

            pages?.ForEach(p =>
            {
                width  = Math.Max(width, p.Width);
                height = Math.Max(height, p.Height);
            });

            context.SetPreferredSizeFit(new Size(width, height), 0.8);
        }
Esempio n. 21
0
        public void Prepare(string path, ContextObject context)
        {
            _imageSize = ImageFileHelper.GetImageSize(path) ?? Size.Empty;

            if (!_imageSize.IsEmpty)
            {
                context.SetPreferredSizeFit(_imageSize, 0.8);
            }
            else
            {
                context.PreferredSize = new Size(1024, 768);
            }

            Directory.SetCurrentDirectory(App.AppPath);

            context.TitlebarBlurVisibility = true;
            context.TitlebarOverlap        = true;
            context.TitlebarAutoHide       = true;
        }
Esempio n. 22
0
        public void Prepare(string path, ContextObject context)
        {
            _meta = new MetaProvider(path);

            var size = _meta.GetSize();

            if (!size.IsEmpty)
            {
                //edit by gh
                //context.SetPreferredSizeFit(size, 0.8);
                context.SetPreferredSizeFit(size, 0.95);
            }
            //--------------------//
            else
            {
                context.PreferredSize = new Size(800, 600);
            }

            context.Theme = (Themes)SettingHelper.Get("LastTheme", 1, "QuickLook.Plugin.ImageViewer");
        }
Esempio n. 23
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;

            try
            {
                _det = File.Create(path);
            }
            catch (Exception)
            {
                // ignored
            }

            context.TitlebarOverlap = true;

            if ((_det?.Properties.MediaTypes ?? MediaTypes.Video).HasFlag(MediaTypes.Video)) // video
            {
                var windowSize = new Size
                {
                    Width  = Math.Max(1366, _det?.Properties.VideoWidth ?? 1366),
                    Height = Math.Max(768, _det?.Properties.VideoHeight ?? 768)
                };
                context.SetPreferredSizeFit(windowSize, 0.8);

                context.TitlebarAutoHide       = true;
                context.Theme                  = Themes.Dark;
                context.TitlebarBlurVisibility = true;
            }
            else // audio
            {
                context.PreferredSize = new Size(500, 300);

                context.CanResize                = false;
                context.TitlebarAutoHide         = false;
                context.TitlebarBlurVisibility   = false;
                context.TitlebarColourVisibility = false;
            }
        }
 public void Prepare(string path, ContextObject context)
 {
     context.SetPreferredSizeFit(new Size {
         Width = 1920, Height = 1440
     }, 0.9);
 }
 public void BoundViewSize(string path, ContextObject context)
 {
     context.SetPreferredSizeFit(new Size {
         Width = 800, Height = 600
     }, 0.8);
 }
Esempio n. 26
0
        public void BoundViewSize(string path, ContextObject context)
        {
            _imageSize = ImageFileHelper.GetImageSize(path);

            context.SetPreferredSizeFit(_imageSize, 0.8);
        }