示例#1
0
        /// <summary>
        /// Initialize helper objects from the DocToolkit Library.
        /// 
        /// Called from Form1_Load. Initialized all objects except
        /// PersistWindowState wich must be initialized in the
        /// form constructor.
        /// </summary>
        private void InitializeHelperObjects()
        {
            // DocManager

            DocManagerData data = new DocManagerData();
            data.FormOwner = this;
            data.UpdateTitle = true;
            data.FileDialogFilter = "DrawTools files (*.dtl)|*.dtl|All Files (*.*)|*.*";
            data.NewDocName = "Untitled.dtl";
            data.RegistryPath = registryPath;

            docManager = new DocManager(data);
            docManager.RegisterFileType("dtl", "dtlfile", "DrawTools File");

            // Subscribe to DocManager events.
            docManager.SaveEvent += docManager_SaveEvent;
            docManager.LoadEvent += docManager_LoadEvent;

            // Make "inline subscription" using anonymous methods.
            docManager.OpenEvent += delegate(object sender, OpenFileEventArgs e)
            {
                // Update MRU List
                if (e.Succeeded)
                    mruManager.Add(e.FileName);
                else
                    mruManager.Remove(e.FileName);
            };

            docManager.DocChangedEvent += delegate(object o, EventArgs e)
            {
                drawArea.Refresh();
                drawArea.ClearHistory();
            };

            docManager.ClearEvent += delegate(object o, EventArgs e)
            {
                if (drawArea.GraphicsList != null)
                {
                    drawArea.GraphicsList.Clear();
                    drawArea.ClearHistory();
                    drawArea.Refresh();
                }
            };

            docManager.NewDocument();

            // DragDropManager
            dragDropManager = new DragDropManager(this);
            dragDropManager.FileDroppedEvent += delegate(object sender, FileDroppedEventArgs e)
            {
                OpenDocument(e.FileArray.GetValue(0).ToString());
            };

            // MruManager
            mruManager = new MruManager();
            mruManager.Initialize(
                this,                              // owner form
                recentFilesToolStripMenuItem,      // Recent Files menu item
                fileToolStripMenuItem,            // parent
                registryPath);                     // Registry path to keep MRU list

            mruManager.MruOpenEvent += delegate(object sender, MruFileOpenEventArgs e)
            {
                OpenDocument(e.FileName);
            };
        }
示例#2
0
        /// <summary>
        /// Initialize helper objects from the DocToolkit Library.
        /// 
        /// Called from Form1_Load. Initialized all objects except
        /// PersistWindowState wich must be initialized in the
        /// form constructor.
        /// </summary>
        private void InitializeHelperObjects()
        {
            // DocManager
            DocManagerData data = new DocManagerData();
            data.FormOwner = this;
            data.UpdateTitle = true;
            data.FileDialogFilter = "DrawTools files (*.dtl)|*.dtl|All Files (*.*)|*.*";
            data.NewDocName = "Untitled.dtl";

            docManager = new DocManager(data);
            docManager.RegisterFileType("dtl", "dtlfile", "DrawTools File");

            docManager.SaveEvent += docManager_SaveEvent;
            docManager.LoadEvent += docManager_LoadEvent;
            docManager.SaveTemplateEvent += docManager_SaveTemplateEvent;
            docManager.LoadTemplateEvent += docManager_LoadTemplateEvent;
            // Make "inline subscription" using anonymous methods.
            docManager.OpenEvent += delegate(object sender, OpenFileEventArgs e)
                                        {
                                            // Update MRU List
                                            if (e.Succeeded)
                                                mruManager.Add(e.FileName);
                                            else
                                                mruManager.Remove(e.FileName);
                                        };

            docManager.DocChangedEvent += delegate
                                            {
                                                drawArea.Refresh();
                                                drawArea.ClearHistory();
                                            };

            docManager.ClearEvent += delegate
                                        {
                                            bool haveObjects = false;
                                            for (int i = 0; i < drawArea.TheLayers.Count; i++)
                                            {
                                                if (drawArea.TheLayers[i].Graphics.Count > 1)
                                                {
                                                    haveObjects = true;
                                                    break;
                                                }
                                            }
                                            if (haveObjects)
                                            {
                                                drawArea.TheLayers.Clear();
                                                drawArea.ClearHistory();
                                                drawArea.Refresh();
                                            }
                                        };

            docManager.NewDocument();

            // DragDropManager
            dragDropManager = new DragDropManager(this);
            dragDropManager.FileDroppedEvent += delegate(object sender, FileDroppedEventArgs e) { OpenDocument(e.FileArray.GetValue(0).ToString()); };

            // MruManager
            mruManager = new MruManager();
            mruManager.Initialize(
                this, // owner form
                tsmiRecentFiles, // Recent Files menu item
                fileToolStripMenuItem // parent
                );

            mruManager.MruOpenEvent += delegate(object sender, MruFileOpenEventArgs e) { OpenDocument(e.FileName); };
        }