Ejemplo n.º 1
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner">Reference to the owner form</param>
        /// <param name="docManager">Reference to Document manager</param>
        public void Initialize(MainForm owner, DocManager docManager)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            Invalidate();

            // Keep reference to owner form
            Owner      = owner;
            DocManager = docManager;

            // set default tool
            activeTool = FBDDrawToolType.Pointer;

            // Create undo manager
            undoManager = new UndoManager(_layers);

            // create array of drawing tools
            tools = new Tool[(int)FBDDrawToolType.NumberOfDrawTools];
            tools[(int)FBDDrawToolType.Pointer]   = new ToolPointer();
            tools[(int)FBDDrawToolType.Variable]  = new ToolVariable();
            tools[(int)FBDDrawToolType.FB]        = new ToolFB();
            tools[(int)FBDDrawToolType.FB]        = new ToolFunction();
            tools[(int)FBDDrawToolType.Connector] = new ToolConnection();
            tools[(int)FBDDrawToolType.Comment]   = new ToolComment();

            LineColor = Color.Black;
            FillColor = Color.White;
            LineWidth = -1;
        }
Ejemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();

            g = this.CreateGraphics();

            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");

            this.Cursor = Cursors.Cross;

            drawArea.Location = new System.Drawing.Point(0, 0);
            drawArea.Size = new System.Drawing.Size(200, 200);
            drawArea.Owner = this;
            drawArea.Visible = false;
            drawArea.Initialize(this, docManager);

            GraphicsProperties graphicProperties = drawArea.GraphicsList.GetProperties();
            this.myColorPicker.SelectedColor = DrawSettings.LastUsedColor;
            this.myColorPicker.PenWidth = graphicProperties.PenWidth;
            this.drawArea.ToolTextBox.ForeColor = DrawSettings.LastUsedColor;

            this.myColorPicker.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                GraphicsProperties p = new GraphicsProperties();
                p.Color = e.Color;
                p.PenWidth = e.Width;
                this.drawArea.ToolTextBox.ForeColor = e.Color.Value;
                this.drawArea.ToolTextBox.Font = new System.Drawing.Font("Arial Narrow", e.TextSize);

                if (drawArea.GraphicsList.ShowColorPickerPanel(drawArea, p))
                {
                    drawArea.SetDirty();
                    drawArea.Refresh();
                }
            };
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner">Reference to the owner form</param>
        /// <param name="docManager">Reference to Document manager</param>
        public void Initialize(DocManager docManager)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                 ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            Invalidate();
            // Keep reference to owner form
            //Owner = owner;
            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.Pointer] as ToolPointer).parentContorl = this;
            //Owner.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FT_Status_Child_FormClosing);
            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();
            tools[(int)DrawToolType.Connector] = new ToolConnector();
            tools[(int)DrawToolType.StationTrack] = new ToolStationTrack();
            tools[(int)DrawToolType.Turnout] = new ToolTurnout();
            tools[(int)DrawToolType.Template] = new ToolTemplate(null);
            // tools[(int)DrawToolType.SwitchMachine] = new ToolSwitchMachine();

            LineColor = Color.Black;
            FillColor = Color.White;
            LineWidth = -1;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="docManager"></param>
        public void Initialize(MainForm owner, DocManager docManager)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);

            // Keep reference to owner form
            this.Owner = owner;
            this.DocManager = docManager;

            // set default tool
            activeTool = DrawToolType.Pointer;

            // create list of graphic objects
            graphicsList = new GraphicsList();

            // Create undo manager
            undoManager = new UndoManager(graphicsList);

            // 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.Triangle] = new ToolTriangle();
            tools[(int)DrawToolType.Line] = new ToolLine();
            tools[(int)DrawToolType.Polygon] = new ToolPolygon();
        }
Ejemplo n.º 5
0
        private void Initialize()
        {
            DocManagerData data = new DocManagerData();
            data.FormOwner = owner;
            data.UpdateTitle = true;
            data.FileDialogFilter = "DrawTools files (*.dtl)|*.dtl|All Files (*.*)|*.*";

            docManager = new DocManager(data);
            //docManager.RegisterFileType("dtl", "dtlfile", "DrawTools File");
            docManager.LoadEvent += docManager_LoadEvent;
            docManager.OpenEvent += delegate(object sender1, OpenFileEventArgs e1)
            {
                if (e1.Succeeded)
                    mruManager.Add(e1.FileName);
                else
                    mruManager.Remove(e1.FileName);
            };

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

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

            mruManager = new MruManager();
        }
Ejemplo n.º 6
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);
            };
        }
Ejemplo n.º 7
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); };
        }