Skip to content

Commit

Permalink
1.2.1
Browse files Browse the repository at this point in the history
- Added toggle for semi-transparent background for text-blocks, enabled per-text block.
  • Loading branch information
VashBaldeus committed Nov 1, 2021
1 parent 52cf581 commit 4ca595a
Show file tree
Hide file tree
Showing 41 changed files with 496 additions and 915 deletions.
Binary file modified .vs/Screenshot_Editor/v16/.suo
Binary file not shown.
32 changes: 32 additions & 0 deletions GTAWorld Screenshot Editor/Converters/BooleanToSolidColorBrush.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Windows.Data;
using System.Windows.Media;

namespace GTAWorld_Screenshot_Editor.Converters
{
public class BooleanToSolidColorBrush : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if(value == null)
return Brushes.Transparent;

var flag = (bool)value;

if (!flag) return Brushes.Transparent;

var brush = (SolidColorBrush)new BrushConverter().ConvertFrom("#000");

if (brush == null) return Brushes.Transparent;

brush.Opacity = 0.5;

return brush;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Brushes.Transparent;
}
}
}
5 changes: 2 additions & 3 deletions GTAWorld Screenshot Editor/GTAWorld Screenshot Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<Compile Include="Controllers\Interfaces\IDialogService.cs" />
<Compile Include="Controllers\Interfaces\IOcrService.cs" />
<Compile Include="Controllers\OcrService.cs" />
<Compile Include="Converters\BooleanToSolidColorBrush.cs" />
<Compile Include="ExtensionMethods.cs" />
<Compile Include="Models\CacheScreenshot.cs" />
<Compile Include="Models\DoNotCensorModel.cs" />
Expand Down Expand Up @@ -132,9 +133,7 @@
<ItemGroup>
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Converters\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="Resources\AppIcon.ico" />
<Resource Include="Resources\Logo.png" />
Expand Down
17 changes: 9 additions & 8 deletions GTAWorld Screenshot Editor/Models/CacheScreenshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ public void InitImage()
{
if (string.IsNullOrEmpty(ImageFilePath))
return;

var fs = File.Open(ImageFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);

using (var fs = new FileStream(ImageFullPath, FileMode.Open))
{
Bitmap.BeginInit();
Bitmap.StreamSource = fs;
Bitmap.CacheOption = BitmapCacheOption.OnLoad;
Bitmap.EndInit();
}
Bitmap.BeginInit();
Bitmap.StreamSource = fs;
Bitmap.CacheOption = BitmapCacheOption.OnLoad;
Bitmap.EndInit();

fs.Close();
}
}
}
}
23 changes: 23 additions & 0 deletions GTAWorld Screenshot Editor/Models/Text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ public string ParsedChat
set { _parsedChat = value; OnPropertyChanged(); }
}

private bool _backgroundOpacity;

public bool BlackBackgroundOpacity
{
get => _backgroundOpacity;
set
{
_backgroundOpacity = value;
OnPropertyChanged();

if(Texts.Count > 0)
Texts.ForEach(fe => fe.BlackBackgroundOpacity = value);
}
}

private ObservableCollection<ImageText> _texts = new ObservableCollection<ImageText>();

[XmlIgnore]
Expand Down Expand Up @@ -137,5 +152,13 @@ public DropShadowEffect Effect
get => _effect;
set { _effect = value; OnPropertyChanged(); }
}

private bool _backgroundOpacity;

public bool BlackBackgroundOpacity
{
get => _backgroundOpacity;
set { _backgroundOpacity = value; OnPropertyChanged(); }
}
}
}
4 changes: 2 additions & 2 deletions GTAWorld Screenshot Editor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,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("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.2.1.0")]
[assembly: AssemblyFileVersion("1.2.1.0")]
29 changes: 19 additions & 10 deletions GTAWorld Screenshot Editor/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ private void InitCommands()
SaveCacheCommand = new RelayCommand(SaveCacheExecute);

ReplaceNameCommand = new RelayCommand(ReplaceNameExecute);

RefreshCachedCommand = new RelayCommand(InitCachedScreenshots);
}

#endregion
Expand All @@ -93,7 +95,7 @@ public void OnLoadExecute(object obj)

InitResolutions();

InitCachedScreenshots();
InitCachedScreenshots(null);

ResetCommand.Execute(null);

Expand Down Expand Up @@ -322,7 +324,7 @@ public void LoadCacheExecute(object obj)

var cache = (CacheScreenshot)obj;

InitCachedScreenshots();
InitCachedScreenshots(null);

cache = ScreenCache.FirstOrDefault(fod => fod.Guid == cache.Guid);

Expand Down Expand Up @@ -662,6 +664,8 @@ public void ReplaceNameExecute(object obj)
}
}

public ICommand RefreshCachedCommand { get; set; }

#endregion

#region Public Properties
Expand Down Expand Up @@ -1066,7 +1070,7 @@ private void InitResolutions()
/// <summary>
/// Initialize Cached Screenshots collection
/// </summary>
private void InitCachedScreenshots()
private void InitCachedScreenshots(object obj)
{
try
{
Expand Down Expand Up @@ -1193,7 +1197,9 @@ private void GenerateText()
BlurRadius = effectValue,
Direction = effectValue,
ShadowDepth = effectValue,
}
},

BlackBackgroundOpacity = SelectedBlock.BlackBackgroundOpacity
}
);

Expand Down Expand Up @@ -1296,27 +1302,30 @@ private void LookForMainDirectory()
/// </summary>
private void CacheCurrentImageAndText()
{
var cacheDir = @"cached_screens";

var cached = new CacheScreenshot
{
Guid = SelectedImage.Guid,
TextBlocks = TextBlocks,
Command = DeleteCachedImageCommand
};

if (!Directory.Exists(cacheDir))
Directory.CreateDirectory(cacheDir);
//create cache folder if missing
if (!Directory.Exists(CacheScreens))
Directory.CreateDirectory(CacheScreens);

if (ScreenCache.Any(a => a.Guid == SelectedImage.Guid) && ScreenCache.Count > 0 || string.IsNullOrEmpty(SelectedImage.Path))
{
//load current image if exists in cache
cached = ScreenCache.FirstOrDefault(fod => fod.Guid == SelectedImage.Guid);

cached?.InitImage();
}
else
{
//copy image if new cache image
var suffix = SelectedImage.Path.Split('.').OrderByDescending(obd => obd).ToList();

var fileName = $@"{cacheDir}\screenshot_{cached.ScreenshotDate:yyyyMMdd_hhmmss}.{suffix[0]}";
var fileName = $@"{CacheScreens}\screenshot_{cached.ScreenshotDate:yyyyMMdd_hhmmss}.{suffix[0]}";

File.Copy(SelectedImage.Path, fileName);

Expand All @@ -1343,7 +1352,7 @@ private void CacheCurrentImageAndText()
ScreenCache =
new ObservableCollection<CacheScreenshot>(ScreenCache.OrderByDescending(obd => obd.ScreenshotDate));

Xml.Serialize<ObservableCollection<CacheScreenshot>>($@"{cacheDir}\screenshots.cache", ScreenCache);
Xml.Serialize<ObservableCollection<CacheScreenshot>>($@"{CacheScreens}\screenshots.cache", ScreenCache);
}

/// <summary>
Expand Down
Loading

0 comments on commit 4ca595a

Please sign in to comment.