public ProjectXmlInfo() { InitOpenLogFileCommand(); TxtInfo.Document.LineHeight = 3; Messenger.Default.Register <NotificationMessage>(this, s => DispatcherHelper.CheckBeginInvokeOnUI(() => { var status = MessageBoxResult.OK; if (s.Sender is MessageBoxResult) { status = (MessageBoxResult)s.Sender; } var paragraph = new Paragraph(); paragraph.Inlines.Add(new Run(DateTime.Now + ": " + s.Notification) { Foreground = status == MessageBoxResult.OK ? Brushes.Black : Brushes.Red }); TxtInfo.Document.Blocks.Add(paragraph); TxtInfo.ScrollToEnd(); TextLogLineCount++; SaveLog(s.Notification + (status == MessageBoxResult.OK ? "" : "[错误,红色]")); if (TextLogLineCount == 1000) { TextLogLineCount = 0; TxtInfo.Document.Blocks.Clear(); } })); }
/// <summary> /// 显示进度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CopyThread_ProgressChanged(object sender, ProgressChangedEventArgs e) { TxtInfo.AppendText(e.UserState.ToString()); if (e.ProgressPercentage == 10) { BarPross.Value++; } }
/// <summary> /// 写日志到内存 /// </summary> /// <param name="txtFileName">目标文本名(不需要后缀)</param> /// <param name="content">内容</param> public void WriteLog(string txtFileName, params string[] content) { var txt = TxtList.SingleOrDefault(p => p.Key == txtFileName); if (txt == null) { TxtInfo txtInfo = new TxtInfo(txtFileName); TxtList.Add(txtInfo); txt = txtInfo; } txt.WirteLog(content); }
/// <summary> /// Inicializa uma nova instancia da classe <see cref="TxtFieldAttribute" />. /// </summary> /// <param name="tipo"></param> public TxtFieldAttribute(TxtInfo tipo) { Nome = ""; Tipo = tipo; Minimo = 0; Maximo = 0; Ordem = 0; Preenchimento = TxtFill.Esquerda; CaracterPreenchimento = ' '; SeparadorDecimal = '.'; QtdDecimais = 2; Obrigatorio = false; }
private void AddInfo(string info) { TxtInfo.AppendText(info + Environment.NewLine); }
public void UsbDeviceChanged() { if (usbdevice.DevicesCount == 0 && reset_flag) { return; } reset_flag = false; Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo version = FileVersionInfo.GetVersionInfo(assembly.Location); Text = string.Format("TL866 firmware updater V{0} ({1} {2} connected)", version.FileVersion, usbdevice.DevicesCount, usbdevice.DevicesCount == 1 ? "device" : "devices"); if (usbdevice.DevicesCount > 0 && usbdevice.OpenDevice(usbdevice.Get_Devices()[0])) { TL866_Report tl866_report = new TL866_Report(); Get_Report(tl866_report); TxtInfo.Clear(); switch (tl866_report.Device_Version) { case 1: TxtInfo.AppendText("Device version: TL866A\n"); devtype = (int)Firmware.PROGRAMMER_TYPE.TL866A; break; case 2: TxtInfo.AppendText("Device version: TL866CS\n"); devtype = (int)Firmware.PROGRAMMER_TYPE.TL866CS; break; default: TxtInfo.AppendText("Device version: Unknown\n"); break; } switch ((Firmware.DEVICE_STATUS)tl866_report.Device_Status) { case Firmware.DEVICE_STATUS.NORMAL_MODE: TxtInfo.AppendText("Device status: Normal working mode.\n"); LedNorm.BackColor = LightGreen; LedBoot.BackColor = DarkGreen; break; case Firmware.DEVICE_STATUS.BOOTLOADER_MODE: TxtInfo.AppendText("Device status: Bootloader mode <waiting for update.>\n"); LedNorm.BackColor = DarkGreen; LedBoot.BackColor = LightGreen; break; default: TxtInfo.AppendText("Device status: Unknown\n"); LedNorm.BackColor = DarkGreen; LedBoot.BackColor = DarkGreen; break; } bool isDumperActive = IsDumperActive(); if (isDumperActive) { usbdevice.Write(new[] { Firmware.DUMPER_INFO }); Dumper_Report dumper_report = new Dumper_Report(); if (usbdevice.Read(dumper_report.buffer) > 0) { devcode = dumper_report.DeviceCode; serial = dumper_report.SerialCode; } else { devcode = string.Empty; serial = string.Empty; } } else { devcode = tl866_report.DeviceCode; serial = tl866_report.SerialCode; } if (AdvancedWindow != null && !AdvancedWindow.IsDisposed) { GetInfo(); } TxtInfo.AppendText(string.Format("Device code: {0}{1}\n", devcode, Firmware.Calc_CRC(devcode, serial) ? "(Bad device code)" : string.Empty)); TxtInfo.AppendText(string.Format("Serial number: {0}{1}\n", serial, Firmware.Calc_CRC(devcode, serial) ? "(Bad serial code)" : string.Empty)); TxtInfo.AppendText(string.Format("Firmware version: {0}\n", isDumperActive ? "Firmware dumper" : tl866_report.Device_Status == (byte)Firmware.DEVICE_STATUS.NORMAL_MODE ? string.Format("{0}.{1}.{2}", tl866_report.hardware_version, tl866_report.firmware_version_major, tl866_report.firmware_version_minor) : "Bootloader\n")); BtnDump.Enabled = isDumperActive; BtnAdvanced.Enabled = isDumperActive; byte cs = 0; for (int i = 5; i < 8; i++) { cs += (byte)tl866_report.DeviceCode[i]; } for (int i = 0; i < 24; i++) { cs += (byte)tl866_report.SerialCode[i]; } cs += tl866_report.b0; cs += tl866_report.b1; if (tl866_report.firmware_version_minor > 82 && cs != tl866_report.checksum && tl866_report.bad_serial == 0) { TxtInfo.AppendText("Bad serial checksum."); } if (tl866_report.firmware_version_minor > 82 && tl866_report.bad_serial != 0) { TxtInfo.AppendText("Bad serial."); } } else { BtnDump.Enabled = false; BtnAdvanced.Enabled = false; Leds_Off(); TxtInfo.Clear(); devcode = string.Empty; serial = string.Empty; if (AdvancedWindow != null && !AdvancedWindow.IsDisposed) { GetInfo(); } } }
/// <summary> /// Inicializa uma nova instancia da classe <see cref="TxtFieldAttribute" />. /// </summary> /// <param name="nome"></param> /// <param name="type"></param> /// <param name="obrigatorio"></param> public TxtFieldAttribute(string nome, TxtInfo type, bool obrigatorio) : this(type) { Nome = nome; Obrigatorio = obrigatorio; }
/// <summary> /// Inicializa uma nova instancia da classe <see cref="TxtFieldAttribute" />. /// </summary> /// <param name="tipo"></param> /// <param name="obrigatorio"></param> public TxtFieldAttribute(TxtInfo tipo, bool obrigatorio) : this(tipo) { Obrigatorio = obrigatorio; }
/// <summary> /// Inicializa uma nova instancia da classe <see cref="TxtFieldAttribute" />. /// </summary> /// <param name="nome"></param> /// <param name="type"></param> public TxtFieldAttribute(string nome, TxtInfo type) : this(type) { Nome = nome; }
private void ResetFiles() { TxtInfo.Clear(); }