Example #1
0
        public bool WriteResult(ZipBlock block)
        {
            var byteLengthByte = BitConverter.GetBytes(block.ActualLength);

            var shardNumberByte = BitConverter.GetBytes(block.Number);

            lock (writeSync)
            {
                try
                {
                    destStream.Write(byteLengthByte, 0, 4);

                    destStream.Write(shardNumberByte, 0, 4);

                    destStream.Write(block.Data, 0, block.ActualLength);
                }
                catch (IOException ex)
                {
                    isCanceled = true;
                    Console.WriteLine($"{Thread.CurrentThread.Name}: Not enough free space to write result");
                    Cancel.Invoke(this, EventArgs.Empty);
                    return(false);
                }
            }
            return(true);
        }
 private void OnCancel(EventArgs e)
 {
     if (Cancel != null)
     {
         Cancel.Invoke(this, e);
     }
     // Cancel?.Invoke(this, e);
 }
        protected async Task CancelAsync(bool isNewActivity = false)
        {
            if (Activity.ActivityId == 0 || isNewActivity)
            {
                if (isNewActivity)
                {
                    await RefreshListAsync();
                }

                await Cancel.Invoke();
            }
            else
            {
                await IsEditingChanged.InvokeAsync(false);

                await RefreshListAsync();
            }
        }
Example #4
0
        // Overridden so that an event is fired on close based on the confirmation state
        protected override void Close()
        {
            base.Close();

            if (_confirmed)
            {
                if (Confirm != null)
                {
                    Confirm.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                if (Cancel != null)
                {
                    Cancel.Invoke(this, EventArgs.Empty);
                }
            }
        }
Example #5
0
 private void textBox_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if ((e.Key == Key.B) && (YesBind != null))
     {
         YesBind.Invoke(this, new EventArgs());
     }
     else if ((e.Key == Key.Y) && (Yes != null))
     {
         Yes.Invoke(this, new EventArgs());
     }
     else if (((e.Key == Key.N) || (e.Key == Key.Enter) || (e.Key == Key.Space)) && (No != null))
     {
         No.Invoke(this, new EventArgs());
     }
     else if ((e.Key == Key.Escape) && (Cancel != null))
     {
         Cancel.Invoke(this, new EventArgs());
     }
     e.Handled = true;
 }
 private void CancelBtn_Click(object sender, RoutedEventArgs e)
 {
     Cancel?.Invoke(this, EventArgs.Empty);
 }
Example #7
0
 protected void btnCancel_Click(object sender, EventArgs e)
 {
     Cancel?.Invoke(sender, e);
 }
Example #8
0
 public async Task ExecuteCancelCommand()
 {
     Cancel?.Invoke(null, new EventArgs());
 }
 void OnCancelClicked()
 {
     Cancel?.Invoke();
 }
Example #10
0
        public void Download()
        {
            using (var Document = new ExcelDocument(XLSXPath))
            {
                Document.ColumnRow        = CRR;
                Document.ImageColumnWidth = ICWR;

                Downloading = "";
                Progress    = 0;

                int total_rows    = Document.RowCount;
                int total_columns = Document.ColumnCount;

                List <int> column_indexes = new List <int>();
                for (int i = 0; i < total_columns; i++)
                {
                    if (Columns.Contains(Document[i, 0]))
                    {
                        column_indexes.Add(i);
                    }
                }

                int total_images  = total_rows * column_indexes.Count;
                int current_count = 0;

                for (int y = 1; y < total_rows; y++)
                {
                    foreach (int x in column_indexes)
                    {
                        string url = Document[x, y];
                        if (url.Length > 0)
                        {
                            url         = Prefix + url;
                            Downloading = url;
                            ProgressChanged?.Invoke(this, EventArgs.Empty);

                            string image_path = Path.GetFullPath("image_buffer" + Path.GetExtension(url));
                            if (SaveImage(url, image_path))
                            {
                                Document.AddImage(x, y, image_path);
                                Document[x, y] = "";
                            }
                        }

                        current_count++;
                        int progress = current_count * 100 / total_images;
                        if (progress > Progress)
                        {
                            Progress = progress;
                            ProgressChanged?.Invoke(this, EventArgs.Empty);
                        }

                        var event_args = new CancelEventArgs();
                        Cancel?.Invoke(this, event_args);
                        if (event_args.Cancel)
                        {
                            Document.Save();
                            return;
                        }
                    }
                }

                Document.Save();
            }
        }
Example #11
0
 private void Canceled()
 {
     Cancel?.Invoke();
 }
 internal void FireCancelEvent() => Cancel?.Invoke(this, EventArgs.Empty);
Example #13
0
 private void OnCancel(Int32 index, Int32 begin, Int32 length)
 {
     Cancel?.Invoke(this, index, begin, length);
 }
Example #14
0
 private void btn_Cancel_Click(object o, EventArgs e)
 {
     Cancel?.Invoke();
 }
Example #15
0
 private void SpawnUnit_Cancel(object sender, EventArgs args)
 {
     Cancel?.Invoke(this, null);
     Destroy();
 }
Example #16
0
 private void OnCancelButtonPointerUp()
 {
     Cancel?.Invoke();
 }
Example #17
0
 protected void OnCancel(EventArgs e)
 {
     Cancel?.Invoke(this, e);
 }
Example #18
0
 private void CancelButton_Click(object sender, RoutedEventArgs e)
 {
     Cancel?.Invoke(this, e);
 }
Example #19
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnCancel
 ///
 /// <summary>
 /// Cancel イベントを発生させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected virtual void OnCancel(EventArgs e) => Cancel?.Invoke(this, e);
Example #20
0
 private void CacelButton_Click(object sender, EventArgs e)
 {
     Cancel?.Invoke(sender, e);
 }
Example #21
0
 /// <summary>Raises the <see cref="Cancel" /> event</summary>
 protected virtual void OnCancel(SvnCancelEventArgs e)
 {
     Cancel?.Invoke(this, e);
 }
        /// <summary>
        /// Fires the Cancel event.
        /// </summary>
        /// <param name="sender">The source object.</param>
        /// <param name="e">The event data.</param>
        private void OnCancel(object?sender, RoutedEventArgs e)
        {
            Cancel?.Invoke(sender, e);

            AfterAdapterAction();
        }
Example #23
0
        protected async Task CheckPasswordAsync()
        {
            if (string.IsNullOrWhiteSpace(MasterPasswordCell.TextField.Text))
            {
                var alert = Dialogs.CreateAlert(AppResources.AnErrorHasOccurred,
                                                string.Format(AppResources.ValidationFieldRequired,
                                                              _pinLock ? AppResources.PIN : AppResources.MasterPassword),
                                                AppResources.Ok);
                PresentViewController(alert, true, null);
                return;
            }

            var email = await _userService.GetEmailAsync();

            var kdf = await _userService.GetKdfAsync();

            var kdfIterations = await _userService.GetKdfIterationsAsync();

            var inputtedValue = MasterPasswordCell.TextField.Text;

            if (_pinLock)
            {
                var failed = true;
                try
                {
                    if (_pinSet.Item1)
                    {
                        var key = await _cryptoService.MakeKeyFromPinAsync(inputtedValue, email,
                                                                           kdf.GetValueOrDefault(KdfType.PBKDF2_SHA256), kdfIterations.GetValueOrDefault(5000),
                                                                           _vaultTimeoutService.PinProtectedKey);

                        var encKey = await _cryptoService.GetEncKeyAsync(key);

                        var protectedPin = await _storageService.GetAsync <string>(Bit.Core.Constants.ProtectedPin);

                        var decPin = await _cryptoService.DecryptToUtf8Async(new EncString(protectedPin), encKey);

                        failed = decPin != inputtedValue;
                        if (!failed)
                        {
                            await SetKeyAndContinueAsync(key);
                        }
                    }
                    else
                    {
                        var key2 = await _cryptoService.MakeKeyFromPinAsync(inputtedValue, email,
                                                                            kdf.GetValueOrDefault(KdfType.PBKDF2_SHA256), kdfIterations.GetValueOrDefault(5000));

                        failed = false;
                        await SetKeyAndContinueAsync(key2);
                    }
                }
                catch
                {
                    failed = true;
                }
                if (failed)
                {
                    _invalidPinAttempts++;
                    if (_invalidPinAttempts >= 5)
                    {
                        Cancel?.Invoke();
                        return;
                    }
                    InvalidValue();
                }
            }
            else
            {
                var key2 = await _cryptoService.MakeKeyAsync(inputtedValue, email, kdf, kdfIterations);

                var keyHash = await _cryptoService.HashPasswordAsync(inputtedValue, key2);

                var storedKeyHash = await _cryptoService.GetKeyHashAsync();

                if (storedKeyHash == null)
                {
                    var oldKey = await _secureStorageService.GetAsync <string>("oldKey");

                    if (key2.KeyB64 == oldKey)
                    {
                        await _secureStorageService.RemoveAsync("oldKey");

                        await _cryptoService.SetKeyHashAsync(keyHash);

                        storedKeyHash = keyHash;
                    }
                }
                if (storedKeyHash != null && keyHash != null && storedKeyHash == keyHash)
                {
                    if (_pinSet.Item1)
                    {
                        var protectedPin = await _storageService.GetAsync <string>(Bit.Core.Constants.ProtectedPin);

                        var encKey = await _cryptoService.GetEncKeyAsync(key2);

                        var decPin = await _cryptoService.DecryptToUtf8Async(new EncString(protectedPin), encKey);

                        var pinKey = await _cryptoService.MakePinKeyAysnc(decPin, email,
                                                                          kdf.GetValueOrDefault(KdfType.PBKDF2_SHA256), kdfIterations.GetValueOrDefault(5000));

                        _vaultTimeoutService.PinProtectedKey = await _cryptoService.EncryptAsync(key2.Key, pinKey);
                    }
                    await SetKeyAndContinueAsync(key2);

                    // Re-enable biometrics
                    if (_biometricLock & !_biometricIntegrityValid)
                    {
                        await _biometricService.SetupBiometricAsync(BiometricIntegrityKey);
                    }
                }
                else
                {
                    InvalidValue();
                }
            }
        }
 /// <summary>
 /// Button_Cancel_Click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Cancel_Click(object sender, RoutedEventArgs e)
 {
     Cancel?.Invoke(null, null);
 }
Example #25
0
 /// <summary>
 /// Called when the user presses cancel. If eventArgs.Cancel is set to true, this
 /// will cancel the cancellation and prevent OnExit from being called.
 /// </summary>
 /// <param name="eventArgs"></param>
 protected virtual void OnCancel(CancelEventArgs eventArgs)
 {
     Cancel?.Invoke(eventArgs);
 }
Example #26
0
 private void CancelProgramItem(object sender, RoutedEventArgs e)
 {
     Cancel?.Invoke(this, new EventArgs());
 }
Example #27
0
 private void BtnCancel_Click(object sender, EventArgs e)
 {
     Cancel?.Invoke(sender, e);
 }
Example #28
0
 private void CancelClick()
 {
     View.Hide();
     Cancel?.Invoke();
 }
 private void OnCancel(EventArgs e)
 {
     Cancel?.Invoke(this, e);
 }
Example #30
0
 void OnCancelClicked (object sender, RoutedEventArgs e)
 {
   if (sender is Button button) {
     Cancel?.Invoke (this, EventArgs.Empty);
   }
 }