void handleBotClientMessagesChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            Log.Debug($"{e.Action}");

            BeginInvokeOnMainThread(() =>
            {
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    addNewMessage(false);
                    break;

                case NotifyCollectionChangedAction.Remove:
                    TableView.DeleteRows(new [] { NSIndexPath.FromIndex((nuint)e.OldStartingIndex) }, UITableViewRowAnimation.None);
                    break;

                case NotifyCollectionChangedAction.Replace:
                    TableView.ReloadData();
                    break;

                case NotifyCollectionChangedAction.Reset:
                    TableView.ReloadData();
                    TableView.SlackScrollToTop(false);
                    break;
                }
            });
        }
示例#2
0
 public void FromIndex()
 {
     using (var ip = NSIndexPath.FromIndex(314159)) {
         Assert.AreEqual((nint)1, ip.Length, "Length");
         var rv = ip.GetIndexes();
         Assert.AreEqual(1, rv.Length, "GetIndexes ().Length");
         Assert.AreEqual((nuint)314159, rv [0], "GetIndexes ()[0]");
     }
 }
示例#3
0
 public void IndexPathByRemovingLastIndexTest()
 {
     using (var ip1 = NSIndexPath.FromIndex(3)) {
         using (var ip2 = ip1.IndexPathByRemovingLastIndex()) {
             Assert.AreEqual((nint)0, ip2.Length, "Length");
             var rv = ip2.GetIndexes();
             Assert.AreEqual(0, rv.Length, "GetIndexes ().Length");
         }
     }
 }
示例#4
0
        public void Clear()
        {
            var array  = (NSArray)TestResultController.Content;
            var length = (int)array.Count;

            for (int i = 0; i < length; i++)
            {
                var index = NSIndexPath.FromIndex(0);
                TestResultController.RemoveObjectAtArrangedObjectIndexPath(index);
            }
        }
示例#5
0
        void ClearSelected()
        {
            var data = (SelectGameDataSource)Grid.Source;

            for (int i = 0; i < GameSet.GameCount; i++)
            {
                var path = NSIndexPath.FromIndex((System.nuint)i);
                var cell = data.GetCell(Grid, path) as SelectGameCell;
                cell.Selected = false;

                var highScore = GameData.Current.GetGameHighScore(cell.GameDefinition as GameDefinition);
                cell.BackgroundColor = highScore == null ? "#FF0000".ToUIColor(0.5f) : "#FF0000".ToUIColor(0);
            }
        }
        // Index is optional such that the method could be used onSelected(item)
        public async void UploadSessions(int index, bool recursive)
        {
            var sessions = SessionsViewSource.Sessions;

            // Out of bounds validation
            if (sessions.ElementAtOrDefault(index) == null)
            {
                return;
            }

            // Update attribute so when item is reloaded the indicator will animate.
            sessions[index].IsUploading = true;
            var item = NSIndexPath.FromIndex((uint)Sessions.IndexOf(sessions[index]));

            SessionsCollectionView.ReloadItems(new NSIndexPath[] { item });
            Logger.LOG_EVENT_WITH_ACTION("UPLOAD_SESSION", "ATTEMPT");
            // TODO: creating a new instance of API for each view, urgh.
            var didUpload = await new RestClient().Upload(sessions[index]);

            if (didUpload)
            {
                Logger.LOG_EVENT_WITH_ACTION("UPLOAD_SESSION", "SUCCESS");
                sessions[index].IsUploaded = true;
                // Update state so the session isnt shown on reload etc.
                Session.Connection.Update(sessions[index]);
                sessions.Remove(sessions[index]);
                SessionsCollectionView.ReloadData();
                PresentViewController(new MessageDialog().BuildErrorMessageDialog(
                                          StringResources.sessions_ui_message_upload_success, ""), true, null);
                // Try to upload the next session
                if (recursive)
                {
                    UploadSessions(0, true);
                }
            }
            else
            {
                Logger.LOG_EVENT_WITH_ACTION("UPLOAD_SESSION", "ERROR");
                // Stop spining
                sessions[index].IsUploading = false;
                SessionsCollectionView.ReloadItems(new NSIndexPath[] { item });
                PresentViewController(
                    new MessageDialog().BuildErrorMessageDialog(
                        StringResources.sessions_ui_message_upload_fail, ""), true, null);
            }
            if (Sessions.Count <= 0)
            {
                ShowHideInstructions();
            }
        }
示例#7
0
        async void OnSessionChanged(TestSession session)
        {
            if (session != null)
            {
                var test = session.RootTestCase;
                if (test != null)
                {
                    var model = await TestCaseModel.Create(session, test);

                    TestResultController.AddObject(model);
                }
            }
            else
            {
                var array  = (NSArray)TestResultController.Content;
                var length = (int)array.Count;
                for (int i = 0; i < length; i++)
                {
                    var index = NSIndexPath.FromIndex(0);
                    TestResultController.RemoveObjectAtArrangedObjectIndexPath(index);
                }
            }
        }