Ejemplo n.º 1
0
        private void openProject(object sender, System.EventArgs e)
        {
            DialogResult r = MessageBox.Show(this, "Discard the current project and all editing done?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (r == DialogResult.OK)
            {
                using (OpenFileDialog fd = new OpenFileDialog())
                {
                    fd.Filter = "Optimization Project Files|*.bilevelopt";
                    DialogResult dr = fd.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        try
                        {
                            IFormatter       formatter           = new BinaryFormatter();
                            Stream           stream              = new FileStream(fd.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                            OptimizedTexture newOptimizedTexture = (OptimizedTexture)formatter.Deserialize(stream);
                            stream.Close();
                            myOptimizedTexture.Dispose();
                            myOptimizedTexture = newOptimizedTexture;
                            myOptimizedTexture.SetEditor(this, myAdjustMetricForm, myRenderWindow);
                            AutoScrollMinSize = myOptimizedTexture.GetSize(getZoom());
                            Dirty();
                            theFile = fd.FileName;
                            Text    = theFile;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(this, "Error on loading:\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void loadBitmap(object sender, System.EventArgs e)
        {
            DialogResult r = MessageBox.Show(this, "Discard the current bitmap and all editing done?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (r == DialogResult.OK)
            {
                using (OpenFileDialog fd = new OpenFileDialog())
                {
                    fd.Filter = "Bitmap Files|*.bmp|JPEG Files|*.jpg|PNG Files|*.png";
                    DialogResult dr = fd.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        try
                        {
                            OptimizedTexture newOptimizedTexture = new OptimizedTexture(fd.FileName, getDownsampling());
                            if (!RenderWindow.IsPowerOfTwo(newOptimizedTexture.GetSize(1).Width) || !RenderWindow.IsPowerOfTwo(newOptimizedTexture.GetSize(1).Height))
                            {
                                throw new Exception("Width and height of bitmap must be powers of 2.");
                            }
                            myOptimizedTexture.Dispose();
                            myOptimizedTexture = newOptimizedTexture;
                            myOptimizedTexture.SetEditor(this, myAdjustMetricForm, myRenderWindow);
                            AutoScrollMinSize = myOptimizedTexture.GetSize(getZoom());
                            Dirty();
                            theFile = null;
                            Text    = "untitled";
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(this, "Error on loading:\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void changeZoom(object sender, System.EventArgs e)
 {
     zoomOffMenuItem.Checked    = false;
     zoom2MenuItem.Checked      = false;
     zoom4MenuItem.Checked      = false;
     ((MenuItem)sender).Checked = true;
     AutoScrollMinSize          = myOptimizedTexture.GetSize(getZoom());
     Dirty();
 }
Ejemplo n.º 4
0
        public ContourEditor()
        {
            InitializeComponent();
            SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

            Assembly assem = Assembly.GetAssembly(typeof(ContourEditor));
            Stream   st    = assem.GetManifestResourceStream("BilievelTextureMagnification.Curvy.jpg");

            myOptimizedTexture = new OptimizedTexture(st, getDownsampling());
            st.Close();
            st = null;

            myAdjustMetricForm = new AdjustMetricForm();
            myRenderWindow     = RenderWindow.Create();
            myOptimizedTexture.SetEditor(this, myAdjustMetricForm, myRenderWindow);
            AutoScrollMinSize = myOptimizedTexture.GetSize(getZoom());
            Dirty();
        }