Example #1
0
        public void Apply()
        {
            if (RefreshDelegate == null)
            {
                return;
            }

            _applied = false;

            var rules = SelectedEventType.As <AssignmentType>().GetSubEventInsertRules();

            var selectedAgents = GetSelectedAgents(EmployeeSelectionWay == 1).ForEach <IAgent>(o =>
            {
                var timeBox       = o.Schedule;
                var newAssignment = Term.NewAssignment(ShiftStart, ShiftEnd, SelectedEventType);
                newAssignment.Tag = Comments;
                timeBox.Create(newAssignment, (terms, success) =>
                {
                    if (success)
                    {
                        timeBox.ArrangeSubEvent(newAssignment as IAssignment, rules, (t, result) =>
                        {
                            if (success)
                            {
                                ((Term)t).Tag = Comments;
                            }
                        });
                        _applied = true;
                    }
                    else
                    {
                        o.OperationFail = true;
                    }
                }, false);
            });

            RefreshDelegate.Invoke(selectedAgents, _applied);
        }
Example #2
0
        internal void Scan(AutomationElement handle)
        {
            this.Handle = handle;
            var EventBlock = handle.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "EventBlocksListBox"));

            SelectedEventType = EventBlock.FindFirst(TreeScope.Children, new PropertyCondition(SelectionItemPattern.IsSelectedProperty, true));
            CurrentEventName  = SelectedEventType.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ClassNameProperty, "TextBlock")).Current.Name;

            PlayLobbyOpenPlayDetails = handle.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "PlayLobbyOpenPlayDetails"));

            if (PlayLobbyOpenPlayDetails != null)
            {
                var MatchesListBox           = PlayLobbyOpenPlayDetails.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "MatchesListBox"));
                List <OpenPlayMatch> matches = new List <OpenPlayMatch>();
                foreach (AutomationElement openPlayMatch in MatchesListBox.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "ListBoxItem")))
                {
                    matches.Add(new OpenPlayMatch(openPlayMatch));
                }
                Matches = matches.ToArray();
            }

            var FFTP = handle.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Freeform Tournament Practice"));

            if (FFTP == null)
            {
                if (DeckListErrors != null)
                {
                    DeckListErrors = null;
                }
                return;
            }

            var fftpOpenPlayViewModel = TreeWalker.ControlViewWalker.GetParent(TreeWalker.ControlViewWalker.GetParent(FFTP));

            var selctable = fftpOpenPlayViewModel.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;

            if (!selctable.Current.IsSelected)
            {
                if (DeckListErrors != null)
                {
                    DeckListErrors = null;
                }
                return;
            }
            FftpLabelLocation = FFTP.Current.BoundingRectangle.Location.ToDrawing();

            var PlayLobbyEventDeckView = handle.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ClassNameProperty, "PlayLobbyEventDeckView"));

            if (PlayLobbyEventDeckView != null && !PlayLobbyEventDeckView.Current.IsOffscreen)
            {
                DeckName = PlayLobbyEventDeckView.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "TextBlock")).Current.Name;
            }


            AutomationElement PlayLobbyDeckListView = handle.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ClassNameProperty, "PlayLobbyDeckListView"));

            if (PlayLobbyDeckListView != null)
            {
                Decklist = new Decklist(PlayLobbyDeckListView);
                Decklist.IsPDLegal();
            }
            else if (DeckListErrors != null)
            {
                DeckListErrors = null;
            }
        }