/// <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); } }
/// <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++; } } }