public void InvokeCompletion() { EventBinder <Action> onDispose = new EventBinder <Action>(e => OnSoftDispose += e, e => OnSoftDispose -= e); onDispose.IsOneTime = true; onDispose.SetHandler(() => { OnCompletion?.Invoke(); // Wait for completion timeout to auto navigate to results. SynchronizedTimer autoExitTimer = new SynchronizedTimer() { Limit = 2f, }; autoExitTimer.OnFinished += Model.ExitGameToResult; autoExitTimer.Start(); }); SynchronizedTimer initialTimer = new SynchronizedTimer() { Limit = 0.5f }; initialTimer.OnFinished += InvokeSoftDispose; initialTimer.Start(); }
public void Create(object masterView, string backgroundImageName, string logoImageName, bool scaleImage, RectangleF frame, OnCompletion onCompletion) { View = PlatformView.Create( ); View.BackgroundColor = 0; View.AddAsSubview(masterView); ImageBG = PlatformImageView.Create( ); ImageBG.BackgroundColor = ControlStylingConfig.OOBE_Splash_BG_Color; ImageBG.AddAsSubview(masterView); // if a background image was provided, use that. if (string.IsNullOrEmpty(backgroundImageName) == false) { MemoryStream stream = Rock.Mobile.IO.AssetConvert.AssetToStream(backgroundImageName); stream.Position = 0; ImageBG.Image = stream; ImageBG.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; stream.Dispose( ); } MemoryStream logoStream = Rock.Mobile.IO.AssetConvert.AssetToStream(logoImageName); logoStream.Position = 0; ImageLogo = PlatformImageView.Create( ); ImageLogo.AddAsSubview(masterView); ImageLogo.Image = logoStream; ImageLogo.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; logoStream.Dispose( ); OnCompletionCallback = onCompletion; }
/// <summary> /// Initializes a new instance of the <see cref="TransactionApplication" /> class. /// </summary> /// <param name="accounts">\\[apat\\] List of accounts in addition to the sender that may be accessed from the application's approval-program and clear-state-program..</param> /// <param name="applicationArgs">\\[apaa\\] transaction specific arguments accessed from the application's approval-program and clear-state-program..</param> /// <param name="applicationId">\\[apid\\] ID of the application being configured or empty if creating. (required).</param> /// <param name="approvalProgram">\\[apap\\] Logic executed for every application transaction, except when on-completion is set to \"clear\". It can read and write global state for the application, as well as account-specific local state. Approval programs may reject the transaction..</param> /// <param name="clearStateProgram">\\[apsu\\] Logic executed for application transactions with on-completion set to \"clear\". It can read and write global state for the application, as well as account-specific local state. Clear state programs cannot reject the transaction..</param> /// <param name="foreignApps">\\[apfa\\] Lists the applications in addition to the application-id whose global states may be accessed by this application's approval-program and clear-state-program. The access is read-only..</param> /// <param name="foreignAssets">\\[apas\\] lists the assets whose parameters may be accessed by this application's ApprovalProgram and ClearStateProgram. The access is read-only..</param> /// <param name="globalStateSchema">globalStateSchema.</param> /// <param name="localStateSchema">localStateSchema.</param> /// <param name="onCompletion">onCompletion (required).</param> public TransactionApplication(List <string> accounts = default(List <string>), List <string> applicationArgs = default(List <string>), long?applicationId = default, byte[] approvalProgram = default(byte[]), byte[] clearStateProgram = default(byte[]), List <int?> foreignApps = default(List <int?>), List <int?> foreignAssets = default(List <int?>), StateSchema globalStateSchema = default(StateSchema), StateSchema localStateSchema = default(StateSchema), OnCompletion onCompletion = default(OnCompletion)) { // to ensure "applicationId" is required (not null) if (applicationId == null) { throw new InvalidDataException("applicationId is a required property for TransactionApplication and cannot be null"); } else { this.ApplicationId = applicationId; } // to ensure "onCompletion" is required (not null) if (onCompletion == null) { throw new InvalidDataException("onCompletion is a required property for TransactionApplication and cannot be null"); } else { this.OnCompletion = onCompletion; } this.Accounts = accounts; this.ApplicationArgs = applicationArgs; this.ApprovalProgram = approvalProgram; this.ClearStateProgram = clearStateProgram; this.ForeignApps = foreignApps; this.ForeignAssets = foreignAssets; this.GlobalStateSchema = globalStateSchema; this.LocalStateSchema = localStateSchema; }
public void Start(GoBoard goBoard, Color playerToMove, SearchOptions searchOptions, SearchMethodType searchMethodType, OnCompletion onCompletion) { // stop existing search, if any if (SearchInterface != null) Stop(); if (SearchMethodType != searchMethodType) { SearchMethodType = searchMethodType; SearchInterface = SearchMethodFactory.CreateFactory(searchMethodType); } // make a private copy of the board Board = goBoard.Clone(); // make a private copy of the search options SearchOptions = searchOptions.Clone(); // set player to move PlayerToMove = playerToMove; // set the Nag Coordinator SearchInterface.SetNagCoordinator(NagCoordinator); // initialize the search parameters SearchInterface.Initialize(Board, PlayerToMove, SearchOptions, onCompletion); // start search SearchThread = new Thread(this.StartThread); SearchThread.Start(); }
protected override void CleanUp() { CloseStream(); StreamWriter?.Close(); OnCompletion?.Invoke(); NLogFinish(); }
public void Create( object masterView, string backgroundImageName, string logoImageName, bool scaleImage, RectangleF frame, OnCompletion onCompletion ) { View = PlatformView.Create( ); View.BackgroundColor = 0; View.AddAsSubview( masterView ); ImageBG = PlatformImageView.Create( true ); ImageBG.BackgroundColor = ControlStylingConfig.OOBE_Splash_BG_Color; ImageBG.AddAsSubview( masterView ); // if a background image was provided, use that. if ( string.IsNullOrEmpty( backgroundImageName ) == false ) { MemoryStream stream = Rock.Mobile.IO.AssetConvert.AssetToStream( backgroundImageName ); stream.Position = 0; ImageBG.Image = stream; ImageBG.SizeToFit( ); ImageBG.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; stream.Dispose( ); } MemoryStream logoStream = Rock.Mobile.IO.AssetConvert.AssetToStream( logoImageName ); logoStream.Position = 0; ImageLogo = PlatformImageView.Create( scaleImage ); ImageLogo.AddAsSubview( masterView ); ImageLogo.Image = logoStream; ImageLogo.SizeToFit( ); ImageLogo.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; logoStream.Dispose( ); OnCompletionCallback = onCompletion; }
/// <summary> /// Login with the given username and password. /// </summary> /// <remarks> /// You will need to do this before loading any profiles. /// Also please note, that the result of this operation is always null! /// </remarks> /// <param name="username">The username that is used.</param> /// <param name="password">The password that is used.</param> /// <param name="onCompletion">The completion handler returns whether the login succeeded.</param> public bool Login(string username, string password, OnCompletion <object> onCompletion) { if (username == null || username.Equals("") || password == null || password.Equals("")) { Debug.Log("Please supply all expected parameters"); onCompletion(false, null); return(false); } if ((_loggedInUser != null && username.Equals(_loggedInUser)) && (_loginResponse != null && _loginResponse.IsValid)) { Debug.Log("Login is still valid!"); onCompletion(true, null); return(true); // TODO remove } _parent.StartChildCoroutine(_LoginCoroutine(username, password, response => { _loginResponse = JsonConvert.DeserializeObject <LoginResponse>(response); _loggedInUser = username; onCompletion(true, null); }, message => { Debug.Log("An error occured while logging in..."); Debug.Log(message); onCompletion(false, null); })); return(true); // TODO remove }
public void Create(object masterView, bool scaleImage, RectangleF frame, OnCompletion onCompletion) { View = PlatformView.Create( ); View.BackgroundColor = ControlStylingConfig.BackgroundColor; View.Frame = frame; View.AddAsSubview(masterView); Credits = new List <Credit>(); Credits.Add(new Credit("Hey you found me! I'm Jered, the mobile app developer here at CCV. Making this app was a ton of work, and couldn't have happened without the support of a ton of people!\n\nThanks so much to:\n" + "Jenni, my beautiful wife and very patient app tester!\n\n" + "Jon & David, for developing this app's backbone, Rock.\n\n" + "Mason & Mike for testing, end points, and endless puns! (See what I did there?)\n\n" + "Nick & Kyle for all the great artwork and design you see in this app.\n\n" + "Dan & Kris Simpson for HUGE feedback, testing, and movie nights!!\n\n" + "The IT boyz: Jim, `Stopher and Chris, for being extremely willing Android guinea pigs.\n\n" + "Matt, Emily, Robin, Jill and Bree, for their testing and feedback.\n\n\n" + "And thanks of course to all of you out there using the app and making CCV the awesome church that it is!", "me.png", scaleImage, frame, View)); CloseButton = PlatformButton.Create( ); CloseButton.AddAsSubview(View.PlatformNativeObject); CloseButton.Text = "Got It!"; CloseButton.BackgroundColor = PrayerConfig.PrayedForColor; CloseButton.TextColor = ControlStylingConfig.Button_TextColor; CloseButton.CornerRadius = ControlStylingConfig.Button_CornerRadius; CloseButton.SizeToFit( ); CloseButton.ClickEvent = delegate(PlatformButton button) { OnCompletionCallback( ); }; OnCompletionCallback = onCompletion; }
public void Complete(T result) { bool signalCompletion = false; OnCompletion completionCallback = null; lock (this) { if (State == ResultState.INCOMPLETE) { State = ResultState.COMPLETE; Result = result; signalCompletion = true; completionCallback = OnCompletionCallback; } else { throw new CrtException("Result already completed"); } } if (signalCompletion) { if (completionCallback != null) { completionCallback(result); } CompletionSignal.Set(); } }
public void Create(object masterView, bool scaleImage, string imageName, RectangleF frame, OnCompletion onCompletion) { View = PlatformView.Create( ); View.BackgroundColor = ControlStylingConfig.BackgroundColor; View.Frame = frame; View.AddAsSubview(masterView); MemoryStream logoStream = Rock.Mobile.IO.AssetConvert.AssetToStream(imageName); logoStream.Position = 0; PonyImage = PlatformImageView.Create( ); PonyImage.AddAsSubview(View.PlatformNativeObject); PonyImage.Image = logoStream; PonyImage.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; logoStream.Dispose( ); CloseButton = PlatformButton.Create( ); CloseButton.AddAsSubview(View.PlatformNativeObject); CloseButton.Text = "Prance! Dance! It's Magic Pony Time!"; CloseButton.BackgroundColor = PrayerConfig.PrayedForColor; CloseButton.TextColor = ControlStylingConfig.Button_TextColor; CloseButton.CornerRadius = ControlStylingConfig.Button_CornerRadius; CloseButton.SizeToFit( ); CloseButton.ClickEvent = delegate(PlatformButton button) { OnCompletionCallback( ); }; OnCompletionCallback = onCompletion; }
public virtual void Wait() { TargetAction.Completion.Wait(); CloseStreamsAction?.Invoke(); OnCompletion?.Invoke(); NLogFinish(); }
/// <summary> /// Updates the user profile with the given id. /// </summary> /// <param name="id">The profile's id</param> /// <param name="preferenceTerms">The updated preference terms to save.</param> /// <param name="onCompletion">The completion handler returns whether the update of the profile succeeded.</param> internal bool UpdateProfile(string id, PreferenceTerms preferenceTerms, OnCompletion <object> onCompletion) { if (_loginResponse?.Token == null) { Debug.Log("You need to login first!"); onCompletion(false, null); return(false); // TODO remove } if (!_loginResponse.IsValid) { Debug.Log("Login has expired!"); onCompletion(false, null); return(false); // TODO remove } _parent.StartChildCoroutine(_UpdateProfileCoroutine(id, preferenceTerms, response => { onCompletion(true, null); }, message => { Debug.Log("An error occured while updating user profile..."); Debug.Log(message); onCompletion(false, null); })); return(true); // TODO remove }
public CrtResult() { Result = default(T); Exception = null; CompletionSignal = new ManualResetEvent(false); State = ResultState.INCOMPLETE; OnCompletionCallback = null; OnExceptionCallback = null; }
/// <summary> /// Create a progress monitor with delegates for reporting status and completion /// </summary> /// <param name="report"></param> /// <param name="complete"></param> public ProgressMonitor(ReportStatus report, OnStart start = null, OnCompletion complete = null) { _reportStatus = report; _onStart = start; _onCompletion = complete; monitor = new BackgroundWorker(); monitor.DoWork += new DoWorkEventHandler(monitor_DoWork); monitor.RunWorkerCompleted += new RunWorkerCompletedEventHandler(monitor_Completed); monitor.ProgressChanged += new ProgressChangedEventHandler(monitor_ReportProgress); monitor.WorkerReportsProgress = true; monitor.WorkerSupportsCancellation = true; }
public void SimpleAsyncSearch(Color playerToMove, OnCompletion onCompletion) { SearchOptions lSearchOptions = GetSearchOptions(playerToMove); lSearchOptions.IncludeEndGameMoves = false; lSearchOptions.UsePatterns = false; Board.Dump(); Console.Error.WriteLine("Move Search: "); Console.Error.WriteLine("Max Level: " + lSearchOptions.MaxPly.ToString() + " - Max Time: " + lSearchOptions.MaxSeconds.ToString() + " Alpha: " + lSearchOptions.AlphaValue.ToString() + " Beta: " + lSearchOptions.BetaValue.ToString()); Search.Start(Board, playerToMove, lSearchOptions, SearchMethodType, onCompletion); }
protected override bool Update(Renderable renderItem, float delta) { if (_actions[0].Run(renderItem, delta)) { _actions.RemoveAt(0); } if (_actions.Count > 0) { return(false); } OnCompletion?.Invoke(null); return(true); }
public new void Initialize(GoBoard goBoard, Color playerToMove, SearchOptions searchOptions, OnCompletion onCompletion) { base.Initialize(goBoard, playerToMove, searchOptions, onCompletion); if (TranspositionTable == null) TranspositionTablePrimary = new TranspositionTablePlus(SearchOptions.TranspositionTableSize); else if (TranspositionTable.Size != SearchOptions.TranspositionTableSize) TranspositionTablePrimary = new TranspositionTablePlus(SearchOptions.TranspositionTableSize); if (TranspositionTableEndGame == null) TranspositionTableEndGame = new TranspositionTablePlus(1024 * 1024); TranspositionTable = TranspositionTablePrimary; }
protected override bool Update(Renderable renderItem, float delta) { for (var i = 0; i < _actions.Count; i++) { if (!_actions[i].Run(renderItem, delta)) { continue; } _actions.RemoveAt(i--); } if (_actions.Count > 0) { return(false); } OnCompletion?.Invoke(null); return(true); }
/// <summary> /// Retrieves the user profile with the given id. /// </summary> /// <remarks> /// You have to be logged in with a valid token and the user needs to have access to the supplied profile. This means /// the user owns it or it is public. /// </remarks> /// <param name="id">The profile's id</param> /// <param name="onCompletion">The completion handler returns whether the getting of the profile succeeded. /// The result is where the preferenceTerms are stored in. May be null on error.</param> internal bool GetProfile(string id, OnCompletion <PreferenceTerms> onCompletion) { if (id == null || id.Equals("")) { Debug.Log("Please supply all expected parameters"); onCompletion(false, null); return(false); } if (_loginResponse?.Token == null) { Debug.Log("You need to login first!"); onCompletion(false, null); return(false); // TODO remove } if (!_loginResponse.IsValid) { Debug.Log("Login has expired!"); onCompletion(false, null); return(false); // TODO remove } _parent.StartChildCoroutine(_GetProfileCoroutine(id, response => { _userContextResponse = JsonConvert.DeserializeObject <UserContextResponse>(response); onCompletion(true, new PreferenceTerms(_userContextResponse.UserPreferences.PreferenceTerms)); }, message => { Debug.Log("An error occured while getting user profile..."); Debug.Log("Are you sure you are logged in with the right user? " + _loggedInUser + " is logged in."); Debug.Log(message); onCompletion(false, null); })); return(true); // TODO remove }
public void Initialize(GoBoard goBoard, Color playerToMove, SearchOptions searchOptions, OnCompletion onCompletion) { lock (this) { SearchStatus = new SearchStatus(); SearchStatus.BoardSize = goBoard.BoardSize; Status = SearchStatusType.Thinking; UpdateStatus(); UpdateStatusFlag = true; StopThinkingFlag = false; SearchOptions = searchOptions.Clone(); NodesSearched = NodesEvaluated = 0; CheckSuperKo = searchOptions.CheckSuperKo; OnCompletion = onCompletion; SearchInterface.Initialize(goBoard, SearchOptions); Board = goBoard; PlayerToMove = playerToMove; } }
public static extern void sendMessageToPeerWithOptions(string msg, string userId, SendMessageOptions options, OnCompletion callback);
public static extern void logout(OnCompletion onDone);
public static extern void sendMessageToPeer(string msg, string userId, OnCompletion onDone);
public new void Initialize(GoBoard goBoard, Color playerToMove, SearchOptions searchOptions, OnCompletion onCompletion) { base.Initialize(goBoard, playerToMove, searchOptions, onCompletion); // setup distributed search coordinator & initialize workers if (NagCoordinator == null) { NagCoordinator = new NagCoordinator(9999, SearchOptions.PatternDetector.Patterns); // default port } NagCoordinator.SetNagCallBack(SetNag); NagCoordinator.Initialize(goBoard); if (TranspositionTable == null) { TranspositionTablePrimary = new TranspositionTablePlus(SearchOptions.TranspositionTableSize); } else if (TranspositionTable.Size != SearchOptions.TranspositionTableSize) { TranspositionTablePrimary = new TranspositionTablePlus(SearchOptions.TranspositionTableSize); } if (TranspositionTableEndGame == null) { TranspositionTableEndGame = new TranspositionTablePlus(1024 * 1024); } TranspositionTable = TranspositionTablePrimary; }
public static extern void loginByToken(string token, string userId, OnCompletion onDone);
public new void Initialize(GoBoard goBoard, Color playerToMove, SearchOptions searchOptions, OnCompletion onCompletion) { base.Initialize(goBoard, playerToMove, searchOptions, onCompletion); if (TranspositionTable == null) { TranspositionTablePrimary = new TranspositionTable(SearchOptions.TranspositionTableSize); } else if (TranspositionTable.Size != SearchOptions.TranspositionTableSize) { TranspositionTablePrimary = new TranspositionTable(SearchOptions.TranspositionTableSize); } if (TranspositionTableEndGame == null) { TranspositionTableEndGame = new TranspositionTable(1024 * 1024); } TranspositionTable = TranspositionTablePrimary; }
protected override void CleanUp() { Data?.CompleteAdding(); OnCompletion?.Invoke(); NLogFinish(); }
public static extern string unsubscribePeersOnlineStatus(string[] peerIds, int count, OnCompletion callback);
public void Wait() { TargetAction.Completion.Wait(); OnCompletion?.Invoke(); NLogFinish(); }
protected virtual void CleanUp() { OnCompletion?.Invoke(); NLogFinish(); }
private void CleanUp() { CloseStreamsAction?.Invoke(); OnCompletion?.Invoke(); NLogFinish(); }
public new void Initialize(GoBoard goBoard, Color playerToMove, SearchOptions searchOptions, OnCompletion onCompletion) { base.Initialize(goBoard, playerToMove, searchOptions, onCompletion); // setup distributed search coordinator & initialize workers if (NagCoordinator == null) NagCoordinator = new NagCoordinator(9999, SearchOptions.PatternDetector.Patterns); // default port NagCoordinator.SetNagCallBack(SetNag); NagCoordinator.Initialize(goBoard); if (TranspositionTable == null) TranspositionTablePrimary = new TranspositionTablePlus(SearchOptions.TranspositionTableSize); else if (TranspositionTable.Size != SearchOptions.TranspositionTableSize) TranspositionTablePrimary = new TranspositionTablePlus(SearchOptions.TranspositionTableSize); if (TranspositionTableEndGame == null) TranspositionTableEndGame = new TranspositionTablePlus(1024 * 1024); TranspositionTable = TranspositionTablePrimary; }
public void Create( object masterView, bool scaleImage, RectangleF frame, OnCompletion onCompletion ) { View = PlatformView.Create( ); View.BackgroundColor = ControlStylingConfig.BackgroundColor; View.Frame = frame; View.AddAsSubview( masterView ); Credits = new List<Credit>(); Credits.Add( new Credit( "Hey you found me! I'm Jered, the mobile app developer here at CCV. Making this app was a ton of work, and couldn't have happened without the support of a ton of people!\n\nThanks so much to:\n" + "Jenni, my beautiful wife and very patient app tester!\n\n" + "Jon & David, for developing this app's backbone, Rock.\n\n" + "Mason & Mike for testing, end points, and endless puns! (See what I did there?)\n\n" + "Nick & Kyle for all the great artwork and design you see in this app.\n\n" + "Dan & Kris Simpson for HUGE feedback, testing, and movie nights!!\n\n" + "The IT boyz: Jim, `Stopher and Chris, for being extremely willing Android guinea pigs.\n\n" + "Matt, Emily, Robin, Jill and Bree, for their testing and feedback.\n\n\n" + "And thanks of course to all of you out there using the app and making CCV the awesome church that it is!", "me.png", scaleImage, frame, View ) ); CloseButton = PlatformButton.Create( ); CloseButton.AddAsSubview( View.PlatformNativeObject ); CloseButton.Text = "Got It!"; CloseButton.BackgroundColor = PrayerConfig.PrayedForColor; CloseButton.TextColor = ControlStylingConfig.Button_TextColor; CloseButton.CornerRadius = ControlStylingConfig.Button_CornerRadius; CloseButton.SizeToFit( ); CloseButton.ClickEvent = delegate(PlatformButton button) { OnCompletionCallback( ); }; OnCompletionCallback = onCompletion; }
public void Create( object masterView, bool scaleImage, string imageName, RectangleF frame, OnCompletion onCompletion ) { View = PlatformView.Create( ); View.BackgroundColor = ControlStylingConfig.BackgroundColor; View.Frame = frame; View.AddAsSubview( masterView ); MemoryStream logoStream = Rock.Mobile.IO.AssetConvert.AssetToStream( imageName ); logoStream.Position = 0; PonyImage = PlatformImageView.Create( scaleImage ); PonyImage.AddAsSubview( View.PlatformNativeObject ); PonyImage.Image = logoStream; PonyImage.SizeToFit( ); PonyImage.ImageScaleType = PlatformImageView.ScaleType.ScaleAspectFit; logoStream.Dispose( ); CloseButton = PlatformButton.Create( ); CloseButton.AddAsSubview( View.PlatformNativeObject ); CloseButton.Text = "Prance! Dance! It's Magic Pony Time!"; CloseButton.BackgroundColor = PrayerConfig.PrayedForColor; CloseButton.TextColor = ControlStylingConfig.Button_TextColor; CloseButton.CornerRadius = ControlStylingConfig.Button_CornerRadius; CloseButton.SizeToFit( ); CloseButton.ClickEvent = delegate(PlatformButton button) { OnCompletionCallback( ); }; OnCompletionCallback = onCompletion; }
public void Start(GoBoard goBoard, Color playerToMove, SearchOptions searchOptions, SearchMethodType searchMethodType, OnCompletion onCompletion) { // stop existing search, if any if (SearchInterface != null) { Stop(); } if (SearchMethodType != searchMethodType) { SearchMethodType = searchMethodType; SearchInterface = SearchMethodFactory.CreateFactory(searchMethodType); } // make a private copy of the board Board = goBoard.Clone(); // make a private copy of the search options SearchOptions = searchOptions.Clone(); // set player to move PlayerToMove = playerToMove; // set the Nag Coordinator SearchInterface.SetNagCoordinator(NagCoordinator); // initialize the search parameters SearchInterface.Initialize(Board, PlayerToMove, SearchOptions, onCompletion); // start search SearchThread = new Thread(this.StartThread); SearchThread.Start(); }
protected override void CleanUp() { CloseStreamsAction?.Invoke(); OnCompletion?.Invoke(); NLogFinish(); }