示例#1
0
 public ItemBasic(Cloud cloud)
 {
     InitializeComponent();
     BasicAvatar.Source = new BitmapImage(cloud.Avatar.Normal);
     BasicName.Text = cloud.Name;
     Cloud = cloud;
 }
示例#2
0
        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");
        }
示例#3
0
 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];
            }
        }
示例#6
0
        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];
        }
示例#7
0
 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);
 }
示例#8
0
 public CloudController(Cloud cloud)
 {
     Cloud = cloud;
     FixSessionStatus();
     BeenLoaded = false;
 }
示例#9
0
        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];
        }
示例#10
0
        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];
        }
示例#11
0
 public Cloud UpdateCloud(Cloud cloud)
 {
     return cloud;
 } 
示例#12
0
 public async Task<CloudView> Page(Cloud cloud)
 {
     return Pages[cloud.Id] ?? new CloudView(cloud);
 }
示例#13
0
 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);
        }