/// <summary>
        /// 列表选择变更消息
        /// </summary>
        private void gridSpectrum_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (selectChangeFromChart == false && newGraphicChart != null)
            {
                List <Guid> sels = new List <Guid>();
                foreach (var item in gridSpectrum.SelectedItems)
                {
                    ColorChartDisplayInfo info = item as ColorChartDisplayInfo;
                    if (info.isChecked)
                    {
                        sels.Add(info.key);
                    }
                }
                newGraphicChart.SelectedItems = sels;
            }

            SelectionChangedEventArgs arg = null;

            if (gridSpectrum.SelectedItem == null)
            {
                arg = new SelectionChangedEventArgs(ItemSelectedEvent, new List <ColorChartDisplayInfo>(), new List <ColorChartDisplayInfo>());
            }
            else
            {
                arg = new SelectionChangedEventArgs(ItemSelectedEvent, new List <ColorChartDisplayInfo>(), new List <ColorChartDisplayInfo>()
                {
                    (ColorChartDisplayInfo)gridSpectrum.SelectedItem
                });
            }

            RaiseEvent(arg);
        }
        /// <summary>
        /// 显示或者隐藏光谱图形
        /// </summary>
        void spectrumData_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            ColorChartDisplayInfo info = sender as ColorChartDisplayInfo;

            if (e.PropertyName == "isChecked")
            {
                if (newGraphicChart != null)
                {
                    //要有读入的光谱数据才能添加
                    if (info.isChecked && info.xDatas != null && info.yDatas != null)
                    {
                        newGraphicChart.AddChart(info.xDatas, info.yDatas, info.color, info.key, info.name, info.dataDisplayFormat);
                    }
                    else
                    {
                        newGraphicChart.RemoveChart(info.key);
                    }
                    newGraphicChart.Refresh();  //需要刷新一下
                }

                //headerVisibleChecker.Checked -= visibleChecker_Checked;
                //headerVisibleChecker.Unchecked -= visibleChecker_Checked;   // visibleChecker_Unchecked;
                //headerVisibleChecker.IsChecked = (from item in spectrumFileList where item.isChecked select item).Count() > 0;
                //headerVisibleChecker.Checked += visibleChecker_Checked;
                //headerVisibleChecker.Unchecked += visibleChecker_Checked;   //visibleChecker_Unchecked;
            }
        }
 /// <summary>
 /// 选中一个Item,并自动将其滚动到可见区域
 /// </summary>
 /// <param name="item"></param>
 public void SelectItem(ColorChartDisplayInfo item)
 {
     gridSpectrum.SelectedItem = item;
     if (gridSpectrum.SelectedItem != null)
     {
         gridSpectrum.UpdateLayout();
         gridSpectrum.ScrollIntoView(gridSpectrum.SelectedItem);
     }
 }
        /// <summary>
        /// 移除列表中的当前项目
        /// </summary>
        private void CellRemoveItem_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (btn.Tag != null && btn.Tag is ColorChartDisplayInfo)
            {
                ColorChartDisplayInfo item = btn.Tag as ColorChartDisplayInfo;

                //发送项目移除消息
                SelectionChangedEventArgs arg = new SelectionChangedEventArgs(ItemRemovedEvent, new List <ColorChartDisplayInfo>()
                {
                    item
                }, null);
                RaiseEvent(arg);

                spectrumFileList.Remove(item);
            }
        }
        /// <summary>
        /// 刷新一个项
        /// </summary>
        /// <param name="item"></param>
        /// <param name="refreshRightNow">是否立即刷新图形</param>
        public void RefreshItem(ColorChartDisplayInfo item, bool refreshRightNow = true)
        {
            if (spectrumFileList.IndexOf(item) == -1)
            {
                return;
            }

            newGraphicChart.RemoveChart(item.key);
            if (item.isChecked == false)
            {
                return;
            }

            newGraphicChart.AddChart(item.xDatas, item.yDatas, item.color, item.key, item.name, item.dataDisplayFormat);
            if (refreshRightNow)
            {
                newGraphicChart.Refresh();
            }
        }
        /// <summary>
        /// 修改显示颜色窗口关闭
        /// </summary>
        void colorPop_Closed(object sender, EventArgs e)
        {
            ColorPicker colorPop = sender as ColorPicker;

            if (colorPop == null || colorPop.selectedBursh == null)
            {
                return;
            }

            if (!colorChangeFromHeader)     //只改变一个文件,文件在 colorPop.Tag 中
            {
                ColorChartDisplayInfo item = colorPop.Tag as ColorChartDisplayInfo;
                if (item == null || spectrumFileList.IndexOf(item) < 0)
                {
                    return;
                }

                item.color = (SolidColorBrush)colorPop.selectedBursh;
                if (newGraphicChart != null)
                {
                    newGraphicChart.ChangeColor(item.key, item.color);
                    newGraphicChart.Refresh();  //需要刷新一下
                }
            }
            else    //改变选中文件
            {
                foreach (var item in gridSpectrum.SelectedItems)
                {
                    ColorChartDisplayInfo info = item as ColorChartDisplayInfo;
                    info.color = (SolidColorBrush)colorPop.selectedBursh;
                    if (newGraphicChart != null)
                    {
                        newGraphicChart.ChangeColor(info.key, info.color);
                    }
                }
                if (newGraphicChart != null && gridSpectrum.SelectedItems.Count > 0)
                {
                    newGraphicChart.Refresh();
                }
            }
        }
        /// <summary>
        /// 文件列表变化消息
        /// </summary>
        void spectrumFileList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            ObservableCollection <ColorChartDisplayInfo> filelist = sender as ObservableCollection <ColorChartDisplayInfo>;

            switch (e.Action)
            {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                if (e.NewItems != null)
                {
                    foreach (var item in e.NewItems)
                    {
                        ColorChartDisplayInfo info = item as ColorChartDisplayInfo;
                        if (info.color == null)
                        {
                            info.color = ColorChartDisplayInfo.GetDisplayColor(filelist.IndexOf(info));
                        }
                        info.PropertyChanged += spectrumData_PropertyChanged;

                        if (info.isChecked && info.xDatas != null && info.yDatas != null)
                        {
                            if (newGraphicChart != null)
                            {
                                newGraphicChart.AddChart(info.xDatas, info.yDatas, info.color, info.key, info.name, info.dataDisplayFormat);
                            }
                        }
                    }
                    if (newGraphicChart != null && e.NewItems.Count > 0)        //需要刷新一下
                    {
                        newGraphicChart.Refresh();
                    }
                }
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                if (e.OldItems != null)
                {
                    foreach (var item in e.OldItems)
                    {
                        ColorChartDisplayInfo info = item as ColorChartDisplayInfo;
                        if (newGraphicChart != null)
                        {
                            newGraphicChart.RemoveChart(info.key);
                        }
                    }
                    if (newGraphicChart != null && e.OldItems.Count > 0)        //需要刷新一下
                    {
                        newGraphicChart.Refresh();
                    }
                }
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                if (e.OldItems != null)
                {
                    foreach (var item in e.OldItems)
                    {
                        ColorChartDisplayInfo info = item as ColorChartDisplayInfo;
                        if (newGraphicChart != null)
                        {
                            newGraphicChart.RemoveChart(info.key);
                        }
                    }
                }
                if (e.NewItems != null)
                {
                    foreach (var item in e.NewItems)
                    {
                        ColorChartDisplayInfo info = item as ColorChartDisplayInfo;
                        if (info.color == null)
                        {
                            info.color = ColorChartDisplayInfo.GetDisplayColor(filelist.IndexOf(info));
                        }
                        info.PropertyChanged += spectrumData_PropertyChanged;

                        if (info.isChecked && info.xDatas != null && info.yDatas != null)
                        {
                            if (newGraphicChart != null)
                            {
                                newGraphicChart.AddChart(info.xDatas, info.yDatas, info.color, info.key, info.name, info.dataDisplayFormat);
                            }
                        }
                    }
                }
                if (newGraphicChart != null && (e.NewItems.Count > 0 || e.OldItems.Count > 0))      //需要刷新一下
                {
                    newGraphicChart.Refresh();
                }
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                if (newGraphicChart != null)
                {
                    newGraphicChart.RemoveAllChart();
                    newGraphicChart.Refresh();
                }
                break;

            default:
                break;
            }
        }
 /// <summary>
 /// 设置一个新增项的属性变更通知消息
 /// </summary>
 /// <param name="item"></param>
 public void SetPropertyChangeEventtemp(ColorChartDisplayInfo item)
 {
     item.PropertyChanged += spectrumData_PropertyChanged;
 }