Showing posts with label Janus UI and Ribbon. Show all posts
Showing posts with label Janus UI and Ribbon. Show all posts
  • Adding a Command to the RibbonStatusBar control [Janus UI and Ribbon Controls v3.5 for .NET] Create and add a StatusBarPanel to a RibbonStatusBar control.

    The RibbonStatusBar control has two collections were you can add commands, the LeftPanelCommands that represents the commands aligned to the left side of control (painted with a light background) and the RightPanelCommands that has a darker background and are aligned to the right edge of the StatusBar.

    The following code shows how to create and add a SatusBarPanel to the left side of the RibbonStatusBar.

    In C#



    //Create the RibbonStatusBar control

    Janus.Windows.Ribbon.RibbonStatusBar statusBar = new Janus.Windows.Ribbon.RibbonStatusBar();

    statusBar.Height = 22;

    this.Controls.Add(statusBar);



    Janus.Windows.Ribbon.StatusBarPanel panel = new Janus.Windows.Ribbon.StatusBarPanel();

    //Specify that the panel should act as label and cannot be clicked

    panel.PanelBehavior = PanelBehavior.Label;

    panel.Text = "Panel text";



    //Specify that the panel should be resized to fill the empty space in the left side of the StatusBar control.

    panel.AutoSize = StatusBarPanelAutoSize.Spring;



    //Add the panel to the LeftPanelCommands collection of the StatusBar

    statusBar.LeftPanelCommands.Add(panel);



    In VB



    'Create the RibbonStatusBar control

    Dim statusBar As New Janus.Windows.Ribbon.RibbonStatusBar()

    statusBar.Height = 22

    Me.Controls.Add(statusBar)



    Dim panel As New Janus.Windows.Ribbon.StatusBarPanel()

    'Specify that the panel should act as label and cannot be clicked

    panel.PanelBehavior = PanelBehavior.Label

    panel.Text = "Panel text"



    'Specify that the panel should be resized to fill the empty space in the left side of the StatusBar control.

    panel.AutoSize = StatusBarPanelAutoSize.Spring



    'Add the panel to the LeftPanelCommands collection of the StatusBar

    statusBar.LeftPanelCommands.Add(panel)



    The following list shows the types of commands that can be added to a RibbonStatusBar



    ButtonCommand : Represents a button that can be clicked. Use the SizeStyle property of the button to specify if the button should be presented as a large button that occupies the full height of the ribbon or as a small button.



    DropDownCommand : Inherits from ButtonCommand and it also has a Commands collection that is displayed on a menu window after clicking on the button.



    LabelCommand : Represents a label in the ribbon with text and image that cannot be clicked or highlighted



    MdiListCommand : Inherits from DropDownCommand and a command is added to its Commands collection for every MDI child form open in the application.



    CheckBoxCommand : Represents a UICheckBox control in the Ribbon.



    ComboBoxCommand : Represents a UIComboBox control in the Ribbon



    TextBoxCommand : Represents a TextBox control.



    ContainerControlCommand : Use this command type to add a custom Control to the Ribbon. Set the custom control to the Control property of the command and use the ControlWidth property to specify its width.



    ButtonGroup : Represents a group of commands with a border around them



    SeparatorCommand : Represents a separator line in its parent object. When you add a SeparatorCommand to a DropDown use the Title property if you want the command to be represents as a title in the menu window.



    StatusBarPanel : Represent a panel in a panel in RibbonStatusBar. Use the PanelBehavior property to specify whether the panel should act as a button or a label and use the AutoSize property to specify how the panel will be sized.

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

    more
  • Creating and displaying a RibbonContextMenu [Janus UI and Ribbon Controls v3.5 for .NET] Create and display a context menu in code.



    In VB:



    Dim ctMenu As RibbonContextMenu = New RibbonContextMenu()

    'Create the commands that will be added to the context menu

    Dim cutCommand As DropDownCommand = New DropDownCommand("Cut", "Cu&t")

    Dim copyCommand As DropDownCommand = New DropDownCommand("Copy", "Cop&y")

    Dim pasteCommand As DropDownCommand = New DropDownCommand("Paste", "&Paste")



    'Add the commands to the Commands collection of the context menu

    ctMenu.Commands.Add(cutCommand)

    ctMenu.Commands.Add(copyCommand)

    ctMenu.Commands.Add(pasteCommand)



    'Call the Show method to display the context menu.

    ctMenu.Show()



    In C#:



    RibbonContextMenu ctMenu = new RibbonContextMenu();

    //Create the commands that will be added to the context menu

    DropDownCommand cutCommand = new DropDownCommand("Cut", "Cu&t");

    DropDownCommand copyCommand = new DropDownCommand("Copy", "Cop&y");

    DropDownCommand pasteCommand = new DropDownCommand("Paste", "&Paste");

    //Add the commands to the Commands collection of the context menu

    ctMenu.Commands.Add(cutCommand);

    ctMenu.Commands.Add(copyCommand);

    ctMenu.Commands.Add(pasteCommand);



    //Call the Show method to display the context menu.

    ctMenu.Show();
    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • 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

    more
  • Using the UIPanelManager as a TabbedMdi control [Janus UI and Ribbon Controls v3.5 for .NET] To give your MDI Container Form a TabbedMdi layout you just need to place a UIPanelManager component on the Form and set its TabbedMdi property as true.





    Setting properties for individual tab pages



    You can use the MdiTabInitialize event to assign the text, tooltip text or the format style for the tab items.



    In C#:



    private void uiPanelManager1_MdiTabInitialize(object sender, Janus.Windows.UI.Dock.MdiTabInitializeEventArgs e)

    {

    e.Tab.ToolTipText = "ToolTipText for the TabPage";

    e.Tab.StateStyles.FormatStyle.BackColor = Color.Red;

    //Use the CustomProperties class to add custom information for the tab page.

    e.Tab.CustomProperties.Add("FormType", e.Tab.Form.GetType().Name);



    }



    In VB:



    Private Sub UiPanelManager1_MdiTabInitialize(ByVal sender As Object, ByVal e As Janus.Windows.UI.Dock.MdiTabInitializeEventArgs) Handles UiPanelManager1.MdiTabInitialize

    e.Tab.ToolTipText = "ToolTipText for the TabPage"

    e.Tab.StateStyles.FormatStyle.BackColor = Color.Red

    'Use the CustomProperties class to add custom information for the tab page

    e.Tab.CustomProperties.Add("FormType", e.Tab.Form.GetType().Name)

    End Sub







    Using a layout file to preserve the tabbed Mdi layout



    The following code shows how to save the tabbed Mdi layout into a file





    In VB:



    Private Sub SaveLayout()

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

    Dim LayoutStream As FileStream

    LayoutStream = New FileStream(LayoutDir, FileMode.Create)

    UiPanelManager1.SaveLayoutFile(LayoutStream, Janus.Windows.UI.Dock.PersistMode.TabbedMdiLayout)

    LayoutStream.Close()

    End Sub







    In C#:



    private void SaveLayout()

    {

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

    FileStream layoutStream;

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

    uiPanelManager1.SaveLayoutFile(layoutStream, Janus.Windows.UI.Dock.PersistMode.TabbedMdiLayout);

    layoutStream.Close();

    }





    The following code shows how to load the tabbed Mdi layout from a file



    In VB:



    Private Sub LoadLayout()

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

    Dim LayoutStream As FileStream

    LayoutStream = New FileStream(LayoutDir, FileMode.Open)

    UiPanelManager1.LoadLayoutFile(LayoutStream)

    LayoutStream.Close()

    End Sub



    In C#:



    private void LoadLayout()

    {

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

    FileStream layoutStream;

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

    uiPanelManager1.LoadLayoutFile(layoutStream);

    layoutStream.Close();

    }



    Use the RestoreMdiChildForm event to load the forms that were open when the layout was saved.



    In C#:



    private void uiPanelManager1_RestoreMdiChildForm(object sender, Janus.Windows.UI.Dock.RestoreMdiChildFormEventArgs e)

    {

    //Get the type of the form that was stored in the MDITabInitialize event

    string formType = (string)e.Tab.CustomProperties["FormType"].Value;

    if (formType == "Form2")

    {

    Form2 frm = new Form2();

    frm.MdiParent = this;

    //Set the new Form as the Form for the tab.

    e.Form = frm;

    frm.Show();

    }

    }



    In VB:



    Private Sub UiPanelManager1_RestoreMdiChildForm(ByVal sender As Object, ByVal e As Janus.Windows.UI.Dock.RestoreMdiChildFormEventArgs) Handles UiPanelManager1.RestoreMdiChildForm

    'Get the type of the form that was stored in the MDITabInitializeEvent

    Dim formType As String = e.Tab.CustomProperties("FormType").Value

    If formType = "Form2" Then

    Dim frm As Form2 = New Form2()

    frm.MdiParent = Me

    'Set the new Form as the Form for the tab.

    e.Form = frm

    frm.Show()

    End If

    End Sub

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

    more
  • Creating a UIPanelGroup [Janus UI and Ribbon Controls v3.5 for .NET] The following code shows how to create a UIPanelGroup containing two panels in code and placed on the Form.





    In C#



    Janus.Windows.UI.Dock.UIPanelManager panelManager = new UIPanelManager();

    //Assign the form as the control in which the panels will be placed

    panelManager.ContainerControl = this;



    Janus.Windows.UI.Dock.UIPanelGroup group = new UIPanelGroup();

    //Specify the group style.

    group.GroupStyle = Janus.Windows.UI.Dock.PanelGroupStyle.Tab;



    //Create the two panels that will be added to the group.

    Janus.Windows.UI.Dock.UIPanel panel1 = new Janus.Windows.UI.Dock.UIPanel("Panel 1");

    Janus.Windows.UI.Dock.UIPanel panel2 = new Janus.Windows.UI.Dock.UIPanel("Panel 2");



    //Add the panels to the group created.

    group.Panels.Add(panel1);

    group.Panels.Add(panel2);



    //Add the group to the Panels collection the UIPanelManager

    panelManager.Panels.Add(group);



    //NOTE: A UIPanelGroup must have at least two panels assigned to it or it will be

    //removed from the Controls collection of the container control if its StaticGroup

    //property is False.





    In VB:



    Dim PanelManager As New Janus.Windows.UI.Dock.UIPanelManager()

    'Assign the form as the control in which the panels will be placed

    PanelManager.ContainerControl = Me



    Dim group As New Janus.Windows.UI.Dock.UIPanelGroup()

    'Specify the group style

    group.GroupStyle = Janus.Windows.UI.Dock.PanelGroupStyle.Tab



    'Create the two panels that will be added to the group.

    Dim panel1 As New Janus.Windows.UI.Dock.UIPanel("Panel 1")

    Dim panel2 As New Janus.Windows.UI.Dock.UIPanel("Panel 2")



    'Add the panels to the group created.

    group.Panels.Add(panel1)

    group.Panels.Add(panel2)



    'Add the group to the Panels collection the UIPanelManager

    PanelManager.Panels.Add(group)



    'NOTE: A UIPanelGroup must have at least two panels assigned to it or it will be

    'removed from the Controls 'collection of the container control if its StaticGroup

    'Property is False.

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

    more
  • Using a layout file to preserve user changes in the CommandManager [Janus UI and Ribbon Controls v3.5 for .NET] Use a layout file to preserve UICommandManager component settings. Using a layout file you could be able to preserve even the changes to the layout made by the user.

    In VB:



    Private Sub LoadLayout()

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

    Dim LayoutStream As FileStream

    LayoutStream = New FileStream(LayoutDir, FileMode.Open)

    CommandManager1.LoadLayoutFile(LayoutStream)

    LayoutStream.Close()

    End Sub

    Private Sub CommandManager1_CurrentLayoutChanging(ByVal sender As Object, _

    ByVal e As System.ComponentModel.CancelEventArgs) Handles _

    CommandManager1.CurrentLayoutChanging



    'tTo persist user changes in the current layout,

    'call the Update method explicitly before changing the layout

    If Not CommandManager1.CurrentLayout Is Nothing Then

    CommandManager1.CurrentLayout.Update()

    End If

    End Sub

    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" & _

    "CommandManager 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)

    CommandManager1.SaveLayoutFile(LayoutStream)

    LayoutStream.Close()

    End If



    End Sub


    In C#:



    private void LoadLayout()

    {

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

    FileStream layoutStream;

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

    CommandManager1.LoadLayoutFile(layoutStream);

    layoutStream.Close();

    }

    private void commandManager1_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 (commandManager1.CurrentLayout != null)

    {

    commandManager1.CurrentLayout.Update();

    }

    }

    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 CommandManager layout?",

    "Preserve changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);



    if (result == DialogResult.Cancel)

    {

    e.Cancel = true;

    }

    else if (result == DialogResult.Yes)

    {

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

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

    commandManager1.SaveLayoutFile(layoutStream);

    layoutStream.Close();

    }

    }

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

    more
  • Changing the Texts in the Customize Dialogs Form of Janus CommandManager [Janus UI and Ribbon Controls v3.5 for .NET] Change the default texts used in the customize dialog of the Janus CommandManager.

    In the ShowingCustomizeDialog event of the UICommandManager assign the dialog to the inherited form



    In VB:



    Private Sub UICommandManager1_ShowingCustomizeDialog(ByVal sender As Object, ByVal e As Janus.Windows.UI.CommandBars.CancelDialogEventArgs) Handles UICommandManager1.ShowingCustomizeDialog

    Select Case e.DialogType

    Case Janus.Windows.UI.CommandBars.DialogType.Customize

    Dim form As CustomizeForm = New CustomizeForm()

    e.Dialog = form

    End Select

    End Sub





    In C#:



    private void uiCommandManager1_ShowingCustomizeDialog(object sender, Janus.Windows.UI.CommandBars.CancelDialogEventArgs e)

    {

    switch (e.DialogType)

    {

    case Janus.Windows.UI.CommandBars.DialogType.Customize:

    CustomizeForm customizeForm = new CustomizeForm();

    e.Dialog = customizeForm;

    break;

    }

    }

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

    more
  • Creating and Displaying an UIContextMenu [Janus UI and Ribbon Controls v3.5 for .NET] The following code shows how to create and display a context menu in code.



    In VB:



    Dim ctMenu As UIContextMenu = New UIContextMenu()

    'Create the commands that will be added to the context menu

    Dim cutCommand As UICommand = New UICommand("Cut", "Cu&t")

    Dim copyCommand As UICommand = New UICommand("Copy", "Cop&y")

    Dim pasteCommand As UICommand = New UICommand("Paste", "&Paste")



    'Add the commands to the Commands collection of the context menu

    ctMenu.Commands.Add(cutCommand)

    ctMenu.Commands.Add(copyCommand)

    ctMenu.Commands.Add(pasteCommand)



    'Call the Show method to display the context menu.

    ctMenu.Show()



    In C#:



    UIContextMenu ctMenu = new UIContextMenu();

    //Create the commands that will be added to the context menu

    UICommand cutCommand = new UICommand("Cut", "Cu&t");

    UICommand copyCommand = new UICommand("Copy", "Cop&y");

    UICommand pasteCommand = new UICommand("Paste", "&Paste");

    //Add the commands to the Commands collection of the context menu

    ctMenu.Commands.Add(cutCommand);

    ctMenu.Commands.Add(copyCommand);

    ctMenu.Commands.Add(pasteCommand);



    //Call the Show method to display the context menu.

    ctMenu.Show();

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

    more
  • Adding Commands to the UICommandBar [Janus UI and Ribbon Controls v3.5 for .NET] The following code shows how to add a UICommand into a command bar at run time.



    In VB:



    Dim CommandManager As UICommandManager = New UICommandManager()

    'Assign the control in which the rebar containing the command bars will be placed

    CommandManager.ContainerControl = Me



    Dim CommandBar As Janus.Windows.UI.CommandBars.UICommandBar = New Janus.Windows.UI.CommandBars.UICommandBar("Menu")

    'Assign the UICommandManager that will hold the structure of the command bar.

    CommandBar.CommandManager = CommandManager

    'Specify that the command bar should behave and look as a Menu

    CommandBar.CommandBarType = Janus.Windows.UI.CommandBars.CommandBarType.Menu



    'Create the file command and add it to the Commands collection of the UICommandManager

    Dim baseCommand As UICommand = New UICommand("File", "&File")

    CommandManager.Commands.Add(baseCommand)



    'Create the command that will be placed on the command bar based on the file command

    Dim toolBarCommand As UICommand = New UICommand(baseCommand)

    CommandBar.Commands.Add(toolBarCommand)





    In C#



    Janus.Windows.UI.CommandBars.UICommandManager commandManager = new UICommandManager();

    //Assign the control in which the rebar containing the command bars will be placed

    commandManager.ContainerControl = this;



    UICommandBar commandBar = new Janus.Windows.UI.CommandBars.UICommandBar("Menu");

    //Assign the UICommandManager that will hold the structure of the command bar.

    commandBar.CommandManager = commandManager;

    //Specify that the command bar should behave and look as a Menu

    commandBar.CommandBarType = Janus.Windows.UI.CommandBars.CommandBarType.Menu;



    //Create the file command and add it to the Commands collection of the UICommandManager

    UICommand baseCommand = new UICommand("File", "&File");

    commandManager.Commands.Add(baseCommand);



    //Create the command that will be placed on the command bar based on the file command

    UICommand toolBarCommand = new UICommand(baseCommand);

    commandBar.Commands.Add(toolBarCommand);

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

    more
  • Creating an UICommandBar [Janus UI and Ribbon Controls v3.5 for .NET] The following code shows how to create a UICommandBar in code and placed on the Form.



    In C#

    Janus.Windows.UI.CommandBars.UICommandManager commandManager = new UICommandManager();

    //Assign the control in which the rebar containing the command bars will be placed

    commandManager.ContainerControl = this;



    UICommandBar commandBar = new Janus.Windows.UI.CommandBars.UICommandBar("Menu");



    //Assign the UICommandManager that will hold the structure of the command bar.

    commandBar.CommandManager = commandManager;

    //Specify that the command bar should behave and look as a Menu

    commandBar.CommandBarType = Janus.Windows.UI.CommandBars.CommandBarType.Menu;




    In VB:


    Dim CommandManager As Janus.Windows.UI.CommandBars.UICommandManager = New UICommandManager()

    'Assign the control in which the rebar containing the command bars will be placed

    CommandManager.ContainerControl = Me



    Dim CommandBar As UICommandBar = New UICommandBar("Menu")

    'Assign the UICommandManager that will hold the structure of the command bar.

    CommandBar.CommandManager = CommandManager

    'Specify that the command bar should behave and look as a Menu

    CommandBar.CommandBarType = Janus.Windows.UI.CommandBars.CommandBarType.Menu

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

    more