static void Main() { Common.InitializeSettings(); // Load properties Common.LoadSettings(); // Create Database if needed CallLog.CreateDatabase(); bool exists = System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Length > 1; if (exists) { FrmTimerMsgBox msg = new FrmTimerMsgBox("App Already Opened", "ELPoup 5 Already Running in System Tray", 4000); msg.ShowDialog(); Application.Exit(); return; } // Setup styles and rendering Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Create main form fMain = new FrmMain(); // Launch main form Application.Run(fMain); }
public void ImportOldDatabase(string filename) { if (!File.Exists(filename)) { return; } DataTable imported_call_log = CallLog.GetCallLog(999999999, filename); FrmTimerMsgBox msg = new FrmTimerMsgBox("Importing Call Log", "Importing", 500000, true); msg.Show(); foreach (DataRow call in imported_call_log.Rows) { Application.DoEvents(); string date_string = call["time"].ToString(); DateTime date = DateTime.ParseExact(date_string, "yyyyMMddHHmmss", null); CallLog.AddCall(call["line"].ToString(), call["type"].ToString(), call["io"].ToString(), call["dur"].ToString(), call["checksum"].ToString(), call["rings"].ToString(), date, call["number"].ToString(), call["name"].ToString(), call["uid"].ToString()); } if (msg.Visible) { msg.Close(); } if (!DO_NOT_UPDATE) { Program.fMain.RefreshCallLog(); } GC.Collect(); GC.WaitForPendingFinalizers(); File.Move(filename, filename.Replace(".db3", "-imported-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "-" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + ".db3")); }
private void btnExportRecords_Click(object sender, EventArgs e) { int records_to_export = (int)ndRecordCount.Value; DataTable records = CallLog.GetCallLog(records_to_export); string export_string = "Date And Time,Number,Name,Duration,Line,IO,Rings" + Environment.NewLine; SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = "Call_Log"; sfd.Filter = "Comma Seperated File|*.csv"; DialogResult r = sfd.ShowDialog(); if (r != DialogResult.Cancel && r != DialogResult.Abort && r != DialogResult.None) { FrmTimerMsgBox fExporting = new FrmTimerMsgBox("Exporting", "Please wait...", 60000 * 10, true); fExporting.Show(); if (File.Exists(sfd.FileName)) { File.Delete(sfd.FileName); } foreach (DataRow record in records.Rows) { Application.DoEvents(); DateTime the_date = Common.GetDateTimeFromSQLiteDate(record["time"].ToString()); // Export into CVS file format export_string += Common.FormatDateToExportCSVFormat(the_date) + ","; export_string += record["number"].ToString() + ","; export_string += "\"" + Common.GetUnsafeSqlString(record["name"].ToString()) + "\","; export_string += "\"" + Common.ConvertDurationToTime(int.Parse(record["dur"].ToString())).Replace(":", ".") + "\","; export_string += record["line"].ToString() + ","; export_string += record["io"].ToString() + ","; export_string += record["rings"].ToString(); export_string += Environment.NewLine; } File.WriteAllText(sfd.FileName, export_string); if (fExporting.Visible) { fExporting.Close(); } } }
public void CopyTextboxText(object sender, EventArgs e) { if (sender is TextBox) { TextBox tb = (TextBox)sender; if (string.IsNullOrEmpty(tb.Text)) { return; } Clipboard.SetText(tb.Text); string type = (tb.Name.ToLower().Contains("number")) ? "Number" : "Name"; FrmTimerMsgBox msg = new FrmTimerMsgBox("Copied " + type, "Copied " + type + " to Clipboard.", 1000); msg.ShowDialog(); } }
private void CopyCallLogMenu(object sender, EventArgs e) { FrmTimerMsgBox msg; switch (LastRowCell[1]) { case DGV_LOG_NUMBER: Clipboard.SetText(dgvCallLog.Rows[LastRowCell[0]].Cells[LastRowCell[1]].Value.ToString()); msg = new FrmTimerMsgBox("Copied", "Copied Number to Clipboard.", 1000); msg.ShowDialog(); break; case DGV_LOG_NAME: Clipboard.SetText(dgvCallLog.Rows[LastRowCell[0]].Cells[LastRowCell[1]].Value.ToString()); msg = new FrmTimerMsgBox("Copied", "Copied Name to Clipboard.", 1000); msg.ShowDialog(); break; } }
private void btnImportOldDatabase_Click(object sender, EventArgs e) { if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\CallerID.com\ELPopup\")) { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\CallerID.com\ELPopup\"; DialogResult r = ofd.ShowDialog(); if (r != DialogResult.OK && r != DialogResult.Yes) { return; } string filename = ofd.FileName; ImportOldDatabase(filename); } else { FrmTimerMsgBox msg = new FrmTimerMsgBox("No Old Database", "Could not find old ELPopup database.", 1500); msg.ShowDialog(); } }
private void btnRefreshSerialList_Click(object sender, EventArgs e) { Program.COM_PORTS.Clear(); cbCOMPorts.Items.Clear(); FrmMain.SerialReceiver.CloseCOMPort(); Program.fMain.SerialReadIn = ""; Program.COM_PORTS.Add("None"); string[] com_ports = SerialPort.GetPortNames(); string found_port_name = ""; FrmTimerMsgBox fPleaseWait = new FrmTimerMsgBox("Searching COM Ports", "Searching COM Ports. Please wait...", 100000); fPleaseWait.Show(); foreach (string port_name in com_ports) { Program.fMain.PortScan = new SerialPort(port_name, 9600, Parity.None, 8, StopBits.One); string found_text = ""; try { Program.fMain.PortScan.DataReceived += new SerialDataReceivedEventHandler(Program.fMain.PortTest); Program.fMain.PortScan.Open(); Program.fMain.PortScan.Write("@"); Program.fMain.PortScan.ReadTimeout = 900; Common.WaitFor(1000); if (Program.fMain.SerialReadIn == "#") { found_port_name = port_name; found_text = " (Unit Detected)"; } Program.fMain.PortScan.Close(); } catch (Exception ex) { Console.Write(ex.ToString()); found_text = " (Another app using COM Port)"; } Program.COM_PORTS.Add(port_name + found_text); } if (fPleaseWait.Visible) { fPleaseWait.Close(); } if (found_port_name != "" && found_port_name != "None") { Program.AppSettings[(int)Program.AppSetting.SS_COM_PORT] = found_port_name; Common.SaveSettings(); } foreach (string port in Program.COM_PORTS) { cbCOMPorts.Items.Add(port); } int port_index = -1; int port_count = 0; foreach (string port in cbCOMPorts.Items) { if (port.Contains(Program.AppSettings[(int)Program.AppSetting.SS_COM_PORT])) { port_index = port_count; break; } port_count++; } if (port_index != -1) { cbCOMPorts.SelectedIndex = port_index; } else { cbCOMPorts.SelectedIndex = 0; } }
public FrmManual(int page = 1) { InitializeComponent(); if (!Directory.Exists(ManualFile)) { Directory.CreateDirectory(ManualFile); } FrmTimerMsgBox fDownloading; if (!File.Exists(ManualFile)) { fDownloading = new FrmTimerMsgBox("Updating Manual", "Downloading Manual from CallerID.com.", 100000); fDownloading.Show(); try { using (WebClient client = new WebClient()) { client.DownloadFile(new Uri("https://secure.callerid.com/downloads/files/ELPopup5_Manual.pdf"), ManualFile + @"\ELPopup5_Manual.pdf"); } } catch (Exception ex) { if (fDownloading.Visible) { fDownloading.Close(); } Console.Write("Failed download: " + ex.ToString()); Common.MessageBox("Manual Download Failed", "Local Manual not found and Remote Manual download failed. Please check Internet Connection.", true, DialogResult.OK, false, DialogResult.None, false, DialogResult.None, "Ok", "", "", 1); } if (fDownloading.Visible) { fDownloading.Close(); } } else { fDownloading = new FrmTimerMsgBox("Updating Manual", "Downloading Manual from CallerID.com.", 100000); fDownloading.Show(); try { using (WebClient client = new WebClient()) { client.DownloadFile(new Uri("https://secure.callerid.com/downloads/files/ELPopup5_Manual.pdf"), ManualFile + @"\ELPopup5_Manual.pdf"); } } catch (Exception ex) { Console.Write("Failed download: " + ex.ToString()); } if (fDownloading.Visible) { fDownloading.Close(); } } GotoPage(page); }