/// <summary>
        /// 直接增加一项,这里肯定是增加光谱文件名
        /// </summary>
        /// <param name="itemName"></param>
        /// <param name="isSelected"></param>
        /// <param name="data"></param>
        public void AddItem(string itemName, bool isSelected, object data = null)
        {
            //查找是否已经加载了
            if (data == null)
            {
                data = itemName;
            }
            if (FileListData.FirstOrDefault(subitem => subitem.Tag == data) != null)
            {
                return;
            }

            int index = FileListData.Count;
            StringAndColorList item = new StringAndColorList(itemName, AllColorList[index % AllColorList.Length], data);

            FileListData.Add(item);
            ListFile.SelectedIndex = ListFile.Items.Count - 1;
            ListFile.ScrollIntoView(item);
            ListFile.Items.Refresh();

            if (isSelected)
            {
                item.IsChecked = isSelected;
            }
        }
        private void ListItem_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            StringAndColorList selitem = GetItemOnClick(sender as Grid);

            selitem.IsChecked = true;

            //RaiseCheckedEvent();
        }
        /// <summary>
        /// 替换项目
        /// </summary>
        /// <param name="oldTag"></param>
        /// <param name="newName"></param>
        /// <param name="newTag"></param>
        public void ReplaceItem(string oldTag, string newName, string newTag)
        {
            StringAndColorList listitem = FileListData.First(item => (string)item.Tag == oldTag);

            if (listitem != null)
            {
                listitem.Name = newName;
                listitem.Tag  = newTag;
            }
        }
        /// <summary>
        /// 清除一项
        /// </summary>
        /// <param name="seldata"></param>
        public void RemoveItem(object seldata)
        {
            StringAndColorList item = FileListData.FirstOrDefault(subitem => subitem.Tag == seldata);

            if (item != null)
            {
                FileListData.Remove(item);
                ListFile.Items.Refresh();
                RaiseCheckedEvent();
            }
        }
        private void ListFile_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ListFile.SelectedIndex < 0)
            {
                return;
            }

            StringAndColorList selitem = FileListData[ListFile.SelectedIndex];

            selitem.IsChecked = true;
            //RaiseCheckedEvent();
        }
        /// <summary>
        /// 增加多项,这里肯定是增加光谱文件名
        /// </summary>
        /// <param name="itemNames"></param>
        /// <param name="isSelected"></param>
        /// <param name="datas"></param>
        /// <param name="clear"></param>
        public void AddItem(List <string> itemNames, bool isSelected, List <object> datas, bool clear)
        {
            if (itemNames == null)
            {
                RemoveAllItems();
                return;
            }

            if (datas == null)
            {
                datas = new List <object>();
                foreach (string str in itemNames)
                {
                    datas.Add(str);
                }
            }
            if (datas.Count != itemNames.Count)
            {
                return;
            }

            //需要删除没有在itemNames列表中的项
            if (clear)
            {
                List <object> tempData = new List <object>();
                foreach (StringAndColorList item in FileListData)
                {
                    if (!datas.Exists(subdata => item.Tag == subdata))
                    {
                        tempData.Add(item.Tag);
                    }
                }
                RemoveItem(tempData);
            }

            for (int i = 0; i < itemNames.Count; i++)
            {
                //查找是否已经加载了
                if (FileListData.FirstOrDefault(olditem => olditem.Tag == datas[i]) != null)
                {
                    continue;
                }

                int index = FileListData.Count;

                StringAndColorList newdata = new StringAndColorList(itemNames[i], AllColorList[index % AllColorList.Length], datas[i]);

                FileListData.Add(newdata);
            }
            ListFile.SelectedIndex = ListFile.Items.Count - 1;
            ListFile.Items.Refresh();
            RaiseCheckedEvent();
        }
 /// <summary>
 /// 一次清除多项
 /// </summary>
 /// <param name="selDatas"></param>
 public void RemoveItem(List <object> selDatas)
 {
     foreach (object data in selDatas)
     {
         StringAndColorList item = FileListData.FirstOrDefault(subitem => subitem.Tag == data);
         if (item != null)
         {
             FileListData.Remove(item);
         }
     }
     ListFile.Items.Refresh();
     RaiseCheckedEvent();
 }
        /// <summary>
        /// 选择指定项目
        /// </summary>
        /// <param name="seldata"></param>
        public void SelectOneItem(object seldata)
        {
            StringAndColorList selitem = FileListData.FirstOrDefault(item => seldata == item.Tag);

            if (selitem != null)
            {
                foreach (StringAndColorList item in FileListData)
                {
                    item.IsChecked = false;
                }

                selitem.IsChecked = true;
                int index = FileListData.IndexOf(selitem);
                if (index >= 0)
                {
                    ListFile.SelectedIndex = index;
                }

                RaiseCheckedEvent();
            }
        }