コード例 #1
0
ファイル: MainUI.cs プロジェクト: etos/wrox-sfv
 public ReportDetails( TimeSpan TimeSpan, CRCState CRCDetails )
 {
     crcState = CRCDetails;
     tsTimeSpan = TimeSpan;
 }
コード例 #2
0
ファイル: MainUI.cs プロジェクト: etos/wrox-sfv
        private void btnRecursiveVerify_Click(object sender, System.EventArgs e)
        {
            //CHECK IF USERS HAVE SELECTED FILES TO SCAN
            if ( this.chklistboxRecursive.Items.Count == 0 )
            {
                MessageBox.Show( this, "Please Scan files first!",
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
                RestartScanCleanUp();
                return;
            }

            bVerifyScanRequested = true;
            bRecursiveScanRequested = true;
            pbarVerifySystemScan.Enabled = true;
            pbarVerifySystemScan.ProgressBarColor = System.Drawing.Color.Black;
            this.lstVerifySFV.Items.Clear();
            this.lstRecursiveSFVs.Items.Clear();
            edtVerifyFileSFV.Text = edtVerifyFileSFV.Text.Trim();
            edtVerifyFileSFV.Enabled = false;
            btnVerifyFileSFV.Enabled = false;
            edtVerifySingleFile.Enabled = false;
            btnVerifySingleFile.Enabled = false;

            this.btnVerify.Text = "Abort Scan";
            btnVerify.Click -= new EventHandler(this.VerifyScan);
            btnVerify.Click += new EventHandler(this.StopScan);

            this.btnRecursiveVerify.Text = "Abort Scan";
            btnRecursiveVerify.Click -= new EventHandler(this.btnRecursiveVerify_Click);
            btnRecursiveVerify.Click += new EventHandler(this.StopScan);

            //RUN CHECK AND VERIFY
            myState = new CRCState();

            string []sfvFiles = new string[this.chklistboxRecursive.CheckedItems.Count];
            this.chklistboxRecursive.CheckedItems.CopyTo( sfvFiles, 0 );

            foreach ( string sfvName in sfvFiles )
            {
                if ( ( sfvName != null ) && ( sfvName != "" ) )
                {
                    myState.setSFVFileNames(sfvName);
                }
            }

            tabMain.SelectedTab = tabValidate;

            //PUT SETTINGS INTO myState (required as the new thread cant cross thread call to UI)
            if (chkVerifyShowFailed.Checked) { myState.boolShowFailed = true; }
            if (chkVerifyUnrar.Checked) { myState.boolUnrar = true; }
            if (chkVerifyDel.Checked) { myState.boolDelRars = true; }
            if (chkVerifyDelSFV.Checked) { myState.boolDelSFV = true; }
            if (chkVerifyBG.Checked) { myState.boolVerBG = true; }

            //RUN PROGRAM IN BACKGROUND MINIMISED TO TRAY
            if (chkVerifyBG.Checked) { this.Hide(); }

            dtVerifyScanStart = DateTime.Now;

            pbarVerifySystemScan.Value = 0;
            pbarVerifySystemScan.Minimum = 0;
            VerifyCRCThread = new System.Threading.Thread( new System.Threading.ThreadStart( VerifyCRC ));
            VerifyCRCThread.IsBackground = true;
            VerifyCRCThread.Name = "Verify File CRC";
            VerifyCRCThread.Priority = System.Threading.ThreadPriority.Normal;
            VerifyCRCThread.Start();
        }
コード例 #3
0
ファイル: MainUI.cs プロジェクト: etos/wrox-sfv
            /// <summary>
            /// Performs a deep copy of the current object and returns the new instance.
            /// </summary>
            /// <returns></returns>
            public object Clone()
            {
                CRCState newState = new CRCState();

                newState.fsFileStream = this.fsFileStream;
                newState.fsFileServices = this.fsFileServices;
                newState.myCRC = this.myCRC;
                newState.iFileCount = this.iFileCount;
                newState.FileCRC = (Hashtable)this.FileCRC.Clone();
                newState.FileSizes = (Hashtable)this.FileSizes.Clone();
                newState.FileVerifyCRC = (Hashtable)this.FileVerifyCRC.Clone();
                newState.queFiles = (Queue)this.queFiles.Clone();
                newState.queSFVList = (Queue)this.queSFVList.Clone();
                newState.strSingleFile = this.strSingleFile;
                newState.boolSingleFile = this.boolSingleFile;
                newState.boolShowFailed = this.boolShowFailed;
                newState.boolEditSFV = this.boolEditSFV;
                newState.boolWinSFVCompat = this.boolWinSFVCompat;
                newState.boolIncDateSize = this.boolIncDateSize;
                newState.boolUnrar = this.boolUnrar;
                newState.boolDelRars = this.boolDelRars;
                newState.boolDelSFV = this.boolDelSFV;
                newState.boolVerBG = this.boolVerBG;

                return (object)newState;
            }
コード例 #4
0
ファイル: MainUI.cs プロジェクト: etos/wrox-sfv
        public void RestartScanCleanUp()
        {
            try
            {
                if ( bScanRequested )
                {
                    StopThreads();
                    bScanRequested = false;

                    btnCreate.Click -= new EventHandler(this.StopScan);
                    //remember to remove stopscan &&&&& any existing registrations
                    btnCreate.Click -= new EventHandler(this.CreateScan);
                    btnCreate.Click += new EventHandler(this.CreateScan);

                    edtFileSFV.Enabled = true;
                    btnFileSFV.Enabled = true;
                    edtFileHeader.Enabled = true;
                    btnFileHeader.Enabled = true;
                    btnFilesLst.Enabled = true;
                    //edtFileSFV.Text = "";
                    btnCreate.Text = "Create";

                    edtFileHeader.Text = "Enter text (or text based file) to be added to SFV's comment (optional)";

                    pbarSystemScan.Value = 0;
                    pbarSystemScan.Refresh();

                    lblAppInfo.Text = "";

                    myState = null;
                }
                else if ( bVerifyScanRequested )
                {
                    StopThreads();
                    bVerifyScanRequested = false;
                    bRecursiveScanRequested = false;

                    btnVerify.Click -= new EventHandler(this.StopScan);
                    btnRecursiveVerify.Click -= new EventHandler(this.StopScan);
                    //remember to remove stopscan &&&&& any existing registrations
                    btnVerify.Click -= new EventHandler(this.VerifyScan);
                    btnVerify.Click += new EventHandler(this.VerifyScan);
                    btnRecursiveVerify.Click -= new EventHandler(this.btnRecursiveVerify_Click);
                    btnRecursiveVerify.Click += new EventHandler(this.btnRecursiveVerify_Click);

                    this.btnVerify.Text = "Verify";
                    this.btnRecursiveVerify.Text = "Verify All";

                    edtVerifyFileSFV.Enabled = true;
                    btnVerifyFileSFV.Enabled = true;

                    if ( this.chkVerifySingleFile.Checked )
                    {
                        edtVerifySingleFile.Enabled = true;
                        btnVerifySingleFile.Enabled = true;
                    }
                    else
                    {
                        edtVerifySingleFile.Enabled = false;
                        btnVerifySingleFile.Enabled = false;
                    }

                    //edtVerifyFileSFV.Text = "";
                    //edtVerifySingleFile.Text = "";
                    pbarVerifySystemScan.ProgressBarColor = System.Drawing.Color.Black;

                    pbarVerifySystemScan.Value = 0;
                    pbarVerifySystemScan.Refresh();

                    myState = null;
                }
                else
                {
                    StopThreads();
                }
            }
            catch
            {
                StopThreads();
            }
        }
コード例 #5
0
ファイル: MainUI.cs プロジェクト: etos/wrox-sfv
        private void VerifyScan(object sender, System.EventArgs e)
        {
            bVerifyScanRequested = true;
            pbarVerifySystemScan.Enabled = true;
            pbarVerifySystemScan.ProgressBarColor = System.Drawing.Color.Black;
            this.lstVerifySFV.Items.Clear();
            this.btnVerify.Text = "Abort Scan";
            edtVerifyFileSFV.Text = edtVerifyFileSFV.Text.Trim();
            edtVerifyFileSFV.Enabled = false;
            btnVerifyFileSFV.Enabled = false;
            edtVerifySingleFile.Enabled = false;
            btnVerifySingleFile.Enabled = false;
            pbarVerifySystemScan.Value = 0;
            pbarVerifySystemScan.Minimum = 0;

            btnVerify.Click -= new EventHandler(this.VerifyScan);
            btnVerify.Click += new EventHandler(this.StopScan);

            myState = new CRCState();

            try
            {
                //WHOLE RELEASE (NO SINGLE FILE) VALIDATION
                if ( (edtVerifyFileSFV.Text == "")  || (edtVerifyFileSFV.TextLength == 0) )
                {
                    MessageBox.Show( this, "You have not entered a valid location path for your SFV File.",
                        "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    RestartScanCleanUp();
                    return;
                }
                else if ( (edtVerifyFileSFV.Text.Length < 2) || (edtVerifyFileSFV.Text.Substring( 0, 1 ) != "\\")
                    && (edtVerifyFileSFV.Text.Substring( 1, 1 ) != "\\") )
                {
                    if ( (edtVerifyFileSFV.Text.Length < 2) || (edtVerifyFileSFV.Text.Substring( 1, 1 ) != ":" ) )
                    {
                        MessageBox.Show( this, "You entered an invalid location path for your SFV. The location" +
                            "\nyou wish to use must begin with a drive letter or network path. Some" +
                            "\nexamples are: D:\\, or \\\\computername\\sharename, or C:\\dir",
                            "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        RestartScanCleanUp();
                        return;
                    }
                }
                else if ( !(new FileInfo( edtVerifyFileSFV.Text ).Exists ) )
                {
                    MessageBox.Show( this, "The SFV File you chose to verify does not exist!\n" +
                        "Please re-check the location path and retry the scan."
                        , "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Information );
                    RestartScanCleanUp();
                    return;
                }

                //SINGLE FILE VALIDATION
                if ( chkVerifySingleFile.Checked )
                {
                    if ( (edtVerifySingleFile.Text == "")  || (edtVerifySingleFile.Text.Length == 0) )
                    {
                        MessageBox.Show( this, "You have not entered a valid location path for your Single File.",
                            "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        RestartScanCleanUp();
                        return;
                    }
                    else if ( (edtVerifySingleFile.Text.Length < 2) || (edtVerifySingleFile.Text.Substring( 0, 1 ) != "\\")
                        && (edtVerifySingleFile.Text.Substring( 1, 1 ) != "\\") )
                    {
                        if ( (edtVerifySingleFile.Text.Length < 2) || (edtVerifySingleFile.Text.Substring( 1, 1 ) != ":" ) )
                        {
                            MessageBox.Show( this, "You entered an invalid location path for your Single File. The location" +
                                "\nyou wish to use must begin with a drive letter or network path. Some" +
                                "\nexamples are: D:\\, or \\\\computername\\sharename, or C:\\dir",
                                "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            RestartScanCleanUp();
                            return;
                        }
                    }
                    else if ( !(new FileInfo( this.edtVerifySingleFile.Text ).Exists ) )
                    {
                        MessageBox.Show( this, "The Single File you chose to verify does not exist!\n" +
                            "Please re-check the location path and retry the scan."
                            , "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Information );
                        RestartScanCleanUp();
                        return;
                    }

                    //if singlefile + all is valid then add to mystate
                    myState.boolSingleFile = true;
                    myState.strSingleFile = StripPath(edtVerifySingleFile.Text);
                }

                //PUT SETTINGS INTO myState (required as the new thread cant cross thread call to UI)
                if ( chkVerifyShowFailed.Checked ) { myState.boolShowFailed = true; }
                if ( chkVerifyUnrar.Checked ) { myState.boolUnrar = true; }
                if ( chkVerifyDel.Checked ) { myState.boolDelRars = true; }
                if ( chkVerifyDelSFV.Checked ) { myState.boolDelSFV = true; }
                if ( chkVerifyBG.Checked ) { myState.boolVerBG = true; }

                //RUN PROGRAM IN BACKGROUND MINIMISED TO TRAY
                if ( chkVerifyBG.Checked ) { this.Hide(); }

                //RUN CHECK AND VERIFY
                myState.setSFVFileNames(edtVerifyFileSFV.Text);

                dtVerifyScanStart = DateTime.Now;

                VerifyCRCThread = new System.Threading.Thread( new System.Threading.ThreadStart( VerifyCRC ));
                VerifyCRCThread.IsBackground = true;
                VerifyCRCThread.Name = "Verify File CRC";
                VerifyCRCThread.Priority = System.Threading.ThreadPriority.Normal;
                VerifyCRCThread.Start();
            }
            catch ( System.Threading.ThreadAbortException se )
            {
                RestartScanCleanUp();
                return;
            }
            catch ( System.ArgumentException se )
            {
                RestartScanCleanUp();
                return;
            }
        }
コード例 #6
0
ファイル: MainUI.cs プロジェクト: etos/wrox-sfv
        public void CleanUpAfterScan()
        {
            try
            {
                //if recursive then change tab back
                if (bRecursiveScanRequested == true)
                {
                    tabMain.SelectedTab = tabRecursive;

                    MessageBox.Show(this, "Recursive Validation Completed!","Complete!",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                //Reset Create SFV Components
                btnCreate.Click -= new EventHandler(this.StopScan);
                btnCreate.Click += new EventHandler(this.CreateScan);

                bScanRequested = false;

                btnCreate.Text = "Create";
                edtFileSFV.Enabled = true;
                btnFileSFV.Enabled = true;
                edtFileHeader.Enabled = true;
                btnFileHeader.Enabled = true;
                btnFilesLst.Enabled = true;
                pbarSystemScan.Enabled = false;

                //Reset Valifate SFV Components
                btnVerify.Click -= new EventHandler(this.StopScan);
                btnRecursiveVerify.Click -= new EventHandler(this.StopScan);
                //remember to remove stopscan &&&&& any existing registrations
                btnVerify.Click -= new EventHandler(this.VerifyScan);
                btnVerify.Click += new EventHandler(this.VerifyScan);
                btnRecursiveVerify.Click -= new EventHandler(this.btnRecursiveVerify_Click);
                btnRecursiveVerify.Click += new EventHandler(this.btnRecursiveVerify_Click);

                bVerifyScanRequested = false;
                bRecursiveScanRequested = false;

                this.btnVerify.Text = "Verify";
                this.btnRecursiveVerify.Text = "Verify All";
                edtVerifyFileSFV.Enabled = true;
                btnVerifyFileSFV.Enabled = true;

                if ( this.chkVerifySingleFile.Checked )
                {
                    edtVerifySingleFile.Enabled = true;
                    btnVerifySingleFile.Enabled = true;
                }
                else
                {
                    edtVerifySingleFile.Enabled = false;
                    btnVerifySingleFile.Enabled = false;
                }

                pbarVerifySystemScan.Enabled = false;

                //both
                myState = null;
                StopThreads();

                //Check for Auto-Quit
                RegistryKey regKeyUserConfMenu = null;
                try
                {
                    if (bVerifyScanGood == true)
                    {
                        regKeyUserConfMenu = Registry.CurrentUser.OpenSubKey(regUserConfMenu);
                        if (regKeyUserConfMenu != null)
                        {
                            //Auto-Quit
                            if (Convert.ToBoolean(regKeyUserConfMenu.GetValue("AutoQuit")) == true)
                            {
                                this.Close();
                            }
                        }
                    }
                }
                catch(Exception ex)
                {
                    //do nothing (no settings set)
                }
                finally
                {
                    if(regKeyUserConfMenu != null)
                        regKeyUserConfMenu.Close();
                }

            }
            catch
            {
                StopThreads();
            }
        }
コード例 #7
0
ファイル: MainUI.cs プロジェクト: etos/wrox-sfv
        private void CreateScan(object sender, System.EventArgs e)
        {
            bScanRequested = true;
            pbarSystemScan.Enabled = true;
            lblAppInfo.Text = "";
            this.lstCreateResults.Items.Clear();
            this.btnCreate.Text = "Abort Scan";
            edtFileSFV.Text = edtFileSFV.Text.Trim();
            edtFileSFV.Enabled = false;
            btnFileSFV.Enabled = false;
            edtFileHeader.Enabled = false;
            btnFileHeader.Enabled = false;
            btnFilesLst.Enabled = false;

            btnCreate.Click -= new EventHandler(this.CreateScan);
            btnCreate.Click += new EventHandler(this.StopScan);

            try
            {
                if ((edtFileSFV.Text == "") || (edtFileSFV.TextLength == 0))
                {
                    MessageBox.Show(this, "You have not entered a valid location to create your SFV File.",
                        "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    RestartScanCleanUp();
                    return;
                }
                else if ((edtFileSFV.Text.Length < 2) || (edtFileSFV.Text.Substring(0, 1) != "\\")
                    && (edtFileSFV.Text.Substring(1, 1) != "\\"))
                {
                    if ((edtFileSFV.Text.Length < 2) || (edtFileSFV.Text.Substring(1, 1) != ":"))
                    {
                        MessageBox.Show(this, "You entered an invalid location to create your SFV. The location" +
                            "\nyou wish to use must begin with a drive letter or network path. Some" +
                            "\nexamples are: D:\\, or \\\\computername\\sharename, or C:\\dir",
                            "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        RestartScanCleanUp();
                        return;
                    }
                }

                //CHECK IF USERS HAVE SELECTED FILES TO SCAN
                if (this.lstBoxSelectedFiles.Items.Count == 0)
                {
                    MessageBox.Show(this, "Hmm, its seems no files were selected for scan!!",
                        Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    RestartScanCleanUp();
                    return;
                }

                myState = new CRCState();

                //PUT SETTINGS INTO myState (required as the new thread cant cross thread call to UI)
                if ( chkEdit.Checked ) { myState.boolEditSFV = true; }
                if ( chkWinSFV.Checked ) { myState.boolWinSFVCompat = true; }
                if ( chkDatesSizes.Checked ) { myState.boolIncDateSize = true; }

                //RUN PROGRAM IN BACKGROUND MINIMISED TO TRAY
                if ( chkBG.Checked ) { this.Hide(); }

                dtScanStart = DateTime.Now;
                myState.iFileCount = this.lstBoxSelectedFiles.Items.Count;
                pbarSystemScan.Value = 0;
                pbarSystemScan.Minimum = 0;
                pbarSystemScan.Maximum = myState.iFileCount;

                //getting filenames from stBoxSelectedFiles + add data to myState class
                string[] sFiles = new string[this.lstBoxSelectedFiles.Items.Count];
                this.lstBoxSelectedFiles.Items.CopyTo(sFiles, 0);
                foreach (string strFile in sFiles)
                {
                    myState.setFileNames(strFile);
                }

                GenerateCRCThread = new System.Threading.Thread(new System.Threading.ThreadStart(GenerateCRC));
                GenerateCRCThread.IsBackground = true;
                GenerateCRCThread.Name = "Generate File CRC";
                GenerateCRCThread.Priority = System.Threading.ThreadPriority.Normal;
                GenerateCRCThread.Start();
            }
            catch (System.Threading.ThreadAbortException se)
            {
                RestartScanCleanUp();
                return;
            }
            catch (System.ArgumentException se)
            {
                RestartScanCleanUp();
                return;
            }
        }