public ContentRow GreateRow(string id) { if (ContentRow.ContainsID(id)) return null; ContentRow row = new ContentRow(this); //初始化值 foreach (ConstructItem constructItem in _ConstuctFile.ConstructItems) { for (int i = 0; i < constructItem.ItemRepeat; ++i) { ContentItem contentItem = new ContentItem(row, constructItem, i + 1); if (constructItem.ItemCode == ConstructConfig.NEW_FILE_DEFAULT_ID_CODE) { contentItem.Value = id; } else { contentItem.Value = constructItem.ItemDefault; } row.AddContentItem(contentItem); } } AddContentRow(row); return row; }
public ContentItem(ContentRow row, ConstructItem construct, int constructIdx) { _ItemConstruct = construct; _ContructRepeatIndex = constructIdx; ContentRow = row; }
public void ShowFileRow(ContentFile fileInfo, ContentRow rowInfo) { ListFrame.PushPage(null, fileInfo.Name, typeof(ContentDataTab), new ShowRowParam() { ShowContentFile = fileInfo, ShowContentRow = rowInfo }); }
public static bool IsValueTableSingle(ConstructItem constructItem, object value, out string errorMsg) { bool isValid = true; errorMsg = ""; ContentFile contentFile = TableContentManager.Instance.GetFileByName(constructItem.ItemType2[0].Name); if (contentFile == null) { errorMsg = "表格无效"; return(false); } string valueType = (string)value; ContentRow contentRow = contentFile.ContentRow.GetRowByID(valueType); if (contentRow == null) { errorMsg = "表格ID无效"; return(false); } return(isValid); }
public static void CreateNewFile(ConstructFile construct) { ContentFile contentFile = new ContentFile(construct); contentFile.Name = construct.Name; ContentRow row = new ContentRow(contentFile); foreach (ConstructItem constructItem in construct.ConstructItems) { for (int i = 0; i < constructItem.ItemRepeat; ++i) { ContentItem contentItem = new ContentItem(row, constructItem, i + 1); if (constructItem.ItemCode == ConstructConfig.NEW_FILE_DEFAULT_ID_CODE) { contentItem.Value = ContentConfig.CONTENT_INIT_DEFAULT_ID; } else { contentItem.Value = ""; } row.AddContentItem(contentItem); } } contentFile.AddContentRow(row); TableContentManager.Instance.AddContentFile(contentFile); }
public ContentRow GreateRow(string id) { if (ContentRow.ContainsID(id)) { return(null); } ContentRow row = new ContentRow(this); //初始化值 foreach (ConstructItem constructItem in _ConstuctFile.ConstructItems) { for (int i = 0; i < constructItem.ItemRepeat; ++i) { ContentItem contentItem = new ContentItem(row, constructItem, i + 1); if (constructItem.ItemCode == ConstructConfig.NEW_FILE_DEFAULT_ID_CODE) { contentItem.Value = id; } else { contentItem.Value = constructItem.ItemDefault; } row.AddContentItem(contentItem); } } AddContentRow(row); return(row); }
private void ShowContent() { if (_ContentFile.ContentRow.Count == 0) { return; } DG1.DataContext = _ContentFile.ContentRow; ContentRow row = _ContentFile.ContentRow[0] as ContentRow; if (row == null) { return; } for (int i = 0; i < row.ContentItems.Count; ++i) { var itemConstrucst = row.ContentItems[i] as ContentItem; DataGridTextColumn textColumn = new DataGridTextColumn(); textColumn.Header = itemConstrucst.ItemConstructName; Binding binding = new Binding(string.Format("ContentItems[{0}].Value", i)) { Mode = BindingMode.TwoWay, ValidatesOnDataErrors = true }; //binding.ValidationRules.Add(new ContentValidationRule() { ConstructItem = itemConstrucst.ItemConstruct }); textColumn.Binding = binding; DG1.Columns.Add(textColumn); } }
public static ContentRow ReadRow(ConstructFile construct, DataRecord data, ContentFile contentFile) { ContentRow row = new ContentRow(contentFile); try { row.IsInit = true; foreach (ConstructItem constructItem in construct.ConstructItems) { ReadItem(constructItem, data, ref row); } row.IsInit = false; //if (row.ContentItems.Count != 0) //{ // row.Name = row.ContentItems[0].Value.ToString(); //} } catch (Exception e) { throw new Exception("read exception:" + e); } row.WriteFlag = false; row._ContentItems.WriteFlag = false; return(row); }
public static void ReadItem(ConstructItem constructItem, DataRecord data, ref ContentRow row) { for (int i = 0; i < constructItem.ItemRepeat; ++i) { if (constructItem.ItemCode == "rate") { int test = 1 + 1; } ContentItem contentItem = new ContentItem(row, constructItem, i + 1); string columnName = constructItem.Name; if (constructItem.ItemRepeat > 1) { columnName = (constructItem.Name + (i + 1).ToString()); } columnName = "\"" + columnName + "\""; if (data.HeaderRecord.Contains(columnName)) { contentItem.Value = data[columnName]; } else { contentItem.Value = ""; } row.AddContentItem(contentItem); } }
public ContentItemInfo(ContentFile contentFile, ContentRow selectedRow = null) { InitializeComponent(); _ContentFile = contentFile; _SelectedRow = selectedRow; SetContex(); }
public void AddNewItem(ContentRow contentRow) { base.AddNewItem(contentRow); if (ContentConfig.IsContentIDInvalid(contentRow.ID)) { _ContentFilesDic.Add(contentRow.ID, contentRow); } }
private void InitTableIdType() { ItemTextValue.Visibility = System.Windows.Visibility.Collapsed; ItemEnmuValue.Visibility = System.Windows.Visibility.Collapsed; ItemIDSingleValue.Visibility = System.Windows.Visibility.Collapsed; ItemIDMultiValue.Visibility = System.Windows.Visibility.Collapsed; ItemBoolValue.Visibility = System.Windows.Visibility.Collapsed; ItemVector3Value.Visibility = System.Windows.Visibility.Collapsed; if (_ContentItem.ItemConstruct.ItemType2.Count > 1) { ItemIDMultiValue.Visibility = System.Windows.Visibility.Visible; //foreach (var typeTable in _ContentItem.ItemConstruct.ItemType2) //{ // //if (contentRow.ID != ContentConfig.CONTENT_INVALID_ID) // { // ItemIDMultiValue1.Items.Add(typeTable.Name); // } //} //_ContentItem.SplitValue(); //ItemIDMultiValue1.Text = _ContentItem.GetSplitValue(0); //ItemIDMultiValue2.Text = _ContentItem.GetSplitValue(1); } else if (_ContentItem.ItemConstruct.ItemType2.Count == 1) { ItemIDSingleValue.Visibility = System.Windows.Visibility.Visible; ContentFile contentFile = TableContentManager.Instance.GetFileByName(_ContentItem.ItemConstruct.ItemType2[0].Name); if (contentFile == null) { return; } ItemIDSingleValue.Items.Clear(); foreach (ContentRow contentRow in contentFile.ContentRow) { if (ContentConfig.IsContentIDInvalid(contentRow.ID)) { ItemIDSingleValue.Items.Add(contentRow); } } //空选择 ItemIDSingleValue.Items.Add("None"); ContentRow selectRow = contentFile.GetRowByID(_ContentItem.Value); if (selectRow != null) { ItemIDSingleValue.Text = selectRow.DisplayName; } ItemIDSingleValue.SelectedValuePath = "WriteValue"; ItemIDSingleValue.DisplayMemberPath = "DisplayName"; } }
private void Row_SelectionChanged(object sender, SelectionChangedEventArgs e) { if(e.AddedItems.Count == 0) return; _SelectedRow = e.AddedItems[0] as ContentRow; if (_SelectedRow == null) return; ItemValueList.ItemsSource = _SelectedRow._ContentItems; }
private void MenuItem_Remove(object sender, RoutedEventArgs e) { ContentRow fileInfo = RowList.SelectedItem as ContentRow; if (fileInfo == null) { return; } _ContentFile.ContentRow.Remove(fileInfo); }
private void DG1_MouseRightButtonUp_1(object sender, MouseButtonEventArgs e) { ContentRow row = DG1.SelectedItem as ContentRow; if (row == null) { return; } if (ContentFileList.Instance != null) { ContentFileList.Instance.ShowFileRow(_ContentFile, row); } }
private void Row_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 0) { return; } _SelectedRow = e.AddedItems[0] as ContentRow; if (_SelectedRow == null) { return; } ItemValueList.ItemsSource = _SelectedRow._ContentItems; }
public static bool IsValueTableMulti(ConstructItem constructItem, object value, out string errorMsg) { errorMsg = ""; var valueList = ContentItem.GetSplitValue((string)value); if (valueList.Count != 2) { errorMsg = "格式无效"; return(false); } if (string.IsNullOrEmpty(valueList[0]) || string.IsNullOrEmpty(valueList[1])) { errorMsg = ""; return(true); } if (constructItem.ItemType2.GetByName(valueList[0]) == null) { errorMsg = "不支持该表"; return(false); } ContentFile contentFile = TableContentManager.Instance.GetFileByName(valueList[0]); if (contentFile == null) { errorMsg = "表格无效"; return(false); } ContentRow contentRow = contentFile.ContentRow.GetRowByID(valueList[1]); if (contentRow == null) { errorMsg = "表格ID无效"; return(false); } return(true); }
private void ItemIDSingleValue_MouseRightButtonDown_1(object sender, MouseButtonEventArgs e) { ContentFile contentFile = TableContentManager.Instance.GetFileByName(_ContentItem.ItemConstruct.ItemType2[0].Name); if (contentFile == null) { return; } ContentRow contentRow = contentFile.ContentRow.GetRowByID(_ContentItem.Value); if (contentRow == null) { return; } if (ContentFileList.Instance != null) { ContentFileList.Instance.ShowFileRow(contentFile, contentRow); } }
private void ItemIDMultiValue2_MouseRightButtonUp_1(object sender, MouseButtonEventArgs e) { ContentFile contentFile = TableContentManager.Instance.GetFileByName(_TableName); if (contentFile == null) { return; } ContentRow contentRow = contentFile.ContentRow.GetRowByID(_TableID); if (contentRow == null) { return; } if (ContentFileList.Instance != null) { ContentFileList.Instance.ShowFileRow(contentFile, contentRow); } }
public void ShowRow(ContentRow contentRow) { ItemValueList.ItemsSource = contentRow.ContentItems; }
public void AddContentRow(ContentRow row) { ContentRow.AddNewItem(row); }
public static void ReadContentFile(ConstructFile construct, ref ContentFile contentFile) { string path = TableGlobalConfig.Instance.ResTablePath + "\\" + construct.Path + construct.Name + ".csv"; if (!string.IsNullOrEmpty(construct.OldName)) { path = TableGlobalConfig.Instance.ResTablePath + "\\" + construct.Path + construct.OldName + ".csv"; } if (!File.Exists(path)) { //CreateNewFile(construct); TableContentManager.Instance.AddContentFile(contentFile); return; } string[] lines = File.ReadAllLines(path, Encoding.Default); if (lines.Length == 0) { return; } contentFile.ContentRow.Clear(); lines[0] = lines[0].Replace("\r\n", "\n"); StringReader rdr = new StringReader(string.Join("\n", lines)); using (var reader = new CsvReader(rdr)) { HeaderRecord header = reader.ReadHeaderRecord(); //string curGourpName = ""; //string curClassName = ""; var columnTitles = construct.GetColumnTitles(); while (reader.HasMoreRecords) { DataRecord data = reader.ReadDataRecord(); //if (data[0].StartsWith("###")) //{ // curGourpName = data[0].TrimStart('#'); // continue; //} //if (data[0].StartsWith("##")) //{ // curClassName = data[0].TrimStart('#'); // continue; //} ContentRow clumn = ReadRow(construct, data, contentFile); contentFile.AddContentRow(clumn); } if (IsHeaderMatch(construct, header)) { contentFile.WriteFlag = false; } else { contentFile.WriteFlag = true; } contentFile.IsInit = false; TableContentManager.Instance.AddContentFile(contentFile); } }
public static ContentRow ReadRow(ConstructFile construct, DataRecord data, ContentFile contentFile) { ContentRow row = new ContentRow(contentFile); try { row.IsInit = true; foreach (ConstructItem constructItem in construct.ConstructItems) { ReadItem(constructItem, data, ref row); } row.IsInit = false; //if (row.ContentItems.Count != 0) //{ // row.Name = row.ContentItems[0].Value.ToString(); //} } catch (Exception e) { throw new Exception("read exception:" + e); } row.WriteFlag = false; row._ContentItems.WriteFlag = false; return row; }
public static void ReadItem(ConstructItem constructItem, DataRecord data, ref ContentRow row) { for (int i = 0; i < constructItem.ItemRepeat; ++i) { ContentItem contentItem = new ContentItem(row, constructItem, i + 1); string columnName = constructItem.Name; if (constructItem.ItemRepeat > 1) { columnName = (constructItem.Name + (i + 1).ToString()); } columnName = "\"" + columnName + "\""; if (data.HeaderRecord.Contains(columnName)) { contentItem.Value = data[columnName]; } else { contentItem.Value = ""; } row.AddContentItem(contentItem); } }