コード例 #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);
        }
コード例 #2
0
 private void OnCancel(EventArgs e)
 {
     if (Cancel != null)
     {
         Cancel.Invoke(this, e);
     }
     // Cancel?.Invoke(this, e);
 }
コード例 #3
0
        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();
            }
        }
コード例 #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);
                }
            }
        }
コード例 #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;
 }
コード例 #6
0
 private void CancelBtn_Click(object sender, RoutedEventArgs e)
 {
     Cancel?.Invoke(this, EventArgs.Empty);
 }
コード例 #7
0
 protected void btnCancel_Click(object sender, EventArgs e)
 {
     Cancel?.Invoke(sender, e);
 }
コード例 #8
0
 public async Task ExecuteCancelCommand()
 {
     Cancel?.Invoke(null, new EventArgs());
 }
コード例 #9
0
 void OnCancelClicked()
 {
     Cancel?.Invoke();
 }
コード例 #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();
            }
        }
コード例 #11
0
ファイル: MainViewModel.cs プロジェクト: roman-belfer/VGA
 private void Canceled()
 {
     Cancel?.Invoke();
 }
コード例 #12
0
 internal void FireCancelEvent() => Cancel?.Invoke(this, EventArgs.Empty);
コード例 #13
0
 private void OnCancel(Int32 index, Int32 begin, Int32 length)
 {
     Cancel?.Invoke(this, index, begin, length);
 }
コード例 #14
0
 private void btn_Cancel_Click(object o, EventArgs e)
 {
     Cancel?.Invoke();
 }
コード例 #15
0
ファイル: SpawnUnit.cs プロジェクト: fire-eggs/CivOne
 private void SpawnUnit_Cancel(object sender, EventArgs args)
 {
     Cancel?.Invoke(this, null);
     Destroy();
 }
コード例 #16
0
 private void OnCancelButtonPointerUp()
 {
     Cancel?.Invoke();
 }
コード例 #17
0
 protected void OnCancel(EventArgs e)
 {
     Cancel?.Invoke(this, e);
 }
コード例 #18
0
 private void CancelButton_Click(object sender, RoutedEventArgs e)
 {
     Cancel?.Invoke(this, e);
 }
コード例 #19
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnCancel
 ///
 /// <summary>
 /// Cancel イベントを発生させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected virtual void OnCancel(EventArgs e) => Cancel?.Invoke(this, e);
コード例 #20
0
ファイル: RegistrationView.cs プロジェクト: TIN2539/UserList
 private void CacelButton_Click(object sender, EventArgs e)
 {
     Cancel?.Invoke(sender, e);
 }
コード例 #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();
        }
コード例 #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();
                }
            }
        }
コード例 #24
0
 /// <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);
 }
コード例 #25
0
ファイル: Menu.cs プロジェクト: eylvisaker/AgateLib.Tester
 /// <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);
 }
コード例 #26
0
 private void CancelProgramItem(object sender, RoutedEventArgs e)
 {
     Cancel?.Invoke(this, new EventArgs());
 }
コード例 #27
0
 private void BtnCancel_Click(object sender, EventArgs e)
 {
     Cancel?.Invoke(sender, e);
 }
コード例 #28
0
 private void CancelClick()
 {
     View.Hide();
     Cancel?.Invoke();
 }
コード例 #29
0
 private void OnCancel(EventArgs e)
 {
     Cancel?.Invoke(this, e);
 }
コード例 #30
0
ファイル: ApplyCommand.cs プロジェクト: robjuca/Blood
 void OnCancelClicked (object sender, RoutedEventArgs e)
 {
   if (sender is Button button) {
     Cancel?.Invoke (this, EventArgs.Empty);
   }
 }