lvle 1 ano atrás
pai
commit
a9bc756b2b

+ 28 - 0
PDF Office/Helper/CacheFilePath.cs

@@ -27,6 +27,12 @@ namespace PDF_Master.Helper
         List<string> SignatureStamp = new List<string> { "Signature", "Stamp" };
         List<string> MergeFile = new List<string> { "Temp" };
 
+        /// <summary>
+        /// 扫描仪缓存文件夹路径
+        /// </summary>
+        List<string> ScanFile = new List<string> { "ScanTemp" };
+
+
         private CPDFDocument copyDoc;
         /// <summary>
         /// 页面编辑复制粘贴的临时缓存文件
@@ -99,6 +105,19 @@ namespace PDF_Master.Helper
             }
         }
 
+
+
+        /// <summary>
+        /// 扫描仪文件的缓存文件夹
+        /// </summary>
+        public string ScanFilePath
+        {
+            get
+            {
+                return CreateCacheDirectory(ScanFile);
+            }
+        }
+
         /// <summary>
         ///  在“文档”路径下创建缓存文件夹,传C:\Users\kdan\Documents\PDF Master 以后的文件夹名
         /// </summary>
@@ -177,6 +196,15 @@ namespace PDF_Master.Helper
                 }
                 Settings.Default.AppProperties.NeedToDeletePath.Clear();
 
+                //清除ScanTemp文件夹及该目录中的所有子内容
+                string ScanTempPath = Path.Combine(App.CurrentPath, "ScanTemp");
+                DirectoryInfo Scantempfolder = new DirectoryInfo(ScanTempPath);
+                if (Scantempfolder.Exists)
+                {
+                    Directory.Delete(ScanTempPath, true);
+                }
+
+
                 //清除Temp文件夹及该目录中的所有子内容
                 string TempPath= Path.Combine(App.CurrentPath, "Temp");
                 DirectoryInfo tempfolder = new DirectoryInfo(TempPath);

BIN
PDF Office/Interop.WIA.dll


+ 4 - 0
PDF Office/PDF Master.csproj

@@ -156,6 +156,10 @@
     <Reference Include="Google.Apis.PlatformServices, Version=1.57.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
       <HintPath>packages\Google.Apis.1.57.0\lib\net45\Google.Apis.PlatformServices.dll</HintPath>
     </Reference>
+    <Reference Include="Interop.WIA">
+      <HintPath>.\Interop.WIA.dll</HintPath>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </Reference>
     <Reference Include="Magick.NET-Q16-AnyCPU, Version=12.2.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
       <HintPath>packages\Magick.NET-Q16-AnyCPU.12.2.2\lib\netstandard20\Magick.NET-Q16-AnyCPU.dll</HintPath>
     </Reference>

+ 134 - 176
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/CreateFromScannerDialogsViewModel.cs

@@ -1,23 +1,33 @@
-using NTwain;
+using ComPDFKit.PDFDocument;
+using NTwain;
 using NTwain.Data;
+using PDF_Master.CustomControl;
+using PDF_Master.Helper;
 using PDF_Master.Model;
 using Prism.Commands;
 using Prism.Mvvm;
+using Prism.Regions;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Reflection;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
 using System.Windows.Interop;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
+using WIA;
 
 namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs
 {
+    
 
     //扫描仪设备
     public class ScannerItem : BindableBase
@@ -34,238 +44,186 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs
     public class CreateFromScannerDialogsViewModel : BindableBase, IDialogAware
     {
 
+
+        public static ImageFile imageFile;
         private List<ScannerItem> _scanners = new List<ScannerItem>();
         public List<ScannerItem> Scanners
         {
             get { return _scanners; }
             set => SetProperty(ref _scanners, value);
         }
-        //图片
-        private ImageSource _img;
-        public ImageSource Img
+
+        public string Title => "";
+        //图片路径
+        public string FilePath { get; private set; }
+        public event Action<IDialogResult> RequestClose;
+        public virtual void RaiseRequestClose(IDialogResult dialogResult)
         {
-            get { return _img; }
-            set => SetProperty(ref _img, value);
+            RequestClose?.Invoke(dialogResult);
         }
 
-       //没有检测到扫描仪
-        private bool _isEmptyScanner;
-        public bool IsEmptyScanner
+        #region 框架
+        public bool CanCloseDialog()
         {
-            get { return _isEmptyScanner; }
-            set => SetProperty(ref _isEmptyScanner, value);
+            return true;
         }
 
-        //没有生成图片
-        private bool isEmptyImg;
-        public bool IsEmptyImg
+        public void OnDialogClosed()
         {
-            get { return isEmptyImg; }
-            set => SetProperty(ref isEmptyImg, value);
+
         }
 
-        public string Title => "";
-        //图片路径
-        public string FilePath { get; private set; }
-        private bool IsScanner = false;
-        public event Action<IDialogResult> RequestClose;
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+
+        }
+        #endregion
 
-        private TwainSession twain;
 
 
-        public DelegateCommand CancelCommand { get; set; }
+     
+
+        //没有检测到扫描仪
+        private int _SeIndex=0;
+        public int SeIndex
+        {
+            get { return _SeIndex; }
+            set => SetProperty(ref _SeIndex, value);
+        }
+
+
+        public MainContentViewModel mainContentViewModel;
+        public DelegateCommand ToScanCommand { get; set; }
         public DelegateCommand CreateCommand { get; set; }
         public DelegateCommand<object> SelectedScannerCommand { get; set; }
 
-        public CreateFromScannerDialogsViewModel()
-        {
-            CancelCommand = new DelegateCommand(cancel);
-            CreateCommand = new DelegateCommand(createFile, CanExcuteCreateFile).ObservesProperty(() => Img);
-            SelectedScannerCommand = new DelegateCommand<object>(SelectedScanner);
 
-            SetupTwain();
 
-            if (Scanners.Count > 0)
-                IsEmptyScanner = false;
-            else
-                IsEmptyScanner = true;
+        CreateFromScannerDialogsViewModel(IRegionManager regionManager, IDialogService dialogService)
+        {
+
+            ToScanCommand = new DelegateCommand(ToScan);
         }
 
-        //选择扫描仪
-        private void SelectedScanner(object obj)
+        public void ToScan()
         {
-            if(obj != null)
-            {
-                if (twain.State == 4)
-                {
-                    twain.CurrentSource.Close();
-                }
-                Img = null;
-                OpenSaveScanner();
-                var result = obj as ScannerItem;
-                if (result.DataSourceItem.Open() != ReturnCode.Success)
-                    MessageBox.Show("连接失败");
-                else
-                {
-                    
-                }
-                Preview();
-            }
-            
+            imageFile = Scan();
+
         }
 
-        //启动检测扫描仪
-        private void SetupTwain()
-        {
-            var appId = TWIdentity.CreateFromAssembly(DataGroups.Image, Assembly.GetEntryAssembly());
-            twain = new TwainSession(appId);
-            twain.Open();
-            //Todo:在程序32位时,可正常扫描;
-            //在程序64位时,不能正常获取扫描仪,并崩溃:找不到TWAINDSM.DLL模块。
 
-            foreach (var s in twain.Select(s => new { DS = s }))
-            {
-                var item = new ScannerItem(s.DS);
-                Scanners.Add(item);
-            }
+        public ImageFile Scan()
+        {
+            ImageFile image = null;
+            DeviceManager deviceManager;
+            deviceManager = new DeviceManager();
+            Device device;
 
-            twain.TransferError += (s, e) =>
-            {
-                CloseSaveScanner();
-               // MessageBox.Show("图片传输错误:" + e.Exception.Message);
-            };
-            twain.DataTransferred += _session_DataTransferred;
-            twain.SourceDisabled += (s, e) =>
-            {
-                //MessageBox.Show("源数据已清除");
-            };
-            twain.TransferReady += (s, e) =>
+            try
             {
-                //MessageBox.Show("数据传输就绪");
-            };
 
-            twain.SynchronizationContext = System.Threading.SynchronizationContext.Current;
-        }
+                WIA.CommonDialog dialog = new WIA.CommonDialog();
 
-        //生成图片+预览图片
-        private void _session_DataTransferred(object sender, DataTransferredEventArgs e)
-        {
-            if (IsScanner)
-            {
-                string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
-                FilePath = docPath + "\\" + DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss") + ".png";
-
-                var encoder = new PngBitmapEncoder();
-                encoder.Frames.Add(BitmapFrame.Create(e.GetNativeImageStream().ConvertToWpfBitmap(300, 0)));
-                var test = encoder.Frames[0];
-                FileStream fileStream = new FileStream(FilePath, FileMode.Create, FileAccess.ReadWrite);
-                encoder.Save(fileStream);
-                fileStream.Close();
-                CloseSaveScanner();
-            }
 
-            ImageSource img = GenerateThumbnail(e);
-            if (img != null)
-            {
-                App.Current.Dispatcher.BeginInvoke(new Action(() =>
+                Items items;
+                for (int i = 1, j = 0; i <= deviceManager.DeviceInfos.Count; i++)
                 {
-                    Img = img;
-                }));
-            }
-        }
 
-        //图片缩略图
-        private ImageSource GenerateThumbnail(DataTransferredEventArgs e)
-        {
-            BitmapSource img = null;
+                    if (deviceManager.DeviceInfos[i].Type != WiaDeviceType.ScannerDeviceType)
+                    {
+                        continue;
+                    }
 
-            switch (e.TransferType)
-            {
-                case XferMech.Native:
-                    using (var stream = e.GetNativeImageStream())
+                    if (j == SeIndex)
                     {
-                        if (stream != null)
+                        device = deviceManager.DeviceInfos[i].Connect();
+                        items = dialog.ShowSelectItems(device, SingleSelect: true);
+                        if (items != null)
                         {
-                            // twain.CurrentSource.Capabilities.ICapYResolution.SetValue();
-                            img = stream.ConvertToWpfBitmap(300, 0);
+                            image = dialog.ShowTransfer(device.Items[1]);
+                            ToImage(image);
                         }
                     }
-                    break;
-                case XferMech.File:
-                    img = new BitmapImage(new Uri(e.FileDataPath));
-                    if (img.CanFreeze)
-                    {
-                        img.Freeze();
-                    }
-                    break;
-                case XferMech.Memory:
-                    // TODO: build current image from multiple data-xferred event
-                    break;
-            }
-            return img;
-        }
+                    j++;
+                }
 
-        //预览图片
-        private void Preview()
-        {
-            if (twain.CurrentSource == null) return;
+                if (image != null)
+                {
 
-            var windowsPtr = new WindowInteropHelper(Window.GetWindow(App.Current.MainWindow)).Handle;
-            twain.CurrentSource.Enable(SourceEnableMode.NoUI, false, windowsPtr);
+                }
+                return image;
+            }
+            catch (COMException ex)
+            {
+                if (ex.ErrorCode == -2145320939)
+                {
+                    //throw new ScannerNotFoundException();
+                }
+                else
+                {
+                    //throw new ScannerException("COM Exception", ex);
+                }
+                return null;
+            }
         }
 
-        private void CloseSaveScanner()
-        {
-            IsScanner = false;
-        }
 
-        private void OpenSaveScanner()
-        {
-            IsScanner = true;
-        }
-        /// <summary>
-        /// 是否可以创建
-        /// </summary>
-        /// <returns></returns>
-        private bool CanExcuteCreateFile()
+        public void ToImage(ImageFile img)
         {
-            if (Img == null)
-                IsEmptyImg = true;
-            else
-                IsEmptyImg = false;
+            //System.Windows.Forms.SaveFileDialog mys = new System.Windows.Forms.SaveFileDialog();
+            //mys.FileName = "MergeDocuments";
+            //mys.Filter = "bmp文件|*.bmp";
+            ////mys.ShowDialog();
+            //string myFileN = mys.FileName.ToString();
+            //myFileN = "C\\";//要保存的文件路径
+            //string FileName = myFileN+ mys.FileName;
+            //FileName = (FileName.Remove(0, FileName.Length - 4).Contains(".bmp")) ? FileName : FileName + ".bmp";
+            //System.IO.Directory.CreateDirectory("C\\img.bmp");
+            if (img != null)
 
-            return (Img != null);
-        }
+            {
+                //System.IO.Directory.CreateDirectory("C\\img.bmp");
+                string path = App.CachePath.ScanFilePath;
+                string FileName = path+ "\\"+ Guid.NewGuid().ToString() + ".bmp";
+                //File.Create(FileName);
+                img.SaveFile(FileName);
+                string keyy = "Imagepath";
+                DialogParameters keyValues = new DialogParameters();
+                keyValues.Add(keyy, FileName);
+                RaiseRequestClose(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK, keyValues));
+                App.CachePath.AddToDeleteFiles(path);
 
-        //扫描,创建文件
-        private void createFile()
-        {
-            DialogParameters valuePairs = new DialogParameters();
-            valuePairs.Add(ParameterNames.DataModel, FilePath);
-            RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
-        }
 
-        private void cancel()
-        {
-            RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
-        }
+            }
+
 
-        #region 框架
-        public bool CanCloseDialog()
-        {
-            return true;
         }
 
-        public void OnDialogClosed()
+
+        private void JpegInsertPage(ref CPDFDocument topdfdoc, string filename, FileInfo fileinfo, int width, int height, int index = 0)
         {
 
+            string tempFileName = "";
+            if (fileinfo.Extension == ".jpg" || fileinfo.Extension == ".jpeg")
+            {
+                topdfdoc.InsertPage(index, width, height, filename);
+            }
+            else
+            {
+                tempFileName = Path.GetTempPath() + "pngtemp.jpg";
+                if (!PictureConverter.SaveJpeg(filename, tempFileName))
+                {
+                    MessageBoxEx.Show("图片格式有问题");
+                }
+                topdfdoc.InsertPage(index, width, height, tempFileName);
+            }
         }
 
-        public void OnDialogOpened(IDialogParameters parameters)
-        {
 
+        public string savefilename(string filename, string filepath)
+        {
+            FileInfo file = new FileInfo(filename);
+            return CommonHelper.CreateFilePath(filepath  + file.Name.Replace(file.Extension, ".pdf") );
         }
-        #endregion
-
     }
-}
+}

+ 0 - 4
PDF Office/ViewModels/Dialog/ServiceDialog/LoginPasswordRegionViewModel.cs

@@ -287,10 +287,6 @@ namespace PDF_Master.ViewModels.Dialog.ServiceDialog
                 App.mainWindowViewModel.OphVis = Visibility.Collapsed;
                 Settings.Default.UserDate.Email = LoginEmail;
             }
-            else if(ServiceHelper.Login(LoginEmail, LoginPassword, uuid) == "300")
-            {
-                LoginDialogViewModel.RegionMan("NOInternetRegion");
-            }
            
             else
             {

+ 4 - 2
PDF Office/ViewModels/HomeContentViewModel.cs

@@ -15,6 +15,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
+using WIA;
 
 namespace PDF_Master.ViewModels
 {
@@ -280,8 +281,9 @@ namespace PDF_Master.ViewModels
                 if (e.Result == ButtonResult.OK)
                 {
                     IsLoading = Visibility.Visible;
-                    var model = e.Parameters.GetValue<string>(ParameterNames.DataModel);
-                    mainContentViewModel.CreateFile(model);
+                    string path;
+                    e.Parameters.TryGetValue("Imagepath", out path);
+                    mainContentViewModel.CreateFile(path);
                     IsLoading = Visibility.Collapsed;
 
                 }

+ 7 - 0
PDF Office/ViewModels/MainContentViewModel.cs

@@ -27,6 +27,7 @@ using ComPDFKit.PDFDocument;
 using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
 using PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs;
 using PDF_Master.Properties;
+using WIA;
 
 namespace PDF_Master.ViewModels
 {
@@ -371,6 +372,12 @@ namespace PDF_Master.ViewModels
             return true;
         }
 
+
+
+
+
+
+
         /// <summary>
         /// 创建文件,路径为空时表示创建空白文档
         /// 否则表示从图片路径创建PDf

+ 6 - 1
PDF Office/ViewModels/MainWindowViewModel.cs

@@ -23,13 +23,14 @@ using Prism.Services.Dialogs;
 using PDF_Master.Properties;
 using PDF_Master.Helper;
 using PDFSettings.Settings;
+using PDF_Master.ViewModels.Dialog.ServiceDialog;
 
 namespace PDF_Master.ViewModels
 {
     public class MainWindowViewModel : BindableBase
     {
         private MainContent selectedItem;
-
+        private LoginDialogViewModel LoginDialogViewModel ;
 
         #region 文案
 
@@ -328,7 +329,9 @@ namespace PDF_Master.ViewModels
                     catch { }
                 }
                 ));
+
                 App.IsFirstOpen = false;
+
                 if (Settings.Default.AppProperties.LoginToken != "")
                 {
                     
@@ -336,6 +339,8 @@ namespace PDF_Master.ViewModels
                     {
                        
                         LoginVis = Visibility.Visible;
+                        LoginDialogViewModel.RegionMan("NOInternetRegion");
+                        
                         OphVis = Visibility.Visible;
 
                     }

+ 42 - 192
PDF Office/Views/Dialog/HomePageToolsDialogs/CreateFromScannerDialogs.xaml

@@ -3,198 +3,48 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:cus="clr-namespace:PDF_Master.CustomControl"
-             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
-             xmlns:prism="http://prismlibrary.com/" 
-             xmlns:dataconvert="clr-namespace:PDF_Master.DataConvert"
-             xmlns:local="clr-namespace:PDF_Master.Views.Dialog.HomePageToolsDialogs"
+             xmlns:prism="http://prismlibrary.com/"
+             prism:Dialog.WindowStyle="{StaticResource DialogWindowStyle}"
+             prism:ViewModelLocator.AutoWireViewModel="True"
              mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
-    <UserControl.Resources>
-        <dataconvert:BoolToVisible x:Key="BoolToVisible"/>
-        <dataconvert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
-        <Style x:Key="ScannerListViewItemStyle" TargetType="{x:Type ListViewItem}">
-            <Setter Property="UIElement.SnapsToDevicePixels" Value="True" />
-            <Setter Property="Panel.Background" Value="#00FFFFFF" />
-            <Setter Property="Border.BorderBrush" Value="#00FFFFFF" />
-            <Setter Property="Border.BorderThickness" Value="1" />
-            <Setter Property="FrameworkElement.FocusVisualStyle">
-                <Setter.Value>
-                    <Style TargetType="{x:Type IFrameworkInputElement}">
-                        <Setter Property="Control.Template">
-                            <Setter.Value>
-                                <ControlTemplate>
-                                    <Rectangle
-                                    Margin="2"
-                                    SnapsToDevicePixels="True"
-                                    Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
-                                    StrokeDashArray="1 2"
-                                    StrokeThickness="1" />
-                                </ControlTemplate>
-                            </Setter.Value>
-                        </Setter>
-                    </Style>
-                </Setter.Value>
-            </Setter>
-            <Setter Property="Control.Template">
-                <Setter.Value>
-                    <ControlTemplate TargetType="{x:Type ListViewItem}">
-                        <Border
-                        Name="Bd"
-                        Padding="{TemplateBinding Control.Padding}"
-                        Background="{TemplateBinding Panel.Background}"
-                        BorderBrush="{TemplateBinding Border.BorderBrush}"
-                        BorderThickness="{TemplateBinding Border.BorderThickness}"
-                        SnapsToDevicePixels="True">
-                            <Grid>
-                                <Grid.ColumnDefinitions>
-                                    <ColumnDefinition Width="Auto" />
-                                    <ColumnDefinition />
-                                </Grid.ColumnDefinitions>
-                                <Grid
-                                x:Name="SelectedIcon"
-                                Margin="12.5,0,0.5,0"
-                                HorizontalAlignment="Left"
-                                VerticalAlignment="Center"
-                                Visibility="Collapsed">
-                                    <Rectangle
-                                    x:Name="Selectedrect"
-                                    Width="20"
-                                    Height="20"
-                                    HorizontalAlignment="Right"
-                                    VerticalAlignment="Top"
-                                    Fill="#FF477EDE" />
-                                    <Path
-                                    x:Name="MultiSelectCheck"
-                                    Width="15"
-                                    Height="15"
-                                    Margin="0,1,0,0"
-                                    HorizontalAlignment="Center"
-                                    VerticalAlignment="Center"
-                                    Data="M15.3493 0.596191L16.0564 1.3033L5.44979 11.9099L0.146484 6.6066L0.853591 5.89949L5.45004 10.496L15.3493 0.596191Z"
-                                    Fill="White" />
-                                </Grid>
-                                <ContentPresenter
-                                Grid.Column="1"
-                                Margin="0,0,0,0"
-                                HorizontalAlignment="Stretch"
-                                VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
-                                Content="{TemplateBinding ContentControl.Content}"
-                                ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
-                                ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
-                                SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
-                                <Rectangle
-                                Grid.Column="1"
-                                Height="1"
-                                HorizontalAlignment="Stretch"
-                                VerticalAlignment="Bottom"
-                                Fill="#C5CBD3" />
-                            </Grid>
-                        </Border>
-                        <ControlTemplate.Triggers>
-                            <MultiTrigger>
-                                <MultiTrigger.Conditions>
-                                    <Condition Property="UIElement.IsMouseOver" Value="True" />
-                                </MultiTrigger.Conditions>
-                                <Setter TargetName="Bd" Property="Panel.Background" Value="{StaticResource color.item-state.hov.bg}" />
-                                <!--<Setter TargetName="Bd" Property="Border.BorderBrush" Value="#1A000000" />-->
-                            </MultiTrigger>
-                            <MultiTrigger>
-                                <MultiTrigger.Conditions>
-                                    <Condition Property="Selector.IsSelectionActive" Value="False" />
-                                    <Condition Property="Selector.IsSelected" Value="True" />
-                                </MultiTrigger.Conditions>
-                                <Setter TargetName="Bd" Property="Panel.Background" Value="{StaticResource color.item-state.sel.bg.lv3}" />
-                                <!--<Setter TargetName="Bd" Property="Border.BorderBrush" Value="#1A477EDE" />-->
-                                <!--<Setter TargetName="SelectedIcon" Property="Grid.Visibility" Value="Visible" />-->
-                            </MultiTrigger>
-                            <MultiTrigger>
-                                <MultiTrigger.Conditions>
-                                    <Condition Property="Selector.IsSelectionActive" Value="True" />
-                                    <Condition Property="Selector.IsSelected" Value="True" />
-                                </MultiTrigger.Conditions>
-                                <Setter TargetName="Bd" Property="Panel.Background" Value="{StaticResource color.item-state.sel.bg.lv3}" />
-                                <!--<Setter TargetName="Bd" Property="Border.BorderBrush" Value="#1A477EDE" />-->
-                                <!--<Setter TargetName="SelectedIcon" Property="Grid.Visibility" Value="Visible" />-->
-                            </MultiTrigger>
-                            <Trigger Property="UIElement.IsEnabled" Value="False">
-                                <Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
-                            </Trigger>
-                        </ControlTemplate.Triggers>
-                    </ControlTemplate>
-                </Setter.Value>
-            </Setter>
-        </Style>
-        <DataTemplate x:Key="ScannerItemTemplate">
-            <TextBlock Text="{Binding ScannerName}">
-            </TextBlock>
-        </DataTemplate>
-    </UserControl.Resources>
-    <cus:DialogContent Header="Create PDF from scanner">
-        <Grid>
-            <Grid Height="406" Margin="16,0,16,0"
-                  Visibility="{Binding IsEmptyScanner,Converter={StaticResource InvertBoolToVisibleConvert}}"
-                  >
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="360"/>
-                    <ColumnDefinition Width="16"/>
-                    <ColumnDefinition Width="312"/>
-                </Grid.ColumnDefinitions>
-
-                <Border Background="{StaticResource color.sys.layout.mg}">
-                    <Grid>
-                        <Grid.RowDefinitions>
-                            <RowDefinition Height="Auto"/>
-                            <RowDefinition/>
-                        </Grid.RowDefinitions>
-                        <TextBlock Text="Scanners"/>
-                        <ListView Grid.Row="1" x:Name="listScanner" 
-                              ItemsSource="{Binding Scanners}"
-                              ItemContainerStyle="{StaticResource ScannerListViewItemStyle}"
-                              ItemTemplate="{StaticResource ScannerItemTemplate}"
-                              >
-                            <i:Interaction.Triggers>
-                                <i:EventTrigger EventName="SelectionChanged">
-                                    <i:InvokeCommandAction Command="{Binding SelectedScannerCommand}" CommandParameter="{Binding ElementName=listScanner,Path=SelectedItem}"/>
-                                </i:EventTrigger>
-                            </i:Interaction.Triggers>
-                        </ListView>
-                    </Grid>
-                </Border>
-                <Border Grid.Column="2" CornerRadius="6" BorderThickness="1" BorderBrush="{StaticResource color.sys.layout.divider}">
-                    <Grid>
-                        <Image  x:Name="ScannerImage" Source="{Binding Img}"
-                                Visibility="{Binding IsEmptyImg,Converter={StaticResource InvertBoolToVisibleConvert}}"
-                                >
-                        </Image>
-                        <TextBlock Text="NO Image" FontSize="25" HorizontalAlignment="Center" VerticalAlignment="Center"
-                                   Visibility="{Binding IsEmptyImg,Converter={StaticResource BoolToVisible}}"
-                                   />
-                    </Grid>
-                </Border>
-            </Grid>
-
-            <Grid Height="406" Margin="16,0,16,0" Visibility="{Binding IsEmptyScanner,Converter={StaticResource BoolToVisible}}">
-                <TextBlock Text="No Scanners" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-            </Grid>
-        </Grid>
-        
-        <cus:DialogContent.BottmBar>
-            <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
-                <Button
-                    Width="80"
-                    Height="32"
-                    Command="{Binding CreateCommand}"
-                    Content="Scan"
-                    Style="{StaticResource Btn.cta}" />
-                <Button
-                    Width="80"
-                    Height="32"
-                    Margin="16,0"
-                    Command="{Binding CancelCommand}"
-                    Content="Cancel"
-                    Style="{StaticResource btn.sec}" />
+             Height="560" Width="352">
+    <Grid Background="White">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="48"/>
+            <RowDefinition/>
+            <RowDefinition Height="64"/>
+        </Grid.RowDefinitions>
+        <TextBlock Text="从扫描仪创建pdf" VerticalAlignment="Center" HorizontalAlignment="Left"/>
+        <Grid Grid.Row="1" Background="#F3F3F3">
+            <StackPanel>
+                <TextBlock Text="扫描仪"/>
+                <ListBox Name="Listboxscan" Height="Auto"  SelectedIndex="{Binding SeIndex,Mode=TwoWay}">
+                
+                </ListBox>
             </StackPanel>
-        </cus:DialogContent.BottmBar>
-    </cus:DialogContent>
+        </Grid>
+        <Grid Grid.Row="2">
+            <WrapPanel HorizontalAlignment="Right" VerticalAlignment="Center">
+                <Button x:Name="But_Scan"                 
+                    Width="60"
+                    Height="32"                 
+                    HorizontalAlignment="Center"
+                    VerticalAlignment="Top"
+                        Command="{Binding ToScanCommand}"
+                    Background="#273C62"                 
+                    Style="{StaticResource Btn.cta}" IsDefault="True" />
+                <Button/>
+                <Button                 
+                    Width="60"
+                    Height="32"   
+                    Margin="8,0,0,0"
+                    HorizontalAlignment="Center"
+                    VerticalAlignment="Top"
+                    Background="#273C62"                 
+                    Style="{StaticResource Btn.cta}" IsCancel="True" />
+                <Button/>
+            </WrapPanel>
+        </Grid>
+    </Grid>
+
 </UserControl>

+ 35 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/CreateFromScannerDialogs.xaml.cs

@@ -1,6 +1,8 @@
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
@@ -12,6 +14,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using WIA;
 
 namespace PDF_Master.Views.Dialog.HomePageToolsDialogs
 {
@@ -20,9 +23,41 @@ namespace PDF_Master.Views.Dialog.HomePageToolsDialogs
     /// </summary>
     public partial class CreateFromScannerDialogs : UserControl
     {
+  
+
+       
         public CreateFromScannerDialogs()
         {
             InitializeComponent();
+            ListScanners();
+          
+          
+        }
+
+        public static ImageFile imageFile ;
+        private void ListScanners()
+        {
+           
+
+            DeviceManager deviceManager;
+            deviceManager = new DeviceManager();
+
+            for (int i = 1; i <= deviceManager.DeviceInfos.Count; i++)
+            {
+
+                if (deviceManager.DeviceInfos[i].Type != WiaDeviceType.ScannerDeviceType)
+                {
+                    continue;
+                }
+                Listboxscan.Items.Add(deviceManager.DeviceInfos[i].Properties["Name"].get_Value());
+            }
+           
         }
+       
+
+
+    
+      
     }
+
 }

+ 4 - 4
PDF Office/Views/Dialog/ServiceDialog/LoginRegion.xaml

@@ -328,11 +328,11 @@
                     </Grid>
                     <TextBlock
                         Width="262"
-                        Height="20"
+                        Height="Auto"
                         Margin="0,2,0,0"
                         HorizontalAlignment="Left"
                         Foreground="#F3465B"
-                        Text="{Binding LoginEmaillook, Mode=TwoWay}" />
+                        Text="{Binding LoginEmaillook, Mode=TwoWay}" TextWrapping="Wrap" />
                     <Button
                         Width="262"
                         Height="32"
@@ -346,9 +346,9 @@
                         Style="{StaticResource Btn.cta}" />
                     <WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                         <TextBlock
-                            Width="144"
+                            Width="Auto"
                             Height="20"
-                            Margin="0,10,0,0"
+                            Margin="0,10,4,0"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             FontFamily="Segoe UI"