mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added missing files
This commit is contained in:
parent
fe6d171366
commit
d8dbf199d4
5
.gitignore
vendored
5
.gitignore
vendored
@ -10,9 +10,6 @@
|
|||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
*.userprefs
|
*.userprefs
|
||||||
|
|
||||||
# Build results
|
|
||||||
[Dd]ebug/
|
|
||||||
[Dd]ebugPublic/
|
|
||||||
[Rr]elease/
|
[Rr]elease/
|
||||||
[Rr]eleases/
|
[Rr]eleases/
|
||||||
x64/
|
x64/
|
||||||
@ -33,8 +30,6 @@ bld/
|
|||||||
*.VisualState.xml
|
*.VisualState.xml
|
||||||
TestResult.xml
|
TestResult.xml
|
||||||
|
|
||||||
# Build Results of an ATL Project
|
|
||||||
[Dd]ebugPS/
|
|
||||||
[Rr]eleasePS/
|
[Rr]eleasePS/
|
||||||
dlldata.c
|
dlldata.c
|
||||||
|
|
||||||
|
|||||||
64
Artemis/Artemis/Modules/Effects/Debug/DebugEffectModel.cs
Normal file
64
Artemis/Artemis/Modules/Effects/Debug/DebugEffectModel.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using Artemis.Models;
|
||||||
|
using Artemis.Utilities.Keyboard;
|
||||||
|
|
||||||
|
namespace Artemis.Modules.Effects.Debug
|
||||||
|
{
|
||||||
|
internal class DebugEffectModel : EffectModel
|
||||||
|
{
|
||||||
|
public DebugEffectModel(DebugEffectSettings settings)
|
||||||
|
{
|
||||||
|
Name = "Debug Effect";
|
||||||
|
Settings = settings;
|
||||||
|
Scale = 4;
|
||||||
|
|
||||||
|
KeyboardRectangle = new KeyboardRectangle(Scale, 0, 0, 21, 6,
|
||||||
|
new List<Color>
|
||||||
|
{
|
||||||
|
Color.Red,
|
||||||
|
Color.OrangeRed,
|
||||||
|
Color.Yellow,
|
||||||
|
Color.Green,
|
||||||
|
Color.Blue,
|
||||||
|
Color.Purple,
|
||||||
|
Color.DeepPink
|
||||||
|
}, LinearGradientMode.Horizontal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Scale { get; set; }
|
||||||
|
|
||||||
|
public DebugEffectSettings Settings { get; set; }
|
||||||
|
|
||||||
|
public KeyboardRectangle KeyboardRectangle { get; set; }
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Enable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
KeyboardRectangle.Height = Settings.Height;
|
||||||
|
KeyboardRectangle.Width = Settings.Width;
|
||||||
|
//KeyboardRectangle.GradientMode = Settings.Type;
|
||||||
|
KeyboardRectangle.Rotate = Settings.Rotate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Bitmap GenerateBitmap()
|
||||||
|
{
|
||||||
|
var bitmap = new Bitmap(21*Scale, 6*Scale);
|
||||||
|
|
||||||
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
|
{
|
||||||
|
g.Clear(Color.Transparent);
|
||||||
|
KeyboardRectangle.Draw(g);
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
37
Artemis/Artemis/Modules/Effects/Debug/DebugEffectSettings.cs
Normal file
37
Artemis/Artemis/Modules/Effects/Debug/DebugEffectSettings.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using Artemis.Models;
|
||||||
|
|
||||||
|
namespace Artemis.Modules.Effects.Debug
|
||||||
|
{
|
||||||
|
internal class DebugEffectSettings : EffectSettings
|
||||||
|
{
|
||||||
|
public DebugEffectSettings()
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Width { get; set; }
|
||||||
|
public int Height { get; set; }
|
||||||
|
public int Spread { get; set; }
|
||||||
|
public bool Rotate { get; set; }
|
||||||
|
public LinearGradientMode Type { get; set; }
|
||||||
|
|
||||||
|
public override sealed void Load()
|
||||||
|
{
|
||||||
|
ToDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override sealed void Save()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override sealed void ToDefault()
|
||||||
|
{
|
||||||
|
Width = 6;
|
||||||
|
Height = 100;
|
||||||
|
Spread = 0;
|
||||||
|
Type = LinearGradientMode.Horizontal;
|
||||||
|
Rotate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
113
Artemis/Artemis/Modules/Effects/Debug/DebugEffectView.xaml
Normal file
113
Artemis/Artemis/Modules/Effects/Debug/DebugEffectView.xaml
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<UserControl x:Class="Artemis.Modules.Effects.Debug.DebugEffectView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:cal="http://www.caliburnproject.org"
|
||||||
|
xmlns:debug="clr-namespace:Artemis.Modules.Effects.Debug"
|
||||||
|
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="407.812" d:DesignWidth="671.484"
|
||||||
|
cal:Bind.AtDesignTime="True">
|
||||||
|
<Grid Margin="15, 5, 15, 5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
|
||||||
|
<Label FontSize="20"
|
||||||
|
Style="{DynamicResource DescriptionHeaderStyle}" HorizontalAlignment="Left">
|
||||||
|
<Label.Content>
|
||||||
|
<AccessText TextWrapping="Wrap" Text="A debug effect." />
|
||||||
|
</Label.Content>
|
||||||
|
</Label>
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
|
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
|
||||||
|
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
|
||||||
|
IsChecked="{Binding Path=EffectEnabled, Mode=OneWay}"
|
||||||
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
|
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
HorizontalAlignment="Left">
|
||||||
|
<Label FontSize="16" Content="Direction" Style="{DynamicResource DescriptionHeaderStyle}"
|
||||||
|
Foreground="#535353" FontFamily="Segoe UI Semibold" />
|
||||||
|
<ComboBox x:Name="RectangleTypes" Width="120" />
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="2"
|
||||||
|
Grid.Column="0"
|
||||||
|
HorizontalAlignment="Left">
|
||||||
|
<Label FontSize="16" Content="Width" Style="{DynamicResource DescriptionHeaderStyle}"
|
||||||
|
Foreground="#535353" FontFamily="Segoe UI Semibold" />
|
||||||
|
<Slider x:Name="Width"
|
||||||
|
VerticalAlignment="top"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Width="132"
|
||||||
|
TickPlacement="BottomRight"
|
||||||
|
TickFrequency="1"
|
||||||
|
Value="{Binding Path=DebugEffectSettings.Width, Mode=TwoWay}" Minimum="1" Maximum="84"
|
||||||
|
SmallChange="1"
|
||||||
|
IsSnapToTickEnabled="True" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="2"
|
||||||
|
Grid.Column="1"
|
||||||
|
HorizontalAlignment="Left">
|
||||||
|
<Label FontSize="16" Content="Height" Style="{DynamicResource DescriptionHeaderStyle}"
|
||||||
|
Foreground="#535353" FontFamily="Segoe UI Semibold" />
|
||||||
|
<Slider x:Name="Height"
|
||||||
|
VerticalAlignment="top"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Width="200"
|
||||||
|
TickPlacement="BottomRight"
|
||||||
|
TickFrequency="1"
|
||||||
|
Value="{Binding Path=DebugEffectSettings.Height, Mode=TwoWay}" Minimum="0" Maximum="24"
|
||||||
|
SmallChange="1"
|
||||||
|
IsSnapToTickEnabled="True" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="3"
|
||||||
|
Grid.Column="1"
|
||||||
|
HorizontalAlignment="Left">
|
||||||
|
<controls:ToggleSwitch IsChecked="{Binding Path=DebugEffectSettings.Rotate, Mode=TwoWay}"
|
||||||
|
Header="Rotate" OnLabel="Yes" OffLabel="No"
|
||||||
|
Margin="0 3 0 0" Width="125" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="3"
|
||||||
|
Grid.Column="0"
|
||||||
|
HorizontalAlignment="Left">
|
||||||
|
<Label FontSize="16" Content="Spread" Style="{DynamicResource DescriptionHeaderStyle}"
|
||||||
|
Foreground="#535353" FontFamily="Segoe UI Semibold" />
|
||||||
|
<Slider x:Name="Spread"
|
||||||
|
VerticalAlignment="top"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Width="132"
|
||||||
|
TickPlacement="BottomRight"
|
||||||
|
TickFrequency="1"
|
||||||
|
Value="{Binding Path=DebugEffectSettings.Spread, Mode=TwoWay}" Minimum="0" Maximum="5"
|
||||||
|
SmallChange="1"
|
||||||
|
IsSnapToTickEnabled="True" />
|
||||||
|
</StackPanel>
|
||||||
|
<!-- Preview panel -->
|
||||||
|
<StackPanel Grid.Column="1" Grid.Row="1">
|
||||||
|
<TextBlock>
|
||||||
|
<InlineUIContainer>
|
||||||
|
<GroupBox Header="Preview" Margin="0" Height="70" Width="118">
|
||||||
|
<Image Source="{Binding ImageSource}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Stretch="Fill" />
|
||||||
|
</GroupBox>
|
||||||
|
</InlineUIContainer>
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace Artemis.Modules.Effects.Debug
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for DebugEffectView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class DebugEffectView : UserControl
|
||||||
|
{
|
||||||
|
public DebugEffectView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
127
Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs
Normal file
127
Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using Artemis.Events;
|
||||||
|
using Artemis.Models;
|
||||||
|
using Caliburn.Micro;
|
||||||
|
|
||||||
|
namespace Artemis.Modules.Effects.Debug
|
||||||
|
{
|
||||||
|
internal class DebugEffectViewModel : Screen, IHandle<ChangeBitmap>, IHandle<ChangeActiveEffect>
|
||||||
|
{
|
||||||
|
private DebugEffectSettings _debugEffectSettings;
|
||||||
|
private ImageSource _imageSource;
|
||||||
|
private string _selectedRectangleType;
|
||||||
|
|
||||||
|
public DebugEffectViewModel(MainModel mainModel)
|
||||||
|
{
|
||||||
|
// Subscribe to main model
|
||||||
|
MainModel = mainModel;
|
||||||
|
MainModel.Events.Subscribe(this);
|
||||||
|
|
||||||
|
// Settings are loaded from file by class
|
||||||
|
DebugEffectSettings = new DebugEffectSettings();
|
||||||
|
|
||||||
|
// Create effect model and add it to MainModel
|
||||||
|
DebugEffectModel = new DebugEffectModel(DebugEffectSettings);
|
||||||
|
MainModel.EffectModels.Add(DebugEffectModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainModel MainModel { get; set; }
|
||||||
|
public DebugEffectModel DebugEffectModel { get; set; }
|
||||||
|
|
||||||
|
public static string Name => "Type Waves";
|
||||||
|
public bool EffectEnabled => MainModel.IsEnabled(DebugEffectModel);
|
||||||
|
|
||||||
|
public DebugEffectSettings DebugEffectSettings
|
||||||
|
{
|
||||||
|
get { return _debugEffectSettings; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (Equals(value, _debugEffectSettings)) return;
|
||||||
|
_debugEffectSettings = value;
|
||||||
|
NotifyOfPropertyChange(() => DebugEffectSettings);
|
||||||
|
|
||||||
|
SelectedRectangleType = value.Type.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BindableCollection<string> RectangleTypes
|
||||||
|
=> new BindableCollection<string>(Enum.GetNames(typeof (LinearGradientMode)));
|
||||||
|
|
||||||
|
public string SelectedRectangleType
|
||||||
|
{
|
||||||
|
get { return _selectedRectangleType; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == _selectedRectangleType) return;
|
||||||
|
_selectedRectangleType = value;
|
||||||
|
NotifyOfPropertyChange(() => SelectedRectangleType);
|
||||||
|
|
||||||
|
DebugEffectSettings.Type = (LinearGradientMode) Enum.Parse(typeof (LinearGradientMode), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageSource ImageSource
|
||||||
|
{
|
||||||
|
get { return _imageSource; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_imageSource = value;
|
||||||
|
NotifyOfPropertyChange(() => ImageSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Handle(ChangeActiveEffect message)
|
||||||
|
{
|
||||||
|
NotifyOfPropertyChange(() => EffectEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Handle(ChangeBitmap message)
|
||||||
|
{
|
||||||
|
//// Doesn't show transparancy
|
||||||
|
//using (var memory = new MemoryStream())
|
||||||
|
//{
|
||||||
|
// message.Bitmap.Save(memory, ImageFormat.Bmp);
|
||||||
|
// memory.Position = 0;
|
||||||
|
|
||||||
|
// var bitmapImage = new BitmapImage();
|
||||||
|
// bitmapImage.BeginInit();
|
||||||
|
// bitmapImage.StreamSource = memory;
|
||||||
|
// bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
|
// bitmapImage.EndInit();
|
||||||
|
|
||||||
|
// ImageSource = bitmapImage;
|
||||||
|
//}
|
||||||
|
|
||||||
|
// Causes "Generic GDI+ Exception" after a while
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ImageSource = Imaging.CreateBitmapSourceFromHBitmap(
|
||||||
|
message.Bitmap.GetHbitmap(),
|
||||||
|
IntPtr.Zero,
|
||||||
|
Int32Rect.Empty,
|
||||||
|
BitmapSizeOptions.FromEmptyOptions());
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ToggleEffect()
|
||||||
|
{
|
||||||
|
MainModel.EnableEffect(DebugEffectModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetSettings()
|
||||||
|
{
|
||||||
|
// TODO: Confirmation dialog (Generic MVVM approach)
|
||||||
|
DebugEffectSettings.ToDefault();
|
||||||
|
NotifyOfPropertyChange(() => DebugEffectSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user