示例#1
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!CheckUnsavedChanges())
            {
                return;
            }

            if (openImageDialog.ShowDialog() == DialogResult.OK)
            {
                var projectDir = Path.GetDirectoryName(openImageDialog.FileName);
                saveProjectDialog.InitialDirectory = projectDir;
                project            = new OrthoProject();
                project.Radiograph = openImageDialog.FileName;
                UpdateSetScale(true);
                InitializeProject(projectDir);
            }
        }
示例#2
0
        void OpenProject(string fileName)
        {
            saveProjectDialog.FileName = fileName;
            using (var reader = XmlReader.Create(fileName))
            {
                var serializer = new XmlSerializer(typeof(OrthoProject));
                try { project = (OrthoProject)serializer.Deserialize(reader); }
                catch (InvalidOperationException)
                {
                    project = null;
                    MessageBox.Show("Unrecognized file format. Please check if project file is compatible with this version of OpenOrtho.", "Invalid file format", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                UpdateSetScale(false);
                InitializeProject(Path.GetDirectoryName(fileName));
            }
        }
示例#3
0
        void InitializeProject(string projectDir)
        {
            if (background != null)
            {
                background.Dispose();
            }

            var radiographPath = Path.IsPathRooted(project.Radiograph) ? project.Radiograph : Path.Combine(projectDir, project.Radiograph);

            if (!File.Exists(radiographPath))
            {
                radiographPath = project.Radiograph;
                project        = null;
                MessageBox.Show(string.Format("Radiograph image file {0} is missing. Unable to load project data.", radiographPath), "Missing radiograph image file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (var bitmap = new Bitmap(radiographPath))
            {
                var query = new int[1];
                GL.GetInteger(GetPName.MaxTextureSize, query);
                var maxSize = query[0];

                textureWidth  = backgroundWidth = bitmap.Width;
                textureHeight = backgroundHeight = bitmap.Height;
                if (!nonPowerOfTwo || backgroundWidth > maxSize || backgroundHeight > maxSize)
                {
                    textureWidth  = Math.Min(maxSize, Utilities.NearestPowerOfTwo(backgroundWidth));
                    textureHeight = Math.Min(maxSize, Utilities.NearestPowerOfTwo(backgroundHeight));
                    using (var potsBitmap = new Bitmap(bitmap, textureWidth, textureHeight))
                    {
                        background = Texture2D.FromBitmap(potsBitmap);
                    }
                }
                else
                {
                    background = Texture2D.FromBitmap(bitmap);
                }
            }

            analysisPropertyGrid.SelectedObject = project;
            analysisPropertyGrid.Enabled        = true;
            ResetProjectStatus();
        }