Skip to content

Commit

Permalink
New file format to store images
Browse files Browse the repository at this point in the history
  • Loading branch information
umaranis committed Jan 16, 2017
1 parent b025eab commit fc1cdb4
Show file tree
Hide file tree
Showing 18 changed files with 270 additions and 32 deletions.
2 changes: 1 addition & 1 deletion MindMate.Tests/App.config
Expand Up @@ -3,4 +3,4 @@
<system.diagnostics>
<assert assertuienabled="false"/>
</system.diagnostics>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
9 changes: 8 additions & 1 deletion MindMate.Tests/MindMate.Tests.csproj
Expand Up @@ -8,7 +8,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MindMate.Tests</RootNamespace>
<AssemblyName>MindMate.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand Down Expand Up @@ -83,6 +83,7 @@
<Compile Include="Controller\MainCtrlTests.cs" />
<Compile Include="Controller\MapCtrlTests.cs" />
<Compile Include="Controller\NoteEditorCtrlTests.cs" />
<Compile Include="Serialization\MapZipSerializerTests.cs" />
<Compile Include="View\NoteEditing\HtmlTableHelperTests.cs" />
<Compile Include="View\NoteEditing\HtmlImageProcessorTests.cs" />
<Compile Include="View\NoteEditing\NoteMapGlueTests.cs" />
Expand Down Expand Up @@ -142,6 +143,12 @@
<None Include="Resources\Feature Display.mm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\New Format with Images.mm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\New Format.mm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\RichNotesMap.mm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Binary file not shown.
Binary file added MindMate.Tests/Resources/New Format.mm
Binary file not shown.
114 changes: 114 additions & 0 deletions MindMate.Tests/Serialization/MapZipSerializerTests.cs
@@ -0,0 +1,114 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MindMate.Model;
using MindMate.Serialization;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MindMate.Tests.Serialization
{
[TestClass()]
public class MapZipSerializerTests
{
[TestMethod()]
[ExpectedException(typeof(InvalidDataException))]
public void DeserializeMap_XmlMapFile()
{
var sut = new MapZipSerializer();
sut.DeserializeMap(new MapTree(), @"Resources\Sample Map.mm");
}

[TestMethod()]
public void DeserializeMap_ZipMapFile()
{
var sut = new MapZipSerializer();
sut.DeserializeMap(new MapTree(), @"Resources\New Format.mm");
}

[TestMethod()]
public void DeserializeMap_ZipFileWithImages()
{
var sut = new MapZipSerializer();
sut.DeserializeMap(new MapTree(), @"Resources\New Format with Images.mm");
}

[TestMethod()]
public void DeserializeMap_LargeObject()
{
var sut = new MapZipSerializer();
byte[] data = sut.DeserializeLargeObject(@"Resources\New Format with Images.mm", "33046437-1659-4d39-91dd-5a420e7c4852.png");
Assert.IsTrue(data.Length > 1000);
}

[TestMethod()]
public void SerializeMap()
{
var sut = new MapZipSerializer();
var tree = new MapTree();
var root = new MapNode(tree, "Center");
new MapNode(root, "c1");
new MapNode(root, "c2");
new MapNode(root, "c3");

sut.SerializeMap(tree, null, "MapZapTest1.mm", false);

var tree2 = new MapTree();
sut.DeserializeMap(tree2, "MapZapTest1.mm");

Assert.AreEqual(3, tree2.RootNode.ChildNodes.Count());
}

[TestMethod()]
public void SerializeMap_UpdateAfterSaving()
{
var sut = new MapZipSerializer();
var tree = new MapTree();
var root = new MapNode(tree, "Center");
new MapNode(root, "c1");
new MapNode(root, "c2");
new MapNode(root, "c3");

sut.SerializeMap(tree, null, "MapZapTest2.mm", false);

new MapNode(root, "c4");
new MapNode(root, "c5");

sut.SerializeMap(tree, null, "MapZapTest2.mm", false);

var tree2 = new MapTree();
sut.DeserializeMap(tree2, "MapZapTest2.mm");

Assert.AreEqual(5, tree2.RootNode.ChildNodes.Count());
}

[TestMethod()]
public void SerializeMap_UpdateAfterSaving_WithLargeObject()
{
var lobs = new List<KeyValuePair<string, byte[]>>();

var sut = new MapZipSerializer();
var tree = new MapTree();
var root = new MapNode(tree, "Center");
new MapNode(root, "c1");
new MapNode(root, "c2");
new MapNode(root, "c3");
lobs.Add(new KeyValuePair<string, byte[]>("1", new byte[100]));
sut.SerializeMap(tree, lobs, "MapZapTest2.mm", false);

new MapNode(root, "c4");
new MapNode(root, "c5");
lobs.Add(new KeyValuePair<string, byte[]>("2", new byte[200]));
sut.SerializeMap(tree, lobs, "MapZapTest2.mm", false);

var tree2 = new MapTree();
sut.DeserializeMap(tree2, "MapZapTest2.mm");

Assert.AreEqual(5, tree2.RootNode.ChildNodes.Count());
Assert.AreEqual(100, sut.DeserializeLargeObject("MapZapTest2.mm", "1").Length);
Assert.AreEqual(200, sut.DeserializeLargeObject("MapZapTest2.mm", "2").Length);
}
}
}
2 changes: 1 addition & 1 deletion MindMate.Win7/App.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
18 changes: 13 additions & 5 deletions MindMate.Win7/MindMate.Win7.csproj
Expand Up @@ -9,10 +9,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MindMate.Win7</RootNamespace>
<AssemblyName>MindMate.Win</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -23,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -32,6 +34,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>MindMap.ico</ApplicationIcon>
Expand All @@ -48,6 +51,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="CustomFontDialog, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null" />
Expand Down Expand Up @@ -290,11 +294,15 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>"C:\Program Files (x86)\Windows Kits\8.1\bin\x86\UICC.exe" "$(ProjectDir)View\Ribbon\RibbonMarkup.xml" "$(ProjectDir)View\Ribbon\RibbonMarkup.bml" /res:"$(ProjectDir)View\Ribbon\RibbonMarkup.rc"
<PreBuildEvent>"C:\Program Files (x86)\Windows Kits\10\bin\x86\UICC.exe" "$(ProjectDir)View\Ribbon\RibbonMarkup.xml" "$(ProjectDir)View\Ribbon\RibbonMarkup.bml" /res:"$(ProjectDir)View\Ribbon\RibbonMarkup.rc"

"C:\Program Files (x86)\Windows Kits\8.1\bin\x86\rc.exe" /v "$(ProjectDir)View\Ribbon\RibbonMarkup.rc"

cmd /c "("$(VS140COMNTOOLS)..\..\VC\bin\vcvars32.bat") &amp;&amp; ("$(VS140COMNTOOLS)..\..\VC\bin\link.exe" /VERBOSE /NOENTRY /DLL /OUT:"$(ProjectDir)View\Ribbon\RibbonMarkup.ribbon" "$(ProjectDir)View\Ribbon\RibbonMarkup.res")"</PreBuildEvent>

"C:\Program Files (x86)\Windows Kits\10\bin\x86\rc.exe" /v "$(ProjectDir)View\Ribbon\RibbonMarkup.rc"



cmd /c "("C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars32.bat") &amp;&amp; ("C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.24629\bin\HostX86\x86\link.exe" /VERBOSE /NOENTRY /DLL /OUT:"$(ProjectDir)View\Ribbon\RibbonMarkup.ribbon" "$(ProjectDir)View\Ribbon\RibbonMarkup.res")"</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion MindMate.Win7/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion MindMate.WinXP/App.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
7 changes: 5 additions & 2 deletions MindMate.WinXP/MindMate.WinXP.csproj
Expand Up @@ -9,10 +9,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MindMate.WinXP</RootNamespace>
<AssemblyName>MindMate.WinXP</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -23,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -32,6 +34,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>MindMap.ico</ApplicationIcon>
Expand Down
2 changes: 1 addition & 1 deletion MindMate.WinXP/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions MindMate/MindMate.csproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -10,14 +10,15 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MindMate</RootNamespace>
<AssemblyName>MindMate</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -42,6 +43,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>false</RunCodeAnalysis>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -50,6 +52,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
Expand All @@ -71,6 +74,10 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Windows.Forms.Calendar, Version=1.0.5704.28890, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Binaries\System.Windows.Forms.Calendar.dll</HintPath>
Expand Down Expand Up @@ -113,6 +120,7 @@
<Compile Include="Controller\StatusBarCtrl.cs" />
<Compile Include="Controller\INoteEditor.cs" />
<Compile Include="Modules\Logging\Log.cs" />
<Compile Include="Serialization\MapZipSerializer.cs" />
<Compile Include="View\NoteEditing\PluggableProtocol\ComSupport.cs" />
<Compile Include="View\NoteEditing\PluggableProtocol\EmbeddedProtocol.cs" />
<Compile Include="View\NoteEditing\ImageLocalProvider.cs" />
Expand Down
2 changes: 1 addition & 1 deletion MindMate/Plugins/Tasks/TaskRes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fc1cdb4

Please sign in to comment.