private void Main_Load(object eventSender, EventArgs eventArgs)
{
this.ImagesListIcons.Images.Add("downloading", Properties.Resources.list_downloading);
this.ImagesListIcons.Images.Add("waiting", Properties.Resources.list_waiting);
this.ImagesListIcons.Images.Add("processing", Properties.Resources.list_processing);
this.ImagesListIcons.Images.Add("downloaded_new", Properties.Resources.list_downloaded_new);
this.ImagesListIcons.Images.Add("downloaded", Properties.Resources.list_downloaded);
this.ImagesListIcons.Images.Add("subscribed", Properties.Resources.list_subscribed);
this.ImagesListIcons.Images.Add("subscribed_multi", Properties.Resources.list_subscribed_multi);
this.ImagesListIcons.Images.Add("error", Properties.Resources.list_error);
this.ImagesListIcons.Images.Add("favourite", Properties.Resources.list_favourite);
this.ImagesListIcons.Images.Add("episode_auto", Properties.Resources.list_episode_auto);
this.ImagesListIcons.Images.Add("episode_noauto", Properties.Resources.list_episode_noauto);
this.ImagesProviders.Images.Add("default", Properties.Resources.provider_default);
this.ImagesToolbar.Images.Add("choose_programme", Properties.Resources.toolbar_choose_programme);
this.ImagesToolbar.Images.Add("clean_up", Properties.Resources.toolbar_clean_up);
this.ImagesToolbar.Images.Add("current_episodes", Properties.Resources.toolbar_current_episodes);
this.ImagesToolbar.Images.Add("delete", Properties.Resources.toolbar_delete);
this.ImagesToolbar.Images.Add("download", Properties.Resources.toolbar_download);
this.ImagesToolbar.Images.Add("help", Properties.Resources.toolbar_help);
this.ImagesToolbar.Images.Add("options", Properties.Resources.toolbar_options);
this.ImagesToolbar.Images.Add("play", Properties.Resources.toolbar_play);
this.ImagesToolbar.Images.Add("report_error", Properties.Resources.toolbar_report_error);
this.ImagesToolbar.Images.Add("retry", Properties.Resources.toolbar_retry);
this.ImagesToolbar.Images.Add("subscribe", Properties.Resources.toolbar_subscribe);
this.ImagesToolbar.Images.Add("unsubscribe", Properties.Resources.toolbar_unsubscribe);
this.ImagesToolbar.Images.Add("add_favourite", Properties.Resources.toolbar_add_favourite);
this.ImagesToolbar.Images.Add("remove_favourite", Properties.Resources.toolbar_remove_favourite);
this.ImagesToolbar.Images.Add("set_auto", Properties.Resources.toolbar_set_auto);
this.ToolbarMain.ImageList = this.ImagesToolbar;
this.ToolbarHelp.ImageList = this.ImagesToolbar;
this.ListProviders.LargeImageList = this.ImagesProviders;
this.ListEpisodes.SmallImageList = this.ImagesListIcons;
this.ListFavourites.SmallImageList = this.ImagesListIcons;
this.ListSubscribed.SmallImageList = this.ImagesListIcons;
this.ListDownloads.SmallImageList = this.ImagesListIcons;
this.ListEpisodes.Columns.Add("Date", (int)(0.179 * this.ListEpisodes.Width));
this.ListEpisodes.Columns.Add("Episode Name", (int)(0.786 * this.ListEpisodes.Width));
this.ListFavourites.Columns.Add("Programme Name", (int)(0.661 * this.ListFavourites.Width));
this.ListFavourites.Columns.Add("Provider", (int)(0.304 * this.ListFavourites.Width));
this.ListSubscribed.Columns.Add("Programme Name", (int)(0.482 * this.ListSubscribed.Width));
this.ListSubscribed.Columns.Add("Last Download", (int)(0.179 * this.ListSubscribed.Width));
this.ListSubscribed.Columns.Add("Provider", (int)(0.304 * this.ListSubscribed.Width));
// NB - these are defined in alphabetical order to save sorting later
this.downloadColNames.Add((int)Model.Download.DownloadCols.EpisodeDate, "Date");
this.downloadColNames.Add((int)Model.Download.DownloadCols.Duration, "Duration");
this.downloadColNames.Add((int)Model.Download.DownloadCols.EpisodeName, "Episode Name");
this.downloadColNames.Add((int)Model.Download.DownloadCols.Progress, "Progress");
this.downloadColNames.Add((int)Model.Download.DownloadCols.Status, "Status");
FindNew.EpisodeAdded += this.ProgData_EpisodeAdded;
FindNew.FindNewViewChange += this.ProgData_FindNewViewChange;
FindNew.FindNewFailed += this.ProgData_FindNewFailed;
FindNew.FoundNew += this.ProgData_FoundNew;
Model.Programme.Updated += this.Programme_Updated;
Model.Favourite.Added += this.Favourite_Added;
Model.Favourite.Updated += this.Favourite_Updated;
Model.Favourite.Removed += this.Favourite_Removed;
Model.Subscription.Added += this.Subscription_Added;
Model.Subscription.Updated += this.Subscription_Updated;
Model.Subscription.Removed += this.Subscription_Removed;
Model.Episode.Updated += this.Episode_Updated;
DownloadManager.ProgressTotal += this.DownloadManager_ProgressTotal;
this.dataSearch = DataSearch.GetInstance();
this.dataSearch.DownloadAdded += this.DataSearch_DownloadAdded;
this.dataSearch.DownloadUpdated += this.DataSearch_DownloadUpdated;
this.dataSearch.DownloadRemoved += this.DataSearch_DownloadRemoved;
this.dataSearch.DownloadProgress += this.DataSearch_DownloadProgress;
this.InitProviderList();
this.InitFavouriteList();
this.InitSubscriptionList();
this.InitDownloadList();
this.view.UpdateNavBtnState += this.View_UpdateNavBtnState;
this.view.ViewChanged += this.View_ViewChanged;
this.view.SetView(ViewState.MainTab.FindProgramme, ViewState.View.FindNewChooseProvider);
this.ListFavourites.ListViewItemSorter = new ListItemComparer(ListItemComparer.ListType.Favourite);
this.ListSubscribed.ListViewItemSorter = new ListItemComparer(ListItemComparer.ListType.Subscription);
this.ListDownloads.ListViewItemSorter = new ListItemComparer(ListItemComparer.ListType.Download);
if (OsUtils.WinSevenOrLater())
{
// New style taskbar - initialise the taskbar notification class
this.tbarNotif = new TaskbarNotify();
}
if (!OsUtils.WinSevenOrLater() || Settings.CloseToSystray)
{
// Show a system tray icon
this.NotifyIcon.Visible = true;
}
// Set up the initial notification status
this.UpdateTrayStatus(false);
this.ImageSidebarBorder.Width = 2;
this.ListProviders.Dock = DockStyle.Fill;
this.PanelPluginSpace.Dock = DockStyle.Fill;
this.ListEpisodes.Dock = DockStyle.Fill;
this.ListFavourites.Dock = DockStyle.Fill;
this.ListSubscribed.Dock = DockStyle.Fill;
this.ListDownloads.Dock = DockStyle.Fill;
this.Font = SystemFonts.MessageBoxFont;
this.LabelSidebarTitle.Font = new Font(this.Font.FontFamily, (int)(this.Font.SizeInPoints * 1.2), this.Font.Style, GraphicsUnit.Point);
// Scale the max size of the sidebar image for values other than 96 dpi, as it is specified in pixels
using (Graphics graphicsForDpi = this.CreateGraphics())
{
this.ImageSidebar.MaximumSize = new Size((int)(this.ImageSidebar.MaximumSize.Width * (graphicsForDpi.DpiX / 96)), (int)(this.ImageSidebar.MaximumSize.Height * (graphicsForDpi.DpiY / 96)));
}
if (Settings.MainFormPos != Rectangle.Empty)
{
if (OsUtils.VisibleOnScreen(Settings.MainFormPos))
{
this.StartPosition = FormStartPosition.Manual;
this.DesktopBounds = Settings.MainFormPos;
}
else
{
this.Size = Settings.MainFormPos.Size;
}
this.WindowState = Settings.MainFormState;
}
this.TableToolbars.Height = this.ToolbarMain.Height;
this.ToolbarMain.SetWholeDropDown(this.ButtonOptionsMenu);
this.ToolbarHelp.SetWholeDropDown(this.ButtonHelpMenu);
this.ToolbarHelp.Width = this.ButtonHelpMenu.Rectangle.Width;
if (this.WindowState != FormWindowState.Minimized)
{
this.TableToolbars.ColumnStyles[0] = new ColumnStyle(SizeType.Absolute, this.TableToolbars.Width - (this.ButtonHelpMenu.Rectangle.Width + this.ToolbarHelp.Margin.Right));
this.TableToolbars.ColumnStyles[1] = new ColumnStyle(SizeType.Absolute, this.ButtonHelpMenu.Rectangle.Width + this.ToolbarHelp.Margin.Right);
}
if (OsUtils.WinVistaOrLater() && VisualStyleRenderer.IsSupported)
{
this.ToolbarView.Margin = new Padding(0);
}
this.SetGlassMargins(0, 0, this.ToolbarView.Height, 0);
this.ToolbarView.Renderer = new TabBarRenderer();
OsUtils.ApplyRunOnStartup();
if (Settings.RssServer)
{
RssServer listener = new RssServer(Settings.RssServerPort);
listener.Start();
}
DownloadManager.ResumeDownloads();
this.TimerCheckForUpdates.Enabled = true;
}