コード例 #1
0
ファイル: VKBoard.xaml.cs プロジェクト: wilson0x4d/Mubox
 public void InitializeButtonState(Mubox.Configuration.KeySettingCollection keySettings, Predicate<Mubox.Configuration.KeySetting> filterCallback, Action<Mubox.Configuration.KeySetting> enableCallback, Action<Mubox.Configuration.KeySetting> disableCallback)
 {
     this.KeySettings = keySettings;
     this.FilterCallback = filterCallback;
     this.EnableCallback = enableCallback;
     this.DisableCallback = disableCallback;
     ProcessFrameworkElementTree(this, (Action<FrameworkElement>)delegate(FrameworkElement frameworkElement)
     {
         try
         {
             System.Windows.Controls.Primitives.ToggleButton toggleButton = frameworkElement as System.Windows.Controls.Primitives.ToggleButton;
             if (toggleButton != null)
             {
                 Mubox.Configuration.KeySetting keySetting;
                 toggleButton.IsChecked =
                     KeySettings.TryGetKeySetting((WinAPI.VK)Enum.Parse(typeof(WinAPI.VK), toggleButton.Tag as string, true), out keySetting)
                     && FilterCallback(keySetting);
             }
         }
         catch (Exception ex)
         {
             ex.Log();
         }
     });
 }
コード例 #2
0
ファイル: KeyboardInput.cs プロジェクト: wilson0x4d/Mubox
 public static KeyboardInput CreateFrom(WinAPI.WM wParam, Mubox.WinAPI.WindowHook.KBDLLHOOKSTRUCT hookStruct)
 {
     KeyboardInput e = new KeyboardInput();
     e.VK = hookStruct.vkCode;
     e.Scan = hookStruct.scanCode;
     e.Flags = hookStruct.flags;
     e.Time = hookStruct.time;
     e.WM = wParam;
     return e;
 }
コード例 #3
0
ファイル: MouseInput.cs プロジェクト: wilson0x4d/Mubox
 public static MouseInput CreateFrom(WinAPI.WM wm, Mubox.WinAPI.WindowHook.MSLLHOOKSTRUCT hookStruct)
 {
     return new MouseInput
     {
         WM = wm,
         Point = new System.Windows.Point(hookStruct.pt.X, hookStruct.pt.Y),
         MouseData = hookStruct.mouseData,
         Time = hookStruct.time,
     };
 }
コード例 #4
0
ファイル: ClientState.cs プロジェクト: wilson0x4d/Mubox
 public ClientState(Mubox.Configuration.ClientSettings settings, Mubox.Configuration.ProfileSettings profile)
     : this()
 {
     Settings = settings;
     Profile = profile;
 }
コード例 #5
0
ファイル: SysTrayMenu.cs プロジェクト: wilson0x4d/Mubox
        private MenuItem QuickLaunchMenu_CreateClientItem(string clientName, Mubox.Configuration.ProfileSettings profile)
        {
            RoutedEventHandler clientStartEventHandler = (sender, e) =>
            {
                var clientSettings = profile.Clients.GetExisting(clientName);
                if (clientSettings != null)
                {
                    Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile = profile;
                    Mubox.Configuration.MuboxConfigSection.Save();
                    ClientState clientState = new ClientState(clientSettings, profile);
                    Mubox.View.Client.ClientWindow clientWindow = new Mubox.View.Client.ClientWindow(clientState);
                    clientWindow.Show();
                }
            };

            RoutedEventHandler clientDeleteEventHandler = (sender, e) =>
            {
                // TODO: add confirmation dialog to avoid accidental deletions
                if (profile.Clients.Remove(clientName))
                {
                    // TODO: we need to clean up the sandbox account as well
                    Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile = profile;
                    Mubox.Configuration.MuboxConfigSection.Save();
                }
            };

            MenuItem clientMenuItem = new MenuItem();
            clientMenuItem.Header = clientName;
            // clientMenuItem.Click += clientLaunchEventHandler;

            MenuItem clientLaunchMenuItem = new MenuItem();
            clientLaunchMenuItem.Header = "_Start";
            clientLaunchMenuItem.Click += clientStartEventHandler;

            MenuItem clientDeleteMenuItem = new MenuItem();
            clientDeleteMenuItem.Header = "_Remove From List";
            clientDeleteMenuItem.Click += clientDeleteEventHandler;

            clientMenuItem.ItemsSource = new object[] {
                clientLaunchMenuItem,
                clientDeleteMenuItem
            };

            return clientMenuItem;
        }
コード例 #6
0
ファイル: SysTrayMenu.cs プロジェクト: wilson0x4d/Mubox
        private static void LaunchProfileClients(Mubox.Configuration.ProfileSettings profile)
        {
            Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile = profile;

            foreach (var o in profile.Clients)
            {
                var character = o as Mubox.Configuration.ClientSettings;
                if (character.CanLaunch)
                {
                    if (Mubox.View.Client.ClientWindowCollection.Instance.Count((dlg) => dlg.ClientState.Settings.Name.ToUpper().Equals(character.Name.ToUpper(), StringComparison.InvariantCultureIgnoreCase)) == 0)
                    {
                        Mubox.View.Client.ClientWindow clientWindow = new Mubox.View.Client.ClientWindow(new Mubox.Model.ClientState(character, profile));
                        clientWindow.Show();
                    }
                }
            }
        }
コード例 #7
0
ファイル: ClientWindow.xaml.cs プロジェクト: wilson0x4d/Mubox
        public ClientWindow(Mubox.Model.ClientState clientState)
        {
            Mubox.View.Client.ClientWindowCollection.Instance.Add(this);
            Debug.Assert(clientState != null);
            try
            {
                this.Dispatcher.UnhandledException += (sender, e) =>
                {
                    try
                    {
                        // TODO remove this event handler, we throw during disconnect when exiting mubox because window closure and network disconnection race
                        e.Handled = e.Exception.InnerException is ObjectDisposedException;
                        if (!e.Handled)
                        {
                            StringBuilder sb = new StringBuilder();
                            Exception ex = e.Exception;
                            while (ex != null)
                            {
                                sb.AppendLine("-------- " + ex.Message).AppendLine(ex.StackTrace);
                                ex = ex.InnerException;
                            }
                            MessageBox.Show("An error has occurred. You may want to restart Mubox and re-try. If this error continues, please send a screenshot of this error pop-up" + Environment.NewLine + "to [email protected], including steps to reproduce. A fix will be provided shortly thereafter." + Environment.NewLine + Environment.NewLine + "--- BEGIN ERROR INFO" + Environment.NewLine + "---" + sb.ToString(), "Mubox Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.Log();
                    }
                };

                // create default state so we can perform initialization without errors related to state-saving
                InitializeComponent();

                clientState.GameProcessExited += (s, e) =>
                    {
                        this.Dispatcher.BeginInvoke((Action)delegate()
                        {
                            try
                            {
                                InitializeWindowPositionAndSizeInputs();
                                clientState_SetStatusText("Application Exit.");
                                buttonLaunchApplication.IsEnabled = true;
                                this.Show();
                                ToggleApplicationLaunchButton();
                            }
                            catch
                            {
                                // NOP - known issue during shutdown where client window is in a closing state before game process has exited, resulting in exception.
                            }
                        });
                    };

                clientState.GameProcessFound += (s, e) =>
                    {
                    };

                ClientState = clientState;

                textMachineName.Text = ClientState.Settings.Name;
                textServerName.Text = ClientState.Settings.ServerName;
                textPortNumber.Text = ClientState.Settings.ServerPortNumber.ToString();
                textApplicationPath.Text = ClientState.Settings.ApplicationPath;
                textApplicationArguments.Text = this.ClientState.Settings.ApplicationArguments;
                checkIsolateApplication.IsChecked = ClientState.Settings.EnableIsolation;
                checkRememberWindowPosition.IsChecked = ClientState.Settings.RememberWindowPosition;
                InitializeWindowPositionAndSizeInputs();
                ToggleWindowPositionInputs();
                checkRemoveWindowBorder.IsChecked = ClientState.Settings.RemoveWindowBorderEnabled;
                textIsolationPath.Text = ClientState.Settings.IsolationPath;
                textWorkingSetMB.Text = ClientState.Settings.MemoryMB.ToString();
                comboProcessorAffinity.Items.Add("Use All");
                for (int i = 0; i < Environment.ProcessorCount; i++)
                {
                    comboProcessorAffinity.Items.Add((i + 1).ToString());
                }
                if (clientState.Settings.ProcessorAffinity < comboProcessorAffinity.Items.Count)
                {
                    comboProcessorAffinity.SelectedIndex = (int)ClientState.Settings.ProcessorAffinity;
                }
                else
                {
                    comboProcessorAffinity.SelectedIndex = 0;
                }

                timerStatusRefresh = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Normal);
                timerStatusRefresh.Interval = TimeSpan.FromMilliseconds(500);
                timerStatusRefresh.Tick += (sender, e) =>
                    {
                        timerStatusRefresh.Stop();
                        timerStatusRefresh.Interval = TimeSpan.FromMilliseconds(500);
                        try
                        {
                            if (ClientState.NetworkClient != null)
                            {
                                buttonConnect.IsEnabled = false;
                                textServerName.IsEnabled = false;
                                textPortNumber.IsEnabled = false;
                                timerStatusRefresh.Interval = TimeSpan.FromMilliseconds(5000);
                            }
                            else if (clientState_AutoReconnect)
                            {
                                if (buttonConnect.IsEnabled)
                                {
                                    if (TimeSpan.FromTicks(DateTime.Now.Ticks - AutoReconnectLastAttempt).TotalSeconds >= AutoReconnectDelay)
                                    {
                                        buttonConnect_Click(null, null);
                                        AutoReconnectLastAttempt = DateTime.Now.Ticks;
                                    }
                                }
                            }
                            else if (clientState.Settings.PerformConnectOnLoad)
                            {
                                if (buttonConnect.IsEnabled)
                                {
                                    buttonConnect_Click(null, null);
                                }
                            }
                            clientState_SetStatusText(clientState_lastStatus);
                        }
                        catch (Exception ex)
                        {
                            ex.Log();
                        }
                        finally
                        {
                            timerStatusRefresh.Start();
                        }
                    };
                timerStatusRefresh.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + "---" + Environment.NewLine + ex.StackTrace, "Exception Info");
                try
                {
                    Close();
                }
                catch (Exception L_ex)
                {
                    L_ex.Log();
                }
            }
        }
コード例 #8
0
ファイル: ServerWindow.xaml.cs プロジェクト: wilson0x4d/Mubox
 private void Server_ClientRemoved(object sender, Mubox.Control.Network.Server.ServerEventArgs e)
 {
     this.Dispatcher.BeginInvoke((Action<Mubox.Control.Network.Server.ServerEventArgs>)delegate(Mubox.Control.Network.Server.ServerEventArgs args)
     {
         ClientWindowProvider.Remove(args.Client);
         RefreshClientView();
     }, e);
     if (e.Client is NetworkClient)
     {
         (e.Client as NetworkClient).CoerceActivation -= ServerWindow_CoerceActivation;
     }
     e.Client.IsAttachedChanged -= Client_IsAttachedChanged;
     clientsCached = null;
 }
コード例 #9
0
ファイル: ServerWindow.xaml.cs プロジェクト: wilson0x4d/Mubox
 private void Server_ClientAccepted(object sender, Mubox.Control.Network.Server.ServerEventArgs e)
 {
     this.Dispatcher.BeginInvoke((Action<Mubox.Control.Network.Server.ServerEventArgs>)delegate(Mubox.Control.Network.Server.ServerEventArgs args)
     {
         (args.Client as NetworkClient).ClientActivated += ServerWindow_ClientActivated;
         ClientWindowProvider.Add(args.Client);
     }, e);
     if (e.Client is NetworkClient)
     {
         (e.Client as NetworkClient).CoerceActivation += new EventHandler<EventArgs>(ServerWindow_CoerceActivation);
     }
     e.Client.IsAttachedChanged += Client_IsAttachedChanged;
     clientsCached = null;
 }