예제 #1
0
 public Calc(double result, double argument, int dotFlag, int action)
 {
     this.result = result;
     this.argument = argument;
     this.dotFlag = dotFlag;
     this.action = (Core.Calc.Actions)action;
 }
예제 #2
0
        private double result; // variable to contain the result of calculation

        #endregion Fields

        #region Constructors

        public Calc()
        {
            result = 0.0;
            argument = 0.0;
            dotFlag = -1;			// -1 means than no decimal part is used
            action = Actions.Unknown;
        }
예제 #3
0
	void Initialize () {
		actions = character.GetComponent<Actions> ();
		controller = character.GetComponent<PlayerController> ();

		foreach (PlayerController.Arsenal a in controller.arsenal)
			CreateWeaponButton(a.name);

		CreateActionButton("Stay");
		CreateActionButton("Walk");
		CreateActionButton("Run");
		CreateActionButton("Sitting");
		CreateActionButton("Jump"); 
		CreateActionButton("Aiming");
		CreateActionButton("Attack");
		CreateActionButton("Damage");
		CreateActionButton("Death Reset", "Death");

		cameras = GameObject.FindObjectsOfType<Camera> ();
		var sort = from s in cameras orderby s.name select s;

		foreach (Camera c in sort)
			CreateCameraButton(c);

		camerasPanel.GetChild (0).GetComponent<Button>().onClick.Invoke();
	}
예제 #4
0
파일: MetaData.cs 프로젝트: PushkinTyt/Chat
 public MetaData(Roles role, Actions action, ContentTypes contentType, string message)
 {
     this.role = role;
     this.action = action;
     this.contentType = contentType;
     messageSize = encoding.GetByteCount(message);
 }
        // Violates rule: DoNotPassTypesByReference.
        public static bool ReplyInformation(TypeOfFeedback input, 
         out string reply, ref Actions action)
        {
            bool returnReply = false;
             string replyText = "Your feedback has been forwarded " +
                            "to the product manager.";

             reply = String.Empty;
             switch (input)
             {
            case TypeOfFeedback.Complaint:
            case TypeOfFeedback.Praise :
               action = Actions.ForwardToManagement;
               reply = "Thank you. " + replyText;
               returnReply = true;
               break;
            case TypeOfFeedback.Suggestion:
               action = Actions.ForwardToDeveloper;
               reply = replyText;
               returnReply = true;
               break;
            case TypeOfFeedback.Incomprehensible:
            default:
               action = Actions.Discard;
               returnReply = false;
               break;
             }
             return returnReply;
        }
예제 #6
0
 /**
  * Overload for Attack Action
  */
 public void Init(int type, int attackerId, int targetId)
 {
     actionType = (Actions)type;
     Debug.Log(actionType.ToString());
     this.unitId = attackerId;
     this.targetId = targetId;
 }
예제 #7
0
 void SetVisuals(Actions state)
 {
     string actionName = actionMap[currentState];
     foreach(Transform child in transform) {
         child.gameObject.SetActive(child.name == actionName);
     }
 }
예제 #8
0
 public Event(Triggers trigger, Actions action, string action_data = "")
 {
     Trigger = trigger;
     Action = action;
     ActionData = action_data;
     Active = false;
 }
예제 #9
0
        private Screensaver(Actions action, bool readOnly, IntPtr[] hwnds) {
            #if (DEBUG)
                this.debugLog = new List<string>();
            #endif
            
            this.version = new Version(Application.ProductVersion);
            this.readOnly = readOnly;
            this.action = action;
            this.hwnds = hwnds;
            this.config = new Config(this);
            this.config.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.PreviewKeyDown);
            this.config.browser.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.PreviewKeyDown);

            this.config.browser.Navigate(new Uri(Constants.getDataFolder(Constants.ConfigHtmlFile)));
            this.config.browser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.config.ConfigDocumentCompleted);
            if (this.action == Actions.Config) this.config.Show();
            else {
                if (this.action != Actions.Wallpaper) {
                    this.mouseMoveTimer = new System.Windows.Forms.Timer();
                    this.mouseMoveTimer.Interval = 1500;
                    this.mouseMoveTimer.Tick += mouseMoveTimer_Tick;
                }
            }
            // Wait for config document to load to complete initialisation: Config.ConfigDocumentCompleted()
        }
예제 #10
0
    public void test_wait_for_specific_action()
    {
        var timer = new Timer();
        var instance = new Actions(timer);
        var complete = false;
        var count = 0;

        // Run an action which doesn't resolved immediately
        var task = new DeferredAction();
        instance.Execute(task, (ep) =>
        {
            count += 1;
            complete = true;
        });
        Assert(complete == false);

        // Run some other action
        // Notice how all ActionCompleteEvents are skipped until the matching action.
        instance.Execute<SimpleAction>();
        instance.Execute<SimpleAction>();
        instance.Execute<SimpleAction>();
        Assert(count == 0);
        Assert(complete == false);

        // Now we fake the deferred completion, and correctly catch it
        task.Complete();
        Assert(count == 1);
        Assert(complete == true);
    }
예제 #11
0
파일: Kitchen.cs 프로젝트: MrJov/GGJ16
	public void SetActivePlayer(GameObject player){
		activePlayer = player;
		elapsedTime = 0f;
		action = ChangeAction (Random.Range (0, 4));
		action.buttonSequence.GetComponent<ShowButton> ().ShowNormal ();
		active = true;
	}
예제 #12
0
파일: Unit.cs 프로젝트: Quaade/SurvivalGame
 public Unit(int x, int y, int health)
     : base(x, y)
 {
     this.action = Actions.None;
     this.nextAction = Actions.None;
     this.speed = 3;
 }
예제 #13
0
파일: Actions.cs 프로젝트: angelcdz/Sirius
        internal Guid RetieveActionGuid(Actions action)
        {
            Guid returnValue = Guid.Empty;

            switch (action)
            {
                case Actions.PrSvDisableProductAc:
                    returnValue = new Guid("9d3eb947-466d-49aa-8a5f-bcb4593e402e");
                    break;
                case Actions.PrSvDisableServiceAc:
                    returnValue = new Guid("aa7fa958-dc74-463d-9ab9-341b8c3e04b2");
                    break;
                case Actions.PrSvEnableServiceAc:
                    returnValue = new Guid("43902389-9bb9-4a78-8814-4db50222a6aa");
                    break;
                case Actions.PrSvDisableTypedSaleAc:
                    returnValue = new Guid("7fc35b44-cab8-44fb-97b4-c95fa3afc23c");
                    break;
                case Actions.PrSvEnableTypedSaleAc:
                    returnValue = new Guid("81a13984-a7c4-4d90-b043-cd98930373bd");
                    break;
                case Actions.PrSvRateChengNegotiationRequestAc:
                    returnValue = new Guid("94d5a751-0094-4268-bf49-d2129d60ceb5");
                    break;
                case Actions.PrSvRequestLicenseAnalysisAc:
                    returnValue = new Guid("e34c98e3-5eca-44f5-a4b9-25c1e2815e32");
                    break;
            }

            return returnValue;
        }
예제 #14
0
파일: Actions.cs 프로젝트: zaully/guokrkill
 public static List<Actions> initialization(List<string> strLstActions, Status thisStat)
 {
     List<Character> chaLstCharacters = thisStat.chaLstCharacter;
     List<Spell> splLstAll = thisStat.splLstSpell;
     List<Actions> actLstResult = new List<Actions>();
     Regex rgSource = new Regex("{.*}");
     Regex rgSpell = new Regex("\\[\\[.*\\]\\]");
     Regex rgDestination = new Regex("->.*<-");
     string strTmp = "";
     for (int i = 0; i < strLstActions.Count; i++)
     {
         Actions actionItem = new Actions();
         strTmp = rgSource.Match(strLstActions[i]).ToString();
         strTmp = strTmp.Replace("{", "");
         actionItem.strCharacterName = strTmp.Replace("}", "");
         strTmp = rgSpell.Match(strLstActions[i]).ToString();
         strTmp = strTmp.Replace("[[", "");
         actionItem.strSpellName = strTmp.Replace("]]", "");
         strTmp = rgDestination.Match(strLstActions[i]).ToString();
         strTmp = strTmp.Replace("->", "");
         actionItem.intCharacter = Character.findIndexForCharacter(actionItem.strCharacterName, chaLstCharacters);
         strTmp = strTmp.Replace("<-", "");
         actionItem.intDestination = Character.findIndexForCharacter(strTmp, chaLstCharacters);
         actionItem.intResult = 0;
         actionItem.intTargetAvailable = Spell.isSpellTargetFixed(actionItem.strSpellName, splLstAll);
         actLstResult.Add(actionItem);
     }
     return actLstResult;
 }
예제 #15
0
 public DownloadForm(Dictionary<string, string> files, Actions action)
 {
     InitializeComponent();
     this.files = files;
     this.action = action;
     numFiles = files.Count;
 }
예제 #16
0
 public Player(string Name, char Sign, int Moves = 0, int NextMove = 0, Actions Action = Actions.Play)
 {
     this.Name = Name;
     this.Sign = Sign;
     this.Moves = Moves;
     this.NextMove = NextMove;
     this.Action = Action;
 }
예제 #17
0
 public void setAction(Actions _val)
 {
     if (!Constant.moveEnabled) {
         mAction = Actions.IDLE;
         return;
     }
     mAction = _val;
 }
예제 #18
0
 public void AddAction(Actions action, object[] attribute)
 {
     _currentActions.Add(new ReverseActionValue()
     {
         _PerformedAction = action,
         _ActionAttribute = attribute
     });
 }
예제 #19
0
        public InputDate(MainDGV dgvMain, Actions action, WayBillType type)
        {
            InitializeComponent();

            _dgvMain = dgvMain;
            _action = action;
            _type = type;
        }
예제 #20
0
 public Player(Player p, Actions Action = Actions.Play)
 {
     this.Name = p.Name;
     this.Moves = p.Moves;
     this.Sign = p.Sign;
     this.NextMove = p.NextMove;
     this.Action = Action;
 }
		/// <summary>
		/// Führt die angegebene Operation aus
		/// </summary>
		/// <param name="ac">Die auszuführende Aktion</param>
		private void DoVerb(Actions ac)
		{
			//controls feststellen
			_owner = _ctl.Owner;
			if (_owner == null)
				return;
			//designer vorbereiten
			IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
			IComponentChangeService chan = (IComponentChangeService)GetService(typeof(IComponentChangeService));
			//rückgängig-aktion anzigen
			DesignerTransaction t = host.CreateTransaction("Item Op");
			//markierungs-service
			ISelectionService sel = (ISelectionService)this.GetService(typeof(ISelectionService));
			using (t)
			{
				//komponentenänderung einleiten
				chan.OnComponentChanging(_owner, null);
				switch (ac)
				{
					case Actions.moveup:
					{
						//control um eine position nach links verschieben
						_owner.Buttons.Move(_ctl, -1);
						break;
					}
					case Actions.movedown:
					{
						//control um eine position nach rechts verschieben
						_owner.Buttons.Move(_ctl, +1);
						break;
					}
					case Actions.delete:
					{
						/*
						//der entwurfszeitinstanz den button entreißen
						//geht jetzt über den destruktor
						_owner.Buttons.Remove(_ctl);*/

						//neue markierung setzen
						ArrayList arr = new ArrayList();
						arr.Add(_owner);
						sel.SetSelectedComponents(arr, SelectionTypes.Replace);
						//die komponente zerstören
						host.DestroyComponent(_ctl);
						break;
					}
					case Actions.updateparent:
					{
						break;
					}
				}
				//komponentenänderung anzeigen
				chan.OnComponentChanged(_owner, null, null, null);
				t.Commit();
			}
			_owner.Refresh();
		}
예제 #22
0
 public Ferry()
 {
     FerryThread = new Thread(new ThreadStart(MoveFerry));
     Coast = CoastEnum.WestCoast;
     _ferryAction = Actions.FerryWait;
     Cars = new Stack<Car>();
     _timer = new Stopwatch();
     _timer.Start();
 }
예제 #23
0
 public void PerformAction(Actions action)
 {
     switch (action)
     {
         case Actions.StartTimer:
             game.objectiveManager.Countdown(3);
             break;
         case Actions.ResetTimer:
             game.objectiveManager.Reset();
             break;
         case Actions.Open:
             Thread openThread = new Thread(DoOpen);
             openThread.SetApartmentState(ApartmentState.STA);
             openThread.Start();
             break;
         case Actions.Reload:
             Thread reloadThread = new Thread(DoReload);
             reloadThread.SetApartmentState(ApartmentState.STA);
             reloadThread.Start();
             break;
         case Actions.Save:
             Thread saveThread = new Thread(DoSave);
             saveThread.SetApartmentState(ApartmentState.STA);
             saveThread.Start();
             break;
         case Actions.PropertyEditor:
             FormManager.Property.Show();
             break;
         case Actions.Copy:
             FormManager.Property.CopySelected();
             break;
         case Actions.Delete:
             KinectRagdollGame.pendingUpdates.Add(delegate() { FormManager.Property.DeleteSelected(); });
             break;
         case Actions.Freeze:
             KinectRagdollGame.pendingUpdates.Add(delegate() { FormManager.Property.FreezeSelected(); });
             break;
         case Actions.Release:
             KinectRagdollGame.pendingUpdates.Add(delegate() { FormManager.Property.UnfreezeSelected(); });
             break;
         case Actions.ToggleCamera:
             game.ragdollManager.CameraShouldTrack = !game.ragdollManager.CameraShouldTrack;
             break;
         case Actions.PowerupEditor:
             object[] selection = FormManager.Property.getSelectedObjects();
             if (selection.Length > 0)
             {
                 PowerupForm p = new PowerupForm();
                 p.Show(selection);
             }
             
             break;
         case Actions.ToggleFullScreen:
             game.ToggleFullscreen();
             break;
     }
 }
예제 #24
0
파일: Actions.cs 프로젝트: angelcdz/Sirius
 public void EnableAction(Actions action)
 {
     _service.Execute(new SetStateRequest()
             {
                 EntityMoniker = new EntityReference(Workflow.EntityLogicalName, RetieveActionGuid(action)),
                 State = new OptionSetValue((int) WorkflowState.Activated),
                 Status = new OptionSetValue((int) ActionStatus.Activated)
             });
 }
예제 #25
0
        public ImagePreviewer(Actions a, string url, string filePath) : base(a, filePath)
        {
            InitializeComponent();

            uiURLTextBox.Text = url;
            FormClosing += ImagePrevEx_FormClosing;
            Url = url;
            //this.filePath = filePath;

        }
 private Node(ulong num, Node parent, Actions action)
 {
     //We're only finding one solution, so just return and call it a day.
     if (solutionLeafs.Count > 0 && findOne)
        return;
     Action = action;
     this.parent = parent;
     this.num = num;
     buildSolutions();
 }
        public ActionResult Details(object id, DetailsViewModel model, Actions formAction = Actions.ViewDetail)
        {
            switch (formAction)
            {
                case Actions.ViewDetail:
                    var user = _providerMembership.GetUserByGuid(Guid.Parse((string)id), false).Data;
                    var userRoles = _providerRoles.FindByUserName(user.UserName);

                    model = new DetailsViewModel()
                    {
                        UserOriginal = user,
                        UserUpdated = user,
                        UserRoles = userRoles.Data,
                        Roles = _providerRoles.FindAll().Data
                    };
                    break;
                case Actions.Approve:
                    model = this.Details_ChangeAproval(model, model.UserOriginal, true);
                    break;
                case Actions.UnApprove:
                    model = this.Details_ChangeAproval(model, model.UserOriginal, false);
                    break;
                case Actions.UnLock:
                    model = this.Details_UnLock(model, model.UserOriginal, formAction);
                    break;
                case Actions.Delete:
                    DataResultBoolean result = _providerMembership.DeleteUser(model.UserOriginal.UserName, true);
                    if (result.Data)
                    {
                        return Redirect(UrlHelperUserAdmin.UserAdminIndex(Url));
                    }
                    else
                    {
                        ModelState.AddModelError(formAction.ToString(), result.Message);
                    }
                    break;
                case Actions.Update:
                    //update roles
                    this.Details_UpdateRoles(model, Actions.Update);
                    //update comment
                    model.UserOriginal.Comment = model.UserUpdated.Comment;
                    model = this.Details_Update(model, model.UserOriginal, formAction);
                    break;
                default:
                    break;
            }

            model.BaseViewModelInfo.Title = GeneralTexts.UserAdmin;
            model.BaseViewModelInfo.Breadcrumb.IsVisible = true;
            model.BaseViewModelInfo.Breadcrumb.BreadcrumbPaths.AddRange(new List<KeyValuePair<string, string>>() {
                new KeyValuePair<string, string>(UserAdminTexts.UserSearch, Url.UserAdminIndex())
            });

            return View(model);
        }
예제 #28
0
        public void AddAction(Actions action, object attribute)
        {
            _currentActions.Add(new ReverseActionValue()
                {
                    _PerformedAction = action,
                    _ActionAttribute = attribute
                });

            if (attribute is string)
                log.DebugFormat("Inserted rollback action {0} with attribute {1} in the event of failure", action.ToString(), attribute.ToString());
        }
예제 #29
0
 public ParserEventArgs(
     Actions p1,
     Char p2,
     String p3,
     uc_Params p4)
 {
     this.Action = p1;
     this.CurChar = p2;
     this.CurSequence = p3;
     this.CurParams = p4;
 }
예제 #30
0
        public void updateView(Actions.Action.UpdateViewType layerUpdateType)
        {
            // check if we must recreate the whole list
            if (layerUpdateType == Actions.Action.UpdateViewType.FULL)
            {
                // first suspend the layout because we will recreate the full layout
                this.SuspendLayout();
                this.Visible = false;
                // clear the layer stack and refill it with the map layer list
                this.Controls.Clear();
                // recreate all the layer from the map
                // we create a new panel to handle this layer
                foreach (Layer layer in Map.Instance.LayerList)
                {
                    // instanciate a new layer panel according to the layer type
                    LayerPanel newLayerPanel = null;
                    if (layer is LayerGrid)
                        newLayerPanel = new LayerGridPanel(layer);
                    else if (layer is LayerText)
                        newLayerPanel = new LayerTextPanel(layer);
                    else if (layer is LayerArea)
                        newLayerPanel = new LayerAreaPanel(layer);
                    else if (layer is LayerBrick)
                        newLayerPanel = new LayerBrickPanel(layer);
                    else if (layer is LayerRuler)
                        newLayerPanel = new LayerRulerPanel(layer);

                    // add the new layer in the control list
                    this.Controls.Add(newLayerPanel);

                    // if the selected layer of the map is the current one,
                    // use the last added layerPanel as the selected layer panel
                    if (Map.Instance.SelectedLayer == layer)
                        newLayerPanel.changeBackColor(true);
                }

                // now we can resume the layout
                this.ResumeLayout(true);
                this.Visible = true;
            }
            else
            {
                // not a full update, just check the property of the layers,
                // but the layout is unchanged
                foreach (Control control in this.Controls)
                {
                    LayerPanel layerPanel = control as LayerPanel;
                    layerPanel.updateView();
                }
            }

            // invalidate the PanelView because we recreated the whole layer panel list
            this.Invalidate();
        }
예제 #31
0
 public override Widget build(BuildContext context)
 {
     return(new StoreConnector <AppState, ArticlesScreenViewModel>(
                converter: state => {
         var currentUserId = state.loginState.loginInfo.userId ?? "";
         var followArticleIds = state.articleState.followArticleIdDict.ContainsKey(key: currentUserId)
                 ? state.articleState.followArticleIdDict[key: currentUserId]
                 : new List <string>();
         var hotArticleIds = state.articleState.hotArticleIdDict.ContainsKey(key: currentUserId)
                 ? state.articleState.hotArticleIdDict[key: currentUserId]
                 : new List <string>();
         var user = state.userState.userDict.ContainsKey(key: currentUserId)
                 ? state.userState.userDict[key: currentUserId]
                 : new User();
         var followings = user.followings ?? new List <Following>();
         var likeMap = state.likeState.likeDict.ContainsKey(key: currentUserId)
                 ? state.likeState.likeDict[key: currentUserId]
                 : new Dictionary <string, bool>();
         var followMap = state.followState.followDict.ContainsKey(key: currentUserId)
                 ? state.followState.followDict[key: currentUserId]
                 : new Dictionary <string, bool>();
         return new ArticlesScreenViewModel {
             followArticlesLoading = state.articleState.followArticlesLoading,
             followingLoading = state.userState.followingLoading,
             followArticleIds = followArticleIds,
             hotArticleIds = hotArticleIds,
             followings = followings,
             blockArticleList = state.articleState.blockArticleList,
             followArticleHasMore = state.articleState.followArticleHasMore,
             hotArticleHasMore = state.articleState.hotArticleHasMore,
             articleDict = state.articleState.articleDict,
             userDict = state.userState.userDict,
             teamDict = state.teamState.teamDict,
             likeMap = likeMap,
             followMap = followMap,
             isLoggedIn = state.loginState.isLoggedIn,
             currentUserId = state.loginState.loginInfo.userId ?? ""
         };
     },
                builder: (context1, viewModel, dispatcher) => {
         var actionModel = new ArticlesScreenActionModel {
             pushToLogin = () => dispatcher.dispatch(new MainNavigatorPushToAction {
                 routeName = MainNavigatorRoutes.Login
             }),
             pushToArticleDetail = id => dispatcher.dispatch(
                 new MainNavigatorPushToArticleDetailAction {
                 articleId = id
             }
                 ),
             pushToReport = (reportId, reportType) => dispatcher.dispatch(
                 new MainNavigatorPushToReportAction {
                 reportId = reportId,
                 reportType = reportType
             }
                 ),
             pushToBlock = articleId => {
                 dispatcher.dispatch(new BlockArticleAction {
                     articleId = articleId
                 });
                 dispatcher.dispatch(new DeleteArticleHistoryAction {
                     articleId = articleId
                 });
             },
             pushToUserFollowing = userId => dispatcher.dispatch(
                 new MainNavigatorPushToUserFollowingAction {
                 userId = userId
             }
                 ),
             pushToUserDetail = userId => dispatcher.dispatch(
                 new MainNavigatorPushToUserDetailAction {
                 userId = userId
             }
                 ),
             pushToTeamDetail = teamId => dispatcher.dispatch(
                 new MainNavigatorPushToTeamDetailAction {
                 teamId = teamId
             }
                 ),
             startFollowUser = userId =>
                               dispatcher.dispatch(new StartFetchFollowUserAction {
                 followUserId = userId
             }),
             followUser = userId => dispatcher.dispatch <IPromise>(Actions.fetchFollowUser(userId)),
             startUnFollowUser = userId =>
                                 dispatcher.dispatch(new StartFetchUnFollowUserAction {
                 unFollowUserId = userId
             }),
             unFollowUser = userId => dispatcher.dispatch <IPromise>(Actions.fetchUnFollowUser(userId)),
             startFollowTeam = teamId =>
                               dispatcher.dispatch(new StartFetchFollowTeamAction {
                 followTeamId = teamId
             }),
             followTeam = teamId => dispatcher.dispatch <IPromise>(Actions.fetchFollowTeam(teamId)),
             startUnFollowTeam = teamId =>
                                 dispatcher.dispatch(new StartFetchUnFollowTeamAction {
                 unFollowTeamId = teamId
             }),
             unFollowTeam = teamId => dispatcher.dispatch <IPromise>(Actions.fetchUnFollowTeam(teamId)),
             sendComment = (articleId, channelId, content, nonce, parentMessageId) => {
                 CustomDialogUtils.showCustomDialog(child: new CustomLoadingDialog());
                 return dispatcher.dispatch <IPromise>(
                     Actions.sendComment(articleId, channelId, content, nonce, parentMessageId));
             },
             likeArticle = articleId => dispatcher.dispatch <IPromise>(Actions.likeArticle(articleId)),
             startFetchFollowing = () => dispatcher.dispatch(new StartFetchFollowingAction()),
             fetchFollowing = offset =>
                              dispatcher.dispatch <IPromise>(Actions.fetchFollowing(viewModel.currentUserId, offset)),
             startFetchFollowArticles = () => dispatcher.dispatch(new StartFetchFollowArticlesAction()),
             fetchFollowArticles = pageNumber =>
                                   dispatcher.dispatch <IPromise>(Actions.fetchFollowArticles(pageNumber)),
             shareToWechat = (type, title, description, linkUrl, imageUrl) => dispatcher.dispatch <IPromise>(
                 Actions.shareToWechat(type, title, description, linkUrl, imageUrl))
         };
         return new FollowArticleScreen(viewModel, actionModel);
     }
                ));
 }
        public void pages_can_be_navigated_by_clicking_on_links()
        {
            // selecting and clicking on image, taking us to detail page
            Thread.Sleep(SlowDownTwo);
            IWebElement parkLink = webDriver.FindElement(By.XPath("//*[@id=\"x1\"]/div[1]/a/img"));

            parkLink.Click();
            Thread.Sleep(SlowDownTwo);

            Assert.IsNotNull(parkLink);
            IWebElement detailH2 = webDriver.FindElement(By.TagName("h2"));

            Assert.AreEqual("Detail", detailH2.Text);

            // on detail page scrolling down to quick facts
            IWebElement scrollToFacts = webDriver.FindElement(By.ClassName("facts-headline"));
            Actions     scrollDown    = new Actions(webDriver);

            scrollDown.MoveToElement(scrollToFacts);
            scrollDown.Perform();
            Thread.Sleep(SlowDownTwo);

            Assert.AreEqual("Quick Facts", scrollToFacts.Text);

            // scrolling down to weather from quick facts
            IWebElement scrollToWeather = webDriver.FindElement(By.ClassName("tile-weather-small"));

            scrollDown.MoveToElement(scrollToWeather);
            scrollDown.Perform();
            Thread.Sleep(SlowDownTwo);

            // going back to home from button home in nav bar
            IWebElement homeLink = webDriver.FindElement(By.XPath("/html/body/nav/div/div[2]/ul/li[1]/a"));

            homeLink.Click();
            Thread.Sleep(SlowDownTwo);

            // going to survey from home via survey button in nav bar
            IWebElement surveyLink = webDriver.FindElement(By.XPath("/html/body/nav/div/div[2]/ul/li[2]/a"));

            surveyLink.Click();
            Thread.Sleep(SlowDownTwo);

            // enter email in survey
            IWebElement surveyEmail = webDriver.FindElement(By.XPath("//*[@id=\"email\"]"));

            surveyEmail.SendKeys("*****@*****.**");
            Thread.Sleep(SlowDownTwo);

            // clicking on park drop down
            IWebElement parkDrop = webDriver.FindElement(By.XPath("//*[@id=\"park-selection\"]"));

            parkDrop.Click();
            Thread.Sleep(SlowDownOne);

            // selecting park from dropdown
            SelectElement parkSelection = new SelectElement(webDriver.FindElement(By.Id("park-selection")));

            parkSelection.SelectByText("Glacier National Park");
            Thread.Sleep(SlowDownOne);

            // clicking on state dropdown
            IWebElement residenceDrop = webDriver.FindElement(By.XPath("//*[@id=\"state-selection\"]"));

            residenceDrop.Click();
            Thread.Sleep(SlowDownOne);

            // selecting state from dropdown
            SelectElement residenceSelection = new SelectElement(webDriver.FindElement(By.Id("state-selection")));

            residenceSelection.SelectByText("Pennsylvania");
            Thread.Sleep(SlowDownTwo);

            // Assert - testing dropdown for activity level
            List <string> activityDropDown = new List <string>()
            {
                "Inactive", "Sedentary", "Active", "Extremely Active"
            };
            IList <IWebElement> activityDropDownList = webDriver.FindElements(By.CssSelector("#activity-selection"));

            foreach (IWebElement i in activityDropDownList)
            {
                foreach (string s in activityDropDown)
                {
                    Assert.AreEqual(true, i.Text.Contains(s));
                }
            }

            // clicking on activity dropdown
            IWebElement activityDrop = webDriver.FindElement(By.XPath("//*[@id=\"activity-selection\"]"));

            activityDrop.Click();
            Thread.Sleep(SlowDownOne);

            // selecting activity level from dropdown
            SelectElement activitySelection = new SelectElement(webDriver.FindElement(By.Id("activity-selection")));

            activitySelection.SelectByText("Extremely Active");
            Thread.Sleep(SlowDownTwo);

            // clicking submit button, going to surveyResults page
            IWebElement submitButton = webDriver.FindElement(By.ClassName("submit-button"));

            submitButton.Click();
            Thread.Sleep(SlowDownTwo);

            // going to home page again from surveyResults page via home button in nav bar
            IWebElement homeLinkReturn = webDriver.FindElement(By.XPath("/html/body/nav/div/div[2]/ul/li[1]/a"));

            homeLinkReturn.Click();
            Thread.Sleep(SlowDownTwo);

            // navigating to google.com
            webDriver.Navigate().GoToUrl("http://google.com");
            Thread.Sleep(SlowDownTwo);

            // going back to our site from google
            webDriver.Navigate().GoToUrl(Helper.URL);
            Thread.Sleep(SlowDownTwo);
        }
        public static void Hover(this IWebElement element)
        {
            Actions action = new Actions(DriverContext.Driver);//so eaay to use driver

            action.MoveToElement(element).Perform();
        }
        public static void HoverAndClick(this IWebElement elementToHover, IWebElement elementToClick)
        {
            Actions action = new Actions(DriverContext.Driver);

            action.MoveToElement(elementToHover).Click(elementToClick).Build().Perform();
        }
예제 #35
0
        /// <summary>
        /// Gets the Action that needs to be executed.
        /// </summary>
        /// <param name="line">The data line to parse</param>
        /// <param name="data">The BotData needed for variable replacement</param>
        /// <returns>The Action to execute</returns>
        public static Action Parse(string line, BotData data)
        {
            // Trim the line
            var input = line.Trim();

            // Initialize the action chain
            Actions actions = null;

            try
            {
                actions = new Actions(data.Driver);
            }
            catch { throw new Exception("No Browser initialized!"); }

            // Build it
            var         offsetX = 0;
            var         offsetY = 0;
            var         point1X = 0;
            var         point1Y = 0;
            var         point2X = 0;
            var         point2Y = 0;
            var         key     = "";
            var         gravity = 1;
            var         wind    = 1;
            var         qty     = 0;
            IWebElement elem1   = null;
            IWebElement elem2   = null;
            Line        newLine = null;

            while (input != string.Empty)
            {
                var parsed = LineParser.ParseToken(ref input, TokenType.Parameter, true).ToUpper();
                switch (parsed)
                {
                case "SPAWN":
                    // Spawn a div in a certain position so you can hook to it later via id
                    if (LineParser.Lookahead(ref input) == TokenType.Integer)
                    {
                        point1X = LineParser.ParseInt(ref input, "X");
                        point1Y = LineParser.ParseInt(ref input, "Y");
                    }
                    else if (LineParser.Lookahead(ref input) == TokenType.Literal)
                    {
                        point1X = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "X"), data));
                        point1Y = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "Y"), data));
                    }
                    SpawnDiv(data.Driver, point1X, point1Y, LineParser.ParseLiteral(ref input, "ID"));
                    break;

                case "CLICK":
                    if (!LineParser.CheckIdentifier(ref input, "ELEMENT"))
                    {
                        actions.Click();
                    }
                    else
                    {
                        actions.Click(ParseElement(ref input, data));
                    }
                    break;

                case "CLICKANDHOLD":
                    if (!LineParser.CheckIdentifier(ref input, "ELEMENT"))
                    {
                        actions.ClickAndHold();
                    }
                    else
                    {
                        actions.ClickAndHold(ParseElement(ref input, data));
                    }
                    break;

                case "RIGHTCLICK":
                    if (!LineParser.CheckIdentifier(ref input, "ELEMENT"))
                    {
                        actions.ContextClick();
                    }
                    else
                    {
                        actions.ContextClick(ParseElement(ref input, data));
                    }
                    break;

                case "DOUBLECLICK":
                    if (!LineParser.CheckIdentifier(ref input, "ELEMENT"))
                    {
                        actions.DoubleClick();
                    }
                    else
                    {
                        actions.DoubleClick(ParseElement(ref input, data));
                    }
                    break;

                case "DRAGANDDROP":
                    elem1 = ParseElement(ref input, data);
                    LineParser.ParseToken(ref input, TokenType.Arrow, true);
                    elem2 = ParseElement(ref input, data);
                    actions.DragAndDrop(elem1, elem2);
                    break;

                case "DRAGANDDROPWITHOFFSET":
                    if (LineParser.Lookahead(ref input) == TokenType.Integer)
                    {
                        offsetX = LineParser.ParseInt(ref input, "OFFSET X");
                        offsetY = LineParser.ParseInt(ref input, "OFFSET Y");
                    }
                    else if (LineParser.Lookahead(ref input) == TokenType.Literal)
                    {
                        offsetX = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "OFFSET X"), data));
                        offsetY = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "OFFSET Y"), data));
                    }
                    actions.DragAndDropToOffset(ParseElement(ref input, data), offsetX, offsetY);
                    break;

                case "KEYDOWN":
                    key = LineParser.ParseLiteral(ref input, "KEY", true, data);
                    if (!LineParser.CheckIdentifier(ref input, "ELEMENT"))
                    {
                        actions.KeyDown(key);
                    }
                    else
                    {
                        actions.KeyDown(ParseElement(ref input, data), key);
                    }
                    break;

                case "KEYUP":
                    key = LineParser.ParseLiteral(ref input, "KEY", true, data);
                    if (!LineParser.CheckIdentifier(ref input, "ELEMENT"))
                    {
                        actions.KeyUp(key);
                    }
                    else
                    {
                        actions.KeyUp(ParseElement(ref input, data), key);
                    }
                    break;

                case "MOVEBY":
                    if (LineParser.Lookahead(ref input) == TokenType.Integer)
                    {
                        offsetX = LineParser.ParseInt(ref input, "OFFSET X");
                        offsetY = LineParser.ParseInt(ref input, "OFFSET Y");
                    }
                    else if (LineParser.Lookahead(ref input) == TokenType.Literal)
                    {
                        offsetX = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "OFFSET X"), data));
                        offsetY = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "OFFSET Y"), data));
                    }
                    actions.MoveByOffset(offsetX, offsetY);
                    break;

                case "MOVETO":
                    actions.MoveToElement(ParseElement(ref input, data));
                    break;

                case "RELEASE":
                    if (!LineParser.CheckIdentifier(ref input, "ELEMENT"))
                    {
                        actions.Release();
                    }
                    else
                    {
                        actions.Release(ParseElement(ref input, data));
                    }
                    break;

                case "SENDKEYS":
                    key = LineParser.ParseLiteral(ref input, "KEY", true, data);
                    if (!LineParser.CheckIdentifier(ref input, "ELEMENT"))
                    {
                        actions.SendKeys(key);
                    }
                    else
                    {
                        actions.SendKeys(ParseElement(ref input, data), key);
                    }
                    break;

                case "DRAWPOINTS":
                    offsetX = LineParser.ParseInt(ref input, "MAX WIDTH");
                    offsetY = LineParser.ParseInt(ref input, "MAX HEIGHT");
                    var    amount    = LineParser.ParseInt(ref input, "AMOUNT");
                    Random rand      = new Random();
                    var    previousx = 0;
                    var    previousy = 0;
                    // Move to the first point
                    actions.MoveToElement(data.Driver.FindElementByTagName("body"), point1X, point1Y);
                    List <Point> points = new List <Point>();
                    for (int i = 0; i < amount; i++)
                    {
                        var x = rand.Next(0, offsetX);
                        var y = rand.Next(0, offsetY);
                        actions.MoveByOffset(x - previousx, y - previousy);
                        previousx = x;
                        previousy = y;
                        points.Add(new Point(x, y));
                    }
                    if (data.GlobalSettings.Selenium.DrawMouseMovement)
                    {
                        DrawRedDots(data.Driver, points.ToArray(), 5);
                    }
                    break;

                case "DRAWLINE":
                    // DRAWLINE 10 10 -> 20 20
                    if (LineParser.Lookahead(ref input) == TokenType.Integer)
                    {
                        point1X = LineParser.ParseInt(ref input, "X1");
                        point1Y = LineParser.ParseInt(ref input, "Y1");
                        LineParser.ParseToken(ref input, TokenType.Arrow, true);
                        point2X = LineParser.ParseInt(ref input, "X2");
                        point2Y = LineParser.ParseInt(ref input, "Y2");
                    }
                    // DRAWLINE "10" "20" -> "<MY_X>" "<MY_Y>"
                    else if (LineParser.Lookahead(ref input) == TokenType.Literal)
                    {
                        point1X = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "X1"), data));
                        point1Y = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "Y1"), data));
                        LineParser.ParseToken(ref input, TokenType.Arrow, true);
                        point2X = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "X2"), data));
                        point2Y = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "Y2"), data));
                    }
                    else
                    {
                        elem1   = ParseElement(ref input, data);
                        point1X = elem1.Location.X;
                        point1Y = elem1.Location.Y;
                        LineParser.ParseToken(ref input, TokenType.Arrow, true);
                        elem2   = ParseElement(ref input, data);
                        point2X = elem2.Location.X;
                        point2Y = elem2.Location.Y;
                    }
                    LineParser.EnsureIdentifier(ref input, ":");
                    qty = LineParser.ParseInt(ref input, "QUANTITY");
                    // Move to the first point
                    actions.MoveToElement(data.Driver.FindElementByTagName("body"), point1X, point1Y);
                    newLine = new Line(new Point(point1X, point1Y), new Point(point2X, point2Y));
                    if (data.GlobalSettings.Selenium.DrawMouseMovement)
                    {
                        DrawRedDots(data.Driver, newLine.getPoints(qty), 5);
                    }
                    foreach (var p in newLine.getOffsets(qty))
                    {
                        actions.MoveByOffset(p.X, p.Y);
                    }
                    break;

                case "DRAWLINEHUMAN":
                    // DRAWLINEHUMAN 10 10 -> 20 20
                    if (LineParser.Lookahead(ref input) == TokenType.Integer)
                    {
                        point1X = LineParser.ParseInt(ref input, "X1");
                        point1Y = LineParser.ParseInt(ref input, "Y1");
                        LineParser.ParseToken(ref input, TokenType.Arrow, true);
                        point2X = LineParser.ParseInt(ref input, "X2");
                        point2Y = LineParser.ParseInt(ref input, "Y2");
                    }
                    // DRAWLINEHUMAN "10" "20" -> "<MY_X>" "<MY_Y>"
                    else if (LineParser.Lookahead(ref input) == TokenType.Literal)
                    {
                        point1X = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "X1"), data));
                        point1Y = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "Y1"), data));
                        LineParser.ParseToken(ref input, TokenType.Arrow, true);
                        point2X = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "X2"), data));
                        point2Y = int.Parse(BlockBase.ReplaceValues(LineParser.ParseLiteral(ref input, "Y2"), data));
                    }
                    else
                    {
                        elem1   = ParseElement(ref input, data);
                        point1X = elem1.Location.X;
                        point1Y = elem1.Location.Y;
                        LineParser.ParseToken(ref input, TokenType.Arrow, true);
                        elem2   = ParseElement(ref input, data);
                        point2X = elem2.Location.X;
                        point2Y = elem2.Location.Y;
                    }
                    LineParser.EnsureIdentifier(ref input, ":");
                    qty = LineParser.ParseInt(ref input, "QUANTITY");
                    if (LineParser.Lookahead(ref input) == TokenType.Integer)
                    {
                        gravity = LineParser.ParseInt(ref input, "GRAVITY");
                        wind    = LineParser.ParseInt(ref input, "WIND");
                    }
                    // Move to the first point
                    actions.MoveToElement(data.Driver.FindElementByTagName("body"), point1X, point1Y);
                    newLine = new Line(new Point(point1X, point1Y), new Point(point2X, point2Y));
                    var array    = newLine.HumanWindMouse(point1X, point1Y, point2X, point2Y, gravity, wind, 1);
                    var shrinked = ShrinkArray(array, qty);
                    if (data.GlobalSettings.Selenium.DrawMouseMovement)
                    {
                        DrawRedDots(data.Driver, shrinked, 5);
                    }
                    foreach (var p in GetOffsets(shrinked))
                    {
                        actions.MoveByOffset(p.X, p.Y);
                    }
                    break;
                }
            }

            return(new Action(() =>
            {
                actions.Build();
                actions.Perform();
                data.Log(new LogEntry("Executed Mouse Actions", Colors.White));
            }));
        }
예제 #36
0
        /// <summary>
        /// Check which Sign Out button text is displayed
        /// Text = Sign Out or Text = [Sign Out]
        ///
        /// </summary>
        public void SignOut()
        {
            //browser.FindElement(By.LinkText("[Sign Out]")).Click();

            //Set Driver wait time = 0
            Libary.SetWebDiverWaitTime(0);
            IWebElement signOut1 = null;
            IWebElement signOut2 = null;
            IWebElement signOut3 = null;

            try
            {
                //Signout for program = FSL
                signOut1 = browser.FindElement(By.Id("ctl00_SafeAccountLink"));
            }
            catch
            {
                //Empty catch
            }

            try
            {
                //Signout for SAFE Home page
                signOut2 = browser.FindElement(By.LinkText("[Sign Out]"));
            }
            catch
            {
                //Empty catch
            }

            try
            {
                //Signout for product application page
                signOut3 = browser.FindElement(By.LinkText("Sign Out"));
            }
            catch
            {
                //Empty catch
            }


            if ((signOut1 == null) &&
                (signOut2 == null) &&
                (signOut3 == null))
            {
                throw new Exception("SignOut Link Not Found");
            }

            //
            //Workaround for the Google browser run-Time Exception
            //Result Message: System.InvalidOperationException : unknown error: Element is not clickable at point (982, 12).
            //Other element would receive the click: <div class="ui-widget-overlay ui-front"></div>
            //Googled the error for fix
            //

            Actions actions = new Actions(browser);

            if (signOut1 != null)
            {
                //signOut1.Click();
                actions.MoveToElement(signOut1).Click().Perform();
            }
            if (signOut2 != null)
            {
                //signOut2.Click();
                actions.MoveToElement(signOut2).Click().Perform();
            }
            if (signOut3 != null)
            {
                //signOut3.Click();
                actions.MoveToElement(signOut3).Click().Perform();
            }


            //Reset Driver Wait Time
            Libary.ReSetWebDiverWaitTime();
        }
 public DocumentCollect(WiniumMethods m, Actions action, ILog debugLog)
 {
     this.m        = m;
     this.action   = action;
     this.debugLog = debugLog;
 }
예제 #38
0
 public void Add(IAction action)
 {
     Actions.Add(action);
 }
        public void ApplicationEditTest()
        {
            _avatarButton.Click();

            var applicationsButton = Waits.WaitUntilElementVisible(_driver, TimeSpan.FromSeconds(5),
                                                                   By.XPath("//div/a[contains(text(),'Application')]/.."));

            if (applicationsButton == null)
            {
                Assert.Fail("Could not load the 'Applications' button in under 5 seconds!");
            }
            applicationsButton.Click();

            var newApplicationButton = Waits.WaitUntilElementLoads(_driver, TimeSpan.FromSeconds(5),
                                                                   By.XPath("//button[contains(text(), 'Create New Application')]"));

            if (newApplicationButton == null)
            {
                Assert.Fail("Could not load the 'Create New Application' button in under 5 seconds!");
            }
            Waits.WaitUntilElementLoads(_driver, TimeSpan.FromSeconds(5), By.XPath("//li[contains(text(), 'Selenium Test Name')]/button[contains(text(), 'Edit')]")).Click();
            var newApplicationNameInput = Waits.WaitUntilElementLoads(_driver, TimeSpan.FromSeconds(5),
                                                                      By.XPath("//input[@data-sid = 'applicationNameInput']"));

            if (newApplicationNameInput == null)
            {
                Assert.Fail("Could not load the 'Name' input in under 5 seconds!");
            }

            newApplicationNameInput.SendKeys(" EDITED");

            var functionalityToDragAndDrop = _driver.FindElement(By.XPath("//span[contains(text(),' Selenium App Test Template ')]"));
            var whereToDrop = _driver.FindElement(By.XPath("//div[@class='col']/kendo-textbox-container/../kendo-treeview"));

            Actions actions = new Actions(_driver);

            actions.DragAndDrop(functionalityToDragAndDrop, whereToDrop).Build().Perform();

            _driver.FindElement(By.XPath("//button[contains(text(),'Update')]")).Click();

            newApplicationButton = Waits.WaitUntilElementLoads(_driver, TimeSpan.FromSeconds(5),
                                                               By.XPath("//button[contains(text(), 'Create New Application')]"));
            if (newApplicationButton == null)
            {
                Assert.Fail("Could not load the 'Create New Application' button in under 5 seconds!");
            }

            var applicationEntry = Waits.WaitUntilElementLoads(_driver, TimeSpan.FromSeconds(5), By.XPath("//li[contains(text(), 'Selenium Test Name EDITED')]"));

            if (applicationEntry == null)
            {
                Assert.Fail("Could not edit (or display on the list) an Application!");
            }

            _driver.Navigate().Refresh();

            var dropdownRoot = Waits.WaitUntilElementLoads(_driver, TimeSpan.FromSeconds(5),
                                                           By.XPath("//a[contains(text(),' SeleniumTestDataTypeGrid ')]"));

            actions = new Actions(_driver);
            actions.MoveToElement(dropdownRoot).Build().Perform();

            var textTemplateFromDropdown = Waits.WaitUntilElementLoads(_driver, TimeSpan.FromSeconds(5),
                                                                       By.XPath("//a[contains(text(),'Selenium App Test Template')]"));

            textTemplateFromDropdown.Click();
            var paragraph = Waits.WaitUntilElementLoads(_driver, TimeSpan.FromSeconds(5),
                                                        By.XPath("//p[text()='Selenium Content']"));

            if (paragraph == null)
            {
                Assert.Fail("Could not load the content of the Text Template in under 5 seconds (or the content is incorrect)!");
            }

            _driver.Navigate().Back();
        }