Esempio n. 1
0
 private void ProcessSourceGroupChange(Common.SignalSourceGroupChangeHolder info)
 {
     if (_viewStatus != null && _viewStatus.View != null && !(_viewStatus.View as DispatcherObject).Dispatcher.CheckAccess())
     {
         (_viewStatus.View as DispatcherObject).Dispatcher.BeginInvoke(new SourceGroupChangeDelegate(ProcessSourceGroupChange), info);
     }
     else
     {
         BaseSourceModel src = null;
         foreach (SourceGroupModel grp in _signalGroups)
         {
             BaseSourceModel tmp = grp.SignalSources.FirstOrDefault(s => s.SignalSourceId == info.SignalSourceId);
             if (tmp != null)
             {
                 src = tmp;
                 grp.SignalSources.Remove(tmp);
                 break;
             }
         }
         if (src != null)
         {
             SourceGroupModel grp = _signalGroups.FirstOrDefault(g => g.GroupId == info.NewGroupId);
             if (grp != null && grp.SignalSources.FirstOrDefault(s => s.SignalSourceId == info.SignalSourceId) == null)
             {
                 grp.AddSignalSourceModelToList(src);
             }
         }
     }
 }
Esempio n. 2
0
        private void ProcessGroupDeleted(Guid id)
        {
            List <BaseSourceModel>  sources = new List <BaseSourceModel>();
            List <SourceGroupModel> grps    = new List <SourceGroupModel>();

            foreach (SourceGroupModel grp in _signalGroups.Where(g => g.GroupId == id))
            {
                grps.Add(grp);
                foreach (BaseSourceModel src in grp.SignalSources)
                {
                    sources.Add(src);
                }
            }
            SourceGroupModel dfltGrp = _signalGroups.FirstOrDefault(g => g.GroupId == Guid.Empty);

            if (dfltGrp == null)
            {
                return;
            }
            foreach (BaseSourceModel src in sources)
            {
                src.SrcInfo.GroupId = Guid.Empty;
                src.GroupInfo       = dfltGrp.GroupInfo;
                dfltGrp.SignalSources.Add(src);
            }
            foreach (SourceGroupModel grp in grps)
            {
                _signalGroups.Remove(grp);
            }
            Common.AppSettings.Instance.SaveSettingsFile();
        }
Esempio n. 3
0
        private void AddSignalGroupToList(Common.SignalGroup grp)
        {
            SourceGroupModel processor = new SourceGroupModel(grp);

            if (processor != null)
            {
                _signalGroups.Add(processor);

                _signalGroups.Sort();
            }
        }
Esempio n. 4
0
        private void AddSignalSourceToList(Common.SignalSource src)
        {
            SourceGroupModel grp = null;

            if (Common.AppSettings.Instance.UseGroups)
            {
                grp = _signalGroups.FirstOrDefault(g => g.GroupId == src.GroupId);
            }
            else
            {
                grp = _signalGroups.FirstOrDefault(g => g.GroupId == Guid.Empty);
            }
            if (grp != null)
            {
                grp.AddSignalSourceToList(src);

                _signalGroups.Sort();
            }
        }
Esempio n. 5
0
        public void ReorderAll()
        {
            int iFeedSortOrder = 10;

            for (int i = 0; i < _signalGroups.Count; i++)
            {
                SourceGroupModel grp = _signalGroups[i];
                grp.DisplayOrder = iFeedSortOrder;
                iFeedSortOrder  += 10;
                for (int j = 0; i < grp.SignalSources.Count; j++)
                {
                    BaseSourceModel src = grp.SignalSources[i];
                    src.DisplayOrder = iFeedSortOrder;
                    iFeedSortOrder  += 10;
                }

                grp.SignalSources.RaiseCollectionChanged();
            }

            this.SignalGroups.RaiseCollectionChanged();

            Common.AppSettings.Instance.SaveSettingsFile();
        }