private void OnDeleteTabAccept(UITabPage tabPage) { int pages = notebook1.NPages; for (int i = 0; i < pages; ++i) { Widget currentPage = notebook1.GetNthPage(i); UITabPage currentTabPage = Utils.static_cast <UITabPage>(currentPage.Data["UITabPage"]); if (currentTabPage == tabPage) { notebook1.RemovePage(i); if (i > 0) { notebook1.Page = i - 1; } GamesConfigLoader gamesConfigLoader = MainApp.GetInstance().GetConfig().GetGameConfig(); gamesConfigLoader.DeleteGameConfig(currentTabPage.GetGameConfig()); return; } } }
public WindowCommandList() : base(Gtk.WindowType.Toplevel) { this.Build(); Gtk.TreeViewColumn column1 = new Gtk.TreeViewColumn(); column1.Title = "Name"; column1.MinWidth = 100; _commandsTree.AppendColumn(column1); Gtk.CellRendererText column1Renderer = new Gtk.CellRendererText(); column1.PackStart(column1Renderer, true); column1.AddAttribute(column1Renderer, "text", 0); Gtk.TreeViewColumn column2 = new Gtk.TreeViewColumn(); column2.Title = "Description"; _commandsTree.AppendColumn(column2); Gtk.CellRendererText column2Renderer = new Gtk.CellRendererText(); column2.PackStart(column2Renderer, true); column2.AddAttribute(column2Renderer, "text", 1); Gtk.ListStore lstore = new Gtk.ListStore(typeof(string), typeof(string)); _commandsTree.Model = lstore; List <KeyValuePair <string, string> > commandsSorted = new List <KeyValuePair <string, string> >(); Dictionary <string, string> commands = MainApp.GetInstance().GetCommands().GetCommands(); foreach (KeyValuePair <string, string> keyCommand in commands) { commandsSorted.Add(keyCommand); } commandsSorted.Sort((keyPair1, keyPair2) => string.Compare(keyPair1.Key, keyPair2.Key)); foreach (KeyValuePair <string, string> commandPair in commandsSorted) { lstore.AppendValues(commandPair.Key, commandPair.Value); } _commandsTree.CursorChanged += OnCursorChanged; _commandsTree.Show(); }
public void Update() { if (GetInteractionState() == InteractionState.Pressed) { Point mousePos = MainApp.GetInstance().GetCanvasMousePos(); if (UIUtils.Distance(mousePos, _mousePressedPosition) >= PRE_DRAG_DISTANCE) { SetButtonState(InteractionState.Dragging); Point elementLocation = GetLocation(); _draggingOffset = new Point(elementLocation.X - mousePos.X, elementLocation.Y - mousePos.Y); } } else if (GetInteractionState() == InteractionState.Dragging) { Point mousePos = MainApp.GetInstance().GetCanvasMousePos(); Point buttonFinalPos = new Point(mousePos.X + _draggingOffset.X, mousePos.Y + _draggingOffset.Y); SetLocation(buttonFinalPos); } DoUpdate(); }
protected void OnExportCommandsButtonPress(object sender, EventArgs e) { Gtk.FileChooserDialog fileChooser = new Gtk.FileChooserDialog ("Choose files" , this , FileChooserAction.SelectFolder , "Select" , ResponseType.Accept , "Cancel" , ResponseType.Close); int response = fileChooser.Run(); if (response == Utils.static_cast <int>(ResponseType.Close)) { UIUtils.ShutDownWindow(ref fileChooser); } else if (response == Utils.static_cast <int>(ResponseType.Accept)) { string fullPath = fileChooser.Filename + "/exported_commands.xml"; UIUtils.ShutDownWindow(ref fileChooser); UITabPage currentTabPage = GetCurrentTabPage(); currentTabPage.GetGameConfig(); GamesConfigLoader gamesLoader = MainApp.GetInstance().GetConfig().GetGameConfig(); FileOperationResult fileOperationResult = gamesLoader.Export(fullPath, currentTabPage.GetGameConfig()); if (!fileOperationResult.IsSuccess()) { UIUtils.ShutDownWindowSafe(ref _windowPrompt); _windowPrompt = new WindowPrompt(fileOperationResult.GetResult()); _windowPrompt.OnAcceptEvent += OnAlertAccept; _windowPrompt.SetCancelVisible(false); _windowPrompt.Show(); MainApp.GetInstance().MoveWindowToMousePos(_windowPrompt); } } }
private void _inputGenericCommand_Changed(object sender, EventArgs e) { _windowCommandList.GetLabel().Text = ""; List <KeyValuePair <string, string> > commands = GetCommandsByInput(_inputGenericCommand.Text, false); if (commands.Count == 0) { commands = GetCommandsByInput(_inputGenericCommand.Text, true); if (commands.Count == 0) { HideCommandTooltip(); return; } } foreach (KeyValuePair <string, string> commandPair in commands) { if (commands.Count < 4) { _windowCommandList.GetLabel().Text += commandPair.Key + ". " + commandPair.Value + "\n"; } else { _windowCommandList.GetLabel().Text += commandPair.Key + "\n"; } } Point tooltipPos = MainApp.GetInstance().GetWindowPos(); tooltipPos.X += 865; tooltipPos.Y += 780; _windowCommandList.Move(tooltipPos.X, tooltipPos.Y); _windowCommandList.KeepAbove = true; }
private void OnEntryUpdateConnectionEvent(WidgetHostTargetEntry sender) { MainApp.GetInstance().GetHostsController().TryConnectHost(sender.GetHost()); }
private void MoveWindowToWindowPos(Gtk.Window window) { MainApp.GetInstance().MoveWindowToWindowPos(window); }
protected void OnMenuSaveButtonClick(object sender, EventArgs e) { MainApp.GetInstance().GetConfig().Save(); }
private void RefreshCommandPickerVisibility() { CommandsTable commandTable = MainApp.GetInstance().GetCommands(); _commandPickerButton.Visible = commandTable.GetCommands().Count > 0; }
protected void OnMenuConfigurationButtonPress(object sender, EventArgs e) { MainApp.GetInstance().OnMenuConfigurationButtonPress(sender, e); }
protected void OnMenuAddHostTargetButtonPress(object sender, EventArgs e) { MainApp.GetInstance().OnOpenWindowAddTargetButtonPress(); }
public void ExecuteThread() { _host._connectionStatus = HostStatus.EStatus.Connecting; bool pingSuccess = false; int timeout = 2; try { Ping ping = new Ping(); PingReply pingReply = ping.Send(_host._host, timeout); pingSuccess = pingReply.Status == IPStatus.Success; } catch (System.Net.Sockets.SocketException /*e*/) { _resultMessage = "Host (" + _host._host + ") not available\n"; _host._connectionStatus = HostStatus.EStatus.Disconnected; OnConnectionDoneEvent?.Invoke(_host, _resultMessage); return; } catch (PingException /*e*/) { _resultMessage = "Host (" + _host._host + ") not available\n"; _host._connectionStatus = HostStatus.EStatus.Disconnected; OnConnectionDoneEvent?.Invoke(_host, _resultMessage); return; } if (pingSuccess) { ApplicationConfig appConfig = MainApp.GetInstance().GetConfig().GetApplicationConfig(); string urlCommand = string.Empty; urlCommand += "http://"; urlCommand += _host._host; urlCommand += ":" + appConfig._port; urlCommand += "/" + appConfig._service; WebRequest wrGETURL; wrGETURL = WebRequest.Create(urlCommand); WebResponse webResponse = null; try { _host._connectionStatus = HostStatus.EStatus.Connecting; webResponse = wrGETURL.GetResponse(); System.IO.Stream objStream; objStream = webResponse.GetResponseStream(); System.IO.StreamReader objReader = new System.IO.StreamReader(objStream); string sLine = ""; while (sLine != null) { sLine = objReader.ReadLine(); if (sLine != null) { _resultMessage += sLine; } } CommandsTable commandsTable = MainApp.GetInstance().GetCommands(); SimpleJSON.JSONNode jsonResponse = SimpleJSON.JSON.Parse(_resultMessage); SimpleJSON.JSONClass jsonObject = jsonResponse.AsObject; foreach (KeyValuePair <string, SimpleJSON.JSONNode> commandPair in jsonObject) { string commandName = commandPair.Key; string commandDescription = commandPair.Value; commandsTable.AddCommand(commandName, commandDescription); } _host._connectionStatus = HostStatus.EStatus.Connected; Messenger.Broadcast("OnCommandsSync"); _resultMessage = "Connected to host: (" + _host._host + ")\n"; } catch (System.Net.WebException /*ex*/) { _resultMessage = "Could not connect to host: (" + _host._host + "), open the game in this device to send commands\n"; _host._connectionStatus = HostStatus.EStatus.Disconnected; } } else { _resultMessage = "Could not connect to host: (" + _host._host + "), open the game in this device to send commands\n"; _host._connectionStatus = HostStatus.EStatus.Disconnected; } OnConnectionDoneEvent?.Invoke(_host, _resultMessage); }
protected void OnWindowAcceptButtonPressed(object sender, EventArgs e) { MainApp.GetInstance().OnWindowAcceptButtonPressed(sender, e); }
protected void OnPickCommandButtonClick(object sender, EventArgs e) { MainApp.GetInstance().OpenCommandPicker(OnCommandPickedEvent); }
protected void OnSendGenericCommandButtonPress(object sender, EventArgs e) { MainApp.GetInstance().ExecuteConsoleCommand(_inputGenericCommand.Text); _commmandsHistory.Add(_inputGenericCommand.Text); _selectedCommandHistory = -1; }
void InputGenericCommand_KeyPressEvent(object o, KeyPressEventArgs args) { Gdk.Key pressedKey = args.Event.Key; if (pressedKey == Gdk.Key.Return) { MainApp.GetInstance().ExecuteConsoleCommand(_inputGenericCommand.Text); _commmandsHistory.Add(_inputGenericCommand.Text); _selectedCommandHistory = -1; UpdateHistoryCommand(); } else if (pressedKey == Gdk.Key.Up) { if (_commmandsHistory.Count > 0) { if (_selectedCommandHistory == -1) { _selectedCommandHistory = (_commmandsHistory.Count - 1); UpdateHistoryCommand(); } else if (_selectedCommandHistory >= 0) { if (_selectedCommandHistory > 0) { --_selectedCommandHistory; } UpdateHistoryCommand(); } } } else if (pressedKey == Gdk.Key.Down) { if (_commmandsHistory.Count > 0) { if (_selectedCommandHistory == -1) { return; } else if (_selectedCommandHistory < _commmandsHistory.Count - 1) { ++_selectedCommandHistory; UpdateHistoryCommand(); } else if (_selectedCommandHistory >= _commmandsHistory.Count - 1) { _selectedCommandHistory = -1; UpdateHistoryCommand(); } } } else if (pressedKey == Gdk.Key.Tab) { List <KeyValuePair <string, string> > commands = GetCommandsByInput(_inputGenericCommand.Text, false); if (commands.Count == 0) { commands = GetCommandsByInput(_inputGenericCommand.Text, true); } if (commands.Count > 0) { _inputGenericCommand.Text = commands[0].Key; } SetCursorLastPos(); _hasChangedHistoryCommand = true; } }
public static void Main(string[] args) { MainApp.CreateInstance(); MainApp.GetInstance().Init(); MainApp.GetInstance().Run(); }
protected void OnCommandPickedEvent(string command) { _inputCommand.Text = command; MainApp.GetInstance().CloseCommandPicker(); }