Example #1
0
        /// <summary>
        /// 转换为用于插入的语句
        /// </summary>
        /// <param name="toolConfig"></param>
        /// <returns></returns>
        private static string ConvertToolItem(StoreItemConfig toolConfig)
        {
            var cfg     = CurrentStoreConfig;
            var content = toolConfig.Content;

            if (string.IsNullOrEmpty(content))
            {
                return(content);
            }
            var tf = cfg.TimeFormat;

            if (tf == null || string.IsNullOrEmpty(tf))
            {
                tf = "yyyy-MM-dd HH:mm:ss";
            }
            content = content.Replace("@company", cfg.CompanyName);
            content = content.Replace("@yourname", cfg.YourName);
            content = content.Replace("@year", DateTime.Now.Year.ToString());
            content = content.Replace("@time", DateTime.Now.ToString(tf));
            //修正换行不对问题
            if (content.Contains("\r\n"))
            {
                content.Replace("\r\n", Environment.NewLine);
            }
            else if (content.Contains("\n"))
            {
                content.Replace("\n", Environment.NewLine);
            }

            return(content);
        }
        /// <summary>
        /// Add
        /// </summary>
        private void CmdAdd()
        {
            var key  = txtInput.Text.Trim();
            var cfg  = CopyrightCore.CurrentStoreConfig;
            var curr = cfg.GetItemByKey(key);

            if (curr != null)
            {
                MessageBox.Show("不能添加重复的Key!");
                return;
            }
            var it = new StoreItemConfig()
            {
                Content = txtContent.Text,
                Key     = key,
            };

            cfg.Configs.Insert(0, it);
            lbType.Items.Insert(0, key);
            lbType.SelectedIndex = 0;
        }
Example #3
0
        /// <summary>
        /// 生成默认配置
        /// </summary>
        /// <returns></returns>
        private static StoreConfig GetDefaultConfig()
        {
            var cfg = new StoreConfig()
            {
                YourName    = "Your Name",
                CompanyName = "Your Company",
            };

            cfg.Configs = new List <StoreItemConfig>();
            var it = new StoreItemConfig()
            {
                Key = "*.*",
            };

            it.Content = @"//===================================================
//  Copyright @  @company @year
//  作者:@yourname
//  时间:@time
//  说明:
//===================================================
";
            cfg.Configs.Add(it);
            return(cfg);
        }