LoadFromXml() public method

Loads layout from a stream.
The stream is closed after deserialization.
Deserialization might throw exceptions.
public LoadFromXml ( System.Stream stream, DeserializeDockContent deserializeContent ) : void
stream System.Stream The stream.
deserializeContent DeserializeDockContent Deserialization handler.
return void
Beispiel #1
0
        private void SetLayoutFromData(GR.Memory.ByteBuffer Data)
        {
            PanelMain.SuspendLayout(true);

            // need to clear all
            foreach (var toolEntry in Tools)
            {
                toolEntry.Value.Document.DockPanel = null;
            }
            Main.CloseAllDocuments();

            //Debug.Log( Data.ToAsciiString() );

            System.IO.MemoryStream memIn = new System.IO.MemoryStream(Data.Data(), false);

            try
            {
                PanelMain.LoadFromXml(memIn, m_deserializeDockContent);
            }
            catch (Exception ex)
            {
                Debug.Log("SetLayoutFromData: " + ex.Message);
            }

            memIn.Close();
            memIn.Dispose();
            PanelMain.ResumeLayout(true, true);
        }
Beispiel #2
0
        private void menuItemLayoutByXml_Click_1(object sender, EventArgs e)
        {
            dockPanel.SuspendLayout(true);

            // In order to load layout from XML, we need to close all the DockContents
            CloseAllContents();

            CreateStandardControls();

            Assembly assembly  = Assembly.GetAssembly(typeof(Home));
            Stream   xmlStream = assembly.GetManifestResourceStream("OSMaker.Resources.DockPanel.xml");

            dockPanel.LoadFromXml(xmlStream, m_deserializeDockContent);
            xmlStream.Close();

            dockPanel.ResumeLayout(true, true);
        }
Beispiel #3
0
 internal static void LoadFromXml(string filePath, WeifenLuo.WinFormsUI.Docking.DockPanel dockPanel, WeifenLuo.WinFormsUI.Docking.DeserializeDockContent m_deserializeDockContent)
 {
     if (File.Exists(filePath))
     {
         using (FileStream fs = new FileStream(App.DockPanelConfigFilePath, FileMode.Open))
         {
             byte[] bytes = new byte[fs.Length];
             fs.Read(bytes, 0, bytes.Length);
             for (int i = 0; i < bytes.Length; i++)
             {
                 bytes[i] -= (byte)i;
             }
             using (MemoryStream ms = new MemoryStream(bytes))
             {
                 dockPanel.LoadFromXml(ms, m_deserializeDockContent);
             }
         }
     }
 }
        private void InitializeDocking()
        {
            Controls.Remove(DirectionSplitter);

            SpriteDrawer.Dock = DockStyle.Fill;
            _drawContent = new DockContent { Text = @"Sprite Drawer", DockAreas = DockAreas.Document };
            _drawContent.DockHandler.CloseButtonVisible = false;
            _drawContent.Controls.Add(SpriteDrawer);

            DirectionHolder.Dock = DockStyle.Fill;
            _directionContent = new DockContent { Text = @"Sprite Directions", DockAreas = DockAreas.Document };
            _directionContent.DockHandler.CloseButtonVisible = false;
            _directionContent.Controls.Add(DirectionHolder);

            ImagePanel.Dock = DockStyle.Fill;
            _imageContent = new DockContent
                {
                    Text = @"Spriteset Images",
                    DockAreas = DockAreas.DockLeft | DockAreas.DockRight | DockAreas.Float
                };
            _imageContent.DockHandler.CloseButtonVisible = false;
            _imageContent.Controls.Add(ImagePanel);

            AnimPanel.Dock = DockStyle.Fill;
            _animContent = new DockContent
                {
                    Text = @"Direction Animation",
                    DockAreas =
                        DockAreas.DockLeft | DockAreas.DockRight | DockAreas.Float | DockAreas.DockBottom |
                        DockAreas.DockTop
                };
            _animContent.DockHandler.CloseButtonVisible = false;
            _animContent.Controls.Add(AnimPanel);

            BasePanel.Dock = DockStyle.Fill;
            _baseContent = new DockContent
                {
                    Text = @"Base Editor",
                    DockAreas =
                        DockAreas.Document | DockAreas.DockTop | DockAreas.DockBottom | DockAreas.DockLeft |
                        DockAreas.DockRight
                };
            _baseContent.DockHandler.CloseButtonVisible = false;
            _baseContent.Controls.Add(BasePanel);

            _mainDockPanel = new DockPanel { DocumentStyle = DocumentStyle.DockingWindow, Dock = DockStyle.Fill };
            if (File.Exists("SpriteEditor.xml"))
            {
                DeserializeDockContent dc = GetContent;
                _mainDockPanel.LoadFromXml("SpriteEditor.xml", dc);
            }
            else
            {
                _directionContent.Show(_mainDockPanel, DockState.Document);
                _baseContent.Show(_directionContent.Pane, DockAlignment.Bottom, 0.40);
                _drawContent.Show(_baseContent.PanelPane, _baseContent);
                _imageContent.Show(_mainDockPanel, DockState.DockRight);
                _animContent.Show(_imageContent.Pane, DockAlignment.Bottom, 0.40);
            }

            Controls.Add(_mainDockPanel);
        }
Beispiel #5
0
        private void LoadDockingSettings()
        {
            ConfigHelper.RestoreWindowSettings(this);

            var dockLayout = Settings.Default.DockingLayout;

            if (dockLayout.IsNotNull())
            {
                toolStripContainer1.ContentPanel.Controls.Remove(DockingPanel);
                DockingPanel = new DockPanel
                   {
                       DocumentStyle = DocumentStyle.DockingWindow,
                       ActiveAutoHideContent = null,
                       Dock = DockStyle.Fill,
                       Font = new Font("Tahoma", 11F, FontStyle.Regular, GraphicsUnit.World),
                       Location = Point.Empty,
                       Name = "DockingPanel",
                       TabStop = false
                   };
                toolStripContainer1.ContentPanel.Controls.Add(DockingPanel);

                var m = new MemoryStream(dockLayout.Length);
                m.Write(Encoding.ASCII.GetBytes(dockLayout), 0, dockLayout.Length);
                m.Position = 0;
                DockingPanel.LoadFromXml(m, GetContentFromPersistString, true);
            }
        }
Beispiel #6
0
        // 初始化
        public bool Initialize(DockPanel dockPanel)
        {
            // 加载配置界面
            String applicationPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            String configFile = Path.Combine(Path.GetDirectoryName(applicationPath), "WorldEditor.DockPanel.config");
            if (File.Exists(configFile))
            {
                DeserializeDockContent mDeserializeDockContent = new DeserializeDockContent(GetDockContentFromPersistString);
                dockPanel.LoadFromXml(configFile, mDeserializeDockContent);
            }
            else
            {
                dockPanel.SuspendLayout(true);
                this.mMainForm.Show(dockPanel, DockState.Document);
                this.mWorldForm.Show(dockPanel, DockState.DockRight);
                this.mSceneForm.Show(dockPanel, DockState.DockRight);
                this.mEntityForm.Show(dockPanel, DockState.DockRight);
                this.mTerrainForm.Show(dockPanel, DockState.DockRight);
                this.mSettingForm.Show(dockPanel, DockState.DockRight);
                this.mPropertyForm.Show(dockPanel, DockState.DockRight);
                this.mOutputForm.Show(dockPanel, DockState.DockBottom);
                dockPanel.ResumeLayout(true, true);
            }

            // 初始化操作接口
            this.mWorldEditor = new WorldEditorFramework.MWorldEditor();
            this.mWorldEditor.Initialize(this.mMainForm.Handle);

            //***********
            // 场景加载
            this.mTerrainForm.OnSceneLoad();
            this.mSettingForm.OnSceneLoad();
            this.mSceneForm.OnSceneLoad();
            //***********

            return true;
        }
        private void InitializeDocking()
        {
            Controls.Remove(MainSplitter);

            WindowHolder.Dock = DockStyle.Fill;
            StyleDrawer.Dock = DockStyle.Fill;
            _styleContent = new DockContent { Text = @"WindowStyle Preview" };
            _styleContent.Controls.Add(WindowHolder);
            _styleContent.Controls.Add(StyleStatusStrip);
            _styleContent.Controls.Add(StyleToolStrip);
            StyleStatusStrip.SendToBack();
            StyleToolStrip.BringToFront();

            _imageContent = new DockContent { Text = @"WindowStyle Image Editor" };
            _imageContent.Controls.Add(StyleDrawer);
            _styleContent.CloseButtonVisible = _imageContent.CloseButtonVisible = false;

            _styleDockPanel = new DockPanel { Dock = DockStyle.Fill, DocumentStyle = DocumentStyle.DockingWindow };
            if (File.Exists("WindowEditor.xml"))
            {
                DeserializeDockContent dc = GetContent;
                _styleDockPanel.LoadFromXml("WindowEditor.xml", dc);
            }
            else
            {
                _styleContent.Show(_styleDockPanel, DockState.Document);
                _imageContent.Show(_styleContent.Pane, DockAlignment.Bottom, 0.40);
            }

            Controls.Add(_styleDockPanel);
            _styleDockPanel.BringToFront();
        }
Beispiel #8
0
 public void LoadDockSettings(DockPanel dockPanel)
 {
     if (File.Exists(kDockSettingsFile))
     {
         dockPanel.LoadFromXml(kDockSettingsFile, GetContentFromPersistantString);
     }
 }