Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mgth committed Apr 27, 2024
1 parent 1228f76 commit 9453360
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

namespace LittleBigMouse.DisplayLayout.Monitors;

public interface IExcludedListItem
{
public class Design(string name) : IExcludedListItem
{
public string Name { get; } = name;
}
string Name { get; }
}

public interface ILayoutOptions
{
public class Design : ILayoutOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ std::string GetParentProcess()

int main(int argc, char *argv[]){

#if !defined(_DEBUG)
constexpr LPCWSTR szUniqueNamedMutex = L"LittleBigMouse_Daemon";

HANDLE hHandle = CreateMutex(nullptr, TRUE, szUniqueNamedMutex);
Expand All @@ -84,7 +85,6 @@ int main(int argc, char *argv[]){
return(1); // Exit program
}

#if !defined(_DEBUG)
ShowWindow( GetConsoleWindow(), SW_HIDE );
#endif

Expand Down Expand Up @@ -134,11 +134,13 @@ int main(int argc, char *argv[]){
daemon.Run("\\Mgth\\LittleBigMouse\\Current.xml");
}

#if !defined(_DEBUG)
if(hHandle)
{
ReleaseMutex (hHandle);
CloseHandle (hHandle);
}
#endif
#if defined(_DEBUG)
system("pause");
#endif
Expand Down
15 changes: 0 additions & 15 deletions LittleBigMouse.Ui/LittleBigMouse.Ui.Avalonia/Controls/ListItem.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public LocationControlViewModel(ILittleBigMouseClientService service,IMainServic

_monitorsService = monitorsService;



SaveCommand = ReactiveCommand.CreateFromTask(
SaveAsync,
this.WhenAnyValue(e => e.Model.Saved,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
using System.Collections.Generic;
using HLab.Mvvm.Annotations;
using LittleBigMouse.Ui.Avalonia.Options;

namespace LittleBigMouse.Ui.Avalonia.Controls;

public class LocationControlViewModelDesign : IDesignViewModel
{
public LocationControlViewModelDesign()
{
}

public List<ListItem> AlgorithmList { get; } = new()
{
new ("strait","Strait","Simple and highly CPU-efficient transition."),
new ("cross","Corner crossing","In direction-friendly manner, allows traversal through corners."),

};

public object SelectedAlgorithm { get; set; }
public object SelectedAlgorithm { get; set; } = "Strait";
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using HLab.Base.Avalonia;
using HLab.Base.Avalonia.Extensions;
using LittleBigMouse.DisplayLayout.Monitors;
using ReactiveUI;

namespace LittleBigMouse.Ui.Avalonia.Main;


public class LbmOptions : ReactiveModel, ILayoutOptions
{
public LbmOptions()
Expand Down Expand Up @@ -159,4 +158,5 @@ public string Algorithm

public ObservableCollection<string> ExcludedList { get; } = new();


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ You should have received a copy of the GNU General Public License
*/

using System;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Threading;
Expand All @@ -33,6 +34,7 @@ You should have received a copy of the GNU General Public License
using HLab.UserNotification;
using LittleBigMouse.DisplayLayout.Monitors;
using LittleBigMouse.Plugins;
using LittleBigMouse.Ui.Avalonia.Options;
using LittleBigMouse.Ui.Avalonia.Persistency;
using LittleBigMouse.Ui.Avalonia.Remote;
using LittleBigMouse.Ui.Avalonia.Updater;
Expand Down Expand Up @@ -224,7 +226,7 @@ async Task DaemonEventReceived(object? sender, LittleBigMouseServiceEventArgs ar

void AddSeenProcess(string process)
{
if(_processesCollector.SeenProcesses.Contains(process)) return;
if(_processesCollector.SeenProcesses.Any(e => e.Contains(process))) return;

_processesCollector.SeenProcesses.Add(process);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
xmlns:mvvm="clr-namespace:HLab.Mvvm.Avalonia;assembly=HLab.Mvvm.Avalonia"
xmlns:plugins="clr-namespace:LittleBigMouse.Plugins;assembly=LittleBigMouse.Plugins"
xmlns:main="clr-namespace:LittleBigMouse.Ui.Avalonia.Main"
xmlns:icons="clr-namespace:HLab.Icons.Avalonia.Icons;assembly=HLab.Icons.Avalonia"
xmlns:avalonia="clr-namespace:LittleBigMouse.Ui.Avalonia"
xmlns:controls="clr-namespace:LittleBigMouse.Ui.Avalonia.Controls"
mc:Ignorable="d"
mc:Ignorable="d"
x:DataType="main:MainViewModel"
>
<!--Foreground="{DynamicResource HLab.Brushes.Foreground}"-->
Expand Down Expand Up @@ -44,7 +41,7 @@

<main:PluginsControlsView/>

<SplitView Grid.Row="1" IsPaneOpen="{Binding OptionsIsVisible}" PaneBackground="Transparent" >
<SplitView OpenPaneLength="500" Grid.Row="1" IsPaneOpen="{Binding OptionsIsVisible, Mode = TwoWay}" PaneBackground="Transparent" >
<SplitView.Pane>
<mvvm:ViewLocator Model="{Binding Options}" />
</SplitView.Pane>
Expand Down
12 changes: 2 additions & 10 deletions LittleBigMouse.Ui/LittleBigMouse.Ui.Avalonia/Main/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ namespace LittleBigMouse.Ui.Avalonia.Main;

public interface IProcessesCollector
{
ObservableCollection<string> SeenProcesses { get; }
ObservableCollectionExtended<string> SeenProcesses { get; }
}

public class ProcessesCollector : ReactiveModel, IProcessesCollector
{
public ObservableCollection<string> SeenProcesses { get; } = [];
public ObservableCollectionExtended<string> SeenProcesses { get; } = [];

}

Expand All @@ -51,8 +51,6 @@ public MainViewModel(IIconService iconService, ILocalizationService localization
MaximizeCommand = ReactiveCommand.Create(() =>
WindowState = WindowState != WindowState.Normal ? WindowState.Maximized : WindowState.Normal);

OptionsCommand = ReactiveCommand.Create(ViewOptions);

_presenterViewMode = this.WhenAnyValue(v => v.ViewList)
.Select(v => v ? typeof(ListViewMode) : typeof(DefaultViewMode))
.ToProperty(this, v => v.PresenterViewMode);
Expand Down Expand Up @@ -116,8 +114,6 @@ public bool OptionsIsVisible

public ICommand MaximizeCommand { get; }

public ICommand OptionsCommand { get; }

void Close()
{
//if (Layout?.Saved ?? true)
Expand Down Expand Up @@ -175,10 +171,6 @@ public void UnMaximize()

SourceCache<IUiCommand, string> _commandsCache { get; } = new(c => c.Id);

void ViewOptions()
{

}

public void AddButton(IUiCommand command)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:LittleBigMouse.Ui.Avalonia.Controls"
xmlns:options="clr-namespace:LittleBigMouse.Ui.Avalonia.Options"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="LittleBigMouse.Ui.Avalonia.Controls.LayoutOptions"
x:DataType="controls:LbmOptionsViewModel"
x:Class="LittleBigMouse.Ui.Avalonia.Options.LayoutOptions"
x:DataType="options:LbmOptionsViewModel"
Background="Transparent"
>
<UserControl.Styles>
Expand Down Expand Up @@ -75,7 +75,7 @@
<DataTemplate>
<Border Background="Transparent">
<Label Classes="RadioButtonListBox"
x:DataType="controls:ListItem"
x:DataType="options:ListItem"
Content="{Binding Caption}"
Background="Transparent"
VerticalAlignment="Center"
Expand Down Expand Up @@ -114,7 +114,7 @@
<DataTemplate>
<Border Background="Transparent">
<RadioButton Classes="RadioButtonListBox"
x:DataType="controls:ListItem"
x:DataType="options:ListItem"
Content="{Binding Caption}"
Background="Transparent"
VerticalAlignment="Center"
Expand Down Expand Up @@ -204,27 +204,59 @@
Padding="10">

<StackPanel>

<ListBox
ItemsSource="{Binding Model.ExcludedList}"
ToolTip.Tip="Those processes will deactivate LittleBigMouse on reaching first plane"
SelectedValue="{Binding SelectedExcludedProcess}"
/>
>
<ListBox.ItemTemplate>
<DataTemplate>
<Border Background="Transparent">
<TextBlock Text="{Binding }"
Background="Transparent"
VerticalAlignment="Center"
ToolTip.Tip ="{Binding }"/>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

<StackPanel Orientation="Horizontal">
<Button Command="{Binding AddExcludedProcessCommand}">/\</Button>
<Button Command="{Binding RemoveExcludedProcessCommand}">\/</Button>
<Button Command="{Binding RemoveExcludedProcessCommand}">Remove</Button>
</StackPanel>

<TextBox TextWrapping="Wrap" Text="{Binding SelectedSeenProcess}"/>

<Label>Match pattern : </Label>
<Grid ColumnDefinitions="*,Auto">
<TextBox Grid.Column="0" TextWrapping="Wrap" Text="{Binding Pattern, UpdateSourceTrigger=PropertyChanged}"/>
<Button Grid.Column="1" Command="{Binding AddExcludedProcessCommand}">Exclude</Button>
</Grid>
<Label>Seen processes : </Label>
<ListBox
ItemsSource="{Binding ProcessesCollector.SeenProcesses}"
ItemsSource="{Binding SeenProcesses}"
ToolTip.Tip="Those processes will deactivate LittleBigMouse on reaching first plane"
SelectedValue="{Binding SelectedSeenProcess}"
/>

>
<ListBox.Styles>
<Style Selector="Border.match">
<Setter Property="Background" Value="Green" />
</Style>
</ListBox.Styles>

<ListBox.ItemTemplate>
<DataTemplate>
<Border Classes.match="{Binding Match }">
<TextBlock
x:DataType="options:SeenProcessViewModel"
Text="{Binding Caption}"
VerticalAlignment="Center"
ToolTip.Tip ="{Binding Description}"/>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>

</ListBox>
</StackPanel>

</Border>

<Label
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Avalonia.Controls;
using HLab.Mvvm.Annotations;
using LittleBigMouse.DisplayLayout.Monitors;

namespace LittleBigMouse.Ui.Avalonia.Controls;
namespace LittleBigMouse.Ui.Avalonia.Options;

public partial class LayoutOptions : UserControl, IView<LbmOptionsViewModel>
{
Expand Down
Loading

0 comments on commit 9453360

Please sign in to comment.