/// <summary> /// Saves the current state of a UltraDockManager (including images & texts) to a (Xml) string. /// No exceptions are catched in this method /// </summary> /// <param name="dockManager">UltraDockManager</param> /// <returns>string (Xml)</returns> public static string SaveControlStateToString(UltraDockManager dockManager) { using (MemoryStream stream = SaveDockManager(dockManager, false)) { StreamReader r = new StreamReader(stream); return(r.ReadToEnd()); } }
/// <summary> /// Restores a DockManager using the provided byte-array. /// Prior to applying the settings the property 'Text' of all DockableControlPanes is /// saved to a collection and restored after applying the settings from the byte-array. /// This avoids that string from a different login-language are restored. /// No Exceptions are catched by this method. /// </summary> /// <param name="dockManager">UltraDockManager</param> /// <param name="stream">Stream</param> /// <param name="asBinary">bool</param> public static void LoadDockManager(UltraDockManager dockManager, Stream stream, bool asBinary) { DockAreaPane oDockArea; DockableControlPane oDockContPane; int i, j; Hashtable oTexts; //First remember original (current language) strings oTexts = new Hashtable(); for (i = 0; i < dockManager.DockAreas.Count; i++) { oDockArea = dockManager.DockAreas[i]; for (j = 0; j < oDockArea.Panes.Count; j++) { oDockContPane = oDockArea.Panes[j] as DockableControlPane; if (oDockContPane != null) { oTexts.Add(oDockContPane.Control.Name, oDockContPane.Text); } } } //Now load the settings try { if (asBinary) { dockManager.LoadFromBinary(stream); } else { dockManager.LoadFromXML(stream); } } catch (Exception ex) { Trace.WriteLine("dockManager.LoadFrom...() failed: " + ex.Message); return; // use it as it was initialized on the original form } //The stream already has the captions stored, so overwrite them //with the current ones (could be different language) for (i = 0; i < dockManager.DockAreas.Count; i++) { oDockArea = dockManager.DockAreas[i]; for (j = 0; j < oDockArea.Panes.Count; j++) { oDockContPane = oDockArea.Panes[j] as DockableControlPane; if (oDockContPane != null) { if (oTexts.Contains(oDockContPane.Control.Name)) { oDockContPane.Text = (string)oTexts[oDockContPane.Control.Name]; } } } } }
/* * ultraExplorerBarGroup1.Items.AddRange(new Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarItem[] { * ultraExplorerBarItem1}); * ultraExplorerBarGroup1.ItemSettings.Style = Infragistics.Win.UltraWinExplorerBar.ItemStyle.Button; * ultraExplorerBarGroup1.Text = "Tareas"; * ultraExplorerBarGroup2.Text = "Favoritos"; * this.explorerBar.Groups.AddRange(new Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarGroup[] { * ultraExplorerBarGroup1, * ultraExplorerBarGroup2}); * */ /*public static void Load( UltraExplorerBar toolbar) * { * //sy_HerramientasDataset data = businessrules.sy_Herramientas.GetList( ID_EXPLORER_BAR, Security.IdPerfil ); * //LoadItems( new DataView( data.sy_Herramientas, "IsNull( IdHerramientaPadre, -1 ) = -1", "IdHerramienta", DataViewRowState.OriginalRows ), toolbar, null ); * * sy_HerramientasDataset data = businessrules.sy_Herramientas.GetList( ID_EXPLORER_BAR, Security.IdPerfil ); * * if (data.sy_Herramientas.Count == 0) * { * toolbar.Visible = false; * } * else * { * LoadItems( new DataView( data.sy_Herramientas, "IsNull( IdHerramientaPadre, -1 ) = -1", "IdHerramienta", DataViewRowState.OriginalRows ), toolbar, null ); * toolbar.Visible = true; * } * }*/ public static void Load(UltraExplorerBar toolbar, UltraDockManager ultraDockManager) { sy_HerramientasDataset data = businessrules.sy_Herramientas.GetList(ID_EXPLORER_BAR, Security.IdPerfil); if (data.sy_Herramientas.Count == 0) { ultraDockManager.Visible = false; } else { LoadItems(new DataView(data.sy_Herramientas, "IsNull( IdHerramientaPadre, -1 ) = -1", "IdHerramienta", DataViewRowState.OriginalRows), toolbar, null); ultraDockManager.Visible = true; } }
/// <summary> /// Restores a DockManager using the provided string. /// Prior to applying the settings the property 'Text' of all DockabelControlPanes is /// saved to a collection and restored after applying the settings from the byte-array. /// This avoids that string from a different login-language are restored. /// Load failures are ignored. /// </summary> /// <param name="dockManager">UltraDockManager</param> /// <param name="theSettings">string</param> public static void LoadControlStateFromString(UltraDockManager dockManager, string theSettings) { if (string.IsNullOrEmpty(theSettings)) { return; } using (Stream stream = new MemoryStream()) { StreamWriter writer = new StreamWriter(stream); writer.Write(theSettings); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); LoadDockManager(dockManager, stream, false); } }
/// <summary> /// Restores a DockManager using the provided byte-array. /// Prior to applying the settings the property 'Text' of all DockabelControlPanes is /// saved to a collection and restored after applying the settings from the byte-array. /// This avoids that string from a different login-language are restored. /// Load failures are ignored. /// </summary> /// <param name="dockManager">UltraDockManager</param> /// <param name="theSettings">byte[]</param> public static void LoadControlStateFromByte(UltraDockManager dockManager, byte[] theSettings) { if (theSettings == null) { return; } if (theSettings.Length == 0) { return; } using (Stream stream = new MemoryStream(theSettings)) { LoadDockManager(dockManager, stream, true); } }
/// <summary> /// Saves the current state of a DockManager (including images & texts) to a byte-array. /// No exceptions are catched in this method /// </summary> public static MemoryStream SaveDockManager(UltraDockManager dockManager, bool asBinary) { MemoryStream stream = new MemoryStream(); if (asBinary) { dockManager.SaveAsBinary(stream); } else { dockManager.SaveAsXML(stream); } stream.Seek(0, SeekOrigin.Begin); return(stream); }
/*public static void Load( UltraToolbarsManager toolbar, UltraExplorerBar explorerbar) * { * _indexSeparator = 1; * Load( toolbar ); * Load( explorerbar); * }*/ public static void Load(UltraToolbarsManager toolbar, UltraExplorerBar explorerbar, UltraDockManager ultraDockManager) { _indexSeparator = 1; Load(toolbar); Load(explorerbar, ultraDockManager); }
/// <summary> /// Saves the current state of a UltraDockManager (including images & texts) to a byte-array. /// No exceptions are catched in this method /// </summary> /// <param name="dockManager">UltraDockManager</param> /// <returns>byte[]</returns> public static byte[] SaveControlStateToByte(UltraDockManager dockManager) { using (MemoryStream stream = SaveDockManager(dockManager, true)) { return(stream.ToArray()); } }