Example #1
0
    public static void begin()
    {
        YDColorizer.GlobalException.Initialize();

        Timer timer = new Timer();

        #region 配置文件不存在,创建默认配置文件
        if (Config.IsConfigExists() == false)
        {
            Config.CreateDefault();
        }
        #endregion

        List <string> dialogBoxTitles = AboutConfig.LoadSearchTitles();

        EditDialogBox edb           = new EditDialogBox();
        int           thisProcessId = System.Diagnostics.Process.GetCurrentProcess().Id;

        timer.Interval = 100;// 设置搜索间隔为100毫秒
        timer.Tick    += new EventHandler((object object_sender, EventArgs EventArgs_e) =>
        {
            try
            {
                if (edb.hWnd == IntPtr.Zero)
                {
                    foreach (var title in dialogBoxTitles)                                                                   // 遍历标题数组寻找对话框
                    {
                        WinApi.Window dialogBox = new WinApi.Window(DialogBoxClassName, title);                              // 搜索we物体编辑器的文本编辑框
                        if (dialogBox.Handle != IntPtr.Zero && thisProcessId == AboutProcess.GetProcessId(dialogBox.Handle)) // 搜索的对话框与该ydwe插件同进程
                        {
                            edb.AttachDialog(dialogBox.Handle);                                                              // 重建模拟窗口
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                timer.Stop();
                GlobalException.CatchException(e, e.ToString());
            }
        });

        timer.Start();// 启动搜索计时器
    }
Example #2
0
        public void ReLoad()
        {
            #region 初始化标签
            WinApi.Label lblStatic = new WinApi.Label(this.hWnd, IntPtr.Zero, StaticClassName, null); // 搜索原窗口中的标签
            this.hStatic        = lblStatic.Handle;                                                   // 保存标签句柄
            this.lblStatic.Text = lblStatic.Text;                                                     // 从原窗口获取标签文本并设置到模拟窗口
            #endregion

            #region 初始化文本框
            WinApi.TextBox txtEdit = new WinApi.TextBox(this.hWnd, IntPtr.Zero, EditClassName, null);                 // 搜索原窗口中的文本框
            this.hEdit = txtEdit.Handle;                                                                              // 保存文本框句柄
            this.txtEdit.lockTextChange = true;                                                                       // 使文本框进入代码修改模式
            this.txtEdit.Text           = txtEdit.Text;                                                               // 从原窗口获取文本框文本并设置到模拟窗口
            this.txtEdit.lastText       = new MyTextBox.UndoRedoInfo(this.txtEdit.Text, this.txtEdit.SelectionStart); // 设置文本框文本为最后修改的文本
            TextConvert.ConvertToPreviewTextBox(this.txtEdit, this.txtPreview);                                       // 强制将文本转化到预览框
            this.lastFocus = this.txtEdit;                                                                            // 设置最后焦点在基础文本框
            this.txtEdit.lockTextChange = false;                                                                      // 离开代码修改模式
            this.txtEdit.SelectAll();                                                                                 // 选取所有文本
            #endregion

            #region 初始化确定按钮
            WinApi.Button btnOk = new WinApi.Button(this.hWnd, this.hEdit, ButtonClassName, null); // 搜索原窗口中的确定按钮
            this.hBtnOk     = btnOk.Handle;                                                        // 保存确定按钮句柄
            this.btnOk.Text = btnOk.Text;                                                          // 从原窗口获取确定按钮文本并设置到模拟窗口
            #endregion

            #region 初始化取消按钮
            WinApi.Button btnCancel = new WinApi.Button(this.hWnd, this.hBtnOk, ButtonClassName, null); // 搜索原窗口中的取消按钮
            this.hBtnCancel     = btnCancel.Handle;                                                     // 保存取消按钮句柄
            this.btnCancel.Text = btnCancel.Text;                                                       // 从原窗口获取取消按钮文本并设置到模拟窗口
            #endregion

            #region 初始化窗口
            WinApi.Window window = new WinApi.Window(this.hWnd); // 创建原窗口实例
            this.Location = window.Location;                     // 设置模拟窗口的位置在原窗口的位置上

            if (Config.LoadDialogSize(this) == false)
            {
                this.Width  = window.Width;
                this.Height = window.Height * 2;
            }

            this.Text = window.Text; // 从原窗口获取标题并设置到模拟窗口
            window.Hide();           // 隐藏原窗口
            #endregion

            #region 初始化用户使用的颜色
            Config.LoadColor(btn1stColor);
            Config.LoadColor(btn2ndColor);
            Config.LoadColor(btn3rdColor);
            Config.LoadColor(btn4thColor);
            #endregion

            #region 初始化提示
            ToolTip toolTip = new ToolTip();
            toolTip.SetToolTip(this.btn1stColor, "点击以选择主颜色");
            toolTip.SetToolTip(this.btn2ndColor, "点击鼠标左键以选取颜色" + Environment.NewLine + "点击鼠标右键以与主颜色交换颜色");
            toolTip.SetToolTip(this.btn3rdColor, "点击鼠标左键以选取颜色" + Environment.NewLine + "点击鼠标右键以与主颜色交换颜色");
            toolTip.SetToolTip(this.btn4thColor, "点击鼠标左键以选取颜色" + Environment.NewLine + "点击鼠标右键以与主颜色交换颜色");
            toolTip.SetToolTip(this.btnSetColor, "点击以设置选择文本的颜色");
            toolTip.SetToolTip(this.btnGradual, "点击以使用主颜色和第一候选色对选择文本进行渐变");
            toolTip.SetToolTip(this.btnUndo, "撤销" + Environment.NewLine + "(Ctrl+Z)");
            toolTip.SetToolTip(this.btnRedo, "重做" + Environment.NewLine + "(Ctrl+Y)");
            toolTip.SetToolTip(this.btnOk, "快捷键Ctrl+Enter");
            #endregion

            //this.Activate();// 激活当前窗口
        }
Example #3
0
    public static void begin()
    {
        YDColorizer.GlobalException.Initialize();

        Timer timer = new Timer();

        #region 配置文件不存在,创建默认配置文件
        if (Config.IsConfigExists() == false)
        {
            Config.CreateDefault();
        }
        #endregion

        Program.language = Config.GetLanguage();

        List<string> dialogBoxTitles = AboutConfig.LoadSearchTitles();

        #region 托盘图标
        if (Config.IsNotifyIconVisible() == true)
        {
            NotifyIcon notifyIcon = new NotifyIcon();
            notifyIcon.Icon = YDColorizer.Properties.Resources.icoYDColorizerRuning;
            switch (Program.language)
            {
                case 0:
                    notifyIcon.Text = "YDWE颜色插件正在执行" + Environment.NewLine + "点击图标可以暂时停止执行";
                    break;
                case 1:
                    notifyIcon.Text = "YDWE顏色插件正在執行" + Environment.NewLine + "點擊圖標可以暫時停止執行";
                    break;
                default:
                    break;
            }
            notifyIcon.Visible = true;
            notifyIcon.Click += new EventHandler((object object_sender, EventArgs EventArgs_e) =>
            {
                if (timer.Enabled == true)
                {
                    timer.Enabled = false;
                    notifyIcon.Icon = YDColorizer.Properties.Resources.icoYDColorizerStop;
                    switch (Program.language)
                    {
                        case 0:
                            notifyIcon.Text = "YDWE颜色插件已暂停" + Environment.NewLine + "点击图标可以恢复执行";
                            break;
                        case 1:
                            notifyIcon.Text = "YDWE顏色插件已暫停" + Environment.NewLine + "點擊圖標可以恢復執行";
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    timer.Enabled = true;
                    notifyIcon.Icon = YDColorizer.Properties.Resources.icoYDColorizerRuning;
                    switch (Program.language)
                    {
                        case 0:
                            notifyIcon.Text = "YDWE颜色插件正在执行" + Environment.NewLine + "点击图标可以暂时停止执行";
                            break;
                        case 1:
                            notifyIcon.Text = "YDWE顏色插件正在執行" + Environment.NewLine + "點擊圖標可以暫時停止執行";
                            break;
                        default:
                            break;
                    }
                }
            });
        }
        #endregion

        timer.Interval = 100;// 设置搜索间隔为100毫秒

        EditDialogBox edb = new EditDialogBox();

        timer.Tick += new EventHandler((object object_sender, EventArgs EventArgs_e) =>
        {
            try
            {
                if (edb.hWnd == IntPtr.Zero)
                {
                    foreach (var title in dialogBoxTitles)// 遍历标题数组寻找对话框
                    {
                        WinApi.Window dialogBox = new WinApi.Window(DialogBoxClassName, title);// 搜索we物体编辑器的文本编辑框
                        if (dialogBox.Handle != IntPtr.Zero)// 找到
                        {
                            int thisProcessId = System.Diagnostics.Process.GetCurrentProcess().Id;
                            int targetProcessId = AboutProcess.GetProcessId(dialogBox.Handle);
                            if (thisProcessId == targetProcessId)// 搜索的对话框与该ydwe插件同进程
                            {
                                edb.AttachDialog(dialogBox.Handle);// 重建模拟窗口
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                timer.Stop();
                GlobalException.CatchException(e, e.ToString());
            }
        });

        timer.Start();// 启动搜索计时器
    }
Example #4
0
    public static void begin()
    {
        YDColorizer.GlobalException.Initialize();

        Timer timer = new Timer();

        #region 配置文件不存在,创建默认配置文件
        if (Config.IsConfigExists() == false)
        {
            Config.CreateDefault();
        }
        #endregion

        Program.language = Config.GetLanguage();

        List <string> dialogBoxTitles = AboutConfig.LoadSearchTitles();

        #region 托盘图标
        if (Config.IsNotifyIconVisible() == true)
        {
            NotifyIcon notifyIcon = new NotifyIcon();
            notifyIcon.Icon = YDColorizer.Properties.Resources.icoYDColorizerRuning;
            switch (Program.language)
            {
            case 0:
                notifyIcon.Text = "YDWE颜色插件正在执行" + Environment.NewLine + "点击图标可以暂时停止执行";
                break;

            case 1:
                notifyIcon.Text = "YDWE顏色插件正在執行" + Environment.NewLine + "點擊圖標可以暫時停止執行";
                break;

            default:
                break;
            }
            notifyIcon.Visible = true;
            notifyIcon.Click  += new EventHandler((object object_sender, EventArgs EventArgs_e) =>
            {
                if (timer.Enabled == true)
                {
                    timer.Enabled   = false;
                    notifyIcon.Icon = YDColorizer.Properties.Resources.icoYDColorizerStop;
                    switch (Program.language)
                    {
                    case 0:
                        notifyIcon.Text = "YDWE颜色插件已暂停" + Environment.NewLine + "点击图标可以恢复执行";
                        break;

                    case 1:
                        notifyIcon.Text = "YDWE顏色插件已暫停" + Environment.NewLine + "點擊圖標可以恢復執行";
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    timer.Enabled   = true;
                    notifyIcon.Icon = YDColorizer.Properties.Resources.icoYDColorizerRuning;
                    switch (Program.language)
                    {
                    case 0:
                        notifyIcon.Text = "YDWE颜色插件正在执行" + Environment.NewLine + "点击图标可以暂时停止执行";
                        break;

                    case 1:
                        notifyIcon.Text = "YDWE顏色插件正在執行" + Environment.NewLine + "點擊圖標可以暫時停止執行";
                        break;

                    default:
                        break;
                    }
                }
            });
        }
        #endregion

        timer.Interval = 100;// 设置搜索间隔为100毫秒

        EditDialogBox edb = new EditDialogBox();

        timer.Tick += new EventHandler((object object_sender, EventArgs EventArgs_e) =>
        {
            try
            {
                if (edb.hWnd == IntPtr.Zero)
                {
                    foreach (var title in dialogBoxTitles)                                      // 遍历标题数组寻找对话框
                    {
                        WinApi.Window dialogBox = new WinApi.Window(DialogBoxClassName, title); // 搜索we物体编辑器的文本编辑框
                        if (dialogBox.Handle != IntPtr.Zero)                                    // 找到
                        {
                            int thisProcessId   = System.Diagnostics.Process.GetCurrentProcess().Id;
                            int targetProcessId = AboutProcess.GetProcessId(dialogBox.Handle);
                            if (thisProcessId == targetProcessId)   // 搜索的对话框与该ydwe插件同进程
                            {
                                edb.AttachDialog(dialogBox.Handle); // 重建模拟窗口
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                timer.Stop();
                GlobalException.CatchException(e, e.ToString());
            }
        });

        timer.Start();// 启动搜索计时器
    }