/// <summary> /// 导出所选择的模板到XML文件 /// </summary> private void ExportModel() { try { TreeNode Node = TemplateTree.SelectedNode; Boolean IsModule = Convert.ToBoolean(Node.Tag); if (IsModule) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "XML文件|*.xml"; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() == DialogResult.OK) { String xml = DepositoryModuleConfiguration.GetModuleRelationData(Node.Name); using (StreamWriter sw = new StreamWriter(saveFileDialog.FileName)) { sw.Write(xml); } MessageBox.Show("导出成功"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ModelView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { ProgressScreen.Current.ShowSplashScreen(); this.AddOwnedForm(ProgressScreen.Current); modelInfo = DepositoryModuleConfiguration.InitModuleConfiguration(e.Node.Name); FpSpread.Sheets.Clear(); foreach (SheetConfiguration Sheet in modelInfo.Sheets) { if (Sheet == null) { continue; } ProgressScreen.Current.SetStatus = "正在初始化表单‘" + Sheet.Description + "’"; SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), Sheet.SheetStyle, "SheetView") as SheetView; SheetView.Tag = Sheet; SheetView.SheetName = Sheet.Description; SheetView.OperationMode = OperationMode.ReadOnly; FpSpread.Sheets.Add(SheetView); if (Sheet.DataTableSchema.Schema == null) { continue; } foreach (FieldDefineInfo field in Sheet.DataTableSchema.Schema.FieldInfos) { SheetView.Cells[field.RangeInfo].BackColor = Color.LightPink; SheetView.Cells[field.RangeInfo].Tag = field; } } //将表外字段的数据表显示在当前窗口中 TableDefineInfo Info = modelInfo.ExtentDataSchema; SheetView ExtentSheet = new SheetView("系统表(含表外字段)"); ExtentSheet.OperationMode = OperationMode.RowMode; ExtentSheet.SelectionUnit = FarPoint.Win.Spread.Model.SelectionUnit.Row; ExtentSheet.Protect = true; ExtentSheet.ColumnCount = 3; ExtentSheet.Columns[0].Label = "字段名称"; ExtentSheet.Columns[0].Width = 100; ExtentSheet.Columns[0].Locked = true; ExtentSheet.Columns[0].HorizontalAlignment = CellHorizontalAlignment.Center; ExtentSheet.Columns[0].VerticalAlignment = CellVerticalAlignment.Center; ExtentSheet.Columns[1].Label = "字段描述"; ExtentSheet.Columns[1].Width = 100; ExtentSheet.Columns[1].Locked = true; ExtentSheet.Columns[1].HorizontalAlignment = CellHorizontalAlignment.Center; ExtentSheet.Columns[1].VerticalAlignment = CellVerticalAlignment.Center; ExtentSheet.Columns[2].Label = "数据类型"; ExtentSheet.Columns[2].Width = 100; ExtentSheet.Columns[2].Locked = true; ExtentSheet.Columns[2].HorizontalAlignment = CellHorizontalAlignment.Center; ExtentSheet.Columns[2].VerticalAlignment = CellVerticalAlignment.Center; ExtentSheet.RowCount = Info.FieldInfos.Count; foreach (FieldDefineInfo FieldInfo in Info.FieldInfos) { int index = Info.FieldInfos.IndexOf(FieldInfo); ExtentSheet.Cells[index, 0].Text = FieldInfo.FieldName; ExtentSheet.Cells[index, 1].Text = FieldInfo.Description; ExtentSheet.Cells[index, 2].Text = FieldInfo.FieldType.DisplayType; } ExtentSheet.Tag = Info.Name; FpSpread.Sheets.Add(ExtentSheet); this.RemoveOwnedForm(ProgressScreen.Current); ProgressScreen.Current.CloseSplashScreen(); Activate(); }