예제 #1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var openFile = new OpenFileDialog()
            {
                DefaultExt       = "jpg",
                AddExtension     = true,
                Filter           = "Bitmap files (*.bmp)|*.bmp|Image files (*.jpg)|*.jpg|Image files (*.jpeg)|*.jpeg|Gif files (*.gif)|*.gif|PNG files (*.png)|*.png",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            };

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                PathToOpenFolder = null;
                ImageFiles.Clear();
                PathToFile = openFile.FileName;
            }
            try
            {
                panelBitmap = new Bitmap(panel1.Width - 15, panel1.Height);
                panel1.AutoScrollMinSize = new Size(0, 900);
                var img     = new Bitmap(PathToFile);
                var drawImg = Graphics.FromImage(panelBitmap);
                var imgSize = new Rectangle(0, 0, panel1.Width - 15, (int)(img.Height / (img.Width / (double)(panel1.Width - 15))));
                drawImg.DrawImage(img, imgSize);
                pictureBox1.Image = null;
                pictureBox1.Tag   = null;
                panel1.Refresh();
            }
            catch
            {
            }
        }
 protected async void OnCancelCommand()
 {
     try
     {
         //dont exit app on sharing
         if ((!SharingProcess) && (ImageFiles == null || ImageFiles?.Count == 0) || (_selectedFiles == null || _selectedFiles?.Count() != 0))
         {
             _applicationService.Exit();
         }
         else
         {
             foreach (var imagefile in ImageFiles)
             {
                 if (imagefile != null)
                 {
                     imagefile.Stream?.Dispose();
                     imagefile.Stream = null;
                 }
             }
             ImageFiles.Clear();
             LastFile?.Stream?.Dispose();
             LastFile = null;
         }
         SharingProcess = false;
         await _localSettings.SaveSettingsAsync();
     }
     catch (Exception e)
     {
         _loggerService?.LogException(nameof(OnCancelCommand), e);
     }
     _loggerService?.LogEvent(nameof(OnCancelCommand));
 }
예제 #3
0
        private void BtnOpenFolder_OnClick(object sender, RoutedEventArgs e)
        {
            var folderBrowserDialog = new FolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                TxtFolder.Text = SelectedFolder = folderBrowserDialog.SelectedPath;
                ImageFiles.Clear();
                var imageFiles = MediaFileParser.ReadAllFiles(SelectedFolder);
                imageFiles.ForEach(ImageFiles.Add);
            }
        }
예제 #4
0
 private void UnloadFiles()
 {
     foreach (var item in ImageFiles)
     {
         item.Stream?.Dispose();
         item.Stream = null;
         if (item.Tag is Image img)
         {
             img.Dispose();
         }
     }
     ImageFiles.Clear();
 }
예제 #5
0
        private async void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new FileOpenPicker();

            picker.FileTypeFilter.Add(".png");
            picker.FileTypeFilter.Add(".jpg");
            var list = await picker.PickMultipleFilesAsync();

            imageFiles.Clear();
            imageFiles.SetStorage(list);
            this.PageSlider.Maximum = imageFiles.count;
            this.PageSlider.Minimum = 1;
            await this.show_specified_image(0);
        }
예제 #6
0
        private void OnFileListChanged(object o, string[] files)
        {
            Application.Current.Dispatcher.BeginInvoke(new System.Action(() =>
            {
                TerminaFiles.Clear();
                foreach (var file in files)
                {
                    TerminaFiles.Add(file);
                }

                ImageFiles.Clear();
                var images = TerminaFiles.Where(x => Path.GetExtension(x) == ".png").ToList();
                images.ForEach(x => ImageFiles.Add(x));
                ImageFile = ImageFiles.FirstOrDefault();
            }));
        }