Esempio n. 1
0
 private void filePrintPreviewMenuItem_Click(object sender, System.EventArgs e)
 {
     if (this.ActiveMdiChild is ChildForm)
     {
         BMDocument doc = (this.ActiveMdiChild as ChildForm).Document;
         doc.SubscribeToPrint(prDoc);
         this.printPreviewDialog.Document = prDoc;
         this.printPreviewDialog.ShowDialog();
         doc.UnsubscribeToPrint(prDoc);
     }
 }
Esempio n. 2
0
        // add new window (yet another view for the document)
        private void windowNewWindowMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild is ChildForm)
            {
                BMDocument doc  = (this.ActiveMdiChild as ChildForm).Document;
                ChildForm  form = new ChildForm(doc);
                form.MdiParent = this;
                form.Show();

                doc.AddView(form);
            }
        }
Esempio n. 3
0
        private void filePrintMenuItem_Click(object sender, System.EventArgs e)
        {
            if (this.ActiveMdiChild is ChildForm)
            {
                BMDocument doc = (this.ActiveMdiChild as ChildForm).Document;

                try
                {
                    doc.SubscribeToPrint(prDoc);
                    prDoc.Print();
                }
                finally
                {
                    doc.UnsubscribeToPrint(prDoc);
                }
            }
        }
Esempio n. 4
0
        public ChildForm(BMDocument document)
        {
            InitializeComponent();
            this.doc = document;

            // subscribing to Document events
            this.doc.TransactionBegin += new EventHandler(doc_TransactionBegin);
            this.doc.TransactionEnd   += new EventHandler(doc_TransactionEnd);
            this.doc.DocumentInvalid  += new EventHandler(doc_DocumentInvalid);

            docIndex  = this.doc.ViewCount;
            this.Text = Path.GetFileName(this.doc.FileName) + " : " + this.docIndex.ToString();

            this.timer.Interval = 100;             //100ms
            this.timer.Tick    += new EventHandler(timer_Tick);

            //create own buffer image
            this.UpdateBuffer();
        }
Esempio n. 5
0
        /// <summary>
        /// Opens and add file
        /// </summary>
        /// <param name="fileName">name of the file</param>
        private void OpenFile(string fileName)
        {
            try
            {
                // create document
                BMDocument doc = new BMDocument(fileName);

                // create view
                ChildForm form = new ChildForm(doc);
                form.MdiParent = this;
                form.Show();
                // adding view to main form
                doc.AddView(form);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Image file {0} coouldn't be loaded due error : {1}",
                                              fileName, ex.Message));
            }
        }
Esempio n. 6
0
        private void editMenuItem_Popup(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild is ChildForm)
            {
                BMDocument doc = (this.ActiveMdiChild as ChildForm).Document;

                // set properties of current document
                this.editHalfMenuItem.Checked = doc.EditHalf;
                this.editUndoMenuItem.Enabled = doc.UndoEnabled;
                // stop operation enable ?
                this.editStopMenuItem.Enabled = !doc.Editable;
                // disable or enable filter operations
                this.editBlurMenuItem.Enabled         = doc.Editable;
                this.editConstrastMenuItem.Enabled    = doc.Editable;
                this.editCountourMenuItem.Enabled     = doc.Editable;
                this.editDenoiseMenuItem.Enabled      = doc.Editable;
                this.editEmbossMenuItem.Enabled       = doc.Editable;
                this.editHistogramMenuItem.Enabled    = doc.Editable;
                this.editInvertColorsMenuItem.Enabled = doc.Editable;
                this.editSharpMenuItem.Enabled        = doc.Editable;
            }
        }
Esempio n. 7
0
        // file - > Save as ...
        private void fileSaveAsMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild is ChildForm)
            {
                // get document
                BMDocument doc = (this.ActiveMdiChild as ChildForm).Document;

                Guid formatGuid;
                formatGuid = doc.CurrentBM.RawFormat.Guid;
                int n = 0; // filter index
                ImageCodecInfo[] codecList = ImageCodecInfo.GetImageEncoders();
                for (n = 1; n < codecList.Length; n++)
                {
                    if (codecList[n].FormatID == formatGuid)
                    {
                        break;
                    }
                }
                // set current filter (curent image type)
                this.saveFileDialog.FilterIndex = n + 1;

                // if User clicks ok in save file dialog
                if (this.saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        // saves file in format, that user choose
                        doc.CurrentBM.Save(this.saveFileDialog.FileName, new ImageFormat(codecList[this.saveFileDialog.FilterIndex - 1].Clsid));
                        //doc.FileName = this.saveFileDialog.FileName; // dont set to docuemnt new file name
                        doc.Modified = false;// set modified flag to false
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(String.Format("Couldn't save file :  {0}", ex.Message), "BWViewer");
                    }
                }
            }
        }