Ejemplo n.º 1
0
        public string TileContent(string id, string sessionCookie, string sessionSignature)
        {
            var authClient = new AuthClient(sessionSignature, sessionCookie);
            var activityList = authClient.GetActivities();
            var couple = authClient.GetUsers();
            foreach (var activity in activityList)
            {
                activity.User = activity.UserId == couple.CurrentUser.Id ? couple.CurrentUser : couple.OtherUser;
            }
            activityList.Reverse();

            // get the first image, or the first message from the other user
            var message = (from a in activityList
                           where a.IsList == false && a.IsEvent == false
                           && (a.IsMessage == false || a.UserId != id)
                           select a).FirstOrDefault();
            var result = string.Empty;
            if (message.IsMessage)
            {
                var messageTile = "<tile><visual version=\"1\" lang=\"en-US\"><binding template=\"TileWideImageAndText01\">"
                    + "<image id=\"1\" src=\"{0}\"/><text id=\"1\">{1}</text></binding><binding template=\"TileSquareText04\"><text id=\"1\">{1}</text></binding></visual></tile>";
                result = string.Format(messageTile, message.User.AvatarUrl, message.Data.Text);
            }
            else if (message.IsImage)
            {
                var imageTile = "<tile><visual version=\"1\" lang=\"en-US\"><binding template=\"TileWideImage\">"
                    + "<image id=\"1\" src=\"{0}\"/></binding><binding template=\"TileSquareImage\">"
                    + "<image id=\"1\" src=\"{0}\"/></binding></visual></tile>";
                result = string.Format(imageTile, message.Data.ImageUrls.Small);

            }
            return result;
        }
Ejemplo n.º 2
0
 public void AttemptLogin()
 {
     AuthClient = new AuthClient();
     AuthClient.Email = Email;
     AuthClient.Password = Password;
     if (AuthClient.AttemptLogin())
     {
         var couple = AuthClient.GetUsers();
         if (couple.CurrentUser != null)
         {
             NavigationService n = new NavigationService();
             n.NavigateTo(typeof(Avocado.Views.Activities), AuthClient);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                //Associate the frame with a SuspensionManager key                                
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter

                // Probably going to navigate to the Login page
                var navigateTo = typeof(LoginPage);
                dynamic param = "";

                // See if we can recover the AuthClient from the session. If so, go straight to the activity view with the auth client as the context
                var AuthClient = new AuthClient();
                if (!string.IsNullOrEmpty(AuthClient.AvoSignature) && !string.IsNullOrEmpty(AuthClient.CookieValue))
                {
                    var couple = AuthClient.GetUsers();
                    if (couple.CurrentUser != null)
                    {
                        navigateTo = typeof(Activities);
                        param = AuthClient;
                    }
                }
                if (!rootFrame.Navigate(navigateTo, param))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }