public static Dictionary <string, string> GetKeysByRegData(string regData) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); string[] temps = regData.Split('{'); if (temps.Length > 1) { for (int i = 1; i < temps.Length; i++) { int endIndex = temps[i].IndexOf('}'); if (endIndex > 0) { string key = temps[i].Substring(0, endIndex).Trim(); if (!string.IsNullOrEmpty(key)) { if (ShowData.CheckKey(key)) { dictionary[key] = "{" + key + "}"; } } } } } return(dictionary); }
private string GetPrintText(string regData) { string text = regData; Dictionary<string, string> keys = ShowData.GetKeysByRegData(regData); foreach (string key in keys.Keys) { text = text.Replace(keys[key], GetTextByKey(key)); } return text; }
/// <summary> /// 判断给定的类型是不是文件路径; /// </summary> private bool IsOnlyFilePath(string regData) { Dictionary<string, string> keys = ShowData.GetKeysByRegData(regData); if (keys.Count != 1) return false; foreach (string key in keys.Keys) { if (key.Equals(ShowData.STR_FILE_PATH) || key.Equals(ShowData.STR_PROJECT_PATH)) return true; } return false; }
/// <summary> /// Set the default print page data /// </summary> /// <param name="datas"></param> private void SetDefaultPageData(ShowDatas datas) { if (null == datas) { return; } txtHeaderLeft.Text = ""; txtHeaderCenter.Text = ShowData.GetShowText(ShowData.STR_FILE_PATH); txtHeaderRight.Text = ""; txtFooterLeft.Text = ShowData.GetShowText(ShowData.STR_DATE_PRINTER); txtFooterCenter.Text = ""; txtFooterRight.Text = ShowData.GetShowText(ShowData.STR_PAGE) + ShowData.GetShowText(ShowData.STR_PAGE_OF); }
private void PopList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (curTextBox != null) { ShowData data = PopList.SelectedValue as ShowData; if (null != data) { int index = curTextBox.SelectionStart; string strHead = curTextBox.Text.Substring(0, index); string strTrail = curTextBox.Text.Substring(index); curTextBox.Text = strHead + data.ShowText + strTrail; curTextBox.SelectionStart = strHead.Length + data.ShowText.Length; } } Pop.IsOpen = false; PopList.UnselectAll(); curTextBox.Focus(); }