/// <summary> /// Initializes a new instance of the SharedFolderSettingVM class. /// </summary> public SharedFolderSettingVM() { _IsInEnable = _IsOutEnable = false; _InSharedFolder = WmiDiskHelper.GetDiskNames().ToObservableCollection(); _OutSharedFolder = WmiDiskHelper.GetDiskNames().ToObservableCollection(); }
//外部(Mainwindow)內的分頁改變了磁碟映射後,需要刷新物件的可用選擇 //提供PrinterWindow呼叫 public void RefreshLocalDrives() { var vm = this.DataContext as SharedFolderSettingVM; vm.InSharedFolder = WmiDiskHelper.GetDiskNames().ToObservableCollection(); vm.OutSharedFolder = WmiDiskHelper.GetDiskNames().ToObservableCollection(); }
static public SharedFolderSettingVM ToSharedFolderSettingVM(this XElement root) { SharedFolderSettingVM ret = null; try { ret = new SharedFolderSettingVM(); ret.IsInEnable = bool.Parse(root.getValue("In")); string _driveletter = root.getAttributeValue("In", "DriveLetter"); string _driveprovider = root.getAttributeValue("In", "DriveProvider"); ret.InDriveInfo = _driveletter + "(" + _driveprovider + ")"; //檢查有否有此driveinfo,若沒有,則create 一個 var _lstCurrentDrives = WmiDiskHelper.GetDiskNames(); bool bExist = _lstCurrentDrives.Exists(X => X.DiskID == _driveletter && X.DiskProviderName == _driveprovider); if (!bExist) { NetworkDriveWrapper.MappingNetDrive(_driveletter, _driveprovider, "", ""); } ret.IsOutEnable = bool.Parse(root.getValue("Out")); _driveletter = root.getAttributeValue("Out", "DriveLetter"); _driveprovider = root.getAttributeValue("Out", "DriveProvider"); ret.OutDriveInfo = _driveletter + "(" + _driveprovider + ")"; //檢查有否有此driveinfo,若沒有,則create 一個 _lstCurrentDrives = WmiDiskHelper.GetDiskNames(); bExist = _lstCurrentDrives.Exists(X => X.DiskID == _driveletter && X.DiskProviderName == _driveprovider); if (!bExist) { NetworkDriveWrapper.MappingNetDrive(_driveletter, _driveprovider, "", ""); } } catch { return(null); } return(ret); }