C# (CSharp) CancelEventArgs примеры использования

C# (CSharp) CancelEventArgs - 30 примеров найдено. Это лучшие примеры C# (CSharp) кода для CancelEventArgs, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
Основные методы
Пример #1
0
 private void ctxObjects_Opening(object sender, CancelEventArgs e)
 {
   if (this.viewer == null)
   {
     e.Cancel = true;
   }
   else
   {
     switch (this.listView.SelectedIndices.Count)
     {
       case 0:
         this.ctxObjects_Add.Enabled = true;
         this.ctxObjects_Edit.Enabled = false;
         this.ctxObjects_Delete.Enabled = false;
         break;
       case 1:
         this.ctxObjects_Add.Enabled = true;
         this.ctxObjects_Edit.Enabled = true;
         this.ctxObjects_Delete.Enabled = true;
         break;
       default:
         this.ctxObjects_Add.Enabled = true;
         this.ctxObjects_Edit.Enabled = false;
         this.ctxObjects_Delete.Enabled = true;
         break;
     }
   }
 }
Пример #2
0
        // Closing
        private void mainWindow_Closing(object sender, CancelEventArgs e)
        {
            // If the document needs to be saved
            if (_needsToBeSaved)
            {
                // Configure the message box
                var messageBoxText =
                    "This document needs to be saved. Click Yes to save and exit, No to exit without saving, or Cancel to not exit.";
                var caption = "Word Processor";
                var button = MessageBoxButton.YesNoCancel;
                var icon = MessageBoxImage.Warning;

                // Display message box
                var messageBoxResult = MessageBox.Show(messageBoxText, caption, button, icon);

                // Process message box results
                switch (messageBoxResult)
                {
                    case MessageBoxResult.Yes: // Save document and exit
                        SaveDocument();
                        break;
                    case MessageBoxResult.No: // Exit without saving
                        break;
                    case MessageBoxResult.Cancel: // Don't exit
                        e.Cancel = true;
                        break;
                }
            }
        }
Пример #3
0
 protected override void OnClosing(CancelEventArgs e)
 {
     string json = _jsonSerializer.Serialize(_storageAccountConnections);
     File.WriteAllText(SettingsFilePath, json);
     _deploymentConfigFileWatcher.Dispose();
     base.OnClosing(e);
 }
Пример #4
0
        private void ValidateTextBox( object sender, CancelEventArgs e )
        {
            bool nameValid = true, passwordValid = true;

              if (String.IsNullOrEmpty(((TextBox)sender).Text))
              {
            switch (Convert.ToByte(((TextBox)sender).Tag))
            {
              case 0:
            errorProvider1.SetError(tbName, "Please, enter your name");
            nameValid = false;
            break;
              case 1:
            errorProvider1.SetError(tbPassword, "Please, enter your password");
            passwordValid = false;
            break;
            }
              }
              else
              {
            switch (Convert.ToByte(((TextBox)sender).Tag))
            {
              case 0:
            errorProvider1.SetError(tbName, "");
            break;
              case 1: errorProvider1.SetError(tbPassword, "");
            break;
            }
              }
              _validForm = nameValid && passwordValid;
        }
Пример #5
0
 private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
 {
     string linija = "";
     int broj = 0;
     bool ide = true;
     try
     {
         using (StreamReader sr = new StreamReader(openFileDialog1.FileName))
         {
             while (ide)
             {
                 linija = sr.ReadLine();
                 if (linija == null) ide = false;
                 string prezime = linija.Split(',')[0];
                 string ime = linija.Split(',')[1];
                 broj++;
                 Igrac igrac_za_unos = new Igrac(ime, prezime);
                 Igrac_GA igrac_za_unos_GA = new Igrac_GA();
                 igrac_za_unos_GA.Daj_Ime_i_prezime = ime + " " + prezime;
                 lista_za_upis.Add(igrac_za_unos);
                 lista_Za_upis_GA.Add(igrac_za_unos_GA);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("The file could not be read:");
         Console.WriteLine(ex.Message);
     }
     foreach (Igrac i in lista_za_upis)
     {
         richTextBox1.Text += lista_za_upis.IndexOf(i) + ". " + i + " \n";
     }
 }
Пример #6
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            //Settings Save
            Settings.Default.gpxLastSummary = chExportSummary.Checked;
            Settings.Default.gpxLastComprehensive = chExportComp.Checked;
            Settings.Default.gpxLastEachAp = chExportEachAp.Checked;

            Settings.Default.gpxLastOrganizeEThenC = cmbOrganize.SelectedIndex == 0;

            Settings.Default.gpxLastRssiLabels = chShowRssiMarkers.Checked;

            Settings.Default.gpxLastGpsLockedup = chGPSLockup.Checked;
            Settings.Default.gpxLastGpsFixLost = chGPSFixLost.Checked;
            Settings.Default.gpxLastMinimumSatsEnabled = chGPSsatCount.Checked;
            Settings.Default.gpxLastMinimumStas = (int)numSatCount.Value;

            Settings.Default.gpxLastMaxSpeedEnabled = chMaxSpeed.Checked;
            Settings.Default.gpxLastMaxSpeed = (int)numMaxSpeed.Value;

            Settings.Default.gpxLastMaxRssiEnabled = chMaxSignal.Checked;
            Settings.Default.gpxLastMaxRssi = (int)numMaxSignal.Value;

            //Save input file(s)
            //(Settings.Default.gpxLastInputFiles ?? (Settings.Default.gpxLastInputFiles = new StringCollection())).AddRange(openFile.FileNames);
            if (_inFiles != null)
            {
                (Settings.Default.gpxLastInputFiles = new StringCollection()).AddRange(_inFiles);
            }

            Settings.Default.gpxLastOutputDir = txtOutDir.Text;
        }
		protected override void OnClosing(CancelEventArgs e)
		{
			if (_token != null)
			{
				if (Sync.IsEnabled)
				{
					var result =
						new MessageBoxBuilder()
							.Text(LocalizedStrings.Str2928)
							.Error()
							.YesNo()
							.Owner(this)
							.Show();

					if (result == MessageBoxResult.Yes)
					{
						StopSync();
					}
				}

				e.Cancel = true;
			}

			base.OnClosing(e);
		}
Пример #8
0
		protected override void OnClosing(CancelEventArgs e)
		{
			if (_connector != null)
				_connector.Dispose();

			base.OnClosing(e);
		}
Пример #9
0
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            base.OnBackKeyPress(e);

            if (!e.Cancel && !ConfirmNavigateAway())
                e.Cancel = true;
        }
Пример #10
0
 protected override void OnClosing(CancelEventArgs e)
 {
     App.MainController.Logout(() =>
     {
         base.OnClosing(e);
     });
 }
Пример #11
0
        private void openKeyFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            BIFTreeView.Nodes.Clear();

            try
            {

                pathContext = Path.GetDirectoryName(openKeyFileDialog.FileName) + "\\";
                String modName = Path.GetFileName(openKeyFileDialog.FileName);
                BIF_KEY tannen = new BIF_KEY(pathContext + modName);

                foreach (BIF_FILETABLE_ENTRY file in tannen.FILETABLE)
                {
                    TreeNode BIFLevelNode = new TreeNode(file.BIFName);

                    foreach (BIF_KEYTABLE_ENTRY key in file.ownedResources)
                    {
                        TreeNode ResourceLevelNode = new TreeNode(BIF_Utility.makeNewResName(key.ResourceName, key.ResourceType));
                        ResourceLevelNode.Tag = key;
                        BIFLevelNode.Nodes.Add(ResourceLevelNode);
                    }
                    BIFTreeView.Nodes.Add(BIFLevelNode);
                }
            }
            catch (FileNotFoundException ee)
            {
                MessageBox.Show("There was a problem reading the BIF index (KEY) file: \r\n"
                    + ee.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #12
0
	private void HistoricViewer_OnClosing (object Sender, CancelEventArgs E)
		{
		foreach (ResultViewer OpenResult in ListOfOpenResultViewer)
			{
			OpenResult.DoFinalClose ();
			}
		}
Пример #13
0
 protected override void OnClosing( CancelEventArgs e )
 {
     if ( !e.Cancel ) {
     CommandRunner.Instance.TopProcessKill ( );
       }
       base.OnClosing ( e );
 }
 protected override void OnClosing(CancelEventArgs e)
 {
     e.Cancel = !_DoClose;
     base.OnClosing(e);
     Program.Status.VideoScreenVisible = false;
     Hide();
 }
 private void Window_OnClosing(object sender, CancelEventArgs e)
 {
     var vm = (FocusTrackerToolWindowViewModel)this.DataContext;
     vm.Remove();
     //((ToolWindow)sender).Hide();
     //e.Cancel = true;
 }
Пример #16
0
 protected override void OnTerminating(CancelEventArgs e)
 {
     base.OnTerminating (e);
     var form = this.MainForm as MainForm;
     if (!form.PromptSave ())
         e.Cancel = true;
 }
        protected override void OnFilterExpressionBuilding(object sender, CancelEventArgs e)
        {
            if (mLastClickedButton == null) return;
            string ColName = this.DataGridViewColumn.DataPropertyName;
            string btnText = mLastClickedButton.Text;
            FilterCaption = OriginalDataGridViewColumnHeaderText + "\n = " + btnText;

            switch (btnText) {
                case "A...D":
                    FilterExpression = "(" + ColName + ">='A' AND "+ColName+"<='DZ')";
                    break;
                case "E...H":
                    FilterExpression = "(" + ColName + ">='E' AND " + ColName + "<='HZ')";
                    break;
                case "I...L":
                    FilterExpression = "(" + ColName + ">='I' AND " + ColName + "<='LZ')";
                    break;
                case "M...P":
                    FilterExpression = "(" + ColName + ">='M' AND " + ColName + "<='PZ')";
                    break;
                case "Q...T":
                    FilterExpression = "(" + ColName + ">='Q' AND " + ColName + "<='TZ')";
                    break;
                case "U...Z":
                    FilterExpression = "(" + ColName + ">='U' AND " + ColName + "<='ZZ')";
                    break;
            }
            Active = true;
            //Apply the filter immediately
            FilterManager.RebuildFilter();
        }
Пример #18
0
 protected override void OnClosing(CancelEventArgs e)
 {
     if (m_vm != null)
     {
         AlphaClient.Instance.Release(m_vm);
     }
 }
        private void maskedTextBoxDateFin_Validating(object sender, CancelEventArgs e)
        {


            if (DateTime.TryParse(maskedTextBoxDateFin.Text, out dateFin))
            {

                errorProviderDateFin.SetError(maskedTextBoxDateFin, string.Empty);
                if (dateFin <= dateDebut)
                {
                    dateIsOk = false;
                    errorProviderDateFin.SetError(maskedTextBoxDateFin, "Attention la date saisie se situe avant la date de début");
                    maskedTextBoxDateFin.Focus();

                }
                else
                {
                    dateIsOk = true;
                    errorProviderDateFin.SetError(maskedTextBoxDateFin, string.Empty);
                }
            }
            else
            {
                dateIsOk = false;
                errorProviderDateFin.SetError(maskedTextBoxDateFin, " Veuillez entrer une date au format valide");
            }

        }
Пример #20
0
        private void contextMenu_Opening(object sender, CancelEventArgs e)
        {
            if (_currentItem == null)
            {
                //e.Cancel = true;
                return;
            }

            for (int i = _contextMenu.Items.Count - 1; i >= 0; i--)
            {
                if (_contextMenu.Items[i] is ToolStripSeparator)
                    break;
                _contextMenu.Items.RemoveAt(i);
            }

            if (_currentItem != null && _currentItem.Tag is IssueItemView)
            {
                IssueItemView issue = (IssueItemView)_currentItem.Tag;
                foreach (IIssueAction action in issue.GetActions())
                {
                    ActionMenuItem menu = new ActionMenuItem(issue, action);
                    menu.Click += new EventHandler(RefreshContents);
                    _contextMenu.Items.Add(menu);
                }
            }
        }
Пример #21
0
 private void tbWord_Validating(object sender, CancelEventArgs e)
 {
     if (tbWord.Text.Trim().Length == 0)
     {
         errorProvider1.SetError(tbWord, "Внесете збор!");
     }
 }
Пример #22
0
 private void CasparCGPortTextBox_Validating(object sender, CancelEventArgs e)
 {
     if (!System.Text.RegularExpressions.Regex.Match(CasparCGPortTextBox.Text, @"^\d+$").Success) {
         MessageBox.Show("Please enter a valid port. Default is 5250", "Invalid port", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         e.Cancel = true;
     }
 }
Пример #23
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            if (DialogResult == DialogResult.OK)
                HandleEvent(ApplyFilterChanges);
        }
Пример #24
0
		public bool FireValidating()
		{
			CancelEventArgs cancelEventArgs = new CancelEventArgs();
			this.OnValidating(cancelEventArgs);

			return cancelEventArgs.Cancel;
		}
Пример #25
0
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     if(_timer != null && _timer.Enabled == true)
     {
         _timer.Enabled = false;
     }
 }
Пример #26
0
 private void UserAppointUrlText_Validating(object sender, CancelEventArgs e)
 {
     if (!UserAppointUrlText.Text.StartsWith("http") && !string.IsNullOrEmpty(UserAppointUrlText.Text))
     {
         MessageBox.Show("Text Error:正しいURLではありません");
     }
 }
Пример #27
0
        protected override void OnClosing(CancelEventArgs e)
        {
            this.Control.Session.StateChanged -= new EventHandler<EventArgs>(Session_StateChanged);

            var state = App.Settings.Current.Windows.States[this.Control.Context.Key];

            if (this.Control.Parent != null)
            {
                if (this.Control.IsConnected && this.Control.IsChannel)
                {
                    this.Control.Session.Part(this.Control.Target.Name);
                }
                state.IsDetached = true;
                this.Control.Dispose();
            }
            else
            {
                state.IsDetached = false;
                var window = App.Current.MainWindow as ChatWindow;
                if (window != null)
                {
                    window.Attach(this.Control);
                }
            }
            state.Placement = Interop.WindowHelper.Save(this);
        }
Пример #28
0
        private void PageSuccess_SetActive(object sender, CancelEventArgs e)
        {
            try
            {
                SetWizardButtons(Wizard.UI.WizardButtons.Finish);

                if (m_wiz.CreateOp != null)
                {
                    lblOp.Text = "Teambox creation:";
                    lblExplanation.Text =
                        "Congratulations! Your Teambox has been successfully created." + Environment.NewLine +
                        "Please press on Finish to go back to your Teambox manager.";
                }

                else
                {
                    lblOp.Text = "Teambox invitation:";
                    lblExplanation.Text =
                        "Congratulations! Your invitations have been successfully processed. " +
                        "Your recipients will receive an email in their inbox in the next minutes." +
                        Environment.NewLine +
                        "Please press on Finish to go back to your Teambox manager.";
                }
            }
            catch (Exception ex)
            {
                Base.HandleException(ex);
            }
        }
Пример #29
0
        private void SizeValidation(object sender, CancelEventArgs e)
        {
            if (!(sender is TextBox)) { return; }

            Regex sizeReg = new Regex(@"^\d{1,4}$");
            string errorMessage = "Некорректный размер изображения";
            TextBox currentTextBox = sender as TextBox;

            if (!sizeReg.IsMatch(currentTextBox.Text))
            {
                this.errorProvider1.SetError(currentTextBox, errorMessage);
                this.isValid = false;
            }
            else
            {
                this.isValid = true;
                this.errorProvider1.SetError(currentTextBox, "");
                switch (currentTextBox.Name)
                {
                    case "tb_width":
                        this.ImageWidth = Int32.Parse(this.tb_width.Text);
                        break;
                    case "tb_heigth":
                        this.ImageHeight = Int32.Parse(this.tb_heigth.Text);
                        break;
                    default:
                        break;
                }
            }
        }
Пример #30
0
 protected override void OnClosing(CancelEventArgs e) {
   base.OnClosing(e);
   if (MainFormManager.MainForm.Views.OfType<IContentView>().Any(v => v.Content is IStorableContent)) {
     if (MessageBox.Show(this, "Some views are still opened. If their content has not been saved, it will be lost after closing. Do you really want to close HeuristicLab Optimizer?", "Close Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
       e.Cancel = true;
   }
 }