예제 #1
0
        public MainWindow()
        {
            InitializeComponent();
            Version version = Assembly.GetExecutingAssembly().GetFileVersion();

            this.Title       = String.Format("IP搜索工具 {0}.{1}", version.Major, version.Minor);
            this.DataContext = this;
            IsSelectedAll    = false;
            Devices          = new ObservableCollection <DeviceModel>();
            DeviceCatalogs   = new ObservableCollection <string>(DeviceCatalogConverter.GetValues());
            DeviceTypes      = new ObservableCollection <string>(DeviceTypeConverter.GetValues());
            CollectionView   = (CollectionView)CollectionViewSource.GetDefaultView(Devices);
            DeviceIPSetting  = new DeviceIPSettingModel()
            {
                DHCP = true
            };
        }
예제 #2
0
 private void ExportExcelData()
 {
     try
     {
         SaveFileDialog saveFileDialog = new SaveFileDialog();
         saveFileDialog.Filter = "Excel Files | *.xlsx";;
         if (saveFileDialog.ShowDialog() == true)
         {
             IList <DeviceExcelData> list            = new List <DeviceExcelData>();
             DeviceModel[]           selectedDevices = this.Devices.Where(x => x.IsSelected).ToArray();
             foreach (var item in selectedDevices)
             {
                 DeviceExcelData data = new DeviceExcelData()
                 {
                     DeviceType        = DeviceTypeConverter.GetString(item.DeviceType),
                     DHCP              = Boolean2ChineseConverter.GetString(item.DHCP),
                     Dns1              = item.Dns1,
                     Dns2              = item.Dns2,
                     Gateway           = item.Gateway,
                     Hardware          = item.Hardware,
                     Software          = item.Software,
                     IPAddress         = item.IPAddress,
                     Username          = item.Username,
                     Password          = item.Password,
                     Model             = item.Model,
                     Name              = item.Name,
                     No                = item.No,
                     PhysicalAddress   = item.PhysicalAddress,
                     Port              = item.Port,
                     ProtocolType      = item.ProtocolType,
                     SubnetMask        = item.SubnetMask,
                     VideoChannelCount = item.VideoChannelCount,
                 };
                 list.Add(data);
             }
             ExcelPackageExporter.ExportDeviceExcelStream(list, saveFileDialog.FileName);
             this.ShowMessageAsync("导出数据成功", null);
         }
     }
     catch (Exception ex)
     {
         Helper.Logger.Error("导出数据失败", ex);
         this.ShowMessageAsync("导出数据失败", ex.Message);
     }
 }
예제 #3
0
        private Boolean SearchFilter(Object obj)
        {
            DeviceModel device = obj as DeviceModel;

            if (device == null)
            {
                return(false);
            }
            if (String.IsNullOrEmpty(this.SearchText) == true)
            {
                return(true);
            }
            if (device.Name != null && device.Name.Contains(this.SearchText))
            {
                return(true);
            }
            if (device.Model != null && device.Model.Contains(this.SearchText))
            {
                return(true);
            }
            if (device.IPAddress != null && device.IPAddress.Contains(this.SearchText))
            {
                return(true);
            }
            if (device.SubnetMask != null && device.SubnetMask.Contains(this.SearchText))
            {
                return(true);
            }
            if (device.Gateway != null && device.Gateway.Contains(this.SearchText))
            {
                return(true);
            }
            if (device.Software != null && device.Software.Contains(this.SearchText))
            {
                return(true);
            }
            if (DeviceTypeConverter.GetString(device.DeviceType).Contains(this.SearchText))
            {
                return(true);
            }
            return(false);
        }
예제 #4
0
        /// <summary>
        /// 添加摄像机信息表单
        /// </summary>
        /// <param name="worksheets">表单列表集合</param>
        /// <param name="list">摄像机列表</param>
        /// <param name="tableStyles">表单样式</param>
        public static void AddDeviceWorkSheet(this ExcelWorksheets worksheets, IList <DeviceExcelData> list, OfficeOpenXml.Table.TableStyles tableStyles = OfficeOpenXml.Table.TableStyles.Light8)
        {
            ExcelWorksheet worksheet = worksheets.Add("设备信息");

            var dataRange = worksheet.Cells["A1"].LoadFromCollection(
                list.OrderBy(x => x.Name).OrderBy(x => x.No),
                true, tableStyles);

            worksheet.DataValidations.AddUniqueValidation("A2:A65536");
            worksheet.DataValidations.AddListValidation("C2:C65536", DeviceTypeConverter.GetValues());
            worksheet.DataValidations.AddListValidation("K2:K65536", Boolean2ChineseConverter.GetValues());
            worksheet.DataValidations.AddUniqueValidation("E2:E65536");
            worksheet.DataValidations.AddUniqueValidation("N2:N65536");
            //worksheet.Column(0).Style.Locked = true;
            //worksheet.Column(13).Style.Locked = true;
            //worksheet.Column(14).Style.Locked = true;
            //worksheet.Column(15).Style.Locked = true;
            //worksheet.Column(16).Style.Locked = true;
            //worksheet.Column(17).Style.Locked = true;
            //worksheet.Protection.IsProtected = true;
            dataRange.AutoFitColumns();
        }