/// <summary>
        /// Save
        /// </summary>
        private void CmdSave()
        {
            var cfg        = CopyrightCore.CurrentStoreConfig;
            var selectItem = lbType.SelectedItem.ToString();
            var it         = cfg.GetItemByKey(selectItem);

            if (it != null)
            {
                it.Content = txtContent.Text;
            }
            cfg.CompanyName   = txtCompanyName.Text.Trim();
            cfg.YourName      = txtYourName.Text.Trim();
            cfg.IsInsertToTop = cbIsInsertToTop.IsChecked == true;
            var tf = txtTimeFormat.Text.Trim();

            if (!string.IsNullOrEmpty(tf))
            {
                try
                {
                    var t = DateTime.Now.ToString(tf);
                }
                catch
                {
                    MessageBox.Show(Properties.Resources.Err_TimeFormat);
                    return;
                }
            }
            cfg.TimeFormat = tf;

            CopyrightCore.Save();
        }
        public void TestGetContentByExtension()
        {
            CopyrightCore.Load();
            var txt = CopyrightCore.GetContentByExtension(".cs");

            Assert.IsNotNull(txt);
        }
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            //获取服务,这玩意儿……可以理解为vs的服务对象吧。
            var dte       = this.ServiceProvider.GetService(typeof(DTE)) as DTE;
            var selection = dte.ActiveDocument.Selection as TextSelection;

            if (selection == null)
            {
                return;
            }
            //获取拓展名
            var ext = Path.GetExtension(dte.ActiveDocument.FullName);

            //删除所选内容
            if (!selection.IsEmpty)
            {
                selection.Delete();
            }

            var txt = CopyrightCore.GetContentByExtension(ext);

            if (txt == null)
            {
                return;
            }
            //Insert to top
            if (CopyrightCore.CurrentStoreConfig.IsInsertToTop)
            {
                selection.StartOfDocument();
            }
            selection.Insert(txt);

            //selection.Insert("//Demo test~~~" + Environment.NewLine + "//Test line 2");
        }
        private void WinLoaded(object sender, RoutedEventArgs e)
        {
            InitControls();

            lblVersion.Text = Constants.FileVersion;

            CopyrightCore.Load();
            var cfg = CopyrightCore.CurrentStoreConfig;

            txtCompanyName.Text       = cfg.CompanyName;
            txtYourName.Text          = cfg.YourName;
            cbIsInsertToTop.IsChecked = cfg.IsInsertToTop;
            txtTimeFormat.Text        = cfg.TimeFormat;

            BindTypeList();

            lbType.SelectedIndex = 0;
        }
 public void TestSave()
 {
     CopyrightCore.Save();
 }
 public void TestLoad()
 {
     CopyrightCore.Load();
 }