/// <summary> /// 创建网格 /// </summary> public PropertyGrid() { BackColor = FCColor.Back; GridLineColor = FCColor.Border; RowStyle.HoveredBackColor = FCDraw.FCCOLORS_HOVEREDROWCOLOR; RowStyle.SelectedBackColor = FCDraw.FCCOLORS_SELECTEDROWCOLOR; RowStyle.SelectedTextColor = FCDraw.FCCOLORS_TEXTCOLOR4; RowStyle.Font = new FCFont("微软雅黑", 12, false, false, false); FCGridRowStyle alternateRowStyle = new FCGridRowStyle(); alternateRowStyle.BackColor = FCDraw.FCCOLORS_ALTERNATEROWCOLOR; alternateRowStyle.HoveredBackColor = FCDraw.FCCOLORS_HOVEREDROWCOLOR; alternateRowStyle.SelectedBackColor = FCDraw.FCCOLORS_SELECTEDROWCOLOR; alternateRowStyle.SelectedTextColor = FCDraw.FCCOLORS_TEXTCOLOR4; alternateRowStyle.Font = new FCFont("微软雅黑", 12, false, false, false); AlternateRowStyle = alternateRowStyle; m_assembly = Assembly.Load("facecat_net"); String content = ""; FCFile.read(DataCenter.GetAppPath() + "\\config\\CN_PROPERTIES.txt", ref content); String[] strs = content.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); int strsSize = strs.Length; for (int i = 0; i < strsSize; i++) { String[] subStrs = strs[i].Split(new String[] { "=" }, StringSplitOptions.RemoveEmptyEntries); m_chNames[subStrs[0].ToLower()] = subStrs[1]; } }
/// <summary> /// 创建窗体 /// </summary> public MainForm() { InitializeComponent(); //创建XML解析器 m_designer = new Designer(); //链接控件库 m_designer.createNative(); m_designer.Script = new DesignerScript(m_designer); m_native = m_designer.Native; m_native.Paint = new GdiPlusPaintEx(); m_native.Host = new WinHostEx(); m_native.Host.Native = m_native; m_native.ResourcePath = WinHostEx.getAppPath() + "\\config"; m_host = m_native.Host as WinHostEx; m_host.HWnd = Handle; //设置尺寸 m_native.AllowScaleSize = true; m_native.DisplaySize = new FCSize(ClientSize.Width, ClientSize.Height); m_designer.resetScaleSize(getClientSize()); m_native.invalidate(); //加载Xml m_host.LoadingDesigner = true; m_designer.load(Path.Combine(DataCenter.GetAppPath(), "config\\MainFrame.html")); m_host.LoadingDesigner = false; }
/// <summary> /// 创建项目 /// </summary> public void createProject() { String name = getTextBox("txtName").Text.Trim(); String path = getTextBox("txtPath").Text.Trim(); if (name == null || name.Length == 0) { MessageBox.Show("请输入项目名称!", "提示"); return; } if (path == null || path.Length == 0) { MessageBox.Show("请输入项目路径!", "提示"); return; } List <FCGridRow> selectedRows = m_gridTemplate.SelectedRows; int selectedRowsSize = selectedRows.Count; if (selectedRowsSize > 0) { String identifier = selectedRows[0].getCell(1).getString(); if (identifier != null && identifier.Length > 0) { String identifier2 = selectedRows[0].getCell(2).getString(); String identifier3 = selectedRows[0].getCell(3).getString(); String identifier4 = selectedRows[0].getCell(4).getString(); DirectoryInfo dir = new DirectoryInfo(DataCenter.GetAppPath()); String codeDir = Application.StartupPath + "\\config\\projects\\" + identifier + "\\" + identifier2 + "\\" + identifier3; if (identifier4 == "0") { ArrayList <String> files = new ArrayList <String>(); FCFile.getFiles(codeDir, files); int filesSize = files.Count; if (filesSize > 0) { String fullName = files.get(0); String suffix = fullName.Substring(fullName.LastIndexOf('.') + 1); String newPath = path + "\\" + name + "." + suffix; File.Copy(fullName, newPath, true); m_designer.openFile(newPath); } } else if (identifier4 == "1") { String projectDir = path + "\\" + name; createProject(name, projectDir, identifier); Process.Start(projectDir); } close(); } } }
/// <summary> /// 加载界面 /// </summary> public virtual void load(FCNative native, String xmlName, String windowName) { Native = native; String xmlPath = DataCenter.GetAppPath() + "\\config\\" + xmlName + ".html"; Script = new DesignerScript(this); loadFile(xmlPath, null); m_window = findControl(windowName) as WindowEx; m_invokeEvent = new FCInvokeEvent(invoke); if (m_window != null) { m_window.addEvent(m_invokeEvent, FCEventID.INVOKE); //注册点击事件 registerEvents(m_window); } }