Exemplo n.º 1
0
        /// <summary>
        /// 创建便签
        /// </summary>
        /// <param name="path">缓存路径</param>
        /// <param name="imdex"></param>
        /// <param name="oldNotepad"></param>
        public static void CreateNotepad(string path, int imdex, WindowNotepad oldNotepad)
        {
            if (WindowList.Count >= 15)
            {
                MessageBox.Show("便签数据日经达到最大值15个!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (WindowList.Exists(t => t.CacheFileName == path))
            {
                return;
            }

            WindowNotepad      window            = null;
            WindowSettingsAllM windowSettingsAll = ReadSetings();
            string             id       = Path.GetFileNameWithoutExtension(path);
            WindowSettingsM    settings = windowSettingsAll?.WindowSettingses.Find(t => t.ID == id);

            if (settings == null)
            {
                settings = GetDefaultWindowSettingsM(id);
            }

            window = new WindowNotepad(settings);
            SetTop(window, oldNotepad);
            window.Show();
            WindowList.Add(window);
            ShowWindowListCount++;
            WindowListCount++;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存所有便签设置
        /// </summary>
        public static void SaveSetings(WindowNotepad windowNotepad = null)
        {
            WindowSettingsAllM windowSettingsAll = ReadSetings();

            if (windowSettingsAll == null)
            {
                windowSettingsAll = new WindowSettingsAllM();
            }
            if (windowSettingsAll.WindowSettingses == null)
            {
                windowSettingsAll.WindowSettingses = new List <WindowSettingsM>();
            }

            windowSettingsAll.SystemSetting = SystemSetting;

            List <WindowNotepad> list;

            if (windowNotepad != null)
            {
                list = WindowList.FindAll(m => m.WindowSettings.ID == windowNotepad.WindowSettings.ID);
            }
            else
            {
                list = WindowList;
            }
            foreach (WindowNotepad notepad in list)
            {
                notepad.WindowSettings.Top           = notepad.Top;
                notepad.WindowSettings.Left          = notepad.Left;
                notepad.WindowSettings.BackColorName = notepad.SkinM.Name;
                notepad.WindowSettings.Width         = notepad.Width;
                notepad.WindowSettings.Height        = notepad.Height;

                //替换为新设置
                int index = windowSettingsAll.WindowSettingses.FindIndex(t => t.ID == notepad.WindowSettings.ID);
                if (index > 0)
                {
                    windowSettingsAll.WindowSettingses.RemoveAt(index);
                }

                windowSettingsAll.WindowSettingses.Add(notepad.WindowSettings);
            }

            XMLSerializer.Serializer(windowSettingsAll);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置便签
        /// </summary>
        /// <param name="window"></param>
        public static void SetWindowNotepad(WindowNotepad window)
        {
            WindowSettingsAllM windowSettingsAll = ReadSetings();

            if (windowSettingsAll == null)
            {
                return;
            }
            //if (_systemSetting == null && windowSettingsAll.SystemSetting != null)
            //    _systemSetting = windowSettingsAll.SystemSetting;
            WindowSettingsM settings = windowSettingsAll.WindowSettingses.Find(t => t.ID == window.WindowSettings.ID);

            if (settings != null)
            {
                window.WindowSettings = settings;
                window.SkinM          = new SkinManage().GetSkin(settings.BackColorName);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 打开所有便签
        /// </summary>
        public static void OpenAllNotepad()
        {
            _isActivatedNotepad = true;
            List <string> files = new List <string>(Directory.GetFiles(RichTextBoxTool.PathCacheVisible, SystemCommon.SearchExtensionName));

            //如果没有便签,则打开一个空的。
            if (files.Count == 0)
            {
                CreateNotepad();
                return;
            }

            WindowSettingsAllM windowSettingsAll = ReadSetings();

            foreach (string s in files)
            {
                CreateNotepad(Path.GetFileNameWithoutExtension(s), windowSettingsAll?.WindowSettingses);
            }
            _isActivatedNotepad = false;

            // ActivatedNotepad();
        }