示例#1
0
        /// <summary>
        /// Open collector window
        /// </summary>
        public void OpenAddCollectorDialog()
        {
            if (_group == null || _group.Length < 1 || _indiv == null | _indiv.Length < 1)
            {
                return;
            }

            var dialog = new Dialog.Dialog();

            dialog.Title        = "Add New Data Collector";
            dialog.QuestionText = "Please give a name to the new data collector.";

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    string mKeySetName = dialog.ResponseText;

                    collectorListViewModel.AllCollectors.Add(Collector.CreateCollector(mKeySetName));

                    using (StreamWriter file = new StreamWriter(Path.Combine(Properties.Settings.Default.SaveLocation, _group, _indiv, "DataCollectors.json"), false))
                    {
                        Collectors mCollector = new Collectors();
                        mCollector.DataCollectors = collectorListViewModel.AllCollectors;
                        file.WriteLine(JsonConvert.SerializeObject(mCollector));
                    }

                    MessageBox.Show("Successfully added: " + dialog.ResponseText);
                }
                catch (IOException e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }