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()); }
/// <summary> /// Removes the specified handler. /// </summary> /// <param name="handler">The handler.</param> public void Remove(IDialogHandler handler) { lock (this) { handlers.Remove(handler); } }
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)); } }
/// <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); } }
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); }
protected virtual void Dispose(bool managedAndNative) { dialogWatcher.Remove(dialogHandler); dialogWatcher = null; dialogHandler = null; }
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(); }
/// <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)); } }
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)); } }
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; } }
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; } }
/// <summary> /// Adds the specified handler. /// </summary> /// <param name="handler">The handler.</param> public void Add(IDialogHandler handler) { lock (this) { handlers.Add(handler); } }
public static void Close <T>(this IDialogHandler handler) where T : Window { var current = Get <T>(); if (current != null) { current.Close(); } }
internal void HandlePossibleCandidate(IDialogHandler dialogHandler, Window window, IntPtr mainWindowHwnd) { UtilityClass.TryActionIgnoreException(() => { if (dialogHandler.CanHandleDialog(window, mainWindowHwnd)) { CandidateDialogHandlers.Add( dialogHandler.GetType().FullName); } }); }
public void HandlePossibleCandidate(IDialogHandler dialogHandler, Window window, IntPtr mainWindowHwnd) { UtilityClass.TryActionIgnoreException(() => { if (dialogHandler.CanHandleDialog(window, mainWindowHwnd)) { CandidateDialogHandlers.Add( dialogHandler.GetType().FullName); } }); }
/// <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(); } }
/// <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(); } }
/// <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(); } }
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 ); }
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; }
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); }
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); }
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); }
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; }
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); }
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()); }
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)); } }
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); }
/// <summary> /// Removes the dialog handler. /// </summary> /// <param name="handler">The dialog handler.</param> public void RemoveDialogHandler(IDialogHandler handler) { DialogWatcher.Remove(handler); }
/// <summary> /// Adds the dialog handler. /// </summary> /// <param name="handler">The dialog handler.</param> public void AddDialogHandler(IDialogHandler handler) { DialogWatcher.Add(handler); }
/// <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); } }
/// <summary> /// Removes the specified handler. /// </summary> /// <param name="handler">The handler.</param> public void Remove(IDialogHandler handler) { lock (this) { _handlers.Remove(handler); } }
/// <summary> /// Adds the specified handler. /// </summary> /// <param name="handler">The handler.</param> public void Add(IDialogHandler handler) { lock (this) { _handlers.Add(handler); } }
public ImageHelper(IDialogHandler handler) { _dialogHandler = handler; }
public void RemoveAll(IDialogHandler handler) { while (this.Contains(handler)) this.Remove(handler); }
public ReferencedSoundsCatalog(LevelSettings settings, string path, IDialogHandler progressReporter = null) { Path = path; Reload(settings, progressReporter); }