Showing posts with label Tool Item. Show all posts
Showing posts with label Tool Item. Show all posts

Saturday, February 14, 2015

How to assign a help document to a tool item with LinsUIWPF Suite


Prerequisite: Follow the link How to create a new project to create your application with LinsUIWPF Suite.

Then, there are four ways to assign a help document to a tool item.                                 
First way,
1.     Open App.xaml.cs file set the “DefaultHelpFilePath” as follows,
public partial class App : Application
{
public App()
{
Assembly assem = Assembly.GetEntryAssembly();
string csAssemName = assem.Location;
string csProjectName = assem.GetName().Name;
string csAppDirectory = Path.GetDirectoryName(csAssemName);
int nIndex = csAppDirectory.LastIndexOf('\\');
string csHelpFilesDirectory = csAppDirectory.Remove(nIndex);

FlexUISettings.DefaultHelpFilePath = System.IO.Path.Combine(csHelpFilesDirectory, "HelpFiles");
}
}

2.     Create a RTF format file or Text format file, for example, MyHelpFile.rtf. Store it under “…\YourApplicationProject\HelpFiles\”
3.     Assign MyHelpFile to a tool item as follows,
myToolItem.HelpFile = "MyHelpFile.rtf"

Second way,
1.     Assign the detail help content to the tool item as follows,
myToolItem.HelpContext = “ Here is your description”

Third way,
1.     Assign a unique ID, which is between FlexConstants.m_nUserDefinedControlStartID (1000) and FlexConstants.m_nUserDefinedControlStartID (10,000,000), to the CommandID attribute of the tool item.
<src:FlexMenuItem ID="1022" CommandID="1001" Text=”My Command” Name=”myToolItem”/>
2.     Create a class as follow, and implement the “COMMAND_EVENT.HELPBUTTON_CLICK”
class MyCommand : LinsUICommand
{
public MyCommand(long nCommandID, object data) base(nCommandID, data)
{
}

public override void Execute(object parameter)
{
base.Execute(parameter);
}

[CommandEventAttribute(COMMAND_EVENT.HELPBUTTON_CLICK)]
protected void HelpClick(object sender, EventArgs e)
{
/////////////////////////////////////////////////
// Create and show your own help document here when the ? help button is clicked
/////////////////////////////////////////////////
}

public override bool CanExecute(object parameter)
{
return true;
}
}
3.     Create the command with the given unique ID (here is 1001). It will automatically link the command to the tool item.
public partial class Window1 : LinsMDIWindow
{
public Window1()
{
InitializeComponent();

MyCommand myCommand = new MyCommand(1001, null);
}
} 

Fourth way,
1.     Customize it as the Video shown; Assign a Help Document to a Tool Item


References:
Commands,
Command Events,
Commands Manager,
Features,
How To,
Index,
Instruction,

How to create a command for a tool item with LinsUIWPF Suite


Prerequisite: Follow the link How to create a new project to create your application with LinsUIWPF Suite.

1.     Assign a unique ID, which is between FlexConstants.m_nUserDefinedControlStartID (1000) and FlexConstants.m_nUserDefinedControlStartID (10,000,000), to the CommandID property of the tool item.
<src:FlexMenuItem ID="1022" CommandID="1001" Text=”My Command” Name=”myToolItem”/>
2.     Create a class as follows,
class MyCommand : LinsUICommand
{
public MyCommand(long nCommandID, object data) base(nCommandID, data)
{
}

public override void Execute(object parameter)
{
base.Execute(parameter);
///////////////////////////////////
// Execute your command here
///////////////////////////////////
}

[CommandEventAttribute(COMMAND_EVENT.HELPBUTTON_CLICK)]
protected void HelpClick(object sender, EventArgs e)
{
/////////////////////////////////////////////////
// Create and show your own help document here when the ? help button is clicked
/////////////////////////////////////////////////
}

public override bool CanExecute(object parameter)
{
return true;
}
}
3.     Create the command with the given unique ID (here is 1001). This will automatically link the command to the tool item.
public partial class Window1 : LinsMDIWindow
{
public Window1()
{
InitializeComponent();
MyCommand myCommand = new MyCommand(1001, null);
}
} 



References:
Assign a Help Document to a Tool Item,
Commands,
Command Events,
Commands Manager,
Dynamically Link a Tool Item to a Command Existed in an Optional Assembly,
Features,
How To,
Index,
Instruction,

How to create a custom tool item with LinsUIWPF Suite

Download   Demonstration  Question?   Contact Us

Prerequisite: Follow the link How to create a new project to create your application with LinsUIWPF Suite.

1.     Create a custom control which is derived from FlexToolBarBaseButton.
public class MyCustomToolItem : FlexToolBarBaseButton
{
}
2.     Overwrite the following virtual function
public override Size MeasureSize(bool bDropDown, FLEX_DOCKING_ALIGN nDock)
{
Size szMySize;
/////////////////////////////////////////////
// Caculate your custom tool item’s size
/////////////////////////////////////////////
return szMySize;
}
3.     Replace the original tool item with your custom tool item.
<src:FlexToolBar x:Class="Demo.BlossomToolBar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:LinsUIWPF;assembly=LinsUIWPF" 
ID = "{StaticResource BLOSSOM_TOOLBAR_ID}" Text="Blossom" FlexDock="LEFT" Height="44" Width="277">
<src:MyCustomToolItem CommandID="{StaticResource DOWN_COMMAND_ID}" ID = "{StaticResource BLOSSOM_DOWN_ID}" HorizontalAlignment="Left" VerticalAlignment="Top" Icon="/Demo;component/Resource/navigate_down.ico"Text="Down" ToolTipText="Tooltip for &quot;Down&quot; comment." />
</src:FlexToolBar>



References:

How to customize tool item and tool container


Prerequisite: Follow the link How to create a new project to create your application with LinsUIWPF Suite.

Click at the System Button -> Cutomize…, it will pop up the Customization sheet which allows users to customize all tool items and tool containers which include Metro Screen, Toolbars, Ribbon Menus, Menus, Context Menus, and all buttons.
It has following tabs,
·       General tab – It allows users to customize the general settings of tool items for Context Menu, Menu, Ribbon Menu, and Toolbar generally (Video). This tab will be invisible when it is in Metro Tasks Screen mode.
User can select a container type from the Container Type dropdown list, and enable the Customization radio button for it. Then users can select their favorite settings and Apply for it.

·       Commands tab – It allows users to customize individual tool item (Video). Users can also delete any user created tool item with this tab (Video). This tab will be invisible when it is in Metro Tasks Screen mode.
Users can select a tool item from the Commands list, and select their favorite setting, ToolTip, or even the documentation linked to the tool item and Apply for it.
Users can also drag a tool item from the Commands list and drop it anywhere they like.

·       Composite Commands tab – It allows users to create a new command which is consisted of a group existing commands (Video), or delete an existing composite command (Video). Users can also use this tab to modify any existing composite command. This tab will be invisible when it is in Metro Tasks Screen mode.
The procedures to create a composite command are listed as follows,
1).       Select the New Composite Command item from the Composite Commands list.
2).       Select at least 2 items from the Available Commands list into the Selected Commands list.
3).       Select the favorite settings.
4).       Click at the Create button at the lower-left corner.
5).       The new created composite command will be shown in the Composite Commands list. Now users can drag it and drop it anywhere they like.

·       Tool Container tab – It allows users to add/remove tool items into a tool item container like Context Menu (Video), Menu (Video), Ribbon Menu (Video), and Toolbar (Video). Users also can use this tab to modify the settings for both tool items and tool item container. Users are able to create a new toolbar (Video) or delete a user created toolbar (Video) with this tab too. This tab will be invisible when it is in Metro Tasks Screen mode.
The procedures to edit/modify a tool container are listed as follows,
1).       Select a tool container type from the Container Type list.
2).       Select the tool container which you want to edit/modify from the containers list. The selected tool container will be displayed at the editor area.
3).       Drag an item from New Sub-containers list, Composite Commands list, or Commands list and drop it into the selected tool container at the editor area.
4).       Select another tool container or close the Customization sheet.

·       Tasks tab – It allows users to modify the settings for task buttons. Users also can drag any task button from this tab and drop it into Metro Tasks Screen (Video). This tab will be visible when it is in Metro Tasks Screen mode.

·       Task Groups tab – It allows users to modify the header of a task group (Video), or create a new task group (Video). Users also can drag any task group from this tab and drop it into Metro Tasks Screen (Video). This tab will be visible when it is in Metro Tasks Screen mode.
The procedures to create a new task group are listed as follows,
1).       Select the New Task Group item from the Task Groups list.
2).       Select the favorite settings and enter a group name for it.
4).       Click at the Create button at the lower-right corner.
5).       The new created task group will be shown in the Task Groups list. Now users can drag it and drop it into the Metro Tasks Screen.



Demo 1 -  Customize the Settings for Tool Item

Demo 2 - Create a Composite Tool Item

Demo 3 - Customize the Settings for Tool Container



How to dynamically show/hide a tool item based on the availability of an assembly


Dynamically show/hide a tool item based on the availability of an assembly with LinsUIWPF Suite.
If a command is located inside an assembly which is optional, how to show/hide a tool item, which is associated to the command, based on the availability of the assembly. This page will show you the way to do it.

Prerequisite: Follow the link How to create a new project to create your application with LinsUIWPF Suite.

1.     Assume you have an assembly AdvanceOpertaion.dll,
First step, create a command inside the assembly AdvanceOpertaion.dll as follows,
namespace AdvanceOperation.Commands
{
class AdvanceOperationCommand : LinsUICommand
{
public AdvanceOperationCommand(long nCommandID, object data) : base(nCommandID, data)
{
}

public override void Execute(object parameter)
{
base.Execute(parameter);
///////////////////////////////////
// Execute your command here
///////////////////////////////////
}

public override bool CanExecute(object parameter)
{
return true;
}
}
}

Second step, create the following initialization class and method inside the assembly AdvanceOpertaion.dll as follows,
namespace AdvanceOperation
{
public static partial class InitializeAdvanceOperation
{
public static void Initialize()
{
CreateCommands();
}

private static void CreateCommands()
{
long nCommandID = 1002;
LinsUICommand command = new AdvanceOperationCommand(nCommandID, null);
}
}
}

Third step, inside your xaml file in your application, bind the tool item’s visibility as follows,
<src:SurfaceSlider
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:src="clr-namespace:LinsUIWPF;assembly=LinsUIWPF" 
x:Class="Demo.SurfaceSliders.MainSurfaceSlider" 
xmlns:localConverters="clr-namespace:Demo.Converters"
mc:Ignorable="d" Height="435" Width="1130">

<src:SurfaceSlider.Resources>
<ResourceDictionary>
<localConverters:AdvanceOperationVisibilityConverter x:Key="advanceOperationVisibilityConverter"/>
</ResourceDictionary>
</src:SurfaceSlider.Resources>

<!--------------------------------------------->   
<src:SurfaceSliderTasksPanel>
<src:TaskGroup>
<src:TaskButton ButtonType="LARGE" CommandID="1002" Visibility="{Binding Path=CommandID, RelativeSource={RelativeSource Self},Converter={StaticResource advanceOperationVisibilityConverter}}">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TextBlock Grid.Row="0" Text="Advance Operation" FontWeight="Thin" FontSize="12" FontStyle="Italic" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0"/>
</Grid>
</src:TaskButton>
</src:TaskGroup>
</src:SurfaceSliderTasksPanel

</src:SurfaceSlider>

Fourth step, create a converter in your application as follows,
namespace Demo.Converters
{
public class AdvanceOperationVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
// Check to see whether value is present or not.
long commandID = (long)value;
LinsUICommand command = null;
return LinsUICommandManager.TryGetCommand(commandID, out command) ? Visibility.Visible : Visibility.Hidden;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}
}

Finally add the following codes at the place where you want to load and initialize the specified assembly, AdvanceOpertaion.dll,
string csAdvanceOperationAssemblyFullName = C:\\Users\\Projects\\Application\\Release\\AdvanceOpertaion.dll”;
LinsUIWPFUtil.InitializeAssembly(
csAdvanceOperationAssemblyFullName,
"AdvanceOpertaion.InitializeAdvanceOperation",
"Initialize",
null);

When you run your application, the taskbutton “Advance Operation” will be hidden until the assembly AdvanceOpertaion.dll is loaded.