コード例 #1
0
        public FlowSettings ToPreviousStep(RequestBase request, int step)
        {
            int count = previousDataStack.Count - step;//step is zero based argument of the nav links

            //Number of items in the back up stack is one more than the number of links
            //e.g if when level == 0 and number items in the stack is 4 we must pop the stack 4 times;

            for (int i = 0; i < count - 1; i++)
            {
                previousDataStack.Pop();
            }

            IDialogHandler handler = BaseDialogHandler.Create(request);

            forwardRepopulateStack.Push(new ViewFieldsListPair {
                View = request.View, Fields = handler.FieldValues
            });                                                             //Get Fields to repopulate current form

            for (int i = 1; i < count - 1; i++)                             //pop one less item from the repopulate stack.  Repopulate stack gets updated on IDialog complete
            {
                forwardRepopulateStack.Push(previousRepopulateStack.Pop()); //get fields for prior forms
            }

            //get backup data for previous form
            ResetValuesOnBackup(previousDataStack.Pop());

            this.Director.ExecuteRulesEngine();

            return(this.GetFlowSettingsOnBackup());
        }
コード例 #2
0
 /// <summary>
 /// Removes the specified handler.
 /// </summary>
 /// <param name="handler">The handler.</param>
 public void Remove(IDialogHandler handler)
 {
     lock (this)
     {
         handlers.Remove(handler);
     }
 }
コード例 #3
0
        public FlowSettings Next(RequestBase request)
        {
            try
            {
                IDialogHandler handler = BaseDialogHandler.Create(request);
                IEnumerable <ValidationResult> errors = handler.GetErrors(request);
                if (errors.Count() > 0)
                {
                    return(new FlowSettings(handler.GetScreenSettings(request, errors)));
                }

                handler.Complete(this);

                previousRepopulateStack.Push(new ViewFieldsListPair {
                    View = request.View, Fields = handler.FieldValues
                });

                this.Director.ExecuteRulesEngine();

                return(this.GetFlowSettings());
            }
            catch (Exception ex)
            {
                //_logger.LogWarning(0, string.Format("Progress Next {0}", Newtonsoft.Json.JsonConvert.SerializeObject(this.Progress)));
                //this._logger.LogError(ex, ex.Message);
                return(this.GetFlowSettings(ex));
            }
        }
コード例 #4
0
 /// <summary>
 /// Removes all instances that match <paramref name="handler"/>.
 /// This method determines equality by calling Object.Equals.
 /// </summary>
 /// <param name="handler">The object implementing IDialogHandler.</param>
 /// <example>
 /// If you want to use RemoveAll with your custom dialog handler to
 /// remove all instances of your dialog handler from a DialogWatcher instance,
 /// you should override the Equals method in your custom dialog handler class
 /// like this:
 /// <code>
 /// public override bool Equals(object obj)
 /// {
 ///   if (obj == null) return false;
 ///
 ///   return (obj is YourDialogHandlerClassNameGoesHere);
 /// }
 /// </code>
 /// You could also inherit from <see cref="BaseDialogHandler"/> instead of implementing
 /// <see cref="IDialogHandler"/> in your custom dialog handler. <see cref="BaseDialogHandler"/> provides
 /// overrides for Equals and GetHashCode that work with RemoveAll.
 /// </example>
 public void RemoveAll(IDialogHandler handler)
 {
     while (Contains(handler))
     {
         Remove(handler);
     }
 }
コード例 #5
0
        internal DialogResult RunDialog(ModernWindow owner, IDialogHandler dialogHandler, DialogViewModel viewModel)
        {
            this.Result = null;
            var decorator = owner.AdornerDecorator;

            if (decorator == null || !owner.IsActive)
            {
                return(ShowDialog(viewModel));
            }
            AdornerLayer adornerLayer = decorator.AdornerLayer;
            var          uiElement    = decorator.Child;

            if (adornerLayer == null || uiElement == null)
            {
                return(ShowDialog(viewModel));
            }

            var adorner = new ContentAdorner(uiElement, this);

            adornerLayer.Add(adorner);

            while (this.Result == null)
            {
                DoEvents();
            }

            adornerLayer.Remove(adorner);
            return(this.Result.Value);
        }
コード例 #6
0
		protected virtual void Dispose(bool managedAndNative)
		{
			dialogWatcher.Remove(dialogHandler);

			dialogWatcher = null;
			dialogHandler = null;
		}
コード例 #7
0
        private void CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, bool createInNewProcess)
        {
            CheckThreadApartmentStateIsSTA();

            UtilityClass.MoveMousePoinerToTopLeft(Settings.AutoMoveMousePointerToTopLeft);

            if (createInNewProcess)
            {
                Logger.LogAction("Creating IE instance in a new process");

                _ieBrowser = CreateIEPartiallyInitializedInNewProcess();
            }
            else
            {
                Logger.LogAction("Creating IE instance");

                _ieBrowser = CreateIEBrowser(new InternetExplorerClass());
            }

            StartDialogWatcher();

            if (logonDialogHandler != null)
            {
                // remove other logon dialog handlers since only one handler
                // can effectively handle the logon dialog.
                DialogWatcher.RemoveAll(new LogonDialogHandler("a", "b"));

                // Add the (new) logonHandler
                DialogWatcher.Add(logonDialogHandler);
            }

            FinishInitialization(uri);

//            WaitForComplete();
        }
コード例 #8
0
 /// <summary>
 /// Determines whether this <see cref="DialogWatcher"/> contains the specified dialog handler.
 /// </summary>
 /// <param name="handler">The dialog handler.</param>
 /// <returns>
 ///     <c>true</c> if [contains] [the specified handler]; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(IDialogHandler handler)
 {
     lock (this)
     {
         return(_handlers.Contains(handler));
     }
 }
コード例 #9
0
        protected virtual void Dispose(bool managedAndNative)
        {
            dialogWatcher.Remove(dialogHandler);

            dialogWatcher = null;
            dialogHandler = null;
        }
コード例 #10
0
        public static Wad2 ImportFromFile(string fileName, bool withSounds, IDialogHandler progressReporter, bool allowTRNGDecryption = false)
        {
            if (fileName.EndsWith(".wad2", StringComparison.InvariantCultureIgnoreCase))
            {
                return(Wad2Loader.LoadFromFile(fileName, withSounds));
            }
            else if (fileName.EndsWith(".wad", StringComparison.InvariantCultureIgnoreCase) ||
                     fileName.EndsWith(".was", StringComparison.InvariantCultureIgnoreCase) ||
                     fileName.EndsWith(".sam", StringComparison.InvariantCultureIgnoreCase) ||
                     fileName.EndsWith(".sfx", StringComparison.InvariantCultureIgnoreCase) ||
                     fileName.EndsWith(".swd", StringComparison.InvariantCultureIgnoreCase))
            {
                if (!fileName.EndsWith(".wad", StringComparison.InvariantCultureIgnoreCase))
                {
                    fileName = Path.ChangeExtension(fileName, "wad");
                }

                var oldWad = new Tr4Wad.Tr4Wad();
                oldWad.LoadWad(fileName);
                return(Tr4WadOperations.ConvertTr4Wad(oldWad, progressReporter));
            }
            else
            {
                var originalLevel = new TrLevel();
                originalLevel.LoadLevel(fileName, allowTRNGDecryption);
                return(TrLevelOperations.ConvertTrLevel(originalLevel));
            }
        }
コード例 #11
0
        public void Reload(LevelSettings settings, IDialogHandler progressReporter = null)
        {
            if (string.IsNullOrEmpty(Path))
            {
                Sounds        = null;
                LoadException = new Exception("Path is empty.");
                return;
            }

            // Load the catalog
            try
            {
                var path = settings.MakeAbsolute(Path);
                if (File.Exists(path))
                {
                    WadSounds newSounds = WadSounds.ReadFromFile(path);
                    Sounds        = newSounds;
                    LoadException = null;
                }
                else
                {
                    LoadException = new Exception("File not found: " + path);
                }
            }
            catch (Exception exc)
            {
                logger.Warn(exc, "Unable to load catalog '" + Path + "'.");
                Sounds        = null;
                LoadException = exc;
            }
        }
コード例 #12
0
        public void Reload(LevelSettings settings, IDialogHandler progressReporter = null)
        {
            if (string.IsNullOrEmpty(Path))
            {
                Wad           = null;
                LoadException = new Exception("Path is empty.");
                return;
            }

            // Load wad
            try
            {
                Wad2 newWad = Wad2.ImportFromFile(
                    settings.MakeAbsolute(Path),
                    false,
                    progressReporter ?? new ProgressReporterSimple());
                Wad           = newWad;
                LoadException = null;
            }
            catch (Exception exc)
            {
                logger.Warn(exc, "Unable to load wad '" + Path + "'.");
                Wad           = null;
                LoadException = exc;
            }
        }
コード例 #13
0
 /// <summary>
 /// Adds the specified handler.
 /// </summary>
 /// <param name="handler">The handler.</param>
 public void Add(IDialogHandler handler)
 {
     lock (this)
     {
         handlers.Add(handler);
     }
 }
コード例 #14
0
ファイル: DialogExtensions.cs プロジェクト: csuffyy/Sumerics
        public static void Close <T>(this IDialogHandler handler)
            where T : Window
        {
            var current = Get <T>();

            if (current != null)
            {
                current.Close();
            }
        }
コード例 #15
0
 internal void HandlePossibleCandidate(IDialogHandler dialogHandler, Window window, IntPtr mainWindowHwnd)
 {
     UtilityClass.TryActionIgnoreException(() =>
                                               {
                                                   if (dialogHandler.CanHandleDialog(window, mainWindowHwnd))
                                                   {
                                                       CandidateDialogHandlers.Add(
                                                           dialogHandler.GetType().FullName);
                                                   }
                                               });
 }
コード例 #16
0
 public void HandlePossibleCandidate(IDialogHandler dialogHandler, Window window, IntPtr mainWindowHwnd)
 {
     UtilityClass.TryActionIgnoreException(() =>
     {
         if (dialogHandler.CanHandleDialog(window, mainWindowHwnd))
         {
             CandidateDialogHandlers.Add(
                 dialogHandler.GetType().FullName);
         }
     });
 }
コード例 #17
0
ファイル: DialogWatcher.cs プロジェクト: minskowl/MY
 /// <summary>
 /// Determines whether this <see cref="DialogWatcher"/> contains the specified dialog handler.
 /// </summary>
 /// <param name="handler">The dialog handler.</param>
 /// <returns>
 ///     <c>true</c> if [contains] [the specified handler]; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(IDialogHandler handler)
 {
     _lockHandlers.EnterReadLock();
     try
     {
         return(_handlers.Contains(handler));
     }
     finally
     {
         _lockHandlers.ExitReadLock();
     }
 }
コード例 #18
0
ファイル: DialogWatcher.cs プロジェクト: minskowl/MY
 /// <summary>
 /// Removes the specified handler.
 /// </summary>
 /// <param name="handler">The handler.</param>
 public void Remove(IDialogHandler handler)
 {
     _lockHandlers.EnterWriteLock();
     try
     {
         _handlers.Remove(handler);
     }
     finally
     {
         _lockHandlers.ExitWriteLock();
     }
 }
コード例 #19
0
ファイル: DialogWatcher.cs プロジェクト: minskowl/MY
 /// <summary>
 /// Adds the specified handler.
 /// </summary>
 /// <param name="handler">The handler.</param>
 public void Add(IDialogHandler handler)
 {
     _lockHandlers.EnterWriteLock();
     try
     {
         _handlers.Add(handler);
     }
     finally
     {
         _lockHandlers.ExitWriteLock();
     }
 }
コード例 #20
0
        public UseDialogOnce( DialogWatcher watcher, IDialogHandler handler )
        {
            if ( watcher == null )
                throw new ArgumentNullException( "watcher" );
            if ( handler == null )
                throw new ArgumentNullException( "handler" );

            _watcher = watcher;
            _handler = handler;

            watcher.Add( handler );
        }
コード例 #21
0
 public ChatListener(
     IEventAggregator eventAggregator,
     ILogger <ChatListener> logger,
     IPlayersNatives playersNatives,
     ISampNatives sampNatives,
     IDialogHandler dialogHandler)
 {
     this.eventAggregator = eventAggregator;
     this.logger          = logger;
     this.playersNatives  = playersNatives;
     this.sampNatives     = sampNatives;
     this.dialogHandler   = dialogHandler;
 }
コード例 #22
0
        public UseDialogOnce(DialogWatcher watcher, IDialogHandler handler)
        {
            if (watcher == null)
            {
                throw new ArgumentNullException("watcher");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            _watcher = watcher;
            _handler = handler;

            watcher.Add(handler);
        }
コード例 #23
0
		public UseDialogOnce(DialogWatcher dialogWatcher, IDialogHandler dialogHandler)
		{
			if (dialogWatcher == null)
			{
				throw new ArgumentNullException("dialogWatcher");
			}

			if (dialogHandler == null)
			{
				throw new ArgumentNullException("dialogHandler");
			}

			this.dialogWatcher = dialogWatcher;
			this.dialogHandler = dialogHandler;

			dialogWatcher.Add(dialogHandler);
		}
コード例 #24
0
        public UseDialogOnce(DialogWatcher dialogWatcher, IDialogHandler dialogHandler)
        {
            if (dialogWatcher == null)
            {
                throw new ArgumentNullException("dialogWatcher");
            }

            if (dialogHandler == null)
            {
                throw new ArgumentNullException("dialogHandler");
            }

            this.dialogWatcher = dialogWatcher;
            this.dialogHandler = dialogHandler;

            dialogWatcher.Add(dialogHandler);
        }
コード例 #25
0
ファイル: DialogExtensions.cs プロジェクト: csuffyy/Sumerics
        public static T Show <T>(this IDialogHandler handler)
            where T : Window, new()
        {
            var current = Get <T>();

            if (current == null)
            {
                current = new T();
                current.Show();
            }
            else
            {
                current.Activate();
            }

            return(current);
        }
コード例 #26
0
 public BrowserControl(
     IContextMenuHandler contextMenuHandler,
     IDialogHandler dialogHandler,
     IDisplayHandler displayHandler,
     IDownloadHandler downloadHandler,
     IKeyboardHandler keyboardHandler,
     ILifeSpanHandler lifeSpanHandler,
     IRequestHandler requestHandler,
     string url) : base(url)
 {
     this.contextMenuHandler = contextMenuHandler;
     this.dialogHandler      = dialogHandler;
     this.displayHandler     = displayHandler;
     this.downloadHandler    = downloadHandler;
     this.keyboardHandler    = keyboardHandler;
     this.lifeSpanHandler    = lifeSpanHandler;
     this.requestHandler     = requestHandler;
 }
コード例 #27
0
        public static Wad2 ConvertTr4Wad(Tr4Wad oldWad, IDialogHandler progressReporter)
        {
            logger.Info("Converting TR4 WAD to Wad2");

            var wad = new Wad2()
            {
                SoundSystem = SoundSystem.Xml, GameVersion = TRVersion.Game.TR4
            };

            // Convert all textures
            Dictionary <int, WadTexture> textures = ConvertTr4TexturesToWadTexture(oldWad, wad);

            logger.Info("Textures read.");

            // Convert sounds
            var sfxPath = Path.GetDirectoryName(oldWad.FileName) + "\\" + Path.GetFileNameWithoutExtension(oldWad.FileName) + ".sfx";

            if (File.Exists(sfxPath))
            {
                wad.Sounds = WadSounds.ReadFromFile(sfxPath);
                logger.Info("Sounds read.");
            }

            // Convert moveables
            for (int i = 0; i < oldWad.Moveables.Count; i++)
            {
                ConvertTr4MoveableToWadMoveable(wad, oldWad, i, textures);
            }
            logger.Info("Moveables read.");

            // Convert statics
            for (int i = 0; i < oldWad.Statics.Count; i++)
            {
                ConvertTr4StaticMeshToWadStatic(wad, oldWad, i, textures);
            }
            logger.Info("Statics read.");

            // Convert sprites
            ConvertTr4Sprites(wad, oldWad);
            logger.Info("Sprites read.");

            return(wad);
        }
コード例 #28
0
        public FlowSettings Previous(RequestBase request)
        {
            if (previousDataStack.Count <= 1)
            {
                throw new InvalidOperationException("{81BF4217-F4D2-459E-B842-85E4BC9D59D2}");
            }

            IDialogHandler handler = BaseDialogHandler.Create(request);

            //remove backup data for current form
            previousDataStack.Pop();

            forwardRepopulateStack.Push(new ViewFieldsListPair {
                View = request.View, Fields = handler.FieldValues
            });                                                                                                       //Get Fields to repopulate current form

            //get backup data for previous form
            ResetValuesOnBackup(previousDataStack.Pop());

            this.Director.ExecuteRulesEngine();

            return(this.GetFlowSettingsOnBackup());
        }
コード例 #29
0
        public FlowSettings Next(RequestBase request)
        {
            try
            {
                IDialogHandler handler = BaseDialogHandler.Create(request);
                //temporarily disable server-side validation.
                IEnumerable <ValidationResult> errors = new List <ValidationResult>();//handler.GetErrors(request);
                if (errors.Count() > 0)
                {
                    return(new FlowSettings(handler.GetScreenSettings(request, errors)));
                }

                handler.Complete(this, request);
                this.Director.ExecuteRulesEngine();

                return(this.FlowSettings);
            }
            catch (Exception ex)
            {
                _logger.LogWarning(0, string.Format("Progress Next {0}", Newtonsoft.Json.JsonConvert.SerializeObject(this.Progress)));
                this._logger.LogError(ex, ex.Message);
                return(this.GetFlowSettings(ex));
            }
        }
コード例 #30
0
        public PolygonManagementViewModel(PolygonGeneratorProvider generatorProvider = null,
                                          IDialogHandler dialogHandler  = null,
                                          PolygonClipper clipper        = null,
                                          AreaCalculator areaCalculator = null)
        {
            Polygons = new ObservableCollection <Polygon>();

            DialogHandler  = dialogHandler;
            Clipper        = clipper;
            AreaCalculator = areaCalculator;

            GenerateAndAddPolygonCommand = new DelegateCommand(
                GenerateAndAddPolygon,
                () => SelectedPolygonGenerator != null);

            ClipPolygonsCommand = new DelegateCommand(
                ClipPolygons,
                () => Polygons.Count == 2 && Clipper != null);
            Polygons.CollectionChanged += (_, __) => ClipPolygonsCommand.RaiseCanExecuteChanged();

            CalculateAreaForSelectedPolygonCommand = new DelegateCommand(
                CalculateAreaForSelectedPolygon,
                () => SelectedPolygon != null && !IsCalculatingArea && AreaCalculator != null);

            CancelAreaCalculationCommand = new DelegateCommand(
                () => CancelSource.Cancel(),
                () => IsCalculatingArea);

            if (generatorProvider != null)
            {
                Generators = GetGeneratorsFromContainer(generatorProvider);
                SelectedPolygonGenerator = Generators.LastOrDefault()?.Generator;
            }

            MouseCommand = new DelegateCommand <Polygon>((x) => SelectedPolygon = x);
        }
コード例 #31
0
ファイル: DomContainer.cs プロジェクト: pusp/o2platform
		/// <summary>
		/// Removes the dialog handler.
		/// </summary>
		/// <param name="handler">The dialog handler.</param>
		public void RemoveDialogHandler(IDialogHandler handler)
		{
			DialogWatcher.Remove(handler);
		}
コード例 #32
0
ファイル: DomContainer.cs プロジェクト: pusp/o2platform
		/// <summary>
		/// Adds the dialog handler.
		/// </summary>
		/// <param name="handler">The dialog handler.</param>
		public void AddDialogHandler(IDialogHandler handler)
		{
			DialogWatcher.Add(handler);
		}
コード例 #33
0
	    private void CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, bool createInNewProcess)
		{
			CheckThreadApartmentStateIsSTA();

			UtilityClass.MoveMousePoinerToTopLeft(Settings.AutoMoveMousePointerToTopLeft);

			if (createInNewProcess)
			{
				Logger.LogAction("Creating IE instance in a new process");

                _ieBrowser = CreateIEPartiallyInitializedInNewProcess();
			}
			else
			{
				Logger.LogAction("Creating IE instance");

                _ieBrowser = CreateIEBrowser(new InternetExplorerClass());
			}
            
            StartDialogWatcher();

			if (logonDialogHandler != null)
			{
				// remove other logon dialog handlers since only one handler
				// can effectively handle the logon dialog.
				DialogWatcher.RemoveAll(new LogonDialogHandler("a", "b"));

				// Add the (new) logonHandler
				DialogWatcher.Add(logonDialogHandler);
			}

            FinishInitialization(uri);
            
//            WaitForComplete();
		}
コード例 #34
0
		/// <summary>
		/// Determines whether this <see cref="DialogWatcher"/> contains the specified dialog handler.
		/// </summary>
		/// <param name="handler">The dialog handler.</param>
		/// <returns>
		/// 	<c>true</c> if [contains] [the specified handler]; otherwise, <c>false</c>.
		/// </returns>
        public bool Contains(IDialogHandler handler)
		{
			lock (this)
			{
				return _handlers.Contains(handler);
			}
		}
コード例 #35
0
		/// <summary>
		/// Removes all instances that match <paramref name="handler"/>.
		/// This method determines equality by calling Object.Equals.
		/// </summary>
		/// <param name="handler">The object implementing IDialogHandler.</param>
		/// <example>
		/// If you want to use RemoveAll with your custom dialog handler to
		/// remove all instances of your dialog handler from a DialogWatcher instance,
		/// you should override the Equals method in your custom dialog handler class 
		/// like this:
		/// <code>
		/// public override bool Equals(object obj)
		/// {
		///   if (obj == null) return false;
		///   
		///   return (obj is YourDialogHandlerClassNameGoesHere);
		/// }                               
		/// </code>
		/// You could also inherit from <see cref="BaseDialogHandler"/> instead of implementing
		/// <see cref="IDialogHandler"/> in your custom dialog handler. <see cref="BaseDialogHandler"/> provides
		/// overrides for Equals and GetHashCode that work with RemoveAll.
		/// </example>
		public void RemoveAll(IDialogHandler handler)
		{
			while (Contains(handler))
			{
				Remove(handler);
			}
		}
コード例 #36
0
		/// <summary>
		/// Removes the specified handler.
		/// </summary>
		/// <param name="handler">The handler.</param>
		public void Remove(IDialogHandler handler)
		{
			lock (this)
			{
				_handlers.Remove(handler);
			}
		}
コード例 #37
0
		/// <summary>
		/// Adds the specified handler.
		/// </summary>
		/// <param name="handler">The handler.</param>
		public void Add(IDialogHandler handler)
		{
			lock (this)
			{
				_handlers.Add(handler);
			}
		}
コード例 #38
0
 public ImageHelper(IDialogHandler handler)
 {
     _dialogHandler = handler;
 }
コード例 #39
0
 /// <summary>
 /// Removes the dialog handler.
 /// </summary>
 /// <param name="handler">The dialog handler.</param>
 public void RemoveDialogHandler(IDialogHandler handler)
 {
     DialogWatcher.Remove(handler);
 }
コード例 #40
0
 /// <summary>
 /// Adds the dialog handler.
 /// </summary>
 /// <param name="handler">The dialog handler.</param>
 public void AddDialogHandler(IDialogHandler handler)
 {
     DialogWatcher.Add(handler);
 }
コード例 #41
0
 public void RemoveAll(IDialogHandler handler)
 {
     while (this.Contains(handler))
     this.Remove(handler);
 }
コード例 #42
0
 public ImageHelper(IDialogHandler handler)
 {
     _dialogHandler = handler;
 }
コード例 #43
0
 public ReferencedSoundsCatalog(LevelSettings settings, string path, IDialogHandler progressReporter = null)
 {
     Path = path;
     Reload(settings, progressReporter);
 }