Beispiel #1
0
        private void DataWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var s = new MyUserSettings();

            s.Isprefixfilterenabled = FilterEnable.Value;
            s.Filters = JsonSerializer.Serialize(Filters.ToArray());
            s.Save();
            MessageBox.Show("You must restart the application for changes to take effect.", "FYI", MessageBoxButton.OK, MessageBoxImage.Asterisk);
        }
Beispiel #2
0
        public Settings()
        {
            InitializeComponent();
            var s = new MyUserSettings();

            Filters            = new ObservableCollection <string>(JsonSerializer.Deserialize <string[]>(s.Filters));
            FilterEnable.Value = s.Isprefixfilterenabled;
            DataContext        = this;
        }
        public MainWindow()
        {
            var myoption = new MyUserSettings();

            InitializeComponent();
            Mainwin.Title           = "TimeGather is collecting data...";
            Servermodelsdatacontext = new ServerModels();
            Servermodelsdatacontext.ServerModelList = new ObservableCollection <ServerModel>();
            Enableprefixfilter.Value = myoption.Isprefixfilterenabled;

            //StringCollection prefixes = myoption.Filters;
            //if (prefixes == null || prefixes.Count == 0)
            //{
            //    prefixes = new StringCollection() { "prefix1", "prefix2" };
            //    Properties.Settings.Default["prefixes"] = prefixes;
            //    Properties.Settings.Default.Save();
            //}

            //Loading = new ServerModel() { Name = "Loading..." };
            ServerModelsDG.DataContext = Servermodelsdatacontext.ServerModelList;
            //_servermodelsdatacontext.ServerModelList.Add(Loading);
            var computers = GetComputer.GetComputers();

            TimeQueryActionBlock = new ActionBlock <ServerModel>(sm =>
            {
                ServerModel temp = ServerModel.Updatethesecondsoffset(sm);
                var tq           = new TimeQuery();
                temp.Source      = tq.GetTimeSource(temp.Name);
                Application.Current.Dispatcher.BeginInvoke(new Action(() => this.Servermodelsdatacontext.ServerModelList.Add(temp)));
            }, new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = 128
            }
                                                                 );

            if (Enableprefixfilter.Value)
            {
                var f = JsonSerializer.Deserialize <string[]>(myoption.Filters);
                computers = (from pc in computers
                             where FilterByPrefix(pc, f) == true
                             select pc).ToList();
            }
            foreach (var s in computers)
            {
                TimeQueryActionBlock.Post(s);
            }
            TimeQueryActionBlock.Complete();

            //servermodelsdatacontext.ServerModelList = (from comp in computers.AsParallel()
            //                 select (ServerModel)Updatethesecondsoffset(comp)).ToList();
            //ServerModelsDG.DataContext = servermodelsdatacontext.ServerModelList;
        }