Skip to content

Commit

Permalink
Merge branch 'dev1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
teranum committed Jan 11, 2024
2 parents 1b38751 + 3b47c46 commit eba1a6c
Show file tree
Hide file tree
Showing 20 changed files with 228 additions and 71 deletions.
19 changes: 19 additions & 0 deletions src/KOAStudio.Core/Helpers/GithubVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;

namespace KOAStudio.Core.Helpers
{
public record GithubTagInfo(string html_url, string tag_name, string name, string published_at, string body);
public static class GithubVersion
{
public static Task<IList<GithubTagInfo>?> GetRepoTagInfos(string Username, string Repository)
{
// 깃헙 릴리즈 태그에서 가져오기
HttpClient client = new();
var pih = ProductInfoHeaderValue.Parse(Repository);
client.DefaultRequestHeaders.UserAgent.Add(pih);
return client.GetFromJsonAsync<IList<GithubTagInfo>>($"https://api.github.com/repos/{Username}/{Repository}/releases");
}
}
}
2 changes: 1 addition & 1 deletion src/KOAStudio.Core/Helpers/OcxPathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static string GetDefaultRegistryValue(RegistryKey rootKey, string regPat
using var regKey = rootKey.OpenSubKey(regPath);
if (regKey != null)
{
string defaultValue = (string)regKey.GetValue("");
if (regKey.GetValue("") is string defaultValue)
{
return defaultValue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/KOAStudio.Core/KOAStudio.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<LangVersion>default</LangVersion>
<!--<TargetFrameworks>net48;net8.0-windows</TargetFrameworks>-->
<TargetFramework>net48</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>x86;x64</Platforms>
<NoWarn>$(NoWarn);MA0048;MA0053;MA0069</NoWarn>
<NoWarn>$(NoWarn);MA0048;MA0053;MA0069;IDE1006</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -21,6 +20,7 @@
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="*" />
<PackageReference Include="AvalonEdit" Version="*" />
<PackageReference Include="KHOpenApi.NET" Version="*" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
62 changes: 55 additions & 7 deletions src/KOAStudio.Core/ViewModels/KOAWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using KOAStudio.Core.Helpers;
using KOAStudio.Core.Models;
using KOAStudio.Core.Services;
using KOAStudio.Core.Views;
using System.Windows.Controls;

namespace KOAStudio.Core.ViewModels
Expand All @@ -11,19 +13,19 @@ internal partial class KOAWindowViewModel : ObservableObject
{
private readonly IUIRequest _uiRequest;
private readonly string _baseTitle;
private readonly string _appVersion;
private IList<GithubTagInfo>? _releaseTags;

public KOAWindowViewModel(IUIRequest uiRequest)
{
var assemblyName = System.Windows.Application.ResourceAssembly.GetName();
_baseTitle = $"{assemblyName.Name} v{assemblyName.Version.Major}.{assemblyName.Version.Minor} - {(Environment.Is64BitProcess ? "64비트" : "32비트")}";
_appVersion = $"{assemblyName.Version!.Major}.{assemblyName.Version.Minor}";
_baseTitle = $"{assemblyName.Name} v{_appVersion} - {(Environment.Is64BitProcess ? "64비트" : "32비트")}";

_uiRequest = uiRequest;
_title = _baseTitle;

_menuCustomizeHeaderText = "Custom";
_searchText = string.Empty;
_resultText = string.Empty;
_statusText = "준비됨";

WeakReferenceMessenger.Default.Register<AppStatusChangedMessageType>(this, (r, m) =>
{
Expand Down Expand Up @@ -65,6 +67,8 @@ public KOAWindowViewModel(IUIRequest uiRequest)
{
UserContent = m.Control;
});

_ = CheckVersionAsync();
}

[ObservableProperty]
Expand All @@ -77,12 +81,15 @@ public KOAWindowViewModel(IUIRequest uiRequest)
private List<string>? _menuCustomizeItems;

[ObservableProperty]
private string _statusText;
private string _statusText = "준비됨";

[ObservableProperty]
private string _statusUrl = string.Empty;

[ObservableProperty]
private string _searchText;
private string _searchText = string.Empty;

private string _resultText;
private string _resultText = string.Empty;
public string ResultText
{
get => _resultText;
Expand Down Expand Up @@ -122,6 +129,47 @@ private void Closed()
_uiRequest.Close();
}

[RelayCommand]
static void Hyperlink_RequestNavigate(Uri url)
{
var sInfo = new System.Diagnostics.ProcessStartInfo(url.AbsoluteUri)
{
UseShellExecute = true,
};
System.Diagnostics.Process.Start(sInfo);
}

private async Task CheckVersionAsync()
{
// 깃헙에서 최신 버전 정보 가져오기

_releaseTags = await GithubVersion.GetRepoTagInfos("teranum", "KOAStudio").ConfigureAwait(true);
if (_releaseTags != null && _releaseTags.Count > 0)
{
var lastTag = _releaseTags[0];
if (string.Equals(lastTag.tag_name, _appVersion))
{
StatusText = "최신 버전입니다.";
}
else
{
StatusUrl = lastTag.html_url;
StatusText = $"새로운 버전({lastTag.tag_name})이 있습니다.";
}
}
}

[RelayCommand]
void Menu_Version()
{
// 버젼 정보
if (_releaseTags != null && _releaseTags.Count != 0)
{
var versionView = new VersionView(_releaseTags);
versionView.ShowDialog();
}
}

[RelayCommand(CanExecute = nameof(CanMenuLogin))]
private void MenuLogin()
{
Expand Down
14 changes: 14 additions & 0 deletions src/KOAStudio.Core/Views/KOAWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
<MenuItem Header="About">
<MenuItem Command="{Binding Menu_VersionCommand}" Header="버젼정보" />
</MenuItem>
</Menu>
<Grid Margin="3,23,3,26">
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -116,6 +119,17 @@
VerticalAlignment="Bottom"
Background="#FF0C4B73">
<TextBlock Foreground="White" Text="{Binding StatusText}" />
<TextBlock Margin="10,0,0,0">
<Hyperlink
Command="{Binding Hyperlink_RequestNavigateCommand}"
CommandParameter="{Binding NavigateUri, RelativeSource={RelativeSource Self}}"
Foreground="White"
NavigateUri="{Binding StatusUrl}">
<Hyperlink.Inlines>
<Run Text="{Binding StatusUrl}" />
</Hyperlink.Inlines>
</Hyperlink>
</TextBlock>
</StatusBar>
</Grid>
</Window>
52 changes: 52 additions & 0 deletions src/KOAStudio.Core/Views/VersionView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<Window
x:Class="KOAStudio.Core.Views.VersionView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:KOAStudio.Core.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="VersionView"
Width="600"
Height="410"
ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
mc:Ignorable="d">
<Grid Margin="10">
<TextBlock
Margin="0,0,0,10"
FontSize="20"
FontWeight="Bold"
Text="Version Infos" />
<ScrollViewer Margin="0,30,0,0">
<ItemsControl d:ItemsSource="{d:SampleData ItemCount=20}" ItemsSource="{Binding TagInfos}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<GroupBox Margin="0,5" Header="{Binding}">
<StackPanel>
<TextBlock Margin="0,5" Text="{Binding published_at}" />
<TextBox
Height="50"
AcceptsReturn="True"
HorizontalScrollBarVisibility="Auto"
IsReadOnly="True"
Text="{Binding body}"
VerticalScrollBarVisibility="Auto" />
</StackPanel>
<GroupBox.HeaderTemplate>
<DataTemplate>
<TextBlock>
<Hyperlink NavigateUri="{Binding html_url}" RequestNavigate="Hyperlink_RequestNavigate">
<Hyperlink.Inlines>
<Run Text="{Binding tag_name}" />
</Hyperlink.Inlines>
</Hyperlink>
</TextBlock>
</DataTemplate>
</GroupBox.HeaderTemplate>
</GroupBox>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Window>
34 changes: 34 additions & 0 deletions src/KOAStudio.Core/Views/VersionView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using KOAStudio.Core.Helpers;
using System.Diagnostics;
using System.Windows;
using System.Windows.Navigation;

namespace KOAStudio.Core.Views
{
/// <summary>
/// Interaction logic for VersionView.xaml
/// </summary>
public partial class VersionView : Window
{
public IList<GithubTagInfo> TagInfos { get; }

public VersionView(IList<GithubTagInfo> tagInfos)
{
InitializeComponent();
Owner = Application.Current.MainWindow;
TagInfos = tagInfos;

this.DataContext = this;
}

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
var sInfo = new ProcessStartInfo(e.Uri.AbsoluteUri)
{
UseShellExecute = true,
};
Process.Start(sInfo);
e.Handled = true;
}
}
}
2 changes: 2 additions & 0 deletions src/KOAStudio/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using KOAStudio.Core.Services;
using KOAStudio.Core.Views;
using Microsoft.Extensions.DependencyInjection;
using System.Text;
using System.Windows;

namespace KOAStudio
Expand All @@ -15,6 +16,7 @@ public partial class App : Application
{
public App()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Ioc.Default.ConfigureServices(
new ServiceCollection()

Expand Down
1 change: 0 additions & 1 deletion src/KOAStudio/Business/BusinessLogic.ApiEvents.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using KHOpenApi.NET;
using KOAStudio.Core.Helpers;
using KOAStudio.Core.Models;
using KOAStudio.Core.ViewModels;
using System.Diagnostics;
Expand Down
16 changes: 8 additions & 8 deletions src/KOAStudio/Business/BusinessLogic.UIRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void ItemSelectedChanged(int tabIndex, IdTextItem selectedItem)
case TAB_TREE_KIND.TR목록:
{
if (selectedItem.Id != 4 && selectedItem.Id != 14) return;
string selected_code = SelectedText.Substring(0, 8);
string selected_code = SelectedText[..8];
TR_SPECIAL? trData = _trDatas.Find(t => t.Code.Equals(selected_code, StringComparison.CurrentCultureIgnoreCase));
if (trData != null)
{
Expand Down Expand Up @@ -396,15 +396,15 @@ public void ReqTRHistory(int tabIndex, string text)
int nSubPos = text.IndexOf(" : ");
if (nSubPos != -1)
{
codeName = text.Substring(nSubPos + " : ".Length);
codeName = text[(nSubPos + " : ".Length)..];
}
}
}

int nPos = codeName.IndexOf(" : ");
if (nPos != -1)
{
string code = codeName.Substring(0, nPos);
string code = codeName[..nPos];
for (int i = 0; i < _trDatas.Count; i++)
{
var trData = _trDatas[i];
Expand Down Expand Up @@ -437,9 +437,9 @@ public void QueryApiAction(string reqText, object parameters, bool bNext)
if (SelectedText.Length < 7) return;
if (parameters is not IList<PropertyItem> datagrid_PropertiesItems || _axOpenAPI == null || !_axOpenAPI.Created)
return;
if (string.Equals(SelectedText.Substring(0, 2).ToUpper(), "OP")) // TR요청
if (string.Equals(SelectedText[..2].ToUpper(), "OP")) // TR요청
{
string OptCode = SelectedText.Substring(0, SelectedText.IndexOf(" : "));
string OptCode = SelectedText[..SelectedText.IndexOf(" : ")];
for (int i = 0; i < datagrid_PropertiesItems.Count; i++)
{
var nvd = datagrid_PropertiesItems[i];
Expand All @@ -457,7 +457,7 @@ public void QueryApiAction(string reqText, object parameters, bool bNext)
szActionMsg = $"<TR ({OptCode}) 요청: 실패> lRet = {lRet}";
}
}
else if (string.Equals(SelectedText.Substring(0, 7), "조건검색 : ")) // 조건검색
else if (string.Equals(SelectedText[..7], "조건검색 : ")) // 조건검색
{
string? szScrNum = datagrid_PropertiesItems[0].Value;
string? szCondName = datagrid_PropertiesItems[1].Value;
Expand All @@ -477,9 +477,9 @@ public void QueryApiAction(string reqText, object parameters, bool bNext)
szActionMsg = $"<조건검색 ({szCondName}) 요청: 실패> lRet = {lRet}";
}
}
else if (string.Equals(SelectedText.Substring(0, 7), "함수호출 : ")) // 함수호출
else if (string.Equals(SelectedText[..7], "함수호출 : ")) // 함수호출
{
string szFuncName = SelectedText.Substring("함수호출 : ".Length);
string szFuncName = SelectedText["함수호출 : ".Length..];
VariantWrapper[] Params = new VariantWrapper[datagrid_PropertiesItems.Count];

string parameter_text = string.Empty;
Expand Down
3 changes: 1 addition & 2 deletions src/KOAStudio/Business/BusinessLogic.UserContent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using KOAStudio.Core.Helpers;
using KOAStudio.Core.Models;
using KOAStudio.Core.Models;
using KOAStudio.Core.ViewModels;
using KOAStudio.Core.Views;
using System.Diagnostics;
Expand Down
Loading

0 comments on commit eba1a6c

Please sign in to comment.