Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
anoyetta committed Jun 23, 2019
2 parents e9ca966 + 2f5534d commit d538234
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 26 deletions.
47 changes: 36 additions & 11 deletions source/XIVNote/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,29 @@
CornerRadius="2"
Background="{Binding BackgroundBrush, Mode=OneWay}" />

<TextBlock
VerticalAlignment="Top"
HorizontalAlignment="Left"
Margin="8"
Height="60"
Foreground="{Binding ForegroundBrush, Mode=OneWay}"
Text="{Binding Text, Mode=OneWay}"
FontFamily="'Century Gothic', 'Yu Gothic'"
FontSize="15"
TextWrapping="Wrap"
TextTrimming="WordEllipsis" />
<StackPanel>
<TextBlock
Margin="8 8 8 -5"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Foreground="{Binding ForegroundBrush, Mode=OneWay}"
Text="{Binding Name, Mode=OneWay}"
FontFamily="'Century Gothic', 'Yu Gothic'"
FontSize="15"
Visibility="{Binding IsExistsName, Mode=OneWay, Converter={StaticResource VisibilityConverter}}" />

<TextBlock
VerticalAlignment="Top"
HorizontalAlignment="Left"
Margin="8 8 8 8"
Height="60"
Foreground="{Binding ForegroundBrush, Mode=OneWay}"
Text="{Binding Text, Mode=OneWay}"
FontFamily="'Century Gothic', 'Yu Gothic'"
FontSize="14"
TextWrapping="Wrap"
TextTrimming="WordEllipsis" />
</StackPanel>

<DockPanel VerticalAlignment="Bottom" Margin="8">
<metro:ToggleSwitch
Expand All @@ -126,6 +138,19 @@
ToolTip="Lock"
Visibility="{Binding IsWidget, Mode=OneWay, Converter={StaticResource VisibilityConverter}}" />

<Button
DockPanel.Dock="Left"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Margin="3 0 0 0"
Style="{DynamicResource IconButtonStyle}"
Background="Transparent"
Command="{Binding RefreshCommand, Mode=OneWay}"
ToolTip="Reload"
Visibility="{Binding IsWidget, Mode=OneWay, Converter={StaticResource VisibilityConverter}}">
<iconPacks:PackIconMaterial Kind="Reload" Foreground="{DynamicResource AccentColorBrush}" Height="18" Width="18" />
</Button>

<Button
DockPanel.Dock="Right"
HorizontalAlignment="Right"
Expand Down
40 changes: 40 additions & 0 deletions source/XIVNote/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ public partial class Note : BindableBase
[XmlIgnore]
public Guid ID { get; private set; } = Guid.NewGuid();

private string name;

[XmlAttribute]
public string Name
{
get => this.name;
set
{
if (this.SetProperty(ref this.name, value))
{
this.RaisePropertyChanged(nameof(this.IsExistsName));
}
}
}

[XmlIgnore]
public bool IsExistsName => !string.IsNullOrEmpty(this.Name);

private double x;

[XmlAttribute]
Expand Down Expand Up @@ -346,6 +364,28 @@ private async void ExecuteRemoveImageCommand(

#endregion RemoveImage

#region Refresh Callback

[XmlIgnore]
public Action RefreshCallback { get; set; }

private DelegateCommand refreshCommand;

public DelegateCommand RefreshCommand =>
this.refreshCommand ?? (this.refreshCommand = new DelegateCommand(this.ExecuteRefreshCommand));

private async void ExecuteRefreshCommand()
{
if (!this.IsWidget)
{
return;
}

await Task.Run(() => this.RefreshCallback?.Invoke());
}

#endregion Refresh Callback

#region Close

private DelegateCommand closeCommand;
Expand Down
2 changes: 1 addition & 1 deletion source/XIVNote/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly
)]
[assembly: AssemblyVersion("2.1.1.0")]
[assembly: AssemblyVersion("2.1.2.0")]
9 changes: 8 additions & 1 deletion source/XIVNote/Views/NoteConfigView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@

<Grid Margin="10">
<StackPanel>
<metro:MetroHeader Header="Background" metro:ControlsHelper.HeaderFontSize="16">
<metro:MetroHeader Header="Name (Optional)" metro:ControlsHelper.HeaderFontSize="16">
<TextBox
Text="{Binding Model.Name, Mode=TwoWay}"
VerticalContentAlignment="Center"
Height="30" />
</metro:MetroHeader>

<metro:MetroHeader Header="Background" metro:ControlsHelper.HeaderFontSize="16" Margin="0 10 0 0">
<StackPanel Orientation="Horizontal">
<Button
Focusable="False"
Expand Down
44 changes: 34 additions & 10 deletions source/XIVNote/Views/WidgetView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,31 @@
CornerRadius="3"
BorderThickness="0"
Padding="12">
<StackPanel Orientation="Horizontal">
<TextBlock Text="URL" Margin="0 0 10 0" VerticalAlignment="Center" />
<TextBox
x:Name="UrlTextBox"
Width="400"
Height="32"
VerticalContentAlignment="Center"
FontSize="17"
FontFamily="Consolas"
Text="{Binding Model.Text, Mode=TwoWay}" />
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="URL" Margin="0 0 10 0" VerticalAlignment="Center" Width="50" />
<TextBox
x:Name="UrlTextBox"
Width="400"
Height="32"
VerticalContentAlignment="Center"
FontSize="17"
FontFamily="Consolas"
Text="{Binding Model.Text, Mode=TwoWay}" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0 5 0 0">
<TextBlock Text="Name" Margin="0 0 10 0" VerticalAlignment="Center" Width="50" />
<TextBox
x:Name="NameTextBox"
Width="200"
Height="32"
VerticalContentAlignment="Center"
FontSize="17"
FontFamily="Consolas"
Text="{Binding Model.Name, Mode=TwoWay}"
ToolTip="Optional" />
</StackPanel>
</StackPanel>
</Border>
</Border>
Expand Down Expand Up @@ -146,6 +161,15 @@
<iconPacks:PackIconMaterial Kind="Web" />
</Button>

<Button
DockPanel.Dock="Left" HorizontalAlignment="Left"
Height="30" Width="30"
Style="{DynamicResource AlterIconButtonStyle}"
Click="ReloadButton_Click"
ToolTip="Reload">
<iconPacks:PackIconMaterial Kind="Reload" />
</Button>

<Button
DockPanel.Dock="Left" HorizontalAlignment="Left"
Height="30" Width="30"
Expand Down
20 changes: 17 additions & 3 deletions source/XIVNote/Views/WidgetView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ await WPFHelper.Dispatcher.InvokeAsync(() =>
Visibility.Collapsed);
};

this.Note.RefreshCallback = () => this.CefBrowser.Reload();

this.CefBrowser.Address = this.Note?.Text;
this.WebGrid.Children.Add(this.CefBrowser);
};
Expand Down Expand Up @@ -102,15 +104,22 @@ await WPFHelper.Dispatcher.InvokeAsync(() =>
this.UrlPanel.MouseLeftButtonUp += (_, __)
=> this.UrlPanel.Visibility = Visibility.Collapsed;

this.UrlTextBox.KeyUp += async (_, e) =>
this.UrlTextBox.KeyUp += (_, e) => closeInputBox(e);
this.NameTextBox.KeyUp += (_, e) => closeInputBox(e);

async void closeInputBox(KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
this.UrlPanel.Visibility = Visibility.Collapsed;
await WPFHelper.Dispatcher.InvokeAsync(
() => this.ViewModel.Model.Text = this.UrlTextBox.Text);
() =>
{
this.ViewModel.Model.Text = this.UrlTextBox.Text;
this.ViewModel.Model.Name = this.NameTextBox.Text;
});
}
};
}
}

public WidgetViewModel ViewModel => this.DataContext as WidgetViewModel;
Expand Down Expand Up @@ -261,6 +270,11 @@ private async void NaviateUrl(
=> await WPFHelper.Dispatcher.InvokeAsync(
() => this.CefBrowser.Address = url);

private void ReloadButton_Click(object sender, RoutedEventArgs e)
{
this.Note.RefreshCommand.Execute();
}

private void DevToolButton_Click(object sender, RoutedEventArgs e)
{
this.CefBrowser.ShowDevTools();
Expand Down

0 comments on commit d538234

Please sign in to comment.