Ejemplo n.º 1
0
        private void DropItemClick(object sender, RoutedEventArgs e)
        {
            var button = sender as FrameworkElement;
            if (button == null) return;
            var drop = button.DataContext as Drop;
            if (drop == null) return;

            Leaving = false;

            if (CloudsdaleUrl.IsMatch(drop.url.ToString())) {
                LayoutRoot.IsHitTestVisible = false;
                var apiend = new Uri("http://www.cloudsdale.org/v1/clouds/" + drop.url.ToString().Split('/').Last());
                WebPriorityManager.BeginHighPriorityRequest(apiend, args => Dispatcher.BeginInvoke(() => {
                    try {
                        var response = JObject.Parse(args.Result);
                        var cloud = PonyvilleDirectory.RegisterCloud(response["result"].ToObject<Cloud>());
                        LayoutRoot.IsHitTestVisible = true;
                        NavigateCloud(cloud);
                    } catch {
                        MessageBox.Show("We're sorry, the cloud you clicked on couldn't be loaded :< Maybe it has been deleted?");
                        LayoutRoot.IsHitTestVisible = true;
                    }
                }));
            } else {
                LastDropClicked = drop;
                NavigationService.Navigate(new Uri("/DropViewer.xaml", UriKind.Relative));
            }
        }
Ejemplo n.º 2
0
        private void InChatDropTap(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
        {
            var button = sender as FrameworkElement;
            if (button == null) return;
            var drop = button.DataContext as Drop;
            if (drop == null) return;

            Leaving = false;

            if (CloudsdaleUrl.IsMatch(drop.url.ToString())) {
                LayoutRoot.IsHitTestVisible = false;
                WebPriorityManager.BeginHighPriorityRequest(new Uri("http://www.cloudsdale.org/v1/clouds/" + drop.url.ToString()
                    .Split('/').Last()), args => {
                        var response = JObject.Parse(args.Result);
                        var cloud = PonyvilleDirectory.RegisterCloud(response["result"].ToObject<Cloud>());
                        Dispatcher.BeginInvoke(() => LayoutRoot.IsHitTestVisible = true);
                        NavigateCloud(cloud);
                    });
            } else {
                LastDropClicked = drop;
                NavigationService.Navigate(new Uri("/DropViewer.xaml", UriKind.Relative));
            }
        }
Ejemplo n.º 3
0
        private void ChatLinkClicked(object sender, LinkClickedEventArgs eargs)
        {
            Uri linkuri;

            if (!Uri.TryCreate(eargs.LinkValue, UriKind.Absolute, out linkuri) &&
                !Uri.TryCreate("http://" + eargs.LinkValue, UriKind.Absolute, out linkuri)) {
                return;
            }

            var drop = new Drop {
                id = Guid.NewGuid().ToString(),
                preview = new Uri("http://assets.cloudsdale.org/assets/fallback/preview_thumb_drop.png"),
                title = eargs.LinkValue,
                url = linkuri,
            };

            if (CloudsdaleUrl.IsMatch(drop.url.ToString())) {
                LayoutRoot.IsHitTestVisible = false;
                var apiend = new Uri("http://www.cloudsdale.org/v1/clouds/" + drop.url.ToString().Split('/').Last());
                WebPriorityManager.BeginHighPriorityRequest(apiend, args => Dispatcher.BeginInvoke(() => {
                    try {
                        var response = JObject.Parse(args.Result);
                        var cloud = PonyvilleDirectory.RegisterCloud(response["result"].ToObject<Cloud>());
                        LayoutRoot.IsHitTestVisible = true;
                        NavigateCloud(cloud);
                    } catch {
                        MessageBox.Show("We're sorry, the cloud you clicked on couldn't be loaded :< Maybe it has been deleted?");
                        LayoutRoot.IsHitTestVisible = true;
                    }
                }));
            } else {
                LastDropClicked = drop;
                NavigationService.Navigate(new Uri("/DropViewer.xaml", UriKind.Relative));
            }
        }