Skip to content

Commit

Permalink
Merge pull request #267 from PixiEditor/development
Browse files Browse the repository at this point in the history
Added development release channel
  • Loading branch information
flabbet committed Dec 8, 2021
2 parents 4ef0fae + 73a2a43 commit 0f820de
Show file tree
Hide file tree
Showing 26 changed files with 1,198 additions and 1,010 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>AnyCPU;x64;x86</Platforms>
Expand Down
2 changes: 1 addition & 1 deletion PixiEditor.UpdateModule/PixiEditor.UpdateModule.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Platforms>AnyCPU;x64;x86</Platforms>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions PixiEditor.UpdateModule/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public bool CheckUpdateAvailable(ReleaseInfo latestRelease)

public bool IsUpdateCompatible(string[] incompatibleVersions)
{
return !incompatibleVersions.Select(x => x.Trim()).Contains(CurrentVersionTag.Trim());
return !incompatibleVersions.Select(x => x.Trim()).Contains(CurrentVersionTag[..7].Trim());
}

public async Task<bool> IsUpdateCompatible()
Expand Down Expand Up @@ -99,7 +99,7 @@ private static async Task<ReleaseInfo> GetLatestReleaseInfoAsync(string apiUrl)

private static bool ParseVersionString(string versionString, out float version)
{
return float.TryParse(versionString.Replace(".", string.Empty).Insert(1, "."), NumberStyles.Any, CultureInfo.InvariantCulture, out version);
return float.TryParse(versionString[..7].Replace(".", string.Empty).Insert(1, "."), NumberStyles.Any, CultureInfo.InvariantCulture, out version);
}
}
}
4 changes: 2 additions & 2 deletions PixiEditor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,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("0.1.7.0")]
[assembly: AssemblyFileVersion("0.1.7.0")]
[assembly: AssemblyVersion("0.1.6.4")]
[assembly: AssemblyFileVersion("0.1.6.4")]
4 changes: 2 additions & 2 deletions PixiEditor/ViewModels/SubViewModels/Main/UpdateViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -87,7 +87,7 @@ public async Task<bool> CheckForUpdate()

private static void AskToInstall()
{
#if RELEASE
#if RELEASE || DEV_RELEASE
if (IPreferences.Current.GetPreference("CheckUpdatesOnStartup", true))
{
string dir = AppDomain.CurrentDomain.BaseDirectory;
Expand Down
66 changes: 33 additions & 33 deletions PixiEditorTests/Helpers/ViewModelHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,44 @@ namespace PixiEditorTests.HelpersTests
{
public static class ViewModelHelper
{
public static IServiceCollection GetViewModelMainCollection()
{
return new ServiceCollection()
.AddScoped<IPreferences, PreferenceSettingsMock>()
.AddSingleton<BitmapManager>();
}
//public static IServiceCollection GetViewModelMainCollection()
//{
// return new ServiceCollection()
// .AddScoped<IPreferences, PreferenceSettingsMock>()
// .AddSingleton<BitmapManager>();
//}

public static ViewModelMain MockedViewModelMain()
{
IServiceCollection provider = MockedServiceCollection();
//public static ViewModelMain MockedViewModelMain()
//{
// IServiceCollection provider = MockedServiceCollection();

return new ViewModelMain(provider);
}
// return new ViewModelMain(provider);
//}

public static IServiceCollection MockedServiceCollection()
{
return new ServiceCollection()
.AddSingleton<IPreferences>(new Mocks.PreferenceSettingsMock())
.AddSingleton<StylusViewModel>()
.AddSingleton<BitmapManager>()
.AddSingleton<ToolsViewModel>();
}
//public static IServiceCollection MockedServiceCollection()
//{
// return new ServiceCollection()
// .AddSingleton<IPreferences>(new Mocks.PreferenceSettingsMock())
// .AddSingleton<StylusViewModel>()
// .AddSingleton<BitmapManager>()
// .AddSingleton<ToolsViewModel>();
//}

public static T BuildMockedTool<T>(bool requireViewModelMain = false)
where T : Tool
{
IServiceProvider services;
//public static T BuildMockedTool<T>(bool requireViewModelMain = false)
// where T : Tool
//{
// IServiceProvider services;

if (requireViewModelMain)
{
services = MockedViewModelMain().Services;
}
else
{
services = MockedServiceCollection().BuildServiceProvider();
}
// if (requireViewModelMain)
// {
// services = MockedViewModelMain().Services;
// }
// else
// {
// services = MockedServiceCollection().BuildServiceProvider();
// }

return ToolBuilder.BuildTool<T>(services);
}
// return ToolBuilder.BuildTool<T>(services);
//}
}
}
150 changes: 75 additions & 75 deletions PixiEditorTests/ModelsTests/ControllersTests/BitmapManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,90 +8,90 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
{
public class BitmapManagerTests
{
[Fact]
public void TestThatBitmapManagerSetsCorrectTool()
{
BitmapManager bitmapManager = new BitmapManager();
bitmapManager.SetActiveTool(new MockedSinglePixelPenTool());
Assert.Equal(typeof(MockedSinglePixelPenTool), bitmapManager.SelectedTool.GetType());
}
//[Fact]
//public void TestThatBitmapManagerSetsCorrectTool()
//{
// BitmapManager bitmapManager = new BitmapManager();
// bitmapManager.SetActiveTool(new MockedSinglePixelPenTool());
// Assert.Equal(typeof(MockedSinglePixelPenTool), bitmapManager.SelectedTool.GetType());
//}

[Fact]
public void TestThatBitmapManagerAddsEmptyNewLayer()
{
string layerName = "TestLayer";
BitmapManager bitmapManager = new BitmapManager
{
ActiveDocument = new Document(10, 10)
};
bitmapManager.ActiveDocument.AddNewLayer(layerName);
Assert.Single(bitmapManager.ActiveDocument.Layers);
Assert.Equal(layerName, bitmapManager.ActiveDocument.ActiveLayer.Name);
Assert.Equal(1, bitmapManager.ActiveDocument.ActiveLayer.Width);
Assert.Equal(1, bitmapManager.ActiveDocument.ActiveLayer.Height);
}
//[Fact]
//public void TestThatBitmapManagerAddsEmptyNewLayer()
//{
// string layerName = "TestLayer";
// BitmapManager bitmapManager = new BitmapManager
// {
// ActiveDocument = new Document(10, 10)
// };
// bitmapManager.ActiveDocument.AddNewLayer(layerName);
// Assert.Single(bitmapManager.ActiveDocument.Layers);
// Assert.Equal(layerName, bitmapManager.ActiveDocument.ActiveLayer.Name);
// Assert.Equal(1, bitmapManager.ActiveDocument.ActiveLayer.Width);
// Assert.Equal(1, bitmapManager.ActiveDocument.ActiveLayer.Height);
//}

[Fact]
public void TestThatBitmapManagerRemovesLayer()
{
BitmapManager bitmapManager = new BitmapManager
{
ActiveDocument = new Document(10, 10)
};
bitmapManager.ActiveDocument.AddNewLayer("_");
bitmapManager.ActiveDocument.AddNewLayer("_1");
Assert.Equal(2, bitmapManager.ActiveDocument.Layers.Count);
bitmapManager.ActiveDocument.RemoveLayer(0);
Assert.Single(bitmapManager.ActiveDocument.Layers);
}
//[Fact]
//public void TestThatBitmapManagerRemovesLayer()
//{
// BitmapManager bitmapManager = new BitmapManager
// {
// ActiveDocument = new Document(10, 10)
// };
// bitmapManager.ActiveDocument.AddNewLayer("_");
// bitmapManager.ActiveDocument.AddNewLayer("_1");
// Assert.Equal(2, bitmapManager.ActiveDocument.Layers.Count);
// bitmapManager.ActiveDocument.RemoveLayer(0);
// Assert.Single(bitmapManager.ActiveDocument.Layers);
//}

[Fact]
public void TestThatGeneratePreviewLayerGeneratesPreviewLayer()
{
BitmapManager bitmapManager = new BitmapManager
{
ActiveDocument = new Document(10, 10)
};
bitmapManager.ActiveDocument.GeneratePreviewLayer();
Assert.NotNull(bitmapManager.ActiveDocument.PreviewLayer);
Assert.Equal(1, bitmapManager.ActiveDocument.PreviewLayer.Width); // Size is 1x1
Assert.Equal(1, bitmapManager.ActiveDocument.PreviewLayer.Height);
Assert.Equal(0, bitmapManager.ActiveDocument.PreviewLayer.OffsetX + bitmapManager.ActiveDocument.PreviewLayer.OffsetY); // Offset is zero
Assert.Equal(bitmapManager.ActiveDocument.Width, bitmapManager.ActiveDocument.PreviewLayer.MaxWidth);
Assert.Equal(bitmapManager.ActiveDocument.Height, bitmapManager.ActiveDocument.PreviewLayer.MaxHeight);
}
//[Fact]
//public void TestThatGeneratePreviewLayerGeneratesPreviewLayer()
//{
// BitmapManager bitmapManager = new BitmapManager
// {
// ActiveDocument = new Document(10, 10)
// };
// bitmapManager.ActiveDocument.GeneratePreviewLayer();
// Assert.NotNull(bitmapManager.ActiveDocument.PreviewLayer);
// Assert.Equal(1, bitmapManager.ActiveDocument.PreviewLayer.Width); // Size is 1x1
// Assert.Equal(1, bitmapManager.ActiveDocument.PreviewLayer.Height);
// Assert.Equal(0, bitmapManager.ActiveDocument.PreviewLayer.OffsetX + bitmapManager.ActiveDocument.PreviewLayer.OffsetY); // Offset is zero
// Assert.Equal(bitmapManager.ActiveDocument.Width, bitmapManager.ActiveDocument.PreviewLayer.MaxWidth);
// Assert.Equal(bitmapManager.ActiveDocument.Height, bitmapManager.ActiveDocument.PreviewLayer.MaxHeight);
//}

[Fact]
public void TestThatIsOperationToolWorks()
{
MockedSinglePixelPenTool singlePixelPen = new MockedSinglePixelPenTool();
Assert.True(BitmapManager.IsOperationTool(singlePixelPen));
}
//[Fact]
//public void TestThatIsOperationToolWorks()
//{
// MockedSinglePixelPenTool singlePixelPen = new MockedSinglePixelPenTool();
// Assert.True(BitmapManager.IsOperationTool(singlePixelPen));
//}

[StaFact]
public void TestThatBitmapChangesExecuteToolExecutesPenTool()
{
BitmapManager bitmapManager = new BitmapManager
{
Documents = new System.Collections.ObjectModel.ObservableCollection<Document>()
{
new Document(5, 5)
}
};
//[StaFact]
//public void TestThatBitmapChangesExecuteToolExecutesPenTool()
//{
// BitmapManager bitmapManager = new BitmapManager
// {
// Documents = new System.Collections.ObjectModel.ObservableCollection<Document>()
// {
// new Document(5, 5)
// }
// };

bitmapManager.ActiveDocument = bitmapManager.Documents[0];
// bitmapManager.ActiveDocument = bitmapManager.Documents[0];

bitmapManager.ActiveDocument.AddNewLayer("Layer");
bitmapManager.SetActiveTool(new MockedSinglePixelPenTool());
bitmapManager.PrimaryColor = SKColors.Black;
// bitmapManager.ActiveDocument.AddNewLayer("Layer");
// bitmapManager.SetActiveTool(new MockedSinglePixelPenTool());
// bitmapManager.PrimaryColor = SKColors.Black;

bitmapManager.MouseController.StartRecordingMouseMovementChanges(true);
bitmapManager.MouseController.RecordMouseMovementChange(new Coordinates(1, 1));
bitmapManager.MouseController.StopRecordingMouseMovementChanges();
// bitmapManager.MouseController.StartRecordingMouseMovementChanges(true);
// bitmapManager.MouseController.RecordMouseMovementChange(new Coordinates(1, 1));
// bitmapManager.MouseController.StopRecordingMouseMovementChanges();

bitmapManager.ExecuteTool(new Coordinates(1, 1), true);
// bitmapManager.ExecuteTool(new Coordinates(1, 1), true);

Assert.Equal(SKColors.Black, bitmapManager.ActiveLayer.GetPixelWithOffset(1, 1));
}
// Assert.Equal(SKColors.Black, bitmapManager.ActiveLayer.GetPixelWithOffset(1, 1));
//}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,39 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
{
public class BitmapOperationsUtilityTests
{
[Fact]
public void TestThatBitmapOperationsUtilityDeletesPixels()
{
BitmapOperationsUtility util = new BitmapOperationsUtility(new BitmapManager());
util.Manager.ActiveDocument = new Document(10, 10);

Layer testLayer = new Layer("test layer", 10, 10);
Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Black);
testLayer.SetPixels(pixels);

util.DeletePixels(new[] { testLayer }, cords);

Assert.Equal(0, testLayer.GetPixel(0, 0).Alpha);
Assert.Equal(0, testLayer.GetPixel(1, 1).Alpha);
}

[StaFact]
public void TestThatBitmapOperationsUtilityExecutesPenToolProperly()
{
BitmapManager manager = new BitmapManager
{
ActiveDocument = new Document(10, 10),
PrimaryColor = SKColors.Black
};
manager.ActiveDocument.AddNewLayer("Test layer", 10, 10);

BitmapOperationsUtility util = new BitmapOperationsUtility(manager);

List<Coordinates> mouseMove = new List<Coordinates>(new[] { new Coordinates(0, 0) });

util.ExecuteTool(new Coordinates(0, 0), mouseMove, new MockedSinglePixelPenTool());
Assert.Equal(manager.ActiveLayer.GetPixel(0, 0), SKColors.Black);
}
//[Fact]
//public void TestThatBitmapOperationsUtilityDeletesPixels()
//{
// BitmapOperationsUtility util = new BitmapOperationsUtility(new BitmapManager());
// util.Manager.ActiveDocument = new Document(10, 10);

// Layer testLayer = new Layer("test layer", 10, 10);
// Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
// BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Black);
// testLayer.SetPixels(pixels);

// util.DeletePixels(new[] { testLayer }, cords);

// Assert.Equal(0, testLayer.GetPixel(0, 0).Alpha);
// Assert.Equal(0, testLayer.GetPixel(1, 1).Alpha);
//}

//[StaFact]
//public void TestThatBitmapOperationsUtilityExecutesPenToolProperly()
//{
// BitmapManager manager = new BitmapManager
// {
// ActiveDocument = new Document(10, 10),
// PrimaryColor = SKColors.Black
// };
// manager.ActiveDocument.AddNewLayer("Test layer", 10, 10);

// BitmapOperationsUtility util = new BitmapOperationsUtility(manager);

// List<Coordinates> mouseMove = new List<Coordinates>(new[] { new Coordinates(0, 0) });

// util.ExecuteTool(new Coordinates(0, 0), mouseMove, new MockedSinglePixelPenTool());
// Assert.Equal(manager.ActiveLayer.GetPixel(0, 0), SKColors.Black);
//}
}
}
Loading

0 comments on commit 0f820de

Please sign in to comment.