Ejemplo n.º 1
0
 public async Task Decrypt(string filename, int seed, int bits)
 {
     await WaitDialogHelper.ExecuteThreadAsync("Decrypt Image",
                                               () => DecryptText = Interface.Decrypt((BitmapImage)ImageSource, ChannelUsage.Default, seed), exception =>
     {
         if (exception != null)
         {
             ErrorHelper.Add(3, exception.Message, exception.StackTrace);
         }
     });
 }
Ejemplo n.º 2
0
        public async Task <int> EnsureServerSync(WaitDialogHelper myDialog)
        {
            if (isRunning == 1)
            {
                return(0);
            }
            isRunning = 1;

            await myDialog.showDialog(doServerSync);

            isRunning = 0;
            return(0);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Encrypts a text to a picture and saves it
        /// </summary>
        /// <param name="openFilePath">Path from were the picture gets loaded</param>
        /// <param name="encryptText">The text which gets hidden in the picture</param>
        /// <param name="seed"></param>
        /// <param name="bits"></param>
        public async Task Encrypt(string openFilePath, string encryptText, int seed, int bits)
        {
            await WaitDialogHelper.ExecuteThreadAsync("Encrypt Message", () =>
            {
                string saveFilePath = RuntimeGlobals.ShowSaveFileDialog("PNG Image (*.png)|*.png", RuntimeGlobals.Settings.SavePath);

                if (string.IsNullOrEmpty(saveFilePath))
                {
                    return;
                }
                if (!InputOutput.CheckPathIsValidImage(saveFilePath))
                {
                    throw new FileFormatException();
                }
                if (saveFilePath.Equals(openFilePath))
                {
                    throw new FileLoadException();
                }

                var image = Interface.Encrypt((BitmapImage)ImageSource, ChannelUsage.Default, seed, encryptText);
                InputOutput.SaveImageToFile(saveFilePath, image);
                GC.Collect();
            }, exception =>
            {
                if (exception != null)
                {
                    if (exception is OutOfMemoryException)
                    {
                        ErrorHelper.Add(6, exception.Message, exception.StackTrace);
                    }
                    else if (exception is FileFormatException)
                    {
                        ErrorHelper.Add(4);
                    }
                    else if (exception is FileLoadException)
                    {
                        ErrorHelper.Add(5);
                    }
                    else
                    {
                        ErrorHelper.Add(3, exception.GetType() + "\n" + exception.Message, exception.StackTrace);
                    }
                }
            });
        }
Ejemplo n.º 4
0
        private async void ManualMode()
        {
            var f = IoC.Get <IWaitDialogFactory>();

            f.CreateInstance(out var window);

            var cancellationTokenSource = new CancellationTokenSource();

            window.StartWaitDialogWithCallback("Wait", "Wait", "Wait", string.Empty, true, 2, true, 0, 0,
                                               new PrivateCallback(cancellationTokenSource));
            await Task.Run(() => AsyncMethod2(WaitDialogHelper.CreateSession(window).Progress, cancellationTokenSource.Token), cancellationTokenSource.Token);

            window.EndWaitDialog(out var canceled);
            if (canceled)
            {
                MessageBox.Show("Canceled");
            }
        }
Ejemplo n.º 5
0
        public void ExportTxt()
        {
            string path = RuntimeGlobals.ShowSaveFileDialog("Text-File (*.txt)|*.txt", RuntimeGlobals.Settings.SavePath);

            if (!string.IsNullOrEmpty(path))
            {
                WaitDialogHelper.ExecuteThread("Save Text", () =>
                {
                    using (StreamWriter writer = new StreamWriter(path))
                    {
                        writer.Write(DecryptText);
                    }
                }, exception =>
                {
                    if (exception != null)
                    {
                        ErrorHelper.Add(3, exception.Message, exception.StackTrace);
                    }
                });
            }
        }