Skip to content

Commit

Permalink
Merge pull request #54 from ScottyMac52/featureMakeConrfigurationsAbl…
Browse files Browse the repository at this point in the history
…eToBeDisabled

Version 2.5.0
  • Loading branch information
ScottyMac52 authored Apr 20, 2019
2 parents 96f4a94 + 65c008a commit bdc3e67
Show file tree
Hide file tree
Showing 13 changed files with 718 additions and 325 deletions.
30 changes: 0 additions & 30 deletions MFDSettingsManager/Configuration/MFDConfigurationSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,36 +65,6 @@ public static MFDConfigurationSection GetConfig(ILog logger, string fullPathtoCo

}

/// <summary>
/// Get the module
/// </summary>
/// <param name="moduleName"></param>
/// <returns><seealso cref="ModuleConfigurationDefintion"/></returns>
public ModuleConfigurationDefintion GetModuleConfiguration(string moduleName)
{
var iterator = Modules.GetEnumerator();
while(iterator.MoveNext())
{
var currentModule = (ModuleConfigurationDefintion)iterator.Current;
if(currentModule.ModuleName == moduleName)
{
var defaultConfigs = DefaultConfigurations.List;
defaultConfigs.ForEach(dc =>
{
var existingConfig = currentModule.MFDConfigurations.List.FirstOrDefault(mfdConfig => mfdConfig.Name == dc.Name);
if(existingConfig == null)
{
var newDef = new MFDDefintion(dc);
dc.FileName = currentModule.FileName;
currentModule.MFDConfigurations.Add(newDef);
}
});
return currentModule;
}
}
return null;
}

#region Properties to support schema definitions

/// <summary>
Expand Down
18 changes: 18 additions & 0 deletions MFDSettingsManager/Configuration/MFDDefintion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public MFDDefintion(MFDDefintion dc)
Left = dc.Left;
Top = dc.Top;
Name = dc.Name;
Enabled = dc.Enabled ?? true;
XOffsetStart = dc.XOffsetStart;
XOffsetFinish = dc.XOffsetFinish;
YOffsetStart = dc.YOffsetStart;
Expand All @@ -53,6 +54,23 @@ public string Name
}
}

/// <summary>
/// Is this configuration enabled for use
/// </summary>
[ConfigurationProperty("enable", IsRequired = false, DefaultValue = true)]
public bool? Enabled
{
get
{
var objectVar = this["enable"];
return objectVar == null ? true : Convert.ToBoolean(objectVar);
}
set
{
this["enable"] = value;
}
}

/// <summary>
/// Opacity setting for the image
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions MFDSettingsManager/Mappers/ConfigSectionModelMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ private static ConfigurationDefinition ConvertFromConfigSectionDefinition(MFDCon
XOffsetFinish = currentConfig.XOffsetFinish ?? 0,
YOffsetStart = currentConfig.YOffsetStart ?? 0,
YOffsetFinish = currentConfig.YOffsetFinish ?? 0,
Enabled = currentConfig.Enabled ?? true,
SaveResults = section.SaveClips
};

Expand Down
55 changes: 34 additions & 21 deletions MFDSettingsManager/Models/ConfigurationDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public class ConfigurationDefinition
/// </summary>
public string FilePath { get; set; }

/// <summary>
/// Determines if the configuration is rendered
/// </summary>
public bool Enabled { get; internal set; }

#endregion Identifying properties

#region Basic Image Properties Left, Top, Width, Height and Opacity
Expand Down Expand Up @@ -103,6 +108,7 @@ public ConfigurationDefinition()
/// <param name="dc"></param>
public ConfigurationDefinition(ConfigurationDefinition dc)
{
Enabled = dc.Enabled;
Logger = dc.Logger;
FileName = dc.FileName;
ModuleName = dc.ModuleName;
Expand All @@ -126,28 +132,35 @@ public ConfigurationDefinition(ConfigurationDefinition dc)
/// <returns></returns>
public BitmapSource CropImage(string imagePath)
{
BitmapImage src = new BitmapImage();
src.BeginInit();
src.UriSource = new Uri(imagePath, UriKind.Relative);
src.CacheOption = BitmapCacheOption.OnLoad;
src.EndInit();

Int32Rect offSet = new Int32Rect(XOffsetStart, YOffsetStart, XOffsetFinish - XOffsetStart, YOffsetFinish - YOffsetStart);
CroppedBitmap croppedBitmap = new CroppedBitmap(src, offSet);
var noAlphaSource = new FormatConvertedBitmap();
noAlphaSource.BeginInit();
noAlphaSource.Source = croppedBitmap;
noAlphaSource.DestinationFormat = PixelFormats.Bgr24;
noAlphaSource.AlphaThreshold = 0;
noAlphaSource.EndInit();

if ((SaveResults ?? false) == true)
if (Enabled)
{
var fi = new FileInfo(imagePath);

SaveImage(noAlphaSource, fi.Directory.FullName, $"X_{XOffsetStart}To{XOffsetFinish}Y_{YOffsetStart}To{YOffsetFinish}_{Opacity}");
BitmapImage src = new BitmapImage();
src.BeginInit();
src.UriSource = new Uri(imagePath, UriKind.Relative);
src.CacheOption = BitmapCacheOption.OnLoad;
src.EndInit();

Int32Rect offSet = new Int32Rect(XOffsetStart, YOffsetStart, XOffsetFinish - XOffsetStart, YOffsetFinish - YOffsetStart);
CroppedBitmap croppedBitmap = new CroppedBitmap(src, offSet);
var noAlphaSource = new FormatConvertedBitmap();
noAlphaSource.BeginInit();
noAlphaSource.Source = croppedBitmap;
noAlphaSource.DestinationFormat = PixelFormats.Bgr24;
noAlphaSource.AlphaThreshold = 0;
noAlphaSource.EndInit();

if ((SaveResults ?? false) == true)
{
var fi = new FileInfo(imagePath);

SaveImage(noAlphaSource, fi.Directory.FullName, $"X_{XOffsetStart}To{XOffsetFinish}Y_{YOffsetStart}To{YOffsetFinish}_{Opacity}");
}
return noAlphaSource;
}
else
{
return null;
}
return noAlphaSource;
}

/// <summary>
Expand All @@ -165,7 +178,7 @@ public string ToReadableString()
pathExists = File.Exists(completePath);
fileStatus = pathExists ? "found " : "not found ";
}
return $"Config {Name} for {ModuleName} at ({Left}, {Top}) for ({Width}, {Height}) with Opacity {Opacity} from {completePath ?? "Unknown Image"} was {fileStatus} at Offset ({XOffsetStart}, {YOffsetStart}) for ({XOffsetFinish - XOffsetStart}, {YOffsetFinish - YOffsetStart}).";
return $"Config: {Name} for: {ModuleName} at: ({Left}, {Top}) for ({Width}, {Height}) with Opacity: {Opacity} Enabled: {Enabled} from: {completePath ?? "Unknown Image"} was: {fileStatus} at Offset: ({XOffsetStart}, {YOffsetStart}) for: ({XOffsetFinish - XOffsetStart}, {YOffsetFinish - YOffsetStart}).";
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions MFDSettingsManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.1.0")]
[assembly: AssemblyFileVersion("2.4.1.0")]
[assembly: AssemblyVersion("2.5.0.0")]
[assembly: AssemblyFileVersion("2.5.0.0")]
24 changes: 12 additions & 12 deletions MFDisplay/MFDWindow.xaml → MFDisplay/AuxWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Window x:Class="MFDisplay.MFDWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MFDisplay"
mc:Ignorable="d"
Title="MFD" Name="mfdWindow" BorderThickness="0" Topmost="True" Loaded="Window_Loaded" Closed="Window_Closed" ResizeMode="NoResize" WindowStyle="None" ShowInTaskbar="False" Opacity="0" AllowsTransparency="True">
<Grid>
<Image Width="auto" Height="auto" x:Name="imgMain" Stretch="Fill" Margin="0"/>
</Grid>
</Window>
<Window x:Class="MFDisplay.AuxWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MFDisplay"
mc:Ignorable="d"
Title="MFD" Name="auxWindow" BorderThickness="0" Topmost="True" Loaded="Window_Loaded" Closed="Window_Closed" ResizeMode="NoResize" WindowStyle="None" ShowInTaskbar="False" Opacity="0" AllowsTransparency="True">
<Grid>
<Image Width="auto" Height="auto" x:Name="imgMain" Stretch="Fill" Margin="0"/>
</Grid>
</Window>
Loading

0 comments on commit bdc3e67

Please sign in to comment.