⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formexecute.cs

📁 工作时用C#编写的WPS密码测试工具,主要用于测试与MSO文件兼容(IO)而写的.功能主要是由MSO文件加密.WPS打开,再由WPS加密,再由MSO打开.每个加密都是根据文件加密类型来加的,此代码.与
💻 CS
📖 第 1 页 / 共 4 页
字号:
			this.gbFileList.Name = "gbFileList";
			this.gbFileList.Size = new System.Drawing.Size(470, 310);
			this.gbFileList.TabIndex = 112;
			this.gbFileList.TabStop = false;
			this.gbFileList.Text = "文件列表";
			// 
			// FormExecute
			// 
			this.AcceptButton = this.btnExecute;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.btnExit;
			this.ClientSize = new System.Drawing.Size(474, 424);
			this.Controls.Add(this.gbFileList);
			this.Controls.Add(this.gbOption);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnSave);
			this.Controls.Add(this.btnExecute);
			this.Controls.Add(this.btnCancle);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.btnDelete);
			this.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.MinimizeBox = false;
			this.MinimumSize = new System.Drawing.Size(482, 458);
			this.Name = "FormExecute";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "测试执行";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Resize += new System.EventHandler(this.FormExecute_Resize);
			this.Closing += new System.ComponentModel.CancelEventHandler(this.FormExecute_Closing);
			this.Load += new System.EventHandler(this.FormExecute_Load);
			this.gbOption.ResumeLayout(false);
			this.gbFileList.ResumeLayout(false);
			this.ResumeLayout(false);

		}
        #endregion

        #region 文件列表操作事件
        /// <summary>
        /// 添加按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            string _strPassword = this.txtPassword.Text;
            foreach(string _strFileName in this.cbFiles.Items)
            {
                if(_strFileName.IndexOf(m_strInPath) == -1)
                {
                    MessageBox.Show(this, "您选择的文件:\n" + _strFileName + "\n不是位于输入目录下的,\n这个文件将不会被添加到文件列表中",
                        "添加文件提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    string _strTmp = _strFileName.Replace(m_strInPath, String.Empty);
                    string[] _strFiles = {this.lvFileList.Items.Count.ToString(), _strTmp, _strPassword};
                    ListViewItem _pLvItem = new ListViewItem(_strFiles);
                    this.lvFileList.Items.Add(_pLvItem);
                    LoggerInf _pLogInf = new LoggerInf("File", String.Empty);
                    _pLogInf.LogNodeAttrs.Add(new LogNodeAttr("ID", m_pLogInfs.SubLoggerInfs.Count.ToString()));
                    _pLogInf.LogNodeAttrs.Add(new LogNodeAttr("FileName", _strTmp));
                    _pLogInf.ActionResult = _strPassword;
                    m_pLogInfs.SubLoggerInfs.Add(_pLogInf);
                }
            }
            this.cbFiles.Items.Clear();
            if(this.lvFileList.SelectedItems.Count > 0)
            {
                ListViewItem _pLvItem = this.lvFileList.SelectedItems[0];
                string _strFileName = _pLvItem.SubItems[1].Text;
                this.cbFiles.Items.Add(m_strInPath + _strFileName);
                this.cbFiles.SelectedIndex = 0;
                this.txtPassword.Text = _pLvItem.SubItems[2].Text;
            }
        }
        /// <summary>
        /// 删除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            if(this.lvFileList.SelectedIndices.Count > 0)
            {
                int _nIndex = this.lvFileList.SelectedIndices[0];
                this.lvFileList.Items.RemoveAt(_nIndex);
                m_pLogInfs.SubLoggerInfs.RemoveAt(_nIndex);
                for(int _nCurrentIndex = _nIndex; _nCurrentIndex < this.lvFileList.Items.Count; _nCurrentIndex ++)
                {
                    this.lvFileList.Items[_nCurrentIndex].Text = _nCurrentIndex.ToString();
                    LoggerInf _pLogInf = (LoggerInf)m_pLogInfs.SubLoggerInfs[_nCurrentIndex];
                    foreach(LogNodeAttr _pLogNodeAttr in _pLogInf.LogNodeAttrs)
                    {
                        if(_pLogNodeAttr.AttrName == "ID")
                            _pLogNodeAttr.AttrValue = _nCurrentIndex.ToString();
                    }
                }
                if(_nIndex < this.lvFileList.Items.Count)
                    this.lvFileList.Items[_nIndex].Selected = true;
                else if(_nIndex > 0)
                    this.lvFileList.Items[_nIndex - 1].Selected = true;
            }
        }
        /// <summary>
        /// 文件列表选中事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lvFileList_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if(this.lvFileList.SelectedItems.Count > 0)
            {
                m_nSeletedIndex = this.lvFileList.SelectedIndices[0];
                LoggerInf _pLogInf = (LoggerInf)m_pLogInfs.SubLoggerInfs[m_nSeletedIndex];
                string _strFileName = String.Empty;
                foreach(LogNodeAttr _pLogNodeAttr in _pLogInf.LogNodeAttrs)
                {
                    if(_pLogNodeAttr.AttrName == "FileName")
                        _strFileName = _pLogNodeAttr.AttrValue;
                }
                this.cbFiles.Items.Add(m_strInPath + _strFileName);
                this.cbFiles.SelectedIndex = 0;
                this.txtPassword.Text = _pLogInf.ActionResult;
            }
            else
            {
                if(this.cbFiles.Items.Count > 0)
                {
                    this.lvFileList.Items[m_nSeletedIndex].SubItems[1].Text =
                        this.cbFiles.Text.Replace(m_strInPath, String.Empty);
                    this.lvFileList.Items[m_nSeletedIndex].SubItems[2].Text = this.txtPassword.Text;
                    LoggerInf _pLogInf = (LoggerInf)m_pLogInfs.SubLoggerInfs[m_nSeletedIndex];
                    LogNodeAttr _pLogNodeAttr = null;
                    foreach(LogNodeAttr _pSubLogNodeAttr in _pLogInf.LogNodeAttrs)
                    {
                        if(_pSubLogNodeAttr.AttrName == "FileName")
                            _pLogNodeAttr = _pSubLogNodeAttr;
                    }
                    _pLogNodeAttr.AttrValue = 
                        this.cbFiles.Items[0].ToString().Replace(m_strInPath, String.Empty);
                    _pLogInf.ActionResult = this.txtPassword.Text;
                }
                this.cbFiles.Items.Clear();
                this.cbFiles.Text = String.Empty;
                this.txtPassword.Text = String.Empty;
            }
        }
        /// <summary>
        /// 取消按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancle_Click(object sender, System.EventArgs e)
        {
            this.cbFiles.Items.Clear();
        }
        /// <summary>
        /// 打开文件按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnFileLocation_Click(object sender, System.EventArgs e)
        {
            string _strTmp = this.cbFiles.Text;
            if(!_strTmp.Equals(""))
            {
                // 变换该路径中的Today和Yesterday关键字为相应的日期 [12/24/2004]
                _strTmp = IOIntegrate.GetDateKeyWord(_strTmp);
                if(File.Exists(_strTmp))
                {
                    this.OFDlgFiles.InitialDirectory = Path.GetDirectoryName(_strTmp);
                    this.OFDlgFiles.FileName = String.Empty;
                }
                else
                {
                    _strTmp = Path.GetDirectoryName(_strTmp);
                    if(Directory.Exists(_strTmp))
                    {
                        this.OFDlgFiles.InitialDirectory = _strTmp;
                        this.OFDlgFiles.FileName = String.Empty;
                    }
                    else
                    {
                        this.OFDlgFiles.InitialDirectory = m_strInPath;
                        this.OFDlgFiles.FileName = String.Empty;
                    }
                }
            }
            else
            {
                this.OFDlgFiles.InitialDirectory = m_strInPath;
                this.OFDlgFiles.FileName = String.Empty;
            }
            if(this.OFDlgFiles.ShowDialog(this) == DialogResult.OK)
            {
                this.cbFiles.Items.Clear();
                foreach(string _strFileName in this.OFDlgFiles.FileNames)
                    this.cbFiles.Items.Add(_strFileName);
                if(this.cbFiles.Items.Count > 0)
                    this.cbFiles.Text = this.cbFiles.Items[0].ToString();
            }
        }
        #endregion

        #region 主界面事件
        /// <summary>
        /// 执行按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExecute_Click(object sender, System.EventArgs e)
        {
            this.btnAdd.Enabled = false;
            this.btnCancle.Enabled = false;
            this.btnDelete.Enabled = false;
            this.btnExecute.Enabled = false;
            this.btnExit.Enabled = false;
            this.btnFileLocation.Enabled = false;
            this.btnInPath.Enabled = false;
            this.btnOutPath.Enabled = false;
            this.btnSave.Enabled = false;
            this.MdiParent.WindowState = FormWindowState.Minimized;
			m_pCapEx = new CaptureException(Path.GetDirectoryName(Application.ExecutablePath) + @"\CapExCfg.ini",
				IOIntegrate.GetDateKeyWord(m_strOutPath) + @"Capture\");
			switch(this.cbTestProject.SelectedIndex)
            {
            	case 0:
                    WPSPasswordTest();
                    break;
            	case 1:
					WPPPasswordTest();
            		break;
                case 2:
                    ETPasswordTest();
                    break;
                default:
                    WPSPasswordTest();
                    break;
            }
        }
        /// <summary>
        /// 保存按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            SaveConfig();
        }
        /// <summary>
        /// 退出按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExit_Click(object sender, System.EventArgs e)
        {
            this.Close();
        }
        /// <summary>
        /// 输入路径更改事件
        /// </summary>
        /// <param name="sender"></param>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -