private void OnReceiveLogMessage(object sender, OnReceivedLogMessageEventArgs e) { logMessage.Add(new LogItem(e.Message)); //coreEngine.SaveLogMessage(e.Message); if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate() { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); //LogListBox.SelectedIndex = LogListBox.Items.Count - 1; curLogIndex++; } //CheckLogLength(); })); } else { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); //LogListBox.SelectedIndex = LogListBox.Items.Count - 1; curLogIndex++; } //CheckLogLength(); } }
private void TxDataArrayReset() { // Tx data 리셋 for (int i = 0; i < 4096; i++) { Tx_data[i] = 0x00000000; } LogListBox.AppendText("Reset Tx data array\n\n"); }
private void OnExceedLimit(ExceedLimitItem item) { this.Dispatcher.BeginInvoke( (Action)(() => { LogListBox.Items.Add(item); LogListBox.ScrollIntoView(item); }) ); }
private void ConstructEndpoints() { if (loopDevice != null && ConnectCyUsbOutEndpointComboBox.Items.Count > 0 && ConnectCyUsbInEndpointComboBox.Items.Count > 0) { // string에서 bAlternateSetting 파싱 string sAltOut = ConnectCyUsbOutEndpointComboBox.Text.Substring(4, 1); byte outAltInferface = Convert.ToByte(sAltOut); string sAltIn = ConnectCyUsbInEndpointComboBox.Text.Substring(4, 1); byte inAltInferface = Convert.ToByte(sAltIn); if (outAltInferface != inAltInferface) { // BULK LOOP 인터페이스는 ALT 인터페이스 세팅 코드가 일치하게 되어있음 // IN, OUT ENDPOINT가 같은 ALT 인터페이스가 아니면 로그 출력 후 리턴 LogListBox.AppendText("Output Endpoint and Input Endpoint should present in the same ALT interface\n\n"); return; } // STRING에서 ENDPOINT 주소 파싱 int aX = ConnectCyUsbInEndpointComboBox.Text.LastIndexOf("0x"); string sAddr = ConnectCyUsbInEndpointComboBox.Text.Substring(aX, 4); byte addrIn = (byte)Util.HexToInt(sAddr); aX = ConnectCyUsbOutEndpointComboBox.Text.LastIndexOf("0x"); sAddr = ConnectCyUsbOutEndpointComboBox.Text.Substring(aX, 4); byte addrOut = (byte)Util.HexToInt(sAddr); outEndpoint = loopDevice.EndPointOf(addrOut) as CyBulkEndPoint; inEndpoint = loopDevice.EndPointOf(addrIn) as CyBulkEndPoint; if ((outEndpoint != null) && (inEndpoint != null)) { //make sure that the device configuration doesn't contain the other than bulk endpoint if ((outEndpoint.Attributes & 0x03 /*0,1 bit for type of transfer*/) != 0x02 /*Bulk endpoint*/) { LogListBox.AppendText("Device Configuration mismatch\n\n"); return; } if ((inEndpoint.Attributes & 0x03) != 0x02) { LogListBox.AppendText("Device Configuration mismatch\n\n"); return; } outEndpoint.TimeOut = 1; inEndpoint.TimeOut = 1; } else { LogListBox.AppendText("Device Configuration mismatch\n\n"); return; } } }
private void Log(string obj) { var tb = new TextBlock(); tb.Text = obj; LogListBox.Items.Add(tb); LogListBox.ScrollIntoView(tb); if (LogListBox.Items.Count > 500) { LogListBox.Items.RemoveAt(0); } }
private void GetTextLog(string text) { if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate { LogListBox.Items.Add(text); })); } else { LogListBox.Items.Add(text); } SetTextFile(_fileName, text); }
public void initDevice() { usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB); if (usbDevices.Count != 0) { LogListBox.AppendText("Found " + usbDevices.Count + " USB Devices\n\n"); setDevice(); } //Adding event handlers for device attachment and device removal usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached); usbDevices.DeviceRemoved += new EventHandler(usbDevices_DeviceRemoved); }
/// <summary>Initializes a new instance of the <see cref="LogView"/> class.</summary> public LogView(IWorkingEnvironment environment) : base(LogViewFactory.Guid, environment) { Height = 200; _logListBox = new LogListBox() { BorderStyle = BorderStyle.None, Dock = DockStyle.Fill, Parent = this, }; Text = Resources.StrLog; }
public void LogSay(object sender, DebugLogEventArgs args) { LogEntry newEntry = new LogEntry() { Text = args.Text }; newEntry.Foreground = "Red"; newEntry.Justification = "Right"; App.Current.Dispatcher.Invoke((Action) delegate { _items.Add(newEntry); LogListBox.ScrollIntoView(LogListBox.Items[LogListBox.Items.Count - 1]); }); }
public void Message(string mes) { if (LogListBox.InvokeRequired) { LogListBox.Invoke(new SetMessageDelegate(Message), new object[] { mes }); } else { if (LogListBox.Items.Count > 100) { LogListBox.Items.Clear(); } LogListBox.Items.Add(mes); } }
void usbDevices_DeviceRemoved(object sender, EventArgs e) { LogListBox.AppendText("Removed USB Device\n\n"); //when device is removed, rd/rw thread will be shutdown. tXfers_Read.Abort(); tXfers_Read.Join(); tXfers_Read = null; outEndpoint.Reset(); tXfers_Write.Abort(); tXfers_Write.Join(); tXfers_Write = null; inEndpoint.Reset(); setDevice(); }
/// <summary> /// Log /// </summary> /// <param name="mes"></param> private void Message(string mes) { if (LogListBox.InvokeRequired) { LogListBox.Invoke(new UpdateUiDelegate(Message), new object[] { mes }); } else { if (LogListBox.Items.Count > 100) { LogListBox.Items.RemoveAt(0); } LogListBox.Items.Add(mes); LogListBox.SelectedIndex = LogListBox.Items.Count - 1; } }
/// <summary> /// log /// </summary> /// <param name="mes"></param> private void GetMessage(string mes) { if (InvokeRequired) { LogListBox.Invoke(new AsynUpdateUi(GetMessage), new object[] { mes }); } else { if (LogListBox.Items.Count > 100) { LogListBox.Items.Clear(); } LogListBox.Items.Add(mes); LogListBox.SelectedIndex = LogListBox.Items.Count - 1; } }
private void AddDataInListBox(byte[] data, bool rxOrTx) { if (!LogListBox.CheckAccess()) { LogListBox.Dispatcher.Invoke(new Action <byte[], bool>(AddDataInListBox), data, rxOrTx); } else { string bytes = string.Join(" ", data.Select(i => i.ToString("X2"))); if (rxOrTx) { LogListBox.Items.Add($"{DateTime.Now.ToString("HH:mm:ss")} TI->PC: " + bytes); } else { LogListBox.Items.Add($"{DateTime.Now.ToString("HH:mm:ss")} PC->TI: " + bytes); } } }
private void OnReceiveLogWarningMessage(object sender, OnReceivedLogMessageEventArgs e) { logMessage.Add(new LogItem(e.Message, LOG_TYPE.WARNING)); //coreEngine.SaveLogMessage(e.Message); List <LogItem> warningItem = logMessage.FindAll(o => o.logType == LOG_TYPE.WARNING); if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate() { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); curLogIndex++; } })); warningLogListBox.Invoke(new MethodInvoker(delegate() { while (curWarningIndex < warningItem.Count) { warningLogListBox.Items.Add(warningItem[curWarningIndex].logTxt); curWarningIndex++; } })); } else { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); curLogIndex++; } while (curWarningIndex < warningItem.Count) { warningLogListBox.Items.Add(warningItem[curWarningIndex].logTxt); curWarningIndex++; } } }
private void SendDataButton_Click(object sender, RoutedEventArgs e) { // Tx data 리셋 for (int i = 0; i < 4096; i++) { Tx_data[i] = 0x00000000; } // TxDataListBox 리셋 TxDataListBox.Clear(); // SendDataListBox에 기록된 Data를 Tx_data에 16진수 형태로 담음 for (int i = 0; i < SendDataListBox.Items.Count; i++) // SendDataListBox 아이템 수만큼 반복 { String Databuff = SendDataListBox.Items[i].ToString(); // String으로 전환 TxDataListBox.AppendText(Databuff + "\n"); // TxDataListBox에 추가 LogListBox.AppendText("Send Data : " + Databuff + "\n\n"); // Send Log 추가 Tx_data[i] = Int32.Parse(Databuff, System.Globalization.NumberStyles.HexNumber); // String을 16진수 숫자로 변환하여 Tx_data에 저장 } writeflag = true; }
private void OnReceiveLogErrorMessage(object sender, OnReceivedLogMessageEventArgs e) { logMessage.Add(new LogItem(e.Message, LOG_TYPE.ERROR)); //coreEngine.SaveLogMessage(e.Message); List <LogItem> errorItem = logMessage.FindAll(o => o.logType == LOG_TYPE.ERROR); if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate() { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); //LogListBox.SelectedIndex = LogListBox.Items.Count - 1; curLogIndex++; } //CheckLogLength(); })); errorListBox.Invoke(new MethodInvoker(delegate() { while (curErrorIndex < errorItem.Count) { errorListBox.Items.Add(errorItem[curErrorIndex].logTxt); curErrorIndex++; } })); } else { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); curLogIndex++; } while (curErrorIndex < errorItem.Count) { errorListBox.Items.Add(errorItem[curErrorIndex].logTxt); curErrorIndex++; } } }
public void LogSpeech(object sender, DebugLogEventArgs args) { LogEntry newEntry = new LogEntry() { Text = args.Text }; if (args.Accepted) { newEntry.Foreground = "LightBlue"; } else { newEntry.Foreground = "Khaki"; } newEntry.Justification = "Left"; App.Current.Dispatcher.Invoke((Action) delegate { _items.Add(newEntry); LogListBox.ScrollIntoView(LogListBox.Items[LogListBox.Items.Count - 1]); }); }
public MainWindow(Control.MainController mainController) { _mainController = mainController ?? throw new ArgumentNullException(nameof(mainController)); _logController = _mainController.LogController; InitializeComponent(); DataContext = _mainController.SettingsController; PhoneModelComboBox.ItemsSource = Phone.Models; LogListBox.ItemsSource = _logController.LogEntries; ImageHost.DataContext = _mainController.ImageReformatController; RingtonePathTextBlock.DataContext = _mainController.RingtoneReformatController; //_ringtoneOpenFileDialog.Filter = _mainController.FileFilter.AudioFilter; //_imageOpenFileDialog.Filter = _mainController.FileFilter.ImageFilter; _logController.LogEntries.CollectionChanged += (s, e) => Dispatcher.Invoke(() => LogListBox.ScrollIntoView(_mainController.LogController.LogEntries.Last())); _mainController.RingtoneReformatController.PropertyChanged += (s, e) => { if (e.PropertyName.Equals(nameof(Control.RingtoneReformatController.Ringtone), StringComparison.Ordinal)) { _waveOutEvent.Stop(); } }; _mainController.ImageServerController.Run(); _logController.Log(new Entry(LogSeverity.Info, Strings.StatusReady)); CheckForUpdates(); }
public void setDevice() { int nCurSelection = 0; int nDeviceList = usbDevices.Count; // 기존 데이터가 있으면 비우기 if (ConnectCyUsbComboBox.Items.Count > 0) { nCurSelection = ConnectCyUsbComboBox.SelectedIndex; ConnectCyUsbComboBox.Items.Clear(); ConnectCyUsbInEndpointComboBox.Items.Clear(); ConnectCyUsbOutEndpointComboBox.Items.Clear(); } // 기기 리스트 추가 for (int nCount = 0; nCount < nDeviceList; nCount++) { USBDevice nDevice = usbDevices[nCount]; String DeviceID = "(0x" + nDevice.ProductID.ToString("X4") + ") MITS_US_BOARD Rev1.0"; ConnectCyUsbComboBox.Items.Add(DeviceID); } if (ConnectCyUsbComboBox.Items.Count > 0) { ConnectCyUsbComboBox.SelectedIndex = nCurSelection; loopDevice = usbDevices[ConnectCyUsbComboBox.SelectedIndex] as CyUSBDevice; GetEndpointsOfNode(loopDevice.Tree); // 아이템이 있으면 인덱스 0 if (ConnectCyUsbInEndpointComboBox.Items.Count > 0) { ConnectCyUsbInEndpointComboBox.SelectedIndex = 0; } if (ConnectCyUsbOutEndpointComboBox.Items.Count > 0) { ConnectCyUsbOutEndpointComboBox.SelectedIndex = 0; } // Set the IN and OUT endpoints per the selected radio buttons. ConstructEndpoints(); if ((outEndpoint != null) && (inEndpoint != null)) { if (loopDevice.bSuperSpeed) { xferLen_Write = 16384; xferLen_Read = 16384; } else if (loopDevice.bHighSpeed) { xferLen_Write = 512; xferLen_Read = 512; } string str = string.Format("Data Speed Write : {0} / Read {1}", xferLen_Write, xferLen_Read); LogListBox.AppendText(str); tXfers_Read = new Thread(new ThreadStart(ReadThread)); tXfers_Read.IsBackground = true; tXfers_Read.Priority = ThreadPriority.Highest; tXfers_Write = new Thread(new ThreadStart(WriteThread)); tXfers_Write.IsBackground = true; tXfers_Write.Priority = ThreadPriority.Lowest; tXfers_Read.Start(); tXfers_Write.Start(); LogListBox.AppendText("thstarted"); } } }
void usbDevices_DeviceAttached(object sender, EventArgs e) { LogListBox.AppendText("Connected New USB Device\n\n"); setDevice(); }
private void ResetLogButton_Click(object sender, RoutedEventArgs e) { LogListBox.Clear(); }
private async void SetLikes(CancellationToken token) { File.Delete(Directory.GetCurrentDirectory() + $"/{_fileName}"); if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate { LogListBox.Items.Clear(); })); } else { LogListBox.Items.Clear(); } GetTextLog($"Начало"); if (token.IsCancellationRequested) { return; } var resultsList = _usersList.OrderByDescending(u => u.NumberLikes).ToList(); foreach (var instagramUser in resultsList) { if (instagramUser.LikeSet) { GetTextLog($"Пользователю = {instagramUser.UserName} уже был поставлен лайк"); continue; } if (_numberLikesDay >= 200) { GetTextLog("Достигнут лимит лайков на день"); GetTextLog($"Конец"); return; } var userMediaList = await _instagramClient.GetUserMedia(instagramUser.UserName, 1); var instaMediaForInstaUser = userMediaList?.Value; if (instaMediaForInstaUser != null && instaMediaForInstaUser.Any() && instaMediaForInstaUser.Count >= 2) { foreach (var currentMedia in instaMediaForInstaUser.ToList().Take(2)) { var likeMedia = _instagramClient.LikeMedia(currentMedia.InstaIdentifier).Result.Value; if (likeMedia) { GetTextLog($"Запись: https://www.instagram.com/p/{currentMedia.Code} Пользователь = {instagramUser.UserName}"); instagramUser.LikeSet = true; _saveUsersList = false; GetItemListBox(ActiveFollowersUserslistBox, _usersList); Thread.Sleep(_rand.Next(90000, 150000)); } } } else { instagramUser.LikeSet = true; _saveUsersList = false; GetItemListBox(ActiveFollowersUserslistBox, _usersList); GetTextLog($"У пользователя {instagramUser.UserName} нет публикаций"); _numberLikesDay--; } _numberLikesDay++; SetNumberLikesDayLabel(); Thread.Sleep(_rand.Next(5000, 25000)); } GetTextLog($"Конец"); }
private void LogListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { LogListBox.ScrollIntoView(LogListBox.SelectedItem); }