91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 0.06M
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2020-12-14
  • 語(yǔ)言: C#
  • 標(biāo)簽: wpf??拖拽??wp??

資源簡(jiǎn)介

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ImageExplorer
{
    /// <summary>
    /// MainWindow.xaml 的交互邏輯
    /// </summary>
    public partial class MainWindow : Window
    {
        private BitmapImage bmi;
        private string path;

        public MainWindow()
        {
            InitializeComponent();
            path = Environment.CurrentDirectory @"\image\";
            GetImage();
        }

        private void GetImage()
        {
            string[] files = Directory.GetFiles(path);
foreach (string file in files)
{
lstImage.Items.Add(file);
}

        }

        private void lstImage_Drop(object sender, DragEventArgs e)
        {
            //僅支持文件的拖放
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            //獲取拖拽的文件
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            //這里需要注意,由于程序既支持拖過來(lái)也支持拖過去,那么ListBox就也能接收自身拖拽過來(lái)的文件
            //為了防止鼠標(biāo)點(diǎn)擊和拖拽的沖突,需要屏蔽從程序自身拖拽過來(lái)的文件
            //這里判斷文件是否從程序外部拖拽進(jìn)來(lái),也就是判斷圖片是否在工作目錄下
            if (files.Length > 0 && !files[0].StartsWith(path) &&
                (e.AllowedEffects & DragDropEffects.Copy) == DragDropEffects.Copy)
            {
                e.Effects = DragDropEffects.Copy;
            }
            else
            {
                e.Effects = DragDropEffects.None;
            }

            foreach (string file in files)
            {
                try
                {
                    //如果是從外部拖拽進(jìn)來(lái)的圖像,則復(fù)制該文件到工作目錄下做備份
                    string destFile = path System.IO.Path.GetFileName(file);

                    switch (e.Effects)
                    {
                        case DragDropEffects.Copy:
                            File.Copy(file, destFile, false);
                            bmi = new BitmapImage(new Uri(destFile));
                            imgShow.Source = bmi;
                            lstImage.Items.Add(destFile);
                            break;
                        default:
                            break;
                    }
                }
                catch
                {
                    MessageBox.Show("已存在此文件或?qū)肓朔菆D像文件!");
                }

            }
        }

        private void lstImage_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed && e.RightButton == MouseButtonState.Released)
            {
                bmi = new BitmapImage(new Uri(lstImage.SelectedItem.ToString()));
                imgShow.Source = bmi;
            }
        }


        private void lstImage_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstImage.SelectedIndex > -1)
            {
                //只使用了Listbox單選功能
                string[] files = new string[1];
                files[0] = lstImage.SelectedItem.ToString();

                DragDrop.DoDragDrop(lstImage, new DataObject(DataFormats.FileDrop, files), DragDropEffects.Copy | DragDropEffects.Move /* | DragDropEffects.Link */);
            }
        }



    }
}

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Configuration;
using?System.Data;
using?System.Linq;
using?System.Windows;

namespace?ImageExplorer
{
????///?
????///?App.xaml?的交互邏輯
????///?

????public?partial?class?App?:?Application
????{
????}
}

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件????????324??2013-05-28?14:44??ImageExplorer\ImageExplorer\App.xaml

?????文件????????309??2013-05-28?14:44??ImageExplorer\ImageExplorer\App.xaml.cs

?????文件??????11776??2013-05-29?14:51??ImageExplorer\ImageExplorer\bin\Debug\ImageExplorer.exe

?????文件??????30208??2013-05-29?14:51??ImageExplorer\ImageExplorer\bin\Debug\ImageExplorer.pdb

?????文件??????22472??2013-05-29?15:31??ImageExplorer\ImageExplorer\bin\Debug\ImageExplorer.vshost.exe

?????文件????????490??2012-06-02?22:34??ImageExplorer\ImageExplorer\bin\Debug\ImageExplorer.vshost.exe.manifest

?????文件???????4401??2013-05-28?15:14??ImageExplorer\ImageExplorer\ImageExplorer.csproj

?????文件????????884??2013-05-29?16:05??ImageExplorer\ImageExplorer\MainWindow.xaml

?????文件???????3967??2013-05-29?16:05??ImageExplorer\ImageExplorer\MainWindow.xaml.cs

?????文件???????2319??2013-05-28?15:14??ImageExplorer\ImageExplorer\obj\Debug\App.g.cs

?????文件???????2319??2013-05-28?15:58??ImageExplorer\ImageExplorer\obj\Debug\App.g.i.cs

?????文件???????7035??2013-05-29?16:05??ImageExplorer\ImageExplorer\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

?????文件???????1009??2013-05-29?15:31??ImageExplorer\ImageExplorer\obj\Debug\ImageExplorer.csproj.FileListAbsolute.txt

?????文件????????917??2013-05-28?15:00??ImageExplorer\ImageExplorer\obj\Debug\ImageExplorer.csproj.GenerateResource.Cache

?????文件???????2501??2013-05-28?15:14??ImageExplorer\ImageExplorer\obj\Debug\ImageExplorer.csprojResolveAssemblyReference.cache

?????文件??????11776??2013-05-29?14:51??ImageExplorer\ImageExplorer\obj\Debug\ImageExplorer.exe

?????文件???????1465??2013-05-29?14:32??ImageExplorer\ImageExplorer\obj\Debug\ImageExplorer.g.resources

?????文件??????30208??2013-05-29?14:51??ImageExplorer\ImageExplorer\obj\Debug\ImageExplorer.pdb

?????文件????????180??2013-05-28?15:14??ImageExplorer\ImageExplorer\obj\Debug\ImageExplorer.Properties.Resources.resources

?????文件????????269??2013-05-29?14:51??ImageExplorer\ImageExplorer\obj\Debug\ImageExplorer_MarkupCompile.cache

?????文件????????268??2013-05-29?16:05??ImageExplorer\ImageExplorer\obj\Debug\ImageExplorer_MarkupCompile.i.cache

?????文件???????1237??2013-05-29?14:32??ImageExplorer\ImageExplorer\obj\Debug\MainWindow.baml

?????文件???????4659??2013-05-29?14:32??ImageExplorer\ImageExplorer\obj\Debug\MainWindow.g.cs

?????文件???????4659??2013-05-29?15:32??ImageExplorer\ImageExplorer\obj\Debug\MainWindow.g.i.cs

?????文件???????2179??2013-05-28?14:44??ImageExplorer\ImageExplorer\Properties\AssemblyInfo.cs

?????文件???????2878??2013-05-28?14:44??ImageExplorer\ImageExplorer\Properties\Resources.Designer.cs

?????文件???????5612??2013-05-28?14:44??ImageExplorer\ImageExplorer\Properties\Resources.resx

?????文件???????1100??2013-05-28?14:44??ImageExplorer\ImageExplorer\Properties\Settings.Designer.cs

?????文件????????201??2013-05-28?14:44??ImageExplorer\ImageExplorer\Properties\Settings.settings

?????文件????????929??2013-05-28?14:44??ImageExplorer\ImageExplorer.sln

............此處省略13個(gè)文件信息

評(píng)論

共有 條評(píng)論