ShowMessage() public static method

public static ShowMessage ( string message, MessageType type ) : void
message string
type MessageType
return void
 private void btnOk_Click(object sender, RoutedEventArgs e)
 {
     if (this.tbOutputPath.Text.IsEmpty())
     {
         Tools.ShowMessage("Output path cannot be empty!", MessageType.Error);
     }
     else
     {
         string path = string.Empty;
         try
         {
             Stopwatch stopwatch = new Stopwatch();
             stopwatch.Start();
             string location   = this.g.Location;
             string text       = this.tbOutputPath.Text;
             string newValue   = this.cbNoHacks.IsChecked.Value ? "--nohacks" : string.Empty;
             string str4       = this.cbNoGui.IsChecked.Value ? "--nogui" : string.Empty;
             string str5       = this.cbNoDisc.IsChecked.Value ? "--nodisc" : string.Empty;
             string str6       = this.cbFullBoot.IsChecked.Value ? "--fullboot" : string.Empty;
             string str7       = this.cbUseDefault.IsChecked.Value ? ("--cfgpath=\"\"" + UserSettings.ConfigDir + @"\" + this.g.FileSafeTitle + "\"\"") : string.Empty;
             string outputName = this.tbOutputPath.Text + @"\" + this.g.FileSafeTitle + ".exe";
             Dictionary <string, string> providerOptions = new Dictionary <string, string>();
             providerOptions.Add("CompilerVersion", "v4.0");
             CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions);
             CompilerParameters options  = new CompilerParameters(new string[] { "mscorlib.dll", "System.Core.dll" }, outputName, true)
             {
                 GenerateExecutable = true
             };
             if (this.cbUseDefaultIcon.IsChecked.Value)
             {
                 path = UserSettings.ImageDir + @"\" + this.g.FileSafeTitle + ".ico";
                 this.CreateIcon(path, true);
                 options.CompilerOptions = string.Format("/target:winexe /optimize /win32icon:{1}{0}{1}", path, "\"");
             }
             else if (!this.cbUseDefault.IsChecked.Value)
             {
                 path = this.tbIconPath.Text;
                 options.CompilerOptions = string.Format("/target:winexe /optimize /win32icon:{1}{0}{1}", path, "\"");
             }
             if (string.IsNullOrWhiteSpace(path))
             {
                 options.CompilerOptions = string.Format("/target:winexe /optimize", new object[0]);
             }
             options.ReferencedAssemblies.Add("System.dll");
             options.IncludeDebugInformation = false;
             string  str9 = Settings.Default.pcsx2Exe;
             IniFile file = new IniFile(UserSettings.ConfigDir + @"\" + this.g.Title + @"\Settings.ini");
             if (!string.IsNullOrWhiteSpace(file.Read("Additional Executables", "Default")))
             {
                 str9 = file.Read("Additional Executables", "Default");
             }
             Process process = new Process {
                 StartInfo = { WorkingDirectory = "" }
             };
             string directoryName = Path.GetDirectoryName(str9);
             string str11         = Resources.executableTemplate.Replace("{1}", str9).Replace("{2}", newValue).Replace("{3}", str4).Replace("{4}", str5).Replace("{5}", str6).Replace("{6}", location).Replace("{7}", "\"\"").Replace("{8}", str7).Replace("{9}", directoryName);
             provider.CompileAssemblyFromSource(options, new string[] { str11 }).Errors.Cast <CompilerError>().ToList <CompilerError>().ForEach(error => Console.WriteLine(error.ErrorText));
             stopwatch.Stop();
             System.Windows.MessageBox.Show(string.Concat(new object[] { "Successfully compiled the executable at ", outputName, "\n[", stopwatch.ElapsedMilliseconds, "ms]" }), "PCSX2Bonus", MessageBoxButton.OK, MessageBoxImage.Asterisk);
         }
         catch (Exception exception)
         {
             Tools.ShowMessage("There was an error building the executable.\nReason: " + exception.Message, MessageType.Error);
         }
         if (File.Exists(path) && Path.GetDirectoryName(path).Contains("PCSX2Bonus"))
         {
             File.Delete(path);
         }
     }
 }
Example #2
0
        public void LaunchGame(Game g, bool tvMode = false)
        {
            Process  p;
            DateTime _timeOpened;
            string   str = string.Empty;

            if (!File.Exists(g.Location))
            {
                Tools.ShowMessage("Unable to find image file!", MessageType.Error);
                if (tvMode)
                {
                    Window window = System.Windows.Application.Current.Windows.Cast <Window>().FirstOrDefault <Window>(w => w.Title == "wndFullScreen");
                    if (window != null)
                    {
                        window.ShowDialog();
                    }
                }
            }
            else
            {
                p = new Process();
                string path = UserSettings.RootDir + string.Format(@"\Configs\{0}", g.FileSafeTitle);
                if (Directory.Exists(path))
                {
                    str = string.Format(" --cfgpath={0}{2}{0} {0}{1}{0}", "\"", g.Location, path);
                }
                else
                {
                    str = string.Format(" {0}{1}{0}", "\"", g.Location);
                }
                str = str.Replace(@"\\", @"\");
                string src  = string.Empty;
                string str4 = Settings.Default.pcsx2Dir;
                if (File.Exists(path + @"\PCSX2Bonus.ini"))
                {
                    IniFile file = new IniFile(path + @"\PCSX2Bonus.ini");
                    string  str5 = file.Read("Additional Executables", "Default");
                    string  str6 = !str5.IsEmpty() ? str5 : Settings.Default.pcsx2Exe;
                    str4 = !str5.IsEmpty() ? Path.GetDirectoryName(str5) : Settings.Default.pcsx2Dir;
                    string str7  = file.Read("Boot", "NoGUI");
                    string str8  = file.Read("Boot", "UseCD");
                    string str9  = file.Read("Boot", "NoHacks");
                    string str10 = file.Read("Boot", "FullBoot");
                    src = file.Read("Shader", "Default");
                    p.StartInfo.FileName = str6;
                    if (str7 == "true")
                    {
                        str = str.Insert(0, " --nogui");
                    }
                    if (str8 == "true")
                    {
                        str = str.Insert(0, " --usecd");
                    }
                    if (str9 == "true")
                    {
                        str = str.Insert(0, " --nohacks");
                    }
                    if (str10 == "true")
                    {
                        str = str.Insert(0, " --fullboot");
                    }
                }
                else
                {
                    p.StartInfo.FileName = Settings.Default.pcsx2Exe;
                }
                p.EnableRaisingEvents        = true;
                p.StartInfo.WorkingDirectory = str4;
                p.StartInfo.Arguments        = str;
                if (!src.IsEmpty())
                {
                    try
                    {
                        File.Copy(src, Path.Combine(str4, "shader.fx"), true);
                    }
                    catch (Exception exception)
                    {
                        Tools.ShowMessage("Could not save shader file! Details: " + exception.Message, MessageType.Error);
                    }
                }
                _timeOpened = DateTime.Now;
                p.Exited   += delegate(object o, EventArgs e) {
                    if (p != null)
                    {
                        p.Dispose();
                    }
                    System.Windows.Application.Current.Dispatcher.Invoke(delegate {
                        DateTime now     = DateTime.Now;
                        g.TimePlayed     = g.TimePlayed.Add(now.Subtract(_timeOpened));
                        XElement element = UserSettings.xGames.Descendants("Game").FirstOrDefault <XElement>(x => x.Element("Name").Value == g.Title);
                        if ((element != null) && (element.Element("Time") != null))
                        {
                            element.Element("Time").Value = g.TimePlayed.ToString();
                        }
                        if (tvMode)
                        {
                            Window window = System.Windows.Application.Current.Windows.Cast <Window>().FirstOrDefault <Window>(w => w.Title == "wndFullScreen");
                            if (window != null)
                            {
                                window.ShowDialog();
                            }
                        }
                        this._notifyIcon.Visible = false;
                        this.Show();
                        this.Activate();
                    });
                };
                base.Hide();
                if (Settings.Default.enableGameToast)
                {
                    new wndGameNotify {
                        Tag = g
                    }.Show();
                }
                this._notifyIcon.Text    = string.Format("Currently playing [{0}]", g.Title.Truncate(40));
                this._notifyIcon.Visible = true;
                p.Start();
            }
        }