public ItemBasic(Cloud cloud) { InitializeComponent(); BasicAvatar.Source = new BitmapImage(cloud.Avatar.Normal); BasicName.Text = cloud.Name; Cloud = cloud; }
public async static void JoinCloud(Cloud cloud) { if (App.Connection.MessageController.CloudControllers.ContainsKey(cloud.Id)) { Main.Instance.Clouds.SelectedItem = Main.Instance.Clouds.Items.IndexOf(App.Connection.ModelController.Clouds[cloud.Id]); return; } var client = new HttpClient { DefaultRequestHeaders = { {"Accept", "application/json"}, {"X-Auth-Token", App.Connection.SessionController.CurrentSession.AuthToken} } }; await client.PutAsync(Endpoints.CloudUserRestate.Replace("[:id]", cloud.Id).ReplaceUserId( App.Connection.SessionController.CurrentSession.Id), new StringContent("")); App.Connection.SessionController.CurrentSession.Clouds.Add(cloud); App.Connection.MessageController.CloudControllers.Add(cloud.Id, new CloudController(cloud)); App.Connection.SessionController.RefreshClouds(); Main.Instance.Clouds.SelectedIndex = Main.Instance.Clouds.Items.Count - 1; FayeConnector.Subscribe("/clouds/" + cloud.Id + "/chat/messages"); }
public OwnedCloud(Cloud cloud) { InitializeComponent(); Cloud = cloud; Shortlink.Text = "/clouds/" + cloud.ShortName; CloudAvatar.Source = new BitmapImage(cloud.Avatar.Normal); Name.Text = cloud.Name; if (cloud.Description != null) DescriptionBox.Text = cloud.Description.Replace("\n", "\r\n"); if (cloud.Rules != null) RulesBox.Text = cloud.Rules.Replace("\n", "\r\n"); }
public StandardCloud(Cloud cloud) { InitializeComponent(); CloudAvatar.Source = new BitmapImage(cloud.Avatar.Normal); CloudName.Text = cloud.Name; Shortlink.Text = "/clouds/" + cloud.ShortName; Cloud = cloud; if (cloud.Rules != null) Rules.Text = cloud.Rules.Replace("\n", "\r\n"); if (cloud.Description != null) Description.Text = cloud.Description.Replace("\n", "\r\n"); if (Cloud.IsSubscribed) SubBox.IsChecked = true; }
public CloudController this[Cloud cloud] { get { if (!CloudControllers.ContainsKey(cloud.Id)) { CloudControllers[cloud.Id] = new CloudController(cloud); } return CloudControllers[cloud.Id]; } }
public async Task<Cloud> UpdateCloudAsync(Cloud cloud) { if (!Clouds.ContainsKey(cloud.Id)) { await cloud.ForceValidate(); Clouds[cloud.Id] = cloud; } else { cloud.CopyTo(Clouds[cloud.Id]); } return Clouds[cloud.Id]; }
public CloudView(Cloud cloud) { InitializeComponent(); Instance = this; Title = cloud.Name; Cloud = cloud; App.Connection.MessageController[cloud].UnreadMessages = 0; Name.Text = cloud.Name; Dispatcher.BeginInvoke(new Action(ChatScroll.ScrollToBottom)); CloudMessages.ItemsSource = App.Connection.MessageController[cloud].Messages; InputBox.Focus(); Dispatcher.InvokeAsync(async() => { foreach (var id in cloud.UserIds) { App.Connection.ModelController.Users[id] = await App.Connection.ModelController.GetUserAsync(id); } }, DispatcherPriority.Background); }
public CloudController(Cloud cloud) { Cloud = cloud; FixSessionStatus(); BeenLoaded = false; }
public Cloud UpdateCloud(Cloud cloud) { if (!Clouds.ContainsKey(cloud.Id)) { cloud.ForceValidate(); Clouds[cloud.Id] = cloud; } else { var cacheCloud = Clouds[cloud.Id]; cloud.CopyTo(cacheCloud); } return Clouds[cloud.Id]; }
public Cloud GetCloud(string cloudId) { if (!Clouds.ContainsKey(cloudId)) { var cloud = new Cloud(cloudId); cloud.ForceValidate(); Clouds[cloud.Id] = cloud; } else { Clouds[cloudId].Validate(); } return Clouds[cloudId]; }
public Cloud UpdateCloud(Cloud cloud) { return cloud; }
public async Task<CloudView> Page(Cloud cloud) { return Pages[cloud.Id] ?? new CloudView(cloud); }
public ItemTop(Cloud cloud) { InitializeComponent(); }
public async void GatherClouds() { FinalizedUI.Visibility = Visibility.Hidden; CurrentStatus.Text = "Gathering clouds..."; var client = new HttpClient { DefaultRequestHeaders = { {"X-Result-Time", DateTime.Now.ToString("o")}, {"X-Result-Per", "100"}, {"Accept", "application/json"} } }; var response = JsonConvert.DeserializeObjectAsync<WebResponse<Cloud[]>>( await client.GetStringAsync(Endpoints.ExplorePopular)); foreach(var cloud in response.Result.Result) { cloud.ForceValidate(); _gathered.Add(cloud); } CurrentStatus.Text = "Finished gathering clouds."; CurrentStatus.Text = "Assigning clouds..."; var newMax = new Random().Next(4, 20); while (_assigned.Count < newMax) { _assigned.Add(_gathered[new Random().Next(0, 99)]); } CurrentStatus.Text = "Finished assigning clouds."; CurrentStatus.Text = "Roulette has gathered " + newMax + " clouds for you. Preparing to choose..."; var clock = new Timer { Interval = 1000, }; clock.Start(); clock.Elapsed += delegate { var sec = 0; if (sec < 3) { ++sec; return; } clock.Stop(); }; var finalInt = new Random().Next(0, newMax - 1); FinalCloud = _assigned[finalInt]; Join(this, null); }