public MainWindow()
        {
            InitializeComponent();

            if (!IsRunningAsAdministrator())
            {
                // Setting up start info of the new process of the same application
                ProcessStartInfo processStartInfo = new ProcessStartInfo(Assembly.GetEntryAssembly().CodeBase);

                // Using operating shell and setting the ProcessStartInfo.Verb to “runas” will let it run as admin
                processStartInfo.UseShellExecute = true;
                processStartInfo.Verb            = "runas";

                // Start the application as new process
                Process.Start(processStartInfo);

                // Shut down the current (old) process
                Application.Current.Shutdown();
            }
            else
            {
                Window CharacterWindow      = new CharacterSelectWindow();
                CharacterSelectViewModel vm = (CharacterSelectViewModel)CharacterWindow.DataContext;
                vm.OnRequestClose += (s, e) => CharacterWindow.Close();
                CharacterWindow.ShowDialog();
                this.Title = CharacterWindow.Title;

                if (Title != "CharacterSelect")
                {
                    processList = Process.GetProcessesByName(processName);

                    foreach (Process proc in processList)
                    {
                        if (proc.MainWindowTitle == this.Title)
                        {
                            ffInstance      = CreateInstance((int)proc.Id);
                            thirdPartyTools = new ThirdPartyTools(ffInstance);
                            api             = new EliteAPI((int)proc.Id);
                        }
                    }
                }

                else
                {
                    MessageBox.Show("A character wasn't selected or the game isn't running.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    this.Close();
                }
            }
        }
Beispiel #2
0
        public ActionResult Index(int id)
        {
            GameSession      session = db.GameSessions.Include("P1").Include("P2").Include("user1").Include("user2").Where(x => x.ID == id).FirstOrDefault();
            List <Character> li      = db.Characters.ToList();

            CharacterSelectViewModel vm = new CharacterSelectViewModel()
            {
                Characters = new List <Character>(),
                MySession  = session,
            };

            foreach (var i in li)
            {
                if (vm.Characters.Where(x => x.Name == i.Name).FirstOrDefault() == null)
                {
                    vm.Characters.Add(i);
                }
            }
            return(View(vm));
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="CharacterSelectView" /> class.
 /// </summary>
 /// <param name="vm">
 ///     The vm.
 /// </param>
 public CharacterSelectView(CharacterSelectViewModel vm)
 {
     InitializeComponent();
     DataContext = vm;
 }
        public CharacterSelectWindow()
        {
            InitializeComponent();

            DataContext = new CharacterSelectViewModel();
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="CharacterSelectView" /> class.
 /// </summary>
 /// <param name="vm">
 ///     The vm.
 /// </param>
 public CharacterSelectView(CharacterSelectViewModel vm)
 {
     InitializeComponent();
     DataContext = vm;
 }
 public CharacterSelect()
 {
     InitializeComponent();
     ViewModel = new CharacterSelectViewModel();
 }