private void button_regedit_Click(object sender, RoutedEventArgs e) { RegeditMng myReg = new RegeditMng(); if (this.button_regedit.Content.ToString() == "右菜单添加") { if (myReg.leftMenuAdd(ToolName, Process.GetCurrentProcess().MainModule.FileName)) { MessageBox.Show("注册成功!", "提示"); this.button_regedit.Content = "右菜单删除"; } else { MessageBox.Show("注册失败!", "提示"); } } else { if (myReg.leftMenuDel(ToolName)) { MessageBox.Show("反注册成功!", "提示"); this.button_regedit.Content = "右菜单添加"; } else { MessageBox.Show("反注册失败!", "提示"); } } }
private void radioButton_CheckedChanged(object sender, EventArgs e) { if (this.radioButton1.Checked) { level = "1"; } else if (this.radioButton2.Checked) { level = "2"; } else if (this.radioButton3.Checked) { level = "3"; } else if (this.radioButton4.Checked) { level = "4"; } RegeditMng myReg = new RegeditMng(ToolName); String time_now = myReg.getRegValue("time_" + level); String wordNum_now = myReg.getRegValue("wordNum_" + level); String line_now = myReg.getRegValue("line_" + level); this.checkBox1.Checked = myReg.getRegBoolValue("base64_" + level); myReg.CloseReg(); this.textBox1.Text = time_now == "" ? "4" : time_now; this.textBox2.Text = wordNum_now == "" ? "15" : wordNum_now; this.text_nowLine.Text = line_now == "" ? "0" : line_now; }
private void initData() { RegeditMng myReg = new RegeditMng(ToolName); dataForm.FromFolder = myReg.getRegValue("FromFolder"); dataForm.ImgType1 = myReg.getRegBoolValue("ImgType1"); dataForm.ImgType2 = myReg.getRegBoolValue("ImgType2"); dataForm.ImgType3 = myReg.getRegBoolValue("ImgType3"); dataForm.SubFolder = myReg.getRegBoolValue("SubFolder"); dataForm.ReMake = myReg.getRegBoolValue("ReMake"); dataForm.OutFolder = myReg.getRegValue("OutFolder"); dataForm.BlackWhiteRadio = myReg.getRegBoolValue("BlackWhiteRadio"); dataForm.ColorRadio = myReg.getRegBoolValue("ColorRadio"); dataForm.ReplaceColor = myReg.getRegValue("ReplaceColor"); myReg.CloseReg(); text_replaceColor.IsEnabled = true; /* if (dataForm.BlackWhiteRadio) * { * text_replaceColor.IsEnabled = false; * } * else if (dataForm.ColorRadio) * { * text_replaceColor.IsEnabled = true; * } * else * { * dataForm.BlackWhiteRadio = true; * text_replaceColor.IsEnabled = false; * }*/ }
private void initData() { RegeditMng myReg = new RegeditMng(ToolName); dataForm.BatFile = myReg.getRegValue("BatFile"); dataForm.OutFolder = myReg.getRegValue("OutFolder"); dataForm.Reg = myReg.getRegValue("Reg"); myReg.CloseReg(); }
private void initData() { Dictionary <string, string> type_list = new Dictionary <string, string>() { { "0", "字符串替换" }, { "1", "文件名替换为作成时间" }, { "2", "文件名替换为更新时间" } }; //浏览器区块设置 this.replaceType.ItemsSource = type_list; this.replaceType.SelectedValuePath = "Key"; this.replaceType.DisplayMemberPath = "Value"; RegeditMng myReg = new RegeditMng(ToolName); if (ReNameTool.Program.inputArgu != "") { dataForm.TextPath = ReNameTool.Program.inputArgu; } else { dataForm.TextPath = myReg.getRegValue("TextPath"); } dataForm.CheckFolder = myReg.getRegBoolValue("CheckFolder"); dataForm.CheckFile = myReg.getRegBoolValue("CheckFile"); dataForm.CheckSubFolder = myReg.getRegBoolValue("CheckSubFolder"); dataForm.TextFrom = myReg.getRegValue("TextFrom"); //this.replaceType.SelectedValue = myReg.getRegValue("ReplaceType"); dataForm.ReplaceType = myReg.getRegValue("ReplaceType"); dataForm.setTextToArr(0, myReg.getRegValue("TextTo0")); dataForm.setTextToArr(1, myReg.getRegValue("TextTo1")); dataForm.setTextToArr(2, myReg.getRegValue("TextTo2")); if (dataForm.ReplaceType == "") { dataForm.ReplaceType = "0"; } if (dataForm.getTextToArr(1) == "") { dataForm.setTextToArr(1, "YYYYMMDD_HHMISS"); } if (dataForm.getTextToArr(2) == "") { dataForm.setTextToArr(2, "YYYYMMDD_HHMISS"); } dataForm.TextTo = dataForm.getTextToArr(int.Parse(dataForm.ReplaceType)); //check右键菜单 if (myReg.leftMenuChk(ToolName)) { this.button_regedit.Content = "右菜单删除"; } myReg.CloseReg(); }
private void button_startDown_Click(object sender, RoutedEventArgs e) { if ((string)button_startDown.Content == "开始下载") { if (dataForm.BatFile.Trim() == "" || dataForm.OutFolder.Trim() == "" || dataForm.Reg.Trim() == "") { MessageBox.Show("未入力"); return; } if (dataList == null || dataList.Count == 0) { readFile(dataForm.BatFile); } if (dataList == null || dataList.Count == 0) { MessageBox.Show("没有处理对象"); return; } if (MessageBox.Show("数据导入完毕。\n立即开始处理吗?", "标题", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } button_startDown.Content = "停止下载"; stopFlag = false; RegeditMng myReg = new RegeditMng(ToolName); myReg.setRegValue("BatFile", dataForm.BatFile); myReg.setRegValue("OutFolder", dataForm.OutFolder); myReg.setRegValue("Reg", dataForm.Reg); myReg.CloseReg(); dataForm.OutFolder = (dataForm.OutFolder.Trim() + "/").Replace(@"\", "/").Replace("//", "/").Replace("//", "/"); for (int i = 0; i < downThread.Length; i++) { downThread[i] = new Thread(new ParameterizedThreadStart(downLoadThread)); threadEndFlg[i] = false; downThread[i].Start(i); } Thread stopThread = new Thread(stopThreadStart); stopThread.Start(); } else { button_startDown.Content = "停止中..."; button_startDown.IsEnabled = false; stopFlag = true; } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { RegeditMng myReg = new RegeditMng(ToolName); myReg.setRegValue("TextPath", dataForm.TextPath); myReg.setRegValue("CheckFolder", dataForm.CheckFolder.ToString()); myReg.setRegValue("CheckFile", dataForm.CheckFile.ToString()); myReg.setRegValue("CheckSubFolder", dataForm.CheckSubFolder.ToString()); myReg.setRegValue("TextFrom", dataForm.TextFrom.ToString()); myReg.setRegValue("ReplaceType", dataForm.ReplaceType.ToString()); myReg.setRegValue("TextTo0", dataForm.getTextToArr(0)); myReg.setRegValue("TextTo1", dataForm.getTextToArr(1)); myReg.setRegValue("TextTo2", dataForm.getTextToArr(2)); myReg.CloseReg(); }
public void popWinThread() { Random random = new Random(); String message = ""; // Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); RegeditMng myReg = new RegeditMng(ToolName); ReadWriteFile rFile = new ReadWriteFile(); String fileSize_new = rFile.getFileSize(System.AppDomain.CurrentDomain.BaseDirectory + @"\" + level + @".txt"); //前回情報取得 int line_pre; int wordNum_pre; int wordNumCount_pre; String base64_pre = myReg.getRegValue("base64_" + level); String fileSize_pre = myReg.getRegValue("fileSize_" + level); Util.isNumberic(myReg.getRegValue("line_" + level), out line_pre); Util.isNumberic(myReg.getRegValue("wordNum_" + level), out wordNum_pre); Util.isNumberic(myReg.getRegValue("wordNumCount_" + level), out wordNumCount_pre); messageWin.label1.ForeColor = ColorTranslator.FromHtml(myReg.getRegValue("font_color")); Font newFont = new Font(messageWin.label1.Font.FontFamily, float.Parse(myReg.getRegValue("font_size"))); messageWin.label1.Font = newFont; messageWin.line_pre = line_pre; messageWin.wordNum_pre = wordNum_pre; messageWin.wordNumCount_pre = wordNumCount_pre; if (fileSize_pre != fileSize_new) { //前後サイズ違い messageWin.line_pre = 0; messageWin.wordNum_pre = wordNum; messageWin.wordNumCount_pre = 0; myReg.setRegValue("line_" + level, messageWin.line_pre + ""); myReg.setRegValue("wordNum_" + level, messageWin.wordNum_pre + ""); myReg.setRegValue("wordNumCount_" + level, messageWin.wordNumCount_pre + ""); myReg.setRegValue("fileSize_" + level, fileSize_new); } else if (messageWin.wordNum_pre != wordNum) { messageWin.wordNumCount_pre = 0; messageWin.wordNum_pre = wordNum; myReg.setRegValue("wordNumCount_" + level, messageWin.wordNumCount_pre + ""); myReg.setRegValue("wordNum_" + level, messageWin.wordNum_pre + ""); } Boolean breakToTopFlg = false; while (true) { breakToTopFlg = false; if (!isHidden && (!isStoped || isPrev)) //没有隐藏,没有停止或正在翻页 { isPrev = false; if (messageWin.line_pre >= wordList.Count) { //messageWin.Close(); messageWin.label1.Text = "<结束>"; break; } if (wordList != null && wordList.Count > 0) { if (messageWin.wordNumCount_pre * messageWin.wordNum_pre >= wordList[messageWin.line_pre].Length) { message = ""; } else { message = wordList[messageWin.line_pre].Substring(messageWin.wordNumCount_pre * messageWin.wordNum_pre); while (message.Length > 0) { if (isStoped) { messageWin.label1.Text = message.Substring(0, Math.Min(wordNum, message.Length)) + "<停止中>"; } else { messageWin.label1.Text = message.Substring(0, Math.Min(wordNum, message.Length)); } message = message.Substring(Math.Min(wordNum, message.Length)); for (int i = 0; i < delayTime * 2; i++) { Thread.Sleep(500); if (isPrev) { breakToTopFlg = true; break; } } if (breakToTopFlg) { break; } messageWin.wordNumCount_pre = messageWin.wordNumCount_pre + 1; myReg.setRegValue("wordNumCount_" + level, messageWin.wordNumCount_pre + ""); while ((isStoped || isHidden) && !isPrev) //隐藏 或者 停止 且 没在翻页 { Thread.Sleep(500); } } if (breakToTopFlg) { continue; } } /* while (message.Length > wordNum) { * messageWin.label1.Text = message.Substring(0,wordNum); * message = message.Substring(wordNum); * Thread.Sleep(delayTime * 1000); * * messageWin.wordNumCount_pre = messageWin.wordNumCount_pre + 1; * myReg.setRegValue("wordNumCount_" + level, messageWin.wordNumCount_pre + ""); * * while (isStoped || isHidden) * { * Thread.Sleep(delayTime * 1000); * } * } * if (message.Length > 0) { * messageWin.label1.Text = message; * Thread.Sleep(delayTime * 1000); * }*/ messageWin.line_pre = messageWin.line_pre + 1; messageWin.wordNumCount_pre = 0; myReg.setRegValue("line_" + level, messageWin.line_pre + ""); myReg.setRegValue("wordNumCount_" + level, messageWin.wordNumCount_pre + ""); } else { messageWin.label1.Text = "<没有内容>"; //messageWin.Close(); break; } } else { Thread.Sleep(500); } } }
private void init() { this.Height = this.Height - this.panel1.Height; RegeditMng myReg = new RegeditMng(ToolName); level = myReg.getRegValue("level"); if (level.Length == 0) { level = "1"; this.textBox1.Text = "4"; this.textBox2.Text = "15"; this.text_nowLine.Text = "0"; this.checkBox1.Checked = false; this.hidden_ctrl.Checked = true; this.hidden_alt.Checked = true; this.hidden_shift.Checked = false; this.hidden_key.Text = "C"; this.stop_ctrl.Checked = true; this.stop_alt.Checked = true; this.stop_shift.Checked = false; this.stop_key.Text = "S"; this.pre_ctrl.Checked = true; this.pre_alt.Checked = true; this.pre_shift.Checked = false; this.pre_key.Text = "←"; this.next_ctrl.Checked = true; this.next_alt.Checked = true; this.next_shift.Checked = false; this.next_key.Text = "→"; this.button_fontColor.ForeColor = Color.Black; this.comboBox_fontSize.Text = "9"; } else { try { this.textBox1.Text = myReg.getRegValue("time_" + level); this.textBox2.Text = myReg.getRegValue("wordNum_" + level); this.text_nowLine.Text = myReg.getRegValue("line_" + level); this.checkBox1.Checked = myReg.getRegBoolValue("base64_" + level); this.hidden_ctrl.Checked = myReg.getRegBoolValue("hidden_ctrl"); this.hidden_alt.Checked = myReg.getRegBoolValue("hidden_alt"); this.hidden_shift.Checked = myReg.getRegBoolValue("hidden_shift"); this.hidden_key.Text = myReg.getRegValue("hidden_key"); this.stop_ctrl.Checked = myReg.getRegBoolValue("stop_ctrl"); this.stop_alt.Checked = myReg.getRegBoolValue("stop_alt"); this.stop_shift.Checked = myReg.getRegBoolValue("stop_shift"); this.stop_key.Text = myReg.getRegValue("stop_key"); this.pre_ctrl.Checked = myReg.getRegBoolValue("pre_ctrl"); this.pre_alt.Checked = myReg.getRegBoolValue("pre_alt"); this.pre_shift.Checked = myReg.getRegBoolValue("pre_shift"); this.pre_key.Text = myReg.getRegValue("pre_key"); this.next_ctrl.Checked = myReg.getRegBoolValue("next_ctrl"); this.next_alt.Checked = myReg.getRegBoolValue("next_alt"); this.next_shift.Checked = myReg.getRegBoolValue("next_shift"); this.next_key.Text = myReg.getRegValue("next_key"); this.button_fontColor.ForeColor = ColorTranslator.FromHtml(myReg.getRegValue("font_color")); this.comboBox_fontSize.Text = myReg.getRegValue("font_size"); } catch (Exception) { level = "1"; this.textBox1.Text = "4"; this.textBox2.Text = "15"; this.text_nowLine.Text = "0"; this.checkBox1.Checked = false; this.hidden_ctrl.Checked = true; this.hidden_alt.Checked = true; this.hidden_shift.Checked = false; this.hidden_key.Text = "C"; this.stop_ctrl.Checked = true; this.stop_alt.Checked = true; this.stop_shift.Checked = false; this.stop_key.Text = "S"; this.pre_ctrl.Checked = true; this.pre_alt.Checked = true; this.pre_shift.Checked = false; this.pre_key.Text = "←"; this.next_ctrl.Checked = true; this.next_alt.Checked = true; this.next_shift.Checked = false; this.next_key.Text = "→"; this.button_fontColor.ForeColor = Color.Black; this.comboBox_fontSize.Text = "9"; } } myReg.CloseReg(); switch (level) { case "2": radioButton2.Checked = true; break; case "3": radioButton3.Checked = true; break; case "4": radioButton4.Checked = true; break; default: radioButton1.Checked = true; break; } }
private void button1_Click(object sender, EventArgs e) { // レーベルが選択されない場合 if (!this.radioButton4.Checked && !this.radioButton3.Checked && !this.radioButton2.Checked && !this.radioButton1.Checked) { MessageBox.Show("请选择1,2,3,4"); return; } // 時間が設定されない場合 if (!Util.isNumberic(this.textBox1.Text, out delayTime)) { MessageBox.Show("持续时间没有设置"); return; } // 文字数を設定 if (!Util.isNumberic(this.textBox2.Text, out wordNum)) { MessageBox.Show("一次显示字数没有设置"); return; } // 热键check if (this.hidden_key.Text.Length != 1 || this.stop_key.Text.Length != 1 || this.pre_key.Text.Length != 1) { MessageBox.Show("快捷键没有设置字母"); return; } RegeditMng myReg = new RegeditMng(ToolName); myReg.setRegValue("level", level); myReg.setRegValue("time_" + level, this.textBox1.Text); myReg.setRegValue("wordNum_" + level, this.textBox2.Text); myReg.setRegValue("line_" + level, this.text_nowLine.Text); myReg.setRegValue("base64_" + level, this.checkBox1.Checked.ToString()); myReg.setRegValue("hidden_ctrl", this.hidden_ctrl.Checked.ToString()); myReg.setRegValue("hidden_alt", this.hidden_alt.Checked.ToString()); myReg.setRegValue("hidden_shift", this.hidden_shift.Checked.ToString()); myReg.setRegValue("hidden_key", this.hidden_key.Text); myReg.setRegValue("stop_ctrl", this.stop_ctrl.Checked.ToString()); myReg.setRegValue("stop_alt", this.stop_alt.Checked.ToString()); myReg.setRegValue("stop_shift", this.stop_shift.Checked.ToString()); myReg.setRegValue("stop_key", this.stop_key.Text); myReg.setRegValue("pre_ctrl", this.pre_ctrl.Checked.ToString()); myReg.setRegValue("pre_alt", this.pre_alt.Checked.ToString()); myReg.setRegValue("pre_shift", this.pre_shift.Checked.ToString()); myReg.setRegValue("pre_key", this.pre_key.Text); myReg.setRegValue("next_ctrl", this.next_ctrl.Checked.ToString()); myReg.setRegValue("next_alt", this.next_alt.Checked.ToString()); myReg.setRegValue("next_shift", this.next_shift.Checked.ToString()); myReg.setRegValue("next_key", this.next_key.Text); myReg.setRegValue("font_color", ColorTranslator.ToHtml(this.button_fontColor.ForeColor)); myReg.setRegValue("font_size", this.comboBox_fontSize.Text); myReg.CloseReg(); //若设置界面是可见的,隐藏 if (panel1.Visible) { panel1.Visible = false; this.Height = this.Height - this.panel1.Height; } // 最小化 到 任务栏 this.WindowState = FormWindowState.Minimized; this.ShowInTaskbar = false; this.notifyIcon1.Icon = IconResource.MiniIco; this.notifyIcon1.Visible = true; isHidden = false; ReadWriteFile rFile = new ReadWriteFile(); wordList = rFile.readFile(System.AppDomain.CurrentDomain.BaseDirectory + @"\" + level + @".txt", this.checkBox1.Checked); /*if (messageWin == null || messageWin.IsDisposed) * { * messageWin = new Form2(); * messageWin.Show(); * * messageWin.level = level; * * //thread start * messageThread = new Thread(popWinThread); * messageThread.Start(); * } else if (!messageWin.Visible) { * messageWin.Visible = true; * isHidden = false; * }*/ if (messageWin != null) { messageWin.Close(); } if (messageThread != null) { messageThread.Abort(); } messageWin = new Form2(); messageWin.Owner = this; messageWin.Show(); messageWin.level = level; //thread start messageThread = new Thread(popWinThread); messageThread.Start(); }
private void button_start_Click(object sender, RoutedEventArgs e) { if ((string)button_start.Content == "开始处理") { if (dataForm.FromFolder.Trim() == "" || dataForm.OutFolder.Trim() == "" || (dataForm.ReplaceColor.Trim() == "" && dataForm.ColorRadio)) { MessageBox.Show("未入力"); return; } if (!dataForm.ImgType1 && !dataForm.ImgType2 && !dataForm.ImgType3) { MessageBox.Show("处理对象类别未选择"); return; } dataForm.FromFolder = (dataForm.FromFolder.Trim() + "/").Replace(@"\", "/").Replace("//", "/").Replace("//", "/"); dataForm.OutFolder = (dataForm.OutFolder.Trim() + "/").Replace(@"\", "/").Replace("//", "/").Replace("//", "/"); if (dataList == null || dataList.Count == 0) { getFileList(dataForm.FromFolder); } if (dataList == null || dataList.Count == 0) { MessageBox.Show("没有处理对象"); return; } if (MessageBox.Show("数据导入完毕。\n立即开始处理吗?", "标题", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } if (!System.IO.Directory.Exists(dataForm.OutFolder)) { Directory.CreateDirectory(dataForm.OutFolder); } button_start.Content = "停止处理"; dataForm.ReplaceColor = dataForm.ReplaceColor.ToUpper(); RegeditMng myReg = new RegeditMng(ToolName); myReg.setRegValue("FromFolder", dataForm.FromFolder.ToString()); myReg.setRegValue("ImgType1", dataForm.ImgType1.ToString()); myReg.setRegValue("ImgType2", dataForm.ImgType2.ToString()); myReg.setRegValue("ImgType3", dataForm.ImgType3.ToString()); myReg.setRegValue("SubFolder", dataForm.SubFolder.ToString()); myReg.setRegValue("ReMake", dataForm.ReMake.ToString()); myReg.setRegValue("OutFolder", dataForm.OutFolder.ToString()); myReg.setRegValue("BlackWhiteRadio", dataForm.BlackWhiteRadio.ToString()); myReg.setRegValue("ColorRadio", dataForm.ColorRadio.ToString()); myReg.setRegValue("ReplaceColor", dataForm.ReplaceColor.ToString()); myReg.CloseReg(); //get ok Str readOKFile(dataForm.OutFolder + "replaceOkList.txt"); if (okStr == null || okStr.Length == 0) { okStr = "|"; } for (int i = 0; i < downThread.Length; i++) { logFile[i] = dataForm.OutFolder + "log_" + i + ".txt"; okStrArr[i] = "|"; writeLog(logFile[i], "Start"); downThread[i] = new Thread(new ParameterizedThreadStart(replaceThread)); threadEndFlg[i] = false; downThread[i].Start(i); } Thread stopThread = new Thread(stopThreadStart); stopThread.Start(); } else { button_start.Content = "停止中..."; button_start.IsEnabled = false; stopFlag = true; } }