프로젝트

일반

사용자정보

개정판 45f9a2ad

ID45f9a2adf8e2a7d01fef47909ea4b768e515fcad
상위 4939a201
하위 f3b8ff8f, ee95e6ee

김태성이(가) 5년 이상 전에 추가함

service Controller 수정
wpf mvvm toolkit추가

Change-Id: I377702b7e388e29af1d18647108109d835b4fefb

차이점 보기:

ConvertService/ServiceBase/Markus.Mvvm.ToolKit/AsyncCommand/AsyncCommand.cs
1
using System;
2
using System.Threading.Tasks;
3
using System.Windows.Input;
4

  
5
namespace Markus.Mvvm.ToolKit
6
{
7
    public class AsyncCommand : IAsyncCommand
8
    {
9
        public event EventHandler CanExecuteChanged;
10

  
11
        private bool _isExecuting;
12
        private readonly Func<Task> _execute;
13
        private readonly Func<bool> _canExecute;
14
        private readonly IErrorHandler _errorHandler;
15

  
16
        public AsyncCommand(
17
            Func<Task> execute,
18
            Func<bool> canExecute = null,
19
            IErrorHandler errorHandler = null)
20
        {
21
            _execute = execute;
22
            _canExecute = canExecute;
23
            _errorHandler = errorHandler;
24
        }
25

  
26
        public bool CanExecute()
27
        {
28
            return !_isExecuting && (_canExecute?.Invoke() ?? true);
29
        }
30

  
31
        public async Task ExecuteAsync()
32
        {
33
            if (CanExecute())
34
            {
35
                try
36
                {
37
                    _isExecuting = true;
38
                    await _execute();
39
                }
40
                finally
41
                {
42
                    _isExecuting = false;
43
                }
44
            }
45

  
46
            RaiseCanExecuteChanged();
47
        }
48

  
49
        public void RaiseCanExecuteChanged()
50
        {
51
            CanExecuteChanged?.Invoke(this, EventArgs.Empty);
52
        }
53

  
54
        #region Explicit implementations
55
        bool ICommand.CanExecute(object parameter)
56
        {
57
            return CanExecute();
58
        }
59

  
60
        void ICommand.Execute(object parameter)
61
        {
62
            ExecuteAsync().FireAndForgetSafeAsync(_errorHandler);
63
        }
64
#endregion
65
    }
66

  
67
	public class AsyncCommand<T> : IAsyncCommand<T>
68
    {
69
        public event EventHandler CanExecuteChanged;
70

  
71
        private bool _isExecuting;
72
        private readonly Func<T, Task> _execute;
73
        private readonly Func<T, bool> _canExecute;
74
        private readonly IErrorHandler _errorHandler;
75

  
76
        public AsyncCommand(Func<T, Task> execute, Func<T, bool> canExecute = null, IErrorHandler errorHandler = null)
77
        {
78
            _execute = execute;
79
            _canExecute = canExecute;
80
            _errorHandler = errorHandler;
81
        }
82

  
83
        public bool CanExecute(T parameter)
84
        {
85
            return !_isExecuting && (_canExecute?.Invoke(parameter) ?? true);
86
        }
87

  
88
        public async Task ExecuteAsync(T parameter)
89
        {
90
            if (CanExecute(parameter))
91
            {
92
                try
93
                {
94
                    _isExecuting = true;
95
                    await _execute(parameter);
96
                }
97
                finally
98
                {
99
                    _isExecuting = false;
100
                }
101
            }
102

  
103
            RaiseCanExecuteChanged();
104
        }
105

  
106
        public void RaiseCanExecuteChanged()
107
        {
108
            CanExecuteChanged?.Invoke(this, EventArgs.Empty);
109
        }
110

  
111
#region Explicit implementations
112
        bool ICommand.CanExecute(object parameter)
113
        {
114
            return CanExecute((T)parameter);
115
        }
116

  
117
        void ICommand.Execute(object parameter)
118
        {
119
            ExecuteAsync((T)parameter).FireAndForgetSafeAsync(_errorHandler);
120
        }
121
#endregion
122
    }
123

  
124
}
ConvertService/ServiceBase/Markus.Mvvm.ToolKit/AsyncCommand/IAsyncCommand.cs
1
using System.Threading.Tasks;
2
using System.Windows.Input;
3

  
4
namespace Markus.Mvvm.ToolKit
5
{
6
    public interface IAsyncCommand : ICommand
7
    {
8
        Task ExecuteAsync();
9
        bool CanExecute();
10
    }
11

  
12
	public interface IAsyncCommand<T> : ICommand
13
    {
14
        Task ExecuteAsync(T parameter);
15
        bool CanExecute(T parameter);
16
    }
17

  
18
}
ConvertService/ServiceBase/Markus.Mvvm.ToolKit/AsyncCommand/IErrorHandler.cs
1
using System;
2

  
3
namespace Markus.Mvvm.ToolKit
4
{
5
    public interface IErrorHandler
6
    {
7
        void HandleError(Exception ex);
8
    }
9
}
ConvertService/ServiceBase/Markus.Mvvm.ToolKit/Markus.Mvvm.ToolKit.csproj
1
<?xml version="1.0" encoding="utf-8"?>
2
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
  <PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFramework)', '^net\d'))">
5
    <DefineConstants>NETFRAMEWORK</DefineConstants>
6
  </PropertyGroup>
7
  <PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFramework)', '^netstandard\d'))">
8
    <DefineConstants>NETSTANDARD</DefineConstants>
9
  </PropertyGroup>
10
  <PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFramework)', '^netcoreapp\d'))">
11
    <DefineConstants>NETCORE</DefineConstants>
12
  </PropertyGroup>
13
  <PropertyGroup>
14
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
15
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
16
    <ProjectGuid>{9EFE95D6-9985-422A-A76F-285C8CF73617}</ProjectGuid>
17
    <OutputType>Library</OutputType>
18
    <AppDesignerFolder>Properties</AppDesignerFolder>
19
    <RootNamespace>Markus.Mvvm.ToolKit</RootNamespace>
20
    <AssemblyName>Markus.Mvvm.ToolKit</AssemblyName>
21
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
22
    <FileAlignment>512</FileAlignment>
23
    <Deterministic>true</Deterministic>
24
  </PropertyGroup>
25
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
26
    <DebugSymbols>true</DebugSymbols>
27
    <DebugType>full</DebugType>
28
    <Optimize>false</Optimize>
29
    <OutputPath>bin\Debug\</OutputPath>
30
    <DefineConstants>TRACE;DEBUG</DefineConstants>
31
    <ErrorReport>prompt</ErrorReport>
32
    <WarningLevel>4</WarningLevel>
33
  </PropertyGroup>
34
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
35
    <DebugType>pdbonly</DebugType>
36
    <Optimize>true</Optimize>
37
    <OutputPath>bin\Release\</OutputPath>
38
    <DefineConstants>TRACE</DefineConstants>
39
    <ErrorReport>prompt</ErrorReport>
40
    <WarningLevel>4</WarningLevel>
41
  </PropertyGroup>
42
  <ItemGroup>
43
    <Reference Include="PresentationCore" />
44
    <Reference Include="System" />
45
    <Reference Include="System.Core" />
46
    <Reference Include="System.Xml.Linq" />
47
    <Reference Include="System.Data.DataSetExtensions" />
48
    <Reference Include="Microsoft.CSharp" />
49
    <Reference Include="System.Data" />
50
    <Reference Include="System.Net.Http" />
51
    <Reference Include="System.Xml" />
52
  </ItemGroup>
53
  <ItemGroup>
54
    <Compile Include="AsyncCommand\AsyncCommand.cs" />
55
    <Compile Include="RelayCommand\EventRaiser.cs" />
56
    <Compile Include="RelayCommand\RelayCommand.cs" />
57
    <Compile Include="AsyncCommand\IAsyncCommand.cs" />
58
    <Compile Include="AsyncCommand\IErrorHandler.cs" />
59
    <Compile Include="Notification.cs" />
60
    <Compile Include="Properties\AssemblyInfo.cs" />
61
    <Compile Include="TaskUtilities.cs" />
62
    <Compile Include="ViewModelBase.cs" />
63
  </ItemGroup>
64
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
65
</Project>
ConvertService/ServiceBase/Markus.Mvvm.ToolKit/Notification.cs
1
using System;
2
using System.ComponentModel;
3
using System.Linq.Expressions;
4

  
5
namespace Markus.Mvvm.ToolKit
6
{
7
    public class NotifyExpectation : INotifyPropertyChanged
8
    {
9
        public event PropertyChangedEventHandler PropertyChanged;
10
        protected virtual void OnPropertyChanged(Expression<Func<object>> propertyExpression)
11
        {
12
            PropertyChangedEventHandler handler = PropertyChanged;
13
            if (handler != null) handler(this, new PropertyChangedEventArgs(GetPropertyName(propertyExpression)));
14
        }
15

  
16
        private string GetPropertyName(Expression<Func<object>> propertyExpression)
17
        {
18
            var unaryExpression = propertyExpression.Body as UnaryExpression;
19
            var memberExpression = unaryExpression == null ? (MemberExpression)propertyExpression.Body : (MemberExpression)unaryExpression.Operand;
20
            var propertyName = memberExpression.Member.Name;
21
            return propertyName;
22
        }
23
    }
24
}
ConvertService/ServiceBase/Markus.Mvvm.ToolKit/Properties/AssemblyInfo.cs
1
using System.Reflection;
2
using System.Runtime.CompilerServices;
3
using System.Runtime.InteropServices;
4

  
5
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 
6
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
7
// 이러한 특성 값을 변경하세요.
8
[assembly: AssemblyTitle("Markus.Mvvm.ToolKit")]
9
[assembly: AssemblyDescription("")]
10
[assembly: AssemblyConfiguration("")]
11
[assembly: AssemblyCompany("")]
12
[assembly: AssemblyProduct("Markus.Mvvm.ToolKit")]
13
[assembly: AssemblyCopyright("Copyright ©  2019")]
14
[assembly: AssemblyTrademark("")]
15
[assembly: AssemblyCulture("")]
16

  
17
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 
18
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
19
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
20
[assembly: ComVisible(false)]
21

  
22
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
23
[assembly: Guid("9efe95d6-9985-422a-a76f-285c8cf73617")]
24

  
25
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
26
//
27
//      주 버전
28
//      부 버전 
29
//      빌드 번호
30
//      수정 버전
31
//
32
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
33
// 기본값으로 할 수 있습니다.
34
// [assembly: AssemblyVersion("1.0.*")]
35
[assembly: AssemblyVersion("1.0.0.0")]
36
[assembly: AssemblyFileVersion("1.0.0.0")]
ConvertService/ServiceBase/Markus.Mvvm.ToolKit/RelayCommand/EventRaiser.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace Markus.Mvvm.ToolKit
8
{
9
    public static class EventRaiser
10
    {
11
        public static void Raise(this EventHandler handler, object sender)
12
        {
13
            handler?.Invoke(sender, EventArgs.Empty);
14
        }
15

  
16
        public static void Raise<T>(this EventHandler<EventArgs<T>> handler, object sender, T value)
17
        {
18
            handler?.Invoke(sender, new EventArgs<T>(value));
19
        }
20

  
21
        public static void Raise<T>(this EventHandler<T> handler, object sender, T value) where T : EventArgs
22
        {
23
            handler?.Invoke(sender, value);
24
        }
25

  
26
        public static void Raise<T>(this EventHandler<EventArgs<T>> handler, object sender, EventArgs<T> value)
27
        {
28
            handler?.Invoke(sender, value);
29
        }
30
    }
31

  
32
    public class EventArgs<T> : EventArgs
33
    {
34
        public EventArgs(T value)
35
        {
36
            Value = value;
37
        }
38

  
39
        public T Value { get; private set; }
40
    }
41
}
ConvertService/ServiceBase/Markus.Mvvm.ToolKit/RelayCommand/RelayCommand.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Diagnostics.CodeAnalysis;
4
using System.Linq;
5
using System.Text;
6
using System.Threading.Tasks;
7
using System.Windows.Input;
8

  
9
namespace Markus.Mvvm.ToolKit
10
{
11
    public class RelayCommand<T> : ICommand
12
    {
13
        private readonly Predicate<T> _canExecute;
14
        private readonly Action<T> _execute;
15

  
16
        public RelayCommand(Action<T> execute)
17
           : this(execute, null)
18
        {
19
            _execute = execute;
20
        }
21

  
22
        public RelayCommand(Action<T> execute, Predicate<T> canExecute)
23
        {
24
            if (execute == null)
25
            {
26
                throw new ArgumentNullException("execute");
27
            }
28
            _execute = execute;
29
            _canExecute = canExecute;
30
        }
31

  
32
        public bool CanExecute(object parameter)
33
        {
34
            return _canExecute == null || _canExecute((T)parameter);
35
        }
36

  
37
        public void Execute(object parameter)
38
        {
39
            _execute((T)parameter);
40
        }
41

  
42
        public event EventHandler CanExecuteChanged
43
        {
44
            add { CommandManager.RequerySuggested += value; }
45
            remove { CommandManager.RequerySuggested -= value; }
46
        }
47
    }
48

  
49
    public class RelayCommand : ICommand
50
    {
51
        private readonly Predicate<object> _canExecute;
52
        private readonly Action<object> _execute;
53

  
54
        public RelayCommand(Action<object> execute)
55
           : this(execute, null)
56
        {
57
            _execute = execute;
58
        }
59

  
60
        public RelayCommand(Action<object> execute, Predicate<object> canExecute)
61
        {
62
            if (execute == null)
63
            {
64
                throw new ArgumentNullException("execute");
65
            }
66
            _execute = execute;
67
            _canExecute = canExecute;
68
        }
69

  
70
        public bool CanExecute(object parameter)
71
        {
72
            return _canExecute == null || _canExecute(parameter);
73
        }
74

  
75
        public void Execute(object parameter)
76
        {
77
            _execute(parameter);
78
        }
79

  
80
        // Ensures WPF commanding infrastructure asks all RelayCommand objects whether their
81
        // associated views should be enabled whenever a command is invoked 
82
        public event EventHandler CanExecuteChanged
83
        {
84
            add
85
            {
86
                CommandManager.RequerySuggested += value;
87
                CanExecuteChangedInternal += value;
88
            }
89
            remove
90
            {
91
                CommandManager.RequerySuggested -= value;
92
                CanExecuteChangedInternal -= value;
93
            }
94
        }
95

  
96
        private event EventHandler CanExecuteChangedInternal;
97

  
98
        public void RaiseCanExecuteChanged()
99
        {
100
            CanExecuteChangedInternal.Raise(this);
101
        }
102
    }
103
}
ConvertService/ServiceBase/Markus.Mvvm.ToolKit/TaskUtilities.cs
1
using System;
2
using System.Threading.Tasks;
3

  
4
namespace Markus.Mvvm.ToolKit
5
{
6
    public static class TaskUtilities
7
    {
8
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
9
        public static async void FireAndForgetSafeAsync(this Task task, IErrorHandler handler = null)
10
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
11
        {
12
            try
13
            {
14
                await task;
15
            }
16
            catch (Exception ex)
17
            {
18
                handler?.HandleError(ex);
19
            }
20
        }
21
    }
22
}
ConvertService/ServiceBase/Markus.Mvvm.ToolKit/ViewModelBase.cs
1
namespace Markus.Mvvm.ToolKit
2
{
3
    public abstract class ViewModelBase : NotifyExpectation
4
    {
5

  
6
        ViewModelBase viewModel;
7

  
8
        public ViewModelBase ViewModel
9
        {
10
            get { return viewModel; }
11
            set { viewModel = value; }
12
        }
13

  
14
        public string Name
15
        {
16
            get { return ViewModel.Name; }
17
            set
18
            {
19
                if (ViewModel.Name != value)
20
                {
21
                    ViewModel.Name = value;
22
                    OnPropertyChanged(()=>Name);
23
                }
24
            }
25
        }
26
    }
27
}
ConvertService/ServiceBase/Markus.Service.StationController/App.config
1
<?xml version="1.0" encoding="utf-8"?>
1
<?xml version="1.0" encoding="utf-8"?>
2 2
<configuration>
3 3
    <startup> 
4
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
4
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
5 5
    </startup>
6 6
  <runtime>
7 7
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8
      <dependentAssembly>
8
      <probing privatePath="bin"/>
9
      <!--<dependentAssembly>
9 10
        <assemblyIdentity name="CommonServiceLocator" publicKeyToken="489b6accfaf20ef0" culture="neutral" />
10 11
        <bindingRedirect oldVersion="0.0.0.0-2.0.4.0" newVersion="2.0.4.0" />
11
      </dependentAssembly>
12
      </dependentAssembly>-->
12 13
    </assemblyBinding>
13 14
  </runtime>
14 15
    <system.serviceModel>
15 16
        <bindings>
16 17
            <basicHttpBinding>
17
                <binding name="BasicHttpBinding_IStationService" />
18
                <binding name="BasicHttpBinding_IStationService"/>
18 19
            </basicHttpBinding>
19 20
        </bindings>
20 21
        <client>
21
            <endpoint address="http://192.168.0.76:9111/StationService" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStationService" contract="StationService.IStationService" name="BasicHttpBinding_IStationService" />
22
            <endpoint address="http://192.168.0.76:9111/StationService" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStationService" contract="StationService.IStationService" name="BasicHttpBinding_IStationService"/>
22 23
        </client>
23 24
    </system.serviceModel>
24 25
</configuration>
ConvertService/ServiceBase/Markus.Service.StationController/App.xaml.cs
14 14
    /// </summary>
15 15
    public partial class App : Application
16 16
    {
17
        private System.Windows.Forms.NotifyIcon _notifyIcon;
18
        private bool _isExit;
17
        //private System.Windows.Forms.NotifyIcon _notifyIcon;
18
        //private bool _isExit;
19 19

  
20 20
        protected override void OnStartup(StartupEventArgs e)
21 21
        {
......
33 33

  
34 34
        private void CreateContextMenu()
35 35
        {
36
            _notifyIcon.ContextMenuStrip =
37
              new System.Windows.Forms.ContextMenuStrip();
38
            _notifyIcon.ContextMenuStrip.Items.Add("MainWindow...").Click += (s, e) => ShowMainWindow();
39
            _notifyIcon.ContextMenuStrip.Items.Add("Exit").Click += (s, e) => ExitApplication();
36
            //_notifyIcon.ContextMenuStrip =
37
            //  new System.Windows.Forms.ContextMenuStrip();
38
            //_notifyIcon.ContextMenuStrip.Items.Add("MainWindow...").Click += (s, e) => ShowMainWindow();
39
            //_notifyIcon.ContextMenuStrip.Items.Add("Exit").Click += (s, e) => ExitApplication();
40 40
        }
41 41

  
42 42
        private void ExitApplication()
43 43
        {
44
            _isExit = true;
45
            MainWindow.Close();
46
            _notifyIcon.Dispose();
47
            _notifyIcon = null;
44
            //_isExit = true;
45
            //MainWindow.Close();
46
            //_notifyIcon.Dispose();
47
            //_notifyIcon = null;
48 48
        }
49 49

  
50 50
        private void ShowMainWindow()
......
63 63
            }
64 64
        }
65 65

  
66
        private void MainWindow_Closing(object sender, CancelEventArgs e)
67
        {
68
            if (!_isExit)
69
            {
70
                e.Cancel = true;
71
                MainWindow.Hide(); // A hidden window can be shown again, a closed one not
72
            }
73
        }
66
        //private void MainWindow_Closing(object sender, CancelEventArgs e)
67
        //{
68
        //    if (!_isExit)
69
        //    {
70
        //        e.Cancel = true;
71
        //        MainWindow.Hide(); // A hidden window can be shown again, a closed one not
72
        //    }
73
        //}
74 74

  
75 75
    }
76 76
}
ConvertService/ServiceBase/Markus.Service.StationController/Base/Notification.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Linq.Expressions;
6
using System.Text;
7
using System.Threading.Tasks;
8

  
9
namespace Markus.Service.StationController.Base
10
{
11
    public class NotifyExpectation : INotifyPropertyChanged
12
    {
13
        public event PropertyChangedEventHandler PropertyChanged;
14
        protected virtual void OnPropertyChanged(Expression<Func<object>> propertyExpression)
15
        {
16
            PropertyChangedEventHandler handler = PropertyChanged;
17
            if (handler != null) handler(this, new PropertyChangedEventArgs(GetPropertyName(propertyExpression)));
18
        }
19

  
20
        private string GetPropertyName(Expression<Func<object>> propertyExpression)
21
        {
22
            var unaryExpression = propertyExpression.Body as UnaryExpression;
23
            var memberExpression = unaryExpression == null ? (MemberExpression)propertyExpression.Body : (MemberExpression)unaryExpression.Operand;
24
            var propertyName = memberExpression.Member.Name;
25
            return propertyName;
26
        }
27
    }
28
}
ConvertService/ServiceBase/Markus.Service.StationController/Base/ViewModelBase.cs
1
using Microsoft.EntityFrameworkCore.Metadata.Internal;
2
using System;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5
using System.Linq;
6
using System.Linq.Expressions;
7
using System.Text;
8
using System.Threading.Tasks;
9

  
10
namespace Markus.Service.StationController.Base
11
{
12
    public abstract class ViewModelBase : Base.NotifyExpectation
13
    {
14

  
15
        ViewModelBase viewModel;
16

  
17
        public ViewModelBase ViewModel
18
        {
19
            get { return viewModel; }
20
            set { viewModel = value; }
21
        }
22

  
23
        public string Name
24
        {
25
            get { return ViewModel.Name; }
26
            set
27
            {
28
                if (ViewModel.Name != value)
29
                {
30
                    ViewModel.Name = value;
31
                    OnPropertyChanged(()=>Name);
32
                }
33
            }
34
        }
35
    }
36
}
ConvertService/ServiceBase/Markus.Service.StationController/MainWindow.xaml
2 2
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
3 3
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4 4
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
        xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
6 5
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
7
        xmlns:materialEx="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
8 6
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
7
        xmlns:mvvmToolkit="clr-namespace:Markus.Mvvm.ToolKit;assembly=Markus.Mvvm.ToolKit"
9 8
        TextElement.Foreground="{DynamicResource MaterialDesignBody}"
10 9
        mc:Ignorable="d"
10
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
11 11
        xmlns:local="clr-namespace:Markus.Service.StationController.ViewModel"
12 12
        Title="Markus Convert Service" Height="450" Width="800" Foreground="{DynamicResource {x:Static SystemColors.MenuHighlightBrushKey}}">
13
    <i:Interaction.Triggers>
14
        <i:EventTrigger  EventName="Loaded">
15
            <i:InvokeCommandAction Command="{Binding LoadedCommand}"/>
16
        </i:EventTrigger>
17
        <i:EventTrigger  EventName="Closing">
18
            <i:InvokeCommandAction Command="{Binding ClosingCommand}"/>
19
        </i:EventTrigger>
20
    </i:Interaction.Triggers>
13 21
    <Window.DataContext>
14 22
        <local:MainViewModel/>
15 23
    </Window.DataContext>
16
        <materialDesign:DialogHost x:Name="m_dialogHost" Identifier="dialogHost" DialogTheme="Light">
24
    <materialDesign:DialogHost x:Name="m_dialogHost" Identifier="dialogHost" DialogTheme="Light">
17 25
            <materialDesign:DrawerHost IsLeftDrawerOpen="{Binding Path=IsNavigationDrawerOpen, ElementName=appBar}" LeftDrawerBackground="{DynamicResource MaterialDesignBackground}">
18 26
                <!--<materialDesign:DrawerHost.LeftDrawerContent>
19 27
                <materialEx:SideNavigation Items="{Binding NavigationItems,Mode=OneTime}" Width="280"/>
......
51 59
                            <materialDesign:MaterialDataGridTextColumn Header="Status" Binding="{Binding ConvertState}"/>
52 60
                            <materialDesign:MaterialDataGridTextColumn Header="Current Page" Binding="{Binding CurrentPageNo}"/>
53 61
                            <materialDesign:MaterialDataGridTextColumn Header="TotalPage" Binding="{Binding TotalPage}"/>
54

  
55 62
                            <materialDesign:MaterialDataGridTextColumn Header="Originfile" Binding="{Binding OriginfilePath}"/>
56 63
                            <materialDesign:MaterialDataGridTextColumn Header="Output Path" Binding="{Binding ConvertPath}"/>
57 64
                        </DataGrid.Columns>
ConvertService/ServiceBase/Markus.Service.StationController/Markus.Service.StationController.csproj
2 2
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 3
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4 4
  <PropertyGroup>
5
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
5 6
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6 7
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7 8
    <ProjectGuid>{9D993D6E-3A7B-470E-B5AD-D2CF89633F1C}</ProjectGuid>
......
26 27
    <DefineConstants>DEBUG;TRACE</DefineConstants>
27 28
    <ErrorReport>prompt</ErrorReport>
28 29
    <WarningLevel>4</WarningLevel>
29
    <Prefer32Bit>true</Prefer32Bit>
30
    <Prefer32Bit>false</Prefer32Bit>
30 31
  </PropertyGroup>
31 32
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
32 33
    <PlatformTarget>AnyCPU</PlatformTarget>
......
54 55
    <Reference Include="Microsoft.EntityFrameworkCore">
55 56
      <HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore\2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll</HintPath>
56 57
    </Reference>
58
    <Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
59
      <HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath>
60
    </Reference>
57 61
    <Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
58 62
    <Reference Include="System" />
59 63
    <Reference Include="System.Data" />
......
61 65
    <Reference Include="System.Runtime.Serialization" />
62 66
    <Reference Include="System.ServiceModel" />
63 67
    <Reference Include="System.Windows.Forms" />
68
    <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
69
      <HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll</HintPath>
70
    </Reference>
64 71
    <Reference Include="System.Xml" />
65 72
    <Reference Include="Microsoft.CSharp" />
66 73
    <Reference Include="System.Core" />
......
79 86
      <Generator>MSBuild:Compile</Generator>
80 87
      <SubType>Designer</SubType>
81 88
    </ApplicationDefinition>
82
    <Compile Include="Base\Notification.cs" />
83
    <Compile Include="Base\ViewModelBase.cs" />
84 89
    <Compile Include="ViewModel\MainViewModel.cs" />
85 90
    <Page Include="MainWindow.xaml">
86 91
      <Generator>MSBuild:Compile</Generator>
......
175 180
    <None Include="Resources\Tranfer_Error.ico" />
176 181
  </ItemGroup>
177 182
  <ItemGroup>
183
    <ProjectReference Include="..\Markus.Mvvm.ToolKit\Markus.Mvvm.ToolKit.csproj">
184
      <Project>{9efe95d6-9985-422a-a76f-285c8cf73617}</Project>
185
      <Name>Markus.Mvvm.ToolKit</Name>
186
    </ProjectReference>
178 187
    <ProjectReference Include="..\Markus.Service.Extensions\Markus.Service.Extensions.csproj">
179 188
      <Project>{5f983789-3e8f-4f9a-a601-138c3a83ca5f}</Project>
180 189
      <Name>Markus.Service.Extensions</Name>
181 190
    </ProjectReference>
182 191
  </ItemGroup>
183 192
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
193
  <PropertyGroup>
194
    <PostBuildEvent>mkdir $(TargetDir)Bin
195
MOVE $(TargetDir)*.dll $(TargetDir)Bin\
196
</PostBuildEvent>
197
  </PropertyGroup>
184 198
</Project>
ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/MainViewModel.cs
4 4
using System.ServiceModel;
5 5
using System.Text;
6 6
using System.Threading.Tasks;
7
using System.Windows.Input;
8
using Markus.Mvvm.ToolKit;
7 9
using Markus.Service.Helper;
8 10
using Markus.Service.StationController.StationService;
9 11
using MaterialDesignExtensions.Model;
10 12

  
11 13
namespace Markus.Service.StationController.ViewModel
12 14
{
13
    public class MainViewModel : Base.ViewModelBase
15
    public class MainViewModel : ViewModelBase
14 16
    {
15 17
        StationService.StationServiceClient client;
18
        System.Windows.Threading.DispatcherTimer timer;
19
        bool IsTimer;
16 20

  
17
        public MainViewModel()
21
        #region Command
22

  
23
        private ICommand _ClosingCommand;
24
        public ICommand ClosingCommand
25
        {
26
            get => _ClosingCommand ?? (_ClosingCommand = new RelayCommand(param => this.Closing()));
27
        }
28

  
29
        private ICommand _LoadedCommand;
30
        public ICommand LoadedCommand
31
        {
32
            get => _LoadedCommand ?? (_LoadedCommand = new RelayCommand(param => this.Loaded()));
33
        }
34

  
35
        #endregion Command
36

  
37
        #region 프로퍼티
38

  
39
        private string id;
40

  
41
        public string Id
42
        {
43
            get => id; set
44
            {
45
                id = value;
46
                OnPropertyChanged(() => Id);
47
            }
48
        }
49

  
50
        private List<StationService.ConvertItem> aliveItems;
51

  
52
        public List<ConvertItem> AliveItems
53
        {
54
            get => aliveItems; set
55
            {
56
                aliveItems = value;
57
                OnPropertyChanged(() => AliveItems);
58
            }
59
        }
60

  
61
        private List<INavigationItem> navigationItems;
62

  
63
        public List<INavigationItem> NavigationItems
64
        {
65
            get => navigationItems; set
66
            {
67
                navigationItems = value;
68
                OnPropertyChanged(() => navigationItems);
69
            }
70
        }
71

  
72
        private INavigationItem selectNavigationItem;
73

  
74
        public INavigationItem SelectNavigationItem
75
        {
76
            get => selectNavigationItem; set
77
            {
78
                selectNavigationItem = value;
79
                OnPropertyChanged(() => SelectNavigationItem);
80
            }
81
        }
82

  
83
        #endregion 프로퍼티
84

  
85
        private void Loaded()
18 86
        {
87
            IsTimer = true;
88

  
19 89
            ServiceConnection();
20 90

  
21
            System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
91
            timer = new System.Windows.Threading.DispatcherTimer();
22 92
            timer.Interval = new TimeSpan(0, 0, 1);
23 93
            timer.Tick += Timer_Tick;
24 94
            timer.Start();
......
34 104
            SelectNavigationItem = NavigationItems.First();
35 105
        }
36 106

  
107
        private void Closing()
108
        {
109
            IsTimer = false;
110
        }
111

  
37 112
        private void ServiceConnection()
38 113
        {
39 114
            try
......
66 141
        {
67 142
            try
68 143
            {
144
                if (!IsTimer)
145
                {
146
                    timer.Stop();
147
                }
148

  
69 149
                client.AliveConvertListAsync();
70 150
            }
71 151
            catch (Exception ex)
......
79 159
            AliveItems = e.Result;
80 160
        }
81 161

  
82
        private string id;
83

  
84
        public string Id
85
        {
86
            get => id; set
87
            {
88
                id = value;
89
                OnPropertyChanged(() => Id);
90
            }
91
        }
92

  
93
        private List<StationService.ConvertItem> aliveItems;
94

  
95
        public List<ConvertItem> AliveItems
96
        {
97
            get => aliveItems; set
98
            {
99
                aliveItems = value;
100
                OnPropertyChanged(() => AliveItems);
101
            }
102
        }
103

  
104
        private List<INavigationItem> navigationItems;
105

  
106
        public List<INavigationItem> NavigationItems
107
        {
108
            get => navigationItems; set
109
            {
110
                navigationItems = value;
111
                OnPropertyChanged(() => navigationItems);
112
            }
113
        }
114

  
115
        private INavigationItem selectNavigationItem;
116

  
117
        public INavigationItem SelectNavigationItem
118
        {
119
            get => selectNavigationItem; set
120
            {
121
                selectNavigationItem = value;
122
                OnPropertyChanged(() => SelectNavigationItem);
123
    }
124
}
125 162

  
126 163

  
127 164
    }
ConvertService/ServiceBase/Markus.Service.StationController/packages.config
4 4
  <package id="MaterialDesignExtensions" version="2.6.0" targetFramework="net461" />
5 5
  <package id="MaterialDesignThemes" version="2.5.1" targetFramework="net461" />
6 6
  <package id="Microsoft.CSharp" version="4.5.0" targetFramework="net45" />
7
  <package id="Salaros.ConfigParser" version="0.3.3" targetFramework="net45" />
7
  <package id="Salaros.ConfigParser" version="0.3.3" targetFramework="net461" />
8
  <package id="System.Windows.Interactivity.WPF" version="2.0.20525" targetFramework="net461" />
8 9
</packages>
ConvertService/ServiceBase/ServiceController.sln
7 7
EndProject
8 8
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Markus.Service.Extensions", "Markus.Service.Extensions\Markus.Service.Extensions.csproj", "{5F983789-3E8F-4F9A-A601-138C3A83CA5F}"
9 9
EndProject
10
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Markus.Mvvm.ToolKit", "Markus.Mvvm.ToolKit\Markus.Mvvm.ToolKit.csproj", "{9EFE95D6-9985-422A-A76F-285C8CF73617}"
11
EndProject
10 12
Global
11 13
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 14
		AppVeyor|Any CPU = AppVeyor|Any CPU
......
56 58
		{5F983789-3E8F-4F9A-A601-138C3A83CA5F}.Release|x64.Build.0 = Release|x64
57 59
		{5F983789-3E8F-4F9A-A601-138C3A83CA5F}.Release|x86.ActiveCfg = Release|Any CPU
58 60
		{5F983789-3E8F-4F9A-A601-138C3A83CA5F}.Release|x86.Build.0 = Release|Any CPU
61
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU
62
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.AppVeyor|Any CPU.Build.0 = Release|Any CPU
63
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.AppVeyor|x64.ActiveCfg = Release|Any CPU
64
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.AppVeyor|x64.Build.0 = Release|Any CPU
65
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.AppVeyor|x86.ActiveCfg = Release|Any CPU
66
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.AppVeyor|x86.Build.0 = Release|Any CPU
67
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
68
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Debug|Any CPU.Build.0 = Debug|Any CPU
69
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Debug|x64.ActiveCfg = Debug|Any CPU
70
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Debug|x64.Build.0 = Debug|Any CPU
71
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Debug|x86.ActiveCfg = Debug|Any CPU
72
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Debug|x86.Build.0 = Debug|Any CPU
73
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Release|Any CPU.ActiveCfg = Release|Any CPU
74
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Release|Any CPU.Build.0 = Release|Any CPU
75
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Release|x64.ActiveCfg = Release|Any CPU
76
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Release|x64.Build.0 = Release|Any CPU
77
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Release|x86.ActiveCfg = Release|Any CPU
78
		{9EFE95D6-9985-422A-A76F-285C8CF73617}.Release|x86.Build.0 = Release|Any CPU
59 79
	EndGlobalSection
60 80
	GlobalSection(SolutionProperties) = preSolution
61 81
		HideSolutionNode = FALSE

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)