示例#1
0
        private void OpenMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dr = openFileDialog.ShowDialog();
            if (dr == DialogResult.Cancel) return;
            string file = openFileDialog.FileName;

            try
            {
                ProjectInfo info = XmlSerialization.DeSerializeObject(file, typeof(ProjectInfo)) as ProjectInfo;
                if (info != null)
                {
                    CurrentProject = info;
                    projectfrm.CurrentProject = CurrentProject;
                    projectfrm.Initi(CurrentProject.Name);

                    try
                    {
                        CurrentConnection.ServerAddress = CurrentProject.ServerAddress;
                        CurrentConnection.UserName = CurrentProject.UserName;
                        CurrentConnection.Password = CurrentProject.Password;
                        CurrentConnection.IsWindowAuth = CurrentProject.WindowsAudhority;

                        databasefrm.CheckSavedPassword();
                    }
                    catch { }

                    string path = Path.Combine(CurrentProject.SolutionPath, CurrentProject.Name);
                    path = Path.Combine(path, CurrentProject.Name);

                    string[] dirs = Directory.GetDirectories(path);
                    foreach (string dir in dirs)
                    {
                        string[] files = Directory.GetFiles(dir, "*.cs");
                        List<CodeInfo> codeInfoList = new List<CodeInfo>();
                        string dirName = Path.GetFileName(dir);
                        foreach (string tmp in files)
                        {
                            CodeInfo tmpInfo = new CodeInfo();
                            tmpInfo.Code = File.ReadAllText(tmp, Encoding.UTF8);
                            tmpInfo.FileName = Path.GetFileName(tmp).Replace(".cs", "");
                            tmpInfo.Template = dirName;

                            codeInfoList.Add(tmpInfo);
                        }

                        projectfrm.AddCodeFiles(dirName, codeInfoList);
                    }
                }
            }
            catch
            {
                MessageBox.Show("文件打开失败", "应用程序提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
 /// <summary>
 /// 添加代码显示
 /// </summary>
 public void DisplayCode(string name, CodeInfo code)
 {
     CodeFrm codeFrm = new CodeFrm();
     codeFrm.SetCode(name, code);
     codeFrm.Show(this.MainDockPanel, DockState.Document);
 }
示例#3
0
 public void SetCode(string file, CodeInfo code)
 {
     this.TabText = file;
     this.texteditorcontrol.Text = code.Code;
 }