private void DeleteConnection(string ip, bool disconnectRequest) { var connection = connectionsDictionary[ip]; if (disconnectRequest) { connection.MessageBroker.SendMessage(new DisconnectServerCommand(true)); } if (connection.RdpViewer != null) { connection.RdpViewer.Disconnect(); } DeleteTabPage($"tabPage{connection.ConnectionId}"); connectionsDictionary.Remove(ip); UntieDisplayToConnection(connection); var item = checkedListBox1.Items.IndexOf($"{connection.ClientIP}"); this.Invoke(new Action(() => { checkedListBox1.Items.RemoveAt(item); })); UpdateGUI.UpdateControl(txtStatus, "Text", $"Клиент {ip} отключен."); }
private void StopTranslationButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; var btnId = ParseControlId(btn.Name, "btnStopView"); if (btnId > 0) { var ip = connectionsDictionary.Where(c => c.Value.ConnectionId == btnId).FirstOrDefault().Value.ClientIP; var connection = connectionsDictionary[ip]; connection.State = Utils.Models.ConnectionState.Off; try { connection.RdpViewer.Disconnect(); } catch { } connection.TabPage.Controls.OfType <Button>().ToList()[0].Enabled = true; connection.TabPage.Controls.OfType <Button>().ToList()[2].Enabled = false; btn.Enabled = false; UpdateGUI.UpdateControl(txtStatus, "Text", "Трансляция остановлена."); } }
private void StartListening() { server.Start(); UpdateGUI.UpdateControl(txtStatus, "Text", "Прослушивание подключений..."); while (!stop) { if (server != null) { if (server.Pending()) { TcpClient client = server.AcceptTcpClient(); var clientIp = ((IPEndPoint)client.Client.RemoteEndPoint).Address.ToString(); connectionId++; AddConnection(clientIp, client); UpdateGUI.UpdateControl(txtStatus, "Text", $"Новое подключение: {clientIp}."); } else { ListenMessages(); } } } }
private void ExecuteProhibit(Connection connection, ICommand cmd) { bool prohibit = (bool)cmd.GetData()[0]; connection.ProhibitDemo = prohibit; connection.State = Utils.Models.ConnectionState.Demonstration; try { connection.RdpViewer.RequestControl(CTRL_LEVEL.CTRL_LEVEL_VIEW); } catch { } var btns = connection.TabPage.Controls.OfType <Button>().ToList(); if (prohibit == true) { UpdateGUI.UpdateControl(btns[2], "Enabled", false); UpdateGUI.UpdateControl(btns[3], "Enabled", false); } else { UpdateGUI.UpdateControl(btns[2], "Enabled", true); } }
private void btnStarter_Click(object sender, EventArgs e) { if (btnStarter.Text.StartsWith("Запустить")) { if (Int32.TryParse(txtPort.Text, out port)) { if (server == null) { stop = false; server = new TcpListener(IPAddress.Any, port); Listening = new Thread(StartListening); Listening.Start(); UpdateGUI.UpdateControl(btnStarter, "Text", "Остановить прослушивание"); UpdateGUI.UpdateControl(txtStatus, "Text", "Прослушивание подключений..."); } } else { MessageBox.Show("Порт введен некорректно."); } } else { StopListening(); UpdateGUI.UpdateControl(btnStarter, "Text", "Запустить прослушивание"); UpdateGUI.UpdateControl(txtStatus, "Text", "Прослушивание остановлено."); } }
public ChatViewModel(int gamenum, KailleraWindowController mgr, Game game = null) { wind = new ChatWindow(); gameNumber = gamenum; wind.Userup += UpdateUsers; updater += wind.WindowUpdate; wind.listBox1.ItemsSource = DisplayUsers; wind.addBuddyList += addBuddy; wind.Logger = ChatLogger.getLog(game); //Set small line height to avoid large line breaks Paragraph p = wind.richTextBox1.Document.Blocks.FirstBlock as Paragraph; p.LineHeight = 1; wind.textBox1.KeyDown += Chat_sendMessageIfEnter; wind.Closed += (object sender, EventArgs e) => winClosed(sender, e); wind.gameNumber = gamenum; //If this is a game chat, we want to leave the game upon window close if (gamenum != 0) { wind.Closed += beginLeaveGame; wind.Title = game.name; } wind.Show(); //Make this the active window in the tray manager KailleraTrayManager.Instance.addActiveWindow(wind); }
public ChatWindow() { updater += WindowUpdate; InitializeComponent(); Closing += Window_Closing; richTextBox1.IsDocumentEnabled = true; }
private void btnConnect_Click(object sender, EventArgs e) { if (btnConnect.Text.StartsWith("Подключиться")) { if (firstRun) { firstRun = false; } try { if (!_client.Settings.IsEmpty()) { if (checkedListBox1.CheckedItems.Count > 0) { _client.ConnectTcp(); _client.CreateSession(desktopOption, chosenApp); _client.CreateConnectionString(); _client.SendConnectionCommand(); txtConnectionString.Text = _client.ConnectionString; UpdateGUI.UpdateControl(btnMsgSend, "Enabled", true); UpdateGUI.UpdateControl(btnSendFile, "Enabled", true); UpdateGUI.UpdateControl(btnPause, "Enabled", true); UpdateGUI.UpdateControl(btnResume, "Enabled", true); _client.MessageListener.Start(); UpdateGUI.UpdateControl(txtStatus, "Text", "Подключение к серверу выполнено успешно."); UpdateGUI.UpdateControl(btnConnect, "Text", "Отключиться от сервера"); } else { MessageBox.Show("Опция демонстрации не выбрана.\n"); } } else { MessageBox.Show("Настройки подключения не заданы!\n"); } } catch (Exception ex) { _client.TcpClient = null; _client.MessageBroker = null; _client.Connected = false; MessageBox.Show("Не удалось подключиться к севреру.\n"); UpdateGUI.UpdateControl(txtStatus, "Text", "Не удалось подключиться к севреру."); } } else { if (_client.TcpClient != null) { _client.Disconnect(true); _client.Dispose(); this.Dispose(); this.Close(); } } }
private void UntieDisplayToConnection(Connection connection) { var display = displays.Where(d => d.ConnectionId == connection.ConnectionId).FirstOrDefault(); if (display != null) { display.Unreserve(connection.ConnectionId); display.RdpDisplay.Disconnect(); UpdateGUI.UpdateControl(display.Label, "Text", string.Empty); } }
/// <summary> /// Initialized the GUI /// Attempts to open COM 9 by default /// </summary> /// <param name="frmChoose">The parent chooser form</param> public frmTeslaGui(frmChoose frmChoose) { InitializeComponent(); this.chooserForm = frmChoose; updateGUI = new UpdateGUI(this.UpdateGUIFunction); //add the serial port selection to the menu string[] serialPorts = System.IO.Ports.SerialPort.GetPortNames(); foreach (string portName in serialPorts) { COMPortToolStripMenuItem.DropDownItems.Add(portName, null, (object sender, EventArgs e) => { serialPort.PortName = portName; UncheckAllComs(); ((ToolStripMenuItem)sender).Checked = true; }); if (portName == "COM9") { ((ToolStripMenuItem)COMPortToolStripMenuItem.DropDownItems[COMPortToolStripMenuItem.DropDownItems.Count - 1]).Checked = true; } } //set up serial port serialPort = new System.IO.Ports.SerialPort(); if (serialPorts.Contains("COM9")) { serialPort.PortName = "COM9"; } serialPort.BaudRate = 57600; serialPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(serialPort_DataReceived); //Initialize classes antComm = new ANTCommunication(ref serialPort, this); spBuffer = new BufferedReader(this); tempConv = new TempVal(); //Initialize timers flashTimer = new System.Timers.Timer(50); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); simTimer = new System.Timers.Timer(500); simTimer.Elapsed += new System.Timers.ElapsedEventHandler(simTimer_Elapsed); pastTemps = new Queue<double>(150); //Clear labels lblError.Text = ""; lblLastMessage.Text = ""; //Set up last received lastRecieved = new Dictionary<DataDecoder.SensorType, int>(3); lastRecieved.Add(DataDecoder.SensorType.Temperature, 100); lastRecieved.Add(DataDecoder.SensorType.Accelerometer, 100); lastRecieved.Add(DataDecoder.SensorType.Button, 100); }
private void TieDisplayToConnection(Connection connection) { var display = FindEmptyDisplay(); var displayId = display.Id; if (display != null) { if (connection.State == Utils.Models.ConnectionState.Demonstration) { display.RdpDisplay.SmartSizing = true; display.Reserve(connection.ConnectionId); display.RdpDisplay.Connect(connection.ConnectionString, connection.AuthData.Name, connection.AuthData.Password); var name = string.IsNullOrEmpty(connection.User.LabName) ? "" : connection.User.LabName; UpdateGUI.UpdateControl(display.Label, "Text", $"{connection.ClientIP} {name}"); } } }
private void btnCreate_Click(object sender, EventArgs e) { if (ValidateControls()) { return; } var failure = !CheckDownloadDirectory(); if (failure) { return; } Program.data.Project.ProjectName = ProjectName; Program.data.Project.ProjectState = Project.ProjectStates.InitializedUnsave; Program.data.Project.Domain = DomainWebsite.ToLower(); Program.data.Project.AlternativeDomains.Clear(); Program.data.Project.AlternativeDomains.AddRange(AlternativeDomains.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)); Program.data.Project.ProjectDate = txtDate.Value; Program.data.Project.ProjectNotes = Notes; Program.data.Project.ProjectSaveFile = string.Empty; Program.FormMainInstance.toolStripStatusLabelLeft.Text = string.Empty; Program.FormMainInstance.toolStripProgressBarDownload.Value = 0; Program.FormMainInstance.LoadInitialProjectGui(); // OnNewProject #if PLUGINS var tPluginOnNewProject = new Thread(Program.data.plugins.OnNewProject) { IsBackground = true }; object[] oProject = { new object[] { DomainWebsite } }; tPluginOnNewProject.Start(oProject); #endif Program.FormMainInstance.ProjectManager.SaveProject(string.Empty); if (Program.data.Project.Id == 0) { Program.FormMainInstance.Reset(); UpdateGUI.Reset(); } }
private void ParseData(Device ParseFor, byte[] Payload) { JointTelemetry tel = Telemetry[ParseFor]; CANPacket canPack = (CANPacket)Payload[0]; switch (canPack) { case CANPacket.TELEMETRY: int Voltage = BitConverter.ToInt16(Payload.Take(3).ToArray(), 1); int Current = BitConverter.ToInt16(Payload, 3); tel.Voltage = Voltage; tel.Current = Current; break; case CANPacket.STATUS: // Basically doesn't exist as of now break; case CANPacket.ENCODER_CNT: int EncoderCount = BitConverter.ToInt32(Payload, 1); tel.Encoder = EncoderCount; break; case CANPacket.ERROR_MSG: int Error = BitConverter.ToInt16(Payload, 0) & 0xFF; tel.ErrorCode = Error; break; case CANPacket.MODEL_NUM: tel.ModelNumber = BitConverter.ToInt16(Payload, 0) & 0xFF; break; case CANPacket.SERVO: tel.ServoPos = BitConverter.ToInt16(Payload, 0) & 0xFF; break; case CANPacket.LASER: // Does not exist yet break; } UpdateGUI?.Invoke(); Telemetry[ParseFor] = tel; }
private void RequestControlButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; var btnId = ParseControlId(btn.Name, "btnRequestControl"); var currentConnection = connectionsDictionary.Where(c => c.Value.ConnectionId == btnId).FirstOrDefault().Value; if (btnId > 0) { var ip = string.Empty; try { currentConnection.RdpViewer.RequestControl(CTRL_LEVEL.CTRL_LEVEL_INTERACTIVE); currentConnection.State = Utils.Models.ConnectionState.Control; foreach (var connection in connectionsDictionary) { var btns = connection.Value.TabPage.Controls.OfType <Button>().ToList(); if (connection.Value.ConnectionId != btnId) { btns[2].Enabled = false; btns[3].Enabled = false; } else { ip = connection.Value.ClientIP; btn.Enabled = false; btns[0].Enabled = false; btns[1].Enabled = true; btns[3].Enabled = true; } } UpdateGUI.UpdateControl(txtStatus, "Text", $"Запущено управление клиентом {ip}."); } catch { MessageBox.Show($"Не удалось запустить управление клиентом {ip}."); UpdateGUI.UpdateControl(txtStatus, "Text", $"Не удалось запустить управление клиентом {ip}."); } } }
private void StartTranslationButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; var btnId = ParseControlId(btn.Name, "btnStartView"); if (btnId > 0) { var ip = connectionsDictionary.Where(c => c.Value.ConnectionId == btnId).FirstOrDefault().Value.ClientIP; var connection = connectionsDictionary[ip]; connection.State = Utils.Models.ConnectionState.Demonstration; var conStr = connectionsDictionary[ip].ConnectionString; connection.RdpViewer.Connect(connection.ConnectionString, connection.AuthData.Name, connection.AuthData.Password); btn.Enabled = false; connection.TabPage.Controls.OfType <Button>().ToList()[1].Enabled = true; connection.TabPage.Controls.OfType <Button>().ToList()[2].Enabled = !connection.ProhibitDemo; connection.TabPage.Controls.OfType <Button>().ToList()[3].Enabled = false; UpdateGUI.UpdateControl(txtStatus, "Text", "Трансляция запущена."); } }
private void ExecuteConnectClient(Connection connection, ICommand cmd) { User user = (User)cmd.GetData()[0]; string connectionString = (string)cmd.GetData()[1]; bool prohibit = (bool)cmd.GetData()[2]; connection.User = user; connection.ProhibitDemo = prohibit; if (!String.IsNullOrEmpty(connectionString)) { connection.ConnectionString = connectionString; var tab = CreateNewTab(connection.ClientIP, true, prohibit); AxRDPViewer viewer = (AxRDPViewer)tab.Controls.Find($"rdpViewer{connectionId}", false).FirstOrDefault(); //Нужно добавить!!! viewer.OnConnectionTerminated += (reason, info) => DeleteConnection(connection.ClientIP, false); viewer.OnApplicationClose += (reason, info) => DeleteConnection(connection.ClientIP, false); viewer.OnAttendeeDisconnected += (reason, info) => DeleteConnection(connection.ClientIP, false); viewer.OnConnectionFailed += (reason, info) => DeleteConnection(connection.ClientIP, false); if (viewer != null) { UpdateGUI.UpdateControl(viewer, "SmartSizing", true); connection.RdpViewer = viewer; connection.TabPage = tab; } } else { var tab = CreateNewTab(connection.ClientIP, false, prohibit); connection.TabPage = tab; MessageBox.Show($"Не удалось получить строку подключения от клиента {connection.ClientIP}. Мониторинг невозможен."); UpdateGUI.UpdateControl(txtStatus, "Text", $"Не удалось получить строку подключения от клиента {connection.ClientIP}."); } }
public bool processFiles(String[] fileEntries, String outputDir,UpdateGUI update) { if (Directory.Exists(outputDir) == false) { Directory.CreateDirectory(outputDir); } //For each selected file type in the source directory, do // pbStatus.Minimum = 0; // pbStatus.Maximum = fileEntries.Length; // pbStatus.Step = 1; int fileCount = 0; bool fail = false; // Console.WriteLine("PROCESSING FILES...."); foreach (String fileName in fileEntries) { if (fail == true) break; //If the found file is of the correct file type then process FileInfo fi = new FileInfo(fileName); fileCount += 1; // pbStatus.Value = fileCount; String currentFile = fileName; String outputFile = DirUtil.JoinDirAndFile(outputDir, fi.Name); /* if (outputDir[outputDir.Length - 1] != '\\') { outputFile = outputDir + "\\" + fi.Name; } else { outputFile = outputDir + fi.Name; }*/ Console.WriteLine("OUTPUT TO: " + outputFile); String resizeString = ""; resizeString = " -resize " + tbOutputWidth.ToString(); // if (tbOutputHeight.Text != "" && tbOutputWidth.Text != "") // resizeString = " -resize " + tbOutputWidth.Text + "x" + tbOutputHeight.Text; //lblStatus.Text = "Processing File " + fileCount.ToString() + " of " + fileEntries.Length.ToString(); Process myProcess = new Process(); try { myProcess.StartInfo.FileName = "\"" + appPath + "\\convert\""; myProcess.StartInfo.Arguments = (@"-type truecolor -quality " + tbQuality+ " -density " + tbDPI+ " \"" + currentFile + "\"" + resizeString + " \"" + outputFile + "\""); myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.CreateNoWindow = true; System.Console.WriteLine(myProcess.StartInfo.FileName + " " + myProcess.StartInfo.Arguments); // myProcess.StartInfo.RedirectStandardOutput = true; // myProcess.OutputDataReceived += new DataReceivedEventHandler(OnDataReceived); //myProcess.ErrorDataReceived += new DataReceivedEventHandler(SortOutputHandler); myProcess.Start(); myProcess.WaitForExit(); if (myProcess.ExitCode != 0) { //update(-1, "Error " + ex.Message); // lblStatus.Text = "Error " + ex.ToString(); //fail = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); //Console.WriteLine(ex.ToString()); update(-1, "Error "+ex.Message); // lblStatus.Text = "Error " + ex.ToString(); fail = true; } update(fileCount,""); Application.DoEvents(); } // pbStatus.Value = 0; return fail; }
public void Rotate(String[] fileEntries, UpdateGUI update, ROTATION rotate) { for (int n = 0; n < fileEntries.Length; n++) { try { Process myProcess = new Process(); myProcess.StartInfo.FileName = "\"" + appPath + "\\convert\""; myProcess.StartInfo.Arguments = (" -rotate 90 \"" + fileEntries[n] + "\" \"" + fileEntries[n]+ "\" "); myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.CreateNoWindow = true; myProcess.Start(); myProcess.WaitForExit(); update(n, ""); Application.DoEvents(); } catch (Exception ex) { MessageBox.Show("Error Rotation " + ex.Message); } } }
private void btnUpdate_Click(object sender, EventArgs e) { FillCheckBoxList(); UpdateGUI.UpdateControl(btnConnect, "Enabled", true); }