Friday, February 13, 2015


TaskButton class
This tool item only can be used on Metro Tasks Screen. It reacts to user input from a mouse, keyboard, stylus, or other input device. The user is able to put simple information about all your stuff over it.
The following example shows how to use both the CommandID attribute and the ViewID attribute of a task button.

In the MainSurfaceSlider.xaml file, add the codes as following
mc:Ignorable="d" Height="435" Width="1130">


<src:TaskGroup ID="4011" Text="File Operation">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ContentPresenter x:Name="GroupHeader1" Content="{Binding}" ContentTemplate="{StaticResource TaskGroupHeaderTemplate1}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<src:TaskButton Text="Copy" ID="4012ButtonType="LARGE" ViewID = "{StaticResource DESERTLAND_DOC_ID}" CommandID="{StaticResource COPY_COMMAND_ID}">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ContentPresenter x:Name="CopyTask" Content="{Binding}" ContentTemplate="{StaticResource CopyTaskTemplate}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>



Create the following command class,                                            
class CopyCommand : LinsUICommand
public CopyCommand(long nCommandID, object data) : base(nCommandID, data)
// Assign a help file to this command. The help file must be stored at the location
// specified by FlexUISettings.DefaultHelpFilePath,
HelpFile = "Copy.rtf";
// Assign a short-cut key to this command.
InputKeyGesture = new System.Windows.Input.KeyGesture(

public override void Execute(object parameter)

// Execute your command //

protected void HelpClick(object sender, EventArgs e)
// ******* //

protected void OnKeyUp(object sender, EventArgs e)
if (!(e is KeyEventArgs))
KeyEventArgs keyEvent = e as KeyEventArgs;
                     // ******* //

public override bool CanExecute(object parameter)
return true;

Create a instance for the command as follow,                    
public partial class MainWindow : LinsMDIWindow
public MainWindow()

private void CreateCommands()
// Create COPY command instance
LinsUICommand command =
new CopyCommand(COPY_COMMAND_ID, null);

§  Constructors
1)  public TaskButton()
Initialize a new instance of TaskButton
§  Members
1)  public virtual Rect Bounds { get; }
Retrieve both the size and the location of the task button, in pixels, relative to its parent.
2)  public virtual Rect BoundsAtMDIFrame { get; }
Retrieve both the size and the location of the task button, in pixels, relative to MDI frame.
3)  public TaskButtonType ButtonType { get; set; }               
Get or set the button type; it can be one of the following values
§   SMALL:             
The button size is 120 X 120.
§   VERTICAL_MEDIUM:         
The button size is 120 X 245.
The button size is 245 X 120.
§   LARGE:         
The button size is 245 X 245.
4)  public bool ClickToSwitchScreen { get; set; }
If this member is set true, then the application will automatically switch from Metro Tasks Screen to View Screen once the button is clicked. The default is true.
5)  public long CommandID { get; set; }               
If this attribute is assigned, then this task button will be associated to the correspondent command with the same CommandID. See the above example for creating a command. 
6)  public virtual long ID { get; set; }               
Every task button should have a unique ID. If the user does not assign a number to the ID, a unique number which is larger than FlexConstants.m_nUserDefinedControlStartID (10,000,000) will be automatically generated and assigned to it. If the ID is between FlexConstants.m_nUserDefinedControlStartID (1000) and FlexConstants.m_nUserDefinedControlStartID (10,000,000), then once the task button is created, it will never been destroyed, and its layout will be persistent and customizable. You can always use LinsUIToolItemManager.GetToolItem() to retrieve its instance, once it is created.
7)  public virtual string Text { get; set; }
Gets or sets the text of the task button.
8)  public long ViewID { get; set; }               
User can assigned any document ID to it. When the task button is clicked, the associated document will be centered in the view screen. 
§  Events
1)     public event ClickEventhandler ClickEvent              
This event is fired when the task button is clicked. 



No comments:

Post a Comment