Skip to content

Commit

Permalink
Merge pull request #272 from mgth/FixRepport
Browse files Browse the repository at this point in the history
setup
  • Loading branch information
mgth authored Dec 6, 2023
2 parents 0b73efc + 124a265 commit 45cd4d1
Show file tree
Hide file tree
Showing 12 changed files with 313 additions and 23 deletions.
2 changes: 1 addition & 1 deletion HLab.Sys/HLab.Sys.Windows.Monitors/DisplayDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public IEnumerable<T> AllChildren<T>() where T : DisplayDevice
}

public DisplayDevice Parent { get; set; }
public IEnumerable<DisplayDevice> Children => _children;
[DataMember] public IEnumerable<DisplayDevice> Children => _children;

/// <summary>
/// Device name as returned by EnumDisplayDevices :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using LittleBigMouse.Zoning;
using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;

namespace LittleBigMouse.DisplayLayout.Monitors;

Expand Down Expand Up @@ -54,13 +55,16 @@ public interface IMonitorsLayout : IDisposable
WinDef.DpiAwareness DpiAwareness { get; }
PhysicalMonitor PrimaryMonitor { get; }

bool Enabled { get; }
bool Enabled { get; set; }

bool AutoUpdate { get; }
bool LoadAtStartup { get; }

ZonesLayout ComputeZones();
void Compact();
void ForceCompact();

void UpdatePhysicalMonitors();
bool Schedule();
void Unschedule();
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static std::string getParentProcess()

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

#if !defined(_DEBUG)
//#if !defined(_DEBUG)
constexpr char szUniqueNamedMutex[] = "LittleBigMouse_Daemon";

HANDLE hHandle = CreateMutex(nullptr, TRUE, reinterpret_cast<LPCWSTR>(szUniqueNamedMutex));
Expand All @@ -82,7 +82,8 @@ int main(int argc, char *argv[]){
return(1); // Exit program
}

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

SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 );
Expand Down Expand Up @@ -110,25 +111,23 @@ int main(int argc, char *argv[]){
if(uiMode)
{
#if defined(_DEBUG)
std::cout << "Starting in UI mode" << std::endl;
std::cout << "Starting in UI mode\n";
#endif
LittleBigMouseDaemon( &server, &engine, &hook ).Run("");
}
else
{
#if defined(_DEBUG)
std::cout << "Starting in Daemon mode" << std::endl;
std::cout << "Starting in Daemon mode\n";
#endif
LittleBigMouseDaemon( &server, &engine, &hook ).Run(R"(\Mgth\LittleBigMouse\Current.xml)");
}

#if !defined(_DEBUG)
if(hHandle)
{
ReleaseMutex (hHandle);
CloseHandle (hHandle);
}
#endif
#if defined(_DEBUG)
system("pause");
#endif
Expand Down
4 changes: 2 additions & 2 deletions LittleBigMouse.Setup/LittleBigMouse.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
;---------------------------------
;General

!define MUI_ICON "${main}\MainIcon.ico"
!define MUI_UNICON "${main}\MainIcon.ico"
!define MUI_ICON "${main}\Assets\lbm-logo.ico"
!define MUI_UNICON "${main}\Assets\lbm-logo.ico"
; !define MUI_SPECIALBITMAP "Bitmap.bmp"

;--------------------------------
Expand Down
221 changes: 221 additions & 0 deletions LittleBigMouse.Ui/LittleBigMouse.Ui.Avalonia/Assets/Icon/lbm_dead.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ You should have received a copy of the GNU General Public License
using HLab.Mvvm.Annotations;
using LittleBigMouse.Plugins;
using System;
using System.IO.Compression;
using System.IO;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using Avalonia.Platform.Storage;
using System.Security.Cryptography.X509Certificates;
using Avalonia.Controls.Shapes;
using System.Diagnostics;

namespace LittleBigMouse.Ui.Avalonia.Controls;

Expand All @@ -45,7 +52,7 @@ public LocationControlView()

private async void Button_Click(object? sender, RoutedEventArgs e)
{
if(!(DataContext is LocationControlViewModel vm)) return;
if(DataContext is not LocationControlViewModel vm) return;

var json = vm.Copy();

Expand All @@ -56,11 +63,55 @@ private async void Button_Click(object? sender, RoutedEventArgs e)
{
await clipboard.SetTextAsync(json);
}

var provider = TopLevel.GetTopLevel(this)?.StorageProvider;
if (provider == null) return;

var folder = await provider.TryGetWellKnownFolderAsync(WellKnownFolder.Documents);
var filename = "LittleBigMouse.Export.gz";

var result = await provider.SaveFilePickerAsync(new FilePickerSaveOptions{
DefaultExtension = ".export.gz" ,
SuggestedFileName = filename,
SuggestedStartLocation = folder
});

if(result!=null)
{
var path = result.TryGetLocalPath();
if(path != null)
{
SaveConfig(json, path);
OpenExplorerWithSelectedFile(path);
}
}
}
catch (Exception ex)
{

}
}

static void SaveConfig(string txt, string path)
{
byte[] donnees = Encoding.UTF8.GetBytes(txt);

using FileStream fichierSortie = File.Create(path);
using GZipStream fluxGZip = new GZipStream(fichierSortie, CompressionMode.Compress);

fluxGZip.Write(donnees, 0, donnees.Length);
}

static void OpenExplorerWithSelectedFile(string filePath)
{
if (!string.IsNullOrEmpty(filePath))
{
Process.Start("explorer.exe", $"/select,\"{filePath}\"");
}
else
{
Console.WriteLine("Invalid file path.");
}
}

}
Loading

0 comments on commit 45cd4d1

Please sign in to comment.