private void Add_Company_Data_click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(txt_compname.Text) || String.IsNullOrEmpty(txt_compaddr.Text)) { MessageBox.Show("Please enter company name and address", application_name); } else { string url_name_config = Folder_Path + "/DataConfig/config_name.txt"; string comp_name = txt_compname.Text; SensorHelper_2.writeTextFile(url_name_config, comp_name); string url_addr_config = Folder_Path + "/DataConfig/config_addr.txt"; string comp_addr = txt_compaddr.Text; SensorHelper_2.writeTextFile(url_addr_config, comp_addr); string url_logo_config = Folder_Path + "/DataConfig/Logo.png"; string filepath = Label_Logo.Content.ToString(); // Stores Original Path in Textbox Uri resourceUri = new Uri(filepath, UriKind.RelativeOrAbsolute); if (!String.IsNullOrEmpty(filepath)) { ImageSource imgsource = new BitmapImage(new Uri(filepath)); File.Copy(filepath, url_logo_config, true); } MessageBox.Show("Company Data successfully saved", application_name); } }
public Report_Window_4() { InitializeComponent(); txt_time.Text = DateTime.Now.ToString("h:mm:ss tt"); txt_date.Text = DateTime.Now.ToString("dd/MM/yyyy"); OpenCon_Port(BaudRate); //MessageBox.Show(BaudRate.ToString(), "Whatwhat"); List <Data_PDFHistory> Sensor1_Histories = new List <Data_PDFHistory> { }; Sensor1_Histories = SensorHelper_2.Read_PDF_History(sensorName); HistoryGrid1.ItemsSource = Sensor1_Histories; if (((MainWindow)Application.Current.MainWindow).RadioBtn_English.IsChecked == true) { Title_Label.Text = "Supplier Name:"; Title_Date.Text = "Date:"; Title_Time.Text = "Time:"; Title_Average.Text = "Average:"; Title_NoMeasure.Text = "No. of Measurement:"; Title_PrintedBy.Text = "Printed By:"; } else { Title_Label.Text = "Nama Supplier:"; Title_Date.Text = "Tanggal:"; Title_Time.Text = "Waktu:"; Title_Average.Text = "Rata-Rata:"; Title_NoMeasure.Text = "Jumlah Pengukuran:"; Title_PrintedBy.Text = "Print Oleh:"; } }
private void Generate_PDF(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(txt_Label.Text)) { MessageBox.Show("Please fill the Label", application_name); //check_data = 0; } else if (String.IsNullOrEmpty(txt_printedby.Text)) { MessageBox.Show("Please fill the Printed by", application_name); //check_data = 0; } else { int PageSize = ((MainWindow)Application.Current.MainWindow).ComboBox_Pagesize.SelectedIndex; int language = 0; if (((MainWindow)Application.Current.MainWindow).RadioBtn_English.IsChecked == false) { language = 1; } //Match match = Regex.Match(txt_Label.Text, @"(?i)^[a-z]+"); // A4 if (PageSize == 0 || PageSize == 2) { SensorHelper_2.Generate_Simple_PDF_A4(txt_Label.Text, sensorName , txt_date.Text, txt_time.Text, txt_average.Text, txt_measure.Text, txt_printedby.Text, data_finals, language); } //A5 else if (PageSize == 1) { SensorHelper_2.Generate_Simple_PDF_A5(txt_Label.Text, sensorName , txt_date.Text, txt_time.Text, txt_average.Text, txt_measure.Text, txt_printedby.Text, data_finals, language); } else { SensorHelper_2.Generate_Simple_PDF_A5_Small(txt_Label.Text, sensorName , txt_date.Text, txt_time.Text, txt_average.Text, txt_measure.Text, txt_printedby.Text, data_finals, language); } //Generate_Simple_PDF(txt_Label.Text, txt_date.Text, txt_time.Text, txt_average.Text, // txt_measure.Text, txt_printedby.Text, data_finals, sensorName); Thread.Sleep(100); Application.Current.Dispatcher.Invoke(new Action(() => { List <Data_PDFHistory> Sensor_Histories = new List <Data_PDFHistory> { }; Sensor_Histories = SensorHelper_2.Read_PDF_History(sensorName); HistoryGrid1.ItemsSource = Sensor_Histories; })); MessageBox.Show("PDF Successfully Created, please check the PDF Folder", application_name); } }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(txt_companyName.Text) || String.IsNullOrEmpty(txt_companyAddress.Text)) { MessageBox.Show("Please enter company name and address", application_name); } else { string url_name_config = Folder_Path + "/DataConfig/config_name.txt"; //string url_name_config = "D:/Sensor_data/DataConfig/config_name.txt"; string comp_name = txt_companyName.Text; SensorHelper_2.writeTextFile(url_name_config, comp_name); //MessageBox.Show("Company name successfully saved", application_name); string url_addr_config = Folder_Path + "/DataConfig/config_addr.txt"; //string url_addr_config = "D:/Sensor_data/DataConfig/config_addr.txt"; string comp_addr = txt_companyAddress.Text; SensorHelper_2.writeTextFile(url_addr_config, comp_addr); //MessageBox.Show("Company address successfully saved", application_name); string url_logo_config = Folder_Path + "/DataConfig/Logo.png"; //string url_logo_config_temp = Folder_Path + "/DataConfig/Logo_temp.png"; string filepath = txt_companyLogo.Text; // Stores Original Path in Textbox Uri resourceUri = new Uri(filepath, UriKind.RelativeOrAbsolute); //((MainWindow)Application.Current.MainWindow).imgDynamic.Source = new BitmapImage(resourceUri); if (!String.IsNullOrEmpty(txt_companyLogo.Text)) { //File.Delete(url_logo_config); ImageSource imgsource = new BitmapImage(new Uri(filepath)); File.Copy(filepath, url_logo_config, true); //File.Copy(url_logo_config, url_logo_config_temp, true); } MessageBox.Show("Company Data successfully saved", application_name); } }
private void Data_Initialize() { var portNames = SerialPort.GetPortNames(); // A4 and A5 page size ComboBox_Pagesize.Items.Clear(); ComboBox_Port1.Items.Clear(); ComboBox_Port2.Items.Clear(); ComboBox_Port3.Items.Clear(); ComboBox_Port4.Items.Clear(); ComboBox_Port5.Items.Clear(); ComboBox_Port6.Items.Clear(); ComboBox_input_data.Items.Clear(); ComboBox_BaudRate1.Items.Clear(); ComboBox_BaudRate2.Items.Clear(); ComboBox_BaudRate3.Items.Clear(); ComboBox_BaudRate4.Items.Clear(); ComboBox_BaudRate5.Items.Clear(); ComboBox_BaudRate6.Items.Clear(); ComboBox_Input_Baud.Items.Clear(); foreach (var portname in portNames) { ComboBox_Port1.Items.Add(portname.ToString()); ComboBox_Port2.Items.Add(portname.ToString()); ComboBox_Port3.Items.Add(portname.ToString()); ComboBox_Port4.Items.Add(portname.ToString()); ComboBox_Port5.Items.Add(portname.ToString()); ComboBox_Port6.Items.Add(portname.ToString()); ComboBox_Port6.Items.Add(portname.ToString()); ComboBox_input_data.Items.Add(portname.ToString()); } List <int> ListBaudRate = new List <int>(new int[] { 110, 300, 600, 1200, 2400, 4800, 9600, 14400 , 19200, 38400, 57600, 115200, 128000 }); List <string> Combobox_Baudrate = ListBaudRate.ConvertAll <string>(delegate(int i) { return(i.ToString()); }); foreach (var Baudrate in Combobox_Baudrate) { ComboBox_BaudRate1.Items.Add(Baudrate); ComboBox_BaudRate2.Items.Add(Baudrate); ComboBox_BaudRate3.Items.Add(Baudrate); ComboBox_BaudRate4.Items.Add(Baudrate); ComboBox_BaudRate5.Items.Add(Baudrate); ComboBox_BaudRate6.Items.Add(Baudrate); ComboBox_Input_Baud.Items.Add(Baudrate); } BitmapImage src = new BitmapImage(new Uri("pack://application:,,,/Resources/Global_Instrument_Logo.jpeg", UriKind.Absolute)); imgDynamic.Source = src; txt_compname.Text = SensorHelper_2.read_config_name(); txt_compaddr.Text = SensorHelper_2.read_config_addr(); //output = (val % 2 == 1) ? "Number is odd" : "Number is even"; if (String.IsNullOrEmpty(txt_compname.Text)) { txt_compname.Text = "Your Company Name"; } if (String.IsNullOrEmpty(txt_compaddr.Text)) { txt_compaddr.Text = "Your Company Address"; } //ComboBox_Pagesize.Items.Add("A4"); //ComboBox_Pagesize.Items.Add("A5"); ComboBox_Pagesize.SelectedValuePath = "Key"; ComboBox_Pagesize.DisplayMemberPath = "Value"; ComboBox_Pagesize.Items.Add(new KeyValuePair <int, string>(0, "A4 Portrait")); ComboBox_Pagesize.Items.Add(new KeyValuePair <int, string>(1, "2 copies of report in PDF (A4)")); ComboBox_Pagesize.Items.Add(new KeyValuePair <int, string>(2, "\"9.5\" x \"11\" (cnt form paper)")); ComboBox_Pagesize.Items.Add(new KeyValuePair <int, string>(3, "\"9.5\" x \"5.5\" (cnt form paper)")); /* * ComboBox_Pagesize.Items.Add("A4 Portrait"); * ComboBox_Pagesize.Items.Add("A5 Landscape"); * ComboBox_Pagesize.Items.Add("A4 Portrait Cnt Paper"); * ComboBox_Pagesize.Items.Add("A5 Landscape Cnt Paper"); */ /* * 1. A4 Portrait * 2. A5 Landscape * 3. A4 Portrait Cnt Paper * 4. A5 Landscape Cnt Paper */ SensorHelper_2.Generate_Initial_Folder(); }
public Company_data_window() { InitializeComponent(); txt_companyName.Text = SensorHelper_2.read_config_name(); txt_companyAddress.Text = SensorHelper_2.read_config_addr(); }
public Report_Window() { InitializeComponent(); txt_time.Text = DateTime.Now.ToString("h:mm:ss tt"); txt_date.Text = DateTime.Now.ToString("dd/MM/yyyy"); OpenCon_Port(BaudRate); //MessageBox.Show(BaudRate.ToString(), "Whatwhat"); List <Data_PDFHistory> Sensor1_Histories = new List <Data_PDFHistory> { }; Sensor1_Histories = SensorHelper_2.Read_PDF_History(sensorName); HistoryGrid1.ItemsSource = Sensor1_Histories; //MessageBox.Show(PageSize.ToString(), "test"); if (((MainWindow)Application.Current.MainWindow).RadioBtn_English.IsChecked == true) { Title_Label.Text = "Supplier Name:"; Title_Date.Text = "Date:"; Title_Time.Text = "Time:"; Title_Average.Text = "Average:"; Title_NoMeasure.Text = "No. of Measurement:"; Title_PrintedBy.Text = "Printed By:"; } else { Title_Label.Text = "Nama Supplier:"; Title_Date.Text = "Tanggal:"; Title_Time.Text = "Waktu:"; Title_Average.Text = "Rata-Rata:"; Title_NoMeasure.Text = "Jumlah Pengukuran:"; Title_PrintedBy.Text = "Print Oleh:"; } /* * SerialPort SendSerialPort = new SerialPort("com7"); * SendSerialPort.BaudRate = BaudRate; * SendSerialPort.Parity = Parity.None; * SendSerialPort.StopBits = StopBits.One; * SendSerialPort.DataBits = 8; * SendSerialPort.Handshake = Handshake.None; * SendSerialPort.RtsEnable = true; * SendSerialPort.ReadBufferSize = 2000000; * SendSerialPort.Encoding = ASCIIEncoding.ASCII; * SendSerialPort.DataReceived += new SerialDataReceivedEventHandler(ProcessSensorData); * SendSerialPort.Open(); * * SendSerialPort.Write("123"); * * //public void Write (byte[] buffer, int offset, int count); * string data = "3232370D0A"; * byte[] hexstring = Encoding.ASCII.GetBytes(data); * foreach (byte hexval in hexstring) * { * byte[] _hexval = new byte[] { hexval }; // need to convert byte * // to byte[] to write * SendSerialPort.Write(_hexval, 0, 1); * Thread.Sleep(2000); * } */ }