예제 #1
0
        /// <summary>
        /// Show image or thumbnail preview on drag enter
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal static void Image_DragEnter(object sender, DragEventArgs e)
        {
            // Error handling
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            var files = e.Data.GetData(DataFormats.FileDrop, true) as string[];
            var check = Drag_Drop_Check(files);

            // Do nothing for invalid files
            if (!check.HasValue)
            {
                return;
            }

            if (!check.Value)
            {
                return;
            }

            // Check if same file
            if (files.Length == 1 && Pics.Count > 0)
            {
                if (files[0] == Pics[FolderIndex])
                {
                    return;
                }
            }

            // Tell that it's succeeded
            e.Effects = DragDropEffects.Copy;
            e.Handled = true;
            ShowTooltipMessage(Application.Current.Resources["DragOverString"] as string, true);

            // If no image, fix it to container
            if (LoadWindows.GetMainWindow.MainImage.Source == null)
            {
                LoadWindows.GetMainWindow.MainImage.Width  = LoadWindows.GetMainWindow.Scroller.ActualWidth;
                LoadWindows.GetMainWindow.MainImage.Height = LoadWindows.GetMainWindow.Scroller.ActualHeight;
            }
            else
            {
                // Save our image so we can swap back to it later if neccesary
                prevPicResource = LoadWindows.GetMainWindow.MainImage.Source;
            }

            // Load from preloader or thumbnails
            var thumb = Preloader.Contains(files[0]) ? Preloader.Load(files[0]) : GetBitmapSourceThumb(files[0]);

            if (thumb != null)
            {
                LoadWindows.GetMainWindow.MainImage.Source = thumb;
            }
        }
예제 #2
0
        internal static void CopyBitmap()
        {
            if (Preloader.Contains(Pics[FolderIndex]))
            {
                Clipboard.SetImage(Preloader.Load(Pics[FolderIndex]));
            }
            else if (mainWindow.img.Source != null)
            {
                Clipboard.SetImage((BitmapSource)mainWindow.img.Source);
            }
            else
            {
                return;
            }

            ToolTipStyle("Copied Image to clipboard");
        }
예제 #3
0
        /// <summary>
        /// Update after FastPic() was used
        /// </summary>
        internal static void FastPicUpdate()
        {
            if (!FastPicRunning)
            {
                return;
            }

            //fastPicTimer.Stop();
            FastPicRunning = false;

            if (!Preloader.Contains(Pics[FolderIndex]))
            {
                PreloadCount = 0;
                Preloader.Clear();
            }

            Pic(FolderIndex);
        }
예제 #4
0
        internal static void CopyBitmap()
        {
            if (Pics.Count == 0 && LoadWindows.GetMainWindow.MainImage.Source != null)
            {
                Clipboard.SetImage((BitmapSource)LoadWindows.GetMainWindow.MainImage.Source);
            }
            else if (Preloader.Contains(Pics[FolderIndex]))
            {
                Clipboard.SetImage(Preloader.Load(Pics[FolderIndex]));
            }
            else if (LoadWindows.GetMainWindow.MainImage.Source != null)
            {
                Clipboard.SetImage((BitmapSource)LoadWindows.GetMainWindow.MainImage.Source);
            }
            else
            {
                return;
            }

            ShowTooltipMessage(Application.Current.Resources["FileCutMessage"]);
        }
예제 #5
0
        /// <summary>
        /// Show image or thumbnail preview on drag enter
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal static void Image_DragEnter(object sender, DragEventArgs e)
        {
            // Error handling
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            var files = e.Data.GetData(DataFormats.FileDrop, true) as string[];
            var check = Drag_Drop_Check(files);

            // Do nothing for invalid files
            if (!check.HasValue)
            {
                return;
            }

            // Tell that it's succeeded
            e.Effects     = DragDropEffects.Copy;
            isDraggedOver = e.Handled = true;
            ToolTipStyle(DragOverString, true);

            if (check.Value)
            {
                // If no image, fix it to container
                if (mainWindow.img.Source == null)
                {
                    mainWindow.img.Width  = mainWindow.Scroller.ActualWidth;
                    mainWindow.img.Height = mainWindow.Scroller.ActualHeight;
                }
                else
                {
                    // Save our image so we can swap back to it later if neccesary
                    prevPicResource = mainWindow.img.Source;
                }

                // Load from preloader or thumbnails
                mainWindow.img.Source = Preloader.Contains(files[0]) ? Preloader.Load(files[0]) : GetBitmapSourceThumb(files[0]);
            }
        }
예제 #6
0
        internal static void Click(int id)
        {
            LoadWindows.GetMainWindow.Focus();

            if (Properties.Settings.Default.PicGallery == 1)
            {
                if (Preloader.Contains(Pics[id]))
                {
                    PreviewItemClick(Preloader.Load(Pics[id]), id);
                }
                else
                {
                    var z = GetPicGallery.Container.Children[id] as UserControls.PicGalleryItem;
                    PreviewItemClick(z.img.Source, id);
                }

                if (WindowLogic.AutoFitWindow)
                {
                    GetPicGallery.Width  = xWidth;
                    GetPicGallery.Height = xHeight;
                }

                GetPicGallery.x2.Visibility = Visibility.Hidden;

                LoadWindows.GetMainWindow.MainImage.Source = null;

                var img = new Image()
                {
                    Source              = GetThumb(id),
                    Stretch             = Stretch.Fill,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                };

                // Need to add border for background to pictures with transparent background
                var border = new Border()
                {
                    Background = ConfigureSettings.ConfigColors.GetBackgroundColorBrush()
                };
                border.Child = img;
                GetPicGallery.grid.Children.Add(border);

                var from         = picGalleryItem_Size;
                var to           = new double[] { xWidth, xHeight };
                var acceleration = 0.2;
                var deceleration = 0.4;
                var duration     = TimeSpan.FromSeconds(.3);

                AnimationHelper.Fade(GetPicGallery.Container, duration, TimeSpan.Zero, 1, 0);

                var da = new DoubleAnimation
                {
                    From              = 0,
                    To                = to[0],
                    Duration          = duration,
                    AccelerationRatio = acceleration,
                    DecelerationRatio = deceleration,
                    FillBehavior      = FillBehavior.Stop
                };

                var da0 = new DoubleAnimation
                {
                    From              = 0,
                    To                = to[1],
                    Duration          = duration,
                    AccelerationRatio = acceleration,
                    DecelerationRatio = deceleration,
                    FillBehavior      = FillBehavior.Stop
                };

                da.Completed += delegate
                {
                    ItemClick(id);
                    GetPicGallery.grid.Children.Remove(border);
                    img    = null;
                    IsOpen = false;
                };

                border.BeginAnimation(FrameworkElement.WidthProperty, da);
                border.BeginAnimation(FrameworkElement.HeightProperty, da0);
            }
            else
            {
                ItemClick(id);
            }
        }
예제 #7
0
        internal static void Paste()
        {
            // file

            if (Clipboard.ContainsFileDropList()) // If Clipboard has one or more files
            {
                var files = Clipboard.GetFileDropList().Cast <string>().ToArray();

                if (files != null)
                {
                    if (files.Length >= 1)
                    {
                        var x = files[0];

                        if (Pics.Count != 0)
                        {
                            // If from same folder
                            if (!string.IsNullOrWhiteSpace(Pics[FolderIndex]) && Path.GetDirectoryName(x) == Path.GetDirectoryName(Pics[FolderIndex]))
                            {
                                if (!Preloader.Contains(x))
                                {
                                    PreloadCount = 4;
                                    Preloader.Add(x);
                                }

                                Pic(Pics.IndexOf(x));
                            }
                            else
                            {
                                Pic(x);
                            }
                        }
                        else
                        {
                            Pic(x);
                        }

                        if (files.Length > 1)
                        {
                            for (int i = 1; i < files.Length; i++)
                            {
                                using (var n = new Process())
                                {
                                    n.StartInfo.FileName  = Assembly.GetExecutingAssembly().Location;
                                    n.StartInfo.Arguments = files[i];
                                    n.Start();
                                }
                            }
                        }
                    }
                    return;
                }
            }

            // Clipboard Image
            if (Clipboard.ContainsImage())
            {
                Pic(Clipboard.GetImage(), "Clipboard Image");
                return;
            }

            // text/string/adddress

            var s = Clipboard.GetText(TextDataFormat.Text);

            if (string.IsNullOrEmpty(s))
            {
                return;
            }

            if (FilePathHasInvalidChars(s))
            {
                MakeValidFileName(s);
            }

            s = s.Replace("\"", "");
            s = s.Trim();

            if (File.Exists(s))
            {
                Pic(s);
            }
            else if (Directory.Exists(s))
            {
                ChangeFolder();
                Pics = FileList(s);
                if (Pics.Count > 0)
                {
                    Pic(Pics[0]);
                }
                else if (!string.IsNullOrWhiteSpace(Pics[FolderIndex]))
                {
                    Pic(Pics[FolderIndex]);
                }
                else
                {
                    Unload();
                }
            }
            else if (Uri.IsWellFormedUriString(s, UriKind.Absolute)) // Check if from web
            {
                LoadFromWeb.PicWeb(s);
            }
            else
            {
                ToolTipStyle("An error occured while trying to paste file");
            }
        }