Ejemplo n.º 1
0
        private void m_addTableToWatch_Click(object sender, RoutedEventArgs e)
        {
            if (m_table != null)
            {
                /* Make sure the table we are adding is not in the table */
                if (!dbsets.isInAllSet((string)m_table.Id))
                {
                    /* Start configuration/setup dialog */
                    WatcherSetupDialog wsd = new WatcherSetupDialog((Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + m_table.Name + "-db.txt"), (string)m_table.Id, m_table, false);
                    bool?result            = wsd.ShowDialog();

                    /* Make sure the addition wasn't canceled */
                    if (result.Value == true)
                    {
                        /* Add to working database */
                        dbsets.addToWatchedSets((string)m_table.Id, m_table.Name, (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + m_table.Name + "-db.txt"));

                        /* Save database to file */
                        dbsets.saveToDbFile((Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Properties.Settings.Default.dbfilepath));
                    }

                    /* Refresh working configuration (in case user wants to update the same table again without closing the window) */
                    dbsets = new WatchedSets(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Properties.Settings.Default.dbfilepath);
                }
                else
                {
                    MessageBox.Show("Table is already being watched.");
                }

                /* MessageBox.Show((string)m_table.Id);
                 * using (FileStream fs = File.Open(Properties.Settings.Default.dbfilepath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None))
                 * {
                 *  StreamReader sr = new StreamReader(fs);
                 *  StreamWriter sw = new StreamWriter(fs);
                 *  MessageBox.Show("Worked!");
                 *  bool inTable = false;
                 *  while(!sr.EndOfStream)
                 *  {
                 *      var parts = sr.ReadLine().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                 *      if (parts[0] == (string)m_table.Id)
                 *      {
                 *          inTable = true;
                 *          break;
                 *      }
                 *  }
                 *  if (inTable == false)
                 *  {
                 *      MessageBox.Show("HERE!");
                 *      sw.WriteLine((string)m_table.Id + DELIM + m_table.Name); //Insert configuration file for ImportContent here
                 *      sw.Flush();
                 *  }
                 *  fs.Close();
                 * }*/
            }
        }
Ejemplo n.º 2
0
        void m_editWatchSets_Click(object sender, RoutedEventArgs e)
        {
            /*NamespaceDialog2 nd = new NamespaceDialog2();
             * bool? result = nd.ShowDialog();*/

            if (m_table != null)
            {
                /* Make sure the table we are adding is not in the table */
                if (dbsets.isInAllSet((string)m_table.Id))
                {
                    /* Start configuration/setup dialog */
                    WatcherSetupDialog wsd = new WatcherSetupDialog((Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + m_table.Name + "-db.txt"), (string)m_table.Id, m_table, true);
                    bool?result            = wsd.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Error: Table is not being watched. Perhaps you meant 'Add to Watch'?");
                }
            }
        }