Skip to content

Commit

Permalink
Merge pull request #21 from TheHeadmaster/0.4.3-alpha
Browse files Browse the repository at this point in the history
0.4.3-alpha
  • Loading branch information
TheHeadmaster authored Jul 30, 2024
2 parents 4bc7063 + 6c34887 commit f43656b
Show file tree
Hide file tree
Showing 34 changed files with 708 additions and 29 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,7 @@ csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_var_for_built_in_types = false:silent
csharp_style_var_when_type_is_apparent = false:silent
csharp_style_var_elsewhere = false:silent
csharp_space_around_binary_operators = before_and_after
csharp_space_around_binary_operators = before_and_after

# CA1416: Validate platform compatibility
dotnet_diagnostic.CA1416.severity = none
29 changes: 24 additions & 5 deletions Horizon/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Horizon.ObjectModel;
using Horizon.View.Windows;
using Horizon.View.Windows;
using Horizon.ViewModel;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
Expand Down Expand Up @@ -53,17 +52,37 @@ public static string UserDirectory
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion ?? "unknown-alpha";

/// <inheritdoc cref="CommandsViewModel" />
/// <inheritdoc cref="ViewModel.CommandsViewModel" />
[Reactive]
public static CommandsViewModel ViewModel { get; } = new CommandsViewModel();
public static CommandsViewModel CommandsViewModel { get; } = new();

public static List<ProjectTemplate> AvailableTemplates { get; set; } = [new() { Name = "Starbound Mod Project", Description = "A mod project for the game Starbound", Tags = ["Starbound", "Mod"] }];
[Reactive]
public static AppViewModel ViewModel { get; } = new();

public static string AppDataDirectory
{
get
{
if (appDataDirectory is null)
{
appDataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Horizon");
if (!Directory.Exists(appDataDirectory))
{
Directory.CreateDirectory(appDataDirectory);
}
}

return appDataDirectory;
}
}

/// <summary>
/// The workspace.
/// </summary>
private static Workspace? workspace;

private static string? appDataDirectory;

/// <summary>
/// Gets all the startup tasks that run while the splash screen is displayed.
/// </summary>
Expand Down
28 changes: 28 additions & 0 deletions Horizon/Converters/ActiveDocumentConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Horizon.ViewModel.Panes;
using ReactiveUI;

namespace Horizon.Converters;

/// <summary>
/// Converts an <see cref="object" /> to an active document binding.
/// </summary>
public sealed class ActiveDocumentConverter : IBindingTypeConverter
{
/// <inheritdoc />
public int GetAffinityForObjects(Type fromType, Type toType) => 0;

/// <inheritdoc />
public bool TryConvert(object? from, Type toType, object? conversionHint, out object? result)
{
if (from is PageViewModel)
{
result = from;
return true;
}
else
{
result = null;
return false;
}
}
}
29 changes: 29 additions & 0 deletions Horizon/Converters/BoolToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace Horizon.Converters;

/// <summary>
/// Converts a <see cref="bool" /> to a <see cref="Visibility" /> and back.
/// </summary>
public sealed class BoolToVisibilityConverter : IValueConverter
{
/// <inheritdoc />
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
Visibility boolVisibility = (bool)value ? Visibility.Visible : Visibility.Collapsed;
return boolVisibility;
}
catch
{
return Visibility.Collapsed;
}
}

// No need to implement converting back on a one-way binding
/// <inheritdoc />
public object? ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => null;
}
28 changes: 28 additions & 0 deletions Horizon/Converters/EnumToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Globalization;
using System.Windows.Data;

namespace Horizon.Converters;

/// <summary>
/// Converts an <see cref="enum" /> to a <see cref="string" /> and back.
/// </summary>
public sealed class EnumToStringConverter : IValueConverter
{
/// <inheritdoc />
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
string EnumString = Enum.GetName(value.GetType(), value) ?? string.Empty;
return EnumString;
}
catch
{
return string.Empty;
}
}

// No need to implement converting back on a one-way binding
/// <inheritdoc />
public object? ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => null;
}
40 changes: 40 additions & 0 deletions Horizon/Converters/StringToImageSourceConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media.Imaging;

namespace Horizon.Converters;

/// <summary>
/// Converts a <see cref="string" /> path to an <see cref="BitmapImage" /> Source and back.
/// </summary>
public class StringToImageSourceConverter : IValueConverter
{
/// <inheritdoc />
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
string? path = value as string;
if (string.IsNullOrWhiteSpace(path))
{
return null;
}

BitmapImage src = new();

try
{
src.BeginInit();
src.UriSource = new Uri(path);
src.EndInit();
}
catch (UriFormatException)
{
return null;
}

return src;
}

// No need to implement converting back on a one-way binding
/// <inheritdoc />
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => null;
}
2 changes: 2 additions & 0 deletions Horizon/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This file is used by Code Analysis to maintain SuppressMessage attributes that are applied to this project. Project-level
// suppressions either have no target or are given a specific target and scoped to a namespace, type, member, etc.
10 changes: 9 additions & 1 deletion Horizon/Horizon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<UseWPF>true</UseWPF>
<VersionPrefix>0.4.2</VersionPrefix>
<VersionPrefix>0.4.3</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand All @@ -31,6 +31,10 @@
<None Remove="Resources\Images\Key Space.png" />
<None Remove="Resources\Images\Key Windows.png" />
<None Remove="Resources\Images\Key.png" />
<None Remove="Resources\Images\New.png" />
<None Remove="Resources\Images\Open Small.png" />
<None Remove="Resources\Images\Open.png" />
<None Remove="Resources\Images\Read Only.png" />
<None Remove="Resources\Images\Splash.png" />
</ItemGroup>

Expand Down Expand Up @@ -82,6 +86,10 @@
<Resource Include="Resources\Images\Key Space.png" />
<Resource Include="Resources\Images\Key Windows.png" />
<Resource Include="Resources\Images\Key.png" />
<Resource Include="Resources\Images\New.png" />
<Resource Include="Resources\Images\Open Small.png" />
<Resource Include="Resources\Images\Open.png" />
<Resource Include="Resources\Images\Read Only.png" />
<Resource Include="Resources\Images\Splash.png" />
</ItemGroup>

Expand Down
14 changes: 10 additions & 4 deletions Horizon/ObjectModel/ProjectTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
namespace Horizon.ObjectModel;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;

public class ProjectTemplate
namespace Horizon.ObjectModel;

public class ProjectTemplate : ReactiveObject
{
public string Name { get; set; }
[Reactive]
public string Name { get; set; } = string.Empty;

public string Description { get; set; }
[Reactive]
public string Description { get; set; } = string.Empty;

[Reactive]
public List<string> Tags { get; set; } = [];
}
Binary file added Horizon/Resources/Images/New.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Horizon/Resources/Images/Open Small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Horizon/Resources/Images/Open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Horizon/Resources/Images/Read Only.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Grid.Column="1"
ContentSource="Header"
RecognizesAccessKey="True" VerticalAlignment="Center" />
<controls:KeyBindingVisuals x:Name="InputGestureText" Grid.Column="2" Margin="5,4,2,2" Height="24" DockPanel.Dock="Right" VerticalAlignment="Center" KeyBindingText="{TemplateBinding InputGestureText}" />
<controls:KeyBindingVisuals x:Name="InputGestureText" Grid.Column="2" Margin="5,2,2,2" Height="18" DockPanel.Dock="Right" VerticalAlignment="Center" KeyBindingText="{TemplateBinding InputGestureText}" />
<Path Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 0 7 L 4 3.5 Z" Fill="{DynamicResource AccentBackgroundColor}" />
<Popup Grid.Column="0" x:Name="Popup"
Placement="Right"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</Path>
</Border>
<ContentPresenter x:Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" VerticalAlignment="Center" />
<controls:KeyBindingVisuals x:Name="InputGestureText" Grid.Column="2" Margin="96,4,0,2" Height="24" DockPanel.Dock="Right" VerticalAlignment="Center" KeyBindingText="{TemplateBinding InputGestureText}" />
<controls:KeyBindingVisuals x:Name="InputGestureText" Grid.Column="2" Margin="96,2,0,2" Height="18" DockPanel.Dock="Right" VerticalAlignment="Center" KeyBindingText="{TemplateBinding InputGestureText}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
Expand Down
7 changes: 6 additions & 1 deletion Horizon/Resources/UI/Converters.xaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Horizon.Converters">
<converters:EnumToStringConverter x:Key="DefaultEnumToStringConverter" />
<converters:BoolToVisibilityConverter x:Key="DefaultBoolToVisibilityConverter" />
<converters:StringToImageSourceConverter x:Key="StringToImageSourceConverter" />
<converters:ActiveDocumentConverter x:Key="ActiveDocumentConverter" />
</ResourceDictionary>
2 changes: 1 addition & 1 deletion Horizon/View/Controls/KeyBindingGlyph.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ColumnDefinition Width="4" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="4" />
<RowDefinition Height="0" />
<RowDefinition Height="*" />
<RowDefinition Height="4" />
</Grid.RowDefinitions>
Expand Down
2 changes: 1 addition & 1 deletion Horizon/View/Controls/MainMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public MainMenu()
this.NewProjectMenuItem.Events()
.Click
.Select(x => new Unit())
.InvokeCommand(App.ViewModel, x => x.NewProjectDialog)
.InvokeCommand(App.CommandsViewModel, x => x.NewProjectDialog)
.DisposeWith(dispose);
});
}
Expand Down
23 changes: 23 additions & 0 deletions Horizon/View/Panes/PanesStyleSelector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Horizon.ViewModel.Panes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace Horizon.View.Panes;

public sealed class PanesStyleSelector : StyleSelector
{
public Style? ToolStyle { get; set; }
public Style? PageStyle { get; set; }

public override Style SelectStyle(object item, DependencyObject container) => item switch
{
ToolViewModel => this.ToolStyle ?? base.SelectStyle(item, container),
PageViewModel => this.PageStyle ?? base.SelectStyle(item, container),
_ => base.SelectStyle(item, container)
};
}
17 changes: 17 additions & 0 deletions Horizon/View/Panes/PanesTemplateSelector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Horizon.ViewModel.Panes;
using System.Windows;
using System.Windows.Controls;

namespace Horizon.View.Panes;

public sealed class PanesTemplateSelector : DataTemplateSelector
{
public DataTemplate? ProjectExplorerViewTemplate { get; set; }

public override DataTemplate? SelectTemplate(object item, DependencyObject container) =>
item switch
{
ProjectExplorerViewModel => this.ProjectExplorerViewTemplate,
_ => base.SelectTemplate(item, container)
};
}
13 changes: 13 additions & 0 deletions Horizon/View/Panes/ProjectExplorerPane.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<rui:ReactiveUserControl x:Class="Horizon.View.Panes.ProjectExplorerPane" x:TypeArguments="panes:ProjectExplorerViewModel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Horizon.View.Panes"
xmlns:rui="http://reactiveui.net"
xmlns:panes="clr-namespace:Horizon.ViewModel.Panes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</rui:ReactiveUserControl>
21 changes: 21 additions & 0 deletions Horizon/View/Panes/ProjectExplorerPane.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Horizon.ViewModel.Panes;
using ReactiveUI;

namespace Horizon.View.Panes;

/// <summary>
/// Interaction logic for ProjectExplorerPane.xaml
/// </summary>
public partial class ProjectExplorerPane
{
public ProjectExplorerPane()
{
this.InitializeComponent();

this.ViewModel = new ProjectExplorerViewModel();

this.WhenActivated(dispose =>
{
});
}
}
2 changes: 1 addition & 1 deletion Horizon/View/Windows/NewProjectWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public NewProjectWindow()

this.ViewModel = new()
{
AvailableTemplates = App.AvailableTemplates
AvailableTemplates = App.ViewModel.AvailableTemplates
};

this.WhenActivated(dispose =>
Expand Down
Loading

0 comments on commit f43656b

Please sign in to comment.