/// <summary>
        /// Sets element context and updates UI
        /// </summary>
        /// <param name="ec"></param>
        public void SetElement()
        {
            var ecId = SelectAction.GetDefaultInstance().GetSelectedElementContextId();

            if (ecId.HasValue)
            {
                ElementContext ec = GetDataAction.GetElementContext(ecId.Value);
                this.ElementContext = ec;
                var brush         = Application.Current.Resources["HLTextBrush"] as SolidColorBrush;
                var overlayDriver = ClearOverlayDriver.GetDefaultInstance();
                overlayDriver.SetElement(ElementContext.Element, brush, null, 0);
                if (this.IsVisible && HighlightVisibility)
                {
                    overlayDriver.Show();
                }
            }
        }
Ejemplo n.º 2
0
        public ResultsT Scan <ResultsT>(A11yElement element, ScanActionCallback <ResultsT> scanCallback)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }
            if (scanCallback == null)
            {
                throw new ArgumentNullException(nameof(scanCallback));
            }

            using (var dataManager = DataManager.GetDefaultInstance())
                using (var sa = SelectAction.GetDefaultInstance())
                {
                    sa.SetCandidateElement(element);

                    if (!sa.Select())
                    {
                        throw new AxeWindowsAutomationException(DisplayStrings.ErrorUnableToSetDataContext);
                    }

                    using (ElementContext ec2 = sa.POIElementContext)
                    {
                        Stopwatch stopwatch = Stopwatch.StartNew();
                        GetDataAction.GetProcessAndUIFrameworkOfElementContext(ec2.Id);
                        if (!CaptureAction.SetTestModeDataContext(ec2.Id, DataContextMode.Test, TreeViewMode.Control))
                        {
                            throw new AxeWindowsAutomationException(DisplayStrings.ErrorUnableToSetDataContext);
                        }
                        long scanDurationInMilliseconds = stopwatch.ElapsedMilliseconds;

                        // send telemetry of scan results.
                        var dc = GetDataAction.GetElementDataContext(ec2.Id);
                        dc.PublishScanResults(scanDurationInMilliseconds);

                        if (dc.ElementCounter.UpperBoundExceeded)
                        {
                            throw new AxeWindowsAutomationException(string.Format(CultureInfo.InvariantCulture,
                                                                                  DisplayStrings.ErrorTooManyElementsToSetDataContext,
                                                                                  dc.ElementCounter.UpperBound));
                        }

                        return(scanCallback(ec2.Element, ec2.Id));
                    } // using
                }// using
        }
Ejemplo n.º 3
0
 public PageList <SmsBatchDetailsMoreInfo> GetList(int PageIndex, int PageSize, string phone, string state, string starttime, string endtime, int eid)
 {
     using (SelectAction action = new SelectAction(""))
     {
         action.SqlClomns = "_sms_batch_details.*,_sms_batch.batchname";
         {
             //添加视图的关联关系
             List <QueryField> field = new List <QueryField>();
             field.Add(new QueryField()
             {
                 Value     = SmsBatchDetailsInfo.Columns.BatchID,
                 Condition = ConditionEnum.And,
                 FiledName = SmsBatchInfo.Columns.ID
             });
             action.AddJoin(ViewJoinEnum.innerjoin, "sms_batch", "sms_batch_details", field);
         }
         if (eid != 1)
         {
             action.SqlWhere("_sms_batch." + SmsBatchInfo.Columns.EnterPriseID, eid);
         }
         if (!string.IsNullOrEmpty(phone))
         {
             action.SqlWhere(SmsBatchDetailsInfo.Columns.Phone, phone, RelationEnum.Like);
         }
         if (!string.IsNullOrEmpty(state) && int.Parse(state) > 0)
         {
             action.SqlWhere(SmsBatchDetailsInfo.Columns.State, state);
         }
         if (!string.IsNullOrEmpty(starttime) && string.IsNullOrEmpty(endtime))
         {
             action.SqlWhere(SmsBatchDetailsInfo.Columns.SubmitTime, starttime, ConditionEnum.And, RelationEnum.LargeThen);
         }
         if (!string.IsNullOrEmpty(endtime) && string.IsNullOrEmpty(starttime))
         {
             action.SqlWhere(SmsBatchDetailsInfo.Columns.SubmitTime, endtime, ConditionEnum.And, RelationEnum.LessThen);
         }
         if (!string.IsNullOrEmpty(endtime) && !string.IsNullOrEmpty(starttime))
         {
             action.SqlWhere(SmsBatchDetailsInfo.Columns.SubmitTime, starttime, endtime, ConditionEnum.And, RelationEnum.Between);
         }
         action.SqlOrderBy("_sms_batch_details.SubmitTime", OrderByEnum.Desc);
         action.PageSize = PageSize;
         return(action.QueryPage <SmsBatchDetailsMoreInfo>(PageIndex));
     }
 }
Ejemplo n.º 4
0
 public PageList <BatchMoreInfo> GetList(int PageIndex, int PageSize, string batchname, string state, string starttime, string endtime, int eid)
 {
     using (SelectAction action = new SelectAction(""))
     {
         action.SqlClomns = "_sms_batch.*,_sms_batch_amount.RealAmount,_sms_batch_amount.SendAmount,_sms_batch_amount.SuccessAmount";
         {
             //添加视图的关联关系
             List <QueryField> field = new List <QueryField>();
             field.Add(new QueryField()
             {
                 Value     = SmsBatchAmountInfo.Columns.BatchID,
                 Condition = ConditionEnum.And,
                 FiledName = SmsBatchInfo.Columns.ID
             });
             action.AddJoin(ViewJoinEnum.leftjoin, "sms_batch", "sms_batch_amount", field);
         }
         if (eid != 1)
         {
             action.SqlWhere("_sms_batch." + SmsBatchInfo.Columns.EnterPriseID, eid);
         }
         if (!string.IsNullOrEmpty(batchname))
         {
             action.SqlWhere(SmsBatchInfo.Columns.BatchName, batchname, ConditionEnum.And, RelationEnum.Like);
         }
         if (!string.IsNullOrEmpty(state) && int.Parse(state) > 0)
         {
             action.SqlWhere(SmsBatchInfo.Columns.BatchState, state);
         }
         if (!string.IsNullOrEmpty(starttime) && string.IsNullOrEmpty(endtime))
         {
             action.SqlWhere(SmsBatchInfo.Columns.PostTime, starttime, ConditionEnum.And, RelationEnum.LargeThen);
         }
         if (!string.IsNullOrEmpty(endtime) && string.IsNullOrEmpty(starttime))
         {
             action.SqlWhere(SmsBatchInfo.Columns.PostTime, endtime, ConditionEnum.And, RelationEnum.LessThen);
         }
         if (!string.IsNullOrEmpty(endtime) && !string.IsNullOrEmpty(starttime))
         {
             action.SqlWhere(SmsBatchInfo.Columns.PostTime, starttime, endtime, ConditionEnum.And, RelationEnum.Between);
         }
         action.SqlOrderBy("_sms_batch.Createtime", OrderByEnum.Desc);
         action.PageSize = PageSize;
         return(action.QueryPage <BatchMoreInfo>(PageIndex));
     }
 }
Ejemplo n.º 5
0
        public override PlayerTask GetMove(POGame.POGame poGame)
        {
            if (poGame.CurrentPlayer.Options().Count == 1)
            {
                return(poGame.CurrentPlayer.Options()[0]);
            }

            Console.WriteLine("Turn #" + poGame.Turn + ": AlvaroAgent needs to take a decision...");
            Console.WriteLine(poGame.FullPrint());
            POGame.POGame initialState = poGame.getCopy();

            Node root = new Node();

            Node  selectedNode;
            Node  nodeToSimulate;
            float scoreOfSimulation;
            int   iterations = 0;

            InitializeRoot(root, initialState);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            while (stopwatch.ElapsedMilliseconds <= MAX_TIME)
            {
                poGame         = initialState;
                selectedNode   = Selection(root, iterations, ref poGame);
                nodeToSimulate = Expansion(selectedNode, ref poGame);

                Console.WriteLine("Iteration #" + iterations + ": node to be simulated:" + selectedNode);

                for (int i = 0; i < NUM_SIMULATIONS; i++)
                {
                    scoreOfSimulation = Simulation(nodeToSimulate, poGame);
                    Backpropagation(nodeToSimulate, scoreOfSimulation);
                    iterations++;
                }
            }
            stopwatch.Stop();

            PlayerTask selectedTask = SelectAction.selectTask(SELECTION_ACTION_METHOD, root, iterations, EXPLORE_CONSTANT);

            Console.WriteLine("Turn #" + poGame.Turn + ", selected task:" + selectedTask);
            return(selectedTask);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handle configuration changed
        /// - apply changes as needed
        /// - Send telemetry
        /// </summary>
        /// <param name="testconfig"></param>
        internal void HandleConfigurationChanged(IReadOnlyDictionary <string, object> changes)
        {
            HotkeyHandler?.ClearHotkeys();
            InitHotKeys();

            var configManager = ConfigurationManager.GetDefaultInstance();

            SelectAction.GetDefaultInstance().IntervalMouseSelector = configManager.AppConfig.MouseSelectionDelayMilliSeconds;
            this.Topmost = configManager.AppConfig.AlwaysOnTop;
            this.ctrlTestMode.ctrlTabStop.SetHotkeyText(configManager.AppConfig.HotKeyForRecord);

            HollowHighlightDriver.GetDefaultInstance().HighlighterMode = configManager.AppConfig.HighlighterMode;

            if (changes != null && changes.ContainsKey(ConfigurationModel.keyFontSize))
            {
                SetFontSize();
            }
        }
Ejemplo n.º 7
0
    private void TrySelect(bool applyToCurrent)
    {
        RaycastHit hit;
        Camera     currentCam     = Service.Cameras.CurrentCamera;
        Ray        mouseRay       = Service.Cameras.CurrentCamera.ScreenPointToRay(Input.mousePosition);
        bool       entitySelected = false;

        if (Physics.Raycast(mouseRay, out hit) && hit.transform != null)
        {
            EntityRef entRef = hit.transform.GetComponent <EntityRef> ();
            if (entRef != null && !CurrentEntities.Contains(entRef.GetEntity()))
            {
                SelectAction selectAction = new SelectAction();
                selectAction.SetArguments(CurrentEntities, entRef.GetEntity(), applyToCurrent);
                Service.ActionManager.ExecuteAction(selectAction);
                entitySelected = true;
            }
            else if (applyToCurrent &&
                     entRef != null &&
                     CurrentEntities.Count > 1 &&
                     CurrentEntities.Contains(entRef.GetEntity()))
            {
                DeselectAction deselectAction = new DeselectAction();
                deselectAction.SetArguments(entRef.GetEntity());
                Service.ActionManager.ExecuteAction(deselectAction);
                entitySelected = true;
            }
            else if (entRef != null && CurrentEntities.Count > 1 && CurrentEntities.Contains(entRef.GetEntity()))
            {
                // If the user selects a single element that is already selected as part of a group, do nothing.
                entitySelected = true;
            }
        }

        // No entity clicked on. Deselect all entities.
        if (!entitySelected && CurrentEntities.Count > 0)
        {
            SelectAction selectAction = new SelectAction();
            selectAction.SetArguments(CurrentEntities, null, false);
            Service.ActionManager.ExecuteAction(selectAction);
            CurrentEntities.Clear();
        }
    }
Ejemplo n.º 8
0
        public void ImportList(List <SmsContactInfo> contacts, int groupid)
        {
            if (contacts.Count > 0)
            {
                using (TradAction action = new TradAction())
                {
                    List <string> sqls = new List <string>();
                    foreach (var filterkey in contacts)
                    {
                        InserAction inserAction = new InserAction(filterkey);
                        sqls.Add(inserAction.CreateSql(OperateEnum.Insert));
                    }
                    action.ExecuteSqlTran(sqls);
                }
                string ids = "";
                using (SelectAction action = new SelectAction(this.Entity))
                {
                    action.SqlClomns = " min(id) as id ";
                    action.SqlGroupBy("Mobile,EnterpriseID,GroupID HAVING COUNT(1)>1");
                    action.SqlWhere("EnterpriseID", contacts[0].EnterpriseId);
                    if (groupid > 0)
                    {
                        action.SqlWhere("GroupID", groupid);
                    }
                    action.SqlPageParms(-1);
                    List <SmsBlackphoneInfo> idlist = action.QueryPage <SmsBlackphoneInfo>(0);

                    foreach (SmsBlackphoneInfo info in idlist)
                    {
                        ids += info.ID + ",";
                    }
                }
                using (DeleteAction taction = new DeleteAction(this.Entity))
                {
                    taction.SqlWhere(SmsBlackphoneInfo.Columns.ID, ids.TrimEnd(','), ConditionEnum.And,
                                     RelationEnum.In);
                    taction.SqlWhere(SmsBlackphoneInfo.Columns.EnterpriseID, contacts[0].EnterpriseId);

                    taction.Excute();
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Show control and hilighter
        /// </summary>
        public void ShowControl()
        {
            this.Visibility           = Visibility.Visible;
            this.prevHighlighterState = HollowHighlightDriver.GetDefaultInstance().IsEnabled;
            this.prevMode             = HollowHighlightDriver.GetDefaultInstance().HighlighterMode;
            HollowHighlightDriver.GetDefaultInstance().HighlighterMode = HighlighterMode.Highlighter;
            MainWin.SetHighlightBtnState(true);
            HollowHighlightDriver.GetDefaultInstance().IsEnabled = true;
            HollowHighlightDriver.GetDefaultInstance().Clear();

            SelectAction.GetDefaultInstance().ClearSelectedContext();

            Dispatcher.InvokeAsync(() =>
            {
                this.SetFocusOnDefaultControl();
            }
                                   , System.Windows.Threading.DispatcherPriority.Input);

            ctrlContrast.SetAutoCCAState(true);
        }
        /// <summary>
        /// Handle Context Menu : Expand all
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            var node = (HierarchyNodeViewModel)((System.Windows.FrameworkElement)sender).DataContext;

            if (node.NeedSnapshot && node.Element is DesktopElement && node.Element.IsRootElement() == false)
            {
                Dispatcher.Invoke(() =>
                {
                    var sa = SelectAction.GetDefaultInstance();
                    sa.SetCandidateElement(this.ElementContext.Id, node.Element.UniqueId);
                    sa.Select();
                    this.HierarchyActions.RefreshHierarchy(true);
                });
            }
            else
            {
                Logger.PublishTelemetryEvent(TelemetryAction.Hilighter_Expand_AllDescendants);
                node.Expand(true);
            }
        }
        /// <summary>
        /// Start snapshot mode.
        /// </summary>
        /// <param name="e">root element for listening events</param>
        private void StartEventsMode(A11yElement e)
        {
            if (e == null)
            {
                this.AllowFurtherAction = false;
                MessageDialog.Show(Properties.Resources.StartElementDetailViewNoElementIsSelectedMessage);
                this.AllowFurtherAction = true;
            }
            else if (e.IsSafeToRefresh() == false)
            {
                this.AllowFurtherAction = false;
                MessageDialog.Show(Properties.Resources.StartEventsModeElementNotAvailableMessage);
                this.AllowFurtherAction = true;
            }
            else
            {
                // we need to explicitly set the highlighter mode despite of the highlighter button status
                HighlightAction.GetDefaultInstance().HighlighterMode = HighlighterMode.Highlighter;

                this.ctrlEventMode.Clear();

                DisableElementSelector();

                this.ctrlCurMode.HideControl();
                this.ctrlCurMode = this.ctrlEventMode;
                this.ctrlEventMode.CurrentView = EventsView.Config;
                this.ctrlCurMode.ShowControl();

                var sa = SelectAction.GetDefaultInstance();

                // set the root element to listen to.
#pragma warning disable CS4014
                // NOTE: We aren't awaiting this async call, so if you
                // touch it, consider if you need to add the await
                this.ctrlEventMode.SetElement(sa.GetSelectedElementContextId().Value);
#pragma warning restore CS4014
                this.CurrentPage = AppPage.Events;
                this.CurrentView = EventsView.Config;
                PageTracker.TrackPage(this.CurrentPage, this.CurrentView.ToString());
            }
        }
Ejemplo n.º 12
0
        public void PlayAction_Valid()
        {
            var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings());

            diceGame.CurrentBoard.SetDices(new List <Dice>
            {
                new Dice(0, 1, diceGame.DiceGameSettings.DiceSettings),
                new Dice(1, 1, diceGame.DiceGameSettings.DiceSettings),
                new Dice(2, 2, diceGame.DiceGameSettings.DiceSettings),
                new Dice(3, 3, diceGame.DiceGameSettings.DiceSettings),
                new Dice(4, 4, diceGame.DiceGameSettings.DiceSettings),
                new Dice(5, 6, diceGame.DiceGameSettings.DiceSettings)
            });

            var playAction   = new PlayAction(0);
            var selectAction = new SelectAction(new Dice(1));

            diceGame.Play(selectAction);

            Assert.IsTrue(diceGame.CurrentBoard.Players.TrueForAll(p => p.PlayerStats.Health < p.PlayerStats.MaxHealth));
        }
 /// <summary>
 /// Event handler for Move to Parent button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnMoveToParent_Click(object sender, RoutedEventArgs e)
 {
     if (this.SelectedElement.Parent != null)
     {
         if (this.SelectedElement.Parent.IsRootElement() == false)
         {
             var sa = SelectAction.GetDefaultInstance();
             sa.SetCandidateElement(this.ElementContext.Id, this.SelectedElement.Parent.UniqueId);
             sa.Select();
             this.HierarchyActions.RefreshHierarchy(true);
         }
         else
         {
             MessageDialog.Show(Properties.Resources.HierarchyControl_btnMoveToParent_Click_The_parent_is_Desktop_Element__Desktop_Element_can_t_be_snapshot);
         }
     }
     else
     {
         MessageDialog.Show(Properties.Resources.HierarchyControl_btnMoveToParent_Click_Parent_element_can_t_be_retrieved);
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Выполнить действие по выбору компонента
        /// </summary>
        public void PerformSelectAction(SelectAction selectAction, int componentID)
        {
            switch (selectAction)
            {
            case SelectAction.Select:
                SelectComponent(componentID);
                break;

            case SelectAction.Append:
                SelectComponent(componentID, true);
                break;

            case SelectAction.Deselect:
                DeselectComponent(componentID);
                break;

            case SelectAction.DeselectAll:
                DeselectAll();
                break;
            }
        }
Ejemplo n.º 15
0
        public IHttpActionResult Current()
        {
            try
            {
                var sa  = SelectAction.GetDefaultInstance();
                var gid = sa.GetSelectedElementContextId();

                if (gid.HasValue)
                {
                    return(Ok(gid));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 16
0
        static BotMessage GetReplay(SlackMessage msg)
        {
            var a = new SlackAttachmentAction {
                Type  = "button",
                Style = SlackAttachmentActionStyle.Danger,
                Name  = "My action name",
                Text  = "My action text",
                Value = "42"
            };

            var sel = new SelectAction {
                Name    = "My action name",
                Text    = "My action text",
                Type    = "select",
                Options = new[] {
                    new Option {
                        Text = "Option one", Value = "1"
                    },
                    new Option {
                        Text = "Option two", Value = "2"
                    },
                },
                //DataSource = SelectAction.DS_USERS,
            };

            var att = new SlackAttachment {
                CallbackId = "my_msg",
                Text       = "My att",
                Title      = "My title",
                Actions    = new[] { sel, a }
            };

            return(new BotMessage {
                //Text = $"RTM message from: {msg.User.Name}\n  ```\n  {JsonConvert.SerializeObject(msg)} \n  ```",
                Text = $"Hej! {msg.Text}",
                ChatHub = msg.ChatHub,
                Attachments = new[] { att }
            });
        }
Ejemplo n.º 17
0
 public List <SmsMoInfo> GetUserMo(string username, string password)
 {
     using (SelectAction action = new SelectAction(""))
     {
         action.SqlClomns = "_SmsMoInfo.*";
         {
             //添加视图的关联关系
             List <QueryField> field = new List <QueryField>();
             field.Add(new QueryField()
             {
                 Value     = SmsMoInfo.Columns.AccountID,
                 Condition = ConditionEnum.And,
                 FiledName = SmsAccountInfo.Columns.ID
             });
             action.AddJoin(ViewJoinEnum.innerjoin, "sms_account", "sms_mo", field);
         }
         action.SqlWhere(SmsAccountInfo.Columns.Account, username);
         action.SqlWhere(SmsAccountInfo.Columns.Password, password);
         action.PageSize = 20;
         return(action.QueryPage <SmsMoInfo>(1));
     }
 }
Ejemplo n.º 18
0
        public void Dice_Board()
        {
            var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings());

            diceGame.CurrentBoard.SetDices(new List <Dice>
            {
                new Dice(0, 4),
                new Dice(1, 4),
                new Dice(2, 4),
                new Dice(3, 4),
                new Dice(4, 4),
                new Dice(5, 4),
            });

            var selectAction = new SelectAction(new Dice(1));

            Assert.IsTrue(diceGame.CanBePlayed(selectAction));

            diceGame.Play(selectAction);

            Assert.IsFalse(diceGame.CanBePlayed(selectAction));
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 获取账号的基本信息
 /// </summary>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public SmsAddrecordInfo GetAccountInfo(string username, string password)
 {
     using (SelectAction action = new SelectAction(Entity))
     {
         action.SqlClomns = "_Sms_AddRecord.*";
         {
             //添加视图的关联关系
             List <QueryField> field = new List <QueryField>();
             field.Add(new QueryField()
             {
                 FiledName = SmsAddrecordInfo.Columns.AccountID,
                 Condition = ConditionEnum.And,
                 Value     = SmsAccountInfo.Columns.ID
             });
             action.AddJoin(ViewJoinEnum.leftjoin, "SmsAccountInfo", "Sms_AddRecord", field);
         }
         action.SqlWhere(SmsAccountInfo.Columns.Account, username);
         action.SqlWhere(SmsAccountInfo.Columns.Password, password);
         action.SqlOrderBy("_Sms_AddRecord." + SmsAddrecordInfo.Columns.CreateTime, OrderByEnum.Desc);
         return(action.QueryEntity <SmsAddrecordInfo>());
     }
 }
        /// <summary>
        /// Update Tree View
        /// </summary>
        /// <param name="rnvm">RootNode View Model</param>
        /// <param name="se">Selected element in hierarchy</param>
        private void UpdateTreeView(HierarchyNodeViewModel rnvm, bool expandall)
        {
            if (!SelectAction.GetDefaultInstance().IsPaused)
            {
                CleanUpTreeView();
            }
            this.RootNode = rnvm;
            this.treeviewHierarchy.ItemsSource = new List <HierarchyNodeViewModel>()
            {
                rnvm
            };
            this.treeviewHierarchy.IsEnabled = true;
            this.HierarchyActions.SelectedElementChanged();

            // expand all if it is required.
            if (expandall)
            {
                rnvm.Expand(true);
            }

            textboxSearch.Text = "";
        }
        /// <summary>
        /// Merge a results file into the local issue store. This clears all internal data contexts
        /// </summary>
        /// <param name="path">Path to the file to merge</param>
        /// <returns>The number of changes (additions or merges) to the store</returns>
        public static int MergeOutputFileToIssueStore(string path)
        {
            int changeCount = 0;

            try
            {
                Tuple <Guid, SnapshotMetaInfo> loadInfo = SelectAction.GetDefaultInstance().SelectLoadedData(path);

                ElementContext elementContext = DataManager.GetDefaultInstance().GetElementContext(loadInfo.Item1);
                IIssueStore    storeToMerge   = new OutputFileIssueStore(path, elementContext.DataContext.Elements.Values);

                changeCount = SessionIssueStore.GetInstance().MergeIssuesFromStore(storeToMerge);
            }
            catch (Exception)
            {
            }
            finally
            {
                SelectAction.GetDefaultInstance().ClearSelectedContext();
            }
            return(changeCount);
        }
Ejemplo n.º 22
0
        public override PlayerTask GetMove(POGame.POGame poGame)
        {
            if (poGame.CurrentPlayer.Options().Count == 1)
            {
                return(poGame.CurrentPlayer.Options()[0]);
            }

            POGame.POGame initialState = new POGame.POGame(poGame.getGame.Clone(), false);

            Node root = new Node();

            Node  selectedNode;
            Node  nodeToSimulate;
            float scoreOfSimulation;
            int   iterations = 0;

            InitializeRoot(root, initialState);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            while (stopwatch.ElapsedMilliseconds <= MAX_TIME)
            {
                poGame         = initialState;
                selectedNode   = Selection(root, iterations, ref poGame);
                nodeToSimulate = Expansion(selectedNode, ref poGame);

                for (int i = 0; i < NUM_SIMULATIONS; i++)
                {
                    scoreOfSimulation = Simulation(nodeToSimulate, poGame);
                    Backpropagation(nodeToSimulate, scoreOfSimulation);
                    iterations++;
                }
            }
            stopwatch.Stop();

            return(SelectAction.selectTask(SELECTION_ACTION_METHOD, root, iterations, EXPLORE_CONSTANT));
        }
Ejemplo n.º 23
0
        public bool OnPressed(KeyBindingPressEvent <GlobalAction> e)
        {
            switch (e.Action)
            {
            case GlobalAction.SelectPrevious:
                InternalButtons.SelectPrevious();
                return(true);

            case GlobalAction.SelectNext:
                InternalButtons.SelectNext();
                return(true);

            case GlobalAction.Back:
                BackAction.Invoke();
                return(true);

            case GlobalAction.Select:
                SelectAction.Invoke();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 24
0
        public void PlayAction_Valid()
        {
            var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings());

            diceGame.CurrentBoard.SetDices(new List <Dice>
            {
                new Dice(0, 1),
                new Dice(1, 1),
                new Dice(2, 2),
                new Dice(3, 3),
                new Dice(4, 4),
                new Dice(5, 5),
            });

            var playAction   = new PlayAction(0);
            var selectAction = new SelectAction(new Dice(1));

            Assert.IsFalse(diceGame.CanBePlayed(playAction));

            diceGame.Play(selectAction);

            Assert.IsTrue(diceGame.CanBePlayed(playAction));
        }
Ejemplo n.º 25
0
        public bool OnPressed(GlobalAction action)
        {
            switch (action)
            {
            case GlobalAction.SelectPrevious:
                InternalButtons.SelectPrevious();
                return(true);

            case GlobalAction.SelectNext:
                InternalButtons.SelectNext();
                return(true);

            case GlobalAction.Back:
                BackAction.Invoke();
                return(true);

            case GlobalAction.Select:
                SelectAction.Invoke();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 26
0
        public bool OnPressed(GlobalAction action)
        {
            switch (action)
            {
            case GlobalAction.SelectPrevious:
                if (selectionIndex == -1 || selectionIndex == 0)
                {
                    setSelected(InternalButtons.Count - 1);
                }
                else
                {
                    setSelected(selectionIndex - 1);
                }
                return(true);

            case GlobalAction.SelectNext:
                if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
                {
                    setSelected(0);
                }
                else
                {
                    setSelected(selectionIndex + 1);
                }
                return(true);

            case GlobalAction.Back:
                BackAction.Invoke();
                return(true);

            case GlobalAction.Select:
                SelectAction.Invoke();
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Start snapshot mode with loading data
        /// </summary>
        private void StartLoadingSnapshot(string path, int?selectedElementId = null)
        {
            DisableElementSelector();

            var v = SelectAction.GetDefaultInstance().SelectLoadedData(path, selectedElementId);

            if (selectedElementId.HasValue)
            {
                Logger.PublishTelemetryEvent(TelemetryAction.Hierarchy_Load_Protocol, TelemetryProperty.ProtocolMode, v.Item2.Mode.ToString());
            }
            Logger.PublishTelemetryEvent(TelemetryAction.Hierarchy_Load_NewFormat, TelemetryProperty.FileMode, v.Item2.Mode.ToString());

            if (v.Item2.Mode == A11yFileMode.Test && !selectedElementId.HasValue)
            {
                StartTestAutomatedChecksView();
            }
            else if (v.Item2.Mode == A11yFileMode.Contrast)
            {
                StartTestAutomatedChecksView(); // we got rid of the CC test tab.
            }
            else // A11yFileMode.Inspect
            {
                this.ctrlCurMode.HideControl();
                this.ctrlCurMode = this.ctrlSnapMode;
                this.ctrlSnapMode.DataContextMode = GetDataContextModeForTest();
                this.CurrentPage = AppPage.Test;
                this.CurrentView = TestView.ElementDetails;
                this.ctrlCurMode.ShowControl();
#pragma warning disable CS4014
                // NOTE: We aren't awaiting this async call, so if you
                // touch it, consider if you need to add the await
                this.ctrlSnapMode.SetElement(v.Item1);
#pragma warning restore CS4014
            }

            PageTracker.TrackPage(this.CurrentPage, this.CurrentView.ToString());
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Start CCA Automatic Monitor mode
        /// show only single selected item information
        /// </summary>
        private void StartCCAMode()
        {
            if (!(this.CurrentPage == AppPage.CCA && (CCAView)this.CurrentView == CCAView.Automatic))
            {
                this.CurrentPage = AppPage.CCA;
                this.CurrentView = CCAView.Automatic;
                PageTracker.TrackPage(this.CurrentPage, this.CurrentView.ToString());

                // make sure that highlighter is cleared for new selection.
                HollowHighlightDriver.GetDefaultInstance().Clear();

                SetWindowForAutomaticMode();
            }

            SelectAction.GetDefaultInstance().Scope = SelectionScope.Element;

            // set the state to Capturing view. it will prevent testing for safety.
            this.CurrentView = CCAView.CapturingData;

            var ecId = SelectAction.GetDefaultInstance().GetSelectedElementContextId();

            if (ecId != null)
            {
                // make sure that no more selection is requested.
                DisableElementSelector();

                // Pass the currently selected Element Context
                this.ctrlCurMode.SetElement(ecId.Value);
            }
            else
            {
                this.CurrentView = CCAView.Automatic;
            }

            // enable element selector
            EnableElementSelector();
        }
        /// <summary>
        /// Set Hot Key for event recording
        /// honor the value from Configuration file.
        /// </summary>
        private void SetHotKeyForToggleRecord()
        {
            SetHotKey(ConfigurationManager.GetDefaultInstance().AppConfig.HotKeyForRecord,
                      new Action(() =>
            {
                lock (_lockObject)
                {
                    Dispatcher.Invoke(() =>
                    {
                        lock (_lockObject)
                        {
                            if (this.CurrentPage == AppPage.Test && (TestView)this.CurrentView == TestView.TabStop)
                            {
                                ctrlTestMode.ctrlTabStop.ToggleRecording();
                            }
                            else if (this.CurrentPage == AppPage.Events && this.CurrentView != EventsView.Load)
                            {
                                ctrlEventMode.ctrlEvents.ToggleRecording();
                            }
                            else
                            {
                                var sa = SelectAction.GetDefaultInstance();

                                // make sure that POI is set.
                                if (this.IsInSelectingState() && sa.HasPOIElement())
                                {
                                    this.StartEventsMode(GetDataAction.GetElementContext(sa.GetSelectedElementContextId().Value).Element);
                                    UpdateMainWindowUI();
                                }
                            }
                        }
                    });
                }
            }),
                      ErrorMessage(ConfigurationManager.GetDefaultInstance().AppConfig.HotKeyForSnap));
        }
Ejemplo n.º 30
0
        public SmsEnterpriseCfgInfo GetModelWithKey(string cfgkey, int enterpriseId)
        {
            string key = "enterprise_" + cfgkey + enterpriseId;
            SmsEnterpriseCfgInfo getCacheValue = CacheHelper.Cache.Get <SmsEnterpriseCfgInfo>(key);

            if (getCacheValue == null)
            {
                using (SelectAction action = new SelectAction(this.Entity))
                {
                    action.SqlWhere(SmsEnterpriseCfgInfo.Columns.CfgKey, cfgkey);
                    SmsEnterpriseCfgInfo info = action.QueryEntity <SmsEnterpriseCfgInfo>();
                    if (info != null)
                    {
                        CacheHelper.Cache.Set(key, info);
                        return(info);
                    }
                }
            }
            else
            {
                return(getCacheValue);
            }
            return(null);
        }
Ejemplo n.º 31
0
    protected override void OnGUI()
    {
        base.OnGUI();

        if (ItemDatabase != null)
        {

            GUILayout.Space(10);

            GUI.color = Color.green;
            GUILayout.BeginHorizontal();

            if (SelectedAction == SelectAction.CreateItem)
            {
                GUI.color = Color.green;
            }
            else
            {
                GUI.color = Color.white;
            }
            if (GUILayout.Button("Create item"))
            {
                SelectedAction = SelectAction.CreateItem;
            }

            if (SelectedAction == SelectAction.ManageItem)
            {
                GUI.color = Color.green;
            }
            else
            {
                GUI.color = Color.white;
            }
            if (GUILayout.Button("Edit items"))
            {
                SelectedAction = SelectAction.ManageItem;
            }
            GUILayout.EndHorizontal();

            GUI.color = Color.white;

            GUILayout.Space(25);

            if (SelectedAction == SelectAction.CreateItem)
            {
                CreateItems();
            }
            else if (SelectedAction == SelectAction.ManageItem)
            {
                ManageItems();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(ItemDatabase);
                PrefabUtility.SetPropertyModifications(PrefabUtility.GetPrefabObject(ItemDatabase), PrefabUtility.GetPropertyModifications(ItemDatabase));
            }
        }
        else
        {
            CreateItemDatabase();
        }
    }
Ejemplo n.º 32
0
    protected override void OnGUI()
    {
        base.OnGUI();
        //BlueprintDatabase = (BlueprintDatabase)AssetDatabase.LoadAssetAtPath("Assets/Components/Inventory/Extensions/Crafting/Data/BlueprintDatabase.asset", typeof(BlueprintDatabase)) as BlueprintDatabase;
        if (ItemDatabase != null && BlueprintDatabase != null)
        {

            GUILayout.Space(10);
            GUILayout.BeginHorizontal();

            if (SelectedAction == SelectAction.CreateBlueprint)
            {
                GUI.color = Color.green;
            }
            else
            {
                GUI.color = Color.white;
            }
            if (GUILayout.Button("Create blueprint"))
            {
                SelectedAction = SelectAction.CreateBlueprint;
                //CraftItem = new CraftedItem();
                //CraftItem.MaterialsId = new List<int>();
            }

            if (SelectedAction == SelectAction.ManageBlueprint)
            {
                GUI.color = Color.green;
            }
            else
            {
                GUI.color = Color.white;
            }
            if (GUILayout.Button("Edit blueprints"))
            {
                SelectedAction = SelectAction.ManageBlueprint;
            }

            GUILayout.EndHorizontal();

            GUI.color = Color.white;

            GUILayout.Space(25);

            if (SelectedAction == SelectAction.CreateBlueprint)
            {
                CreateBlueprint();
            }
            else if (SelectedAction == SelectAction.ManageBlueprint)
            {
                ManageBlueprint();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(BlueprintDatabase);
                PrefabUtility.SetPropertyModifications(PrefabUtility.GetPrefabObject(BlueprintDatabase), PrefabUtility.GetPropertyModifications(BlueprintDatabase));
            }
        }
        else
        {
            CreateBlueprintDatabase();
        }
    }