예제 #1
0
        /// <summary>
        /// 添加一个磁盘的路径
        /// </summary>
        /// <param name="deviceFolder">目的磁盘所代表的文件夹</param>
        /// <returns>添加后的 AccessItem,如果该路径不合法或已存在,弹出提示框</returns>
        public MDeviceAccessItem AppendDeviceLocation(StorageFolder deviceFolder)
        {
            var devicePath = deviceFolder.Path;
            var regex      = new Regex("^[A-Z]:\\\\$");

            if (regex.Match(devicePath).Success)
            {
                if (_rootObject.devicesList.Exists(p => p.displayPath == deviceFolder.DisplayName))
                {
                    // 弹出框提示
                    MDialogAgency.DisplayMessageDialog("The device path was existed.");
                }
                else
                {
                    var token         = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(deviceFolder);
                    var newDeviceItem = new MDeviceAccessItem {
                        token = token, displayPath = deviceFolder.DisplayName
                    };
                    _rootObject.devicesList.Add(newDeviceItem);
                    this.isModify = true;

                    return(newDeviceItem);
                }
            }
            else
            {
                // 弹出框提示
                MDialogAgency.DisplayMessageDialog("Invalid Path");
            }

            return(null);
        }
예제 #2
0
        private async void DeviceAppendBtn_Click(object sender, RoutedEventArgs e)
        {
            var deviceFolder = await MDialogAgency.DisplayFolderPicker();

            if (deviceFolder is null)
            {
                return;
            }                                     // 如果取消了文件夹的选择,返回退出

            var deviceToAppend = agency.AppendDeviceLocation(deviceFolder);

            if (deviceToAppend != null)   // 添加成功
            {
                this.deviceItems.Add(deviceToAppend);
            }
        }
예제 #3
0
        private async void AccessItemAppendBtn_Click(object sender, RoutedEventArgs e)
        {
            var deviceFolder = await MDialogAgency.DisplayFolderPicker();

            if (deviceFolder is null)
            {
                return;
            }                                     // 如果取消了文件夹的选择,返回退出

            var categoryTitle = (e.OriginalSource as FrameworkElement).DataContext as string;
            var newAccessItem = agency.AppendAccessLocation(deviceFolder, categoryTitle);

            if (newAccessItem != null)   // 添加成功
            {
                var modifiedGroup = accessGroups.First(p => p.Title == categoryTitle);
                modifiedGroup.itemLists.Add(newAccessItem);;
            }
        }
예제 #4
0
파일: BaseField.cs 프로젝트: ktpm489/UWPEP
        public virtual async Task <List <IStorageItem> > PasteEntriesAsync(StorageFolder destFolder)
        {
            if (!Excutor.IsCopyAvailable)
            {
                await ShowNothingPasteDialogAsync();

                return(null);
            }

            List <IStorageItem> newCollection = null;
            await MDialogAgency.WaitThenDisplayMessageAsync(new TimeSpan(0, 0, RConstants.CopyDialogWaitTime), "Copying...", async delegate() {
                newCollection = await Excutor.PasteEntriesAsyncTo(destFolder);
            });

            if (Excutor.IsContainsFailedCopyEntry)
            {
                Excutor.ShowFailedCopyItemDialogIfNeed();
            }

            return(newCollection);
        }