Beispiel #1
0
        } = new ShortcutsWindow();                                                           // Keyboard Shortcuts Window (one instance)

        public MainForm()
        {
            Program.log.Info("Initializing");

            // Add all the supported file types to one list (There must be a cleaner way, but oh well)
            Types.All.AddRange(Types.Video); Types.All.AddRange(Types.Audio); Types.All.AddRange(Types.Books); Types.All.AddRange(Types.Subtitle); Types.All.AddRange(Types.Torrent); Types.All.AddRange(Types.Software); Types.All.AddRange(Types.Other);

            SelectedFilesType = Types.All;                                                        // Set selected files type to All

            InitializeComponent();                                                                // Initialize

            Form = this;                                                                          // Set this instance

            labelChangeLog.Text = String.Format(labelChangeLog.Text, Application.ProductVersion); // Set this version on Change Log label in the About tab

            // Show Splash Screen
            Controls.Add(FrmSplashScreen);
            FrmSplashScreen.Dock       = DockStyle.Fill;
            FrmSplashScreen.Location   = new Point(0, 0);
            FrmSplashScreen.ClientSize = ClientSize;
            FrmSplashScreen.BringToFront();
            FrmSplashScreen.Show();

            comboBoxSearchHome.DropDownWidth = ControlExtensions.DropDownWidth(comboBoxSearchHome); // Set home search button combobox to fit its contents
            comboBoxSortFiles.DropDownWidth  = ControlExtensions.DropDownWidth(comboBoxSortFiles);  // Set files sort combobox to fit its contents

            Program.log.Info("Initialized");
        }
Beispiel #2
0
        public void ShowFiles(List <WebFile> dataFiles)
        {
            EnableSearchControls(false);

            var stopWatch = new Stopwatch();

            Program.log.Info("Searching files started");
            imageSearchFiles.Image = Properties.Resources.loader;
            BackGroundWorker.RunWorkAsync <List <WebFile> >(() => Query.Search(dataFiles, textBoxSearchFiles.Text, SelectedFilesSort), (data) =>
            {
                if (tabSearch.InvokeRequired)
                {
                    var b = new loadFilesCallBack(ShowFiles);
                    Invoke(b, new object[] { dataFiles });
                }
                else
                {
                    dataGridFiles.Rows.Clear();

                    comboBoxFilterFiles.Items.Clear(); comboBoxFilterFiles.Items.Add("Any");

                    stopWatch.Start();

                    foreach (var jsonData in data)
                    {
                        if (SelectedFilesType.Contains(jsonData.Type) && jsonData.Host.Contains(SelectedFilesHost))
                        {
                            dataGridFiles.Rows.Add(jsonData.Type, jsonData.Name, TextExtensions.BytesToString(jsonData.Size), TextExtensions.GetTimeAgo(jsonData.DateUploaded), jsonData.Host, jsonData.URL);
                            if (!(comboBoxFilterFiles.Items.Contains(jsonData.Host)))
                            {
                                comboBoxFilterFiles.Items.Add(jsonData.Host);
                            }
                        }
                    }

                    stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed;
                    labelResultsInfo.Text         = TextExtensions.GetFormattedNumber(dataGridFiles.Rows.Count.ToString()) + " / " + TextExtensions.GetFormattedNumber(dataFiles.Count.ToString()) + " Files (" + String.Format("{0:0.000}", ts.TotalSeconds) + " Seconds)"; stopWatch.Reset();

                    tab.SelectedTab = CurrentTab;

                    comboBoxFilterFiles.DropDownWidth = ControlExtensions.DropDownWidth(comboBoxFilterFiles);

                    imageSearchFiles.Image = Properties.Resources.magnify_orange;

                    if (dataGridFiles.Rows.Count == 0)
                    {
                        labelNoResultsFound.Visible = true;
                    }
                    else
                    {
                        labelNoResultsFound.Visible = false;
                    }

                    EnableSearchControls(true);

                    Program.log.Info("Successfully returned search results");
                }
            });
        }
Beispiel #3
0
        private void comboBoxFilesHost_SelectedIndexChanged(object sender, EventArgs e)
        {
            var startText = buttonFilterFiles.Text.Split(':');

            buttonFilterFiles.Text      = startText[0] + ": " + comboBoxFilterFiles.GetItemText(comboBoxFilterFiles.SelectedItem);
            flowLayoutFilterFiles.Width = ControlExtensions.GetPanelComboBoxWidth(buttonFilterFiles);
            Refresh();

            comboBoxFilterFiles.DropDownWidth = ControlExtensions.DropDownWidth(comboBoxFilterFiles);

            if (comboBoxFilterFiles.SelectedIndex == 0)
            {
                SelectedFilesHost = "";
            }
            else
            {
                SelectedFilesHost = comboBoxFilterFiles.SelectedItem.ToString();
            }
        }