-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fleshed out AvalonDock and pane system. Layout loads and saves automa…
…tically. Added Project Explorer. Name of project (or Horizon if no project is open) now displays at top of workspace window. #22 #23 #24
- Loading branch information
1 parent
cfcddd2
commit 297b6b0
Showing
14 changed files
with
519 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => | ||
{ | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Horizon.ObjectModel; | ||
using ReactiveUI; | ||
using ReactiveUI.Fody.Helpers; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Horizon.ViewModel; | ||
|
||
public sealed class AppViewModel : ReactiveObject | ||
{ | ||
[Reactive] | ||
public ObservableCollection<ProjectTemplate> AvailableTemplates { get; set; } = [new() { Name = "Starbound Mod Project", Description = "A mod project for the game Starbound", Tags = ["Starbound", "Mod"] }]; | ||
|
||
[Reactive] | ||
public ProjectFile? CurrentProject { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using AvalonDock.Layout; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Horizon.ViewModel; | ||
|
||
public sealed class LayoutInitializer : ILayoutUpdateStrategy | ||
{ | ||
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) | ||
{ | ||
// AvalonDock wants to add the anchorable into destinationContainer just for test provide a new anchorable pane if the | ||
// pane is floating let the manager go ahead | ||
LayoutAnchorablePane? destPane = destinationContainer as LayoutAnchorablePane; | ||
if (destinationContainer?.FindParent<LayoutFloatingWindow>() is not null) | ||
{ | ||
return false; | ||
} | ||
|
||
LayoutAnchorablePane? toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane"); | ||
if (toolsPane is not null) | ||
{ | ||
toolsPane.Children.Add(anchorableToShow); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public void AfterInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableShown) | ||
{ } | ||
|
||
public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer) => false; | ||
|
||
public void AfterInsertDocument(LayoutRoot layout, LayoutDocument anchorableShown) | ||
{ } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using ReactiveUI; | ||
using ReactiveUI.Fody.Helpers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reactive.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Horizon.ViewModel.Panes; | ||
|
||
public abstract class PageViewModel : PaneViewModel | ||
{ | ||
public PageViewModel() | ||
{ | ||
this.WhenAnyValue(x => x.ID) | ||
.Select(id => $"{this.GetType().Name}|{id}") | ||
.ToPropertyEx(this, x => x.ContentID); | ||
} | ||
|
||
[Reactive] | ||
public int ID { get; set; } | ||
|
||
[Reactive] | ||
public bool IsDirty { get; set; } | ||
|
||
[Reactive] | ||
public bool IsReadOnly { get; set; } | ||
|
||
[Reactive] | ||
public string? ReadOnlyReason { get; set; } | ||
} |
Oops, something went wrong.