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.
Examples
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
<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"
mc:Ignorable="d" Height="435" Width="1130">
<!--------------------------------------------->
<src:SurfaceSliderTasksPanel>
<src:TaskGroup ID="4011"
Text="File
Operation">
<src:TaskGroupHeader>
<Grid
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<ContentPresenter x:Name="GroupHeader1" Content="{Binding}"
ContentTemplate="{StaticResource
TaskGroupHeaderTemplate1}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>
</Grid>
</src:TaskGroupHeader>
<src:TaskButton Text="Copy"
ID="4012” ButtonType="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"/>
</Grid>
</src:TaskButton>
</src:TaskGroup>
</src:SurfaceSliderTasksPanel>
<!--------------------------------------------->
</src:SurfaceSlider>
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(
System.Windows.Input.Key.C,
System.Windows.Input.ModifierKeys.Control);
}
public override void
Execute(object parameter)
{
base.Execute(parameter);
//
Execute your command //
}
[CommandEventAttribute(COMMAND_EVENT.HELPBUTTON_CLICK)]
protected void HelpClick(object sender, EventArgs e)
{
//
******* //
}
[CommandEventAttribute(COMMAND_EVENT.KEY_UP)]
protected void OnKeyUp(object
sender, EventArgs e)
{
if (!(e is KeyEventArgs))
{
return;
}
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()
{
InitializeComponent();
CreateCommands();
}
private void CreateCommands()
{
//
Create COPY command instance
LinsUICommand command =
new CopyCommand(COPY_COMMAND_ID, null);
}
}
§
Constructors
1)
public
TaskButton()
Remarks
Initialize
a new instance of TaskButton.
§
Members
1)
public virtual Rect Bounds { get; }
Remarks
Retrieve
both the size and the location of the task button, in pixels, relative to its
parent.
2)
public virtual Rect BoundsAtMDIFrame { get; }
Remarks
Retrieve
both the size and the location of the task button, in pixels, relative to MDI
frame.
3)
public
TaskButtonType ButtonType
{ get; set; }
Remarks
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.
§
HORIZONTAL_MEDIUM:
The
button size is 245 X 120.
§
LARGE:
The
button size is 245 X 245.
4)
public bool ClickToSwitchScreen { get; set; }
Remarks
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; }
Remarks
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; }
Remarks
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; }
Remarks
Gets
or sets the text of the task button.
8)
public
long ViewID {
get; set; }
Remarks
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
Remarks
This
event is fired when the task button is clicked.
Demo
References:
No comments:
Post a Comment