/// <summary> /// /// </summary> public MainWindowViewModel() { // Initialize InitializeCommand = new DelegateCommand(() => { User = new User() { Name = "yamada taro", }; Message = "Hello"; Text = "Wpf 導入ツール"; }); // Change User ChangeUserCommand = new ChangeUserCommand(this); // get text GetTextCommand = new GetTextCommand(this); // get text delaegate GetTextDelegateCommand = new DelegateCommand(() => { MessageBox.Show(this.Text); }, () => { return(!string.IsNullOrEmpty(this.Text)); }); }
private bool TryGetTextFromAutomationIdentifier(AutomationIdentifier controlIdentifier, out string text, int ordinal, AutomationIdentifier parentIdentifier) { text = null; var command = new GetTextCommand { AutomationIdentifier = controlIdentifier, Ordinal = ordinal, ParentIdentifier = parentIdentifier }; var result = SyncExecuteCommand(command); var successResult = result as SuccessResult; if (successResult == null) { return(false); } text = successResult.ResultText; return(true); }
private bool TryGetTextFromAutomationIdentifier(AutomationIdentifier automationIdentifier, out string text) { text = null; var command = new GetTextCommand() { AutomationIdentifier = automationIdentifier }; var result = SyncExecuteCommand(command); var successResult = result as SuccessResult; if (successResult == null) return false; text = successResult.ResultText; return true; }
private bool TryGetTextFromAutomationIdentifier(AutomationIdentifier controlIdentifier, out string text, int ordinal, AutomationIdentifier parentIdentifier) { text = null; var command = new GetTextCommand { AutomationIdentifier = controlIdentifier, Ordinal = ordinal, ParentIdentifier = parentIdentifier }; var result = SyncExecuteCommand(command); var successResult = result as SuccessResult; if (successResult == null) { return false; } text = successResult.ResultText; return true; }
public void ClientSocketHandlerDidReadMessage(AltClientSocketHandler handler, string message) { string[] separator = new string[] { requestSeparatorString }; string[] pieces = message.Split(separator, System.StringSplitOptions.None); AltUnityComponent altComponent; AltUnityObject altUnityObject; string methodParameters; UnityEngine.Vector2 size; PLayerPrefKeyType option; Command command = null; try { switch (pieces[0]) { case "findAllObjects": methodParameters = pieces[1] + requestSeparatorString + pieces[2]; command = new FindAllObjectsCommand(methodParameters); break; case "findObjectByName": methodParameters = pieces[1] + requestSeparatorString + pieces[2] + requestSeparatorString + pieces[3]; command = new FindObjectByNameCommand(methodParameters); break; case "findObjectWhereNameContains": methodParameters = pieces[1] + requestSeparatorString + pieces[2] + requestSeparatorString + pieces[3]; command = new FindObjectWhereNameContainsCommand(methodParameters); break; case "tapObject": altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[1]); command = new TapCommand(altUnityObject); break; case "findObjectsByName": methodParameters = pieces[1] + requestSeparatorString + pieces[2] + requestSeparatorString + pieces[3]; command = new FindObjectsByNameCommand(methodParameters); break; case "findObjectsWhereNameContains": methodParameters = pieces[1] + requestSeparatorString + pieces[2] + requestSeparatorString + pieces[3]; command = new FindObjectsWhereNameContainsCommand(methodParameters); break; case "getCurrentScene": command = new GetCurrentSceneCommand(); break; case "findObjectByComponent": methodParameters = pieces[1] + requestSeparatorString + pieces[2] + requestSeparatorString + pieces[3] + requestSeparatorString + pieces[4]; command = new FindObjectByComponentCommand(methodParameters); break; case "findObjectsByComponent": methodParameters = pieces[1] + requestSeparatorString + pieces[2] + requestSeparatorString + pieces[3] + requestSeparatorString + pieces[4]; command = new FindObjectsByComponentCommand(methodParameters); break; case "getObjectComponentProperty": command = new GetComponentPropertyCommand(pieces[1], pieces[2]); break; case "setObjectComponentProperty": command = new SetObjectComponentPropertyCommand(pieces[1], pieces[2], pieces[3]); break; case "callComponentMethodForObject": command = new CallComponentMethodForObjectCommand(pieces[1], pieces[2]); break; case "closeConnection": UnityEngine.Debug.Log("Socket connection closed!"); _socketServer.StartListeningForConnections(); break; case "clickEvent": altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[1]); command = new ClickEventCommand(altUnityObject); break; case "tapScreen": command = new ClickOnScreenAtXyCommand(pieces[1], pieces[2]); break; case "dragObject": UnityEngine.Vector2 positionVector2 = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector2>(pieces[1]); altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[2]); command = new DragObjectCommand(positionVector2, altUnityObject); break; case "dropObject": UnityEngine.Vector2 positionDropVector2 = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector2>(pieces[1]); altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[2]); command = new DropObjectCommand(positionDropVector2, altUnityObject); break; case "pointerUpFromObject": altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[1]); command = new PointerUpFromObjectCommand(altUnityObject); break; case "pointerDownFromObject": altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[1]); command = new PointerDownFromObjectCommand(altUnityObject); break; case "pointerEnterObject": altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[1]); command = new PointerEnterObjectCommand(altUnityObject); break; case "pointerExitObject": altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[1]); command = new PointerExitObjectCommand(altUnityObject); break; case "tilt": UnityEngine.Vector3 vector3 = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector3>(pieces[1]); command = new TiltCommand(vector3); break; case "movingTouch": UnityEngine.Vector2 start2 = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector2>(pieces[1]); UnityEngine.Vector2 end2 = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector2>(pieces[2]); command = new SetMovingTouchCommand(start2, end2, pieces[3]); break; case "loadScene": command = new Assets.AltUnityTester.AltUnityServer.Commands.LoadSceneCommand(pieces[1]); break; case "setTimeScale": float timeScale = Newtonsoft.Json.JsonConvert.DeserializeObject <float>(pieces[1]); command = new SetTimeScaleCommand(timeScale); break; case "getTimeScale": command = new GetTimeScaleCommand(); break; case "deletePlayerPref": command = new DeletePlayerPrefCommand(); break; case "deleteKeyPlayerPref": command = new DeleteKeyPlayerPrefCommand(pieces[1]); break; case "setKeyPlayerPref": option = (PLayerPrefKeyType)System.Enum.Parse(typeof(PLayerPrefKeyType), pieces[3]); command = new SetKeyPlayerPrefCommand(option, pieces[1], pieces[2]); break; case "getKeyPlayerPref": option = (PLayerPrefKeyType)System.Enum.Parse(typeof(PLayerPrefKeyType), pieces[2]); command = new GetKeyPlayerPrefCommand(option, pieces[1]); break; case "actionFinished": command = new ActionFinishedCommand(); break; case "getAllComponents": command = new GetAllComponentsCommand(pieces[1]); break; case "getAllFields": altComponent = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityComponent>(pieces[2]); command = new GetAllFieldsCommand(pieces[1], altComponent); break; case "getAllMethods": altComponent = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityComponent>(pieces[1]); command = new GetAllMethodsCommand(altComponent); break; case "getAllScenes": command = new GetAllScenesCommand(); break; case "getAllCameras": command = new GetAllCamerasCommand(); break; case "getScreenshot": size = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector2>(pieces[1]); command = new GetScreenshotCommand(size, handler); break; case "hightlightObjectScreenshot": var id = System.Convert.ToInt32(pieces[1]); size = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector2>(pieces[3]); command = new HighlightSelectedObjectCommand(id, pieces[2], size, handler); break; case "hightlightObjectFromCoordinatesScreenshot": var coordinates = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector2>(pieces[1]); size = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector2>(pieces[3]); command = new HightlightObjectFromCoordinatesCommand(coordinates, pieces[2], size, handler); break; case "pressKeyboardKey": var piece = pieces[1]; UnityEngine.KeyCode keycode = (UnityEngine.KeyCode)System.Enum.Parse(typeof(UnityEngine.KeyCode), piece); float power = Newtonsoft.Json.JsonConvert.DeserializeObject <float>(pieces[2]); float duration = Newtonsoft.Json.JsonConvert.DeserializeObject <float>(pieces[3]); command = new HoldButtonCommand(keycode, power, duration); break; case "moveMouse": UnityEngine.Vector2 location = Newtonsoft.Json.JsonConvert.DeserializeObject <UnityEngine.Vector2>(pieces[1]); duration = Newtonsoft.Json.JsonConvert.DeserializeObject <float>(pieces[2]); command = new MoveMouseCommand(location, duration); break; case "scrollMouse": var scrollValue = Newtonsoft.Json.JsonConvert.DeserializeObject <float>(pieces[1]); duration = Newtonsoft.Json.JsonConvert.DeserializeObject <float>(pieces[2]); command = new ScrollMouseCommand(scrollValue, duration); break; case "findObject": methodParameters = pieces[1] + requestSeparatorString + pieces[2] + requestSeparatorString + pieces[3]; command = new FindObjectCommand(methodParameters); break; case "findObjects": methodParameters = pieces[1] + requestSeparatorString + pieces[2] + requestSeparatorString + pieces[3]; command = new FindObjectsCommand(methodParameters); break; case "findActiveObjectByName": methodParameters = pieces[1] + requestSeparatorString + pieces[2] + requestSeparatorString + pieces[3]; command = new FindActiveObjectsByNameCommand(methodParameters); break; case "enableLogging": var enableLogging = bool.Parse(pieces[1]); command = new EnableLoggingCommand(enableLogging); break; case "getText": altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[1]); command = new GetTextCommand(altUnityObject); break; case "setText": altUnityObject = Newtonsoft.Json.JsonConvert.DeserializeObject <AltUnityObject>(pieces[1]); command = new SetTextCommand(altUnityObject, pieces[2]); break; case "getPNGScreenshot": command = new GetScreenshotPNGCommand(handler); break; default: command = new UnknowStringCommand(); break; } } catch (Newtonsoft.Json.JsonException exception) { UnityEngine.Debug.Log(exception); handler.SendResponse(errorCouldNotParseJsonString); } if (command != null) { command.SendResponse(handler); } }