/// <summary> /// 可见性 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="inControl"></param> /// <param name="text"></param> public static void SetD18 <T>(this T inControl, string text) where T : IControl { if (string.IsNullOrEmpty(text)) { } (inControl as FrameworkElement).Visibility = CommonConverter.StringToBool(text) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; }
/// <summary> /// 设置行高 /// </summary> /// <param name="text"></param> public void SetD19(string text) { if (!string.IsNullOrEmpty(text)) { MyDataGrid.RowHeight = CommonConverter.StringToInt(text); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string uristring = value as string; if (string.IsNullOrEmpty(uristring)) { return(CommonConverter.ImageToBitMapImage(Properties.Resources.picture)); } if (!uristring.StartsWith("http")) { uristring = ConfigManagerSection.serverUrl + uristring; } if (LocalCacher._ListCachedPhoto.ContainsKey(uristring)) { return(LocalCacher._ListCachedPhoto[uristring]); } BitmapImage img = new BitmapImage(new Uri(uristring, UriKind.RelativeOrAbsolute)); if (!object.Equals(img, null)) { LocalCacher._ListCachedPhoto.Add(uristring, img); return(img); } else if (object.Equals(img, null)) { return(CommonConverter.ImageToBitMapImage(Properties.Resources.picture)); } else { return(img); } //return new BitmapImage(new Uri(uristring, UriKind.RelativeOrAbsolute)); }
/// <summary> /// 获取该页面所有版本 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnGetPageVersionClick(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtPageId.Text) && CommonConverter.StringToInt(txtPageId.Text) != -1) { RefreshDataGrid(txtPageId.Text); } }
/// <summary> /// 解析右半边部分 /// </summary> /// <param name="rightPart"></param> /// <param name="control"></param> private void DecodeRightPart(string rightPart, DecoderOfControl control) { //先看看简单的情况 if (!rightPart.StartsWith("{")) { control.RightDirectValue = rightPart; } else { //右边也包含控件ID的情况 string pattern = @"{(.*)}"; string trimPattern = Regex.Match(rightPart, pattern).Groups[1].ToString(); string[] rightpart = trimPattern.Split('.'); DecoderOfControl obj = new DecoderOfControl(); obj.CtrlId = CommonConverter.StringToInt(rightpart[0]); //obj.LeftCtrlProperty = rightpart[1]; if (Regex.IsMatch(trimPattern, @"\d+.a\d+[(]\w*[)]")) { //取参数值 obj.Patameter = Regex.Match(trimPattern, @"[(](.*)[)]").Groups[1].ToString(); obj.LeftCtrlProperty = rightpart[1].Replace(Regex.Match(trimPattern, @"[(](.*)[)]").Groups[0].ToString(), string.Empty); } else { obj.LeftCtrlProperty = rightpart[1]; } control.RightDirectValue = obj; } }
private List <Post> GetPostsFromSession() { try { List <Post> posts = new List <Post>(); object json; TempData.TryGetValue("blogPosts", out json); if (json == null || string.IsNullOrEmpty(json.ToString())) { posts = postsService.GetAll(); TempData["blogPosts"] = (posts == null ? "" : CommonConverter.SerializeObject(posts)); } else { posts = CommonConverter.DeserializeObject <List <Post> >(json.ToString()); } if (posts == null) { posts = new List <Post>(); } return(posts); } catch (Exception ex) { return(new List <Post>()); } }
/// <summary> /// 刷新版本列表 /// </summary> /// <param name="pageId"></param> private async void RefreshDataGrid(string pageId) { var listpageresult = await _pageConnection.GetPageGroupInfo(pageId); listpageresult = listpageresult.OrderBy(p => CommonConverter.StringToInt(p.version)).ToList(); MyDataGrid.ItemsSource = listpageresult; }
/// <summary> /// 获取列与值对应 /// </summary> /// <param name="inText"></param> /// <returns></returns> private Dictionary <int, string> GetDicCtrlToColumn(string inText) { Dictionary <int, string> dicresult = new Dictionary <int, string>(); //顺便获取列名与属性名对应的字典 _propertyNameToColumnName.Clear(); string[] array = inText.Split('&'); int propertyIndex = 0; foreach (string str in array) { string[] value = str.Split('='); int tagId = CommonConverter.StringToInt(value[0].Split('.')[0]); if (!dicresult.ContainsKey(tagId)) { dicresult.Add(tagId, value[1]); if (!_propertyNameToColumnName.ContainsKey(value[1])) { _propertyNameToColumnName.Add(value[1], "Value" + propertyIndex.ToString()); propertyIndex++; } } } return(dicresult); }
/// <summary> /// 获取控件基本信息 /// </summary> /// <param name="pageid"></param> /// <returns></returns> private List <ControlDetailForPage> GetControlBaseInfo(int pageid) { string sql = @"select * from hs_new_page_ctrls t where t.page_id = '{0}'"; sql = string.Format(sql, pageid); SQLiteDataReader reader = this.ExcuteReader(sql); List <ControlDetailForPage> listControl = new List <ControlDetailForPage>(); while (reader.Read()) { //int index = 0; ControlDetailForPage obj = new ControlDetailForPage(); foreach (var prop in obj.GetType().GetFields()) { string value = reader[prop.Name].ToString(); //这里判断一下类型 if ("Boolean".Equals(prop.FieldType.Name)) { prop.SetValue(obj, CommonConverter.StringToBool(value)); } else if ("Int32".Equals(prop.FieldType.Name)) { prop.SetValue(obj, CommonConverter.StringToInt(value)); } else { prop.SetValue(obj, value); } } listControl.Add(obj); } reader.Close(); this._connection.Close(); return(listControl); }
public async void ConvertButton_Click(object sender, RoutedEventArgs e) { string sourceDirectory = this.InputDirectoryControl.Text; string outputFile = this.OutputFileControl.Text; if (string.IsNullOrWhiteSpace(sourceDirectory)) { UpdateStatus("Please specify a source directory"); return; } if (!Directory.Exists(sourceDirectory)) { UpdateStatus("Source directory doesn't exist"); return; } if (string.IsNullOrWhiteSpace(outputFile)) { UpdateStatus("Please specify an output file"); return; } UpdateStatus("Converting"); await Task.Run(() => { try { CommonConverter.ConvertFiles(this.InputDirectoryControl.Text, this.OutputFileControl.Text); } catch (Exception ex) { UpdateStatus("Unexpected issue in conversion " + ex.Message); } }); UpdateStatus("Conversion Successful"); }
public override IEnumerator <CommonRow> GetEnumerator() { var path = GetPath(); if (!File.Exists(path)) { throw Error.Fatal("no such file {path}"); } using (var rdr = new TextFieldParser(path) { TextFieldType = FieldType.Delimited, Delimiters = new string[] { "," }, }) { for (var id = 0; !rdr.EndOfData; ++id) { var row = rdr.ReadFields(); if (id > 0) { if (_hasid) { row = (new string[] { id.ToString() }) .Concat(row).ToArray(); } yield return(CommonConverter.ToObject(row, Heading.Fields)); } } } }
/// <summary> /// 装载窗体 /// 这里暂时唯一的用处是用来与菜单栏控件进行关联 /// </summary> /// <param name="value"></param> public async void SetA1(string value) { if (string.IsNullOrEmpty(value)) { return; } // 这里加载新的窗口ID的页面 int pageId = CommonConverter.StringToInt(value); if (pageId == -1) { return; } _currentPageId = pageId; var page = await _pageFactory.ProducePage(_currentPageId, true); if (object.Equals(page, null)) { return; } Frame frame = new Frame(); page.HorizontalAlignment = HorizontalAlignment.Left; page.VerticalAlignment = VerticalAlignment.Top; frame.Content = page; frame.Width = page.Width; frame.Height = page.Height; frame.VerticalAlignment = VerticalAlignment.Top; frame.HorizontalAlignment = HorizontalAlignment.Left; this.Children.Clear(); this.Children.Add(frame); }
static void Main(string[] args) { Parser.Default.ParseArguments <Arguments>(args).WithParsed((arguments) => { CommonConverter.ConvertFiles(arguments.InputDirectory, arguments.OutputFile); }); }
/// <summary> /// 初始化控件,由于比较复杂,所以这种情况由控件自身进行初始化 /// </summary> /// <param name="controlObj"></param> /// <param name="listControlObj"></param> /// <param name="listControl"></param> public void InitControl(ControlDetailForPage controlObj, List <ControlDetailForPage> listControlObj, List <IControl> listControl) { this.Items.Clear(); List <ControlDetailForPage> listgroups = this.GetParentGroups(listControlObj, controlObj.d17); //开始生成控件 foreach (ControlDetailForPage groupobj in listgroups) { //生成树节点 TreeViewItem itemGroup = new TreeViewItem(); itemGroup.Header = ProduceTreeviewItem(listControlObj, listControl, groupobj); //获取该目录下的子节点 List <ControlDetailForPage> listItems = listControlObj.Where(p => groupobj.ctrl_id.ToString().Equals(p.d13) && xinLongyuControlType.pcnavigationBarItemType.Equals(p.ctrl_type)).ToList(); if (object.Equals(listItems, null) || listItems.Count < 1) { continue; } //排序 listItems = listItems.OrderBy(p => CommonConverter.StringToInt(p.d21)).ToList(); foreach (ControlDetailForPage itemObj in listItems) { TreeViewItem childItem = new TreeViewItem(); childItem.Header = ProduceTreeviewItem(listControlObj, listControl, itemObj); childItem.Tag = itemObj; childItem.MouseDoubleClick += ChildItem_MouseDoubleClick; itemGroup.Items.Add(childItem); } this.Items.Add(itemGroup); } }
/// <summary> /// 设置表格的数据 /// </summary> /// <param name="value"></param> public void SetD6(string value) { //1、sql 2、字典实体 if ("1".Equals(_sourceType)) { string sql = value.ToString(); SqlController cn = new SqlController(); var dicReturn = cn.ExcuteSqlWithReturn(sql); Dictionary <string, string>[] result = dicReturn.data; List <KeyValuePair <string, int> > source = this.DictionaryToListKeyValuePair(result); this.MyChart.DataContext = source; } else if ("2".Equals(_sourceType)) { string valueStr = value.Trim(); string[] valueArray = valueStr.Split('&'); List <KeyValuePair <string, int> > dicTemp = new List <KeyValuePair <string, int> >(); foreach (string str in valueArray) { dicTemp.Add(new KeyValuePair <string, int>(str.Split('=')[0], CommonConverter.StringToInt(str.Split('=')[1]))); } //foreach (string key in dicTemp.Keys) //{ // //暂时注释,后面h实现事件的时候顺便实现这个 // //LocalCacher.AddCache(key, DecoderAssistant.FormatSql(dicTemp[key], this)); //} } }
/// <summary> /// 设置字体颜色 /// </summary> /// <param name="value"></param> public void SetD7(string value) { if (string.IsNullOrEmpty(value.Trim())) { return; } this.Foreground = new SolidColorBrush(CommonConverter.ConvertStringToColor(value)); }
/// <summary> /// 设置总时长 /// </summary> /// <param name="text"></param> public void SetD10(string text) { int value = CommonConverter.StringToInt(text); if (value != -1) { this._totalTime = value; } }
/// <summary> /// 设置时间间隔 /// </summary> /// <param name="text"></param> public void SetD11(string text) { int interval = CommonConverter.StringToInt(text); if (interval != -1) { _timer.Interval = new TimeSpan(interval * 1000); } }
// extract value from row in common type object GetDatarowValue(DataRow row, string fieldname, CommonType ctype) { try { var value = row[fieldname]; return((value == null || value == DBNull.Value) ? CommonConverter.GetDefault(ctype) : value); } catch (Exception) { throw Error.Fatal($"bad field {fieldname}"); } }
private bool dealWithUpper(string leftvalue, string rightValue) { if (CommonConverter.StringToInt(leftvalue) > CommonConverter.StringToInt(rightValue)) { return(true); } else { return(false); } }
private bool dealWithLowerAndEqual(string leftvalue, string rightValue) { if (CommonConverter.StringToInt(leftvalue) <= CommonConverter.StringToInt(rightValue)) { return(true); } else { return(false); } }
/// <summary> /// 设置字体样式 /// </summary> /// <param name="value"></param> public void SetD6(string value) { if (!string.IsNullOrEmpty(value.Trim())) { Font font = JsonController.DeSerializeToClass <Font>(value); this.FontStyle = font.Style == System.Drawing.FontStyle.Italic ? FontStyles.Italic : FontStyles.Normal; this.FontFamily = CommonConverter.FontToMediaFontFamily(font); this.FontSize = font.Size; this.FontWeight = font.Bold ? FontWeights.Bold : FontWeights.Normal; } }
/// <summary> /// 解析事件实体 /// </summary> /// <param name="inText"></param> /// <returns></returns> public DecoderOfControl DecodeNewCharacter(string inText) { DecoderOfControl control = new DecoderOfControl(); inText = inText.Trim(); if (inText.ToLower().StartsWith("sql:")) { //sql语法的进行单独处理 return(DecodeSqlEvent(inText)); } if (inText.IndexOf("=") != -1 && Regex.IsMatch(inText, @"\d+.d\d+ *= *\w*")) { if (Regex.IsMatch(inText, @"\d+.d\d+ *=.*")) { string leftPart = inText.Trim().Split('=')[0]; leftPart = Regex.Match(leftPart, @"\d+.\w\d+").Groups[0].ToString(); int rightIndex = inText.Trim().IndexOf("="); string rightPart = inText.Substring(rightIndex + 1, inText.Length - rightIndex - 1).Trim(); this.DecodeLeftPart(leftPart, control); this.DecodeRightPart(rightPart, control); } } else if (Regex.IsMatch(inText, @"\d+.a\d+[(]((.|\n)*)[)]")) { if (Regex.IsMatch(inText, @"\d+.a\d+[(]\d+,\w+=.*")) { string leftParttern = Regex.Match(inText, @"[(]((.|\n)*)[)]").Groups[0].ToString().Trim(); string leftPart = inText.Replace(leftParttern, string.Empty); leftPart = Regex.Match(leftPart, @"\d+.\w\d+").Groups[0].ToString(); control.CtrlId = CommonConverter.StringToInt(leftPart.Split('.')[0]); control.LeftCtrlProperty = leftPart.Split('.')[1]; control.RightDirectValue = leftParttern.Substring(1, leftParttern.Length - 2); } else { control.CtrlId = CommonConverter.StringToInt(inText.Split('.')[0]); string rightpart = inText.Substring(inText.IndexOf(".") + 1); control.RightDirectValue = Regex.Match(rightpart, @"[(]((.|\n)*)[)]").Groups[1].ToString(); control.LeftCtrlProperty = rightpart.Replace(Regex.Match(rightpart, @"[(]((.|\n)*)[)]").Groups[0].ToString(), string.Empty); } } //事件语法,例如12.a1 else if (Regex.IsMatch(inText, @"\d+.a|A\d+")) { control.CtrlId = CommonConverter.StringToInt(inText.Trim().Split('.')[0]); control.LeftCtrlProperty = inText.Trim().Split('.')[1]; } //事件语法,例如12.a5(1236) return(control); }
/// <summary> /// 设置底部显示的一些相关信息 /// </summary> private void DealWithPageIndex() { _rowCount = GetTotalRowCount(); _pageSize = CommonConverter.StringToInt(_CurrentCtObj.d15); if (_pageSize != 0 && _pageSize != -1) { _totalPage = _rowCount / _pageSize; } lblCurrentPageIndex.Text = _currentPageIndex.ToString() + " / " + _totalPage.ToString(); //当前页面设置 lblTotalPageCount.Text = "共" + _rowCount.ToString() + " 条"; //总数据条数设置 }
/// <summary> /// 设置限制的长度 /// </summary> /// <param name="text"></param> public void SetD11(string text) { if (string.IsNullOrEmpty(text)) { return; } var length = CommonConverter.StringToInt(text); if (length != -1) { this.txtContent.MaxLength = length; } }
/// <summary> /// 读取配置信息文件 /// </summary> private void ReadConfigFromFile() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(ConfigFilePath); // 读取到配置信息对象 Config.CachePhotoDirectory = xmlDoc.GetElementValue(@"PhotoCacheDir", DefaultConfig.PhotoCacheDir); Config.ServerPhotoDirectory = xmlDoc.GetElementValue(@"ServerPhotoDir", DefaultConfig.ServerPhotoDir); Config.ThumbSize = CommonConverter.StringToSize(xmlDoc.GetElementValue(@"ThumbSize", DefaultConfig.ThumbSize)); Config.LargeSize = CommonConverter.StringToSize(xmlDoc.GetElementValue(@"LargeSize", DefaultConfig.LargeSize)); Config.ThumbShowSize = CommonConverter.StringToSize(xmlDoc.GetElementValue(@"ThumbShowSize", DefaultConfig.ThumbShowSize)); }
// select the schema as the current table bool SelectSchema() { _table = null; var schema = GetSchema(); var scols = schema.Columns; var fields = Enumerable.Range(0, scols.Count) .Select(x => new CommonField { Name = scols[x].ColumnName, CType = CommonConverter.TypeToCommon(scols[x].DataType) }).ToArray(); Heading = CommonHeading.Create(fields); return(true); }
// extract reader value in common type object GetReaderValue(DbDataReader rdr, string fieldname, CommonType ctype) { var field = rdr.GetOrdinal(fieldname); if (rdr.IsDBNull(field)) { return(CommonConverter.GetDefault(ctype)); } else { return(rdr.GetValue(field)); } }
public override IEnumerator <CommonRow> GetEnumerator() { var path = GetPath(); if (!File.Exists(path)) { yield break; } using (var rdr = File.OpenText(path)) { for (var line = rdr.ReadLine(); line != null; line = rdr.ReadLine()) { yield return(CommonConverter.ToObject(new string[] { line }, Heading.Fields)); } } }
/// <summary> /// 获取所有的一级目录 /// </summary> /// <returns></returns> private List <ControlDetailForPage> GetParentGroups(List <ControlDetailForPage> listControlObj, string childlistStr) { List <int> controlIdList = JsonController.DeSerializeToClass <List <int> >(childlistStr); if (controlIdList.Count < 1) { return(null); } //获取父目录控件并进行排序 List <ControlDetailForPage> childrenList = listControlObj.Where(p => controlIdList.Contains(p.ctrl_id) && validStr.Equals(p.d12)) .OrderBy(p => CommonConverter.StringToInt(p.d21)).ToList(); return(childrenList); }