Contains functionality for presenting the size of a file
예제 #1
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            CancelAction = false;
            ConditionalSelectParameters.FileNameFilterTypes fnf = (ConditionalSelectParameters.FileNameFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.FileNameFilterTypes), ((ConditionalSelectComboBoxItem)namefilter.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.FileSizeFilterTypes fsf = (ConditionalSelectParameters.FileSizeFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.FileSizeFilterTypes), ((ConditionalSelectComboBoxItem)sizefilter.SelectedItem).IdentifyingName);
            FriendlySizeConverter.FileSizeMeasurements      sd1 = (FriendlySizeConverter.FileSizeMeasurements)Enum.Parse(typeof(FriendlySizeConverter.FileSizeMeasurements), ((ConditionalSelectComboBoxItem)sizebox1.SelectedItem).IdentifyingName);
            FriendlySizeConverter.FileSizeMeasurements      sd2 = (FriendlySizeConverter.FileSizeMeasurements)Enum.Parse(typeof(FriendlySizeConverter.FileSizeMeasurements), ((ConditionalSelectComboBoxItem)sizebox2.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.DateFilterTypes     dcf = (ConditionalSelectParameters.DateFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.DateFilterTypes), ((ConditionalSelectComboBoxItem)dcfilter.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.DateFilterTypes     dmf = (ConditionalSelectParameters.DateFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.DateFilterTypes), ((ConditionalSelectComboBoxItem)dmfilter.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.DateFilterTypes     daf = (ConditionalSelectParameters.DateFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.DateFilterTypes), ((ConditionalSelectComboBoxItem)dafilter.SelectedItem).IdentifyingName);

            csd = new ConditionalSelectData(
                new ConditionalSelectParameters.FileNameParameters(namequery.Text, fnf, namecase.IsChecked.Value),
                new ConditionalSelectParameters.FileSizeParameters(FriendlySizeConverter.GetByteLength(
                                                                       Convert.ToDouble(sizequery1.Text.Replace(",", ci.NumberFormat.NumberDecimalSeparator).Replace(
                                                                                            ".", ci.NumberFormat.NumberDecimalSeparator)), sd1),
                                                                   FriendlySizeConverter.GetByteLength(Convert.ToDouble(sizequery2.Text.Replace(
                                                                                                                            ",", ci.NumberFormat.NumberDecimalSeparator).Replace(
                                                                                                                            ".", ci.NumberFormat.NumberDecimalSeparator)), sd2), fsf),
                new ConditionalSelectParameters.DateParameters(dcquery.SelectedDate.Value.Date, dcf),
                new ConditionalSelectParameters.DateParameters(dmquery.SelectedDate.Value.Date, dmf),
                new ConditionalSelectParameters.DateParameters(daquery.SelectedDate.Value.Date, daf),
                namecheck.IsChecked.Value, sizecheck.IsChecked.Value, dccheck.IsChecked.Value, dmcheck.IsChecked.Value, dacheck.IsChecked.Value);
            this.Close();
        }
        private void UpdateFileListFromBox()
        {
            int  tfc = 0;
            long tfs = 0;

            foreach (object item in listBox1.Items)
            {
                System.IO.FileInfo fd = new System.IO.FileInfo((string)item);
                tfc += 1;
                tfs += fd.Length;
            }

            if (tfc > 1)
            {
                this.radioButton3.Visible = false;
                this.radioButton4.Visible = false;
                this.radioButton6.Visible = false;
                label7.Visible            = true;
            }
            else
            {
                this.radioButton3.Visible = true;
                this.radioButton4.Visible = true;
                this.radioButton6.Visible = true;
                label7.Visible            = false;
            }

            this.lblCount.Text = Convert.ToString(tfc);
            this.lblSize.Text  = FriendlySizeConverter.GetFriendlySize(tfs);

            if (this.listBox1.SelectedItems.Count > 0)
            {
                this.button3.Enabled = true;
            }
            else
            {
                this.button3.Enabled = false;
            }

            if (tfc == 0)
            {
                if (hsa == false)
                {
                    MessageBox.Show("You have not selected any files. Please select some files and try again.", "Create Archive", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cos = true;
                }
                else
                {
                    MessageBox.Show("There are currently no files listed to be archived. Please add some files before continuing.", "Create Archive", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.wizardPage1.AllowNext = false;
                }
            }
            else
            {
                this.wizardPage1.AllowNext = true;
            }
        }