Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #19 from porohkun/v0.1
Browse files Browse the repository at this point in the history
merge for 0.2 release
  • Loading branch information
porohkun authored Aug 14, 2020
2 parents e76bb94 + 2e95138 commit 3ec0d0a
Show file tree
Hide file tree
Showing 108 changed files with 4,309 additions and 942 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,4 @@ ModelManifest.xml
# FAKE - F# Make
.fake/
/packages/
/Lab/
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ScreenSlicer
This application is designed to conveniently place multiple windows on ultrawide monitors. It works the same for multi-screen setups.

[![Latest Stable Release](https://img.shields.io/github/release/porohkun/ScreenSlicer.svg?style=flat-square)](https://github.com/porohkun/ScreenSlicer/releases)
[![Total Downloads](https://img.shields.io/github/downloads/porohkun/ScreenSlicer/total.svg?style=flat-square)](https://github.com/porohkun/ScreenSlicer/releases)
[![License](https://img.shields.io/github/license/porohkun/ScreenSlicer.svg?style=flat-square)](https://github.com/porohkun/ScreenSlicer/blob/master/LICENSE)

Download binaries from [releases page](https://github.com/porohkun/ScreenSlicer/releases)
## How it works
![Demo](docs/demo.gif)
102 changes: 102 additions & 0 deletions ScreenSlicer/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ScreenSlicer"
xmlns:w="clr-namespace:ScreenSlicer.Windows"
xmlns:sp="clr-namespace:ScreenSlicer.Pages.SettingsWindow"
Startup="Application_Startup">
<Application.Resources>
<ResourceDictionary>
Expand All @@ -12,9 +13,110 @@
<ResourceDictionary Source="MuiModify.xaml"/>
<ResourceDictionary Source="Converters.xaml"/>
<ResourceDictionary Source="IntUpDown.xaml"/>
<ResourceDictionary Source="Controls/RegionView.xaml"/>
<ResourceDictionary Source="Controls/MultiSelectComboBox.xaml"/>
</ResourceDictionary.MergedDictionaries>

<w:SlicingWindowDummy x:Key="SlicingWindowDummy"/>
<w:SelectRulesWindowDummy x:Key="SelectRulesWindowDummy"/>
<sp:CompatibilityPageDummy x:Key="CompatibilityPageDummy"/>

<Style x:Key="GlueRegionButtonStyle" TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Background" Value="{DynamicResource ButtonBackground}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorder}"/>
<Setter Property="Foreground" Value="{DynamicResource ButtonText}"/>
<Setter Property="Width" Value="24"/>
<Setter Property="Height" Value="24"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Margin" Value="-12"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="Chrome"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True">
<Path Data="M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M19,19H5V5H19V19M17,8.4L13.4,12L17,15.6L15.6,17L12,13.4L8.4,17L7,15.6L10.6,12L7,8.4L8.4,7L12,10.6L15.6,7L17,8.4Z"
SnapsToDevicePixels="True"
Fill="{TemplateBinding Foreground}"
Stretch="Uniform"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource ButtonTextDisabled}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource CloseButtonBackgroundIsPressed}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderHover}"/>
<Setter Property="Foreground" Value="{DynamicResource ButtonTextHover}"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#FFFF5A4A"/>
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderPressed}"/>
<Setter Property="Foreground" Value="{DynamicResource ButtonTextPressed}"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" TargetName="Chrome" Value="{DynamicResource Accent}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="TrashButtonStyle" TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorder}"/>
<Setter Property="Foreground" Value="{DynamicResource ButtonText}"/>
<Setter Property="Width" Value="20"/>
<Setter Property="Height" Value="20"/>
<Setter Property="Padding" Value="3"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="Chrome"
Padding="{TemplateBinding Padding}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True">
<Path Data="M13.46,12L19,17.54V19H17.54L12,13.46L6.46,19H5V17.54L10.54,12L5,6.46V5H6.46L12,10.54L17.54,5H19V6.46L13.46,12Z"
SnapsToDevicePixels="True"
Fill="{TemplateBinding Foreground}"
Stretch="Uniform"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource ButtonTextDisabled}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource CloseButtonBackgroundIsPressed}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderHover}"/>
<Setter Property="Foreground" Value="{DynamicResource ButtonBackground}"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource #FFFF5A4A}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderPressed}"/>
<Setter Property="Foreground" Value="{DynamicResource ButtonTextPressed}"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" TargetName="Chrome" Value="{DynamicResource Accent}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
19 changes: 7 additions & 12 deletions ScreenSlicer/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using Hardcodet.Wpf.TaskbarNotification;
using Ninject;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace ScreenSlicer
Expand All @@ -15,7 +9,7 @@ namespace ScreenSlicer
/// </summary>
public partial class App : Application
{
private IKernel _container;
public static IKernel Container { get; private set; }

private TaskbarIcon _notifyIcon;

Expand All @@ -24,26 +18,27 @@ private void Application_Startup(object sender, StartupEventArgs e)
ConfigureContainer();
ComposeObjects();
_notifyIcon.BeginInit();
_container.Get<Managers.ProcessesWatcher>();
Container.Get<Managers.ProcessesWatcher>();
}

private void ConfigureContainer()
{
_container = new StandardKernel(new MainModule());
Container = new StandardKernel(new MainModule());
}

private void ComposeObjects()
{
_notifyIcon = _container.Get<NotifyIcon.NotifyIcon>();
_container.Get<Updating.Updater>().CheckUpdates();
_notifyIcon = Container.Get<NotifyIcon.NotifyIcon>();
#if DEBUG
_container.Get<Windows.WinListWindow>().Show();
Container.Get<Updating.Updater>().CheckUpdates();
//Container.Get<Windows.SettingsWindow>().Show();
#endif
}

protected override void OnExit(ExitEventArgs e)
{
_notifyIcon.Dispose(); //the icon would clean up automatically, but this is cleaner
NLog.LogManager.Shutdown();
base.OnExit(e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ScreenSlicer/Commands/AppActivatedCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace ScreenSlicer.Commands
{
public class AppActivatedCommand : InjectableCommand
public class AppActivatedCommand : InjectableCommand<AppActivatedCommand>
{
protected override bool CanExecuteInternal(object parameter)
{
Expand All @@ -14,7 +14,7 @@ protected override bool CanExecuteInternal(object parameter)

protected override void ExecuteInternal(object parameter)
{

Settings.Instance.Main.IsActive = !Settings.Instance.Main.IsActive;
}
}
}
2 changes: 1 addition & 1 deletion ScreenSlicer/Commands/BeginSliceRegionsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace ScreenSlicer.Commands
{
public class BeginSliceRegionsCommand : InjectableCommand
public class BeginSliceRegionsCommand : InjectableCommand<BeginSliceRegionsCommand>
{
private readonly RegionsManager _manager;

Expand Down
26 changes: 26 additions & 0 deletions ScreenSlicer/Commands/DelegateCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;

namespace ScreenSlicer.Commands
{
public class DelegateCommand : InjectableCommand<DelegateCommand>
{
private Action<object> _executeAction;
private Func<object, bool> _canExecuteAction;

public DelegateCommand(Action<object> executeAction, Func<object, bool> canExecuteAction = null)
{
_executeAction = executeAction;
_canExecuteAction = canExecuteAction;
}

protected override bool CanExecuteInternal(object parameter)
{
return _canExecuteAction?.Invoke(parameter) ?? true;
}

protected override void ExecuteInternal(object parameter)
{
_executeAction?.Invoke(parameter);
}
}
}
2 changes: 1 addition & 1 deletion ScreenSlicer/Commands/EndSliceRegionsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace ScreenSlicer.Commands
{
public class EndSliceRegionsCommand : InjectableCommand
public class EndSliceRegionsCommand : InjectableCommand<EndSliceRegionsCommand>
{
private RegionsManager _manager;

Expand Down
2 changes: 1 addition & 1 deletion ScreenSlicer/Commands/ExitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace ScreenSlicer.Commands
{
public class ExitCommand : InjectableCommand
public class ExitCommand : InjectableCommand<ExitCommand>
{
protected override bool CanExecuteInternal(object parameter)
{
Expand Down
2 changes: 1 addition & 1 deletion ScreenSlicer/Commands/GlueRegionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace ScreenSlicer.Commands
{
public class GlueRegionCommand : InjectableCommand
public class GlueRegionCommand : InjectableCommand<GlueRegionCommand>
{
protected override bool CanExecuteInternal(object parameter)
{
Expand Down
18 changes: 18 additions & 0 deletions ScreenSlicer/Commands/HyperlinkCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace ScreenSlicer.Commands
{
public class HyperlinkCommand : InjectableCommand<HyperlinkCommand>
{
protected override bool CanExecuteInternal(object parameter)
{
return true;
}

protected override void ExecuteInternal(object parameter)
{
if (parameter is string url)
Process.Start(new ProcessStartInfo(url));
}
}
}
Loading

0 comments on commit 3ec0d0a

Please sign in to comment.