• Using a layout file to preserve user changes in the PanelManager [Janus UI and Ribbon Controls v3.5 for .NET]

    Using a layout file you could be able to preserve the changes to the layout made by the user.



    Follow these steps to use a layout file at run time:



    1 Define the layout at design time and then save it clicking in the "Save Layout File" button that is found in the "Layout Manager" tab of the UIPanelManager designer.



    2 In the Load event of the form, load the layout from a file calling a procedure similar to the following:



    In VB:



    Private Sub LoadLayout()

    Dim LayoutDir As String = "C:\PanelsLayout.xml"

    Dim LayoutStream As FileStream

    LayoutStream = New FileStream(LayoutDir, FileMode.Open)

    PanelManager1.LoadLayoutFile(LayoutStream)

    LayoutStream.Close()

    End Sub



    In C#:



    private void LoadLayout()

    {

    string layoutDir = @"C:\PanelsLayout.xml";

    FileStream layoutStream;

    layoutStream = new FileStream(layoutDir, FileMode.Open);

    panelManager1.LoadLayoutFile(layoutStream);

    layoutStream.Close();

    }





    3 (Optional) To preserve user changes to the layout, update each layout before it is changed in the CurrentLayoutChanging event.



    In VB:



    Private Sub PanelManager1_CurrentLayoutChanging(ByVal sender As Object, _

    ByVal e As System.ComponentModel.CancelEventArgs) Handles _

    PanelManager1.CurrentLayoutChanging



    'To persist user changes in the current layout,

    'call the Update method explicitly before changing the layout

    If Not PanelManager1.CurrentLayout Is Nothing Then

    PanelManager1.CurrentLayout.Update()

    End If

    End Sub



    In C#:



    private void panelManager1_CurrentLayoutChanging(object sender,

    System.ComponentModel.CancelEventArgs e)

    {

    //To persist user changes in the current layout,

    //call the Update method explicitly before changing the layout

    if (panelManager1.CurrentLayout != null)

    {

    panelManager1.CurrentLayout.Update();

    }

    }



    4 In the FormClosing event of the form, save the layout file again to be able to preserve the changes the user did-



    In VB:



    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing



    Dim Result As DialogResult

    Dim LayoutDir As String

    Dim LayoutStream As FileStream



    Result = MessageBox.Show("Do you want to preserve the changes in the " & _

    "PanelManager layout?", "Preserve changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)

    If Result = Windows.Forms.DialogResult.Cancel Then

    e.Cancel = True

    ElseIf Result = Windows.Forms.DialogResult.Yes Then

    LayoutDir = "C:\UIBarsLayout.xml"

    LayoutStream = New FileStream(LayoutDir, FileMode.Create)

    PanelManager1.SaveLayoutFile(LayoutStream)

    LayoutStream.Close()

    End If



    End Sub



    In C#:



    private void Form1_FormClosing(object sender, FormClosingEventArgs e)

    {

    DialogResult result;

    string layoutDir;

    FileStream layoutStream;



    result = MessageBox.Show("Do you want to preserve the changes in the PanelManager layout?", "Preserve changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);



    if (result == DialogResult.Cancel)

    {

    e.Cancel = true;

    }

    else if (result == DialogResult.Yes)

    {

    layoutDir = @"C:\PanelsLayout.xml";

    layoutStream = new FileStream(layoutDir, FileMode.Create);

    panelManager1.SaveLayoutFile(layoutStream);

    layoutStream.Close();

    }

    }
    Source Of Information : Janus v3.5 Help Files for VS 2008


0 comments:

Leave a Reply