[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 System.Globalization;
using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using System.IO;
using System.Text.Json;
using System.Windows;
using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using WPFBeginner.Configurations;
using WPFBeginner.Exceptions;
using WPFBeginner.Services;
@@ -38,7 +36,7 @@ namespace WPFBeginner
Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
App.Current.MainWindow.Show();
}
catch(Exception ex)
catch (Exception ex)
{
App.Current.MainWindow.Close();
Environment.Exit(0);
@@ -47,7 +45,7 @@ namespace WPFBeginner
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)
{
if (_currentLanguage != null)
App.Current.Resources.MergedDictionaries.Remove( _currentLanguage );
App.Current.Resources.MergedDictionaries.Remove(_currentLanguage);
_currentLanguage = ResourceExplorer.GetLanguageResourceDic(code);
App.Current.Resources.MergedDictionaries.Add(_currentLanguage);

View File

@@ -1,6 +1,6 @@
using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.Windows;
using System.Windows.Interop;
namespace WPFBeginner.Behaviors
{
@@ -24,7 +24,8 @@ namespace WPFBeginner.Behaviors
#region HideCloseButton (attached property)
private static readonly RoutedEventHandler HideCloseButtonWhenLoadedDelegate = (sender, args) => {
private static readonly RoutedEventHandler HideCloseButtonWhenLoadedDelegate = (sender, args) =>
{
if (sender is Window == false)
return;
@@ -33,7 +34,8 @@ namespace WPFBeginner.Behaviors
w.Loaded -= HideCloseButtonWhenLoadedDelegate;
};
private static readonly RoutedEventHandler ShowCloseButtonWhenLoadedDelegate = (sender, args) => {
private static readonly RoutedEventHandler ShowCloseButtonWhenLoadedDelegate = (sender, args) =>
{
if (sender is Window == false)
return;
@@ -97,7 +99,7 @@ namespace WPFBeginner.Behaviors
#region IsHiddenCloseButton (readonly attached property)
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;

View File

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

View File

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

View File

@@ -1,18 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Controls
{
@@ -22,7 +9,7 @@ namespace WPFBeginner.Controls
public partial class MemberInputPanel : UserControl
{
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
{

View File

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

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WPFBeginner.Exceptions
namespace WPFBeginner.Exceptions
{
internal class LoginFailedException : Exception
{

View File

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

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;
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
{

View File

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

View File

@@ -1,12 +1,4 @@
using System;
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;
using System.Windows;
namespace WPFBeginner.Services
{
@@ -24,7 +16,7 @@ namespace WPFBeginner.Services
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)
return;
@@ -53,7 +45,7 @@ namespace WPFBeginner.Services
//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));
if (found == null)
return new ResourceDictionary(){ Source = new Uri(foundName, UriKind.RelativeOrAbsolute) };
return new ResourceDictionary() { Source = new Uri(foundName, UriKind.RelativeOrAbsolute) };
return found.Item;
}

View File

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

View File

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

View File

@@ -16,7 +16,7 @@ namespace WPFBeginner.ViewModels
{
get
{
if(filterMemebers != null)
if (filterMemebers != null)
return filterMemebers;
return members;

View File

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

View File

@@ -1,13 +1,4 @@
using System.Text;
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;
using System.Windows;
namespace WPFBeginner
{

View File

@@ -1,16 +1,4 @@
using System;
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;
using System.Windows;
namespace WPFBeginner.Views
{