Skip to content

Commit

Permalink
Debug System config changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mgth committed Mar 6, 2016
1 parent d71c82a commit 666e3d8
Show file tree
Hide file tree
Showing 16 changed files with 306 additions and 248 deletions.
12 changes: 10 additions & 2 deletions LittleBigMouse_Control/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public object Convert(object value, Type targetType, object parameter, CultureIn

double scale = double.Parse((string)parameter, CultureInfo.InvariantCulture);

return Math.Max(v * scale, 0.1);
double result = Math.Min(Math.Max(v * scale, 0.1), 35791);

if (double.IsNaN(result) || double.IsInfinity(result)) return 0.1;

return result;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Expand All @@ -70,7 +74,11 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur

double scale = double.Parse((string)parameter, CultureInfo.InvariantCulture);

return Math.Max(v * scale, 0.1);
double result = Math.Min(Math.Max(v * scale, 0.1), 35791);

if (double.IsNaN(result) || double.IsInfinity(result)) return 0.1;

return result;
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
Expand Down
45 changes: 24 additions & 21 deletions LittleBigMouse_Control/MultiScreensViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -22,7 +23,7 @@ public MultiScreensViewModel()
ScreenFrames.CollectionChanged += ScreenFrames_CollectionChanged;
}

private void ScreenFrames_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
private void ScreenFrames_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
foreach (ScreenFrameViewModel frame in e.OldItems)
Expand Down Expand Up @@ -62,31 +63,33 @@ private void BringSelectedToFront()


[DependsOn(nameof(Config))]
private void UpdateScreensControlViews()
private void UpdateConfig()
{
IList<ScreenFrameViewModel> old = ScreenFrames.ToList();

foreach (Screen s in Config.AllScreens)
{
ScreenFrameViewModel vm = old.FirstOrDefault(v => v.Screen.Equals(s) );
AllScreens_CollectionChanged(Config.AllScreens, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,Config.AllScreens));
Config.AllScreens.CollectionChanged += AllScreens_CollectionChanged;
}

if (vm != null) { old.Remove(vm); }
else
private void AllScreens_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if(e.NewItems!=null)
foreach (Screen screen in e.NewItems)
{
vm = new ScreenFrameViewModel
{
Screen = s,
Presenter = this
};
ScreenFrames.Add(vm);
ScreenFrameViewModel vm = ScreenFrames.FirstOrDefault(v => v.Screen.Equals(screen) );
if (vm == null)
ScreenFrames.Add(new ScreenFrameViewModel
{
Screen = screen,
Presenter = this
});
}
if (e.OldItems != null)
foreach (Screen screen in e.OldItems)
{
ScreenFrameViewModel vm = ScreenFrames.FirstOrDefault(v => v.Screen.Equals(screen));
if (vm!=null) ScreenFrames.Remove(vm);
}
}

foreach (ScreenFrameViewModel frame in old)
{
ScreenFrames.Remove(frame);
}
}

public static DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), typeof(ScreenConfig), typeof(MultiScreensViewModel), WatchNotifier());


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public LocationPlugin Plugin
public double RatioX
{
get { return Screen.PhysicalRatioX*100; }
set { Screen.PhysicalRatioX = value/100; }
set { Screen.PhysicalRatioX = value/100; Screen.Config.Compact(); }
}

[DependsOn("Screen.PhysicalRatioY")]
public double RatioY
{
get { return Screen.PhysicalRatioY * 100; }
set { Screen.PhysicalRatioY = value / 100; }
set { Screen.PhysicalRatioY = value / 100; Screen.Config.Compact(); }
}

[DependsOn("Screen.Orientation")]
Expand Down Expand Up @@ -81,12 +81,10 @@ public void EndMove()
Plugin.VerticalAnchors.Children.Clear();
Plugin.HorizontalAnchors.Children.Clear();

//if (!Screen.Config.AllowOverlaps) Screen.Config.Expand();

Screen.Config.Moving = false;
Screen.Config.UpdatePhysicalOutsideBounds();

//if (!Screen.Config.AllowDiscontinuity) Screen.Config.Compact();
Screen.Config.Compact();

//Todo : Plugin.ActivateConfig();
}
Expand Down
1 change: 0 additions & 1 deletion LittleBigMouse_Control/Plugins/Size/SizePlugin.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using LbmScreenConfig;
using LittleBigMouse_Control.PluginLocation;
using LittleBigMouse_Control.SizePlugin;

namespace LittleBigMouse_Control.Plugins.Size
{
Expand Down
12 changes: 6 additions & 6 deletions LittleBigMouse_Control/Plugins/Size/SizeScreenView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
Grid.Row="2"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Text="{Binding Screen.RealPhysicalHeight, StringFormat=N1}"
Text="{Binding RealPhysicalHeight, StringFormat=N1}"
MouseWheel="InsideHeight_MouseWheel"
KeyUp="OnKeyEnterUpdate"
>
Expand All @@ -85,7 +85,7 @@
Grid.Row="2"
VerticalAlignment="Bottom"
HorizontalAlignment="Center"
Text="{Binding Screen.RealPhysicalWidth, StringFormat=N1}"
Text="{Binding RealPhysicalWidth, StringFormat=N1}"
MouseWheel="InsideWidth_MouseWheel"
KeyUp="OnKeyEnterUpdate"
>
Expand Down Expand Up @@ -147,7 +147,7 @@

<TextBox
Foreground="#FFD9DCEC"
Text="{Binding Path=Screen.RealTopBorder, StringFormat=N1, FallbackValue=top}"
Text="{Binding Path=RealTopBorder, StringFormat=N1, FallbackValue=top}"
KeyUp="OnKeyEnterUpdate"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Expand All @@ -158,7 +158,7 @@
<TextBox
Foreground="#FFD9DCEC"

Text="{Binding Path=Screen.RealLeftBorder, StringFormat=N1, FallbackValue=left}"
Text="{Binding Path=RealLeftBorder, StringFormat=N1, FallbackValue=left}"
KeyUp="OnKeyEnterUpdate"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Expand All @@ -168,7 +168,7 @@

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom">
<TextBox
Text="{Binding Path=Screen.RealBottomBorder, StringFormat=N1, FallbackValue=bottom}"
Text="{Binding Path=RealBottomBorder, StringFormat=N1, FallbackValue=bottom}"
KeyUp="OnKeyEnterUpdate"
VerticalAlignment="Bottom"
HorizontalAlignment="Center"
Expand All @@ -179,7 +179,7 @@

<StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" >
<TextBox
Text="{Binding Path=Screen.RealRightBorder, StringFormat=N1,FallbackValue=right}"
Text="{Binding Path=RealRightBorder, StringFormat=N1,FallbackValue=right}"
KeyUp="OnKeyEnterUpdate"
HorizontalAlignment="Right"
Foreground="#FFD9DCEC"
Expand Down
1 change: 0 additions & 1 deletion LittleBigMouse_Control/Plugins/Size/SizeScreenView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using LittleBigMouse_Control.SizePlugin;

namespace LittleBigMouse_Control.Plugins.Size
{
Expand Down
74 changes: 70 additions & 4 deletions LittleBigMouse_Control/Plugins/Size/SizeViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Shapes;
using LittleBigMouse_Control.SizePlugin;
using NotifyChange;

namespace LittleBigMouse_Control.SizePlugin
namespace LittleBigMouse_Control.Plugins.Size
{
class CotationMark
{
Expand Down Expand Up @@ -189,5 +187,73 @@ public void DrawLines()
_outsideVerticalCotation.SetPoints(arrow, x + (w/8)-(w/128),y2,x + (w/8)-(w/128),y2+h2);
_ousideHorizontalCotation.SetPoints(arrow, x2, y + (h/8)-(h/128),x2+w2,y + (h/8)-(h/128));
}

[DependsOn("Screen.RealPhysicalHeight")]
public double RealPhysicalHeight
{
get { return Screen.RealPhysicalHeight; }
set { Screen.RealPhysicalHeight = value; Screen.Config.Compact(); }
}


[DependsOn("Screen.RealPhysicalWidth")]
public double RealPhysicalWidth
{
get { return Screen.RealPhysicalWidth; }
set { Screen.RealPhysicalWidth = value; Screen.Config.Compact(); }
}

[DependsOn("Screen.RealTopBorder")]
public double RealTopBorder
{
get { return Screen.RealTopBorder; }
set { Screen.RealTopBorder = value; Screen.Config.Compact(); }
}

[DependsOn("Screen.RealRightBorder")]
public double RealRightBorder
{
get { return Screen.RealRightBorder; }
set { Screen.RealRightBorder = value; Screen.Config.Compact(); }
}

[DependsOn("Screen.RealBottomBorder")]
public double RealBottomBorder
{
get { return Screen.RealBottomBorder; }
set { Screen.RealBottomBorder = value; Screen.Config.Compact(); }
}

[DependsOn("Screen.RealLeftBorder")]
public double RealLeftBorder
{
get { return Screen.RealLeftBorder; }
set { Screen.RealLeftBorder = value; Screen.Config.Compact(); }
}

[DependsOn("Screen.RealPhysicalHeight", "Screen.RealTopBorder", "Screen.RealBottomBorder")]
public double PhysicalOutsideHeight
{
get { return Screen.RealPhysicalHeight + Screen.RealTopBorder + Screen.RealBottomBorder; }
set
{
double offset = value - PhysicalOutsideHeight;
Screen.RealBottomBorder += offset;
Screen.Config.Compact();
}
}

[DependsOn("Screen.RealPhysicalWidth", "Screen.RealLeftBorder", "Screen.RealRightBorder")]
public double PhysicalOutsideWidth
{
get { return Screen.RealPhysicalWidth + Screen.RealLeftBorder + Screen.RealRightBorder; }
set
{
double offset = (value - PhysicalOutsideWidth) / 2;
Screen.RealLeftBorder += offset;
Screen.RealRightBorder += offset;
Screen.Config.Compact();
}
}
}
}
14 changes: 6 additions & 8 deletions LittleBigMouse_Control/ScreenFrameView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Height="{Binding Path=Height, FallbackValue=180}"
Margin="{Binding Path=Margin}"
Foreground="White"
x:Name="UserControl"
>
<UserControl.ContextMenu>
<ContextMenu>
Expand Down Expand Up @@ -119,15 +120,12 @@
Padding="0"
Grid.Row="0"
Grid.Column="1"
Content="{Binding Path=Screen.PnpDeviceName, FallbackValue=Unknown}"
FontSize="{Binding
ElementName=TopRow,
Path=ActualHeight,
Converter={StaticResource Scale},
ConverterParameter=0.8,
FallbackValue=14}"
>
Content="{Binding Path=Screen.PnpDeviceName, FallbackValue=Unknown}">

<Label.FontSize>
<Binding ElementName="TopRow" Path="ActualHeight" Converter="{StaticResource Scale}" ConverterParameter="0.8"
FallbackValue="14" />
</Label.FontSize>
<Label.Foreground>
<LinearGradientBrush>
<GradientStop Offset="0" Color="#F0FFFFFF"/>
Expand Down
6 changes: 3 additions & 3 deletions LittleBigMouse_Control/ScreenFrameViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public double UnrotatedHeight
private set { SetValue(UnrotatedHeightPropertyKey, value); }
}

[DependsOn("Screen", "Screen.Orientation", "Width", "Height")]
[DependsOn("Screen", "Monitor.DisplayOrientation", "Width", "Height")]
private void UpdateUnrotatedWidthHeight()
{
if (Screen.Monitor.DisplayOrientation % 2 == 0)
Expand Down Expand Up @@ -208,7 +208,7 @@ public Transform ScreenOrientation
private set { SetProperty(ref _screenOrientation, value); }
}

[DependsOn("DisplayMonitor.DisplayOrientation", nameof(Width), nameof(Height))]
[DependsOn("Monitor.DisplayOrientation", nameof(Width), nameof(Height))]
public void UpddateScreenOrientation()
{
var t = new TransformGroup();
Expand Down Expand Up @@ -238,7 +238,7 @@ public Viewbox Logo
private set { SetProperty(ref _logo, value); }
}

[DependsOn("Screen.DisplayMonitor.ManufacturerCode")]
[DependsOn("Monitor.ManufacturerCode")]
public void UpdateLogo()
{
switch (Screen.Monitor.ManufacturerCode.ToLower())
Expand Down
25 changes: 2 additions & 23 deletions LittleBigMouse_Control/ScreenViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace LittleBigMouse_Control
{
public class ScreenViewModel : ViewModel
{


private ViewModel _control = null;
public ViewModel Control => _control??(_control=NewControl);
Expand All @@ -30,30 +30,9 @@ public Screen Screen
private void WatchConfig()
{
Watch(Screen.Config,"Config");
Watch(Screen.Monitor,"Monitor");
}

[DependsOn("Screen.RealPhysicalHeight", "Screen.RealTopBorder", "Screen.RealBottomBorder")]
public double PhysicalOutsideHeight
{
get { return Screen.RealPhysicalHeight + Screen.RealTopBorder + Screen.RealBottomBorder; }
set
{
double offset = value - PhysicalOutsideHeight;
Screen.RealBottomBorder += offset;
}
}

[DependsOn("Screen.RealPhysicalWidth", "Screen.RealLeftBorder", "Screen.RealRightBorder")]
public double PhysicalOutsideWidth
{
get { return Screen.RealPhysicalWidth + Screen.RealLeftBorder + Screen.RealRightBorder; }
set
{
double offset = (value - PhysicalOutsideWidth) / 2;
Screen.RealLeftBorder += offset;
Screen.RealRightBorder += offset;
}
}

private bool _power = true;
public Viewbox PowerButton => _power
Expand Down
2 changes: 1 addition & 1 deletion LittleBigMouse_Control/setup/LittleBigMouse.iss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; -- LittleBigMouse.iss --
;#define AppVer GetFileVersion('..\bin\x64\Release\LittleBigMouse_Control.exe')
#define AppVer '3.0-alpha3'
#define AppVer '3.0-alpha4'

[Setup]
AppName=Little Big Mouse
Expand Down
Loading

0 comments on commit 666e3d8

Please sign in to comment.