Exemplo n.º 1
0
        private void SAVE_Click(object sender, RoutedEventArgs e)
        {
            DevZest.Windows.Docking.DockLayout layout = c1.Save();
            // XmlWriterSettings settings = new XmlWriterSettings();
            // settings.Indent = true;
            // settings.IndentChars = new string(' ', 4);
            // StringBuilder strbuild = new StringBuilder();
            // XmlWriter xmlWriter = XmlWriter.Create(strbuild, settings);
            // XamlWriter.Save(layout, xmlWriter);

            string s = WpfApp2.XamlWriter.Save(layout);
            // Textbox3.textBox.Text = WpfApp2.XamlWriter.Save(layout);



            // string json = JsonConvert.SerializeObject(layout);
            FileStream   xjFileStream   = new FileStream(rfp, FileMode.Create, FileAccess.Write);
            StreamWriter xjStreamWriter = new StreamWriter(xjFileStream, Encoding.Default);

            //   Console.WriteLine(s);
            xjStreamWriter.WriteLine(s);
            // xjStreamWriter.WriteLine(strbuild.ToString());
            //  xjStreamWriter.WriteLine(XamlWriter.Save(layout));
            xjStreamWriter.Close();
            xjFileStream.Close();
        }
Exemplo n.º 2
0
        private void savelayout()
        {
            DevZest.Windows.Docking.DockLayout layout = c1.Save();
            string       s              = WpfApp2.XamlWriter.Save(layout);
            FileStream   xjFileStream   = new FileStream(rfp, FileMode.Create, FileAccess.Write);
            StreamWriter xjStreamWriter = new StreamWriter(xjFileStream, Encoding.Default);

            xjStreamWriter.WriteLine(s);
            xjStreamWriter.Close();
            xjFileStream.Close();
        }
Exemplo n.º 3
0
        /// <summary>Loads the window layout.</summary>
        /// <param name="layout">The specified <see cref="DockLayout"/> instance.</param>
        /// <param name="loadDockItemCallback">Callback to load <see cref="DockItem"/>. This callback
        /// takes an <see cref="object"/> returned by <see cref="DockItem.Save">DockItem.Save</see> method, returns an
        /// <see cref="DockItem"/> instance.</param>
        /// <remarks>Calling this method will clear all undo stack.</remarks>
        /// <exception cref="ArgumentNullException"><paramref name="layout"/> is <see langword="null"/>.</exception>
        /// <exception cref="InvalidOperationException">The <see cref="DockItems"/> collection is not empty. Close all <see cref="DockItem"/> before calling <see cref="Load"/>.</exception>
        public void Load(DockLayout layout, Func <object, DockItem> loadDockItemCallback)
        {
            if (layout == null)
            {
                throw new ArgumentNullException("layout");
            }

            if (DockItems.Count != 0)
            {
                throw new InvalidOperationException(SR.Exception_DockControl_Load_DockItemsNotEmpty);
            }

            DockLayoutAdapter.Load(this, layout, loadDockItemCallback);
            ClearUndo();
        }
Exemplo n.º 4
0
        private void FillDockActions(DockControl dockControl, DockLayout layout)
        {
            lock (this)
            {
                foreach (DockItem item in GetDockItems(dockControl, delegate(DockItem item, DockPane pane) { return(item.SecondPane == pane); }))
                {
                    layout.ShowActions.Add(GetShowAction(item, item.SecondPane));
                }

                foreach (DockItem item in GetDockItems(dockControl, delegate(DockItem item, DockPane pane) { return(item.FirstPane == pane); }))
                {
                    layout.ShowActions.Add(GetShowAction(item, item.FirstPane));
                }

                _itemsCollections.Clear();
                _panes.Clear();
                _splits.Clear();
            }
        }
Exemplo n.º 5
0
        internal static void Load(DockControl dockControl, DockLayout layout, Func <object, DockItem> loadDockItemCallback)
        {
            Debug.Assert(dockControl.DockItems.Count == 0);

            dockControl.DockTreeZOrder       = layout.DockTreeZOrder;
            dockControl.LeftDockTreeWidth    = layout.LeftDockTreeWidth;
            dockControl.RightDockTreeWidth   = layout.RightDockTreeWidth;
            dockControl.TopDockTreeHeight    = layout.TopDockTreeHeight;
            dockControl.BottomDockTreeHeight = layout.BottomDockTreeHeight;
            DockItemCollection items = dockControl.DockItems;

            foreach (DockItemReference itemRef in layout.DockItems)
            {
                DockItem item = loadDockItemCallback == null ? (DockItem)itemRef.Target : loadDockItemCallback(itemRef.Target);
                item.AutoHideSize = itemRef.AutoHideSize;
                items.AddInternal(item);
            }

            foreach (ShowAction action in layout.ShowActions)
            {
                action.Run(dockControl);
            }
        }
Exemplo n.º 6
0
        internal static DockLayout Save(DockControl dockControl)
        {
            DockLayout layout = new DockLayout();

            layout.DockTreeZOrder       = dockControl.DockTreeZOrder;
            layout.LeftDockTreeWidth    = dockControl.LeftDockTreeWidth;
            layout.RightDockTreeWidth   = dockControl.RightDockTreeWidth;
            layout.TopDockTreeHeight    = dockControl.TopDockTreeHeight;
            layout.BottomDockTreeHeight = dockControl.BottomDockTreeHeight;
            layout.DockItems.Clear();
            layout.ShowActions.Clear();

            foreach (DockItem item in dockControl.DockItems)
            {
                DockItemReference itemRef = new DockItemReference();
                itemRef.AutoHideSize = item.AutoHideSize;
                itemRef.Target       = item.Save();
                layout.DockItems.Add(itemRef);
            }

            Default.FillDockActions(dockControl, layout);

            return(layout);
        }