Bladeren bron

修改文件

tags/录制修改前
zhangxueyang 4 jaren geleden
bovenliggende
commit
1ead98994f
2 gewijzigde bestanden met toevoegingen van 97 en 16 verwijderingen
  1. 2
    2
      XHWK.WKTool/FileDirectoryWindow.xaml
  2. 95
    14
      XHWK.WKTool/FileDirectoryWindow.xaml.cs

+ 2
- 2
XHWK.WKTool/FileDirectoryWindow.xaml Bestand weergeven

@@ -6,7 +6,7 @@
6 6
         xmlns:local="clr-namespace:XHWK.WKTool"
7 7
         mc:Ignorable="d"
8 8
         Title="FileDirectoryWindow" Height="729" Width="1030" AllowsTransparency="True" 
9
-    ShowInTaskbar="False" MouseLeftButtonDown="Window_MouseLeftButtonDown_1"
9
+    ShowInTaskbar="False" MouseLeftButtonDown="Window_MouseLeftButtonDown_1" MouseLeftButtonUp="Window_MouseLeftButtonUp"
10 10
     WindowStartupLocation="CenterOwner"
11 11
     WindowStyle="None">
12 12
     <Window.Resources>
@@ -49,7 +49,7 @@
49 49
                     HorizontalAlignment="Center"
50 50
                     VerticalAlignment="Center"
51 51
                     FontSize="15"
52
-                    Text="{Binding VideoName}" />
52
+                    Text="{Binding VideoName,Mode=TwoWay}" />
53 53
                         <Button x:Name="btnModify" Background="Transparent"
54 54
                                 Cursor="Hand"
55 55
                         BorderThickness="0" Click="BtnModify_Click">

+ 95
- 14
XHWK.WKTool/FileDirectoryWindow.xaml.cs Bestand weergeven

@@ -91,7 +91,9 @@ namespace XHWK.WKTool
91 91
                 pageData.menuList.Add(new FileDirectoryModel()
92 92
                 {
93 93
                     SerialNumber = i,
94
-                    VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".mp4", "").Replace(".flv", "").Replace("avi", "").Trim(),
94
+                    VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace("AVI", "").Trim(),
95
+                    Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace("AVI", "").Trim(),
96
+                    FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
95 97
                     VideoDuration = 0,
96 98
                     VideoSize = videoinfo.VideoSize,
97 99
                     VideoTime = videoinfo.RSTime,
@@ -102,7 +104,7 @@ namespace XHWK.WKTool
102 104
                     Coll = cos,
103 105
                     FileGuid = videoinfo.FileGuid,
104 106
                     VideoType = videoinfo.VideoType.ToString()
105
-                }) ; 
107
+                }); ; 
106 108
                 i++;
107 109
             }
108 110
             txbSum.Text = pageData.menuList.Count.ToString();
@@ -113,21 +115,31 @@ namespace XHWK.WKTool
113 115
         /// </summary>
114 116
         public void LoadingVideoList()
115 117
         {
116
-            model_VideoList = new List<Model_Video>();
117
-            foreach(Model_WKData Vdata in APP.WKDataList)
118
+            try
118 119
             {
119
-                if (Vdata.VideoList == null)
120
-                    continue;
121
-                foreach(Model_Video videoinfo in Vdata.VideoList)
120
+                model_VideoList = new List<Model_Video>();
121
+                foreach (Model_WKData Vdata in APP.WKDataList)
122 122
                 {
123
-                    if (string.IsNullOrWhiteSpace(videoinfo.VideoSize)|| videoinfo.VideoSize=="0 MB")
123
+                    if (Vdata.VideoList == null)
124
+                        continue;
125
+                    foreach (Model_Video videoinfo in Vdata.VideoList)
124 126
                     {
125
-                        videoinfo.VideoSize = FileToolsCommon.GetFileSizeByMB(videoinfo.VideoPath).ToString() + " MB";
126
-                    }
127
-                    model_VideoList.Add(videoinfo);
127
+                        if (!string.IsNullOrWhiteSpace(videoinfo.VideoPath))
128
+                        {
129
+                            if (string.IsNullOrWhiteSpace(videoinfo.VideoSize) || videoinfo.VideoSize == "0 MB")
130
+                            {
131
+                                videoinfo.VideoSize = FileToolsCommon.GetFileSizeByMB(videoinfo.VideoPath).ToString() + " MB";
132
+                            }
128 133
 
134
+                            model_VideoList.Add(videoinfo);
135
+                        }
136
+                    }
129 137
                 }
130 138
             }
139
+            catch (Exception ex)
140
+            {
141
+
142
+            }
131 143
         }
132 144
         /// <summary>
133 145
         /// 关闭
@@ -324,14 +336,75 @@ namespace XHWK.WKTool
324 336
         /// <param name="e"></param>
325 337
         private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
326 338
         {
327
-            if(IsModify)
339
+            //if(IsModify)
340
+            //{
341
+            //    if(MouseNumber>0&& pageData.menuList.Count> Subscript)
342
+            //    {
343
+            //        pageData.menuList[Subscript].IsEnabled = false;
344
+            //        try
345
+            //        {
346
+            //            if(!pageData.menuList[Subscript].Name.Equals(pageData.menuList[Subscript].VideoName))
347
+            //            {
348
+
349
+            //                string tempPath = pageData.menuList[Subscript].VideoName + pageData.menuList[Subscript].VideoType;
350
+            //                tempPath = pageData.menuList[Subscript].Path.Replace(tempPath, "").Trim();
351
+            //                tempPath = tempPath + pageData.menuList[Subscript].Name;
352
+            //                FileToolsCommon.MoveDirectory(pageData.menuList[Subscript].Path, tempPath,out string Message);
353
+            //            }
354
+            //        }
355
+            //        catch (Exception ex)
356
+            //        {
357
+            //            MessageBox.Show("无法修改视频名称!" + ex.Message);
358
+            //            return;
359
+            //        }
360
+            //    }
361
+            //    MouseNumber++;
362
+            //}
363
+        }
364
+
365
+        private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
366
+        {
367
+            if (IsModify)
328 368
             {
329
-                if(MouseNumber>0&& pageData.menuList.Count> Subscript)
369
+                if (MouseNumber > 1 && pageData.menuList.Count > Subscript)
330 370
                 {
331 371
                     pageData.menuList[Subscript].IsEnabled = false;
332 372
                     try
333 373
                     {
334
-                        //FileToolsCommon.MoveDirectory(pageData.menuList[Subscript].Path,);
374
+                        if (!pageData.menuList[Subscript].Name.Equals(pageData.menuList[Subscript].VideoName))
375
+                        {
376
+                            
377
+                            string tempPath = pageData.menuList[Subscript].FilePath + pageData.menuList[Subscript].VideoName+"."+ pageData.menuList[Subscript].VideoType;
378
+                            if(FileToolsCommon.IsExistFile(tempPath))
379
+                            {
380
+                                MessageBox.Show("文件名已存在!");
381
+                                return;
382
+                            }
383
+                            foreach (Model_WKData wKData in APP.WKDataList)
384
+                            {
385
+                                if (wKData.VideoList == null)
386
+                                    continue;
387
+                                if (wKData.VideoList.Exists(x => x.FileGuid == pageData.menuList[Subscript].FileGuid))
388
+                                {
389
+                                    try
390
+                                    {
391
+                                        FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[Subscript].FileGuid).VideoPath);
392
+                                        FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[Subscript].FileGuid).ThumbnailPath);
393
+                                        wKData.VideoList.Remove(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[Subscript].FileGuid));
394
+                                        Initialize();
395
+                                        return;
396
+                                    }
397
+                                    catch (Exception ex)
398
+                                    {
399
+                                        MessageBox.Show("无法删除视频!" + ex.Message);
400
+                                        return;
401
+                                    }
402
+                                }
403
+                            }
404
+
405
+
406
+                            FileToolsCommon.Copy(pageData.menuList[Subscript].Path, tempPath); 
407
+                        }
335 408
                     }
336 409
                     catch (Exception ex)
337 410
                     {
@@ -481,5 +554,13 @@ namespace XHWK.WKTool
481 554
         /// 视频类型
482 555
         /// </summary>
483 556
         public string VideoType { get; set; }
557
+        /// <summary>
558
+        /// 初始名称
559
+        /// </summary>
560
+        public string Name { get; set; }
561
+        /// <summary>
562
+        /// 文件路径
563
+        /// </summary>
564
+        public string FilePath { get; set; }
484 565
     }
485 566
 }

Laden…
Annuleren
Opslaan