예제 #1
0
        //--------------------------------------------------------------------------------
        //
        //      exporting
        //
        //--------------------------------------------------------------------------------

        private void exportData()
        {
            //build string data
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("ID,Start Time,Duration,Tag,Comments");
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                Session session = DatabaseResultMapper.rowToSession(dataTable.Rows[i]);
                builder.AppendLine(session.toExportString());
            }
            //save data to file
            string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + Path.DirectorySeparatorChar + "TimeLogger export data.csv";

            File.WriteAllText(path, builder.ToString());
            //show confirmation message
            MessageBox.Show("Data exported to:\n" + path, "Complete", MessageBoxButton.OK, MessageBoxImage.Information);
        }
예제 #2
0
        private void selectionChangedHandler(object sender, SelectionChangedEventArgs e)
        {
            //if no selection, exit
            if (e.AddedItems.Count == 0)
            {
                return;
            }

            //find selected row
            DataRow row = (e.AddedItems[0] as DataRowView).Row;
            //get data from row
            Session session = DatabaseResultMapper.rowToSession(row);

            //dispatch event
            if (session != null)
            {
                openSessionPanelRequest?.Invoke(session);
            }
        }