资源简介

C# 绘图实例 矩形 椭圆 直线 曲线 带控制点 可撤销 实例

资源截图

代码片段和文件信息

#region Using directives

using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Globalization;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using Microsoft.Win32;
using System.Security;

#endregion

// Using: in the end of this file.

namespace DocToolkit
{
    #region Class DocManager

    /// 
    /// Document manager. Makes file-related operations:
    /// open new save updating of the form title 
    /// registering of file type for Windows Shell.
    /// Built using the article:
    /// Creating Document-Centric Applications in Windows Forms
    /// by Chris Sells
    /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms09182003.asp
    /// 

    public class DocManager
    {

        #region Events

        public event SaveEventHandler SaveEvent;
        public event LoadEventHandler LoadEvent;
        public event OpenFileEventHandler OpenEvent;
        public event EventHandler ClearEvent;
        public event EventHandler DocChangedEvent;

        #endregion

        #region Members

        private string fileName = ““;
        private bool dirty = false;

        private Form frmOwner;
        private string newDocName;
        private string fileDlgFilter;
        private string registryPath;
        private bool updatetitle;

        private const string registryValue = “Path“;
        private string fileDlgInitDir = ““;         // file dialog initial directory

        #endregion

        #region Enum

        /// 
        /// Enumeration used for Save function
        /// 

        public enum SaveType
        {
            Save
            SaveAs
        }

        #endregion

        #region Constructor

        /// 
        /// Initialization
        /// 

        /// 
        public DocManager(DocManagerData data)
        {
            frmOwner = data.FormOwner;
            frmOwner.Closing += OnClosing;

            updatetitle = data.Updatetitle;

            newDocName = data.NewDocName;

            fileDlgFilter = data.FileDialogFilter;

            registryPath = data.RegistryPath;

            if (!registryPath.EndsWith(“\\“))
                registryPath += “\\“;

            registryPath += “FileDir“;

            // attempt to read initial directory from registry
            RegistryKey key = Registry.CurrentUser.OpenSubKey(registryPath);

            if (key != null)
            {
                string s = (string)key.GetValue(registryValue);

                if (!Empty(s))
                    fileDlgInitDir = s;
            }
        }

        #endregion

        #region Public functions and Properties

        /// 

        /// Dirty property (true when document has unsaved changes).
 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2007-01-21 21:27  DrawTools2005\
     目录           0  2007-01-21 21:27  DrawTools2005\DocToolkit\
     文件       28000  2007-01-12 16:46  DrawTools2005\DocToolkit\DocManager.cs
     文件        2191  2007-01-12 16:52  DrawTools2005\DocToolkit\DocToolkit.csproj
     文件        3941  2007-01-12 16:50  DrawTools2005\DocToolkit\DragDropManager.cs
     文件       16590  2007-01-12 16:47  DrawTools2005\DocToolkit\MruManager.cs
     文件        6401  2007-01-12 16:52  DrawTools2005\DocToolkit\PersistWindowState.cs
     目录           0  2007-01-21 21:26  DrawTools2005\DocToolkit\Properties\
     文件        1393  2007-01-12 16:44  DrawTools2005\DocToolkit\Properties\AssemblyInfo.cs
     目录           0  2007-01-21 21:27  DrawTools2005\DrawTools\
     文件         904  2007-01-20 20:50  DrawTools2005\DrawTools\Command.cs
     文件         766  2007-01-13 19:21  DrawTools2005\DrawTools\CommandAdd.cs
     文件        2399  2007-01-16 21:48  DrawTools2005\DrawTools\CommandChangeState.cs
     文件        1700  2007-01-16 21:32  DrawTools2005\DrawTools\CommandDelete.cs
     文件        1245  2007-01-16 21:32  DrawTools2005\DrawTools\CommandDeleteAll.cs
     文件       10149  2007-01-20 09:31  DrawTools2005\DrawTools\DrawArea.cs
     文件        1761  2007-01-13 17:36  DrawTools2005\DrawTools\DrawArea.Designer.cs
     文件        5814  2007-01-13 10:26  DrawTools2005\DrawTools\DrawArea.resx
     文件        1033  2007-01-14 20:22  DrawTools2005\DrawTools\DrawEllipse.cs
     文件        7237  2007-01-14 20:22  DrawTools2005\DrawTools\DrawLine.cs
     文件        9054  2007-01-14 21:08  DrawTools2005\DrawTools\Drawobject.cs
     文件        6625  2007-01-14 20:21  DrawTools2005\DrawTools\DrawPolygon.cs
     文件       10248  2007-01-14 20:22  DrawTools2005\DrawTools\DrawRectangle.cs
     文件        5716  2007-01-16 21:32  DrawTools2005\DrawTools\DrawTools.csproj
     文件         326  2007-01-13 11:43  DrawTools2005\DrawTools\Ellipse.cur
     文件         731  2007-01-13 17:37  DrawTools2005\DrawTools\FrmAbout.cs
     文件        3134  2007-01-13 11:54  DrawTools2005\DrawTools\FrmAbout.Designer.cs
     文件        7730  2007-01-13 11:54  DrawTools2005\DrawTools\FrmAbout.resx
     文件       14088  2007-01-19 21:02  DrawTools2005\DrawTools\GraphicsList.cs
     文件         916  2007-01-13 17:37  DrawTools2005\DrawTools\GraphicsProperties.cs
     目录           0  2007-01-21 21:26  DrawTools2005\DrawTools\Images\
............此处省略43个文件信息

评论

共有 条评论