Пример #1
0
        public Save_Open(Save_Open_Data data)
        {
            frmOwner = data.FormOwner;

            updateTitle = data.UpdateTitle;

            newDocName = data.NewDocName;

            fileDlgFilter = data.FileDialogFilter;

            registryPath = data.RegistryPath;

            if (!registryPath.EndsWith("\\"))
            {
                registryPath += "\\";
            }

            registryPath += "FileDir";

            RegistryKey key = Registry.CurrentUser.OpenSubKey(registryPath);

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

                if (!Empty(s))
                {
                    fileDlgInitDir = s;
                }
            }
        }
Пример #2
0
        // Khởi tạo DocManger để quản lý save/open file .meg
        public void InitializeHelperObjects()
        {
            Save_Open_Data data = new Save_Open_Data();

            data.FormOwner        = this;
            data.UpdateTitle      = true;
            data.FileDialogFilter = "Mega files (*.meg)|*.meg|All Files (*.*)|*.*";
            data.NewDocName       = "Untitled.meg";

            docManager = new Save_Open(data);
            docManager.RegisterFileType("meg", "megfile", "Mega File");

            docManager.SaveEvent += docManager_SaveEvent;
            docManager.LoadEvent += docManager_LoadEvent;

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

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

            docManager.NewDocument();
        }