mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 10:43:31 +00:00
Small fixes
This commit is contained in:
parent
a982e28615
commit
8e7f327200
@ -88,8 +88,6 @@ namespace Artemis
|
||||
ContractResolver = _kernel.Get<NinjectContractResolver>()
|
||||
};
|
||||
JsonConvert.DefaultSettings = () => settings;
|
||||
// Configure MoonSharp
|
||||
UserData.RegisterAssembly();
|
||||
}
|
||||
|
||||
protected override void OnExit(object sender, EventArgs e)
|
||||
|
||||
@ -11,6 +11,7 @@ using Artemis.Profiles;
|
||||
using Artemis.Profiles.Layers.Types.Keyboard;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using MoonSharp.Interpreter;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
|
||||
@ -27,17 +28,23 @@ namespace Artemis.DAL
|
||||
|
||||
static ProfileProvider()
|
||||
{
|
||||
// Configure MoonSharp
|
||||
UserData.RegisterAssembly();
|
||||
CheckProfiles();
|
||||
InstallDefaults();
|
||||
}
|
||||
|
||||
public static List<string> GetProfileNames(KeyboardProvider keyboard, EffectModel effect)
|
||||
{
|
||||
if (keyboard == null || effect == null)
|
||||
return null;
|
||||
return ReadProfiles(keyboard.Slug + "/" + effect.Name).Select(p => p.Name).ToList();
|
||||
}
|
||||
|
||||
public static ProfileModel GetProfile(KeyboardProvider keyboard, EffectModel effect, string name)
|
||||
{
|
||||
if (keyboard == null || effect == null)
|
||||
return null;
|
||||
return ReadProfiles(keyboard.Slug + "/" + effect.Name).FirstOrDefault(p => p.Name == name);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using Artemis.DeviceProviders;
|
||||
using Caliburn.Micro;
|
||||
using Ninject.Extensions.Logging;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
@ -160,9 +159,18 @@ namespace Artemis.Managers
|
||||
generic.UpdateDevice(frame.GenericBitmap);
|
||||
foreach (var mousemat in mousemats)
|
||||
mousemat.UpdateDevice(frame.MousematBitmap);
|
||||
|
||||
OnRenderCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler RenderCompleted;
|
||||
|
||||
protected virtual void OnRenderCompleted()
|
||||
{
|
||||
RenderCompleted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public class RenderFrame : IDisposable
|
||||
@ -185,16 +193,26 @@ namespace Artemis.Managers
|
||||
MousematBitmap.SetResolution(96, 96);
|
||||
|
||||
using (var g = Graphics.FromImage(KeyboardBitmap))
|
||||
{
|
||||
g.Clear(Color.Black);
|
||||
}
|
||||
using (var g = Graphics.FromImage(MouseBitmap))
|
||||
{
|
||||
g.Clear(Color.Black);
|
||||
}
|
||||
using (var g = Graphics.FromImage(HeadsetBitmap))
|
||||
{
|
||||
g.Clear(Color.Black);
|
||||
}
|
||||
using (var g = Graphics.FromImage(GenericBitmap))
|
||||
{
|
||||
g.Clear(Color.Black);
|
||||
}
|
||||
using (var g = Graphics.FromImage(MousematBitmap))
|
||||
{
|
||||
g.Clear(Color.Black);
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap KeyboardBitmap { get; set; }
|
||||
public Bitmap MouseBitmap { get; set; }
|
||||
|
||||
@ -20,11 +20,14 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
private PerformanceCounter _overallCpu;
|
||||
private SpotifyLocalAPI _spotify;
|
||||
private bool _spotifySetupBusy;
|
||||
private DateTime _lastSpotifyUpdate;
|
||||
|
||||
public WindowsProfileModel(ILogger logger, MainManager mainManager)
|
||||
: base(mainManager, SettingsProvider.Load<WindowsProfileSettings>(), new WindowsProfileDataModel())
|
||||
{
|
||||
_logger = logger;
|
||||
_lastSpotifyUpdate = DateTime.Now;
|
||||
|
||||
Name = "WindowsProfile";
|
||||
}
|
||||
|
||||
@ -163,10 +166,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
return;
|
||||
|
||||
_spotifySetupBusy = true;
|
||||
_spotify = new SpotifyLocalAPI {ListenForEvents = true};
|
||||
_spotify.OnPlayStateChange += UpdateSpotifyPlayState;
|
||||
_spotify.OnTrackChange += UpdateSpotifyTrack;
|
||||
_spotify.OnTrackTimeChange += UpdateSpotifyTrackTime;
|
||||
_spotify = new SpotifyLocalAPI();
|
||||
|
||||
// Connecting can sometimes use a little bit more conviction
|
||||
Task.Factory.StartNew(() =>
|
||||
@ -186,31 +186,28 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
|
||||
public void UpdateSpotify(WindowsProfileDataModel dataModel)
|
||||
{
|
||||
// This is quite resource hungry so only update it once every two seconds
|
||||
if (DateTime.Now - _lastSpotifyUpdate < TimeSpan.FromSeconds(2))
|
||||
return;
|
||||
_lastSpotifyUpdate = DateTime.Now;
|
||||
|
||||
if (!dataModel.Spotify.Running && SpotifyLocalAPI.IsSpotifyRunning())
|
||||
SetupSpotify();
|
||||
|
||||
var status = _spotify.GetStatus();
|
||||
dataModel.Spotify.Playing = status.Playing;
|
||||
dataModel.Spotify.Running = SpotifyLocalAPI.IsSpotifyRunning();
|
||||
if (status.Track != null)
|
||||
{
|
||||
dataModel.Spotify.Artist = status.Track.ArtistResource?.Name;
|
||||
dataModel.Spotify.SongName = status.Track.TrackResource?.Name;
|
||||
dataModel.Spotify.Album = status.Track.AlbumResource?.Name;
|
||||
dataModel.Spotify.SongLength = status.Track.Length;
|
||||
}
|
||||
|
||||
private void UpdateSpotifyPlayState(object sender, PlayStateEventArgs e)
|
||||
{
|
||||
((WindowsProfileDataModel) DataModel).Spotify.Playing = e.Playing;
|
||||
}
|
||||
|
||||
private void UpdateSpotifyTrack(object sender, TrackChangeEventArgs e)
|
||||
{
|
||||
var dataModel = (WindowsProfileDataModel) DataModel;
|
||||
dataModel.Spotify.Artist = e.NewTrack.ArtistResource?.Name;
|
||||
dataModel.Spotify.SongName = e.NewTrack.TrackResource?.Name;
|
||||
dataModel.Spotify.Album = e.NewTrack.AlbumResource?.Name;
|
||||
dataModel.Spotify.SongLength = e.NewTrack.Length;
|
||||
}
|
||||
|
||||
private void UpdateSpotifyTrackTime(object sender, TrackTimeChangeEventArgs e)
|
||||
{
|
||||
var dataModel = (WindowsProfileDataModel) DataModel;
|
||||
if (dataModel.Spotify.SongLength > 0)
|
||||
dataModel.Spotify.SongPercentCompleted = (int) (e.TrackTime/dataModel.Spotify.SongLength*100.0);
|
||||
dataModel.Spotify.SongPercentCompleted =
|
||||
(int) (status.PlayingPosition/dataModel.Spotify.SongLength*100.0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -48,14 +48,15 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
}
|
||||
|
||||
// Load the ZIP from resources
|
||||
var stream = new MemoryStream(Resources.witcher3_mod);
|
||||
var archive = new ZipArchive(stream);
|
||||
|
||||
using (var stream = new MemoryStream(Resources.witcher3_mod))
|
||||
{
|
||||
using (var archive = new ZipArchive(stream))
|
||||
{
|
||||
// Look for any conflicting mods
|
||||
if (Directory.Exists(dialog.SelectedPath + @"\mods"))
|
||||
{
|
||||
var file =
|
||||
Directory.GetFiles(dialog.SelectedPath + @"\mods", "playerWitcher.ws", SearchOption.AllDirectories)
|
||||
var file = Directory.GetFiles(dialog.SelectedPath + @"\mods", "playerWitcher.ws",
|
||||
SearchOption.AllDirectories)
|
||||
.FirstOrDefault();
|
||||
if (file != null)
|
||||
if (!file.Contains("modArtemis"))
|
||||
@ -70,17 +71,20 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
|
||||
// Put the mod in the documents folder instead
|
||||
// Create the directory structure
|
||||
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Artemis";
|
||||
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
|
||||
@"\Artemis";
|
||||
|
||||
archive.ExtractToDirectory(folder + @"witcher3-mod", true);
|
||||
|
||||
System.Diagnostics.Process.Start(new ProcessStartInfo("https://github.com/SpoinkyNL/Artemis/wiki/The-Witcher-3"));
|
||||
System.Diagnostics.Process.Start(
|
||||
new ProcessStartInfo("https://github.com/SpoinkyNL/Artemis/wiki/The-Witcher-3"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
archive.ExtractToDirectory(dialog.SelectedPath, true);
|
||||
DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -34,76 +34,21 @@ namespace Artemis.ViewModels.Profiles
|
||||
private LayerModel _selectedLayer;
|
||||
private bool _showAll;
|
||||
|
||||
public ProfileViewModel(DeviceManager deviceManager)
|
||||
public ProfileViewModel(DeviceManager deviceManager, LoopManager loopManager)
|
||||
{
|
||||
_deviceManager = deviceManager;
|
||||
|
||||
PreviewTimer = new Timer(40);
|
||||
ShowAll = false;
|
||||
|
||||
PreviewTimer.Elapsed += InvokeUpdateKeyboardPreview;
|
||||
loopManager.RenderCompleted += LoopManagerOnRenderCompleted;
|
||||
deviceManager.OnKeyboardChangedEvent += DeviceManagerOnOnKeyboardChangedEvent;
|
||||
}
|
||||
|
||||
public ProfileModel SelectedProfile { get; set; }
|
||||
public Timer PreviewTimer { get; set; }
|
||||
private void LoopManagerOnRenderCompleted(object sender, EventArgs eventArgs)
|
||||
{
|
||||
if (!Activated)
|
||||
return;
|
||||
|
||||
public LayerModel SelectedLayer
|
||||
{
|
||||
get { return _selectedLayer; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _selectedLayer)) return;
|
||||
_selectedLayer = value;
|
||||
NotifyOfPropertyChange(() => SelectedLayer);
|
||||
}
|
||||
}
|
||||
|
||||
public DrawingImage KeyboardPreview
|
||||
{
|
||||
get { return _keyboardPreview; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _keyboardPreview)) return;
|
||||
_keyboardPreview = value;
|
||||
NotifyOfPropertyChange(() => KeyboardPreview);
|
||||
}
|
||||
}
|
||||
|
||||
public double BlurRadius
|
||||
{
|
||||
get { return _blurRadius; }
|
||||
set
|
||||
{
|
||||
if (value.Equals(_blurRadius)) return;
|
||||
_blurRadius = value;
|
||||
NotifyOfPropertyChange(() => BlurRadius);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowAll
|
||||
{
|
||||
get { return _showAll; }
|
||||
set
|
||||
{
|
||||
if (value == _showAll) return;
|
||||
_showAll = value;
|
||||
NotifyOfPropertyChange(() => ShowAll);
|
||||
}
|
||||
}
|
||||
|
||||
public ImageSource KeyboardImage => ImageUtilities
|
||||
.BitmapToBitmapImage(_deviceManager.ActiveKeyboard?.PreviewSettings.Image ?? Resources.none);
|
||||
|
||||
public bool Activated { get; set; }
|
||||
|
||||
private void DeviceManagerOnOnKeyboardChangedEvent(object sender, KeyboardChangedEventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(() => KeyboardImage);
|
||||
}
|
||||
|
||||
private void InvokeUpdateKeyboardPreview(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (_blurProgress > 2)
|
||||
_blurProgress = 0;
|
||||
_blurProgress = _blurProgress + 0.025;
|
||||
@ -117,7 +62,6 @@ namespace Artemis.ViewModels.Profiles
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var keyboardRect = _deviceManager.ActiveKeyboard.KeyboardRectangle(4);
|
||||
var visual = new DrawingVisual();
|
||||
using (var drawingContext = visual.RenderOpen())
|
||||
@ -175,19 +119,75 @@ namespace Artemis.ViewModels.Profiles
|
||||
}
|
||||
var drawnPreview = new DrawingImage(visual.Drawing);
|
||||
drawnPreview.Freeze();
|
||||
|
||||
KeyboardPreview = drawnPreview;
|
||||
}
|
||||
|
||||
public ProfileModel SelectedProfile { get; set; }
|
||||
|
||||
public LayerModel SelectedLayer
|
||||
{
|
||||
get { return _selectedLayer; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _selectedLayer)) return;
|
||||
_selectedLayer = value;
|
||||
NotifyOfPropertyChange(() => SelectedLayer);
|
||||
}
|
||||
}
|
||||
|
||||
public DrawingImage KeyboardPreview
|
||||
{
|
||||
get { return _keyboardPreview; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _keyboardPreview)) return;
|
||||
_keyboardPreview = value;
|
||||
NotifyOfPropertyChange(() => KeyboardPreview);
|
||||
}
|
||||
}
|
||||
|
||||
public double BlurRadius
|
||||
{
|
||||
get { return _blurRadius; }
|
||||
set
|
||||
{
|
||||
if (value.Equals(_blurRadius)) return;
|
||||
_blurRadius = value;
|
||||
NotifyOfPropertyChange(() => BlurRadius);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowAll
|
||||
{
|
||||
get { return _showAll; }
|
||||
set
|
||||
{
|
||||
if (value == _showAll) return;
|
||||
_showAll = value;
|
||||
NotifyOfPropertyChange(() => ShowAll);
|
||||
}
|
||||
}
|
||||
|
||||
public ImageSource KeyboardImage => ImageUtilities
|
||||
.BitmapToBitmapImage(_deviceManager.ActiveKeyboard?.PreviewSettings.Image ?? Resources.none);
|
||||
|
||||
public bool Activated { get; set; }
|
||||
|
||||
private void DeviceManagerOnOnKeyboardChangedEvent(object sender, KeyboardChangedEventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(() => KeyboardImage);
|
||||
}
|
||||
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
Activated = true;
|
||||
PreviewTimer.Start();
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
Activated = false;
|
||||
PreviewTimer.Stop();
|
||||
}
|
||||
|
||||
#region Processing
|
||||
|
||||
@ -66,13 +66,17 @@ namespace ColorBox
|
||||
arr = stream.ToArray();
|
||||
}
|
||||
|
||||
BitmapSource bitmap = BitmapFrame.Create(new MemoryStream(arr));
|
||||
using (var ms = new MemoryStream(arr))
|
||||
{
|
||||
BitmapSource bitmap = BitmapFrame.Create(ms);
|
||||
|
||||
var pixels = new byte[4];
|
||||
var cb = new CroppedBitmap(bitmap, new Int32Rect((int) p.X, (int) p.Y, 1, 1));
|
||||
|
||||
cb.CopyPixels(pixels, 4, 0);
|
||||
return Color.FromArgb(pixels[3], pixels[2], pixels[1], pixels[0]);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return ColorBox.Color;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user