System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window, string)

Here are the examples of the csharp api System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window, string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2794 Examples 7

19 View Source File : MonitorItemForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button1_Click(object sender, EventArgs e)
        {
            int index = tabControl1.SelectedIndex;
            bool isnew = false;
            if (monitorConfig == null)
            {
                isnew = true;                
            }
            else
            {
                index = tabIndex;
            }
            if (index == 0)
            { // springboot
                SpringBootMonitorItem item = new SpringBootMonitorItem();                
                item.AppName = stb_app_name.Text;
                item.BuildFileName = stb_build_file.Text;
                item.CrlFileName = stb_ctl_file.Text;
                item.ShFileDir = stb_sh_dir.Text;
                if (item.ShFileDir.EndsWith("/"))
                {
                    item.ShFileDir = item.ShFileDir.Substring(0, item.ShFileDir.Length);
                }
                item.ProjectSourceDir = stb_project_source_dir.Text;
                if (item.ProjectSourceDir.EndsWith("/"))
                {
                    item.ProjectSourceDir = item.ProjectSourceDir.Substring(0, item.ProjectSourceDir.Length);
                }
                item.HomeUrl = stb_home_url.Text;
                item.RunStatus = RunState.NoCheck;
                if (string.IsNullOrWhiteSpace(item.HomeUrl))
                {
                    item.HomeUrl = "http://" + config.Host + ":8080/";
                }
                if (string.IsNullOrWhiteSpace(item.AppName) || hasNonChar(item.AppName))
                {
                    MessageBox.Show(this, "请填写应用名称,且不能包含'\",:;|");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.ShFileDir))
                {
                    MessageBox.Show(this, "请填写应用脚本目录");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.BuildFileName))
                {
                    MessageBox.Show(this, "请填写应用编译脚本文件名称");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.CrlFileName))
                {
                    MessageBox.Show(this, "请填写应用控制脚本文件名称");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.ProjectSourceDir))
                {
                    MessageBox.Show(this, "请填写应用代码存放目录");
                    return;
                }

                item.NeedAdd = cb_need_add.Checked;
                if (item.NeedAdd)
                {
                    item.ProjectSvnUrl = stb_project_svn.Text;
                    if (string.IsNullOrWhiteSpace(item.ProjectSvnUrl))
                    {
                        MessageBox.Show(this, "请填写应用SVN地址");
                        return;
                    }
                }
                if (isnew)
                {
                    item.Uuid = Guid.NewGuid().ToString("N");
                    monitorConfig = new MonitorItemConfig();
                }
                else
                {
                    item.Uuid = monitorConfig.spring.Uuid;
                }
                monitorConfig.spring = item;
            }
            else if (index == 1)
            { // tomcat
                TomcatMonitorItem item = new TomcatMonitorItem();                
                item.TomcatName = stb_tomcat_name.Text;
                item.TomcatDir = stb_tomcat_path.Text;
                item.TomcatPort = stb_tomcat_port.Text;
                item.RunStatus = RunState.NoCheck;
                if (string.IsNullOrWhiteSpace(item.TomcatName) || hasNonChar(item.TomcatName))
                {
                    MessageBox.Show(this, "请填写Tomcat名称,且不能包含'\",:;|");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.TomcatDir))
                {
                    MessageBox.Show(this, "请填写Tomcat根目录");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.TomcatPort))
                {
                    item.TomcatPort = "8080";
                }
                if (isnew)
                {
                    item.Uuid = Guid.NewGuid().ToString("N");
                    monitorConfig = new MonitorItemConfig();
                }
                else
                {
                    item.Uuid = monitorConfig.tomcat.Uuid;
                }
                monitorConfig.tomcat = item;
            }
            else if (index == 2)
            { // nginx
                NginxMonitorItem item = new NginxMonitorItem();                
                item.NginxName = stb_nginx_name.Text;
                item.NginxPath = stb_nginx_path.Text;
                item.NginxConfig = stb_nginx_conf.Text;
                item.RunStatus = RunState.NoCheck;
                if (string.IsNullOrWhiteSpace(item.NginxName) || hasNonChar(item.NginxName))
                {
                    MessageBox.Show(this, "请填写Nginx名称,且不能包含'\",:;|");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.NginxPath))
                {
                    MessageBox.Show(this, "请填写Nginx执行文件完整路径");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.NginxConfig))
                {
                    MessageBox.Show(this, "请填写Nginx配置文件完整路径");
                    return;
                }
                if (isnew)
                {
                    monitorConfig = new MonitorItemConfig();
                    item.Uuid = Guid.NewGuid().ToString("N");
                }
                else
                {
                    item.Uuid = monitorConfig.nginx.Uuid;
                }
                monitorConfig.nginx = item;
            }
            else if (index == 3)
            { // ice
                IceMonitorItem item = new IceMonitorItem();
                item.AppName = stb_ice_appname.Text;
                item.IceSrvDir = stb_ice_srvpath.Text;
                item.NodePorts = stb_ice_ports.Text;
                item.ServerName = stb_ice_servername.Text;
                item.RunStatus = RunState.NoCheck;
                if (string.IsNullOrWhiteSpace(item.AppName) || hasNonChar(item.AppName))
                {
                    MessageBox.Show(this, "请填写项目名称,且不能包含'\",:;|");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.IceSrvDir))
                {
                    MessageBox.Show(this, "请填写项目Ice目录完整路径");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.ServerName))
                {
                    MessageBox.Show(this, "请填写Ice服务名称");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(item.NodePorts))
                {
                    MessageBox.Show(this, "请填写项目使用的端口号,多个以逗号(,)分隔");
                    return;
                }
                if (isnew)
                {
                    monitorConfig = new MonitorItemConfig();
                    item.Uuid = Guid.NewGuid().ToString("N");
                }
                else
                {
                    item.Uuid = monitorConfig.ice.Uuid;
                }
                monitorConfig.ice = item;
            }


            if (isnew)
            {
                config.MonitorConfigList.Add(monitorConfig);
            }

            AppConfig.Instance.SaveConfig(2);

            if (null != parentForm && monitorConfig.spring != null)
            {
                // TODO 执行checkout
                if (monitorConfig.spring.NeedAdd)
                {
                    string home = parentForm.getSftp().getHome();
                    string buildStr = YSTools.YSFile.readFileToString(MainForm.CONF_DIR + "__build.sh");
                    string ctlStr = YSTools.YSFile.readFileToString(MainForm.CONF_DIR + "__ctl.sh");
                    if (monitorConfig.spring.ProjectSourceDir.StartsWith(home))
                    {
                        string path = monitorConfig.spring.ProjectSourceDir.Substring(home.Length);
                        if (path.StartsWith("/"))
                        {
                            path = path.Substring(1);
                        }
                        buildStr = buildStr.Replace("_sourcePath_", "~/" + path);
                        ctlStr = ctlStr.Replace("_sourcePath_", "~/" + path);
                    }
                    else
                    {
                        buildStr = buildStr.Replace("_sourcePath_", monitorConfig.spring.ProjectSourceDir);
                        ctlStr = ctlStr.Replace("_sourcePath_", monitorConfig.spring.ProjectSourceDir);
                    }
                    buildStr = buildStr.Replace("_projectName_", monitorConfig.spring.AppName);
                    ctlStr = ctlStr.Replace("_projectName_", monitorConfig.spring.AppName);
                    ctlStr = ctlStr.Replace("_disconfigUrl_", stb_disconfig_url.Text);                    

                    string localBuild = MainForm.CONF_DIR + monitorConfig.spring.BuildFileName;
                    string localCtl = MainForm.CONF_DIR + monitorConfig.spring.CrlFileName;
                    string remoteBuild = monitorConfig.spring.ShFileDir + "/" + monitorConfig.spring.BuildFileName;
                    string remoteCtl = monitorConfig.spring.ShFileDir + "/" + monitorConfig.spring.CrlFileName;

                    YSTools.YSFile.writeFileByString(localBuild, buildStr);
                    YSTools.YSFile.writeFileByString(localCtl, ctlStr);

                    ThreadPool.QueueUserWorkItem((a) =>
                    {
                        Thread.Sleep(500);
                        parentForm.BeginInvoke((MethodInvoker)delegate()
                        {
                            parentForm.getSftp().put(localBuild, remoteBuild, ChannelSftp.OVERWRITE);
                            parentForm.getSftp().put(localCtl, remoteCtl, ChannelSftp.OVERWRITE);

                            parentForm.RunShell("cd " + monitorConfig.spring.ProjectSourceDir, true);
                            parentForm.RunShell("svn checkout " + monitorConfig.spring.ProjectSvnUrl, true);

                            File.Delete(localBuild);
                            File.Delete(localCtl);
                        });
                    });
                }                
            }

            this.Close();
        }

19 View Source File : LockForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button1_Click(object sender, EventArgs e)
        {
            string pwd = stb_pwd.Text;
            if(pwd == lockPwd){
                Program.MAIN.unLockForm();
            }
            else
            {
                MessageBox.Show(this, "密码不正确");
            }
        }

19 View Source File : IceMonitorForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            if (customShellListView.SelectedItems.Count > 0)
            {
                try
                {
                    ListViewItem item = customShellListView.SelectedItems[0];
                    DialogResult dr = MessageBox.Show(this, "您确定要删除此项吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (dr == System.Windows.Forms.DialogResult.OK)
                    {
                        customShellListView.Items.Remove(item);
                        CmdShell cmds = (CmdShell)item.Tag;
                        seConfig.CustomShellList.Remove(cmds);

                        AppConfig.Instance.SaveConfig(2);
                    }
                }
                catch { }
            }
        }

19 View Source File : ConditionTaskForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button1_Click(object sender, EventArgs e)
        {
            // 新增
            string name = shell_name.Text;
            string code = shell.Text;

            if (string.IsNullOrWhiteSpace(name))
            {
                MessageBox.Show(this, "请输入指令名称");
                shell_name.Focus();
            }
            else if (string.IsNullOrWhiteSpace(code))
            {
                MessageBox.Show(this, "请输入指令脚本(Shell)");
                shell.Focus();
            }
            else
            {
                JObject obj = new JObject();
                obj.Add("name", name);
                obj.Add("code", code);
                AddTaskItem(obj);

                shell.Text = "";
                shell_name.Text = "";
            }
        }

19 View Source File : ConditionTaskForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button2_Click(object sender, EventArgs e)
        {
            string name = task_name.Text;
            int count = customShellListView.Items.Count;

            Object item1 = scb_condition1.SelectedItem;
            Object item2 = scb_condition2.SelectedItem;
            Object item3 = scb_condition3.SelectedItem;

            if (string.IsNullOrWhiteSpace(name))
            {
                MessageBox.Show(this, "请输入任务名称");
                task_name.Focus();
            }
            else if (item1 == null)
            {
                MessageBox.Show(this, "请至少选择一个条件");
            }
            else if (count == 0)
            {
                MessageBox.Show(this, "请添加任务指令脚本(Shell)");
                shell_name.Focus();
            }
            else
            {
                string condition = "";
                ConditionItem ci1 = (ConditionItem)item1;
                condition += gereplacedemUuid(ci1) + "," + (scb_status1.SelectedIndex == 1 ? "Y" : "N");
                if(item2 != null){
                    ConditionItem ci2 = (ConditionItem)item2;
                    condition += gereplacedemCondi(1) + gereplacedemUuid(ci2) + "," + (scb_status2.SelectedIndex == 1 ? "Y" : "N");

                    if (item3 != null)
                    {
                        ConditionItem ci3 = (ConditionItem)item2;
                        condition += gereplacedemCondi(2) + gereplacedemUuid(ci3) + "," + (scb_status3.SelectedIndex == 1 ? "Y" : "N");
                    }
                }
                
                ListView.ListViewItemCollection coll = customShellListView.Items;
                if (null == cmdShell)
                {
                    cmdShell = new CmdShell();
                    cmdShell.Uuid = Guid.NewGuid().ToString("N");
                }
                JObject obj = null;
                JArray list = new JArray();
                List<TaskShell> shellList = new List<TaskShell>();
                TaskShell task = null;
                cmdShell.Name = name;
                cmdShell.TaskType = TaskType.Condition;
                cmdShell.Condition = condition;
                cmdShell.Type = "条件任务";
                foreach(ListViewItem item in coll){
                    obj = (JObject)item.Tag;
                    task = new TaskShell();
                    task.Uuid = Guid.NewGuid().ToString("N");
                    task.Shell = obj["code"].ToString();
                    task.Name = obj["name"].ToString();
                    shellList.Add(task);
                }
                cmdShell.ShellList = shellList;

                if (null != this.callback)
                {
                    this.callback(cmdShell);
                }

                this.Close();
            }
        }

19 View Source File : LockForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button4_Click(object sender, EventArgs e)
        {
            // 锁定
            string pwd = stb_pwd.Text;
            if (string.IsNullOrWhiteSpace(pwd))
            {
                MessageBox.Show(this, "请输入解锁密码,并牢记");
            }
            else
            {
                lockPwd = pwd;
                stb_pwd.Text = "";
                
                Program.MAIN.Lock();
            }
        }

19 View Source File : NginxMonitorForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (projects.SelectedItems.Count > 0)
            {
                try
                {
                    ListViewItem item = projects.SelectedItems[0];
                    DialogResult dr = MessageBox.Show(this, "您确定要删除此项吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if(dr == System.Windows.Forms.DialogResult.OK){
                        projects.Items.Remove(item);
                    }
                }
                catch { }  
            }
        }

19 View Source File : CustomShellForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button1_Click(object sender, EventArgs e)
        {
            string name = stb_name.Text;
            string cmdstr = cmd.Text;
            if(string.IsNullOrWhiteSpace(name)){
                MessageBox.Show(this, "请定义一个名称");
                return;
            }
            if (string.IsNullOrWhiteSpace(cmdstr))
            {
                MessageBox.Show(this, "请输入要执行的命令");
                return;
            }
            List<TaskShell> cmdList = new List<TaskShell>();
            string[] cmds = cmdstr.Split('\n');
            TaskShell task = null;
            foreach(string c in cmds){
                if (!string.IsNullOrWhiteSpace(c.Trim()))
                {
                    task = new TaskShell();
                    task.Uuid = Guid.NewGuid().ToString("N");
                    task.Name = "";
                    task.Shell = c.Trim();
                    cmdList.Add(task);
                }                
            }
            bool isnew = false;
            if(shell == null){
                shell = new CmdShell();
                shell.Uuid = Guid.NewGuid().ToString("N");
                shell.Target = uuid;
                isnew = true;
            }            
            shell.Name = name;
            shell.Type = "自定义脚本";
            shell.TaskType = TaskType.Default;
            shell.ShellList = cmdList;
            if (isnew)
            {
                config.CustomShellList.Add(shell);
            }

            AppConfig.Instance.SaveConfig(2);

            this.Close();
        }

19 View Source File : TimedTaskForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button1_Click(object sender, EventArgs e)
        {
            // 新增
            string timestr = "";
            // 1、获取执行周期
            int index = scb_cycle.SelectedIndex;
            timestr += index + "|";
            // 2、获取执行日期,除了每天周期不需要知道日期,其他都需要知道日期
            string rq = "";
            if(index == 0){// 一次
                rq = date.Value.ToString("yyyy-MM-dd");
            }
            else if (index == 1)
            { 
                // 每天
                rq = "";       
            }
            else if(index == 2)
            {
                // 每周
                rq += (week1.Checked ? ",1" : "");
                rq += (week2.Checked ? ",2" : "");
                rq += (week3.Checked ? ",3" : "");
                rq += (week4.Checked ? ",4" : "");
                rq += (week5.Checked ? ",5" : "");
                rq += (week6.Checked ? ",6" : "");
                rq += (week0.Checked ? ",7" : "");
                if (!string.IsNullOrWhiteSpace(rq))
                {
                    rq = rq.Substring(1);
                }
            }
            else if (index == 3)
            {
                // 每月
                rq = date.Value.ToString("dd");
            }
            else if (index == 4)
            {
                // 每年
                rq = date.Value.ToString("MM-dd");
            }
            timestr += rq + "|";
            // 3、获取执行时间
            timestr += time.Value.ToString("HH:mm:ss");

            string name = shell_name.Text;
            string code = shell.Text;

            if (string.IsNullOrWhiteSpace(name))
            {
                MessageBox.Show(this, "请输入指令名称");
                shell_name.Focus();
            }
            else if (string.IsNullOrWhiteSpace(code))
            {
                MessageBox.Show(this, "请输入指令脚本(Shell)");
                shell.Focus();
            }
            else
            {
                JObject obj = new JObject();
                obj.Add("time", timestr);
                obj.Add("name", name);
                obj.Add("code", code);
                AddTaskItem(obj);

                shell.Text = "";
                shell_name.Text = "";
            }
        }

19 View Source File : TimedTaskForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button2_Click(object sender, EventArgs e)
        {
            string name = task_name.Text;
            int count = customShellListView.Items.Count;
            if (string.IsNullOrWhiteSpace(name))
            {
                MessageBox.Show(this, "请输入任务名称");
                task_name.Focus();
            }
            else if (count == 0)
            {
                MessageBox.Show(this, "请添加任务指令脚本(Shell)");
                shell_name.Focus();
            }
            else
            {
                ListView.ListViewItemCollection coll = customShellListView.Items;
                if (null == cmdShell)
                {
                    cmdShell = new CmdShell();
                    cmdShell.Type = "定时任务";
                    cmdShell.TaskType = TaskType.Timed;
                }                
                cmdShell.Name = name;
                
                JObject obj = null;
                JArray list = new JArray();
                List<TaskShell> shellList = new List<TaskShell>();
                TaskShell task = null;
                
                foreach(ListViewItem item in coll){
                    obj = (JObject)item.Tag;
                    task = new TaskShell();
                    task.Uuid = Guid.NewGuid().ToString("N");
                    task.DateTime = obj["time"].ToString();
                    task.Shell = obj["code"].ToString();
                    task.Name = obj["name"].ToString();
                    shellList.Add(task);
                }
                cmdShell.ShellList = shellList;

                if (null != this.callback)
                {
                    this.callback(cmdShell);
                }

                this.Close();
            }
        }

19 View Source File : SftpForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void RunLocalToRemote() {
            getTransferItem("L2R", (item) => {
                if (item != null)
                {
                    transfering = true;
                    try
                    {
                        if (RemoteExist(item.RemotePath, item.Name))
                        {
                            this.BeginInvoke((MethodInvoker)delegate()
                            {
                                DialogResult dr = MessageBox.Show(this, item.RemotePath + "已存在,是否覆盖?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                                if (dr == System.Windows.Forms.DialogResult.Yes)
                                {
                                    WriteLog("L2R", item.Id, item.LocalPath, item.RemotePath);
                                    SftpProgressMonitor monitor = rightForm.TransfersToRemote(item.Id, item.LocalPath, item.RemotePath, ChannelSftp.OVERWRITE, new ProgressDelegate(TransfersFileProgress), new TransfersEndDelegate(TransfersFileEnd));
                                }
                                else
                                {
                                    ChangeTransferItemStatus("L2R", item.Id, TransferStatus.Cancel);
                                }
                            });
                        }
                        else
                        {
                            createRemoteDir(item.RemotePath, () =>
                            {
                                WriteLog("L2R", item.Id, item.LocalPath, item.RemotePath);
                                SftpProgressMonitor monitor = rightForm.TransfersToRemote(item.Id, item.LocalPath, item.RemotePath, ChannelSftp.OVERWRITE, new ProgressDelegate(TransfersFileProgress), new TransfersEndDelegate(TransfersFileEnd));
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error("传输文件的到服务器时异常:" + ex.Message);
                        ChangeTransferItemStatus("L2R", item.Id, TransferStatus.Failed);
                    }
                }
                else
                {
                    localToRemoteRun = false;
                }
            });            
        }

19 View Source File : SftpWinForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void newFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InputForm form = new InputForm("请输入文件夹名称", "", new InputForm.FormResult((name) =>
            {
                if (!string.IsNullOrWhiteSpace(name))
                {
                    DirectoryInfo dire = new DirectoryInfo(getCurrDir() + name);
                    if(!dire.Exists){
                        dire.Create();
                    }
                    else
                    {
                        MessageBox.Show(this, "目录已存在");
                    }

                    ThreadPool.QueueUserWorkItem((a) =>
                    {
                        Thread.Sleep(500);
                        RefreshFiles();
                    });
                }
                else
                {
                    MessageBox.Show(this, "名称不能为空");
                }
            }));
            form.ShowDialog(this);
        }

19 View Source File : SftpForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void toolStripButton7_Click(object sender, EventArgs e)
        {
            string host = text_host.Text;
            string username = text_username.Text;
            string preplaced = text_preplaced.Text;
            string port = text_port.Text;

            IPAddress ip;
            if (IPAddress.TryParse(host, out ip))
            {
                if(string.IsNullOrWhiteSpace(username)){
                    MessageBox.Show(this, "请输入用户名");
                }
                else if (string.IsNullOrWhiteSpace(preplaced))
                {
                    MessageBox.Show(this, "请输入密码");
                }
                else if (string.IsNullOrWhiteSpace(port))
                {
                    MessageBox.Show(this, "请输入端口号");
                }
                else
                {
                    user.Host = host;
                    user.UserName = username;
                    user.Preplacedword = YSEncrypt.EncryptA(preplaced, KeysUtil.PreplacedKey);
                    user.Port = Convert.ToInt32(port);

                    LoadRightForm(user);
                }
            }
            else
            {
                MessageBox.Show(this, "Host地址不正确");
            }
        }

19 View Source File : CentralServerConfigForm.cs
License : Apache License 2.0
Project Creator : 214175590

private bool Validate(ListViewItem item, string content)
        {
            bool result = true;
            YmlFile file = (YmlFile)item.Tag;
            YmlError error = YmlFormatUtil.ValidateYml(content);
            if (error != null)
            {
                try
                {
                    if (tabControl1.SelectedIndex == 1)
                    {
                        ymlEditor.SelectionStart = error.index - 1;
                        ymlEditor.ScrollToCaret();
                        ymlEditor.Select(error.index, 0);
                        ymlEditor.Focus();
                    }
                }
                catch { }

                MessageBox.Show(this, error.msg);
                file.correct = false;
                item.ImageIndex = 3;

                result = false;
            }
            else
            {
                if (file.status == YmlFileState.NoModif)
                {
                    item.ImageIndex = 1;
                }
                else if (file.status == YmlFileState.Modif)
                {
                    item.ImageIndex = 2;
                }
                else if (file.status == YmlFileState.NoAsync)
                {
                    item.ImageIndex = 0;
                }
            }
            return result;
        }

19 View Source File : CentralServerConfigForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void btn_new_Click(object sender, EventArgs e)
        {
            string oldName = "";
            string msg = "请输入文件名称(不包含.yml后缀)";
            InputForm form = new InputForm(msg, oldName, new InputForm.FormResult((newName) =>
            {
                if (oldName != newName)
                {
                    oldName = newName + ".yml";
                    string path = cfgDir + "/" + oldName;
                    YSTools.YSFile.writeFileByString(path, "#.yml File Create By AMShell - " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                    listView1.Items.Add(new ListViewItem()
                    {
                        Text = oldName,
                        ImageIndex = 0,
                        Tag = new YmlFile()
                        {
                            remotePath = remoteCfgPath + "/",
                            remoteName = oldName,
                            localName = oldName,
                            localPath = cfgDir + "/",
                            status = YmlFileState.NoAsync,
                            correct = true
                        }
                    });
                }
                else
                {
                    MessageBox.Show(this, "文件名称不能为空");
                }
            }));
            form.ShowDialog(this);
        }

19 View Source File : IceDeployVersionForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void timer1_Tick(object sender, EventArgs e)
        {
            if (run)
            {
                if(step == 0){
                    gifBox1.Visible = true;
                    btn_start.Enabled = false;
                    btn_cancel.Enabled = false;
                    pb_state1.BackgroundImage = Properties.Resources.Circle_72px1;
                    l_state1.BackColor = backColor1;

                    if (checkBox2.Checked)
                    {
                        // 1、mvn clean
                        step = 1;
                        MvnClean();
                    }
                    else
                    {
                        step = 3;
                    }                                       
                } else if(step == 2){
                    // 2、mvn package 打包
                    MvnPackage();
                }
                else if (step == 3)
                {
                    // 3、上传war包
                    if (checkBox1.Checked)
                    {
                        UploadWar();
                    }
                    else
                    {
                        step = 4;
                    }
                }
                else if (step == 4)
                {
                    // 4、更新配置
                    if (checkBox1.Checked)
                    {
                        pb_state1.BackgroundImage = Properties.Resources.Circle_72px2;
                        l_state1.BackColor = backColor2;
                        line_state1.BackColor = backColor2;
                        pb_state2.BackgroundImage = Properties.Resources.Circle_72px1;
                        l_state2.BackColor = backColor1;

                        UpdateConfig();
                    }
                    else
                    {
                        step = 5;
                    }
                }
                else if (step == 5)
                {
                    // 5、重启服务

                    pb_state1.BackgroundImage = Properties.Resources.Circle_72px2;
                    l_state1.BackColor = backColor2;

                    line_state1.BackColor = backColor2;
                    pb_state2.BackgroundImage = Properties.Resources.Circle_72px2;
                    l_state2.BackColor = backColor2;

                    line_state2.BackColor = backColor2;
                    pb_state3.BackgroundImage = Properties.Resources.Circle_72px1;
                    l_state3.BackColor = backColor1;

                    RestartService();
                }
                else if (step == 6)
                {
                    // 6、完成
                    pb_state1.BackgroundImage = Properties.Resources.Circle_72px2;
                    l_state1.BackColor = backColor2;

                    line_state1.BackColor = backColor2;
                    pb_state2.BackgroundImage = Properties.Resources.Circle_72px2;
                    l_state2.BackColor = backColor2;

                    line_state2.BackColor = backColor2;
                    pb_state3.BackgroundImage = Properties.Resources.Circle_72px2;
                    l_state3.BackColor = backColor2;

                    line_state3.BackColor = backColor2;
                    pb_state4.BackgroundImage = Properties.Resources.Circle_72px2;
                    l_state4.BackColor = backColor2;

                    run = false;
                    MessageBox.Show(this, "部署完成,正在启动服务...");                    
                }
            }
            else
            {
                timer1.Stop();
                btn_start.Text = "重置状态";
                btn_start.Enabled = true;
                btn_cancel.Enabled = true;
                gifBox1.Visible = false;
            }
        }

19 View Source File : IceDeployVersionForm.cs
License : Apache License 2.0
Project Creator : 214175590

public void MvnClean()
        {
            try
            {
                string path = stb_local_pdir.Text;
                String cmd = "cd " + path + " & mvn clean";
                CmdResult result = Command.run(cmd);
                step = 2;
            }
            catch (Exception ex)
            {
                errorLabel.Text = "mvn clean 异常:" + ex.Message;
                run = false;
                MessageBox.Show(this, errorLabel.Text);
            }            
        }

19 View Source File : IceDeployVersionForm.cs
License : Apache License 2.0
Project Creator : 214175590

public void MvnPackage()
        {
            try
            {
                string path = stb_local_pdir.Text;
                DirectoryInfo dire = new DirectoryInfo(path);
                String cmd = string.Format("cd {0} & mvn package --settings {1} -DskipTests", dire.Parent.FullName, stb_maven_xml.Text);
                CmdResult result = Command.run(cmd);
                if (result.isFailed())
                {
                    errorLabel.Text = "打包失败:" + result.result;
                    run = false;
                    MessageBox.Show(this, errorLabel.Text);
                }
                else if (result.isSuccess())
                {
                    step = 3;
                }
            }
            catch (Exception ex)
            {
                errorLabel.Text = "mvn package 异常:" + ex.Message;
                run = false;
                MessageBox.Show(this, errorLabel.Text);
            }
        }

19 View Source File : IceDeployVersionForm.cs
License : Apache License 2.0
Project Creator : 214175590

public void UploadWar()
        {
            try
            {
                string local_pdir = stb_local_pdir.Text;
                string remote_pdir = stb_remote_pdir.Text;
                string targetDir = Utils.PathEndAddSlash(Utils.PathWinToLinux(local_pdir)) + "target/";
                DirectoryInfo dire = new DirectoryInfo(targetDir);
                FileInfo warfile = null;
                if(dire.Exists){
                    FileInfo[] files = dire.GetFiles();
                    foreach(FileInfo file in files){
                        if(file.Extension == ".war"){
                            warfile = file;
                            break;
                        }
                    }
                }
                if (null != warfile)
                {
                    string localPath = warfile.FullName;
                    string remotePath = Utils.PathEndAddSlash(remote_pdir) + "package/" + warfile.Name;

                    monitorForm.getSftp().put(localPath, remotePath, ChannelSftp.OVERWRITE);

                    step = 4;
                }
                else
                {
                    errorLabel.Text = "war上传失败:war包不存在,可能是打包失败";
                    run = false;
                    MessageBox.Show(this, errorLabel.Text);
                }   
            }
            catch (Exception ex)
            {
                errorLabel.Text = "Upload .War 异常:" + ex.Message;
                run = false;
                MessageBox.Show(this, errorLabel.Text);
            }
        }

19 View Source File : IceDeployVersionForm.cs
License : Apache License 2.0
Project Creator : 214175590

public void UpdateConfig()
        {
            try
            {
                string localXml = stb_icexml.Text;
                string remote_pdir = stb_remote_pdir.Text;
                string remoteXml = Utils.PathEndAddSlash(remote_pdir) + "config/" + ice.AppName + ".xml";

                monitorForm.getSftp().put(localXml, remoteXml, ChannelSftp.OVERWRITE);

                // 更新
                monitorForm.RunShell(Utils.PathEndAddSlash(remote_pdir) + "bin/admin.sh", false, true);
                monitorForm.GetShellResult(string.Format("application update config/{0}.xml", ice.AppName), (s) => {
                    monitorForm.RunShell("quit", false);

                    step = 5;
                }, true);
            }
            catch (Exception ex)
            {
                errorLabel.Text = string.Format("application update config/{0}.xml 异常:", ice.AppName) + ex.Message;
                run = false;
                MessageBox.Show(this, errorLabel.Text);
            }
        }

19 View Source File : IceDeployVersionForm.cs
License : Apache License 2.0
Project Creator : 214175590

public void RestartService()
        {
            try
            {
                string remote_pdir = stb_remote_pdir.Text;
                monitorForm.RunShell(Utils.PathEndAddSlash(remote_pdir) + "bin/admin.sh", false, true);
                monitorForm.RunShell("server stop " + ice.ServerName, false, true);
                monitorForm.RunShell("server start " + ice.ServerName, false, true);
                monitorForm.RunShell("quit", false, true);

                step = 6;
            }
            catch (Exception ex)
            {
                errorLabel.Text = string.Format("Restart Service 异常:", ice.AppName) + ex.Message;
                run = false;
                MessageBox.Show(this, errorLabel.Text);
            }
        }

19 View Source File : SftpForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void RunRemoteToLocal()
        {
            getTransferItem("R2L", (item) =>
            {
                if (item != null)
                {
                    transfering = true;
                    try
                    {
                        if (File.Exists(item.LocalPath))
                        {
                            this.BeginInvoke((MethodInvoker)delegate()
                            {
                                DialogResult dr = MessageBox.Show(this, item.LocalPath + "已存在,是否覆盖?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                                if (dr == System.Windows.Forms.DialogResult.Yes)
                                {
                                    WriteLog("R2L", item.Id, item.LocalPath, item.RemotePath);
                                    SftpProgressMonitor monitor = rightForm.TransfersToLocal(item.Id, item.LocalPath, item.RemotePath, ChannelSftp.OVERWRITE, new ProgressDelegate(TransfersFileProgress), new TransfersEndDelegate(TransfersFileEnd));
                                }
                                else
                                {
                                    ChangeTransferItemStatus("R2L", item.Id, TransferStatus.Cancel);
                                }
                            });
                        }
                        else
                        {
                            FileInfo file = new FileInfo(item.LocalPath);
                            if (!file.Directory.Exists)
                            {
                                Utils.createParentDir(file.Directory);
                            }
                            WriteLog("R2L", item.Id, item.LocalPath, item.RemotePath);
                            SftpProgressMonitor monitor = rightForm.TransfersToLocal(item.Id, item.LocalPath, item.RemotePath, ChannelSftp.OVERWRITE, new ProgressDelegate(TransfersFileProgress), new TransfersEndDelegate(TransfersFileEnd));
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error("传输文件的到服务器时异常:" + ex.Message, ex);
                        ChangeTransferItemStatus("R2L", item.Id, TransferStatus.Failed);
                    }
                }
                else
                {
                    remoteToLocalRun = false;
                }
            });
        }

19 View Source File : SftpLinuxForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void newFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InputForm form = new InputForm("请输入文件夹名称", "", new InputForm.FormResult((name) => {
                if(!string.IsNullOrWhiteSpace(name)){

                    SendShell("mkdir -p " + getCurrDir() + Utils.getLinuxName(name));

                    ThreadPool.QueueUserWorkItem((a) =>
                    {
                        Thread.Sleep(500);
                        RefreshFiles();
                    });
                }
                else
                {
                    MessageBox.Show(this, "名称不能为空");
                }                
            }));
            form.ShowDialog(this);
        }

19 View Source File : IceDeployVersionForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button1_Click(object sender, EventArgs e)
        {
            string name = btn_start.Text;
            if (name == "重置状态")
            {
                btn_start.Text = "开始部署";
                errorLabel.Text = "";
                pb_state1.BackgroundImage = Properties.Resources.Circle_72px0;
                l_state1.BackColor = backColor0;
                line_state1.BackColor = backColor0;
                pb_state2.BackgroundImage = Properties.Resources.Circle_72px0;
                l_state2.BackColor = backColor0;
                line_state2.BackColor = backColor0;
                pb_state3.BackgroundImage = Properties.Resources.Circle_72px0;
                l_state3.BackColor = backColor0;
                line_state3.BackColor = backColor0;
                pb_state4.BackgroundImage = Properties.Resources.Circle_72px0;
                l_state4.BackColor = backColor0;
                return;
            }

            // 开始部署
            string local_pdir = stb_local_pdir.Text;
            string xml = stb_icexml.Text;
            string remote_pdir = stb_remote_pdir.Text;
            string mvnxml = stb_maven_xml.Text;
            if (string.IsNullOrWhiteSpace(local_pdir))
            {
                MessageBox.Show(this, "请选择本地代码目录");
                return;
            }
            if (!Directory.Exists(local_pdir))
            {
                MessageBox.Show(this, "本地代码目录不存在,请检查");
                return;
            }
            if (checkBox1.Checked && string.IsNullOrWhiteSpace(local_pdir))
            {
                MessageBox.Show(this, "请选择ice接口服务配置文件(" + ice.AppName + ".xml)");
                return;
            }
            if (string.IsNullOrWhiteSpace(remote_pdir))
            {
                MessageBox.Show(this, "请输入服务器ICE项目目录");
                return;
            }
            if (checkBox2.Checked && string.IsNullOrWhiteSpace(mvnxml))
            {
                MessageBox.Show(this, "自动打包需要配置Maven环境变量,并指定settings.xml");
                return;
            }

            if (ice.Project == null)
            {
                ice.Project = new IceProjectAttr();
            }
            ice.Project.LocalCodePath = local_pdir;
            ice.Project.LocalIceXmlPath = xml;
            ice.Project.MavenSetting = mvnxml;
            AppConfig.Instance.SaveConfig(2);

            // 开始
            run = true;
            timer1.Start();
        }

19 View Source File : IceDeployVersionForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void button1_Click(object sender, EventArgs e)
        {
            string name = btn_start.Text;
            if (name == "重置状态")
            {
                btn_start.Text = "开始部署";
                errorLabel.Text = "";
                pb_state1.BackgroundImage = Properties.Resources.Circle_72px0;
                l_state1.BackColor = backColor0;
                line_state1.BackColor = backColor0;
                pb_state2.BackgroundImage = Properties.Resources.Circle_72px0;
                l_state2.BackColor = backColor0;
                line_state2.BackColor = backColor0;
                pb_state3.BackgroundImage = Properties.Resources.Circle_72px0;
                l_state3.BackColor = backColor0;
                line_state3.BackColor = backColor0;
                pb_state4.BackgroundImage = Properties.Resources.Circle_72px0;
                l_state4.BackColor = backColor0;
                return;
            }

            // 开始部署
            string local_pdir = stb_local_pdir.Text;
            string xml = stb_icexml.Text;
            string remote_pdir = stb_remote_pdir.Text;
            string mvnxml = stb_maven_xml.Text;
            if (string.IsNullOrWhiteSpace(local_pdir))
            {
                MessageBox.Show(this, "请选择本地代码目录");
                return;
            }
            if (!Directory.Exists(local_pdir))
            {
                MessageBox.Show(this, "本地代码目录不存在,请检查");
                return;
            }
            if (checkBox1.Checked && string.IsNullOrWhiteSpace(local_pdir))
            {
                MessageBox.Show(this, "请选择ice接口服务配置文件(" + ice.AppName + ".xml)");
                return;
            }
            if (string.IsNullOrWhiteSpace(remote_pdir))
            {
                MessageBox.Show(this, "请输入服务器ICE项目目录");
                return;
            }
            if (checkBox2.Checked && string.IsNullOrWhiteSpace(mvnxml))
            {
                MessageBox.Show(this, "自动打包需要配置Maven环境变量,并指定settings.xml");
                return;
            }

            if (ice.Project == null)
            {
                ice.Project = new IceProjectAttr();
            }
            ice.Project.LocalCodePath = local_pdir;
            ice.Project.LocalIceXmlPath = xml;
            ice.Project.MavenSetting = mvnxml;
            AppConfig.Instance.SaveConfig(2);

            // 开始
            run = true;
            timer1.Start();
        }

19 View Source File : FrmStartPage.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private void Read(Manga m)
        {
            if (!File.Exists(m.mangaDirectory.FullName + "\\downloading"))
            {
                if ((bool)Properties.Settings.Default["doublePageReader"] == false)
                {
                    Logger.Log("Opening Reader to " + m.name);
                    FrmReader reader = new FrmReader();
                    reader.Show();
                    reader.StartUp(m, this);
                }
                else
                {
                    Logger.Log("Opening DPReader to " + m.name);
                    FrmDoublePageReader reader = new FrmDoublePageReader();
                    reader.Show();
                    reader.StartUp(m, this);
                }
            }
            else
            {
                MessageBox.Show("Cannot read '" + m.name + "' because it is currently being downloaded");
            }
        }

19 View Source File : FrmLauncher.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private void BtnRead_Click(object sender, EventArgs e)
        {
            replacedle selected = GetSelected();
            if (selected != null)
            {
                if (selected.IsDownloading())
                {
                    MessageBox.Show(ll.Msg_dlwait);
                    return;
                }

                if (SettingsHelper.UseDoubleReader)
                    new FrmDoublePageReader(selected).Show();
                else
                    new FrmSinglePageReader(selected).Show();
            }
            else
                MessageBox.Show(ll.Msg_notfound);

        }

19 View Source File : FrmLauncher.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private replacedle GetSelected()
        {
            replacedle selected = null;
            if (tabControl1.SelectedTab == tabpageManga)
            {
                string selectedText = lstManga.SelectedItem.ToString();
                string name = selectedText.Substring(0, selectedText.LastIndexOf('»')).Trim();

                foreach (Manga m in WFClient.dbm.GetMangaPopulation())
                {
                    if (m.GetUserreplacedle().StartsWith(name))
                    {
                        selected = m;
                        break;
                    }
                }
            }
            else // Hentai
            {
                string selectedText = lstHentai.SelectedItem.ToString();
                string name = selectedText.Substring(0, selectedText.LastIndexOf('»')).Trim();

                foreach (Hentai h in WFClient.dbm.GetHentaiPopulation())
                {
                    if (h.GetUserreplacedle().StartsWith(name))
                    {
                        selected = h;
                        break;
                    }
                }
            }

            if (selected != null)
            {
                return selected;
            }
            else
                MessageBox.Show(ll.Msg_notfound);

            return null;
        }

19 View Source File : FrmLauncher.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private void UpdateMangas()
        {
            List<Chapter> updates = new List<Chapter>();
            foreach (Manga m in WFClient.dbm.GetMangaPopulation())
            {
                Chapter[] u = m.GetUpdates();
                updates.AddRange(u);

                if (m is MangaDex)
                {
                    foreach (Chapter c in u)
                    {
                        WFClient.dlm.AddToQueue(new MangaDexDownload(c));
                    }
                }
                else if (m is KissManga)
                {
                    foreach (Chapter c in u)
                    {
                        WFClient.dlm.AddToQueue(new KissMangaDownload(c));
                    }
                } else
                {
                    MessageBox.Show(ll.Msg_invalid);
                }
            }
            if (updates.Count > 0)
            {
                MessageBox.Show(ll.Msg_downloading1 + updates.Count + ll.Msg_downloading2);
                WFClient.dlm.DownloadNext();
            }
            else
            {
                MessageBox.Show(ll.Msg_uptodate);
            }
        }

19 View Source File : FrmSettings.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private void BtnSave_Click(object sender, EventArgs e)
        {
            SettingsHelper.UseDoubleReader = rbDouble.Checked;
            SettingsHelper.CheckForUpdates = chkUpdates.Checked;

            if (!txtDir.Text.Equals((string)Properties.Settings.Default["approot"]))
            {
                DialogResult dr = MessageBox.Show(sl.Msg_saveloc, "Confirmation", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    if (!txtDir.Text.Equals(""))
                    {
                        Properties.Settings.Default["approot"] = txtDir.Text;
                        Properties.Settings.Default.Save();
                    } else
                    {
                        Properties.Settings.Default["approot"] = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MikuReader2");
                        Properties.Settings.Default.Save();
                    }                    
                } else
                {
                    txtDir.Text = (string)Properties.Settings.Default["approot"];
                }
            }

            if (!cmboLanguage.SelectedItem.ToString().Equals(Properties.Settings.Default["language"].ToString()))
            {
                DialogResult dr = MessageBox.Show(sl.Msg_lang, "Confirmation", MessageBoxButtons.OK);
                Properties.Settings.Default["language"] = cmboLanguage.SelectedItem.ToString();
                Properties.Settings.Default.Save();
            }

            SettingsHelper.Save();
            WFClient.logger.Log("Settings saved.");
            MessageBox.Show(sl.Msg_saved);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : ab4d

private static void Main()
        {
			RenderForm form = new RenderForm("OculusWrap SharpDX demo");

            IntPtr sessionPtr;
			InputLayout				inputLayout					= null;
			Buffer					contantBuffer				= null;
			Buffer					vertexBuffer				= null;
			ShaderSignature			shaderSignature				= null;
			PixelShader				pixelShader					= null;
			ShaderBytecode			pixelShaderByteCode			= null;
			VertexShader			vertexShader				= null;
			ShaderBytecode			vertexShaderByteCode		= null;
			Texture2D				mirrorTextureD3D			= null;
			EyeTexture[]			eyeTextures					= null;
			DeviceContext			immediateContext			= null;
			DepthStencilState		depthStencilState			= null;
			DepthStencilView		depthStencilView			= null;
			Texture2D				depthBuffer					= null;
			RenderTargetView		backBufferRenderTargetView	= null;
			Texture2D				backBuffer					= null;
			SharpDX.DXGI.SwapChain	swapChain					= null;
			Factory					factory						= null;
			MirrorTexture			mirrorTexture				= null;
			Guid					textureInterfaceId			= new Guid("6f15aaf2-d208-4e89-9ab4-489535d34f9c"); // Interface ID of the Direct3D Texture2D interface.

            Result result;

            OvrWrap OVR = OvrWrap.Create();

            // Define initialization parameters with debug flag.
            InitParams initializationParameters = new InitParams();
			initializationParameters.Flags = InitFlags.Debug | InitFlags.RequestVersion;
            initializationParameters.RequestedMinorVersion = 17;

            // Initialize the Oculus runtime.
            string errorReason = null;
            try
            {
                result = OVR.Initialize(initializationParameters);

                if (result < Result.Success)
                    errorReason = result.ToString();
            }
            catch (Exception ex)
            {
                errorReason = ex.Message;
            }

			if (errorReason != null)
			{
				MessageBox.Show("Failed to initialize the Oculus runtime library:\r\n" + errorReason, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

            // Use the head mounted display.
            sessionPtr = IntPtr.Zero;
            var graphicsLuid = new GraphicsLuid();
            result = OVR.Create(ref sessionPtr, ref graphicsLuid);
            if (result < Result.Success)
            { 
				MessageBox.Show("The HMD is not enabled: " + result.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

            var hmdDesc = OVR.GetHmdDesc(sessionPtr);


            try
			{
				// Create a set of layers to submit.
				eyeTextures = new EyeTexture[2];

				// Create DirectX drawing device.
				SharpDX.Direct3D11.Device device = new Device(SharpDX.Direct3D.DriverType.Hardware, DeviceCreationFlags.Debug);

                // Create DirectX Graphics Interface factory, used to create the swap chain.
                factory = new SharpDX.DXGI.Factory4();

				immediateContext = device.ImmediateContext;

				// Define the properties of the swap chain.
				SwapChainDescription swapChainDescription						= new SwapChainDescription();
				swapChainDescription.BufferCount								= 1;
				swapChainDescription.IsWindowed									= true;
				swapChainDescription.OutputHandle								= form.Handle;
				swapChainDescription.SampleDescription							= new SampleDescription(1, 0);
				swapChainDescription.Usage										= Usage.RenderTargetOutput | Usage.ShaderInput;
				swapChainDescription.SwapEffect									= SwapEffect.Sequential;
				swapChainDescription.Flags										= SwapChainFlags.AllowModeSwitch;
				swapChainDescription.ModeDescription.Width						= form.Width;
				swapChainDescription.ModeDescription.Height						= form.Height;
				swapChainDescription.ModeDescription.Format						= Format.R8G8B8A8_UNorm;
				swapChainDescription.ModeDescription.RefreshRate.Numerator		= 0;
				swapChainDescription.ModeDescription.RefreshRate.Denominator	= 1;

                // Create the swap chain.
                swapChain = new SwapChain(factory, device, swapChainDescription);

				// Retrieve the back buffer of the swap chain.
				backBuffer					= swapChain.GetBackBuffer<Texture2D>(0);	
				backBufferRenderTargetView	= new RenderTargetView(device, backBuffer);	

				// Create a depth buffer, using the same width and height as the back buffer.
				Texture2DDescription depthBufferDescription = new Texture2DDescription();
				depthBufferDescription.Format				= Format.D32_Float;
				depthBufferDescription.ArraySize			= 1;
				depthBufferDescription.MipLevels			= 1;
				depthBufferDescription.Width				= form.Width;
				depthBufferDescription.Height				= form.Height;
				depthBufferDescription.SampleDescription	= new SampleDescription(1, 0);
				depthBufferDescription.Usage				= ResourceUsage.Default;
				depthBufferDescription.BindFlags			= BindFlags.DepthStencil;
				depthBufferDescription.CpuAccessFlags		= CpuAccessFlags.None;
				depthBufferDescription.OptionFlags			= ResourceOptionFlags.None;

				// Define how the depth buffer will be used to filter out objects, based on their distance from the viewer.
				DepthStencilStateDescription depthStencilStateDescription	= new DepthStencilStateDescription();
				depthStencilStateDescription.IsDepthEnabled					= true;
				depthStencilStateDescription.DepthComparison				= Comparison.Less;
				depthStencilStateDescription.DepthWriteMask					= DepthWriteMask.Zero;

				// Create the depth buffer.
				depthBuffer		  = new Texture2D(device, depthBufferDescription);
				depthStencilView  = new DepthStencilView(device, depthBuffer);	
				depthStencilState = new DepthStencilState(device, depthStencilStateDescription);

				var viewport = new Viewport(0, 0, hmdDesc.Resolution.Width, hmdDesc.Resolution.Height, 0.0f, 1.0f);

				immediateContext.OutputMerger.SetDepthStencilState(depthStencilState);
				immediateContext.OutputMerger.SetRenderTargets(depthStencilView, backBufferRenderTargetView);
				immediateContext.Rasterizer.SetViewport(viewport);

				// Retrieve the DXGI device, in order to set the maximum frame latency.
				using(SharpDX.DXGI.Device1 dxgiDevice = device.QueryInterface<SharpDX.DXGI.Device1>())
				{
					dxgiDevice.MaximumFrameLatency = 1;
				}

			    var layerEyeFov = new LayerEyeFov();
                layerEyeFov.Header.Type = LayerType.EyeFov;
                layerEyeFov.Header.Flags = LayerFlags.None;

                for (int eyeIndex=0; eyeIndex<2; eyeIndex++)
				{
					EyeType eye = (EyeType)eyeIndex;
					var eyeTexture = new EyeTexture();
					eyeTextures[eyeIndex] = eyeTexture;

					// Retrieve size and position of the texture for the current eye.
					eyeTexture.FieldOfView				= hmdDesc.DefaultEyeFov[eyeIndex];
					eyeTexture.TextureSize				= OVR.GetFovTextureSize(sessionPtr, eye, hmdDesc.DefaultEyeFov[eyeIndex], 1.0f);
				    eyeTexture.RenderDescription        = OVR.GetRenderDesc(sessionPtr, eye, hmdDesc.DefaultEyeFov[eyeIndex]);
                    eyeTexture.HmdToEyeViewOffset		= eyeTexture.RenderDescription.HmdToEyePose.Position;
					eyeTexture.ViewportSize.Position	= new Vector2i(0, 0);
					eyeTexture.ViewportSize.Size		= eyeTexture.TextureSize;
					eyeTexture.Viewport					= new Viewport(0, 0, eyeTexture.TextureSize.Width, eyeTexture.TextureSize.Height, 0.0f, 1.0f);

					// Define a texture at the size recommended for the eye texture.
					eyeTexture.Texture2DDescription						= new Texture2DDescription();
					eyeTexture.Texture2DDescription.Width				= eyeTexture.TextureSize.Width;
					eyeTexture.Texture2DDescription.Height				= eyeTexture.TextureSize.Height;
					eyeTexture.Texture2DDescription.ArraySize			= 1;
					eyeTexture.Texture2DDescription.MipLevels			= 1;
					eyeTexture.Texture2DDescription.Format				= Format.R8G8B8A8_UNorm;
					eyeTexture.Texture2DDescription.SampleDescription	= new SampleDescription(1, 0);
					eyeTexture.Texture2DDescription.Usage				= ResourceUsage.Default;
					eyeTexture.Texture2DDescription.CpuAccessFlags		= CpuAccessFlags.None;
					eyeTexture.Texture2DDescription.BindFlags			= BindFlags.ShaderResource | BindFlags.RenderTarget;

					// Convert the SharpDX texture description to the Oculus texture swap chain description.
					TextureSwapChainDesc textureSwapChainDesc = SharpDXHelpers.CreateTextureSwapChainDescription(eyeTexture.Texture2DDescription);

                    // Create a texture swap chain, which will contain the textures to render to, for the current eye.
				    IntPtr textureSwapChainPtr;

                    result = OVR.CreateTextureSwapChainDX(sessionPtr, device.NativePointer, ref textureSwapChainDesc, out textureSwapChainPtr);
					WriteErrorDetails(OVR, result, "Failed to create swap chain.");

                    eyeTexture.SwapTextureSet = new TextureSwapChain(OVR, sessionPtr, textureSwapChainPtr);


                    // Retrieve the number of buffers of the created swap chain.
                    int textureSwapChainBufferCount;
					result = eyeTexture.SwapTextureSet.GetLength(out textureSwapChainBufferCount);
					WriteErrorDetails(OVR, result, "Failed to retrieve the number of buffers of the created swap chain.");

					// Create room for each DirectX texture in the SwapTextureSet.
					eyeTexture.Textures				= new Texture2D[textureSwapChainBufferCount];
					eyeTexture.RenderTargetViews	= new RenderTargetView[textureSwapChainBufferCount];

					// Create a texture 2D and a render target view, for each unmanaged texture contained in the SwapTextureSet.
					for (int textureIndex=0; textureIndex<textureSwapChainBufferCount; textureIndex++)
					{
						// Retrieve the Direct3D texture contained in the Oculus TextureSwapChainBuffer.
						IntPtr	swapChainTextureComPtr = IntPtr.Zero;
						result = eyeTexture.SwapTextureSet.GetBufferDX(textureIndex, textureInterfaceId, out swapChainTextureComPtr);
						WriteErrorDetails(OVR, result, "Failed to retrieve a texture from the created swap chain.");

						// Create a managed Texture2D, based on the unmanaged texture pointer.
						eyeTexture.Textures[textureIndex] = new Texture2D(swapChainTextureComPtr);

						// Create a render target view for the current Texture2D.
						eyeTexture.RenderTargetViews[textureIndex]	= new RenderTargetView(device, eyeTexture.Textures[textureIndex]);
					}

					// Define the depth buffer, at the size recommended for the eye texture.
					eyeTexture.DepthBufferDescription					= new Texture2DDescription();
					eyeTexture.DepthBufferDescription.Format			= Format.D32_Float;
					eyeTexture.DepthBufferDescription.Width				= eyeTexture.TextureSize.Width;
					eyeTexture.DepthBufferDescription.Height			= eyeTexture.TextureSize.Height;
					eyeTexture.DepthBufferDescription.ArraySize			= 1;
					eyeTexture.DepthBufferDescription.MipLevels			= 1;
					eyeTexture.DepthBufferDescription.SampleDescription	= new SampleDescription(1, 0);
					eyeTexture.DepthBufferDescription.Usage				= ResourceUsage.Default;
					eyeTexture.DepthBufferDescription.BindFlags			= BindFlags.DepthStencil;
					eyeTexture.DepthBufferDescription.CpuAccessFlags	= CpuAccessFlags.None;
					eyeTexture.DepthBufferDescription.OptionFlags		= ResourceOptionFlags.None;

					// Create the depth buffer.
					eyeTexture.DepthBuffer		= new Texture2D(device, eyeTexture.DepthBufferDescription);
					eyeTexture.DepthStencilView	= new DepthStencilView(device, eyeTexture.DepthBuffer);

					// Specify the texture to show on the HMD.
				    if (eyeIndex == 0)
				    {
				        layerEyeFov.ColorTextureLeft = eyeTexture.SwapTextureSet.TextureSwapChainPtr;
				        layerEyeFov.ViewportLeft.Position = new Vector2i(0, 0);
				        layerEyeFov.ViewportLeft.Size = eyeTexture.TextureSize;
				        layerEyeFov.FovLeft = eyeTexture.FieldOfView;
				    }
				    else
				    {
                        layerEyeFov.ColorTextureRight = eyeTexture.SwapTextureSet.TextureSwapChainPtr;
                        layerEyeFov.ViewportRight.Position = new Vector2i(0, 0);
                        layerEyeFov.ViewportRight.Size = eyeTexture.TextureSize;
                        layerEyeFov.FovRight = eyeTexture.FieldOfView;
                    }
				}

				MirrorTextureDesc mirrorTextureDescription	= new MirrorTextureDesc();
				mirrorTextureDescription.Format					= TextureFormat.R8G8B8A8_UNorm_SRgb;
				mirrorTextureDescription.Width					= form.Width;
				mirrorTextureDescription.Height					= form.Height;
				mirrorTextureDescription.MiscFlags				= TextureMiscFlags.None;

				// Create the texture used to display the rendered result on the computer monitor.
			    IntPtr mirrorTexturePtr;
                result = OVR.CreateMirrorTextureDX(sessionPtr, device.NativePointer, ref mirrorTextureDescription, out mirrorTexturePtr);
				WriteErrorDetails(OVR, result, "Failed to create mirror texture.");

                mirrorTexture = new MirrorTexture(OVR, sessionPtr, mirrorTexturePtr);


				// Retrieve the Direct3D texture contained in the Oculus MirrorTexture.
				IntPtr	mirrorTextureComPtr = IntPtr.Zero;
				result = mirrorTexture.GetBufferDX(textureInterfaceId, out mirrorTextureComPtr);
				WriteErrorDetails(OVR, result, "Failed to retrieve the texture from the created mirror texture buffer.");

				// Create a managed Texture2D, based on the unmanaged texture pointer.
				mirrorTextureD3D = new Texture2D(mirrorTextureComPtr);

				#region Vertex and pixel shader
				// Create vertex shader.
				vertexShaderByteCode	= ShaderBytecode.CompileFromFile("Shaders.fx", "VertexShaderPositionColor", "vs_4_0");
				vertexShader			= new VertexShader(device, vertexShaderByteCode);

				// Create pixel shader.
				pixelShaderByteCode		= ShaderBytecode.CompileFromFile("Shaders.fx", "PixelShaderPositionColor", "ps_4_0");
				pixelShader				= new PixelShader(device, pixelShaderByteCode);
            
				shaderSignature			= ShaderSignature.GetInputSignature(vertexShaderByteCode);

				// Specify that each vertex consists of a single vertex position and color.
				InputElement[] inputElements = new InputElement[]
				{
					new InputElement("POSITION",	0, Format.R32G32B32A32_Float, 0, 0),
					new InputElement("COLOR",		0, Format.R32G32B32A32_Float, 16, 0)
				};

				// Define an input layout to be preplaceded to the vertex shader.
				inputLayout = new InputLayout(device, shaderSignature, inputElements);

				// Create a vertex buffer, containing our 3D model.
				vertexBuffer = Buffer.Create(device, BindFlags.VertexBuffer, m_vertices);

				// Create a constant buffer, to contain our WorldViewProjection matrix, that will be preplaceded to the vertex shader.
				contantBuffer = new Buffer(device, Utilities.SizeOf<Matrix>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);

				// Setup the immediate context to use the shaders and model we defined.
				immediateContext.Inputreplacedembler.InputLayout			= inputLayout;
				immediateContext.Inputreplacedembler.PrimitiveTopology	= PrimitiveTopology.TriangleList;
				immediateContext.Inputreplacedembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, sizeof(float)*4*2, 0));
				immediateContext.VertexShader.SetConstantBuffer(0, contantBuffer);
				immediateContext.VertexShader.Set(vertexShader);
				immediateContext.PixelShader.Set(pixelShader);
				#endregion

				DateTime startTime = DateTime.Now;
				Vector3  position  = new Vector3(0, 0, -1);

				#region Render loop
				RenderLoop.Run(form, () =>
				{
					Vector3f[] hmdToEyeViewOffsets = {eyeTextures[0].HmdToEyeViewOffset, eyeTextures[1].HmdToEyeViewOffset};
					double displayMidpoint = OVR.GetPredictedDisplayTime(sessionPtr, 0);
					TrackingState trackingState = OVR.GetTrackingState(sessionPtr, displayMidpoint, true);
					Posef[] eyePoses = new Posef[2];
				
					// Calculate the position and orientation of each eye.
					OVR.CalcEyePoses(trackingState.HeadPose.ThePose, hmdToEyeViewOffsets, ref eyePoses);

					float timeSinceStart = (float)(DateTime.Now - startTime).TotalSeconds;

					for(int eyeIndex = 0; eyeIndex < 2; eyeIndex ++)
					{
						EyeType eye	= (EyeType)eyeIndex;
						EyeTexture eyeTexture = eyeTextures[eyeIndex];

                        if (eyeIndex == 0)
						    layerEyeFov.RenderPoseLeft = eyePoses[0];
                        else
                            layerEyeFov.RenderPoseRight = eyePoses[1];

                        // Update the render description at each frame, as the HmdToEyeOffset can change at runtime.
                        eyeTexture.RenderDescription = OVR.GetRenderDesc(sessionPtr, eye, hmdDesc.DefaultEyeFov[eyeIndex]);

						// Retrieve the index of the active texture
						int textureIndex;
				        result = eyeTexture.SwapTextureSet.GetCurrentIndex(out textureIndex);
						WriteErrorDetails(OVR, result, "Failed to retrieve texture swap chain current index.");

						immediateContext.OutputMerger.SetRenderTargets(eyeTexture.DepthStencilView, eyeTexture.RenderTargetViews[textureIndex]);
						immediateContext.ClearRenderTargetView(eyeTexture.RenderTargetViews[textureIndex], Color.Black);
						immediateContext.ClearDepthStencilView(eyeTexture.DepthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0);
						immediateContext.Rasterizer.SetViewport(eyeTexture.Viewport);

						// Retrieve the eye rotation quaternion and use it to calculate the LookAt direction and the LookUp direction.
						Quaternion rotationQuaternion = SharpDXHelpers.ToQuaternion(eyePoses[eyeIndex].Orientation);
						Matrix     rotationMatrix     = Matrix.RotationQuaternion(rotationQuaternion);
						Vector3    lookUp             = Vector3.Transform(new Vector3(0, -1, 0), rotationMatrix).ToVector3();
						Vector3    lookAt             = Vector3.Transform(new Vector3(0, 0, 1), rotationMatrix).ToVector3();

						Vector3    viewPosition       = position - eyePoses[eyeIndex].Position.ToVector3();

						Matrix world      = Matrix.Scaling(0.1f) * Matrix.RotationX(timeSinceStart/10f) * Matrix.RotationY(timeSinceStart*2/10f) * Matrix.RotationZ(timeSinceStart*3/10f);
                        Matrix viewMatrix = Matrix.LookAtLH(viewPosition, viewPosition+lookAt, lookUp); 

						Matrix projectionMatrix = OVR.Matrix4f_Projection(eyeTexture.FieldOfView, 0.1f, 100.0f, ProjectionModifier.LeftHanded).ToMatrix();
						projectionMatrix.Transpose();

						Matrix worldViewProjection = world * viewMatrix * projectionMatrix;
						worldViewProjection.Transpose();

						// Update the transformation matrix.
						immediateContext.UpdateSubresource(ref worldViewProjection, contantBuffer);

						// Draw the cube
						immediateContext.Draw(m_vertices.Length/2, 0);

						// Commits any pending changes to the TextureSwapChain, and advances its current index
						result = eyeTexture.SwapTextureSet.Commit();
						WriteErrorDetails(OVR, result, "Failed to commit the swap chain texture.");
					}

                    
                    result = OVR.SubmitFrame(sessionPtr, 0L, IntPtr.Zero, ref layerEyeFov);
					WriteErrorDetails(OVR, result, "Failed to submit the frame of the current layers.");

                    immediateContext.CopyResource(mirrorTextureD3D, backBuffer);
                    swapChain.Present(0, PresentFlags.None);
                });
				#endregion
			}
			finally
			{
				if(immediateContext != null)
				{
					immediateContext.ClearState();
					immediateContext.Flush();
				}

				// Release all resources
				Dispose(inputLayout);
				Dispose(contantBuffer);
				Dispose(vertexBuffer);
				Dispose(shaderSignature);
				Dispose(pixelShader);
				Dispose(pixelShaderByteCode);
				Dispose(vertexShader);
				Dispose(vertexShaderByteCode);
				Dispose(mirrorTextureD3D);
				Dispose(mirrorTexture);
				Dispose(eyeTextures[0]);
				Dispose(eyeTextures[1]);
				Dispose(immediateContext);
				Dispose(depthStencilState);
				Dispose(depthStencilView);
				Dispose(depthBuffer);
				Dispose(backBufferRenderTargetView);
				Dispose(backBuffer);
				Dispose(swapChain);
				Dispose(factory);

                // Disposing the device, before the hmd, will cause the hmd to fail when disposing.
                // Disposing the device, after the hmd, will cause the dispose of the device to fail.
                // It looks as if the hmd steals ownership of the device and destroys it, when it's shutting down.
                // device.Dispose();
                OVR.Destroy(sessionPtr);
			}
        }

19 View Source File : FrmCaptcha.cs
License : MIT License
Project Creator : ACBrNet

private void RefreshCaptcha()
		{
			var primaryTask = Task<Image>.Factory.StartNew(() => getCaptcha());
			primaryTask.ContinueWith(task =>
			{
				if (task.Result.IsNull()) return;

				captchaPictureBox.Image = task.Result;
				captchaTextBox.Text = string.Empty;
			}, CancellationToken.None, TaskContinuationOptions.NotOnCanceled | TaskContinuationOptions.NotOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());

			primaryTask.ContinueWith(task => MessageBox.Show(this, task.Exception.InnerExceptions.Select(x => x.Message).replacedtring()),
				CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());
		}

19 View Source File : FrmCaptcha.cs
License : MIT License
Project Creator : ACBrNet

private void enviarCaptchaButton_Click(object sender, EventArgs e)
		{
			if (captchaTextBox.Text.IsEmpty())
			{
				MessageBox.Show(this, @"Digite o captcha !");
				return;
			}

			Close();
		}

19 View Source File : LocationForm.cs
License : Microsoft Public License
Project Creator : achimismaili

private void DeactivateButton_Click(object sender, EventArgs e)
        {
            if ((_selectedFeatureLocations.Count == 0))
            {
                MessageBox.Show(Constants.Text.NOFEATURESELECTED);
                // logDateMsg(Constants.Text.NOFEATURESELECTED);
                return;
            }


            // make sure, only one type of feature scopes is selected
            var countWeb = 0;
            var countSiCo = 0;
            var countWebApp = 0;
            var countFarm = 0;

            foreach (FeatureLocation fl in _selectedFeatureLocations)
            {
                switch (fl.Feature.Scope)
                {
                    case SPFeatureScope.Web:
                        countWeb++;
                        break;
                    case SPFeatureScope.Site:
                        countSiCo++;
                        break;
                    case SPFeatureScope.WebApplication:
                        countWebApp++;
                        break;
                    case SPFeatureScope.Farm:
                        countFarm++;
                        break;
                    default:
                        // invalid? tbd error logging
                        break;
                }
            }

            // when multiplicating with 0, it results in 0, so when every combination results in 0, only 1 can be not zero

            if (countFarm * countWebApp == 0
                && countFarm * countSiCo == 0
                && countFarm * countWeb == 0
                && countWebApp * countSiCo == 0
                && countWebApp * countWeb == 0
                && countSiCo * countWeb == 0
                && countFarm + countWebApp + countSiCo + countWeb > 0 // sanity check ...
                )
            {
                foreach (FeatureParent l in _selectedFeatureLocations.Select(fl => fl.Location).Distinct())
                {
                    _parentForm.PromptAndActivateSelectedFeaturesAcrossSpecifiedScope(
                       _selectedFeatureLocations
                            .Where(fl => fl.Location.FullUrl.Equals(l.FullUrl, StringComparison.InvariantCultureIgnoreCase))
                            .Select(fl => fl.Feature).ToList(),
                       SPFeatureScope.WebApplication,
                       l,
                       FeatureActivator.Action.Deactivating
                       );
                }
            }
            else
            {
                MessageBox.Show("Canceled because of mixed or invalid scopes in selected features");
                // logDateMsg(Constants.Text.NOFEATURESELECTED);
                return;
            }



        }

19 View Source File : Program.cs
License : MIT License
Project Creator : Aeroblast

static void ReadBook(string bookPath)
        {
            try
            {
                epub = new EpubFile(bookPath);
            }
            catch (System.IO.IOException)
            {
                MessageBox.Show("该文件无法打开,可能已被其他程序打开:" + bookPath);
                return;
            }
            catch (EreplacedrrorException e)
            {

                MessageBox.Show("读取EPUB时发生错误:" + bookPath + "\n" + e.Message);
                return;
            }
            try
            {
                TocManage.Parse();
            }
            catch (EreplacedrrorException e)
            {
                Console.WriteLine(e.Message);
            }
            UserSettings.ReadSettings();
            var settings = new CefSettings();
            if (epub.language != "")
                settings.Locale = Util.TrimLanguageCode(epub.language);

            settings.RegisterScheme(new CefCustomScheme
            {
                SchemeName = "aeroepub",
                SchemeHandlerFactory = new AeroEpubSchemeHandlerFactory()
            });
            settings.CachePath = cachePath;
            Cef.Initialize(settings);
            Cef.EnableHighDPISupport();
            Application.Run(new EpubViewer());
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AgentRev

public void ErrMessage(Exception err)
        {
            MessageBox.Show("An unexpected error occured when attempting to access the game's process.\n\n" +
                            "If the FoV changer has already worked for you before, please try to delete '" + c_settingsFileName + "' located in " + settingsPath + "\n\n" +
                            "Otherwise, please try to run the changer as an administator. If that doesn't work, " +
                            "please contact me at [email protected], and be sure to include a screenshot of this error:\n\n" + err.Message,
                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AgentRev

private void TimerVerif_Tick(object sender, EventArgs e)
        {
            if (proc != null && mem != null && isRunning(false))
            {
                if (btnStartGame.Enabled) ToggleButton(false);
                proc.Refresh();

                if (proc.PagedMemorySize64 > 0x2000000)
                {
                    byte step = 0;

                    try
                    {
                        mem.FindFoVOffset(ref pFoV, ref step);

                        if (!isOffsetWrong(pFoV)) progStart();
                        else if (proc.PagedMemorySize64 > memSearchRange)
                        {
                            TimerVerif.Stop();
                            TimerCheck.Stop();

                            //bool offsetFound = false;

                            //int ptrSize = IntPtr.Size * 4;
                            /*for (int i = -0x50000; i < 0x50000 && !offsetFound; i += 16)
                            {
                                if (mem.ReadFloat(true, pFoV + i) == 65f && !isOffsetWrong(pFoV + i))
                                {
                                    pFoV += i;
                                    offsetFound = true;
                                }

                                if (i % 50000 == 0)
                                {
                                    label1.Text = i.ToString();
                                    Update();
                                }
                            }*/

                            //Console.Beep(5000, 100);

                            //MessageBox.Show("find " + pFoV.ToString("X8"));
                            if (isRunning(false) && !mem.FindFoVOffset(ref pFoV, ref step))
                            {
                                string memory = BitConverter.ToString(BitConverter.GetBytes(mem.ReadFloat(pFoV)));

                                MessageBox.Show("The memory research pattern wasn't able to find the FoV offset in your " + c_supportMessage + ".\n" +
                                                "Please look for an updated version of this FoV Changer tool.\n\n" +
                                                "If you believe this might be a bug, please send me an email at [email protected], and include a screenshot of this:\n\n" + c_toolVer +
                                                "\n0x" + Convert.ToInt32(proc.WorkingSet64).ToString("X8") +
                                                "\n0x" + Convert.ToInt32(proc.PagedMemorySize64).ToString("X8") +
                                                "\n0x" + Convert.ToInt32(proc.VirtualMemorySize64).ToString("X8") +
                                                "\nStep = " + step.ToString() +
                                                "\n0x" + (pFoV - 0xC).ToString("X8") + " = " + memory,
                                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                pFoV = c_pFoV;
                                Application.Exit();
                            }
                            else
                            {
                                //Console.Beep(5000, 100);
                                SaveData();
                                proc = null;
                                TimerCheck.Start();
                            }
                        }
                    }
                    catch (Exception err)
                    {
                        ErrMessage(err);
                        Application.Exit();
                    }
                }
            }
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AgentRev

private void btnStartGame_Click(object sender, EventArgs e)
        {
            if (gameFound)
            {
                try { Process.Start("steam://rungameid/" + c_gameID); }
                catch
                {
                    MessageBox.Show(c_errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show(c_notFoundMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AgentRev

private void btnAbout_Click(object sender, EventArgs e)
        {
            MessageBox.Show(this.Text + " v" + c_toolVer + "\n" +
                            "Made by AgentRev\n\n" +
                            "Contact/support email: [email protected]\n" +
                            "Most emails are answered within 24h, or if you're lucky, 5 minutes.\n" +
                            "If your question is about any platform other than PC, the answer is 'no'.",
                            "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

19 View Source File : frmCustomers.cs
License : MIT License
Project Creator : ahm3tcelik

private void dgvCustomers_CellClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dgvCustomers.Columns["Show"].Index && e.RowIndex != -1)
            {
                NavigationTool.OpenNewTab(new frmCustomerDetail(customers[e.RowIndex]));
            }
            else if (e.ColumnIndex == dgvCustomers.Columns["Edit"].Index && e.RowIndex != -1)
            {
                NavigationTool.OpenNewTab(new frmEditCustomer(customers[e.RowIndex]));
                LoadCustomers(customerService.GetAll(Session.currentUser));
            }
            else if (e.ColumnIndex == dgvCustomers.Columns["Delete"].Index && e.RowIndex != -1)
            {
                Customer customer = customers[e.RowIndex];

                DialogResult dialogResult = MessageBox.Show(customer.CustomerName + " " + customer.CustomerSurname +
                    " adlı müşteriyi silmek istediğinizden emin misiniz?", "Müşteri Sil", MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        customerService.Delete(customer, Session.currentUser);
                        customers.Remove(customer);
                        LoadCustomers(customers);
                        MessageBox.Show("Müşteri başarıyla silindi!", "Başarılı!");
                    } catch (Exception ex)
                    {
                        MessageBox.Show("Bağımlılıkları kontrol edin\n" + ex.Message, "Hata!");
                    
                    }
                }
            }
        }

19 View Source File : frmSchedules.cs
License : MIT License
Project Creator : ahm3tcelik

private void dgvSchedules_CellClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dgvSchedules.Columns["Show"].Index && e.RowIndex != -1)
            {
                NavigationTool.OpenNewTab(new frmScheduleDetail(schedules[e.RowIndex]));
            }
            else if (e.ColumnIndex == dgvSchedules.Columns["Edit"].Index && e.RowIndex != -1)
            {
                NavigationTool.OpenNewTab(new frmEditSchedule(schedules[e.RowIndex]));
                LoadSchedules(scheduleService.GetAll(Session.currentUser));
            }
            else if (e.ColumnIndex == dgvSchedules.Columns["Delete"].Index && e.RowIndex != -1)
            {
                Schedule schedule = schedules[e.RowIndex];

                DialogResult dialogResult = MessageBox.Show(schedule.ScheduleName +
                    " adlı programı silmek istediğinizden emin misiniz?", "Programı Sil", MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        scheduleService.Delete(schedule, Session.currentUser);
                        MessageBox.Show("Program başarıyla silindi!", "Başarılı!");
                    } catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Hata!");
                    }
                    schedules.Remove(schedule);
                    LoadSchedules(schedules);
                }
            }
        }

19 View Source File : frmAddCustomer.cs
License : MIT License
Project Creator : ahm3tcelik

private void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                Customer customer = new Customer {
                    CustomerName = tbxName.Text.Trim(),
                    CustomerSurname = tbxSurname.Text.Trim(),
                    CustomerGsm = tbxGsm.Text.Trim(),
                    Duration = Convert.ToInt32(tbxDuration.Text.Trim()),
                    StarterDate = dtStarter.Value,
                    ScheduleID = Convert.ToInt32(cbxSchedules.SelectedValue)
                };
                ValidationTool.Validate(new CustomerValidator(), customer);
                clearForm();
                customerService.Add(customer, Session.currentUser);
                MessageBox.Show("'" + customer.CustomerName + " " + customer.CustomerSurname + "' başarıyla eklendi.", "Başarılı!");

            } catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }

19 View Source File : frmEditCustomer.cs
License : MIT License
Project Creator : ahm3tcelik

private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lvlStats.SelectedItems.Count < 1)
                return;

            Statistic st = stats[lvlStats.SelectedItems[0].Index];
            DialogResult dialogResult = MessageBox.Show(st.StatisticDate.ToShortDateString() + 
                " Tarihli istatistiği silmek istediğinizden emin misiniz?", "İstatistik Sil", MessageBoxButtons.YesNo);
            
            if (dialogResult == DialogResult.Yes)
            {
                try
                {
                    statisticService.Delete(st, Session.currentUser);
                    lvlStats.Items.RemoveAt(lvlStats.SelectedItems[0].Index);
                    MessageBox.Show("İstatistik başarıyla silindi!", "Başarılı!");
                } catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Hata!");
                }
            }
        }

19 View Source File : frmSettings.cs
License : MIT License
Project Creator : ahm3tcelik

private void btnDel_Click(object sender, System.EventArgs e)
        {
            if (lvlAuthorities.SelectedItems.Count < 1)
                return;

            User user = authorities[lvlAuthorities.SelectedItems[0].Index];
            DialogResult dialogResult = MessageBox.Show(user.UserName +
                " adlı yetkiliyi silmek istediğinizden emin misiniz?", "Yetkili Sil", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                try
                {
                    userService.Delete(user, Session.currentUser);
                    MessageBox.Show("Yetkili başarıyla silindi!", "Başarılı!");
                    lvlAuthorities.Items.RemoveAt(lvlAuthorities.SelectedItems[0].Index);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Hata!");
                }
            }
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : ahmed605

private void LoadGameDirectory( KeyUtil keyUtil, string gameName )
        {
            using (new WaitCursor(this))
            {
                FileSystem fs = new RealFileSystem();

                string gamePath = keyUtil.FindGameDirectory();
                while (gamePath == null)
                {
                    var fbd = new VistaFolderBrowserDialog
                    {
                        Description =
                            "Could not find the " + gameName + " game directory. Please select the directory containing " + keyUtil.ExecutableName,
                        ShowNewFolderButton = false
                    };

                    if (fbd.ShowDialog() == DialogResult.Cancel)
                    {
                        MessageBox.Show(
                            keyUtil.ExecutableName +
                            " is required to extract cryptographic keys for this program to function. " +
                            "SparkIV can not run without this file.", "Error", MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                        return;
                    }
                    if (System.IO.File.Exists(Path.Combine(fbd.SelectedPath, keyUtil.ExecutableName)))
                    {
                        gamePath = fbd.SelectedPath;
                    }
                }

                byte[] key = keyUtil.FindKey( gamePath );

                if (key == null)
                {
                    string message = "Your " + keyUtil.ExecutableName + " seems to be modified or is a newer version than this tool supports. " +
                                    "SparkIV can not run without a supported " + keyUtil.ExecutableName + " file." + "\n" + "Would you like to check for updates?";
                    string caption = "Newer or Modified " + keyUtil.ExecutableName;

                    if (MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                    {
                        Updater.CheckForUpdate();
                    }

                    return;
                }


                KeyStore.SetKeyLoader(() => key);

                fs.Open(gamePath);

                if (_fs != null)
                {
                    _fs.Close();
                }
                _fs = fs;

                Text = Application.ProductName + " - Browse Game Directory";

                PopulateUI();
            }
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : ahmed605

private void lvFiles_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (lvFiles.SelectedItems.Count == 1)
                {
                    var file = lvFiles.SelectedItems[0].Tag as File;
                    PreviewOrEditFile(file);
                }
            }

            if (e.KeyCode == Keys.Delete)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure to delete this file : " + lvFiles.SelectedItems[0].Text, "Delete", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    //do something
                    if (System.IO.File.Exists(Path.Combine(KeyUtil.GetDir.Get(), lvFiles.SelectedItems[0].Text)))
                    {
                        System.IO.File.Delete(Path.Combine(KeyUtil.GetDir.Get(), lvFiles.SelectedItems[0].Text));
                        lvFiles.Items.Remove(lvFiles.SelectedItems[0]);
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }
            }

            //if (e.KeyCode == Keys.C && e.Control)
            //{
              //  Clipboard.SetData(DataFormats.FileDrop, Path.Combine(KeyUtil.GetDir.Get(), lvFiles.SelectedItems[0].Text));
                //Clipboard.SetFileDropList(Path.Combine(KeyUtil.GetDir.Get(), lvFiles.SelectedItems[0].Text));
            //}
           // if (e.KeyCode == Keys.V && e.Control)
           // {
              //  if (Clipboard.ContainsFileDropList())
              //  {
                    //copy to D:\test
               //     foreach (string source in Clipboard.GetFileDropList())
                //    {
               //         System.IO.File.Copy(source, KeyUtil.GetDir.Get());
               //         lvFiles.Items.Add(Path.GetFileName(source));
               //         lvFiles.Sorting = SortOrder.Ascending;
                //    }
               // }
           // }
        }

19 View Source File : frmEditSchedule.cs
License : MIT License
Project Creator : ahm3tcelik

private void btnDel_Click(object sender, EventArgs e)
        {
            if (lvlExercises.SelectedItems.Count < 1)
                return;

            Exercise ex = exercises[lvlExercises.SelectedItems[0].Index];
            DialogResult dialogResult = MessageBox.Show("#" + ex.ExerciseID + " " + ex.ExerciseName + 
                " adlı egzersizi silmek istediğinizden emin misiniz?", "Egzersiz Sil", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                try
                {
                    exerciseService.Delete(ex, Session.currentUser);
                    MessageBox.Show("Egzersiz başarıyla silindi!", "Başarılı!");
                    lvlExercises.Items.RemoveAt(lvlExercises.SelectedItems[0].Index);
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message, "Hata!");
                }
            }
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AhmedOS

private void ConvertButton_Click(object sender, EventArgs e)
        {
            if (fileByFileRadioButton.Checked)
            {
                if (Directory.Exists(outputFolderTextBox.Text))
                {
                    logTextBox.Clear();
                    SwitchUIControlsEnabled();
                    WebvttSubripConverter converter = new WebvttSubripConverter();
                    foreach (string inputFilePath in filesListBox.Items)
                    {
                        logTextBox.Text += inputFilePath + Environment.NewLine;
                        try
                        {
                            converter.ConvertToSubrip(inputFilePath, outputFolderTextBox.Text);
                            logTextBox.Text += Strings.convertedSuccessfully;
                        }
                        catch (Exception exception)
                        {
                            logTextBox.Text += "Error:: " + exception.Message;
                        }
                        logTextBox.Text += Environment.NewLine + Environment.NewLine;
                    }
                    MessageBox.Show(Strings.convertingFinished, "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    SwitchUIControlsEnabled();
                }
                else
                    MessageBox.Show(Strings.noOutputFolder, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (recursiveFolderRadioButton.Checked)
            {
                if (Directory.Exists(recursiveFolderTextBox.Text))
                {
                    System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(recursiveFolderTextBox.Text);

                    logTextBox.Clear();
                    SwitchUIControlsEnabled();

                    WebvttSubripConverter converter = new WebvttSubripConverter();
                    WalkDirectoryTree(di, converter);

                    MessageBox.Show(Strings.convertingFinished, "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    SwitchUIControlsEnabled();
                }
                else
                    MessageBox.Show(Strings.noOutputFolder, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AhmedOS

private void WalkDirectoryTree(System.IO.DirectoryInfo root, WebvttSubripConverter converter)
        {
            System.IO.FileInfo[] files = null;
            System.IO.DirectoryInfo[] subDirs = null;

            try
            {
                files = root.GetFiles("*.vtt");
            }
            catch (UnauthorizedAccessException e)
            {
                MessageBox.Show(Strings.unauthorizedAccess, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            catch (System.IO.DirectoryNotFoundException e)
            {
                MessageBox.Show(Strings.noOutputFolder, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (files != null)
            {
                foreach (System.IO.FileInfo fi in files)
                {
                    logTextBox.Text += fi.FullName + Environment.NewLine;
                    try
                    {
                        converter.ConvertToSubrip(fi.FullName, root.FullName);
                        logTextBox.Text += Strings.convertedSuccessfully;
                    }
                    catch (Exception exception)
                    {
                        logTextBox.Text += "Error:: " + exception.Message;
                    }
                    logTextBox.Text += Environment.NewLine + Environment.NewLine;
                }

                subDirs = root.GetDirectories();

                foreach (System.IO.DirectoryInfo dirInfo in subDirs)
                {
                    WalkDirectoryTree(dirInfo, converter);
                }
            }
        }

19 View Source File : progressForm.cs
License : MIT License
Project Creator : ajohns6

private void downloadPAK(object sender, EventArgs e)
        {
            this.Refresh();

            if (!IsConnectedToInternet())
            {
                MessageBox.Show("Unable to connect to the internet.\n\nPlease ensure you have a stable internet connection before downloading new PAK files.\n\n" + progressPAK.modName + " was not downloaded and will not be applied at this time.", 
                    "No Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Dispose();
                return;
            }

            Task.Run(() =>
            {
                using (var client = new WebClient())
                {
                    if (!Directory.Exists(Path.Combine(mainForm.pakDir, progressPAK.modDir)))
                    {
                        Directory.CreateDirectory(Path.Combine(mainForm.pakDir, progressPAK.modDir));
                    }
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(downloadProgress);
                    Uri pakLink = new Uri(progressPAK.modURL);
                    client.DownloadFileAsync(pakLink, Path.Combine(mainForm.pakDir, progressPAK.modDir, progressPAK.modFile));
                }
            });

            while (!Directory.Exists(Path.Combine(mainForm.pakDir, progressPAK.modDir)))
            {
                Application.DoEvents();
            }

            progBar.Maximum = 100;

            do
            {
                progBar.Value = progress;
            } while (progress < 100);

            this.Close();
        }

See More Examples