Skip to content

Commit

Permalink
- add: new ERROR Levels: AlreadyExist, NotAllowed
Browse files Browse the repository at this point in the history
- add: tooltips for better understanding
- add: more translations
- fix: check security settings when creating / deleting apps
- fix: check security settings when creating / deleting files
- fix: set security settings correctly when creating applications
  • Loading branch information
c3rebro committed Mar 13, 2021
1 parent 36cf2c0 commit 0f26e3c
Show file tree
Hide file tree
Showing 47 changed files with 2,622 additions and 912 deletions.
28 changes: 27 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
/VCNEditor
/VCNEditor
/18-01_SMARTINTEGO-VCN_DEVKIT
/docs
/packages
/PluginSystem/bin
/.vs
/MVVMDialogs/bin
/MVVMDialogs/obj
/PluginSystem/obj
/RFiDGear/3rdParty/RedCell/RedCell.Diagnostics.Update/Update.cd
/RFiDGear/bin
/RFiDGear/obj
/RFiDGear/__obj
/RFiDGear/Mifare_4k_1_57.jpg
/RFiDGear/mvvmdialogsample.txt
/RFiDGearBundleSetup
/Setup/bin
/Setup/obj
/key.pub
/key
/idFile.hex
/database.xml
/accessFile_neu.hex
/UpgradeLog2.htm
/UpgradeLog.htm
/taskdatabase.xml
/setup example.wxs
2 changes: 1 addition & 1 deletion MVVMDialogs/Behaviors/DialogBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private static void AddDialog(IDialogViewModel viewModel, ObservableCollection<I
}
}

catch (Exception e)
catch
{

}
Expand Down
7 changes: 3 additions & 4 deletions MVVMDialogs/MVVMDialogs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
<OutputType>Library</OutputType>
<RootNamespace>MVVMDialogs</RootNamespace>
<AssemblyName>MVVMDialogs</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -90,9 +91,7 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="View" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Page Include="View\CustomDialogBox.xaml" />
</ItemGroup>
Expand Down
223 changes: 223 additions & 0 deletions PluginSystem/DataAccessLayer/AsyncCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
/*
* Created by SharpDevelop.
* User: C3rebro
* Date: 14.11.2017
* Time: 22:24
*
* Based on the article: Patterns for Asynchronous MVVM Applications: Commands
* http://msdn.microsoft.com/en-us/magazine/dn630647.aspx
*
* Modified by Scott Chamberlain 11-19-2014
* - Added parameter support
* - Added the ability to shut off the single invocation restriction.
* - Made a non-generic version of the class that called the generic version with a <object> return type.
*/
using GalaSoft.MvvmLight;

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;

namespace RFiDGear.DataAccessLayer
{
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;

public class AsyncCommand<TResult> : AsyncCommandBase, INotifyPropertyChanged
{
private readonly Func<CancellationToken, Task<TResult>> _command;
private readonly CancelAsyncCommand _cancelCommand;
private NotifyTaskCompletion<TResult> _execution;

public AsyncCommand(Func<CancellationToken, Task<TResult>> command)
{
_command = command;
_cancelCommand = new CancelAsyncCommand();
}

public override bool CanExecute(object parameter)
{
return Execution == null || Execution.IsCompleted;
}

public override async Task ExecuteAsync(object parameter)
{
_cancelCommand.NotifyCommandStarting();
Execution = new NotifyTaskCompletion<TResult>(_command(_cancelCommand.Token));
RaiseCanExecuteChanged();
await Execution.TaskCompletion;
_cancelCommand.NotifyCommandFinished();
RaiseCanExecuteChanged();
}

public ICommand CancelCommand
{
get { return _cancelCommand; }
}

public NotifyTaskCompletion<TResult> Execution
{
get { return _execution; }
private set
{
_execution = value;
OnPropertyChanged();
}
}

public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}

private sealed class CancelAsyncCommand : ICommand
{
private CancellationTokenSource _cts = new CancellationTokenSource();
private bool _commandExecuting;

public CancellationToken Token { get { return _cts.Token; } }

public void NotifyCommandStarting()
{
_commandExecuting = true;
if (!_cts.IsCancellationRequested)
return;
_cts = new CancellationTokenSource();
RaiseCanExecuteChanged();
}

public void NotifyCommandFinished()
{
_commandExecuting = false;
RaiseCanExecuteChanged();
}

bool ICommand.CanExecute(object parameter)
{
return _commandExecuting && !_cts.IsCancellationRequested;
}

void ICommand.Execute(object parameter)
{
_cts.Cancel();
RaiseCanExecuteChanged();
}

public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}

private void RaiseCanExecuteChanged()
{
CommandManager.InvalidateRequerySuggested();
}
}
}

public static class AsyncCommand
{
public static AsyncCommand<object> Create(Func<Task> command)
{
return new AsyncCommand<object>(async _ => { await command(); return null; });
}

public static AsyncCommand<TResult> Create<TResult>(Func<Task<TResult>> command)
{
return new AsyncCommand<TResult>(_ => command());
}

public static AsyncCommand<object> Create(Func<CancellationToken, Task> command)
{
return new AsyncCommand<object>(async token => { await command(token); return null; });
}

public static AsyncCommand<TResult> Create<TResult>(Func<CancellationToken, Task<TResult>> command)
{
return new AsyncCommand<TResult>(command);
}
}
}
// public interface AsyncCommand<TParam>: ICommand, IDisposable
// {
//
// }
//
// public class AsyncCommand : ICommand, IDisposable
// {
// private readonly BackgroundWorker _backgroundWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
// private readonly Func<bool> _canExecute;
//
// public AsyncCommand(Action action, Func<bool> canExecute = null, Action<object> completed = null,
// Action<Exception> error = null)
// {
// _backgroundWorker.DoWork += (s, e) =>
// {
// CommandManager.InvalidateRequerySuggested();
// action();
// };
//
// _backgroundWorker.RunWorkerCompleted += (s, e) =>
// {
// if (completed != null && e.Error == null)
// completed(e.Result);
//
// if (error != null && e.Error != null)
// error(e.Error);
//
// CommandManager.InvalidateRequerySuggested();
// };
//
// _canExecute = canExecute;
// }
//
// public void Cancel()
// {
// if (_backgroundWorker.IsBusy)
// _backgroundWorker.CancelAsync();
// }
//
// public bool CanExecute(object parameter)
// {
// return _canExecute == null
// ? !_backgroundWorker.IsBusy
// : !_backgroundWorker.IsBusy && _canExecute();
// }
//
// public void Execute(object parameter)
// {
// _backgroundWorker.RunWorkerAsync();
// }
//
// public event EventHandler CanExecuteChanged
// {
// add { CommandManager.RequerySuggested += value; }
// remove { CommandManager.RequerySuggested -= value; }
// }
//
// public void Dispose()
// {
// Dispose(true);
// GC.SuppressFinalize(this);
// }
//
// protected virtual void Dispose(bool disposing)
// {
// if (disposing)
// {
// if (_backgroundWorker != null)
// _backgroundWorker.Dispose();
// }
// }
// }
//}
39 changes: 39 additions & 0 deletions PluginSystem/DataAccessLayer/AsyncCommandBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Created by SharpDevelop.
* User: C3rebro
* Date: 15.11.2017
* Time: 21:54
*
* Based on the article: Patterns for Asynchronous MVVM Applications: Commands
* http://msdn.microsoft.com/en-us/magazine/dn630647.aspx
*/

using System;
using System.Threading.Tasks;
using System.Windows.Input;

namespace RFiDGear.DataAccessLayer
{
public abstract class AsyncCommandBase : IAsyncCommand
{
public abstract bool CanExecute(object parameter);

public abstract Task ExecuteAsync(object parameter);

public async void Execute(object parameter)
{
await ExecuteAsync(parameter);
}

public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}

protected void RaiseCanExecuteChanged()
{
CommandManager.InvalidateRequerySuggested();
}
}
}
7 changes: 7 additions & 0 deletions PluginSystem/DataAccessLayer/IAsyncCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System.Threading.Tasks;
using System.Windows.Input;

public interface IAsyncCommand : ICommand
{
Task ExecuteAsync(object parameter);
}
47 changes: 47 additions & 0 deletions PluginSystem/DataAccessLayer/LogWriter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Created by SharpDevelop.
* Date: 31.08.2017
* Time: 20:32
*
*/

using System;
using System.IO;

namespace PluginSystem.DataAccessLayer
{
/// <summary>
/// Description of LogWriter.
/// </summary>
public static class LogWriter
{
private static StreamWriter textStream;

private static readonly string _logFileName = "log.txt";

/// <summary>
///
/// </summary>
/// <param name="entry"></param>
public static void CreateLogEntry(string entry)
{
string _logFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "RFiDGear", "log");

if (!Directory.Exists(_logFilePath))
Directory.CreateDirectory(_logFilePath);
try
{
if (!File.Exists(Path.Combine(_logFilePath, _logFileName)))
textStream = File.CreateText(Path.Combine(_logFilePath, _logFileName));
else
textStream = File.AppendText(Path.Combine(_logFilePath, _logFileName));
textStream.WriteAsync(string.Format("{0}" + Environment.NewLine, entry.Replace("\r\n", "; ")));
textStream.Close();
textStream.Dispose();
}
catch
{
}
}
}
}
Loading

0 comments on commit 0f26e3c

Please sign in to comment.