[clean] 코드 정리

This commit is contained in:
최준영
2024-04-02 13:49:43 +09:00
parent f6a0b99295
commit a86225f951
18 changed files with 38 additions and 124 deletions

View File

@@ -1,10 +1,8 @@
using System; using CommunityToolkit.Mvvm.DependencyInjection;
using System.Globalization; using Microsoft.Extensions.DependencyInjection;
using System.IO; using System.IO;
using System.Text.Json; using System.Text.Json;
using System.Windows; using System.Windows;
using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using WPFBeginner.Configurations; using WPFBeginner.Configurations;
using WPFBeginner.Exceptions; using WPFBeginner.Exceptions;
using WPFBeginner.Services; using WPFBeginner.Services;
@@ -38,7 +36,7 @@ namespace WPFBeginner
Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
App.Current.MainWindow.Show(); App.Current.MainWindow.Show();
} }
catch(Exception ex) catch (Exception ex)
{ {
App.Current.MainWindow.Close(); App.Current.MainWindow.Close();
Environment.Exit(0); Environment.Exit(0);
@@ -47,7 +45,7 @@ namespace WPFBeginner
private void UnhandledExceptionHandle(object e) private void UnhandledExceptionHandle(object e)
{ {
if(e is UnhandledExceptionEventArgs uee && uee.ExceptionObject is LoginFailedException) if (e is UnhandledExceptionEventArgs uee && uee.ExceptionObject is LoginFailedException)
{ {
} }
@@ -86,7 +84,7 @@ namespace WPFBeginner
private static void SetLanguage(string code) private static void SetLanguage(string code)
{ {
if (_currentLanguage != null) if (_currentLanguage != null)
App.Current.Resources.MergedDictionaries.Remove( _currentLanguage ); App.Current.Resources.MergedDictionaries.Remove(_currentLanguage);
_currentLanguage = ResourceExplorer.GetLanguageResourceDic(code); _currentLanguage = ResourceExplorer.GetLanguageResourceDic(code);
App.Current.Resources.MergedDictionaries.Add(_currentLanguage); App.Current.Resources.MergedDictionaries.Add(_currentLanguage);

View File

@@ -1,6 +1,6 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.Windows; using System.Windows;
using System.Windows.Interop;
namespace WPFBeginner.Behaviors namespace WPFBeginner.Behaviors
{ {
@@ -24,7 +24,8 @@ namespace WPFBeginner.Behaviors
#region HideCloseButton (attached property) #region HideCloseButton (attached property)
private static readonly RoutedEventHandler HideCloseButtonWhenLoadedDelegate = (sender, args) => { private static readonly RoutedEventHandler HideCloseButtonWhenLoadedDelegate = (sender, args) =>
{
if (sender is Window == false) if (sender is Window == false)
return; return;
@@ -33,7 +34,8 @@ namespace WPFBeginner.Behaviors
w.Loaded -= HideCloseButtonWhenLoadedDelegate; w.Loaded -= HideCloseButtonWhenLoadedDelegate;
}; };
private static readonly RoutedEventHandler ShowCloseButtonWhenLoadedDelegate = (sender, args) => { private static readonly RoutedEventHandler ShowCloseButtonWhenLoadedDelegate = (sender, args) =>
{
if (sender is Window == false) if (sender is Window == false)
return; return;
@@ -43,7 +45,7 @@ namespace WPFBeginner.Behaviors
}; };
public static readonly DependencyProperty HideCloseButtonProperty = public static readonly DependencyProperty HideCloseButtonProperty =
DependencyProperty.RegisterAttached("HideCloseButton", typeof(bool), OwnerType, DependencyProperty.RegisterAttached("HideCloseButton", typeof(bool), OwnerType,
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(HideCloseButtonChangedCallback))); new FrameworkPropertyMetadata(false, new PropertyChangedCallback(HideCloseButtonChangedCallback)));
[AttachedPropertyBrowsableForType(typeof(Window))] [AttachedPropertyBrowsableForType(typeof(Window))]
@@ -97,7 +99,7 @@ namespace WPFBeginner.Behaviors
#region IsHiddenCloseButton (readonly attached property) #region IsHiddenCloseButton (readonly attached property)
private static readonly DependencyPropertyKey IsHiddenCloseButtonKey = private static readonly DependencyPropertyKey IsHiddenCloseButtonKey =
DependencyProperty.RegisterAttachedReadOnly( "IsHiddenCloseButton", typeof(bool), OwnerType, new FrameworkPropertyMetadata(false)); DependencyProperty.RegisterAttachedReadOnly("IsHiddenCloseButton", typeof(bool), OwnerType, new FrameworkPropertyMetadata(false));
public static readonly DependencyProperty IsHiddenCloseButtonProperty = IsHiddenCloseButtonKey.DependencyProperty; public static readonly DependencyProperty IsHiddenCloseButtonProperty = IsHiddenCloseButtonKey.DependencyProperty;

View File

@@ -1,10 +1,4 @@
using System; using System.Text.Json.Serialization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using System.Windows;
using WPFBeginner.Models; using WPFBeginner.Models;
namespace WPFBeginner.Configurations namespace WPFBeginner.Configurations
@@ -15,7 +9,7 @@ namespace WPFBeginner.Configurations
public EventHandler<StringChangedEventArg> ThemeChanged; public EventHandler<StringChangedEventArg> ThemeChanged;
[JsonPropertyName("Login")] [JsonPropertyName("Login")]
public LoginInfo Login { get; set;} public LoginInfo Login { get; set; }
private string language; private string language;
[JsonPropertyName("Language")] [JsonPropertyName("Language")]
@@ -62,7 +56,7 @@ namespace WPFBeginner.Configurations
} }
[JsonPropertyName("DefaultMembers")] [JsonPropertyName("DefaultMembers")]
public List<Member> Members { get; set;} public List<Member> Members { get; set; }
} }
public class StringChangedEventArg : EventArgs public class StringChangedEventArg : EventArgs

View File

@@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFBeginner.Controls"
mc:Ignorable="d" Name="root" mc:Ignorable="d" Name="root"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">

View File

@@ -1,18 +1,5 @@
using System; using System.Windows;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPFBeginner.Controls namespace WPFBeginner.Controls
{ {
@@ -22,7 +9,7 @@ namespace WPFBeginner.Controls
public partial class MemberInputPanel : UserControl public partial class MemberInputPanel : UserControl
{ {
public static readonly DependencyProperty MemberNameProperty = public static readonly DependencyProperty MemberNameProperty =
DependencyProperty.Register(nameof(MemberName), typeof(string), typeof(MemberInputPanel), new FrameworkPropertyMetadata(){BindsTwoWayByDefault = true}); DependencyProperty.Register(nameof(MemberName), typeof(string), typeof(MemberInputPanel), new FrameworkPropertyMetadata() { BindsTwoWayByDefault = true });
public string MemberName public string MemberName
{ {

View File

@@ -1,9 +1,4 @@
using System; using System.Windows.Markup;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Markup;
namespace WPFBeginner.Converters namespace WPFBeginner.Converters
{ {

View File

@@ -1,16 +1,10 @@
using System; namespace WPFBeginner.Exceptions
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WPFBeginner.Exceptions
{ {
internal class LoginFailedException : Exception internal class LoginFailedException : Exception
{ {
public LoginFailedException() : base() public LoginFailedException() : base()
{ {
} }
} }
} }

View File

@@ -1,10 +1,4 @@
using System; using System.Text.Json.Serialization;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace WPFBeginner.Models namespace WPFBeginner.Models
{ {
@@ -26,7 +20,8 @@ namespace WPFBeginner.Models
Name = name, Name = name,
Call = call, Call = call,
EMail = email, EMail = email,
EmployeeNo = employeeNo }; EmployeeNo = employeeNo
};
} }
} }
} }

View File

@@ -1,9 +1,4 @@
using System; using System.Windows;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace WPFBeginner.Resources namespace WPFBeginner.Resources
{ {

View File

@@ -1,5 +1,5 @@
using System.Windows.Input; using System.Windows;
using System.Windows; using System.Windows.Input;
namespace WPFBeginner.Services namespace WPFBeginner.Services
{ {
@@ -26,7 +26,7 @@ namespace WPFBeginner.Services
private static void Unloaded(object sender, RoutedEventArgs e) private static void Unloaded(object sender, RoutedEventArgs e)
{ {
var uiElement = sender as FrameworkElement; var uiElement = sender as FrameworkElement;
if (uiElement == null) if (uiElement == null)
return; return;
uiElement.Unloaded -= Unloaded; uiElement.Unloaded -= Unloaded;

View File

@@ -1,5 +1,5 @@
using System.Windows.Controls; using System.Windows;
using System.Windows; using System.Windows.Controls;
namespace WPFBeginner.Services namespace WPFBeginner.Services
{ {
@@ -90,6 +90,6 @@ namespace WPFBeginner.Services
} }
} }

View File

@@ -1,12 +1,4 @@
using System; using System.Windows;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
namespace WPFBeginner.Services namespace WPFBeginner.Services
{ {
@@ -24,7 +16,7 @@ namespace WPFBeginner.Services
public static void ChangeXamlResource(string oldRes, string newRes) public static void ChangeXamlResource(string oldRes, string newRes)
{ {
var found = App.Current.Resources.MergedDictionaries.Select((item, i) => new { Item = item, Index = i}).FirstOrDefault(i => i.Item.Source.AbsoluteUri.Equals($"{oldRes}", StringComparison.OrdinalIgnoreCase)); var found = App.Current.Resources.MergedDictionaries.Select((item, i) => new { Item = item, Index = i }).FirstOrDefault(i => i.Item.Source.AbsoluteUri.Equals($"{oldRes}", StringComparison.OrdinalIgnoreCase));
if (found == null) if (found == null)
return; return;
@@ -53,7 +45,7 @@ namespace WPFBeginner.Services
//var foundName = $"/WPFBeginner;component/Themes/Colors/{name}.xaml"; //var foundName = $"/WPFBeginner;component/Themes/Colors/{name}.xaml";
var found = App.Current.Resources.MergedDictionaries.Select((item, i) => new { Item = item, Index = i }).FirstOrDefault(i => i.Item.Source.AbsoluteUri.Equals(foundName, StringComparison.OrdinalIgnoreCase)); var found = App.Current.Resources.MergedDictionaries.Select((item, i) => new { Item = item, Index = i }).FirstOrDefault(i => i.Item.Source.AbsoluteUri.Equals(foundName, StringComparison.OrdinalIgnoreCase));
if (found == null) if (found == null)
return new ResourceDictionary(){ Source = new Uri(foundName, UriKind.RelativeOrAbsolute) }; return new ResourceDictionary() { Source = new Uri(foundName, UriKind.RelativeOrAbsolute) };
return found.Item; return found.Item;
} }

View File

@@ -1,9 +1,4 @@
using CommunityToolkit.Mvvm.DependencyInjection; using CommunityToolkit.Mvvm.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WPFBeginner.ViewModels; using WPFBeginner.ViewModels;
namespace WPFBeginner.Services namespace WPFBeginner.Services

View File

@@ -1,8 +0,0 @@
## 요구사항
1. 프로그램 중복실행 방지
2. 로그인 화면
- 파일로부터 데이터 읽어와 비교
3.

View File

@@ -16,7 +16,7 @@ namespace WPFBeginner.ViewModels
{ {
get get
{ {
if(filterMemebers != null) if (filterMemebers != null)
return filterMemebers; return filterMemebers;
return members; return members;
@@ -92,7 +92,7 @@ namespace WPFBeginner.ViewModels
return; return;
} }
IEnumerable<Member> result = Members; IEnumerable<Member> result = Members;
if (!string.IsNullOrWhiteSpace(MemberName)) if (!string.IsNullOrWhiteSpace(MemberName))
result = result.Where(i => i.Name?.Contains(MemberName) ?? false); result = result.Where(i => i.Name?.Contains(MemberName) ?? false);

View File

@@ -1,11 +1,8 @@
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using WPFBeginner.Services; using WPFBeginner.Services;
using WPFBeginner.Views;
namespace WPFBeginner.ViewModels namespace WPFBeginner.ViewModels
{ {

View File

@@ -1,13 +1,4 @@
using System.Text; using System.Windows;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPFBeginner namespace WPFBeginner
{ {

View File

@@ -1,16 +1,4 @@
using System; using System.Windows;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace WPFBeginner.Views namespace WPFBeginner.Views
{ {