Пример #1
0
        private void OnNavigationComplete(object sender, NavigationCompleteEventArgs args)
        {
            NavigationLogEventArgs eventArgs = new NavigationLogEventArgs();
            bool oldCanNavigateBackward      = CanNavigateBackward;
            bool oldCanNavigateForward       = CanNavigateForward;

            if ((pendingNavigation != null))
            {
                // navigation log traversal in progress

                // determine if new location is the same as the traversal request
                int result = 0;
                pendingNavigation.Location.NativeShellItem.Compare(
                    args.NewLocation.NativeShellItem, SICHINTF.SICHINT_ALLFIELDS, out result);
                bool shellItemsEqual = (result == 0);
                if (shellItemsEqual == false)
                {
                    // new location is different than traversal request,
                    // behave is if it never happened!
                    // remove history following currentLocationIndex, append new item
                    if (currentLocationIndex < (_locations.Count - 1))
                    {
                        _locations.RemoveRange((int)currentLocationIndex + 1, (int)(_locations.Count - (currentLocationIndex + 1)));
                    }
                    _locations.Add(args.NewLocation);
                    currentLocationIndex       = (_locations.Count - 1);
                    eventArgs.LocationsChanged = true;
                }
                else
                {
                    // log traversal successful, update index
                    currentLocationIndex       = (int)pendingNavigation.Index;
                    eventArgs.LocationsChanged = false;
                }
                pendingNavigation = null;
            }
            else
            {
                // remove history following currentLocationIndex, append new item
                if (currentLocationIndex < (_locations.Count - 1))
                {
                    _locations.RemoveRange((int)currentLocationIndex + 1, (int)(_locations.Count - (currentLocationIndex + 1)));
                }
                _locations.Add(args.NewLocation);
                currentLocationIndex       = (_locations.Count - 1);
                eventArgs.LocationsChanged = true;
            }

            // update event args
            eventArgs.CanNavigateBackwardChanged = (oldCanNavigateBackward != CanNavigateBackward);
            eventArgs.CanNavigateForwardChanged  = (oldCanNavigateForward != CanNavigateForward);

            if (NavigationLogChanged != null)
            {
                NavigationLogChanged(this, eventArgs);
            }
        }
Пример #2
0
		private void OnNavigationComplete(object sender, NavigationCompleteEventArgs args) {
			NavigationLogEventArgs eventArgs = new NavigationLogEventArgs();
			bool oldCanNavigateBackward = CanNavigateBackward;
			bool oldCanNavigateForward = CanNavigateForward;

			if ((pendingNavigation != null)) {
				// navigation log traversal in progress

				// determine if new location is the same as the traversal request
				int result = 0;
				pendingNavigation.Location.NativeShellItem.Compare(
					args.NewLocation.NativeShellItem, SICHINTF.SICHINT_ALLFIELDS, out result);
				bool shellItemsEqual = (result == 0);
				if (shellItemsEqual == false) {
					// new location is different than traversal request, 
					// behave is if it never happened!
					// remove history following currentLocationIndex, append new item
					if (currentLocationIndex < (_locations.Count - 1)) {
						_locations.RemoveRange((int)currentLocationIndex + 1, (int)(_locations.Count - (currentLocationIndex + 1)));
					}
					_locations.Add(args.NewLocation);
					currentLocationIndex = (_locations.Count - 1);
					eventArgs.LocationsChanged = true;
				} else {
					// log traversal successful, update index
					currentLocationIndex = (int)pendingNavigation.Index;
					eventArgs.LocationsChanged = false;
				}
				pendingNavigation = null;
			} else {
				// remove history following currentLocationIndex, append new item
				if (currentLocationIndex < (_locations.Count - 1)) {
					_locations.RemoveRange((int)currentLocationIndex + 1, (int)(_locations.Count - (currentLocationIndex + 1)));
				}
				_locations.Add(args.NewLocation);
				currentLocationIndex = (_locations.Count - 1);
				eventArgs.LocationsChanged = true;
			}

			// update event args
			eventArgs.CanNavigateBackwardChanged = (oldCanNavigateBackward != CanNavigateBackward);
			eventArgs.CanNavigateForwardChanged = (oldCanNavigateForward != CanNavigateForward);

			if (NavigationLogChanged != null) {
				NavigationLogChanged(this, eventArgs);
			}
		}