Skip to content

Commit

Permalink
change perms
Browse files Browse the repository at this point in the history
  • Loading branch information
mkromis committed Jul 3, 2022
1 parent 5433d01 commit 5508c5b
Show file tree
Hide file tree
Showing 13 changed files with 336 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace MinoriEditorShell.Platforms.Avalonia.Controls
{
internal class MesDocumentDock : MesDockBase, IDocumentDock
public class MesDocumentDock : MesDockBase, IDocumentDock
{
private Boolean _canCreateDocument;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Controls
/// Proportional dock.
/// </summary>
[DataContract(IsReference = true)]
internal class MesProportionalDock : MesDockBase, IProportionalDock
public class MesProportionalDock : MesDockBase, IProportionalDock
{
private Orientation _orientation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace MinoriEditorShell.Platforms.Avalonia.Controls
/// <summary>
/// Main root dock
/// </summary>
internal class MesRootDock : MesDockBase, IRootDock
public class MesRootDock : MesDockBase, IRootDock
{
private Boolean _isFocusableRoot = true;
private IDockWindow _window;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace MinoriEditorShell.Platforms.Avalonia.Controls
{
internal class MesToolDock : MesDockBase, IToolDock
public class MesToolDock : MesDockBase, IToolDock
{
private Alignment _alignment = Alignment.Unset;
private Boolean _isExpanded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\MvvmCross\MvvmCross.Plugins\Messenger\MvvmCross.Plugin.Messenger.csproj" />
<ProjectReference Include="..\..\..\..\MvvmCross\MvvmCross\MvvmCross.csproj" />
<ProjectReference Include="..\MinoriEditorShell\MinoriEditorShell.csproj" />

<PackageReference Include="Avalonia" Version="0.10.10" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.10" />
<PackageReference Include="Dock.Avalonia" Version="0.10.8" />
<PackageReference Include="Dock.Model" Version="0.10.8" />
<PackageReference Include="MvvmCross" Version="8.0.2" />
<PackageReference Include="MvvmCross.Plugin.Messenger" Version="8.0.2" />
<PackageReference Include="MvvmCross.Plugin.ResxLocalization" Version="8.0.2" />
<PackageReference Include="System.ComponentModel.Composition" Version="5.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia.Controls;
using Dock.Model.Controls;
using Dock.Model.Core;
using Microsoft.Extensions.Logging;
using MinoriEditorShell.Platforms.Avalonia.Presenters.Attributes;
using MinoriEditorShell.Platforms.Avalonia.ViewModels;
Expand Down Expand Up @@ -199,35 +200,59 @@ protected virtual Task<bool> CloseWindow(IMvxViewModel toClose)
/// Depending on what the type is, will define where the class goes.
/// Either to MesDocumentManager or main view if not a IMesDocument or IMesTool
/// </summary>
/// <param name="element"></param>
/// <param name="view"></param>
/// <param name="attribute"></param>
/// <param name="request"></param>
/// <returns></returns>
protected async Task<Boolean> ShowContentView(
IMvxView element, MesContentPresentationAttribute attribute, MvxViewModelRequest request)
protected async Task<Boolean> ShowContentView(IMvxView view, MesContentPresentationAttribute attribute, MvxViewModelRequest request)
{
try
{
// Everything that passes here should be a view
IMvxView view = element as IMvxView;
MesDocumentManagerViewModel manager = (MesDocumentManagerViewModel)Mvx.IoCProvider.Resolve<IMesDocumentManager>();

// from which we can now get the view model.
switch (view.ViewModel)
{
case IMesDocument document:
{
// Try to set view, this is needed for DocumentManager
IMesDocument docViewModel = (IMesDocument)view.ViewModel;
docViewModel.View = view; // Needed for Binding with AvalonDock

// Try to set view, this is needed for DocumentManager
IMesDocument docViewModel = (IMesDocument)view.ViewModel;
docViewModel.View = view; // Needed for Binding with AvalonDock
MesDocumentWrapper documentWrapper = new(docViewModel);

MesDocumentWrapper documentWrapper = new(docViewModel);
// Add to manager model
IDocumentDock docdock = manager.DocumentDock;
IRootDock layout = manager.Layout;

// Add to manager model
//manager.Documents.Add(docViewModel);
manager.AddDockable(manager.GetDockable<IDocumentDock>("Files"), documentWrapper);
_log.LogTrace($"Add {document} to IMesDocumentManager.Documents");
return true;
if (layout is { } && docdock is { })
{
manager.DocumentDock.VisibleDockables.Add(documentWrapper);
manager.AddDockable(docdock, documentWrapper);
manager.SetActiveDockable(documentWrapper);
manager.SetFocusedDockable(layout, documentWrapper);

_log.LogTrace($"Add {document} to IMesDocumentManager.Documents");
}
else
{
_log.LogTrace("There was an error attaching to layout");
}

// ---------- remove after test
ContentControl contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier)
?? FrameworkElementsDictionary.Keys.Last();

if (!attribute.StackNavigation && FrameworkElementsDictionary[contentControl].Any())
FrameworkElementsDictionary[contentControl].Pop(); // Close previous view

FrameworkElementsDictionary[contentControl].Push((Control)view);
contentControl.Content = documentWrapper;
_log.LogTrace($"Passing to parent {view.ViewModel}");

return true;
}

case IMesTool tool:
// Try to set view, this is needed for DocumentManager
Expand All @@ -240,16 +265,18 @@ protected async Task<Boolean> ShowContentView(
return true;

default:
_log.LogTrace($"Passing to parent {view.ViewModel}");
ContentControl contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier)
?? FrameworkElementsDictionary.Keys.Last();

if (!attribute.StackNavigation && FrameworkElementsDictionary[contentControl].Any())
FrameworkElementsDictionary[contentControl].Pop(); // Close previous view

FrameworkElementsDictionary[contentControl].Push((Control)element);
contentControl.Content = element;
return true;
{
_log.LogTrace($"Passing to parent {view.ViewModel}");
ContentControl contentControl = FrameworkElementsDictionary.Keys.FirstOrDefault(w => (w as MesWindow)?.Identifier == attribute.WindowIdentifier)
?? FrameworkElementsDictionary.Keys.Last();

if (!attribute.StackNavigation && FrameworkElementsDictionary[contentControl].Any())
FrameworkElementsDictionary[contentControl].Pop(); // Close previous view

FrameworkElementsDictionary[contentControl].Push((Control)view);
contentControl.Content = view;
return true;
}
}
}
catch (Exception exception)
Expand Down
Loading

0 comments on commit 5508c5b

Please sign in to comment.