Skip to content

Commit

Permalink
engine start stop fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mgth committed Jan 4, 2018
1 parent 0bc12ca commit 0fcc658
Show file tree
Hide file tree
Showing 16 changed files with 488 additions and 261 deletions.
19 changes: 12 additions & 7 deletions HLab/Windows.Monitors/DisplayDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ namespace HLab.Windows.Monitors
{
public class DisplayDevice : NotifierObject
{
public DisplayDevice()
public DisplayDevice(MonitorsService service)
{
Service = service;
this.SubscribeNotifier();
}

public MonitorsService Service => this.Get(()=>MonitorsService.D);
public MonitorsService Service
{
get => this.Get<MonitorsService>();
private set => this.Set(value);
}

public void Init(DisplayDevice parent, NativeMethods.DISPLAY_DEVICE dev, IList<DisplayDevice> oldDevices)
{
Expand All @@ -57,13 +62,13 @@ public void Init(DisplayDevice parent, NativeMethods.DISPLAY_DEVICE dev, IList<D
case "ROOT":
break;
case "MONITOR":
var mon = Service.GetOrAddMonitor(DeviceId, () => new Monitor {DeviceId = DeviceId});
var mon = Service.GetOrAddMonitor(DeviceId, () => new Monitor(Service) {DeviceId = DeviceId});
mon.DeviceKey = DeviceKey;
mon.DeviceString = DeviceString;
mon.AttachedToDesktop = AttachedToDesktop;
break;
case "PCI":
Service.GetOrAddAdapter(DeviceId, () => new PhysicalAdapter
Service.GetOrAddAdapter(DeviceId, () => new PhysicalAdapter(Service)
{
DeviceId = DeviceId,
DeviceString = DeviceString
Expand All @@ -81,17 +86,17 @@ public void Init(DisplayDevice parent, NativeMethods.DISPLAY_DEVICE dev, IList<D

while (NativeMethods.EnumDisplayDevices(DeviceName, i++, ref child, 0))
{
var device = MonitorsService.D.Devices.FirstOrDefault(m => m.DeviceName == child.DeviceName);
var device = Service.Devices.FirstOrDefault(m => m.DeviceName == child.DeviceName);
if (device != null)
{
oldDevices.Remove(device);
device.Init(this, child, oldDevices);
}
else
{
device = new DisplayDevice();
device = new DisplayDevice(Service);
device.Init(this, child,oldDevices);
MonitorsService.D.Devices.Add(device);
Service.Devices.Add(device);
}
child = new NativeMethods.DISPLAY_DEVICE(true);
}
Expand Down
10 changes: 8 additions & 2 deletions HLab/Windows.Monitors/Monitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ public class Monitor : NotifierObject
if (_pPhysicalMonitorArray != null && _pPhysicalMonitorArray.Length > 0)
NativeMethods.DestroyPhysicalMonitors((uint)_pPhysicalMonitorArray.Length, ref _pPhysicalMonitorArray);
}
public MonitorsService Service => this.Get(() => MonitorsService.D);
public MonitorsService Service
{
get => this.Get<MonitorsService>();
private set => this.Set(value);
}

public string DeviceKey
{
get => this.Get<string>();
Expand Down Expand Up @@ -168,8 +173,9 @@ internal set

private NativeMethods.PHYSICAL_MONITOR[] _pPhysicalMonitorArray;

public Monitor()
public Monitor(MonitorsService service)
{
Service = service;
this.SubscribeNotifier();
}

Expand Down
16 changes: 11 additions & 5 deletions HLab/Windows.Monitors/MonitorsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ You should have received a copy of the GNU General Public License

namespace HLab.Windows.Monitors
{
public class MonitorsService : Singleton<MonitorsService>, INotifyPropertyChanged
public interface IMonitorsService
{
ObservableCollection<Monitor> Monitors { get; }
ObservableFilter<Monitor> AttachedMonitors { get; }
}


public class MonitorsService : Singleton<MonitorsService>, INotifyPropertyChanged, IMonitorsService
{

public event EventHandler DevicesUpdated;
Expand All @@ -48,6 +55,8 @@ private MonitorsService()
_displayChanges.Show();
_displayChanges.Hide();

UpdateDevices();

this.SubscribeNotifier();
}

Expand All @@ -57,9 +66,6 @@ private MonitorsService()
public ObservableCollection<DisplayDevice> Devices => this.Get(() => new ObservableCollection<DisplayDevice>());

public ObservableCollection<Monitor> Monitors => this.Get(() => new ObservableCollection<Monitor>());
[TriggedOn(nameof(Monitors), "Item", "AttachedToDesktop")]
public void test()
{ }

[TriggedOn(nameof(Monitors),"Item","AttachedToDesktop")]
public ObservableFilter<Monitor> AttachedMonitors => this.Get(()=> new ObservableFilter<Monitor>()
Expand Down Expand Up @@ -101,7 +107,7 @@ public void UpdateDevices()
List<DisplayDevice> oldDevices = Devices.ToList();


var device = new DisplayDevice();
var device = new DisplayDevice(this);
device.Init(null,new NativeMethods.DISPLAY_DEVICE(true){DeviceID = "ROOT",DeviceName = null}, oldDevices );

foreach (var d in oldDevices)
Expand Down
14 changes: 12 additions & 2 deletions HLab/Windows.Monitors/PhysicalAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ namespace HLab.Windows.Monitors
{
public class PhysicalAdapter : NotifierObject
{
public MonitorsService Service => this.Get(()=>MonitorsService.D);
public PhysicalAdapter(MonitorsService service)
{
Service = service;
this.SubscribeNotifier();
}

public MonitorsService Service
{
get => this.Get<MonitorsService>();
private set => this.Set(value);
}

public string DeviceString
{
Expand All @@ -24,7 +34,7 @@ public string DeviceId
}

[TriggedOn(nameof(DeviceId))]
[TriggedOn(nameof(Service),"Displays","Item","DeviceId")]
[TriggedOn(nameof(Service), "Devices", "Item","DeviceId")]
public ObservableFilter<DisplayDevice> Displays => this.Get(() => new ObservableFilter<DisplayDevice>()
.AddFilter(a => a.DeviceId == DeviceId)
.Link(Service.Devices)
Expand Down
5 changes: 4 additions & 1 deletion LittleBigMouse/Control.Core/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
using System.Windows;
using HLab.Mvvm;
using HLab.Plugin;
using HLab.Windows.Monitors;
using LittleBigMouse.ScreenConfigs;

namespace LittleBigMouse.Control.Core
Expand All @@ -34,7 +35,9 @@ public override void Register()
{
var viewModel = D.MainViewModel;

var config = new ScreenConfig();
var m = MonitorsService.D;

var config = new ScreenConfig(m);

viewModel.Config = config;
viewModel.Presenter = new MultiScreensViewModel { Config = config };
Expand Down
1 change: 1 addition & 0 deletions LittleBigMouse/Control.Core/ScreenFrameViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public void UpdateLogo()
Logo = (Viewbox)Application.Current.FindResource("LogoHp"); return;
case "lg":
case "lgs":
case "gsm"://GoldStar
Logo = (Viewbox)Application.Current.FindResource("LogoLg"); return;
case "apl":
case "app":
Expand Down
2 changes: 1 addition & 1 deletion LittleBigMouse/Control.Loader/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 '4.0-beta5'
#define AppVer '4.0-beta6'

[Setup]
AppName=Little Big Mouse
Expand Down
7 changes: 4 additions & 3 deletions LittleBigMouse/Daemon/Geo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,18 @@ public Segment(Point a, Point b)
public Line Line => _line ?? (_line = Line.fromSegment(this));

public Rect Rect => new Rect(A, B);

public double Size
public double SizeSquared
{
get
{
Rect r = Rect;
return Math.Sqrt(r.Width * r.Width + r.Height * r.Height);
return r.Width * r.Width + r.Height * r.Height;
}

}

public double Size => Math.Sqrt(SizeSquared);

public Point? Intersect(Line l)
{
if (l == null) throw new ArgumentNullException(nameof(l));
Expand Down
1 change: 1 addition & 0 deletions LittleBigMouse/Daemon/LittleBigMouse.Daemon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Zone.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
Loading

0 comments on commit 0fcc658

Please sign in to comment.