Exemplo n.º 1
0
        private void ListViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Topmost = false;
            //MessageBox.Show(lvItems[lv.SelectedIndex].FilePath);
            string ClickedFile                     = lvItems[lv.SelectedIndex].FilePath;
            string ClickedFileExtension            = System.IO.Path.GetExtension(ClickedFile).Replace(".", "").ToUpper();
            string ClickedFileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(ClickedFile);
            string ClickedFileFolder               = System.IO.Path.GetDirectoryName(ClickedFile);
            string ExtractFolder                   = System.IO.Path.Combine(
                ClickedFileFolder,
                "VFILENAME-" + ClickedFileExtension + "-" + ClickedFileNameWithoutExtension + "-" + DateTime.Now.ToString("*****@*****.**")
                );

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            if (ClickedFileExtension == "RAR")
            {
                string RarExe = ConfigTxt.Read("rarexe", "");
                if (RarExe == "")
                {
                    MessageBox.Show("WinRAR程序位置没有定义。");
                    return;
                }
                startInfo.FileName  = RarExe;
                startInfo.Arguments = "x \"" + ClickedFile + "\" \"" + ExtractFolder + "\\\"";
                //MessageBox.Show(startInfo.Arguments);
            }
            if (ClickedFileExtension == "7Z")
            {
                string SevenZipExe = ConfigTxt.Read("7zexe", "");
                if (SevenZipExe == "")
                {
                    MessageBox.Show("7-Zip程序位置没有定义。");
                    return;
                }
                startInfo.FileName  = SevenZipExe;
                startInfo.Arguments = "x \"" + ClickedFile + "\" -o\"" + ExtractFolder + "\\\"";
                //MessageBox.Show(startInfo.Arguments);
            }
            process.StartInfo = startInfo;
            process.Start();
            process.WaitForExit();
            System.Diagnostics.Process.Start(ExtractFolder);
        }
Exemplo n.º 2
0
        public static void MonitorThreadFunction()
        {
            App.Current.Dispatcher.Invoke((Action)(() =>
            {
                fnw = new FileNameWindow();
            }));
            while (true)
            {
                if (((GetActiveWindowTitle() == "压缩文件名和参数") || (GetActiveWindowTitle() == "添加到压缩包")) &&
                    (GetForegroundWindow() != HandledHwnd))
                {
                    int RarOr7z = 0;
                    if (GetActiveWindowTitle() == "压缩文件名和参数")
                    {
                        RarOr7z = 1;
                        string RarExe = GetRarExe();
                        ConfigTxt.Write("rarexe", RarExe, "");
                    }
                    if (GetActiveWindowTitle() == "添加到压缩包")
                    {
                        RarOr7z = 2;
                        string SevenZipExe = Get7zExe();
                        ConfigTxt.Write("7zexe", SevenZipExe, "");
                    }

                    Thread.Sleep(1100);
                    HandledHwnd = GetForegroundWindow();
                    Rect r = new Rect();
                    GetWindowRect(GetForegroundWindow(), ref r);
                    App.Current.Dispatcher.Invoke((Action)(() =>
                    {
                        fnw.Topmost = true;
                        fnw.Top = -10000;
                        fnw.Left = -10000;
                        fnw.UserNameTextBox.Text = ConfigTxt.Read("username", "用户名");
                        fnw.InitShow();
                        IntPtr fnwHwnd = (new WindowInteropHelper(fnw)).Handle;

                        if (RarOr7z == 1)
                        {
                            MoveWindow(fnwHwnd,
                                       r.Left + (r.Right - r.Left) / 2 - (r.Right - r.Left) * 150 / (100 * 2),
                                       r.Top + (r.Bottom - r.Top) / 2 - (r.Bottom - r.Top) * 46 / (100 * 2),
                                       (r.Right - r.Left) * 150 / 100,
                                       (r.Bottom - r.Top) * 46 / 100,
                                       true);
                        }
                        else if (RarOr7z == 2)
                        {
                            MoveWindow(fnwHwnd,
                                       r.Left,
                                       r.Top + (r.Bottom - r.Top) / 2 - (r.Bottom - r.Top) * 33 / (100 * 2),
                                       (r.Right - r.Left),
                                       (r.Bottom - r.Top) * 33 / 100,
                                       true);
                        }
                    }));
                }
                if (!IsWindow(HandledHwnd))
                {
                    App.Current.Dispatcher.Invoke((Action)(() =>
                    {
                        fnw.Close();
                    }));
                }
                Thread.Sleep(100);
            }
        }
Exemplo n.º 3
0
 private void UserNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     ConfigTxt.Write("username", ((TextBox)sender).Text, "用户名");
 }