Skip to content

Commit

Permalink
Added Web open feature
Browse files Browse the repository at this point in the history
  • Loading branch information
EX3exp committed Sep 29, 2024
1 parent 0767467 commit 20c4839
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 13 deletions.
10 changes: 9 additions & 1 deletion Mirivoice/Assets/Lang/strings-en-US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
<system:String x:Key="app.no">No</system:String>
<system:String x:Key="app.cancel">Cancel</system:String>
<system:String x:Key="app.ok">OK</system:String>

<system:String x:Key="app.beforeExit">Current Project File is not saved. Do you want to save? </system:String>
<system:String x:Key="app.openproject">Open Project</system:String>
<system:String x:Key="app.saveproject">Save Mrp</system:String>

<system:String x:Key="app.defprojectname">New Project</system:String>
<system:String x:Key="app.Error">Error</system:String>

Expand All @@ -31,8 +33,10 @@
<system:String x:Key="menu.files.recent">Recent...</system:String>
<system:String x:Key="menu.files.openFailed">An Error occured during open file.
Please Check Log file for more informations.</system:String>

<system:String x:Key="menu.files.recent.openFailed">Selected Recent file not exists.
It seems to be already removed from your disk.</system:String>

<system:String x:Key="menu.files.save">Save</system:String>
<system:String x:Key="menu.files.saveas">Save As...</system:String>
<system:String x:Key="menu.files.new">New</system:String>
Expand All @@ -55,16 +59,19 @@
<system:String x:Key="menu.project.title">Project</system:String>
<system:String x:Key="menu.project.undo">Undo</system:String>
<system:String x:Key="menu.project.redo">Redo</system:String>

<system:String x:Key="menu.project.pref">Project Expressions</system:String>
<system:String x:Key="menu.project.clearCache">Clear Cache</system:String>

<!--tools...-->
<system:String x:Key="menu.tools.title">Tools</system:String>
<system:String x:Key="menu.tools.settings">Global Settings</system:String>
<system:String x:Key="menu.tools.voicers">Voicers</system:String>

<system:String x:Key="menu.tools.voicerinstall">Install Voicer...</system:String>
<system:String x:Key="menu.tools.voicerinstall.desc">Select .zip file to install Voicer</system:String>
<system:String x:Key="menu.tools.voicerinstall.process">Installing Voicer...</system:String>

<system:String x:Key="menu.tools.voicerinstall.error">Failed to install Voicer.
There's no voicer.yaml inside the archive.</system:String>
<system:String x:Key="menu.tools.voicerinstall.success">Voicer installed successfully!</system:String>
Expand All @@ -85,6 +92,7 @@
<!--help...-->
<system:String x:Key="menu.help.title">Help</system:String>
<system:String x:Key="menu.help.update">Check Updates</system:String>
<system:String x:Key="menu.help.github">Visit GitHub</system:String>

<!--editor body 1 -->
<system:String x:Key="editor.input.mult.title">Lines Input</system:String>
Expand All @@ -97,7 +105,7 @@
안녕하세요!
[미리] (bright)
날씨가 좋네요! </system:String>
<system:String x:Key="editor.input.mult.placeholder">Input your Lines here... </system:String>

<system:String x:Key="editor.input.mult.lineCount">Lines: {0}</system:String>

<system:String x:Key="editor.input.mult.defaultVoicerName">Default Voicer</system:String>
Expand Down
1 change: 1 addition & 0 deletions Mirivoice/Mirivoice.Core/Managers/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ public void StopAudio()
_audioReaders.Clear();
_waveOut.Stop();
_waveOut.Dispose();
v.MainWindowGetInput = true;
MainViewModelPlaying = false;
}

Expand Down
6 changes: 3 additions & 3 deletions Mirivoice/ViewModels/LineBoxViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public override void OnVoicerChanged(Voicer voicer)
}
else
{
var uri = new Uri("avares://Mirivoice/Assets/default_icon.bmp");
var uri = new Uri("avares://Mirivoice.Main/Assets/default_icon.bmp");
var assets = AssetLoader.Open(uri);

using (var stream = assets)
Expand Down Expand Up @@ -233,7 +233,7 @@ public LineBoxViewModel(LineBoxView l): base(true)
}
else
{
var uri = new Uri("avares://Mirivoice/Assets/default_icon.bmp");
var uri = new Uri("avares://Mirivoice.Main/Assets/default_icon.bmp");
var assets = AssetLoader.Open(uri);

using (var stream = assets)
Expand Down Expand Up @@ -276,7 +276,7 @@ public LineBoxViewModel(int voicerIndex, int metaIndex, LineBoxView l) : base(vo
}
else
{
var uri = new Uri("avares://Mirivoice/Assets/default_icon.bmp");
var uri = new Uri("avares://Mirivoice.Main/Assets/default_icon.bmp");
var assets = AssetLoader.Open(uri);

using (var stream = assets)
Expand Down
4 changes: 4 additions & 0 deletions Mirivoice/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public async void OnSaveAsButtonClick()
await SaveAs();
}

public void OnGithubButtonClick()
{
VoicersWindow.OpenUrl("https://github.com/EX3exp/MiriVoice");
}
public async Task SaveProject(bool forceSaveAs = false)
{
if (File.Exists(CurrentProjectPath) && !forceSaveAs)
Expand Down
7 changes: 4 additions & 3 deletions Mirivoice/ViewModels/VoicersVoicerButtonViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public VoicersVoicerButtonViewModel(Voicer voicer, VoicersWindowViewModel v, Mai
}
else
{
var uri = new Uri("avares://Mirivoice/Assets/default_icon.bmp");
var uri = new Uri("avares://Mirivoice.Main/Assets/default_icon.bmp");
var assets = AssetLoader.Open(uri);

using (var stream = assets)
Expand Down Expand Up @@ -114,6 +114,7 @@ public void OnButtonClick()
v.Illustrator = Voicer.Info.Illustrator;
v.Version = Voicer.Info.Version;
v.Description = Voicer.Info.Description;
v.Web = Voicer.Info.Web;

VoicerInfo vInfo = Voicer.Info;
Voicer voicer = Voicer;
Expand All @@ -135,7 +136,7 @@ public void OnButtonClick()
}
else
{
var uri = new Uri("avares://Mirivoice/Assets/default_portrait.bmp");
var uri = new Uri("avares://Mirivoice.Main/Assets/default_portrait.bmp");
var assets = AssetLoader.Open(uri);

using (var stream = assets)
Expand Down Expand Up @@ -166,7 +167,7 @@ public void OnButtonClick()
}
else
{
var uri = new Uri("avares://Mirivoice/Assets/default_icon.bmp");
var uri = new Uri("avares://Mirivoice.Main/Assets/default_icon.bmp");
var assets = AssetLoader.Open(uri);

using (var stream = assets)
Expand Down
2 changes: 1 addition & 1 deletion Mirivoice/Views/LineBoxView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<StackPanel Margin="0 0 0 0" Grid.Column="2" Grid.RowSpan="2" Width="100">
<Rectangle Margin="0 0 0 0" Width="100" Height="70" Fill="{Binding Icon}" />

<ComboBox HorizontalContentAlignment="Left" ItemsSource="{Binding voicerSelector.Voicers, Mode=TwoWay}" Cursor="Hand" SelectedIndex="{Binding voicerSelector.CurrentDefaultVoicerIndex, Mode=TwoWay}" Margin="0 0 0 0" Grid.Column="1" Grid.Row="2" FontSize="15" Height="34" Width="100" CornerRadius="2" TextBlock.TextTrimming="CharacterEllipsis" VerticalAlignment="Center" >
<ComboBox HorizontalContentAlignment="Left" ItemsSource="{Binding voicerSelector.Voicers, Mode=TwoWay}" Cursor="Hand" SelectedIndex="{Binding voicerSelector.CurrentDefaultVoicerIndex, Mode=TwoWay}" Margin="0 0 0 0" Grid.Column="1" Grid.Row="2" FontSize="13" Height="35" Width="100" CornerRadius="2" TextBlock.TextTrimming="CharacterEllipsis" VerticalAlignment="Center" >
<ComboBox.ItemTemplate>

<DataTemplate>
Expand Down
1 change: 1 addition & 0 deletions Mirivoice/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

<MenuItem Header="{DynamicResource menu.help.title}">
<MenuItem Header="{DynamicResource menu.help.update}" Command="{Binding OnUpdateCheckButtonClick}"></MenuItem>
<MenuItem Header="{DynamicResource menu.help.github}" Command="{Binding OnGithubButtonClick}"></MenuItem>
</MenuItem>
</Menu>

Expand Down
10 changes: 5 additions & 5 deletions Mirivoice/Views/VoicersWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 0 0 0">
<TextBlock TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{DynamicResource voicers.author}" FontSize="15" Margin="0 0 0 0" FontWeight="Bold" Foreground="DarkOliveGreen"></TextBlock>
<TextBlock TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{Binding Author}" FontSize="11" Margin="10 0 0 0" FontWeight="Light" ></TextBlock>
<TextBlock xml:space="preserve" TextAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{Binding Author}" FontSize="11" Margin="10 0 0 0" FontWeight="Light" ></TextBlock>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0 0 0 0" >
<TextBlock TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{DynamicResource voicers.voice}" FontSize="15" Margin="0 0 0 0" FontWeight="Bold" Foreground="DarkOliveGreen"></TextBlock>
<TextBlock TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{Binding Voice}" FontSize="11" Margin="10 0 0 0" FontWeight="Light" ></TextBlock>
<TextBlock xml:space="preserve" TextAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{Binding Voice}" FontSize="11" Margin="10 0 0 0" FontWeight="Light" ></TextBlock>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0 0 0 0">
<TextBlock TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{DynamicResource voicers.engineer}" FontSize="15" Margin="0 0 0 0" FontWeight="Bold" Foreground="DarkOliveGreen"></TextBlock>
<TextBlock TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{Binding Engineer}" FontSize="11" Margin="10 0 0 0 " FontWeight="Light" ></TextBlock>
<TextBlock xml:space="preserve" TextAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{Binding Engineer}" FontSize="11" Margin="10 0 0 0 " FontWeight="Light" ></TextBlock>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0 0 0 0" >
<TextBlock TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{DynamicResource voicers.illust}" FontSize="15" Margin="0 0 0 0" FontWeight="Bold" Foreground="DarkOliveGreen"></TextBlock>
<TextBlock TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{Binding Illustrator}" FontSize="11" Margin="10 0 0 0" FontWeight="Light" ></TextBlock>
<TextBlock xml:space="preserve" TextAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" Height="48" LineHeight="15" Text="{Binding Illustrator}" FontSize="11" Margin="10 0 0 0" FontWeight="Light" ></TextBlock>
</StackPanel>
</StackPanel>

Expand All @@ -96,7 +96,7 @@
</Grid>
<Grid Grid.Column="3" Margin="10 5 5 5">
<StackPanel VerticalAlignment="Stretch" Width="280" >
<TextBlock Height="124" VerticalAlignment="Center" TextWrapping="Wrap" Foreground="DarkOliveGreen" LineHeight="26" MaxLines="4" Text="{Binding Name}" FontSize="45" Margin="15 30 10 10" Padding="10 10 10 10" FontWeight="Bold" ></TextBlock>
<TextBlock Tapped="OnVoicerWebClicked" Cursor="Hand" Height="124" VerticalAlignment="Center" TextWrapping="Wrap" Foreground="DarkOliveGreen" LineHeight="26" MaxLines="4" Text="{Binding Name}" FontSize="45" Margin="15 30 10 10" Padding="10 10 10 10" FontWeight="Bold" ></TextBlock>
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Foreground="DarkOliveGreen" LineHeight="15" Text="{DynamicResource voicers.styles}" FontSize="15" Margin="15 30 10 10" FontWeight="Bold" ></TextBlock>
<Border BorderBrush="LightGray" BorderThickness="1" CornerRadius="5" Margin="15 0 0 0">
<ScrollViewer BorderBrush="LightGray" Height="126" BorderThickness="1" AllowAutoHide="False" Margin="0 0 0 0" Focusable="True" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" >
Expand Down
39 changes: 39 additions & 0 deletions Mirivoice/Views/VoicersWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Mirivoice.ViewModels;
using Avalonia.Interactivity;
using Avalonia.Input;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace Mirivoice;



public partial class VoicersWindow : Window
{
VoicersWindowViewModel viewModel;
Expand All @@ -19,4 +25,37 @@ private void InitializeComponent(MainViewModel v)
DataContext = viewModel = new VoicersWindowViewModel(v);

}

private void OnVoicerWebClicked(object sender, TappedEventArgs e)
{
OpenUrl(viewModel.Web);
}

public static void OpenUrl(string url)
{
try
{
Process.Start(url);
}
catch
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url);
}
else
{
throw;
}
}
}
}

0 comments on commit 20c4839

Please sign in to comment.