// 移動(剪下/貼上) 操作
        private void moveTo_Btn_Click(object sender, RoutedEventArgs e)
        {
            String newPath = folderPath.Text.ToString();

            GloableObject.moveTo(GloableObject.img_path, newPath);
            GloableObject.folderInfo();
        }
Beispiel #2
0
        // 選擇Favorite
        private void Favorite_Click(object sender, RoutedEventArgs e)
        {
            GloableObject.mainWin.preview_mode.IsChecked    = false;
            GloableObject.mainWin.targetFolder_path.Text    = this.favorite_path.Text;
            GloableObject.mainWin.targetFolder_path.ToolTip = this.favorite_path.Text;
            GloableObject.curPath = this.favorite_path.Text;
            GloableObject.random_image(GloableObject.curPath);
            Properties.Settings.Default.Current_Favorite = this.favorite_aka.Text;

            // 控件

            GloableObject.mainWin.control_panel.Children.Clear();

            foreach (string name in Properties.Settings.Default.Favorite_Controls_List)
            {
                string[] ary = name.Split(':', '"');
                string   key = ary[1].ToString();
                // 解第一層dict
                if (key == this.favorite_aka.Text)
                {
                    // {"favorite_name":{"control_x":["color","aka","paht"], "control_x":["color","aka","paht"]}}
                    Dictionary <string, Dictionary <string, List <string> > > favorite_controls_list = (Dictionary <string, Dictionary <string, List <string> > >)JsonConvert.DeserializeObject(name, typeof(Dictionary <string, Dictionary <string, List <string> > >));
                    // "{control_x":["color","aka","paht"], "control_x":["color","aka","paht"]}
                    Dictionary <string, List <string> > controls = favorite_controls_list[key];
                    foreach (string control in controls.Keys)
                    {
                        List <string>  data           = controls[control];
                        Folder_Control folder_control = new Folder_Control();
                        // 顏色
                        BrushConverter tagColor = new BrushConverter(); // 轉換顏色
                        folder_control.colorTag.Background = (Brush)tagColor.ConvertFrom(data[0]);
                        // aka
                        folder_control.akaLabel.Text = data[1];
                        // path
                        folder_control.folderPath.Text  = data[2];
                        folder_control.akaLabel.ToolTip = data[2];
                        folder_control.Height           = 25;
                        GloableObject.mainWin.control_panel.Children.Add(folder_control);
                    }
                }
            }
            GloableObject.folderInfo();
            GloableObject.logger($"✔🔄 [Switch Favorite] - Switch to Favorite {this.favorite_aka.Text}", "HighLight");
            Window.GetWindow(this.Parent).Close();
        }
        // 選取主要路徑
        private void chooseTargetFolder_Btn_Click(object sender, RoutedEventArgs e)
        {
            preview_mode.IsChecked = false;
            WinForms.FolderBrowserDialog folderDialog = new WinForms.FolderBrowserDialog();
            folderDialog.ShowNewFolderButton = false;
            folderDialog.RootFolder          = Environment.SpecialFolder.Desktop;
            folderDialog.SelectedPath        = GloableObject.lastPath;
            WinForms.DialogResult result = folderDialog.ShowDialog();
            if (result == WinForms.DialogResult.Cancel)
            {
                return;
            }
            string sPath = folderDialog.SelectedPath;

            GloableObject.curPath  = sPath;
            GloableObject.lastPath = sPath;
            GloableObject.random_image(sPath);
            GloableObject.folderInfo();
            GloableObject.logger($"✔⚙ [Set Main Directory] - Path: [ {sPath} ]", "HighLight");
        }
 // 刪除檔案 Delte File
 private void deleteImg_Btn_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Delete File Forever?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
     {
         return;
     }
     else
     {
         if (File.Exists(GloableObject.img_path))
         {
             System.IO.File.Delete(GloableObject.img_path);
             GloableObject.logger($"♻🗑 [Delete File] - FileName: [ {GloableObject.img_filename} ]");
             GloableObject.random_image(GloableObject.curPath);
             GloableObject.folderInfo();
         }
         else
         {
             GloableObject.logger($"❌🗑 [Error] [Delete File] - Can't Not Delete, File Dosen't Exsit.");
         }
     }
 }
 // 資料夾拖曳進 Image Viewer / Main Folder
 private void Grid_Drop(object sender, DragEventArgs e)
 {
     preview_mode.IsChecked = false;
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
         if (files.Length == 1)
         {
             string file     = files[0];
             string filename = System.IO.Path.GetFileName(file);
             string file_ex  = System.IO.Path.GetExtension(filename);
             if (file_ex != string.Empty)
             {
                 GloableObject.change_src(file);
                 folder_info.Text          = "...";
                 targetFolder_path.Text    = System.IO.Path.GetFileName(file);
                 targetFolder_path.ToolTip = file;
                 GloableObject.logger($"✔🔽 [Load File] - Loaded:[{filename}] Path:[{file}]");
             }
             else
             {
                 GloableObject.curPath = file;
                 GloableObject.random_image(file + '\\');
                 targetFolder_path.Text = file;
                 GloableObject.logger($"✔🔽 [Load Folder] - Loaded:[{filename}] Path:[{file}]");
                 GloableObject.logger($"✔⚙ [Set Main Directory] - Path: [ {file} ]", "HighLight");
                 GloableObject.folderInfo();
             }
         }
         else
         {
             MessageBox.Show("Only Can Drop One File / Folder.");
             return;
         }
     }
 }