Пример #1
0
 /// <summary>
 /// 保存数据到注册表
 /// </summary>
 /// <returns></returns>
 public bool Save()
 {
     try
     {
         REGISTRY.SetData(ViewId.ToString(), new ViewSettingData(this));
         return(true);
     }
     catch { return(false); }
 }
Пример #2
0
        /// <summary>
        /// 删除选中项事件
        /// </summary>
        private void DeleteSelectNoteBtn_Click(object sender, RoutedEventArgs e)
        {
            if (this.dataGrid.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选中某项再执行操作!", "提示"); return;
            }
            ;                                                                                             //判断是否有选中项,否则退出
            if (MessageBox.Show("你确定要删除选中的便签?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;                                    //弹出提示,如果确定则删除,否则退出
            }
            var selectItems = this.dataGrid.SelectedItems; //获取选中的所有Item

            foreach (var item in selectItems)
            {
                DataModel      dataModel = item as DataModel;        //转换对象
                StickyNoteView noteView  = dataModel.StickyNoteView; //获取窗口,进行操作
                REGISTRY.Delete(noteView.ViewId.ToString());
                Window.EmptySlots.Enqueue(noteView.ViewId);          //去除集合中的项
                noteView.Close();
            }
            LoadAllNoteView();//重新加载标签数据
        }
Пример #3
0
        /// <summary>
        /// 加载所有的便签页面
        /// </summary>
        private static void LoadAllStickyNoteView()
        {
            List <ViewSettingData> viewSettingDataList = new List <ViewSettingData>();

            foreach (string id in REGISTRY.OPENED_NOTES)
            {
                object val = REGISTRY.GetData(id);
                if (val != null)
                {
                    viewSettingDataList.Add((ViewSettingData)val);             //将数据加入集合中
                }
            }
            ViewId = 1;
            foreach (ViewSettingData dat in viewSettingDataList)
            {
                AddNewStickyNoteView(dat);
            }
            if (ViewId == 1)
            {
                AddNewStickyNoteView();
            }
            REGISTRY.DeleteAll();
            SaveAllNotes();
        }