Skip to content

Commit

Permalink
2.1.3 Updated
Browse files Browse the repository at this point in the history
1. 자막 파일 변경 시 프로그램을 종료하지 않고 초기상태로 리셋하도록 변경함
2. 자막 리스트뷰의 위로, 아래로 버튼 작동 버그 수정 (null 체크)
3. 중복 실행되어 불필요한 내부 코드 삭제 (xxx_listView.ItemsSouce = xxxxFilesLinkedList;)
  • Loading branch information
hykeegj committed Aug 29, 2020
1 parent aa89ba2 commit d3c0bd0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion SubtitleRun/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
FontWeight="Normal"
SizeToContent="WidthAndHeight"
ResizeMode="NoResize"
Title="자막런 2.1.2"
Title="자막런 2.1.3"
FontStyle="Normal"
MinWidth="1100" FontFamily=".\Fonts\#Maplestory">
<Window.Resources>
Expand Down
46 changes: 25 additions & 21 deletions SubtitleRun/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ private void videoDeleteButton_Click(object sender, RoutedEventArgs e)
videoFilesLinkedList.Remove(item);
}

videoFile_listView.ItemsSource = videoFilesLinkedList;
videoFile_listView.Items.Refresh();
}
else if (videoFilesLinkedList.Count <= 0)
Expand Down Expand Up @@ -165,7 +164,6 @@ private void sortByVideoFileName_Click(object sender, RoutedEventArgs e)
isSortedVideoFileNameFlag = false;
}

videoFile_listView.ItemsSource = videoFilesLinkedList;
videoFile_listView.Items.Refresh();
}
else if (videoFilesLinkedList.Count <= 0)
Expand Down Expand Up @@ -207,7 +205,7 @@ private void sortByVideoFileExtension_Click(object sender, RoutedEventArgs e)

isSortedVideoFileExtensionFlag = false;
}
videoFile_listView.ItemsSource = videoFilesLinkedList;

videoFile_listView.Items.Refresh();
}
else if (videoFilesLinkedList.Count <= 0)
Expand All @@ -224,7 +222,6 @@ private void moveVideoIndexTopButton_Click(object sender, RoutedEventArgs e)
videoFilesLinkedList.Remove((File)videoFile_listView.SelectedItem);
videoFilesLinkedList.AddFirst((File)videoFile_listView.SelectedItem);

videoFile_listView.ItemsSource = videoFilesLinkedList;
videoFile_listView.Items.Refresh();
}
else if (videoFilesLinkedList.Count > 0 && videoFile_listView.SelectedItems.Count > 1)
Expand All @@ -251,7 +248,6 @@ private void moveVideoIndexUpButton_Click(object sender, RoutedEventArgs e)
videoFilesLinkedList.AddBefore(previousNode, currentNode);
}

videoFile_listView.ItemsSource = videoFilesLinkedList;
videoFile_listView.Items.Refresh();
}
else if (videoFilesLinkedList.Count > 0 && videoFile_listView.SelectedItems.Count > 1)
Expand All @@ -278,7 +274,6 @@ private void moveVideoIndexDownButton_Click(object sender, RoutedEventArgs e)
videoFilesLinkedList.AddAfter(nextNode, currentNode);
}

videoFile_listView.ItemsSource = videoFilesLinkedList;
videoFile_listView.Items.Refresh();
}
else if (videoFilesLinkedList.Count > 0 && videoFile_listView.SelectedItems.Count > 1)
Expand All @@ -299,7 +294,6 @@ private void moveVideoIndexBottomButton_Click(object sender, RoutedEventArgs e)
videoFilesLinkedList.Remove((File)videoFile_listView.SelectedItem);
videoFilesLinkedList.AddLast((File)videoFile_listView.SelectedItem);

videoFile_listView.ItemsSource = videoFilesLinkedList;
videoFile_listView.Items.Refresh();
}
else if (videoFilesLinkedList.Count > 0 && videoFile_listView.SelectedItems.Count > 1)
Expand Down Expand Up @@ -341,6 +335,7 @@ private void subtitleFile_listView_Drop(object sender, DragEventArgs e)
subtitleFilesLinkedList.AddLast(new File() { Path = System.IO.Path.GetDirectoryName(subtitleFilePath), Name = System.IO.Path.GetFileNameWithoutExtension(subtitleFilePath), Extension = System.IO.Path.GetExtension(subtitleFilePath) });
}
}

subtitleFile_listView.ItemsSource = subtitleFilesLinkedList;
subtitleFile_listView.Items.Refresh();
}
Expand All @@ -361,6 +356,7 @@ private void subtitleAddButton_Click(object sender, RoutedEventArgs e)
{
subtitleFilesLinkedList.AddLast(new File() { Path = System.IO.Path.GetDirectoryName(subtitleFilePath), Name = System.IO.Path.GetFileNameWithoutExtension(subtitleFilePath), Extension = System.IO.Path.GetExtension(subtitleFilePath) });
}

subtitleFile_listView.ItemsSource = subtitleFilesLinkedList;
subtitleFile_listView.Items.Refresh();
}
Expand All @@ -375,7 +371,7 @@ private void subtitleDeleteButton_Click(object sender, RoutedEventArgs e)
{
subtitleFilesLinkedList.Remove(item);
}
subtitleFile_listView.ItemsSource = subtitleFilesLinkedList;

subtitleFile_listView.Items.Refresh();
}
else if (subtitleFilesLinkedList.Count == 0)
Expand Down Expand Up @@ -418,7 +414,6 @@ private void sortBySubtitleFileName_Click(object sender, RoutedEventArgs e)
isSortedSubtitleFileNameFlag = false;
}

subtitleFile_listView.ItemsSource = subtitleFilesLinkedList;
subtitleFile_listView.Items.Refresh();
}
else if (subtitleFilesLinkedList.Count <= 0)
Expand Down Expand Up @@ -460,7 +455,7 @@ private void sortBySubtitleFileExtension_Click(object sender, RoutedEventArgs e)

isSortedSubtitleFileExtensionFlag = false;
}
subtitleFile_listView.ItemsSource = subtitleFilesLinkedList;

subtitleFile_listView.Items.Refresh();
}
else if (subtitleFilesLinkedList.Count <= 0)
Expand All @@ -477,7 +472,6 @@ private void moveSubtitleIndexTopButton_Click(object sender, RoutedEventArgs e)
subtitleFilesLinkedList.Remove((File)subtitleFile_listView.SelectedItem);
subtitleFilesLinkedList.AddFirst((File)subtitleFile_listView.SelectedItem);

subtitleFile_listView.ItemsSource = subtitleFilesLinkedList;
subtitleFile_listView.Items.Refresh();
}
else if (subtitleFilesLinkedList.Count > 0 && subtitleFile_listView.SelectedItems.Count > 1)
Expand All @@ -498,10 +492,12 @@ private void moveSubtitleIndexUpButton_Click(object sender, RoutedEventArgs e)
LinkedListNode<File> previousNode = subtitleFilesLinkedList.Find((File)subtitleFile_listView.SelectedItem).Previous;
LinkedListNode<File> currentNode = subtitleFilesLinkedList.Find((File)subtitleFile_listView.SelectedItem);

subtitleFilesLinkedList.Remove(currentNode);
subtitleFilesLinkedList.AddBefore(previousNode, currentNode);
if (previousNode != null)
{
subtitleFilesLinkedList.Remove(currentNode);
subtitleFilesLinkedList.AddBefore(previousNode, currentNode);
}

subtitleFile_listView.ItemsSource = subtitleFilesLinkedList;
subtitleFile_listView.Items.Refresh();
}
else if (subtitleFilesLinkedList.Count > 0 && subtitleFile_listView.SelectedItems.Count > 1)
Expand All @@ -522,10 +518,12 @@ private void moveSubtitleIndexDownButton_Click(object sender, RoutedEventArgs e)
LinkedListNode<File> nextNode = subtitleFilesLinkedList.Find((File)subtitleFile_listView.SelectedItem).Next;
LinkedListNode<File> currentNode = subtitleFilesLinkedList.Find((File)subtitleFile_listView.SelectedItem);

subtitleFilesLinkedList.Remove(currentNode);
subtitleFilesLinkedList.AddAfter(nextNode, currentNode);

subtitleFile_listView.ItemsSource = subtitleFilesLinkedList;
if (nextNode != null)
{
subtitleFilesLinkedList.Remove(currentNode);
subtitleFilesLinkedList.AddAfter(nextNode, currentNode);
}

subtitleFile_listView.Items.Refresh();
}
else if (subtitleFilesLinkedList.Count > 0 && subtitleFile_listView.SelectedItems.Count > 1)
Expand All @@ -546,7 +544,6 @@ private void moveSubtitleIndexBottomButton_Click(object sender, RoutedEventArgs
subtitleFilesLinkedList.Remove((File)subtitleFile_listView.SelectedItem);
subtitleFilesLinkedList.AddLast((File)subtitleFile_listView.SelectedItem);

subtitleFile_listView.ItemsSource = subtitleFilesLinkedList;
subtitleFile_listView.Items.Refresh();
}
else if (subtitleFilesLinkedList.Count > 0 && subtitleFile_listView.SelectedItems.Count > 1)
Expand Down Expand Up @@ -582,8 +579,15 @@ private void convertButton_Click(object sender, RoutedEventArgs e)
}
}

MessageBox.Show("자막 파일 이름이 비디오 파일의 이름에 맞게 변경되었습니다.\n변경된 파일을 확인해주세요.\n프로그램을 종료합니다.", Properties.Resources.Information, MessageBoxButton.OK, MessageBoxImage.Information);
Application.Current.MainWindow.Close();
MessageBox.Show("자막 파일 이름이 비디오 파일의 이름에 맞게 변경되었습니다.\n변경된 파일을 확인해주세요.", Properties.Resources.Information, MessageBoxButton.OK, MessageBoxImage.Information);

// 비디오 파일 리스트뷰 항목 전부 삭제 후 새로고침
videoFilesLinkedList.Clear(); // 전부 삭제
videoFile_listView.Items.Refresh(); // 새로고침

// 자막 파일 리스트뷰 항목 전부 삭제 후 새로고침
subtitleFilesLinkedList.Clear(); // 전부 삭제
subtitleFile_listView.Items.Refresh(); // 새로고침
}
else if (videoFilesLinkedList.Count <= 0 && subtitleFilesLinkedList.Count > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion SubtitleRun/SubtitleRun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<ApplicationIcon>SubtitleRun.ico</ApplicationIcon>
<Version>2.1.2</Version>
<Version>2.1.3</Version>
<PackageIcon>SubtitleRun.png</PackageIcon>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
Expand Down

0 comments on commit d3c0bd0

Please sign in to comment.