예제 #1
0
        public void ReadContainerFromExternalFile()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Editor   ed = Application.DocumentManager.MdiActiveDocument.Editor;

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter      = "MSH or Text Files|*.msh;*.txt|Text Files|*.txt|Office Files|*.doc|All Files|*.*";
            dlg.Multiselect = false;
            dlg.Title       = "Select MSH File ";
            dlg.DefaultExt  = "msh";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                container = new Containers();
                if (container.ReadFromExternalFile(dlg.FileName))
                {
                    int notfictive = 0;
                    foreach (Bend b in container.Bends)
                    {
                        if (!b.Fictive)
                        {
                            notfictive++;
                        }
                    }

                    string formatString = "{0,-20}\t{1,-12}\n\n";

                    string mess = "\n";
                    mess += string.Format(formatString, "Nodes:", container.Nodes.Count);
                    mess += string.Format(formatString, "All Bends:", container.Bends.Count);
                    mess += string.Format(formatString, "Bends:", notfictive);
                    mess += string.Format(formatString, "Fictive Bends:", container.Bends.Count - notfictive);
                    mess += string.Format(formatString, "Peripheral Bends:", container.peripheralBendsNumers.Count);
                    mess += string.Format(formatString, "Triangles:", container.Triangles.Count);
                    mess += string.Format(formatString, "Polygons:", container.Polygons.Count);

                    MessageBox.Show("\nMesh data was loaded from the Dictionary !\n\n" + mess +
                                    "\n\n" + ConstantsAndSettings.GetString(), "Reading from the Dictionary ...", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ed.WriteMessage("\nMesh data was loaded from the Dictionary !");
                }
                else
                {
                    container = new Containers();
                }
            }
        }