Hello everyone,
I found an interesting easy working example for RadDock but teh problem that I'm facing that its in vb, and the application is c#
can anyone help me to convert it [ Please note that the online converters couldn't convert it specially the bold + underlined lines ]
| Imports System |
| Imports System.Data |
| Imports System.Configuration |
| Imports System.Collections |
| Imports System.Web |
| Imports System.Web.Security |
| Imports System.Web.UI |
| Imports System.Web.UI.WebControls |
| Imports System.Web.UI.WebControls.WebParts |
| Imports System.Web.UI.HtmlControls |
| Imports System.Data.SqlClient |
| Imports Telerik.Web.UI |
| Imports System.Collections.Generic |
| Imports System.Text |
| Imports System.Web.Script.Serialization |
| Partial Public Class DefaultVB |
| Inherits System.Web.UI.Page |
| Private _conn As New SqlConnection(ConfigurationManager.ConnectionStrings("DockConnectionString").ConnectionString) |
| Private _count As Integer = 0 |
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) |
| End Sub |
| Protected Sub RadDockLayout1_LoadDockLayout(ByVal sender As Object, ByVal e As Telerik.Web.UI.DockLayoutEventArgs) |
| Dim dock As RadDock = Nothing |
| Dim serializer As New JavaScriptSerializer() |
| Dim converters As New List(Of JavaScriptConverter)() |
| converters.Add(New UnitConverter()) |
| serializer.RegisterConverters(converters) |
| 'Get saved state string from the database - set it to dockState variable for example |
| Dim dockState As String = "" |
| Try |
| _conn.Open() |
| Dim command As New SqlCommand("select State from States where id=1", _conn) |
| dockState = command.ExecuteScalar().ToString() |
| _conn.Close() |
| Catch |
| End Try |
| Dim currentDockStates As String() = dockState.Split("|"c) |
| For Each stringState As String In currentDockStates |
| If stringState.Trim() <> String.Empty Then |
| Dim state As DockState = serializer.Deserialize(Of DockState)(stringState) |
| e.Positions(state.UniqueName) = state.DockZoneID |
| e.Indices(state.UniqueName) = state.Index |
| dock = DirectCast(RadDockLayout1.FindControl(state.UniqueName), RadDock) |
| dock.ApplyState(state) |
| End If |
| Next |
| End Sub |
| Protected Sub RadDockLayout1_SaveDockLayout(ByVal sender As Object, ByVal e As Telerik.Web.UI.DockLayoutEventArgs) |
| Dim dockState As String |
| Dim serializer As New JavaScriptSerializer() |
| Dim converters As New List(Of JavaScriptConverter)() |
| converters.Add(New UnitConverter()) |
| serializer.RegisterConverters(converters) |
| Dim stateList As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState() |
| Dim serializedList As New StringBuilder() |
| Dim i As Integer = 0 |
| While i < stateList.Count |
| serializedList.Append(serializer.Serialize(stateList(i))) |
| serializedList.Append("|") |
| System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) |
| End While |
| dockState = serializedList.ToString() |
| If dockState.Trim() <> [String].Empty Then |
| Try |
| _conn.Open() |
| Dim command As New SqlCommand([String].Format("update States set State='{0}' where id=1", dockState), _conn) |
| command.ExecuteNonQuery() |
| _conn.Close() |
| Catch |
| End Try |
| End If |
| End Sub |
| End Class |
Thank you in advance