Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Equbuxu committed Apr 20, 2021
1 parent 8322033 commit da36473
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
34 changes: 34 additions & 0 deletions PixiEditor/Views/ColorPanelController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using AvalonDock.Layout;
using System.Windows;

namespace PixiEditor.Views
{
internal class ColorPanelController
{
private LayoutAnchorable colorPickerPanel;
private LayoutAnchorable colorSlidersPanel;
private LayoutAnchorable smallColorPickerPanel;

public ColorPanelController(LayoutAnchorable colorPickerPanel, LayoutAnchorable colorSlidersPanel, LayoutAnchorable smallColorPickerPanel)
{
this.colorPickerPanel = colorPickerPanel;
this.colorSlidersPanel = colorSlidersPanel;
this.smallColorPickerPanel = smallColorPickerPanel;
}

public void DeterminePanelsToDisplay()
{
if (SystemParameters.PrimaryScreenHeight < 1010)
{
colorPickerPanel.IsVisible = false;
colorSlidersPanel.IsVisible = true;
smallColorPickerPanel.IsVisible = true;
}
else
{
colorSlidersPanel.IsVisible = false;
smallColorPickerPanel.IsVisible = false;
}
}
}
}
19 changes: 3 additions & 16 deletions PixiEditor/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using PixiEditor.Models.UserPreferences;
using PixiEditor.ViewModels;
using PixiEditor.Views;
using System;
using System.ComponentModel;
using System.Windows;
Expand Down Expand Up @@ -30,7 +31,8 @@ public MainWindow()
viewModel.CloseAction = Close;
Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;

HideOrShowColorPickerPanels();
ColorPanelController controller = new ColorPanelController(colorPickerPanel, colorSlidersPanel, smallColorPickerPanel);
controller.DeterminePanelsToDisplay();
}

protected override void OnClosing(CancelEventArgs e)
Expand All @@ -39,21 +41,6 @@ protected override void OnClosing(CancelEventArgs e)
viewModel.DiscordViewModel.Dispose();
}

private void HideOrShowColorPickerPanels()
{
if (SystemParameters.PrimaryScreenHeight < 1010)
{
colorPickerPanel.IsVisible = false;
colorSlidersPanel.IsVisible = true;
smallColorPickerPanel.IsVisible = true;
}
else
{
colorSlidersPanel.IsVisible = false;
smallColorPickerPanel.IsVisible = false;
}
}

private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
Expand Down

0 comments on commit da36473

Please sign in to comment.