Ejemplo n.º 1
0
        public MainForm()
        {
            Program.log.Info("Initializing");

            // Adds all file types to one list
            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);

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

            // Initialize
            InitializeComponent();

            // Set this instance
            Form = this;

            // Show Splash Screen
            Controls.Add(FrmSplashScreen);
            FrmSplashScreen.Dock = DockStyle.Fill;
            FrmSplashScreen.BringToFront();
            FrmSplashScreen.Show();

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

            // Set static combo dropdown width to max items size
            comboBoxSearchHome.DropDownWidth = ControlExtensions.GetMaxDropDownWidth(comboBoxSearchHome);
            comboBoxSortFiles.DropDownWidth  = ControlExtensions.GetMaxDropDownWidth(comboBoxSortFiles);

            Program.log.Info("Initialized");
        }
Ejemplo n.º 2
0
        public void ShowFiles(List <WebFile> dataFiles)
        {
            EnableSearchControls(false);
            var stopWatch = new Stopwatch();

            Program.log.InfoFormat("Starting query. Preferences - Sort: {0}, Type: {1}, Host: {2}", SelectedFilesSort.ToString(), SelectedFilesType.ToString(), SelectedFilesHost);
            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, StringExtensions.BytesToPrefix(jsonData.Size), StringExtensions.TimeSpanAge(jsonData.DateUploaded), jsonData.Host, jsonData.URL);
                            if (!(comboBoxFilterFiles.Items.Contains(jsonData.Host)))
                            {
                                comboBoxFilterFiles.Items.Add(jsonData.Host);
                            }
                        }
                    }

                    stopWatch.Stop();
                    labelResultsInfo.Text = string.Format("{0} Results ({2} seconds)", StringExtensions.FormatNumber(dataGridFiles.Rows.Count.ToString()), StringExtensions.FormatNumber(dataFiles.Count.ToString()), String.Format("{0:0.000}", stopWatch.Elapsed.TotalSeconds));
                    stopWatch.Reset();

                    tab.SelectedTab = CurrentTab;

                    comboBoxFilterFiles.DropDownWidth = ControlExtensions.GetMaxDropDownWidth(comboBoxFilterFiles);

                    imageSearchFiles.Image = Properties.Resources.magnify_orange;

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

                    Program.log.Info("Successfully returned search results - " + labelResultsInfo.Text);
                }

                EnableSearchControls(true);
            });
        }
Ejemplo n.º 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.GetMaxPanelWidth(buttonFilterFiles);
            Refresh();

            comboBoxFilterFiles.DropDownWidth = ControlExtensions.GetMaxDropDownWidth(comboBoxFilterFiles);

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