public NavigationBarControl()
        {
            InitializeComponent();

            // Handle visibility/invisibility of settings menu
            this.mainGrid.MouseLeftButtonDown  += (object obj, MouseButtonEventArgs e) => this.MakeSettingsMenuInvisible();
            this.settingsBtn.MouseLeftButtonUp += (object obj, MouseButtonEventArgs e) => this.MakeSettingsMenuVisible();

            // Download page loading animation
            this.downloadBtn.MouseEnter += (object obj, MouseEventArgs e) => this.loadingWebpageControl.Visibility = Visibility.Visible;
            this.downloadBtn.MouseLeave += (object obj, MouseEventArgs e) => this.loadingWebpageControl.Visibility = Visibility.Hidden;

            // Download button animation
            var converter = new ImageSourceConverter();

            this.downloadBtn.MouseEnter += (object obj, MouseEventArgs e) =>
            {
                this.downloadImage.Source = (ImageSource)converter.ConvertFromString((string)this.FindResource("greenDownloadSource"));
            };
            this.downloadBtn.MouseLeave += (object obj, MouseEventArgs e) =>
            {
                this.downloadImage.Source = (ImageSource)converter.ConvertFromString((string)this.FindResource("downloadSource"));
            };

            // Handle theme changing
            (Application.Current as App).ThemeChanged += (object obj, ThemeChangedEventArgs e) =>
            {
                OrganicUtility.UpdateImages(this.mainGrid);
            };
            Application.Current.Activated += (object obj, EventArgs e) => OrganicUtility.UpdateImages(this.mainGrid);
        }
Exemplo n.º 2
0
        public PreferencesWindow()
        {
            InitializeComponent();

            // Mention that the window is running
            IsRunning = true;
            PreferencesWindow.CurrentRunningWindow = this;

            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            // Handle theme changing
            (Application.Current as App).ThemeChanged += (object obj, ThemeChangedEventArgs e) =>
            {
                OrganicUtility.UpdateImages(this.mainLayout);
            };
            Application.Current.Activated += (object obj, EventArgs e) => OrganicUtility.UpdateImages(this.mainLayout);

            // Fill the preferences from the usersettings file
            UserSettings settings = UserSettings.Load();

            this.homePage.Value             = settings.HomePage;
            this.newTabPage.Value           = settings.NewTabPage;
            this.darkRadioButton.IsChecked  = settings.Theme == Theme.Dark;
            this.lightRadioButton.IsChecked = settings.Theme == Theme.Light;
            this.autoRadioButton.IsChecked  = settings.Theme == Theme.Auto;
        }
        public WindowManagementControl()
        {
            InitializeComponent();

            // Handle theme changing
            (Application.Current as App).ThemeChanged += (object obj, ThemeChangedEventArgs e) =>
            {
                OrganicUtility.UpdateImages(this.mainLayout);
            };
            Application.Current.Activated += (object obj, EventArgs e) => OrganicUtility.UpdateImages(this.mainLayout);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Applies the theme saved in the user settings file
        /// </summary>
        private void ApplySavedTheme()
        {
            var   settings = UserSettings.Load();
            Theme theme    = settings.Theme;

            if (theme == Theme.Auto)
            {
                theme = OrganicUtility.GetWindowsTheme();
            }
            ((App)Application.Current).ApplyTheme(theme);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Executes on application startup
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        {
            var settings = UserSettings.Load();

            if (settings.Theme == Theme.Auto)
            {
                this.CurrentTheme = OrganicUtility.GetWindowsTheme();
            }
            else
            {
                this.CurrentTheme = settings.Theme;
            }
            base.OnStartup(e);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns the initial url to start from.
        /// The url may be a file opened with the browser or the home page
        /// </summary>
        /// <returns></returns>
        private static string GetInitialUrl()
        {
            string[] args = Environment.GetCommandLineArgs();

            if (args.Length == 2 && File.Exists(args[1]))
            {
                // In case a file was opened with the browser, show the file
                return(OrganicUtility.GetUrlFromPath(args[1]));
            }
            else
            {
                return(UserSettings.Load().HomePage);
            }
        }
        public event EventHandler TabClosed;                // Event for closing a tab

        public BrowserTabControl()
        {
            InitializeComponent();
            this.tabItems = new List <TabItem>();
            this.tabControl.SizeChanged += this.TabControlSizeChangedHandler;

            // Margin the add new tab button
            this.addNewTabButton.Margin = this.AddNewTabMargin;

            // Handle theme changing
            (Application.Current as App).ThemeChanged += (object obj, ThemeChangedEventArgs e) =>
            {
                OrganicUtility.UpdateImages(this.mainGrid);
            };
            Application.Current.Activated += (object obj, EventArgs e) => OrganicUtility.UpdateImages(this.mainGrid);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Inserts all the saved pages into the XAML page
        /// </summary>
        private void InsertAllSavedPages()
        {
            Grid pagesGrid = this.savedPagesGrid;
            int  currentRow = 0, currentCol = 0;

            foreach (SavedPage savedPage in GetAllSavedPages())
            {
                // In case there aren't enough rows add one
                if (currentRow == pagesGrid.RowDefinitions.Count)
                {
                    pagesGrid.RowDefinitions.Add(new RowDefinition()
                    {
                        Style = FindResource("savedPagesGridRow") as Style
                    });
                }

                // Create the save page control
                SavedPageControl control = new SavedPageControl()
                {
                    Title      = savedPage.Title,
                    IconSource = new ImageSourceConverter().ConvertFromString(savedPage.IconSource) as ImageSource,
                    Height     = 135,
                    Width      = 145
                };
                // Handle saved page control click
                control.MouseLeftButtonUp += (object sender, MouseButtonEventArgs e) =>
                {
                    (Application.Current.MainWindow as MainWindow).AddNewTab(OrganicUtility.GetUrlFromPath(savedPage.HtmlFilePath));
                    this.Close();
                };
                pagesGrid.Children.Add(control);
                Grid.SetRow(control, currentRow);
                Grid.SetColumn(control, currentCol);

                if (currentCol + 1 == pagesGrid.ColumnDefinitions.Count)
                {
                    currentCol = 0;
                    currentRow++;
                }
                else
                {
                    currentCol++;
                }
            }
        }
Exemplo n.º 9
0
        }                                                                       // The current running window

        public LibraryWindow()
        {
            InitializeComponent();

            // Mention that the window is running
            IsRunning = true;
            LibraryWindow.CurrentRunningWindow = this;

            // Insert all the saved pages
            this.InsertAllSavedPages();

            // Handle theme changing
            (Application.Current as App).ThemeChanged += (object obj, ThemeChangedEventArgs e) =>
            {
                OrganicUtility.UpdateImages(this.mainGrid);
            };
            Application.Current.Activated += (object obj, EventArgs e) => OrganicUtility.UpdateImages(this.mainGrid);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Validates the fields, if not valid prompt an error message
        /// </summary>
        /// <returns> Whether all fields are valid or not </returns>
        private bool ValidateFields()
        {
            string errorMessage = string.Empty;

            // Validate the home page
            if (!OrganicUtility.IsValidUrl(this.homePage.Value))
            {
                errorMessage = "The given URL for the home page is invalid";
            }
            // Validate the new tab page
            else if (!OrganicUtility.IsValidUrl(this.newTabPage.Value))
            {
                errorMessage = "The given URL for the new tab page is invalid";
            }

            // Prompt the error message and return whether valid or not
            if (errorMessage != string.Empty)
            {
                this.Prompt(errorMessage, RedColor);
            }
            return(string.IsNullOrEmpty(errorMessage));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Downloads the page favicon
        /// </summary>
        private void DownloadFavicon()
        {
            string faviconUrl = "https://www.google.com/s2/favicons?domain=" + OrganicUtility.GetDomainName(this.Url);

            this.webClient.DownloadFile(faviconUrl, Path.Combine(this.basePath, "favicon.ico"));
        }
Exemplo n.º 12
0
 /// <summary>
 /// Executes when the Auto theme radio button is checked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AutoRadioButton_Checked(object sender, RoutedEventArgs e)
 {
     ((App)Application.Current).ApplyTheme(OrganicUtility.GetWindowsTheme());
 }