protected override void OnLoad(EventArgs e) { XmlLayoutSerializer serializer = new XmlLayoutSerializer(_dockingManager); serializer.LayoutSerializationCallback += (s, args) => { switch (args.Model.ContentId) { case "toolWindow1": args.Content = new System.Windows.Controls.TextBlock() { Text = args.Model.ContentId }; break; default: args.Content = new System.Windows.Controls.TextBox() { Text = args.Model.ContentId }; break; } }; serializer.Deserialize( new System.IO.StringReader( AvalonDock.WinFormsTestApp.Properties.Settings.Default.DefaultLayout)); //LayoutDocument doc = new LayoutDocument() { Title = "test" }; //dockingManager.Layout.Descendents().OfType<LayoutDocumentPane>().First().Children.Add(doc); dockingManagerHost.Child = _dockingManager; base.OnLoad(e); }
// Attemps to create a new Layout public static bool CreateNewLayout(string layoutName) { if (layoutName.Trim().Equals(string.Empty)) return false; EditorCommands.ShowOutputMessage("Attempting to create a new layout"); if (layoutName.Equals("Default")) { EditorCommands.ShowOutputMessage("Cannot override Gibbo's Default Layout"); return false; } if (RemoveLayout(layoutName)) EditorCommands.ShowOutputMessage("Attempting to replace layout"); try { EditorCommands.ShowOutputMessage("Attempting to save the layout"); var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(DockManager); using (var stream = new StreamWriter(layoutPath + layoutName + LayoutExtension)) serializer.Serialize(stream); EditorCommands.ShowOutputMessage("Layout saved successfully"); } catch (Exception) { EditorCommands.ShowOutputMessage("Layout saving attempt has failed"); return false; } Properties.Settings.Default.Layout = layoutName; return true; }
public void LoadLayout(Action<ITool> addToolCallback) { var layoutSerializer = new XmlLayoutSerializer(Manager); layoutSerializer.LayoutSerializationCallback += (s, e) => { var anchorable = e.Model as LayoutAnchorable; if (anchorable != null) { var toolType = Type.GetType(e.Model.ContentId); if (toolType != null) { var tool = IoC.GetInstance(toolType, null) as ITool; if (tool != null) { e.Content = tool; addToolCallback(tool); tool.IsVisible = anchorable.IsVisible; if (anchorable.IsActive) tool.Activate(); tool.IsSelected = anchorable.IsSelected; } } } }; try { layoutSerializer.Deserialize(LayoutUtility.LayoutFile); } catch { } }
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { var layoutSerializer = new XmlLayoutSerializer(this.DockingManager); layoutSerializer.Serialize(@".\AvalonDock.layout"); base.OnClosing(e); }
private void Button_Click_1(object sender, RoutedEventArgs e) { ser = new XmlLayoutSerializer(dockingManager); StreamWriter sw = new StreamWriter(@"c:\working\1.ser"); ser.Serialize(sw); sw.Close(); }
private async Task SaveLayout() { using (var writer = new StringWriter()) { var layoutSerializer = new XmlLayoutSerializer(dockingManager); layoutSerializer.Serialize(writer); await BlobCache.UserAccount.InsertObject("layout", writer.ToString()); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { ser = new XmlLayoutSerializer(dockingManager); ser.LayoutSerializationCallback+=new EventHandler<LayoutSerializationCallbackEventArgs>(ser_LayoutSerializationCallback); using (StreamReader sr = new StreamReader(@"c:\working\1.ser")) { ser.Deserialize(sr); } }
public void Save(DockingManager manager) { string path = GetDockLayoutPath(); XmlLayoutSerializer layoutSerializer = new XmlLayoutSerializer(manager); using (var writer = new System.IO.StreamWriter(path)) { layoutSerializer.Serialize(writer); } }
public static void LoadLayout(DockingManager manager, Stream stream, Action<IDocument> addDocumentCallback, Action<ITool> addToolCallback, Dictionary<string, ILayoutItem> items) { var layoutSerializer = new XmlLayoutSerializer(manager); layoutSerializer.LayoutSerializationCallback += (s, e) => { ILayoutItem item; if (items.TryGetValue(e.Model.ContentId, out item)) { e.Content = item; var tool = item as ITool; var anchorable = e.Model as LayoutAnchorable; var document = item as IDocument; var layoutDocument = e.Model as LayoutDocument; if (tool != null && anchorable != null) { addToolCallback(tool); tool.IsVisible = anchorable.IsVisible; if (anchorable.IsActive) tool.Activate(); tool.IsSelected = e.Model.IsSelected; return; } if (document != null && layoutDocument != null) { addDocumentCallback(document); // Nasty hack to get around issue that occurs if documents are loaded from state, // and more documents are opened programmatically. layoutDocument.GetType().GetProperty("IsLastFocusedDocument").SetValue(layoutDocument, false, null); document.IsSelected = layoutDocument.IsSelected; return; } } // Don't create any panels if something went wrong. e.Cancel = true; }; try { layoutSerializer.Deserialize(stream); } catch { } }
void MainWindow_Unloaded(object sender, RoutedEventArgs e) { var rSerializer = new XmlLayoutSerializer(DockingManager); var rDirectory = Path.GetDirectoryName(DockConfigFile); if (!Directory.Exists(rDirectory)) Directory.CreateDirectory(rDirectory); rSerializer.Serialize(DockConfigFile); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer( dockManager ); serializer.LayoutSerializationCallback += (s, args) => { args.Content = args.Content; }; if (File.Exists(@".\AvalonDock.config")) serializer.Deserialize(@".\AvalonDock.config"); }
public MainWindow() { InitializeComponent(); DockManager.ActiveContentChanged += new EventHandler(DockManager_ActiveDocumentChanged); NewProfile(); _layoutSerializer = new XmlLayoutSerializer(this.DockManager); _layoutSerializer.LayoutSerializationCallback += LayoutSerializer_LayoutSerializationCallback; _defalutLayoutFile = System.IO.Path.Combine(ConfigManager.DocumentPath, "DefaultLayout.hly"); }
/// <summary> /// Save the docking style to file /// </summary> /// <param name="dm">the docking manager</param> public static void Save(DockingManager dm) { using (var sw = new StreamWriter("designer.dock")) { using (StringWriter fs = new StringWriter()) { XmlLayoutSerializer xmlLayout = new XmlLayoutSerializer(dm); xmlLayout.Serialize(fs); sw.Write(fs.ToString()); } } }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager); serializer.LayoutSerializationCallback += (s, args) => { args.Content = args.Content; }; if (File.Exists(@".\AvalonDock.config")) { serializer.Deserialize(@".\AvalonDock.config"); } }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { var rSerializer = new XmlLayoutSerializer(DockingManager); rSerializer.LayoutSerializationCallback += Serializer_LayoutSerializationCallback; if (File.Exists(DockConfigFile)) { var rDirectory = Path.GetDirectoryName(DockConfigFile); if (!Directory.Exists(rDirectory)) Directory.CreateDirectory(rDirectory); rSerializer.Deserialize(DockConfigFile); } }
/// <summary> /// load the dockign style from file /// </summary> /// <param name="dm">the docking manager</param> public static void Load(DockingManager dm) { if (File.Exists("designer.dock")) { XmlLayoutSerializer xmlLayout = new XmlLayoutSerializer(dm); using (var fs = new FileStream("designer.dock", FileMode.OpenOrCreate)) { xmlLayout.Deserialize(fs); } } else { // load default dock from ressource } }
private void LoadLayout() { BlobCache.UserAccount.GetObject<string>("layout") .SubscribeOnBackground() .Catch(Observable.Empty<string>()) .ObserveOnUI() .Subscribe(xml => { using (var reader = new StringReader(xml)) { var layoutSerializer = new XmlLayoutSerializer(dockingManager); layoutSerializer.Deserialize(reader); } }); }
public void Load(DockingManager manager) { string path = GetDockLayoutPath(); if (VerifyLayout(path)) { XmlLayoutSerializer layoutSerializer = new XmlLayoutSerializer(manager); layoutSerializer.LayoutSerializationCallback += (s, args) => { args.Content = args.Content; }; using (var reader = new System.IO.StreamReader(path)) { layoutSerializer.Deserialize(reader); } } }
private void OnLoadLayout(object parameter) { var layoutSerializer = new XmlLayoutSerializer(dockManager); //Here I've implemented the LayoutSerializationCallback just to show // a way to feed layout desarialization with content loaded at runtime //Actually I could in this case let AvalonDock to attach the contents //from current layout using the content ids //LayoutSerializationCallback should anyway be handled to attach contents //not currently loaded layoutSerializer.LayoutSerializationCallback += (s, e) => { //if (e.Model.ContentId == FileStatsViewModel.ToolContentId) // e.Content = Workspace.This.FileStats; //else if (!string.IsNullOrWhiteSpace(e.Model.ContentId) && // File.Exists(e.Model.ContentId)) // e.Content = Workspace.This.Open(e.Model.ContentId); }; layoutSerializer.Deserialize(@".\AvalonDock.Layout.config"); }
public UiMainWindow() { #region Construct Assembly assembly = Assembly.GetEntryAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); Title = String.Format("{0} {1} {2}", fvi.ProductName, fvi.FileVersion, fvi.LegalCopyright); Width = 640; Height = 480; WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowState = WindowState.Maximized; UiGrid root = UiGridFactory.Create(2, 1); root.RowDefinitions[0].Height = GridLength.Auto; DockingManager dockingManager = new DockingManager(); { root.AddUiElement(dockingManager, 1, 0); _layoutSerializer = new XmlLayoutSerializer(dockingManager); _layoutSerializer.LayoutSerializationCallback += OnLayoutDeserialized; } _mainMenu = UiMenuFactory.Create(); { _mainMenuView = _mainMenu.AddChild(UiMenuItemFactory.Create("Вид")); { foreach (UiMainDockableControl dockable in UiMainDockableControl.CreateKnownDockables(dockingManager)) _mainMenuView.AddChild(dockable.CreateMenuItem()); } root.AddUiElement(_mainMenu, 0, 0); } Content = root; #endregion Loaded += OnLoaded; Closing += OnClosing; }
// Attemps to Load a Layout public static bool LoadLayout(string layoutName) { if (!LayoutExists(layoutName)) { layoutName = "Default"; } try { var serializer = new XmlLayoutSerializer(DockManager); using (var stream = new StreamReader(string.Format(layoutPath + "{0}" + layoutExtension, layoutName))) serializer.Deserialize(stream); Properties.Settings.Default.Layout = layoutName; } catch (Exception) { return false; } // loaded successfully return true; }
// Attemps to create a new Layout public static bool CreateNewLayout(string layoutName) { if (layoutName.Trim().Equals(string.Empty)) { return(false); } EditorCommands.ShowOutputMessage("Attempting to create a new layout"); if (layoutName.Equals("Default")) { EditorCommands.ShowOutputMessage("Cannot override Gibbo's Default Layout"); return(false); } if (RemoveLayout(layoutName)) { EditorCommands.ShowOutputMessage("Attempting to replace layout"); } try { EditorCommands.ShowOutputMessage("Attempting to save the layout"); var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(DockManager); using (var stream = new StreamWriter(layoutPath + layoutName + LayoutExtension)) serializer.Serialize(stream); EditorCommands.ShowOutputMessage("Layout saved successfully"); } catch (Exception) { EditorCommands.ShowOutputMessage("Layout saving attempt has failed"); return(false); } Properties.Settings.Default.Layout = layoutName; return(true); }
void MainWindow_Unloaded(object sender, RoutedEventArgs e) { var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager); serializer.Serialize(@".\AvalonDock.config"); }
private void OnSaveLayout(object parameter) { var layoutSerializer = new XmlLayoutSerializer(dockingManager); layoutSerializer.Serialize(@".\AvalonDock.Layout.config"); }
/// <summary> /// Save docking manager layout. /// </summary> /// <param name="path">The layout resource path.</param> private void SaveLayout(string path) { var serializer = new XmlLayoutSerializer(dockingManager); using (var writer = new System.IO.StreamWriter(path)) { serializer.Serialize(writer); } }
/// <summary> /// Load docking manager layout. /// </summary> /// <param name="path">The layout resource path.</param> private void LoadLayout(string path) { if (!System.IO.File.Exists(path)) return; var serializer = new XmlLayoutSerializer(dockingManager); serializer.LayoutSerializationCallback += (s, e) => { var element = e.Content as FrameworkElement; if (element != null) { element.DataContext = _projectEditor; } }; using (var reader = new System.IO.StreamReader(path)) { serializer.Deserialize(reader); } }
/// <summary> /// Load docking manager layout from resource. /// </summary> /// <param name="path">The layout resource path.</param> private void LoadLayoutFromResource(string path) { var serializer = new XmlLayoutSerializer(dockingManager); serializer.LayoutSerializationCallback += (s, e) => { var element = e.Content as FrameworkElement; if (element != null) { element.DataContext = _projectEditor; } }; var assembly = this.GetType().Assembly; using (var stream = assembly.GetManifestResourceStream(path)) { using (var reader = new System.IO.StreamReader(stream)) { serializer.Deserialize(reader); } } }
private void OnSaveLayout(object sender, RoutedEventArgs e) { string fileName = (sender as MenuItem).Header.ToString(); var serializer = new XmlLayoutSerializer(dockManager); using (var stream = new StreamWriter(string.Format(@".\AvalonDock_{0}.config", fileName))) serializer.Serialize(stream); }
private void OnLoadLayout(object sender, RoutedEventArgs e) { var currentContentsList = dockManager.Layout.Descendents().OfType<LayoutContent>().Where(c => c.ContentId != null).ToArray(); string fileName = (sender as MenuItem).Header.ToString(); var serializer = new XmlLayoutSerializer(dockManager); //serializer.LayoutSerializationCallback += (s, args) => // { // var prevContent = currentContentsList.FirstOrDefault(c => c.ContentId == args.Model.ContentId); // if (prevContent != null) // args.Content = prevContent.Content; // }; using (var stream = new StreamReader(string.Format(@".\AvalonDock_{0}.config", fileName))) serializer.Deserialize(stream); }
public void LoadLayout(string settings) { if (settings == null) throw new ArgumentNullException(nameof(settings)); try { var titles = DockingManager .Layout .Descendents() .OfType<LayoutContent>() .ToDictionary(c => c.ContentId, c => c.Title); using (var reader = new StringReader(settings)) { var layoutSerializer = new XmlLayoutSerializer(DockingManager); layoutSerializer.LayoutSerializationCallback += (s, e) => { if (e.Content == null) e.Model.Close(); }; layoutSerializer.Deserialize(reader); } var items = DockingManager .Layout .Descendents() .OfType<LayoutContent>(); foreach (var content in items.Where(c => c.Content is BaseStudioControl)) { content.DoIfElse<LayoutDocument>(d => _documents[d.ContentId] = d, () => { }); content.DoIfElse<LayoutAnchorable>(d => _anchorables[d.ContentId] = d, () => { }); if (!(content.Content is BaseStudioControl)) { var title = titles.TryGetValue(content.ContentId); if (!title.IsEmpty()) content.Title = title; } else content.SetBindings(LayoutContent.TitleProperty, content.Content, "Title"); } } catch (Exception excp) { this.AddErrorLog(excp, LocalizedStrings.Str3649); } }
protected void SaveLayout(object iParam) { var layoutSerializer = new XmlLayoutSerializer(DockingManager); layoutSerializer.Serialize(@".\AvalonDock." + iParam + ".Layout.config"); }
void MainWindow_Unloaded(object sender, RoutedEventArgs e) { var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager); serializer.Serialize(@".\AvalonDock.config"); }
public static void SaveLayout(DockingManager manager, Stream stream) { var layoutSerializer = new XmlLayoutSerializer(manager); layoutSerializer.Serialize(stream); }