Exemplo n.º 1
0
		public void CurrentChangingEventArgsConstructor1Test()
		{
			CurrentChangingEventArgs args = new CurrentChangingEventArgs ();

			Assert.IsFalse (args.Cancel, "CTOR1_#1");
			Assert.IsTrue (args.IsCancelable, "CTOR1_#2");
		}
 private async void OnCurrentSpeakerChanging(object sender, CurrentChangingEventArgs e)
 {
     if (await this.SaveChangesAsync() == false && e.IsCancelable)
     {
         e.Cancel = true;
     }
 }
 private void OnCurrentChanging(object sender, SCM.CurrentChangingEventArgs args)
 {
     SCM.CurrentChangingEventHandler currentChangingEventHandler = this.CurrentChanging;
     if (currentChangingEventHandler != null)
     {
         currentChangingEventHandler(this, args);
     }
 }
 void Items_CurrentChanging(object sender, CurrentChangingEventArgs e)
 {
     if (!e.IsCancelable)
     {
         return;
     }
     Validate();
 }
Exemplo n.º 5
0
		public void ChangeCancelIfNotCancelableTest()
		{
			CurrentChangingEventArgs args = new CurrentChangingEventArgs (false);

			Assert.IsFalse (args.Cancel, "InvOp_#1");
			Assert.IsFalse (args.IsCancelable, "InvOp_#2");

			args.Cancel = true;
		}
 void Items_CurrentChanging(object sender, CurrentChangingEventArgs e)
 {
     if (!e.IsCancelable)
     {
         return;
     }
     if (Validate())
     {
         return;
     }
     e.Cancel = true;
     tabControl.SelectedItem = ((ICollectionView)sender).CurrentItem;
 }
Exemplo n.º 7
0
		public void CurrentChangingEventArgsConstructor2Test()
		{
			CurrentChangingEventArgs args = new CurrentChangingEventArgs (false);

			Assert.IsFalse (args.Cancel, "CTOR2_#1");
			Assert.IsFalse (args.IsCancelable, "CTOR2_#2");

			args = new CurrentChangingEventArgs (true);

			Assert.IsFalse (args.Cancel, "CTOR1_#3");
			Assert.IsTrue (args.IsCancelable, "CTOR1_#4");

			args.Cancel = true;

			Assert.IsTrue (args.Cancel, "CTOR1_#5");
		}
 protected virtual void OnCurrentChanging(SCM.CurrentChangingEventArgs args)
 {
     if (args == null)
     {
         throw new ArgumentNullException("args");
     }
     if (this.CurrentChangedMonitor.Busy)
     {
         if (!args.IsCancelable)
         {
             return;
         }
         args.Cancel = true;
     }
     else
     {
         if (this.CurrentChanging == null)
         {
             return;
         }
         this.CurrentChanging((object)this, args);
     }
 }
        /// <summary>
        /// Raises the CurrentChanging event
        /// </summary>
        /// <param name="args">
        ///     CancelEventArgs used by the consumer of the event.  args.Cancel will
        ///     be true after this call if the CurrentItem should not be changed for
        ///     any reason.
        /// </param>
        /// <exception cref="InvalidOperationException">
        ///     This CurrentChanging event cannot be canceled.
        /// </exception>
        private void OnCurrentChanging(CurrentChangingEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            if (this._currentChangedMonitor.Busy)
            {
                if (args.IsCancelable)
                {
                    args.Cancel = true;
                }

                return;
            }

            if (this.CurrentChanging != null)
            {
                this.CurrentChanging(this, args);
            }
        }
Exemplo n.º 10
0
 protected bool OKToChangeCurrent()
 {
     SCM.CurrentChangingEventArgs args = new SCM.CurrentChangingEventArgs();
     this.OnCurrentChanging(args);
     return(!args.Cancel);
 }
Exemplo n.º 11
0
        private void CollView_CurrentChanging(object sender, CurrentChangingEventArgs e)
        {
            if (_blockTabControlChanged)
            {
                int previousIndex = tabControl1.Items.IndexOf(tabControl1.SelectedContent);
                tabControl1.SelectedIndex = previousIndex;

                e.Cancel = true;
            }
        }
        internal void OnCurrentChanging(object sender, CurrentChangingEventArgs e)
        {
            if (TraceData.IsExtendedTraceEnabled(this, TraceDataLevel.Events))
            {
                TraceData.Trace(TraceEventType.Warning,
                                    TraceData.GotEvent(
                                        TraceData.Identify(this),
                                        "CurrentChanging",
                                        TraceData.Identify(sender)));
            }

            Update();
            // 
        }
 private async void OnCurrentSessionChanging(object sender, CurrentChangingEventArgs e)
 {
     if (this.IsBusy) return;
     // vorherige Session speichern
     if (await this.SaveChangesAsync() == false && e.IsCancelable)
         e.Cancel = true;
 }
        /// <summary>
        /// Delete view if not cached!
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">CurrentChangingEventArgs</param>
        private void ViewsCurrentChanging(object sender, CurrentChangingEventArgs e)
        {
            var viewViewModel = Views.CurrentItem as ViewViewModel;

            if (!CacheViews)
                viewViewModel.View = null;
        }
Exemplo n.º 15
0
        //
        //  Private Methods
        //

        // event handler for CurrentChanging event
        private void OnCurrentChanging(object sender, CurrentChangingEventArgs args)
        {
            DeliverEvent(sender, args);
        }
Exemplo n.º 16
0
 private void OnCurrentChanging(CurrentChangingEventArgs args)
 {
     if (args == null)
     {
         throw new ArgumentNullException("args");
     }
     if (this._currentChangedMonitor.Busy)
     {
         if (args.get_IsCancelable())
         {
             args.set_Cancel(true);
         }
     }
     else if (this.CurrentChanging != null)
     {
         this.CurrentChanging.Invoke(this, args);
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Raises the CurrentChanging event
        /// </summary>
        /// <param name="args">
        ///     CancelEventArgs used by the consumer of the event.  args.Cancel will
        ///     be true after this call if the CurrentItem should not be changed for
        ///     any reason.
        /// </param>
        /// <exception cref="InvalidOperationException">
        ///     This CurrentChanging event cannot be canceled.
        /// </exception>
        protected virtual void OnCurrentChanging(CurrentChangingEventArgs args)
        {
            if (args == null)
                throw new ArgumentNullException("args");

            if (_currentChangedMonitor.Busy)
            {
                if (args.IsCancelable)
                    args.Cancel = true;
                return;
            }

            if (CurrentChanging != null)
            {
                CurrentChanging(this, args);
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// ask listeners (via <seealso cref="ICollectionView.CurrentChanging"/> event) if it's OK to change currency
 /// </summary>
 /// <returns>false if a listener cancels the change, true otherwise</returns>
 protected bool OKToChangeCurrent()
 {
     CurrentChangingEventArgs args = new CurrentChangingEventArgs();
     OnCurrentChanging(args);
     return (!args.Cancel);
 }
Exemplo n.º 19
0
		protected virtual void OnCurrentChanging (CurrentChangingEventArgs args)
		{
			if (CurrentChanging != null)
				CurrentChanging (this, args);
		}
Exemplo n.º 20
0
		public virtual bool MoveCurrentToPosition (int position)
		{
			VerifyRefreshNotDeferred ();
			CurrentChangingEventArgs e;
			is_current_after_last = false;
			is_current_before_first = false;
			if (position < 0) {
				e = new CurrentChangingEventArgs ();
				OnCurrentChanging (e);
				if (e.Cancel)
					return true;
				current_position = -1;
				current_item = null;
				is_current_before_first = true;
				OnCurrentChanged ();
				return false;
			}
			current_position = 0;
			foreach (object item in source_collection) {
				if (current_position == position) {
					e = new CurrentChangingEventArgs ();
					OnCurrentChanging (e);
					if (e.Cancel)
						return true;
					current_item = item;
					OnCurrentChanged ();
					return true;
				}
				current_position++;
			}
			if (position <= current_position) {
				e = new CurrentChangingEventArgs ();
				OnCurrentChanging (e);
				if (e.Cancel)
					return true;
			}
			current_item = null;
			is_current_after_last = true;
			if (position > current_position)
				throw new ArgumentOutOfRangeException ("position");
			OnCurrentChanged ();
			return false;
		}
Exemplo n.º 21
0
        /// <summary>
        /// Handles the situation where the current item is changing on the ICollectionView.
        /// </summary>
        /// <param name="sender">The ICollectionView.</param>
        /// <param name="e">The event args.</param>
        private void OnCollectionViewCurrentChanging(object sender, CurrentChangingEventArgs e)
        {
            if (this.ShouldValidateOnCurrencyChange)
            {
                this.ValidateItem();
            }

            if (e.IsCancelable && (this.AutoCommitPreventsCurrentItemChange || !this.IsItemValid))
            {
                e.Cancel = true;
            }
        }
Exemplo n.º 22
0
        void _OnCurrentChanging(object sender, CurrentChangingEventArgs args)
        {
//             VerifyAccess();    // will throw an exception if caller is not in correct UiContext

            if (PrivateCurrentChanging != null)
                PrivateCurrentChanging(this, args);
        }
        /// <summary>
        /// Generates script when going to Script tab, and prevents returning to Transform tab without a confirmation to lose changes.
        /// </summary>
        private void Items_CurrentChanging(object sender, CurrentChangingEventArgs e) {
            if (string.IsNullOrEmpty(encodeSettings.FileName))
                return;

            SettingsTab.Focus();
            var item = ((ICollectionView)sender).CurrentItem;
            bool Cancel = false;
            // Generate script when going to Script tab.
            if (SettingsTab.SelectedIndex == 2 && string.IsNullOrEmpty(encodeSettings.CustomScript)) {
                if (Validate())
                    business.GenerateCustomScript(encodeSettings);
                else
                    Cancel = true;
            } else if (SettingsTab.SelectedIndex == 0 && !string.IsNullOrEmpty(encodeSettings.CustomScript)) {
                // Ask for confirmation before going back to Transform tab and losing changes.
                if (business.CustomScriptHasChanges(encodeSettings))
                    if (MessageBox.Show("You will lose any changes to your script. Are you sure?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No)
                        Cancel = true;
                if (!Cancel)
                    encodeSettings.CustomScript = null;
            }

            // Revert to previously-selected tab.
            if (Cancel) {
                e.Cancel = true;
                SettingsTab.SelectedItem = item;
            }
        }
 private void CollectionView_CurrentChanging(object sender, CurrentChangingEventArgs e)
 {
     if (this._owner.NoCurrentCellChangeCount == 0 &&
         !this._expectingCurrentChanged &&
         !this.CommittingEdit &&
         !this._owner.CommitEdit())
     {
         // If CommitEdit failed, then the user has most likely input invalid data.
         // We should cancel the current change if we can, otherwise we have to abort the edit.
         if (e.IsCancelable)
         {
             e.Cancel = true;
         }
         else
         {
             this._owner.CancelEdit(DataGridEditingUnit.Row, false);
         }
     }
 }
Exemplo n.º 25
0
 private void OnCurrentChanging(object sender, CurrentChangingEventArgs args)
 {
     if (this.ignoreEventsLevel != 0)
     {
         return;
     }
     this.OnCurrentChanging(args);
 }
 private void ActiveFilesView_CurrentChanging(object sender, CurrentChangingEventArgs e)
 {
 }
Exemplo n.º 27
0
        void _OnCurrentChanging(object sender, CurrentChangingEventArgs args)
        {
            if (_ignoreEventsLevel != 0)
                return; 

            OnCurrentChanging(); 
        } 
Exemplo n.º 28
0
		bool MoveCurrentTo (int position, bool force)
		{
			object newItem = ItemAtIndex (position);
			bool raiseEvents = force || CurrentItem != newItem;

			if (raiseEvents) {
				CurrentChangingEventArgs e = new CurrentChangingEventArgs (true);
				RaiseCurrentChanging (e);
				if (e.Cancel)
					return true;
			}

			IsCurrentAfterLast = position == ActiveList.Count || ActiveList.Count == 0;
			IsCurrentBeforeFirst = position == -1 || ActiveList.Count == 0;
			UpdateCurrentPositionAndItem (position, newItem);

			if (raiseEvents)
				RaiseCurrentChanged (EventArgs.Empty);

			return IsValidSelection;
		}
Exemplo n.º 29
0
        /// <summary>
        /// Handles the event which occurs when the selected item is about to change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CollectionViewCurrentChanging(object sender, CurrentChangingEventArgs e)
        {
            CollectionView collectionView = (CollectionView)sender;

            if (collectionView != null && collectionView.CurrentPosition >= 0 && collectionView.CurrentPosition <= piePieces.Count)
            {
                PiePiece piece = piePieces[collectionView.CurrentPosition];

                DoubleAnimation a = new DoubleAnimation();
                a.To = 0;
                a.Duration = new Duration(TimeSpan.FromMilliseconds(200));

                piece.BeginAnimation(PiePiece.PushOutProperty, a);
            }
        }
        //
        //  Private Methods 
        //

        // event handler for CurrentChanging event
        private void OnCurrentChanging(object sender, CurrentChangingEventArgs args) 
        {
            DeliverEvent(sender, args); 
        } 
Exemplo n.º 31
0
 private void ItemsCollectionView_CurrentChanging(object sender, System.ComponentModel.CurrentChangingEventArgs e)
 {
     ModifiedRequest();
 }
    private bool SetCurrentItem( int newCurrentPosition, object newCurrentItem, bool isCancelable, bool beforeDeleteOperation )
    {
      object oldCurrentItem = this.CurrentItem;
      int oldCurrentPosition = this.CurrentPosition;
      bool oldIsCurrentBeforeFirst = this.IsCurrentBeforeFirst;
      bool oldIsCurrentAfterLast = this.IsCurrentAfterLast;

      if( ( !object.Equals( oldCurrentItem, newCurrentItem ) ) || ( oldCurrentPosition != newCurrentPosition ) )
      {
        // We raise the changing event even if we are in DeferCurrencyEvent
        CurrentChangingEventArgs currentChangingEventArgs = new CurrentChangingEventArgs( isCancelable );
        this.OnCurrentChanging( currentChangingEventArgs );

        if( ( !currentChangingEventArgs.Cancel ) || ( !currentChangingEventArgs.IsCancelable ) )
        {
          int count = this.Count;

          if( beforeDeleteOperation )
          {
            Debug.Assert( count > 0 );
            count--;
          }

          bool isCurrentBeforeFirst;
          bool isCurrentAfterLast;

          if( count == 0 )
          {
            isCurrentBeforeFirst = true;
            isCurrentAfterLast = true;
          }
          else
          {
            isCurrentBeforeFirst = newCurrentPosition < 0;
            isCurrentAfterLast = newCurrentPosition >= count;
          }

#if DEBUG
          if( newCurrentItem == null )
            Debug.Assert( ( newCurrentPosition == -1 ) || ( newCurrentPosition >= ( count - 1 ) ) );
#endif

          this.SetCurrentItemAndPositionCore(
            newCurrentItem, newCurrentPosition, isCurrentBeforeFirst, isCurrentAfterLast );

          if( !this.IsCurrencyDeferred )
          {
            if( !object.Equals( oldCurrentItem, newCurrentItem ) )
              this.OnPropertyChanged( new PropertyChangedEventArgs( "CurrentItem" ) );

            if( oldCurrentPosition != this.CurrentPosition )
              this.OnPropertyChanged( new PropertyChangedEventArgs( "CurrentPosition" ) );

            if( oldIsCurrentBeforeFirst != this.IsCurrentBeforeFirst )
              this.OnPropertyChanged( new PropertyChangedEventArgs( "IsCurrentBeforeFirst" ) );

            if( oldIsCurrentAfterLast != this.IsCurrentAfterLast )
              this.OnPropertyChanged( new PropertyChangedEventArgs( "IsCurrentAfterLast" ) );

            this.OnCurrentChanged();
          }
        }
      }

      return ( newCurrentItem != null );
    }
 /// <summary>
 /// Ask listeners (via ICollectionView.CurrentChanging event) if it's OK to change currency
 /// </summary>
 /// <returns>False if a listener cancels the change, True otherwise</returns>
 private bool OkToChangeCurrent()
 {
     CurrentChangingEventArgs args = new CurrentChangingEventArgs();
     this.OnCurrentChanging(args);
     return !args.Cancel;
 }
 protected virtual new void OnCurrentChanging(System.ComponentModel.CurrentChangingEventArgs args)
 {
 }
Exemplo n.º 35
0
        private void OnTabItemSelecting(Object sender, CurrentChangingEventArgs e)
        {

        }
 void collectionView_CurrentChanging(object sender, CurrentChangingEventArgs e)
 {
     this.mediaElement.Stop();
 }
 protected virtual new void OnCurrentChanging(System.ComponentModel.CurrentChangingEventArgs args)
 {
     Contract.Requires(args != null);
 }