Ejemplo n.º 1
0
        /*
         * The following methods are responsible for creating new
         * documents and opening existing documents from file paths
         * supplied by the document management system.
         */

        public IDockContent NewDocument()
        {
            /*
             * This doesn't mean much for this demo as we'll just
             * end up with an empty document.
             */

            DocumentForm form = new DocumentForm();

            form.Text = String.Format("untitled{0}{1}",
                                      documentCount++, documentType.ToString());
            form.FileName = form.Text;
            form.FilePath = null;

            return(form);
        }
Ejemplo n.º 2
0
        public IDockContent OpenDocument(string path, bool readOnly)
        {
            /*
             * Activate the file if it's already been loaded.
             */

            foreach (Document d in mainForm.ClientWindow.Documents)
            {
                if (d.FilePath != null &&
                    d.FilePath.ToLower() == path.ToLower() &&
                    !d.AllowDuplicates())
                {
                    d.Activate();
                    return(null);
                }
            }

            /*
             * Create a new document and load the image.
             */

            FileInfo fileInfo = new FileInfo(path);

            DocumentForm form = new DocumentForm();

            form.Text     = fileInfo.Name;
            form.FileName = form.Text;
            form.FilePath = fileInfo.FullName;

            /*
             * Load the data.
             */

            try
            {
                form.Image.Load(fileInfo.FullName);
            }
            catch
            {
                // Return null if open fails.
                return(null);
            }

            return(form);
        }
Ejemplo n.º 3
0
        private void UpdateImageMenu()
        {
            /*
             * When the menu is opened check if it is the correct
             * document type and then set the menu state based on the
             * document properties. Again there could be multiple
             * menu items here but we only have one for this demo.
             */

            DocumentForm form = mainForm.ActiveDocument as DocumentForm;

            if (form == null)
            {
                return;
            }

            imageMenuStretch.Checked = form.Stretch;
        }
Ejemplo n.º 4
0
        private void UpdateToolbar()
        {
            /*
             * The toolbar is always visible so we have to make
             * some effort to keep it up to date. This method
             * is called wherever an action could change the state
             * of the toolbar.
             */

            if (toolbarButtonStretch.Enabled)
            {
                DocumentForm form =
                    mainForm.ActiveDocument as DocumentForm;

                if (form != null)
                {
                    toolbarButtonStretch.Checked = form.Stretch;
                }
            }
            else
            {
                toolbarButtonStretch.Checked = false;
            }
        }