Skip to content

Commit ba46e8e

Browse files
committed
First release version
1 parent 77d9a37 commit ba46e8e

14 files changed

Lines changed: 201 additions & 32 deletions

SharpPasswordManager.BL/StorageController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ occurs when <modelList> not initialized and file
2121
model list to a file by <path>.
2222
----------------------------------------------------------------------------------*/
2323
/// <summary>
24-
/// Manage models collection taken from file. Can get, paste and find count of models.
24+
/// Manage models collection taken from file. Can get, add, remove, paste and find count of models.
2525
/// </summary>
2626
/// <typeparam name="TModel">Any model class.</typeparam>
2727
public class StorageController<TModel> : IStorageController<TModel>

SharpPasswordManager.DL/Models/CategoryModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public override int GetHashCode()
3030
if (Name != null)
3131
hash = (hash * hashMultiple) ^ Name.GetHashCode();
3232

33-
if (DataIndexes.Count > 0)
33+
if (DataIndexes != null && DataIndexes.Count > 0)
3434
{
3535
foreach (var item in DataIndexes)
3636
hash = (hash * hashMultiple) ^ item.GetHashCode();

SharpPasswordManager/Handlers/IStorageHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
namespace SharpPasswordManager.Handlers
44
{
5+
/// <summary>
6+
/// Provides mechanism to manage categories storage controller and data storage controller.
7+
/// </summary>
8+
/// <typeparam name="TCategory"></typeparam>
9+
/// <typeparam name="TData"></typeparam>
510
public interface IStorageHandler<TCategory, TData>
611
{
712
TCategory CurrentCategory { get; set; }

SharpPasswordManager/Handlers/StorageHandler.cs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,49 @@
66

77
namespace SharpPasswordManager.Handlers
88
{
9+
/// <summary>
10+
/// Manage two <seealso cref="IStorageController{TModel}"/> instance, one of which storage categories and second storage data.
11+
/// </summary>
912
public class StorageHandler : IStorageHandler<CategoryModel, DataModel>
1013
{
1114
private IStorageController<CategoryModel> categoryController;
1215
private IStorageController<DataModel> dataController;
1316

1417
private Dictionary<DataModel, int> usingData = new Dictionary<DataModel, int>();
18+
/// <summary>
19+
/// Selected model of <see cref="CategoryModel"/>.
20+
/// </summary>
1521
public CategoryModel CurrentCategory { get; set; }
16-
Random random = new Random();
22+
private Random random = new Random();
1723

24+
/// <summary>
25+
/// Create a new class instance.
26+
/// </summary>
27+
/// <param name="categoryController"><seealso cref="IStorageController{TModel}"/> with categories.</param>
28+
/// <param name="dataController"><seealso cref="IStorageController{TModel}"/> with data.</param>
1829
public StorageHandler(IStorageController<CategoryModel> categoryController, IStorageController<DataModel> dataController)
1930
{
2031
this.categoryController = categoryController;
2132
this.dataController = dataController;
2233
}
2334

35+
/// <summary>
36+
/// Add <seealso cref="CategoryModel"/> to category storage contoller.
37+
/// </summary>
38+
/// <param name="category">Adding category</param>
2439
public void AddCategory(CategoryModel category)
2540
{
2641
categoryController.Add(category);
2742
}
2843

44+
/// <summary>
45+
/// Write <seealso cref="DataModel"/> to data storage contoller at defined random index. Then write that index to CurrentCategory index collection, and save changes of category storage controller.
46+
/// </summary>
47+
/// <param name="category">Adding data</param>
2948
public void AddData(DataModel data)
3049
{
3150
if (CurrentCategory == null)
32-
{
3351
return;
34-
}
3552

3653
List<int> usingIndexes = new List<int>();
3754
for (int i = 0; i < categoryController.Count(); i++)
@@ -61,11 +78,19 @@ public void AddData(DataModel data)
6178
}
6279
}
6380

81+
/// <summary>
82+
/// Get list of categories.
83+
/// </summary>
84+
/// <returns></returns>
6485
public List<CategoryModel> GetCategories()
6586
{
6687
return categoryController.ToList();
6788
}
6889

90+
/// <summary>
91+
/// Get list of data referenced in CurrentCategory.
92+
/// </summary>
93+
/// <returns></returns>
6994
public List<DataModel> GetData()
7095
{
7196
if (CurrentCategory != null)
@@ -87,11 +112,19 @@ public List<DataModel> GetData()
87112
return new List<DataModel>();
88113
}
89114

115+
/// <summary>
116+
/// Remove category from cetegory storage controller.
117+
/// </summary>
118+
/// <param name="category">Category to remove.</param>
90119
public void RemoveCategory(CategoryModel category)
91120
{
92121
categoryController.Remove(category);
93122
}
94123

124+
/// <summary>
125+
/// Finds which category refers to this data, and remove this reference.
126+
/// </summary>
127+
/// <param name="data">Data to remove.</param>
95128
public void RemoveData(DataModel data)
96129
{
97130
int index = -1;
@@ -120,6 +153,9 @@ public void RemoveData(DataModel data)
120153
}
121154
}
122155

156+
/// <summary>
157+
/// Replace old category by new.
158+
/// </summary>
123159
public void ReplaceCategory(CategoryModel oldCategory, CategoryModel newCategory)
124160
{
125161
for (int i = 0; i < categoryController.Count(); i++)
@@ -132,6 +168,9 @@ public void ReplaceCategory(CategoryModel oldCategory, CategoryModel newCategory
132168
}
133169
}
134170

171+
/// <summary>
172+
/// Replace old data by new.
173+
/// </summary>
135174
public void ReplaceData(DataModel oldData, DataModel newData)
136175
{
137176
foreach (var item in usingData)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3+
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
4+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5+
<security>
6+
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7+
<!-- UAC Manifest Options
8+
If you want to change the Windows User Account Control level replace the
9+
requestedExecutionLevel node with one of the following.
10+
11+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
12+
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
13+
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
14+
15+
Specifying requestedExecutionLevel element will disable file and registry virtualization.
16+
Remove this element if your application requires this virtualization for backwards
17+
compatibility.
18+
-->
19+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
20+
</requestedPrivileges>
21+
<applicationRequestMinimum>
22+
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
23+
<defaultAssemblyRequest permissionSetReference="Custom" />
24+
</applicationRequestMinimum>
25+
</security>
26+
</trustInfo>
27+
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
28+
<application>
29+
<!-- A list of the Windows versions that this application has been tested on
30+
and is designed to work with. Uncomment the appropriate elements
31+
and Windows will automatically select the most compatible environment. -->
32+
<!-- Windows Vista -->
33+
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
34+
<!-- Windows 7 -->
35+
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
36+
<!-- Windows 8 -->
37+
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
38+
<!-- Windows 8.1 -->
39+
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
40+
<!-- Windows 10 -->
41+
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
42+
</application>
43+
</compatibility>
44+
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
45+
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
46+
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
47+
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
48+
<!--
49+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
50+
<windowsSettings>
51+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
52+
</windowsSettings>
53+
</application>
54+
-->
55+
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
56+
<!--
57+
<dependency>
58+
<dependentAssembly>
59+
<assemblyIdentity
60+
type="win32"
61+
name="Microsoft.Windows.Common-Controls"
62+
version="6.0.0.0"
63+
processorArchitecture="*"
64+
publicKeyToken="6595b64144ccf1df"
65+
language="*"
66+
/>
67+
</dependentAssembly>
68+
</dependency>
69+
-->
70+
</assembly>

SharpPasswordManager/SecureManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
/// </summary>
66
public static class SecureManager
77
{
8+
static public string PasswordKey = "Password";
9+
static public string DataFileName = "Data.bin";
10+
static public string CategoriesFileName = "Categories.bin";
11+
12+
813
public static int StartingIndex { get; private set; }
914

1015
private static string key;

SharpPasswordManager/SharpPasswordManager.csproj

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
<Deterministic>true</Deterministic>
1717
<NuGetPackageImportStamp>
1818
</NuGetPackageImportStamp>
19+
<IsWebBootstrapper>false</IsWebBootstrapper>
20+
<PublishUrl>C:\Users\frolo\Desktop\SharpPasswordManager\</PublishUrl>
21+
<Install>true</Install>
22+
<InstallFrom>Disk</InstallFrom>
23+
<UpdateEnabled>false</UpdateEnabled>
24+
<UpdateMode>Foreground</UpdateMode>
25+
<UpdateInterval>7</UpdateInterval>
26+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
27+
<UpdatePeriodically>false</UpdatePeriodically>
28+
<UpdateRequired>false</UpdateRequired>
29+
<MapFileExtensions>true</MapFileExtensions>
30+
<ApplicationRevision>1</ApplicationRevision>
31+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
32+
<UseApplicationTrust>false</UseApplicationTrust>
33+
<PublishWizardCompleted>true</PublishWizardCompleted>
34+
<BootstrapperEnabled>true</BootstrapperEnabled>
1935
</PropertyGroup>
2036
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2137
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -38,6 +54,27 @@
3854
<WarningLevel>4</WarningLevel>
3955
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4056
</PropertyGroup>
57+
<PropertyGroup>
58+
<ApplicationIcon>secure-socket-layer-ssl_icon-icons.com_52820.ico</ApplicationIcon>
59+
</PropertyGroup>
60+
<PropertyGroup>
61+
<ManifestCertificateThumbprint>769B197A0AFFCC9BB33B52168E0A73C9BD57742D</ManifestCertificateThumbprint>
62+
</PropertyGroup>
63+
<PropertyGroup>
64+
<ManifestKeyFile>SharpPasswordManager_TemporaryKey.pfx</ManifestKeyFile>
65+
</PropertyGroup>
66+
<PropertyGroup>
67+
<GenerateManifests>true</GenerateManifests>
68+
</PropertyGroup>
69+
<PropertyGroup>
70+
<TargetZone>LocalIntranet</TargetZone>
71+
</PropertyGroup>
72+
<PropertyGroup>
73+
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
74+
</PropertyGroup>
75+
<PropertyGroup>
76+
<SignManifests>true</SignManifests>
77+
</PropertyGroup>
4178
<ItemGroup>
4279
<Reference Include="MaterialDesignColors, Version=1.2.2.920, Culture=neutral, processorArchitecture=MSIL">
4380
<HintPath>..\packages\MaterialDesignColors.1.2.2\lib\net45\MaterialDesignColors.dll</HintPath>
@@ -186,10 +223,12 @@
186223
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
187224
</EmbeddedResource>
188225
<None Include="packages.config" />
226+
<None Include="Properties\app.manifest" />
189227
<None Include="Properties\Settings.settings">
190228
<Generator>SettingsSingleFileGenerator</Generator>
191229
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
192230
</None>
231+
<None Include="SharpPasswordManager_TemporaryKey.pfx" />
193232
<Resource Include="Views\Fonts\LoraBold.ttf" />
194233
<Resource Include="Views\Fonts\LoraBoldItalic.ttf" />
195234
<Resource Include="Views\Fonts\LoraItalic.ttf" />
@@ -198,7 +237,9 @@
198237
<ItemGroup>
199238
<None Include="App.config" />
200239
</ItemGroup>
201-
<ItemGroup />
240+
<ItemGroup>
241+
<Resource Include="secure-socket-layer-ssl_icon-icons.com_52820.ico" />
242+
</ItemGroup>
202243
<ItemGroup>
203244
<ProjectReference Include="..\SharpPasswordManager.BL\SharpPasswordManager.BL.csproj">
204245
<Project>{4346b910-ee1a-449f-aa12-03c109be012a}</Project>
@@ -209,6 +250,18 @@
209250
<Name>SharpPasswordManager.DL</Name>
210251
</ProjectReference>
211252
</ItemGroup>
253+
<ItemGroup>
254+
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
255+
<Visible>False</Visible>
256+
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
257+
<Install>true</Install>
258+
</BootstrapperPackage>
259+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
260+
<Visible>False</Visible>
261+
<ProductName>.NET Framework 3.5 SP1</ProductName>
262+
<Install>false</Install>
263+
</BootstrapperPackage>
264+
</ItemGroup>
212265
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
213266
<Import Project="..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets" Condition="Exists('..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" />
214267
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

SharpPasswordManager/ViewModels/CategoryViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private void EditCategory()
149149
CategoryModel oldCategory = new CategoryModel();
150150
oldCategory.Name = selectedCategory.Name;
151151
oldCategory.DataIndexes = new List<int>(selectedCategory.DataIndexes);
152-
152+
153153
CategoryValidateViewModel validateVM = new CategoryValidateViewModel(ref selectedCategory);
154154
Views.CategoryValidateView validateView = new Views.CategoryValidateView();
155155
validateView.DataContext = validateVM;

SharpPasswordManager/ViewModels/DataViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.ObjectModel;
66
using System.ComponentModel;
77
using System.IO;
8+
using System.Linq;
89
using System.Windows;
910
using System.Windows.Input;
1011

@@ -93,7 +94,7 @@ private void AddData()
9394
MessageBox.Show($"Can't read data from file {ex.Message}.");
9495
}
9596
OnDataChanged?.Invoke();
96-
SelectedData = DataList[DataList.Count - 1];
97+
SelectedData = DataList.LastOrDefault();
9798
}
9899
}
99100

0 commit comments

Comments
 (0)