Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

폰트 지정기능 추가 #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions HangulClock v3.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036
# Visual Studio Version 16
VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HangulClockDataKit", "HangulClockDataKit\HangulClockDataKit.csproj", "{78753ECD-E7BB-472A-A89A-444D4F6E02B2}"
EndProject
Expand Down
48 changes: 46 additions & 2 deletions HangulClock/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.35.1.0" newVersion="1.35.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth.PlatformServices" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.35.1.0" newVersion="1.35.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.1.0" newVersion="3.5.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Api.Gax" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Api.Gax.Grpc" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Api.CommonProtos" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Expression.Drawing" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
24 changes: 24 additions & 0 deletions HangulClock/ClockSettingTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
<FontFamily x:Key="NanumSquareRegular">/Resources/#NanumSquare</FontFamily>
</UserControl.Resources>
<Grid>
<Label x:Name="clockFontText" Content="시계 글꼴" Foreground="White" FontFamily="{StaticResource NanumSquareRegular}" FontSize="17" Margin="643,235,289,207" />
<Button x:Name="clockFontValueText" Content="Noto Sans" FontFamily="{StaticResource NanumSquareRegular}" FontSize="17" Margin="520,232,401,432" Click="clockFontValueText_Click" BorderBrush="White">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<uiKit:HangulClock x:Name="hangulClock" Width="310" Height="310" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="120,194,0,196" ClockFontSize="30" ShowClockBold="True" />
<!-- <uiKit:MinimalButton x:Name="clockPositionSettingButton" ButtonText="시계 위치 설정" Width="150" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="200,530,0,110" /> -->

Expand Down
37 changes: 37 additions & 0 deletions HangulClock/ClockSettingTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Drawing;
using System.Windows.Threading;

namespace HangulClock
{
Expand Down Expand Up @@ -33,12 +35,23 @@ public void loadInitData()

bool isWhiteClock = !monitorSetting.IsWhiteClock;
int clockSize = monitorSetting.ClockSize;
string font = monitorSetting.FontName;

this.Dispatcher.Invoke(new Action(() =>
{
clockColorToggle.IsChecked = isWhiteClock;
clockSizeSlider.Value = clockSize;
clockSizeValueText.Content = String.Format(CLOCK_SIZE, clockSizeSlider.Value);

try
{
var cvt = new FontConverter();
Font f = cvt.ConvertFromString(font) as Font;
clockFontValueText.Content = f.Name;
}catch
{
clockFontValueText.Content = "Noto Sans";
}
}));
}).Start();
}
Expand Down Expand Up @@ -92,5 +105,29 @@ private void clockColorToggle_Unchecked(object sender, RoutedEventArgs e)
});
}).Start();
}

private void clockFontValueText_Click(object sender, RoutedEventArgs e)
{
new Thread(() =>
{
var fontDialog= new System.Windows.Forms.FontDialog();
fontDialog.ShowColor = false;
fontDialog.ShowEffects = false;

if (fontDialog.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
{
var changedFont = fontDialog.Font.Name.ToString();
Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { clockFontValueText.Content = changedFont; }));
var DataKit = new DataKit();
var monitorSetting = (from c in DataKit.Realm.All<ClockSettingsByMonitor>() where c.MonitorDeviceName == MainWindow.MonitorDeviceName select c).First();
var cvt = new FontConverter();
var fontSerial= cvt.ConvertToString(fontDialog.Font);
DataKit.Realm.Write(() =>
{
monitorSetting.FontName = fontSerial;
});
}
}).Start();
}
}
}
15 changes: 12 additions & 3 deletions HangulClockDataKit/DataKit.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

using Realms;
using Realms;
using HangulClockDataKit.Model;
using System.Linq;

namespace HangulClockDataKit
{
Expand All @@ -11,7 +12,15 @@ public DataKit()
{
var config = new RealmConfiguration("C:\\Hangul Clock Configuration Files\\")
{
SchemaVersion = 5,
SchemaVersion = 6,
MigrationCallback = (migration, oldSchemaVersion) =>
{
if (oldSchemaVersion < 6)
{
var newBackgroundSetting = migration.NewRealm.All<ClockSettingsByMonitor>();
var oldBackgroundSetting = migration.OldRealm.All("ClockSettingsByMonitor").ToList();
}
}
};

Realm = Realm.GetInstance(config);
Expand Down
1 change: 1 addition & 0 deletions HangulClockDataKit/Model/ClockSettingsByMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public class ClockSettingsByMonitor : RealmObject
public int ClockSize { get; set; }

public bool isUseHangulClock { get; set; }
public string FontName { get; set; }
}
}
50 changes: 49 additions & 1 deletion HangulClockRenderer/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.35.1.0" newVersion="1.35.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth.PlatformServices" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.35.1.0" newVersion="1.35.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.1.0" newVersion="3.5.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Api.Gax" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Api.Gax.Grpc" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Api.CommonProtos" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Remotion.Linq" publicKeyToken="fee00910d6e5f53b" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
7 changes: 7 additions & 0 deletions HangulClockRenderer/HangulClockDesktop.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ public void SetClockColor(bool isWhite)
}
}

public void SetClockFont(string fontName)
{
BrushConverter bc = new BrushConverter();
hangulClock.FontFamily = new FontFamily(fontName);
hangulClockBlack.FontFamily = new FontFamily(fontName);
}

private void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
{

Expand Down
15 changes: 15 additions & 0 deletions HangulClockRenderer/HangulClockRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Windows;
using System.Windows.Interop;
using System.Windows.Threading;
using System.Drawing;

namespace HangulClockRenderer
{
Expand Down Expand Up @@ -286,6 +287,19 @@ private static void MainThread()

int clockSize = clockSetting.ClockSize;
bool isWhiteClick = clockSetting.IsWhiteClock;
string fontName;

try
{
var cvt = new FontConverter();
Font f = cvt.ConvertFromString(clockSetting.FontName) as Font;
fontName = f.Name;
}
catch
{
fontName = "/Resources/#Noto Sans KR Regular";
}

int clockDirection = commentSetting.DirectionOfComment;

string name = commentSetting.Name;
Expand Down Expand Up @@ -334,6 +348,7 @@ private static void MainThread()
hangulClockDesktop.ucScale.ScaleY = (double)clockSize / 100;

hangulClockDesktop.SetClockColor(isWhiteClick);
hangulClockDesktop.SetClockFont(fontName);

if (clockDirection == CommentSettingsByMonitor.CommentDirection.TOP)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@

namespace HangulClockUIKit.Controls.Converters
{
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{

bool vis = System.Convert.ToBoolean(value);
return vis ? Visibility.Visible : Visibility.Hidden;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
Visibility vis = (Visibility)value;
return (vis == Visibility.Visible);
}
}

public class InvertingBooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{

bool vis = System.Convert.ToBoolean(value);
return vis ? Visibility.Hidden : Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
Visibility vis = (Visibility)value;
return (vis == Visibility.Hidden);
}
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool vis = System.Convert.ToBoolean(value);
return vis ? Visibility.Visible : Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
Visibility vis = (Visibility)value;
return (vis == Visibility.Visible);
}
}
public class InvertingBooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool vis = System.Convert.ToBoolean(value);
return vis ? Visibility.Hidden : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
Visibility vis = (Visibility)value;
return (vis == Visibility.Hidden);
}
}
}
Loading