Пример #1
0
 public static SimC AcquireSimC()
 {
     if (simc != null)
     {
         return(simc);
     }
     simc = new SimC();
     return(simc);
 }
Пример #2
0
 public static SimC AcquireSimC()
 {
     if (simc != null)
     {
         return(simc);
     }
     try
     {
         simc = new SimC();
     }
     catch (Exception e)
     {
         return(null);
     }
     return(simc);
 }
Пример #3
0
        public void LoadArmoryData(String region, String server, String name)
        {
            SimC simc = null;

            Label = "Acquiring SimC Executable";
            ThreadPool.QueueUserWorkItem((_) =>
            {
                try
                {
                    simc = SimCManager.AcquireSimC();
                    if (simc == null)
                    {
                        MessageBox.Show("Could not acquire SimC. Please try again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        App.Current.Dispatcher.Invoke(() =>
                        {
                            PreloadingFailed(this, new EventArgs());
                        });
                        return;
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Could not acquire SimC because of an Exception: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        PreloadingFailed(this, new EventArgs());
                    });
                    return;
                }
                Label    = "Generating Armory Profile";
                var text = File.ReadAllText("templates/armory.simc").Replace("%region%", region).Replace("%realm%", server).Replace("%name%", name);
                if (!Directory.Exists("characters"))
                {
                    Directory.CreateDirectory("characters");
                }
                if (File.Exists("characters/" + name + ".simc"))
                {
                    File.Delete("characters/" + name + ".simc");
                }
                File.WriteAllText("characters/" + name + ".simc", text);
                if (simc.RunSim("characters/" + name + ".simc"))
                {
                    Label    = "Armory Profile Generated";
                    charName = name;
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        PreloadingComplete(this, new EventArgs());
                    });
                }
                else
                {
                    Label = "Failed to Generate Profile";
                    MessageBox.Show("Failed to generate profile. Please check your input and try again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    App.Current.Dispatcher.Invoke(() =>
                    {
                        PreloadingFailed(this, new EventArgs());
                    });
                }
            });
        }