private void DealWithF9(IntPtr activeWindow, Rect activeWindowRect) { if (positionMap.ContainsKey(activeWindow) && currentStateMap.ContainsKey(activeWindow) && ((CustomState)currentStateMap[activeWindow]).screenIndex == ScreenIndex.S4 && ((CustomState)currentStateMap[activeWindow]).state == FormWindowState.Maximized) { RestWindows(activeWindow); } else { MoveWindow(activeWindow, 3840, 0, 1920, 1040, true); ShowWindow(activeWindow, 3); CustomState cs = new CustomState(); cs.state = FormWindowState.Maximized; cs.screenIndex = ScreenIndex.S4; if (currentStateMap.ContainsKey(activeWindow)) { currentStateMap[activeWindow] = cs; } else { currentStateMap.Add(activeWindow, cs); } } }
public async Task BotStateMemoryScopeTest() { await CreateDialogContext(async (dc, ct) => { var dsm = dc.State as DialogStateManager; var storage = dc.Context.TurnState.Get <IStorage>(); var userState = dc.Context.TurnState.Get <UserState>(); var conversationState = dc.Context.TurnState.Get <ConversationState>(); var customState = new CustomState(storage); dc.Context.TurnState.Add(customState); var stateScopes = new (BotState State, MemoryScope Scope)[] { (userState, new UserMemoryScope()), (conversationState, new ConversationMemoryScope()), (customState, new BotStateMemoryScope <CustomState>("test")), }; foreach (var stateScope in stateScopes) { const string Name = "test-name"; const string Value = "test-value"; await stateScope.State.CreateProperty <string>(Name).SetAsync(dc.Context, Value, ct); var memory = stateScope.Scope.GetMemory(dc); Assert.AreEqual(Value, ObjectPath.GetPathValue <string>(memory, Name), "Memory scope should have correct value"); } }).StartTestAsync();
public async Task CustomStateTest() { var activities = TranscriptUtilities.GetFromTestContext(TestContext); var storage = new MemoryStorage(); TestAdapter adapter = new TestAdapter() .Use(new CustomState(storage)); var flow = new TestFlow(adapter, async(context) => { var(command, value) = GetCommandValue(context); switch (command) { case "delete": CustomState.Get(context).Value = null; break; case "set": CustomState.Get(context).Value = value; break; case "read": await context.SendActivityAsync($"value:{CustomState.Get(context).Value}"); break; default: await context.SendActivityAsync("bot message"); break; } }); await flow.Test(activities).StartTestAsync(); }
public void SetState(CustomState state) { _state = state; if (state == CustomState.End) { GetComponent <Animator>().SetBool("End", true); } }
protected override IParcelable OnSaveInstanceState() { var superState = base.OnSaveInstanceState(); var state = new CustomState(superState); state.progress = GetProgress(); state.max = mMax; state.min = mMin; return(base.OnSaveInstanceState()); }
internal void Reset() { if (state != null && state.Chatroom != Guid.Empty) { rooms.LeaveRoom(state.Chatroom); } state = new CustomState(); OnStateChanged(); }
public void Delete(CustomState customState) { customState.IsDeleted = true; foreach (var existingDetails in customState.Details) { DeleteDetail(existingDetails); } Save(customState); }
public async Task <CustomState> DeleteAsync(CustomState customState, CancellationToken cancellationToken = default(CancellationToken)) { customState.IsDeleted = true; foreach (var existingDetails in customState.Details) { await DeleteDetailAsync(existingDetails, cancellationToken); } return(await SaveAsync(customState, cancellationToken)); }
private static void CreateDefaultCustomStates(List <string> states, ConfigurationV2 configuration, string customeStateName, string expectedWorkItemState, Color customeStateColor) { if (states.Contains(expectedWorkItemState)) { var newState = new CustomState() { Color = customeStateColor, Name = customeStateName }; newState.WorkItemStates.Add(expectedWorkItemState); configuration.States.Add(newState); } }
public MainWindow() { InitializeComponent(); _stateMachine = new StateMachine(); _linearState = new LinearState(this, _stateMachine); _logState = new LogState(this, _stateMachine); _powerState = new PowerState(this, _stateMachine); _customState = new CustomState(this, _stateMachine); _stateMachine.Initialize(_linearState); ProcessingPopup.Visibility = Visibility.Hidden; }
// Update is called once per frame void Update() { if (nextState != null) { currentState = nextState; animationInstancing.Play(currentState.name, 0); nextState = null; } if (animationInstancing.percent >= 1) { SetNextState(currentState.nextName); } }
public CustomState Save(CustomState customState) { _customStateRepository.SaveOrUpdate(customState); _cacheProvider.Remove(string.Format(CacheKey, customState.DepartmentId)); _eventAggregator.SendMessage <DepartmentSettingsUpdateEvent>(new DepartmentSettingsUpdateEvent() { DepartmentId = customState.DepartmentId }); return(customState); }
public async Task <CustomState> SaveAsync(CustomState customState, CancellationToken cancellationToken = default(CancellationToken)) { var saved = await _customStateRepository.SaveOrUpdateAsync(customState, cancellationToken); _cacheProvider.Remove(string.Format(CacheKey, customState.DepartmentId)); _eventAggregator.SendMessage <DepartmentSettingsUpdateEvent>(new DepartmentSettingsUpdateEvent() { DepartmentId = customState.DepartmentId }); return(saved); }
private void RestWindows(IntPtr activeWindow) { if (positionMap.ContainsKey(activeWindow) && currentStateMap.ContainsKey(activeWindow)) { State ss = (State)positionMap[activeWindow]; ShowWindow(activeWindow, ss.state == FormWindowState.Normal ? 1 : 3); MoveWindow(activeWindow, ss.rect.X, ss.rect.Y, ss.rect.Width - ss.rect.X, ss.rect.Height - ss.rect.Y, true); ShowWindow(activeWindow, ss.state == FormWindowState.Normal ? 1 : 3); CustomState cs = new CustomState(); cs.state = ss.state; cs.screenIndex = ScreenIndex.NONE; currentStateMap[activeWindow] = cs; } }
public void SetNextState(string stateName) { if (string.IsNullOrEmpty(stateName) == false) { for (int i = 0; i < totalStates.Length; i++) { var state = totalStates[i]; if (state.name.Equals(stateName)) { nextState = state; } } } }
public CustomState Update(CustomState state, List <CustomStateDetail> details) { foreach (var existingDetails in state.Details) { DeleteDetail(existingDetails); } foreach (var detail in details) { state.Details.Add(detail); } return(Save(state)); }
public async Task <CustomState> UpdateAsync(CustomState state, List <CustomStateDetail> details, CancellationToken cancellationToken = default(CancellationToken)) { foreach (var existingDetails in state.Details) { await DeleteDetailAsync(existingDetails, cancellationToken); } foreach (var detail in details) { detail.CustomStateId = state.CustomStateId; state.Details.Add(detail); } return(await SaveAsync(state, cancellationToken)); }
public async Task CustomStateTest() { var testName = "CustomStateTest"; var activities = TranscriptUtilities.GetActivitiesFromFile(ClassName, testName); var storage = new MemoryStorage(); var customState = new CustomState(storage); var testProperty = customState.CreateProperty <CustomStateObject>("Test"); var adapter = new TestAdapter(TestAdapter.CreateConversation(testName)) .Use(new AutoSaveStateMiddleware(customState)); var flow = new TestFlow(adapter, async(context, cancellationToken) => { if (context.Activity.Type == ActivityTypes.Message) { var(command, value) = GetCommandValue(context); switch (command) { case "delete": await testProperty.DeleteAsync(context); break; case "set": { var data = await testProperty.GetAsync(context, () => new CustomStateObject()); data.Value = value; await testProperty.SetAsync(context, data); } break; case "read": { var data = await testProperty.GetAsync(context, () => new CustomStateObject()); await context.SendActivityAsync($"value:{data.Value}"); } break; default: await context.SendActivityAsync("bot message"); break; } } }); await flow.Test(activities).StartTestAsync(); }
public void GetStateFromAnimator() { #if UNITY_EDITOR var runtimeController = animator.runtimeAnimatorController; if (runtimeController == null) { Debug.LogErrorFormat("RuntimeAnimatorController must not be null."); return; } var controller = UnityEditor.AssetDatabase.LoadAssetAtPath <UnityEditor.Animations.AnimatorController>(UnityEditor.AssetDatabase.GetAssetPath(runtimeController)); if (controller == null) { Debug.LogErrorFormat("AnimatorController must not be null."); return; } var stateMachine = controller.layers[0].stateMachine; var states = stateMachine.states; if (stateMachine.defaultState != null && stateMachine.defaultState.motion != null) { defaultState = stateMachine.defaultState.motion.name; } totalStates = new CustomState[states.Length]; for (int i = 0; i < states.Length; i++) { var state = states[i]; if (state.state == null || state.state.motion == null) { continue; } var transitions = state.state.transitions; var newState = new CustomState(); newState.name = state.state.motion.name; if (transitions.Length > 0) { var nextState = transitions[0].destinationState; newState.nextName = nextState.motion.name; } totalStates[i] = newState; } #endif }
public async Task CustomStateTest() { var activities = TranscriptUtilities.GetFromTestContext(TestContext); var storage = new MemoryStorage(); var customState = new CustomState(storage); var testProperty = customState.CreateProperty <CustomStateObject>("Test", () => new CustomStateObject()); TestAdapter adapter = new TestAdapter() .Use(customState); var flow = new TestFlow(adapter, async(context) => { if (context.Activity.Type == ActivityTypes.Message) { var(command, value) = GetCommandValue(context); switch (command) { case "delete": await testProperty.DeleteAsync(context); break; case "set": { var data = await testProperty.GetAsync(context); data.Value = value; await testProperty.SetAsync(context, data); } break; case "read": { var data = await testProperty.GetAsync(context); await context.SendActivityAsync($"value:{data.Value}"); } break; default: await context.SendActivityAsync("bot message"); break; } } }); await flow.Test(activities).StartTestAsync(); }
//老的->S5->S6->老的 循环 private void DealWithF10(IntPtr activeWindow, Rect activeWindowRect) { if (positionMap.ContainsKey(activeWindow) && currentStateMap.ContainsKey(activeWindow) && ((CustomState)currentStateMap[activeWindow]).screenIndex == ScreenIndex.S6 && ((CustomState)currentStateMap[activeWindow]).state == FormWindowState.Normal) { RestWindows(activeWindow); } else if (positionMap.ContainsKey(activeWindow) && currentStateMap.ContainsKey(activeWindow) && ((CustomState)currentStateMap[activeWindow]).screenIndex == ScreenIndex.S5 && ((CustomState)currentStateMap[activeWindow]).state == FormWindowState.Normal) { ShowWindow(activeWindow, 1); MoveWindow(activeWindow, 960, 540, 1920, 1080, true); CustomState cs = new CustomState(); cs.state = FormWindowState.Normal; cs.screenIndex = ScreenIndex.S6; if (currentStateMap.ContainsKey(activeWindow)) { currentStateMap[activeWindow] = cs; } else { currentStateMap.Add(activeWindow, cs); } } else { ShowWindow(activeWindow, 1); MoveWindow(activeWindow, 0, 0, 3840, 2120, true); CustomState cs = new CustomState(); cs.state = FormWindowState.Normal; cs.screenIndex = ScreenIndex.S5; if (currentStateMap.ContainsKey(activeWindow)) { currentStateMap[activeWindow] = cs; } else { currentStateMap.Add(activeWindow, cs); } } }
public override int GetHashCode() { int hash = 1; if (CustomState.Length != 0) { hash ^= CustomState.GetHashCode(); } if (dataCase_ == DataOneofCase.GenericDialog) { hash ^= GenericDialog.GetHashCode(); } if (dataCase_ == DataOneofCase.Pause) { hash ^= Pause.GetHashCode(); } if (dataCase_ == DataOneofCase.AdviceOverlay) { hash ^= AdviceOverlay.GetHashCode(); } if (dataCase_ == DataOneofCase.AdviceInterjection) { hash ^= AdviceInterjection.GetHashCode(); } if (dataCase_ == DataOneofCase.ConversationInterjection) { hash ^= ConversationInterjection.GetHashCode(); } if (CallToActionAsset.Length != 0) { hash ^= CallToActionAsset.GetHashCode(); } if (CallToActionButtonIdentifier.Length != 0) { hash ^= CallToActionButtonIdentifier.GetHashCode(); } hash ^= (int)dataCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public CustomState GetActiveStaffingLevelsForDepartment(int departmentId) { CustomState state = null; var states = GetAllCustomStatesForDepartment(departmentId); if (states != null) { state = states.FirstOrDefault(x => x.DepartmentId == departmentId && x.IsDeleted == false && x.Type == (int)CustomStateTypes.Staffing); } if (state != null) { if (state.Details == null) { state.Details = new List <CustomStateDetail>(); } return(state); } return(null); }
protected virtual ConfigurationV5 CreateConfiguration() { var config = new ConfigurationV5(); config.BacklogItems.AddRange(new List <string> { "Requirement", "Bug" }); config.ChildItems.AddRange(new List <string> { "Task", "TestCase" }); config.ColumnSummaryFieldName = "Remaining Work"; config.RowSummaryFieldName = "Completed Work"; config.QueryId = Guid.NewGuid(); config.SortDirection = SortDirection.Descending; config.SortFieldName = "Priority"; config.HideColumnSummaryFieldName = true; config.WorkItemSize = WorkItemSize.Small; var stateA = new CustomState { Color = Colors.AliceBlue, Name = "Pending" }; stateA.WorkItemStates.Add("Proposed"); var stateB = new CustomState { Color = Colors.Navy, Name = "In Progress" }; stateB.WorkItemStates.Add("Active"); var stateC = new CustomState { Color = Colors.DarkRed, Name = "Done" }; stateC.WorkItemStates.Add("Resolved"); stateC.WorkItemStates.Add("Closed"); config.States.Add(stateA); config.States.Add(stateB); config.States.Add(stateC); return(config); }
public async Task <CustomState> GetActivePersonnelStateForDepartmentAsync(int departmentId) { CustomState state = null; var states = await GetAllCustomStatesForDepartmentAsync(departmentId); if (states != null) { state = states.FirstOrDefault(x => x.DepartmentId == departmentId && x.IsDeleted == false && x.Type == (int)CustomStateTypes.Personnel); } if (state != null) { if (state.Details == null) { state.Details = new List <CustomStateDetail>(); } return(state); } return(null); }
public MarketplaceScreen(CustomState customState) { this._customState = customState; this._customState.Listener = (IGameStateListener)this; }
public static void SetState( Stopwatch context, CustomState state ) { context.SetState(state); }
// Changing of scene to the custom battle scene. public void StartBattle(BattleUnit trainerUnit) { state = CustomState.Battle; CustomBattleSystem.Instance.gameObject.SetActive(true); CustomBattleSystem.Instance.StartBattle(trainerUnit); }
// Method to signal the end of the battle and setting the battle scene to false. public void EndBattle(bool won) { state = CustomState.End; CustomBattleSystem.Instance.gameObject.SetActive(false); }
private State AddState(IState state, State parentState = null) { State newState; switch (state) { case ParallelState parallelState: newState = new Parallel(stack, state.Name, new ParallelProps()); var branches = new List <IChainable>(); foreach (var childState in parallelState.States) { branches.Add(AddState(childState)); } (newState as Parallel).Branch(branches.ToArray()); break; case IMapState mapState: var firstStateOfMap = AddState(mapState.StartState); newState = new Map(stack, state.Name, new MapProps()).Iterator(firstStateOfMap); break; case IAmazonStateTask amazonState: var parameters = amazonState.Parameters; newState = new CustomState(stack, state.Name, new CustomStateProps { StateJson = new Dictionary <string, object> { { "Type", "Task" }, { "Resource", amazonState.Arn }, { "Parameters", parameters } } }); if (amazonState.ErrorHandlers.Any()) { //(newState as TaskStateBase).Add() } break; case SuccessState successState: newState = new Succeed(stack, state.Name, new SucceedProps { Comment = successState.Comment }); break; default: throw new NotSupportedException(state.GetType().Name); } if (parentState is null) { SMP.Definition = newState; } else { (parentState as INextable).Next(newState); } if (state is ITransitionalState transitionalState && transitionalState.NextState != null) { AddState(transitionalState.NextState, newState); } return(newState); }
public TextCommandPayload DetermineType(string message, CustomState customActions, CustomState customStates) { var payload = new TextCommandPayload(); payload.Type = TextCommandTypes.None; if (String.IsNullOrWhiteSpace(message)) { return(payload); } if (customActions != null && customActions.IsDeleted == false && customActions.GetActiveDetails() != null && customActions.GetActiveDetails().Any()) { int actionId = 0; if (int.TryParse(message.Trim(), out actionId)) { payload.Type = TextCommandTypes.CustomAction; payload.Data = actionId.ToString(); } } else { if (message.Trim().ToLower() == "responding" || message.Trim().ToLower() == "1") { payload.Type = TextCommandTypes.Action; payload.Data = ((int)ActionTypes.Responding).ToString(); } if (message.Trim().ToLower() == "notresponding" || message.Trim().ToLower() == "not responding" || message.Trim().ToLower() == "2") { payload.Type = TextCommandTypes.Action; payload.Data = ((int)ActionTypes.NotResponding).ToString(); } if (message.Trim().ToLower() == "onscene" || message.Trim().ToLower() == "on scene" || message.Trim().ToLower() == "3") { payload.Type = TextCommandTypes.Action; payload.Data = ((int)ActionTypes.OnScene).ToString(); } if (message.Trim().ToLower() == "standingby" || message.Trim().ToLower() == "4") { payload.Type = TextCommandTypes.Action; payload.Data = ((int)ActionTypes.StandingBy).ToString(); } } if (customStates != null && customStates.IsDeleted == false && customStates.GetActiveDetails() != null && customStates.GetActiveDetails().Any()) { if (message.Trim().ToLower()[0] == char.Parse("s")) { payload.Type = TextCommandTypes.CustomStaffing; payload.Data = message.Trim().ToLower().Replace("c", ""); } } else { if (message.Trim().ToLower() == "available" || message.Trim().ToLower() == "s1") { payload.Type = TextCommandTypes.Staffing; payload.Data = ((int)UserStateTypes.Available).ToString(); } if (message.Trim().ToLower() == "delayed" || message.Trim().ToLower() == "s2") { payload.Type = TextCommandTypes.Staffing; payload.Data = ((int)UserStateTypes.Delayed).ToString(); } if (message.Trim().ToLower() == "unavailable" || message.Trim().ToLower() == "s3") { payload.Type = TextCommandTypes.Staffing; payload.Data = ((int)UserStateTypes.Unavailable).ToString(); } if (message.Trim().ToLower() == "committed" || message.Trim().ToLower() == "s4") { payload.Type = TextCommandTypes.Staffing; payload.Data = ((int)UserStateTypes.Committed).ToString(); } if (message.Trim().ToLower() == "onshift" || message.Trim().ToLower() == "on shift" || message.Trim().ToLower() == "s5") { payload.Type = TextCommandTypes.Staffing; payload.Data = ((int)UserStateTypes.OnShift).ToString(); } } if (message.Trim().ToLower() == "help" || message.Trim().ToLower() == "info") { payload.Type = TextCommandTypes.Help; } // Wanting to stop recieving text messages if (message.Trim().ToLower() == "stop" || message.Trim().ToLower() == "end" || message.Trim().ToLower() == "quit" || message.Trim().ToLower() == "cancel" || message.Trim().ToLower() == "unsubscribe") { payload.Type = TextCommandTypes.Stop; } if (message.Trim().ToLower() == "calls") { payload.Type = TextCommandTypes.Calls; } if (message.Trim().ToLower() == "units") { payload.Type = TextCommandTypes.Units; } if (message.Trim().ToLower() == "status") { payload.Type = TextCommandTypes.MyStatus; } // Call Detail if (string.IsNullOrWhiteSpace(payload.Data)) { if (message.Trim().ToLower()[0] == char.Parse("c")) { payload.Type = TextCommandTypes.CallDetail; payload.Data = message.Trim().ToLower().Replace("c", ""); } } return(payload); }