Ejemplo n.º 1
0
 /**<summary>删除文件</summary>**/
 private void Delete()
 {
     if (FileList.SelectedItems.Cast <AFile>().ToList() is IList <AFile> files)
     {
         if (files.Count < 1)
         {
             return;
         }
         string files_name = Adb.Files2String(files);
         if (!DeleteTip(files_name))
         {
             return;
         }
         string task_name = $"{Properties.Resources.Deleting} {string.Join(", ", files.Select(file => file.Name))}";
         if (TaskList.ContainsKey(task_name))
         {
             return;
         }
         TaskList.Add(task_name, Task.Factory.StartNew(() =>
         {
             ShowWarnMessage(Adb.Delete(Adb.Path, files, task_name));
             Reflush();
             TaskList.Remove(task_name);
         }));
     }
 }
        /***** 断开连接 *****/
        private void Disconnect_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            if (CurrentDevice != null)
            {
                if (MessageBox.Show(Properties.Resources.Message_DisconnectConfirm,
                                    Properties.Resources.Tip,
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Question)
                    == MessageBoxResult.No)
                {
                    return;
                }

                string[] message = Adb.Disconnect(CurrentDevice);

                if (!string.IsNullOrEmpty(message[Adb.RESULT]))
                {
                    MessageBox.Show(message[Adb.RESULT],
                                    Properties.Resources.Tip,
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                }

                if (!string.IsNullOrEmpty(message[Adb.ERROR]))
                {
                    MessageBox.Show(Properties.Resources.Message_CanNoDisconnect,
                                    Properties.Resources.Error,
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                Reflush();
            }
        }
Ejemplo n.º 3
0
        private void Rename(AFile file)
        {
            /* 不接受空文件 */
            if (file == null || OldName == null)
            {
                return;
            }
            /* 文件名不接受斜杠 */
            NewName = file.Name;
            /* 不接受空文件名 */
            if (string.IsNullOrEmpty(NewName))
            {
                file.Name = NewName = OldName;
            }
            /* 同名无需操作 */
            if (NewName == OldName)
            {
                return;
            }
            bool result = ShowErrMessage(Adb.Rename(NewName, OldName));

            /* 更新列表 */
            ForceReflush();
            string filename = result ? OldName : NewName;

            /* 选中被修改的文件 */
            FileList.SelectedItem = FileList.Items.Cast <AFile>().First(new_file => new_file.Name.ToString().Equals(filename));
            /* 清空新文件名缓存 */
            NewName = null;
        }
        /**<summary>提交数据</summary>**/
        private void Submit()
        {
            string message;
            string address = Address_TextBox.Text;

            if (string.IsNullOrEmpty(address))
            {
                message = Properties.Resources.Message_NoAddressTip;
            }
            else if (string.IsNullOrEmpty(Port_TextBox.Text))
            {
                message = Adb.Connect(address)[Adb.RESULT];
            }
            else
            {
                uint port = Convert.ToUInt16(Port_TextBox.Text);
                message = Adb.Connect(address, port)[Adb.RESULT];
            }
            /* 如果连接成功直接关闭窗口 */
            if (string.IsNullOrEmpty(message) || new Regex("^already+").IsMatch(message) || new Regex("^connected+").IsMatch(message))
            {
                Close();
            }
            else
            {
                MessageBox.Show(message, Properties.Resources.Tip, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 5
0
 /**<summary>打开目标路径</summary>**/
 private void OpenDir(string path)
 {
     if (path[path.Length - 1] != '/')
     {
         path += '/';
     }
     LoadDir(Adb.OpenFilesList(ref FileListData, path));
 }
Ejemplo n.º 6
0
 /**<summary>检查连接状态</summary>**/
 private bool Check()
 {
     if (!Adb.CheckPath())
     {
         Stop();
         MessageBox.Show($"\"{Adb.CurrentDevice.Model}\" {Properties.Resources.ConnectFailed}",
                         Properties.Resources.Error,
                         MessageBoxButton.OK,
                         MessageBoxImage.Error);
         Close();
     }
     return(true);
 }
Ejemplo n.º 7
0
 private void Sent2Clipboard(bool move)
 {
     if (FileList.SelectedItems.Cast <AFile>().ToList() is IList <AFile> files)
     {
         if (files.Count < 1)
         {
             return;
         }
         IsMove = move;
         Clipboard.Clear();
         Clipboard.SetData(DataFormats.UnicodeText, Adb.Files2String(files));
     }
 }
Ejemplo n.º 8
0
        /**<summary>移动</summary>**/
        private void Move(string path)
        {
            string task_name = $"{Properties.Resources.Moving} {path.Replace("\n", ", ")}";

            if (TaskList.ContainsKey(task_name))
            {
                return;
            }
            TaskList.Add(task_name, Task.Factory.StartNew(() =>
            {
                ShowErrMessage(Adb.Move(path, CoverTip, task_name));
                Reflush();
                TaskList.Remove(task_name);
            }));
        }
Ejemplo n.º 9
0
        private void Duplicate(string files)
        {
            string task_name = $"{Properties.Resources.Copying} {files.Replace("\n", ", ")}";

            if (TaskList.ContainsKey(task_name))
            {
                return;
            }
            TaskList.Add(task_name, Task.Factory.StartNew(() =>
            {
                ShowErrMessage(Adb.Copy(Adb.Path, files, CoverTip, task_name));
                Reflush();
                TaskList.Remove(task_name);
            }));
        }
Ejemplo n.º 10
0
 /* 设置标题 */
 private void RootStatus()
 {
     Title = $"{Properties.Resources.ATP} | {Adb.CurrentDevice.Model}";
     if (Adb.CheckRoot(Adb.CurrentDevice))
     {
         Title += $" | {Properties.Resources.Rooted}";
         Menu_Elevation.Visibility       = Context_Elevation.Visibility = Visibility.Collapsed;
         Menu_Deauthorization.Visibility = Context_Deauthorization.Visibility = Visibility.Visible;
     }
     else
     {
         Menu_Elevation.Visibility       = Context_Elevation.Visibility = Visibility.Visible;
         Menu_Deauthorization.Visibility = Context_Deauthorization.Visibility = Visibility.Collapsed;
     }
 }
Ejemplo n.º 11
0
        /**<summary>上传</summary>**/
        private void Upload(string[] files)
        {
            string task_name = $"{Properties.Resources.Uploading} {string.Join(", ", files)}";

            if (TaskList.ContainsKey(task_name))
            {
                return;
            }
            TaskList.Add(task_name, Task.Factory.StartNew(() =>
            {
                ShowWarnMessage(Adb.UpLoad(files, Adb.Path, CoverTip, task_name));
                Reflush();
                TaskList.Remove(task_name);
            }));
        }
Ejemplo n.º 12
0
        private void Duplicate(IList <AFile> files)
        {
            string task_name = $"{Properties.Resources.Copying} {string.Join(", ", files.Select(file => file.Name))}";

            if (TaskList.ContainsKey(task_name))
            {
                return;
            }
            TaskList.Add(task_name, Task.Factory.StartNew(() =>
            {
                ShowErrMessage(Adb.Copy(Adb.Path, files, task_name));
                Reflush();
                TaskList.Remove(task_name);
            }));
        }
Ejemplo n.º 13
0
 /**<summary>下载</summary>**/
 private void Download(string path)
 {
     if (FileList.SelectedItems.Cast <AFile>().ToList() is IList <AFile> files)
     {
         string task_name = $"{Properties.Resources.Downloading} {string.Join(", ", files.Select(file => file.Name))}";
         if (TaskList.ContainsKey(task_name))
         {
             return;
         }
         TaskList.Add(task_name, Task.Factory.StartNew(() =>
         {
             ShowWarnMessage(Adb.Download(path, Adb.Path, files, CoverTip, task_name));
             TaskList.Remove(task_name);
         }));
     }
 }
 private void Force_Reflush_Execute(object sender, ExecutedRoutedEventArgs e)
 {
     if (IsReflushing)
     {
         return;
     }
     IsReflushing = true;
     Cursor       = Cursors.Wait;
     Dispatcher.Invoke(() =>
     {
         Adb.KillServer();
         Reflush();
         Cursor       = Cursors.Arrow;
         IsReflushing = false;
     }, DispatcherPriority.ContextIdle);
 }
Ejemplo n.º 15
0
        private void CreateEnding()
        {
            /* 不允许空文件或文件名 */
            if (EditingFile == null)
            {
                FileListData.Remove(EditingFile);
                return;
            }
            string error_message = EditingFile.Type.Equals(AFile.FILE) ? Adb.CreateFile(EditingFile.Name) : Adb.CreateDir(EditingFile.Name);

            if (ShowErrMessage(error_message))
            {
                FileListData.Remove(EditingFile);
            }
            RmStatus(Properties.Resources.Creating);
        }
 private void Init()
 {
     if (Adb.CheckAdb())
     {
         /* 绑定数据源 */
         DevicesList.ItemsSource = DevicesListData;
         Reflush();
     }
     else
     {
         MessageBox.Show(Properties.Resources.AdbLose,
                         Properties.Resources.SeriousError,
                         MessageBoxButton.OK,
                         MessageBoxImage.Error);
         Close();
     }
 }
Ejemplo n.º 17
0
        /**<summary>新建</summary>**/
        private void Preview_Create(string file_name, string type)
        {
            if (!FileNameCol.IsReadOnly)
            {
                return;
            }
            AddStatus(Properties.Resources.Creating);
            FileList.Focus();
            /* 避免文件名冲突, 添加前缀 */
            while (Adb.CheckPath($"{Adb.Path}{file_name}"))
            {
                file_name = $"{Properties.Resources.New}{file_name}";
            }
            var new_file = new AFile {
                Name = file_name, Type = type
            };

            FileListData.Add(new_file);
            IsNewFile = true;
            BeginRename(new_file);
        }
        private void OpenDevice()
        {
            if (CurrentDevice == null || Opening)
            {
                return;
            }
            Opening = true;

            Dictionary <string, Configure.DeviceProp> DevicesProp = Configure.Configurer.conf.Device;

            Configure.DeviceProp DeviceProp;
            if (!DevicesProp.ContainsKey(CurrentDevice.UsbSerialNum))
            {
                DevicesProp.Add(CurrentDevice.UsbSerialNum, new Configure.DeviceProp {
                    Mod = CurrentDevice.Model
                });
            }
            DeviceProp = DevicesProp[CurrentDevice.UsbSerialNum];
            if (!DeviceProp.Mod.Equals(CurrentDevice.Model))
            {
                DeviceProp.Mod  = CurrentDevice.Model;
                DeviceProp.Path = "/";
            }
            Adb.ChangeDevice(CurrentDevice, DeviceProp.Path);

            if (Adb.CheckPath())
            {
                new FileManager().Show();
                Close();
            }
            else
            {
                MessageBox.Show(Properties.Resources.ConnectFailed,
                                Properties.Resources.Error,
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
                Reflush();
            }
            Opening = false;
        }
Ejemplo n.º 19
0
        /**<summary>用于处理数据列表发生变化后的事件</summary>**/
        private void LoadDir(string message)
        {
            PathBar.Text = Adb.Path;
            if (ShowWarnMessage(message))
            {
                if (Check())
                {
                    OpenDir(Adb.GetUpperDir(Adb.Path));
                }
            }

            Dispatcher.CurrentDispatcher.Invoke(() =>
            {
                FileList.ItemsSource = FileListData;
                if (SelectedFile.ContainsKey(Adb.Path))
                {
                    Go2File(SelectedFile[Adb.Path]);
                }
            }, DispatcherPriority.ContextIdle);

            FileList.Focus();
            DefaultStatus();
        }
Ejemplo n.º 20
0
 /**<summary>后退</summary>**/
 private void Last() => LoadDir(Adb.LastFileList(ref FileListData));
Ejemplo n.º 21
0
 /**<summary>上一级目录</summary>**/
 private void Upper() => OpenDir(Adb.GetUpperDir(Adb.Path));
        /***** 刷新 *****/

        /**<summary>刷新设备列表</summary>**/
        private void Reflush() => Adb.GetDevicesList(DevicesListData);
Ejemplo n.º 23
0
 private void Application_Exit(object sender, ExitEventArgs e)
 {
     Adb.Stop();
     Configure.Configurer.Save();
 }
Ejemplo n.º 24
0
 private void Stop(string task_name = null) => Adb.Stop(task_name);
Ejemplo n.º 25
0
 /**<summary>前进</summary>**/
 private void Next() => LoadDir(Adb.NextFileList(ref FileListData));
Ejemplo n.º 26
0
 /**<summary>刷新缓存</summary>**/
 private void ForceReflush()
 {
     Adb.FlushCache(Adb.Path);
     FileList.Dispatcher.Invoke(() => OpenDir(Adb.Path));
 }