public void ShowFileRow(ContentFile fileInfo, ContentRow rowInfo) { ListFrame.PushPage(null, fileInfo.Name, typeof(ContentDataTab), new ShowRowParam() { ShowContentFile = fileInfo, ShowContentRow = rowInfo }); }
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 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 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 ContentItemInfo(ContentFile contentFile, ContentRow selectedRow = null) { InitializeComponent(); _ContentFile = contentFile; _SelectedRow = selectedRow; SetContex(); }
public static void ReadContentFile(ConstructFile construct) { ContentFile contentFile = new ContentFile(construct); contentFile.Name = construct.Name; contentFile.IsInit = true; ReadContentFile(construct, ref contentFile); }
public ContentDataGrid(ContentFile contentFile) { InitializeComponent(); _ContentFile = contentFile; if (_ContentFile != null) ShowContent(); }
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"; } }
public ContentDataGrid(ContentFile contentFile) { InitializeComponent(); _ContentFile = contentFile; if (_ContentFile != null) { ShowContent(); } }
new public void AddNewItem(ContentFile contentFile) { base.RemoveByName(contentFile.Name); base.AddNewItem(contentFile); if (_ContentFilesDic.ContainsKey(contentFile.Name)) { _ContentFilesDic.Remove(contentFile.Name); } _ContentFilesDic.Add(contentFile.Name, contentFile); }
public static void CreateFileNotExist() { foreach (ConstructFile constructFile in ConstructFold.Instance.ConstructFiles) { string path = TableGlobalConfig.Instance.ResTablePath + "/" + constructFile.Name + ".csv"; if (File.Exists(path)) continue; ContentFile contentFile = new ContentFile(constructFile); contentFile.Name = constructFile.Name; contentFile.GreateRow("empty"); TableContentManager.Instance.AddContentFile(contentFile); } }
public static void WriteFile(ContentFile file) { if (!string.IsNullOrEmpty(file.ConstructFile.OldName)) { string oldPath = TableGlobalConfig.Instance.ResTablePath + "\\" + file.ConstructFile.Path + file.ConstructFile.OldName + ".csv"; if (!string.IsNullOrEmpty(oldPath)) { File.Delete(oldPath); } file.WriteFlag = true; WriteConstruct.WriteFileOldName(file.ConstructFile, ""); } //if(!file.IsNeedWrite()) // return; string path = TableGlobalConfig.Instance.ResTablePath + "\\" + file.ConstructFile.Path + "\\" + file.ConstructFile.Name + ".csv"; if (string.IsNullOrEmpty(path)) { return; } string diretPath = TableGlobalConfig.Instance.ResTablePath + "\\" + file.ConstructFile.Path; if (!Directory.Exists(diretPath)) { Directory.CreateDirectory(diretPath); } File.Delete(path); using (StreamWriter SourceStream = new StreamWriter(path, false, System.Text.Encoding.UTF8)) { CsvWriter writer = new CsvWriter(SourceStream); writer.WriteRecord(file.ConstructFile.GetColumnTitles()); foreach (ContentRow row in file.ContentRow) { writer.WriteRecord(row.GetItemsStr()); } } file.AlreadyWrite(); }
public static void CreateFileNotExist() { foreach (ConstructFile constructFile in ConstructFold.Instance.ConstructFiles) { string path = TableGlobalConfig.Instance.ResTablePath + "\\" + constructFile.Path + constructFile.Name + ".csv"; if (File.Exists(path)) { continue; } ContentFile contentFile = new ContentFile(constructFile); contentFile.Name = constructFile.Name; //contentFile.GreateRow("empty"); TableContentManager.Instance.AddContentFile(contentFile); } }
private void LinkList_SelectionChanged(object sender, SelectionChangedEventArgs e) { ContentFile fileInfo = LinkList.SelectedItem as ContentFile; if (fileInfo == null) { return; } ListFrame.PushPage(null, fileInfo.Name, typeof(ContentDataTab), new ShowRowParam() { ShowContentFile = fileInfo }); //PathBaseFrame pathFrame = ParentBaseFrame as PathBaseFrame; //if (pathFrame == null) // return; //pathFrame.PushPage(PathItem, fileInfo.Name, typeof(ContentDataTab), fileInfo); }
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); }
public void ShowContent(object param) { ShowRowParam showParam = param as ShowRowParam; if (showParam == null) return; _ContentFile = showParam.ShowContentFile; ShowList(); if (showParam.ShowContentRow != null) { _ListShow.ShowRow(showParam.ShowContentRow); } //ItemAttrPanel.Visibility = System.Windows.Visibility.Collapsed; //LinkList.ItemsSource = _ContentFile.ContentColumn; //InitItemType1(); //InitItemType1(); }
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); } }
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 ItemIDMultiValue1_SelectionChanged_1(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 0) { return; } string selectedTable = e.AddedItems[0] as string; if (string.IsNullOrEmpty(selectedTable)) { return; } _TableName = selectedTable; ContentFile contentFile = TableContentManager.Instance.GetFileByName(selectedTable); if (contentFile != null) { ItemIDMultiValue2.Items.Clear(); foreach (ContentRow contentRow in contentFile.ContentRow) { if (ContentConfig.IsContentIDInvalid(contentRow.ID)) { ItemIDMultiValue2.Items.Add(contentRow.ID); } } } else if (selectedTable == "None") { _TableName = ""; _TableID = ""; ItemIDMultiValue1.Text = _TableName; ItemIDMultiValue2.Text = _TableID; ValidValue(); } //ItemIDMultiValue2.DisplayMemberPath = "DisplayName"; }
public void ShowContent(object param) { ShowRowParam showParam = param as ShowRowParam; if (showParam == null) { return; } _ContentFile = showParam.ShowContentFile; ShowList(); if (showParam.ShowContentRow != null) { _ListShow.ShowRow(showParam.ShowContentRow); } //ItemAttrPanel.Visibility = System.Windows.Visibility.Collapsed; //LinkList.ItemsSource = _ContentFile.ContentColumn; //InitItemType1(); //InitItemType1(); }
public static void WriteFile(ContentFile file) { if (!string.IsNullOrEmpty(file.ConstructFile.OldName)) { string oldPath = TableGlobalConfig.Instance.ResTablePath + "/" + file.ConstructFile.OldName + ".csv"; if (!string.IsNullOrEmpty(oldPath)) { File.Delete(oldPath); } file.WriteFlag = true; WriteConstruct.WriteFileOldName(file.ConstructFile, ""); } if(!file.IsNeedWrite()) return; string path = TableGlobalConfig.Instance.ResTablePath + "/" + file.ConstructFile.Name + ".csv"; if (string.IsNullOrEmpty(path)) return; File.Delete(path); using (StreamWriter SourceStream = new StreamWriter(path, false, System.Text.Encoding.UTF8)) { CsvWriter writer = new CsvWriter(SourceStream); writer.WriteRecord(file.ConstructFile.GetColumnTitles()); foreach (ContentRow row in file.ContentRow) { writer.WriteRecord(row.GetItemsStr()); } } file.AlreadyWrite(); }
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 void ReadContentFile(ConstructFile construct, ref ContentFile contentFile) { string path = TableGlobalConfig.Instance.ResTablePath + "/" + construct.Name + ".csv"; if (!string.IsNullOrEmpty(construct.OldName)) { path = TableGlobalConfig.Instance.ResTablePath + "/" + construct.OldName + ".csv"; } if (!File.Exists(path)) { CreateNewFile(construct); 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 ContentItems ContentItems = new ContentItems(); #endregion public ContentRow(ContentFile contentFile) { _ContentFile = contentFile; }
public void AddContentFile(ContentFile file) { ContentFiles.AddNewItem(file); }
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; }