Example #1
0
 private void setImage_btn_Click(object sender, RoutedEventArgs e)
 {
     if (CustomBackgroundImage != null && !CustomBackgroundImage.selected)
     {
         BackgroundImageCache.setCustomBackgroundImage();
         //chatDetailsDummy_cdc.loadBackgrundImage();
     }
 }
Example #2
0
 private void AdaptiveGridView_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (e.ClickedItem is BackgroundImageTemplate)
     {
         BackgroundImageTemplate img = e.ClickedItem as BackgroundImageTemplate;
         BackgroundImageCache.setExampleBackgroundImage(img);
         //chatDetailsDummy_cdc.loadBackgrundImage();
     }
 }
Example #3
0
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--


        #endregion

        #region --Misc Methods (Private)--
        private async Task browseBackgroundAsync()
        {
            FileOpenPicker picker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");

            StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                string path = await BackgroundImageCache.saveAsCustomBackgroundImageAsync(file);

                if (path != null)
                {
                    BackgroundImageCache.setCustomBackgroundImage();
                    CustomBackgroundImage = null;
                    CustomBackgroundImage = BackgroundImageCache.customBackgroundImage;
                    //chatDetailsDummy_cdc.loadBackgrundImage();
                    Logger.Info("Custom background image set to: " + file.Path);
                }
                else
                {
                    showInfo("Failed to pick image!");
                    Logger.Warn("Failed to set image as background image. Path is null!");
                }
            }
            else
            {
                showInfo("Selection canceled!");
            }
        }
Example #4
0
        private async void deleteCustomImage_btn_Click(object sender, RoutedEventArgs e)
        {
            await BackgroundImageCache.deleteCustomBackgroundImage();

            CustomBackgroundImage = BackgroundImageCache.customBackgroundImage;
        }
Example #5
0
 private void remove_ibtn_Click(object sender, RoutedEventArgs args)
 {
     BackgroundImageCache.removeBackgroundImage();
     //chatDetailsDummy_cdc.loadBackgrundImage();
 }
Example #6
0
        private async Task onActivatedOrLaunchedAsync(IActivatedEventArgs args)
        {
            // Sets the log level:
            initLogLevel();

            // Register background tasks:
            Logger.Info("Registering background tasks...");
            await BackgroundTaskHelper.registerToastBackgroundTaskAsync();

            Logger.Info("Finished registering background tasks.");

            // Init all db managers to force event subscriptions:
            initAllDBManagers();

            // Set default background:
            if (!Settings.getSettingBoolean(SettingsConsts.INITIALLY_STARTED))
            {
                Settings.setSetting(SettingsConsts.CHAT_EXAMPLE_BACKGROUND_IMAGE_NAME, "light_bulb.jpeg");
            }
            // Loads all background images into the cache:
            BackgroundImageCache.loadCache();

            // Setup push server connection:
            if (!Settings.getSettingBoolean(SettingsConsts.DISABLE_PUSH))
            {
                Push_App_Server.Classes.PushManager.init();
            }

            isRunning = true;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (!(Window.Current.Content is Frame rootFrame))
            {
                // Create a Frame to act as the navigation context and navigate to the first page:
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (args is ToastNotificationActivatedEventArgs)
            {
                var toastActivationArgs = args as ToastNotificationActivatedEventArgs;
                Logger.Info("App activated by toast with: " + toastActivationArgs.Argument);
                // If empty args, no specific action (just launch the app)
                if (string.IsNullOrEmpty(toastActivationArgs.Argument))
                {
                    if (rootFrame.Content == null)
                    {
                        if (!Settings.getSettingBoolean(SettingsConsts.INITIALLY_STARTED))
                        {
                            rootFrame.Navigate(typeof(AddAccountPage), "App.xaml.cs");
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(ChatPage), "App.xaml.cs");
                        }
                    }
                }
                else
                {
                    rootFrame.Navigate(typeof(ChatPage), ToastActivationArgumentParser.parseArguments(toastActivationArgs.Argument));
                }
                if (rootFrame.BackStack.Count == 0)
                {
                    rootFrame.BackStack.Add(new PageStackEntry(typeof(ChatPage), null, null));
                }
            }
            else if (args is LaunchActivatedEventArgs)
            {
                var launchActivationArgs = args as LaunchActivatedEventArgs;

                Push.CheckLaunchedFromNotification(launchActivationArgs);

                // If launched with arguments (not a normal primary tile/applist launch)
                if (launchActivationArgs.Arguments.Length > 0)
                {
                    Logger.Debug(launchActivationArgs.Arguments);
                    // TODO: Handle arguments for cases = launching from secondary Tile, so we navigate to the correct page
                    //throw new NotImplementedException();
                }

                // If we're currently not on a page, navigate to the main page
                if (rootFrame.Content == null)
                {
                    if (!Settings.getSettingBoolean(SettingsConsts.INITIALLY_STARTED))
                    {
                        rootFrame.Navigate(typeof(AddAccountPage), "App.xaml.cs");
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(ChatPage), "App.xaml.cs");
                    }
                }
            }

            // Set requested theme:
            string       themeString = Settings.getSettingString(SettingsConsts.APP_REQUESTED_THEME);
            ElementTheme theme       = ElementTheme.Dark;

            if (themeString != null)
            {
                bool b = Enum.TryParse(themeString, out theme);
            }
            RootTheme = theme;

            Window.Current.Activate();

            // Connect to all clients:
            ConnectionHandler.INSTANCE.connectAll();
        }