/// <summary> /// Initialization /// </summary> /// <param name="owner">Reference to the owner form</param> /// <param name="docManager">Reference to Document manager</param> public void Initialize(Form owner, DocManager docManager) { SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); Invalidate(); // Keep reference to owner form //HAMID //this.Owner = owner; this.DocManager = docManager; // set default tool activeTool = DrawToolType.Pointer; // Create undo manager undoManager = new UndoManager(_layers); // create array of drawing tools tools = new Tool[(int)DrawToolType.NumberOfDrawTools]; tools[(int)DrawToolType.Pointer] = new ToolPointer(); tools[(int)DrawToolType.Rectangle] = new ToolRectangle(); tools[(int)DrawToolType.Ellipse] = new ToolEllipse(); tools[(int)DrawToolType.Line] = new ToolLine(); tools[(int)DrawToolType.PolyLine] = new ToolPolyLine(); tools[(int)DrawToolType.Polygon] = new ToolPolygon(); tools[(int)DrawToolType.Text] = new ToolText(); tools[(int)DrawToolType.Image] = new ToolImage(); LineColor = Color.White; FillColor = Color.Gray; LineWidth = -1; }
private void InitializeHelperObjects() { int x = drawArea.TheLayers.ActiveLayerIndex; // DocManager DocManagerData data = new DocManagerData(); //HAMID //data.FormOwner = this; data.UpdateTitle = true; data.FileDialogFilter = "Genetibase.NuGenAnnotation files (*.dtl)|*.dtl|All Files (*.*)|*.*"; data.NewDocName = "Untitled.dtl"; //data.RegistryPath = registryPath; docManager = new DocManager(data); docManager.RegisterFileType("dtl", "dtlfile", "Genetibase.NuGenAnnotation File"); // Subscribe to DocManager events. docManager.SaveEvent += docManager_SaveEvent; docManager.LoadEvent += docManager_LoadEvent; docManager.DocChangedEvent += delegate(object o, EventArgs e) { drawArea.Refresh(); drawArea.ClearHistory(); }; docManager.ClearEvent += delegate(object o, EventArgs e) { 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(); }
/// <summary> /// Initialize helper objects from the Genetibase.NuGenAnnotation Library. /// /// Called from Form1_Load. Initialized all objects except /// PersistWindowState wich must be initialized in the /// form constructor. /// </summary> private void InitializeHelperObjects() { int x = drawArea.TheLayers.ActiveLayerIndex; // DocManager DocManagerData data = new DocManagerData(); //HAMID //data.FormOwner = this; data.UpdateTitle = true; data.FileDialogFilter = "Genetibase.NuGenAnnotation files (*.dtl)|*.dtl|All Files (*.*)|*.*"; data.NewDocName = "Untitled.dtl"; data.RegistryPath = registryPath; docManager = new DocManager(data); docManager.RegisterFileType("dtl", "dtlfile", "Genetibase.NuGenAnnotation 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) { 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 recentFilesToolStripMenuItem, // Recent Files menu item fileToolStripMenuItem, // parent registryPath); // Registry path to keep MRU list mruManager.MruOpenEvent += delegate(object sender, MruFileOpenEventArgs e) { OpenDocument(e.FileName); }; }
/// <summary> /// Initialize helper objects from the Genetibase.NuGenAnnotation Library. /// /// Called from Form1_Load. Initialized all objects except /// PersistWindowState wich must be initialized in the /// form constructor. /// </summary> private void InitializeHelperObjects() { int x = drawArea.TheLayers.ActiveLayerIndex; // DocManager DocManagerData data = new DocManagerData(); //HAMID //data.FormOwner = this; data.UpdateTitle = true; data.FileDialogFilter = "Genetibase.NuGenAnnotation files (*.dtl)|*.dtl|All Files (*.*)|*.*"; data.NewDocName = "Untitled.dtl"; data.RegistryPath = registryPath; docManager = new DocManager(data); docManager.RegisterFileType("dtl", "dtlfile", "Genetibase.NuGenAnnotation 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) { 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 recentFilesToolStripMenuItem, // Recent Files menu item fileToolStripMenuItem, // parent registryPath); // Registry path to keep MRU list mruManager.MruOpenEvent += delegate(object sender, MruFileOpenEventArgs e) { OpenDocument(e.FileName); }; }