private void RunAsync(object o) { lock (sync) { requests++; } var node = o as Node; if (null != node) { var client = new Client(model.LocalNode); var verb = new CompareVerb(model); if (client.Execute(verb, node)) { if (!verb.Allowed) { verb.Node.Nickname = node.Nickname; verb.Node.Location = node.Location; verb.Node.Status = "Denied"; data.Add(verb.Node); } else { verb.Node.Nickname = node.Nickname; verb.Node.Location = node.Location; verb.Node.Status = "OK"; data.Add(verb.Node); } } else { verb.Node = new CompareNode(); verb.Node.Nickname = node.Nickname; verb.Node.Location = node.Location; verb.Node.Status = "Error"; data.Add(verb.Node); } } lock (sync) { requests--; viewModel.Status = "Status: Waiting for a response from " + requests + " peers.."; if (requests == 0) { viewModel.EnableRun = true; viewModel.Status = "Status: All Information recieved, click start to refresh info (Note clients will cache information for 5 minutes)."; } } }
private void GetStatusReplied(TwitterStatus status) { if (status.InReplyToStatusId != null) { Interlocked.Increment(ref pendingCalls); service.GetTweet(new GetTweetOptions { Id = (long)status.InReplyToStatusId }, (result, response) => { if (result == null || response.StatusCode != HttpStatusCode.OK) { RaiseCallback(new List <TwitterStatus>(), response); // report the error TryFinish(); return; } okResponse = response; if (!searchCache.Contains(result)) { searchCache.Add(result); } RaiseCallback(new List <TwitterStatus> { status, result }, response); GetConversationForStatus(result); TryFinish(); }); } }
private void AddCachedResult(string user, long from) { searchesPerformed.Add(new SearchRequest { user = user, from = from }); }
public MainPageModel() { Samples = new SafeObservable <SampleItem>(); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "SelectedSample" && SelectedSample != null) { SelectedSample.Navigate(); } }; Samples.Add(SampleItem.Create <AppBarModel>("app bar")); Samples.Add(SampleItem.Create <ConverterModel>("converter")); Samples.Add(SampleItem.Create <AutoSettingsModel>("automatic settings")); Samples.Add(SampleItem.Create <ProgressModel>("progress indicator")); }
void ReevaluateInList() { List <T> itemsToDelete = new List <T>(); foreach (var item in this) { if (Matches(item)) { itemsToDelete.Add(item); discardedItems.Add(item); } } foreach (var item in itemsToDelete) { this.Remove(item); } }
/// <summary> /// New conversion has been added - add a window. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void uiConversations_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (Conversation c in e.NewItems) { var vm = container.Resolve <ConversationViewModel>(); vm.SendChatMessage = new DelegateCommand(SendChatMessage); vm.Conversation = c; viewModels.Add(vm); windowController.AddWindow(vm.View, c.OtherParty.Nickname); } } }
public ColumnViewModel() { Pivots = new SafeObservable <ColumnViewPivotModel>(); enableQuickAdd = new DelegateCommand((param) => FastAddMode = true); disableQuickAdd = new DelegateCommand((param) => FastAddMode = false); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "FastAddMode") { foreach (var p in Pivots) { p.FastAddMode = FastAddMode; } } }; foreach (var account in Config.Accounts) { var pivot = new ColumnViewPivotModel(account); pivot.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsLoading") { var p = sender as ColumnViewPivotModel; if (p == null) { return; } if (p.IsLoading) { pivotsLoading++; } else { pivotsLoading--; } IsLoading = pivotsLoading > 0; } }; Pivots.Add(pivot); } }
private void ReceiveUsers(TwitterCursorList <TwitterUser> users, TwitterResponse response) { if (response.StatusCode == HttpStatusCode.NotFound) { MessageService.ShowError(Resources.CouldntFindUser); GoBack(); return; } else if (response.StatusCode != HttpStatusCode.OK || users == null) { MessageService.ShowError(Resources.ErrorMessage); GoBack(); return; } foreach (var usr in users) { if (!list.Contains(usr)) { list.Add(usr); } } if (users.NextCursor != null && users.NextCursor != 0) { if (whatUserList == "followers") { ServiceDispatcher.GetCurrentService().ListFollowers(new ListFollowersOptions { ScreenName = user }, ReceiveUsers); } else if (whatUserList == "following") { ServiceDispatcher.GetCurrentService().ListFriends(new ListFriendsOptions { ScreenName = user }, ReceiveUsers); } } else { IsLoading = false; } }
public ColumnViewModel() { Pivots = new SafeObservable<ColumnViewPivotModel>(); enableQuickAdd = new DelegateCommand((param) => FastAddMode = true); disableQuickAdd = new DelegateCommand((param) => FastAddMode = false); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "FastAddMode") foreach (var p in Pivots) p.FastAddMode = FastAddMode; }; foreach (var account in Config.Accounts) { var pivot = new ColumnViewPivotModel(account); pivot.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsLoading") { var p = sender as ColumnViewPivotModel; if (p == null) return; if (p.IsLoading) pivotsLoading++; else pivotsLoading--; IsLoading = pivotsLoading > 0; } }; Pivots.Add(pivot); } }
private void GetRepliesFor(TwitterStatus status) { if (processedStatuses.Contains(status)) { return; } processedStatuses.Add(status); // There's a possibility that a status can be processed two times... but it's not significant nor a real problem. if (AreResultsCached(status.AuthorName, status.Id)) { RetrieveRepliesFromCache(status); TryFinish(); } else { Interlocked.Increment(ref pendingCalls); service.Search(new SearchOptions { Q = "to:" + status.AuthorName, SinceId = status.Id, Count = 100 }, (result, response) => SearchCallback(result, response, status)); } }
public AppBarModel() { MenuItems = new SafeObservable <BindableAppBarMenuItem>(); Buttons = new SafeObservable <BindableAppBarButton>(); AddButton = new DelegateCommand(() => { if (Buttons.Count < 4) { Buttons.Add(new BindableAppBarButton { Text = NewItemText, IconUri = new Uri("/Toolkit.Content/ApplicationBar.Select.png", UriKind.Relative) }); } else { Notificator.ShowError("Woops, too many buttons."); } }); AddMenuItem = new DelegateCommand(() => MenuItems.Add(new BindableAppBarMenuItem { Text = NewItemText })); var button = new BindableAppBarToggleButton { Text1 = "not toggled", Text2 = "toggled", IconUri1 = new Uri("/Toolkit.Content/ApplicationBar.Add.png", UriKind.Relative), IconUri2 = new Uri("/Toolkit.Content/ApplicationBar.Delete.png", UriKind.Relative) }; var hlButton = new BindableAppBarHyperlinkButton { Text = "external link", IconUri = new Uri("/Toolkit.Content/ApplicationBar.Check.png", UriKind.Relative), Uri = "http://github.com/gjulianm/AncoraMVVM" }; var hlIButton = new BindableAppBarHyperlinkButton { Text = "internal link", IconUri = new Uri("/Toolkit.Content/ApplicationBar.Check.png", UriKind.Relative), Uri = "/Views/MainPage.xaml" }; Buttons.Add(button); Buttons.Add(hlButton); Buttons.Add(hlIButton); MenuItems.Add(new BindableAppBarHyperlinkMenuItem { Text = "external link", Uri = "http://github.com/gjulianm/AncoraMVVM" }); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "Toggled") { button.Toggled = Toggled; } }; Opacity = 0.5; }