本文整理汇总了C#中Command类的典型用法代码示例。如果您正苦于以下问题:C# Command类的具体用法?C# Command怎么用?C# Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于命名空间,在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MarcoTest
public void MarcoTest()
{
var a = 1;
var b = 2;
var actual = 0;
var expected = 5;
var cmdA = new Command((parameters) =>
{
a++;
});
var cmdB = new Command((parameters) =>
{
b++;
});
var cmdC = new Command((parameters) =>
{
actual = a + b;
});
/// Another way to execute dynamic command:
/// var maco=new Macro();
/// macro.Add(() => { a++; }, () => { b++; }, () => { actual = a + b; });
var macro = new Macro(cmdA, cmdB, cmdC);
macro.Call();
Assert.AreEqual(expected, actual);
}
示例2: SendCommand
public void SendCommand( Command command, short commandData )
{
byte[] data = new byte[2];
data[0] = (byte) (commandData & 0xFF);
data[0] = (byte) (commandData >> 8 );
SendCommand( command, data );
}
示例3: LeadListHeaderView
public LeadListHeaderView(Command newLeadTappedCommand)
{
_NewLeadTappedCommand = newLeadTappedCommand;
#region title label
Label headerTitleLabel = new Label()
{
Text = TextResources.Leads_LeadListHeaderTitle.ToUpperInvariant(),
TextColor = Palette._003,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
FontAttributes = FontAttributes.Bold,
HorizontalTextAlignment = TextAlignment.Start,
VerticalTextAlignment = TextAlignment.Center
};
#endregion
#region new lead image "button"
var newLeadImage = new Image
{
Source = new FileImageSource { File = Device.OnPlatform("add_ios_gray", "add_android_gray", null) },
Aspect = Aspect.AspectFit,
HorizontalOptions = LayoutOptions.EndAndExpand,
};
//Going to use FAB
newLeadImage.IsVisible = false;
newLeadImage.GestureRecognizers.Add(new TapGestureRecognizer()
{
Command = _NewLeadTappedCommand,
NumberOfTapsRequired = 1
});
#endregion
#region absolutLayout
AbsoluteLayout absolutLayout = new AbsoluteLayout();
absolutLayout.Children.Add(
headerTitleLabel,
new Rectangle(0, .5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize),
AbsoluteLayoutFlags.PositionProportional);
absolutLayout.Children.Add(
newLeadImage,
new Rectangle(1, .5, AbsoluteLayout.AutoSize, .5),
AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.HeightProportional);
#endregion
#region setup contentView
ContentView contentView = new ContentView()
{
Padding = new Thickness(10, 0), // give the content some padding on the left and right
HeightRequest = RowSizes.MediumRowHeightDouble, // set the height of the content view
};
#endregion
#region compose the view hierarchy
contentView.Content = absolutLayout;
#endregion
Content = contentView;
}
示例4: LoginPageViewModel
public LoginPageViewModel (IMyNavigationService navigationService)
{
this.navigationService = navigationService;
LoggedIn = App.LoggedIn;
GoToSignupPage = new Command (() => {
this.navigationService.NavigateTo(ViewModelLocator.SignupPageKey);
});
Login = new Command ( async () => {
// var database = new ECOdatabase();
var database = new AzureDatabase ();
// database1.GetUsers();
int rowcount = await database.ValidateUser (Username, Password);
if (rowcount == 0) {
App.LoggedIn = false;
} else {
App.LoggedIn = true;
//Navigate to homepage without back key
this.navigationService.NavigateToModal (ViewModelLocator.HomePageKey);
}
});
}
示例5: DXToolStripMenuItem
public DXToolStripMenuItem(String name, Command cmd)
: base()
{
ci = new CommandInterface(name, cmd, this);
this.Click += new EventHandler(cmd.executeEvent);
}
示例6: ExtendedMessage
/// <summary>
/// Creates new X10 extended message.
/// </summary>
/// <param name="house">Valid range is A-P.</param>
/// <param name="unit">Valid units are 01-16.</param>
/// <param name="command">Only commands ExtendedCode and ExtendedData are valid for extended messages.</param>
/// <param name="extendedCommand">Byte 0-255. Make sure that either extended command or data is above 0.</param>
/// <param name="extendedData">Byte 0-255. Make sure that either extended command or data is above 0.</param>
public ExtendedMessage(House house, Unit unit, Command command, byte extendedCommand, byte extendedData)
: base(house, unit, command)
{
Validate(extendedCommand, extendedData);
ExtendedCommand = extendedCommand;
ExtendedData = extendedData;
}
示例7: FishboneNodeActionPlansVM
public FishboneNodeActionPlansVM(FishboneNodeVM defection, AccessType access)
: base(access)
{
UnitOfWork = new SoheilEdmContext();
CurrentFishboneNode = defection;
FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork);
FishboneNodeDataService.ActionPlanAdded += OnActionPlanAdded;
FishboneNodeDataService.ActionPlanRemoved += OnActionPlanRemoved;
ActionPlanDataService = new ActionPlanDataService(UnitOfWork);
var selectedVms = new ObservableCollection<ActionPlanFishboneVM>();
foreach (var productFishboneNode in FishboneNodeDataService.GetActionPlans(defection.Id))
{
selectedVms.Add(new ActionPlanFishboneVM(productFishboneNode, Access, RelationDirection.Reverse));
}
SelectedItems = new ListCollectionView(selectedVms);
var allVms = new ObservableCollection<ActionPlanVM>();
foreach (var actionPlan in ActionPlanDataService.GetActives())
{
allVms.Add(new ActionPlanVM(actionPlan, Access, ActionPlanDataService));
}
AllItems = new ListCollectionView(allVms);
IncludeCommand = new Command(Include, CanInclude);
ExcludeCommand = new Command(Exclude, CanExclude);
}
示例8: EmployeeMainPropertiesViewModel
public EmployeeMainPropertiesViewModel(Employee employee)
{
_departmentRepository = new DepartmentRepository();
_employee = employee;
ChangeDepartmentCommand = new Command(ChangeDepartment);
}
示例9: AsyncRequest
public override FutureResponse AsyncRequest(Command command)
{
lock(transmissionLock)
{
return base.AsyncRequest(command);
}
}
示例10: OnReceiveCommand
private bool OnReceiveCommand(SocketState cs, Command c)
{
if(!requesting || this.IsDisposed || c.CommandType != Command.Type.Screenshot || cs.Connection.RemoteEndPoint.ToString() != this.cs.Connection.RemoteEndPoint.ToString())
{
return false;
}
CommandState cmdState = CommandHandler.HandleCommand(c, cs);
try
{
pbScreenshot.Invoke((MethodInvoker)delegate
{
tmrScreenshot.Enabled = requesting;
tmrScreenshotTimeout.Enabled = false;
pbScreenshot.Image = byteArrayToImage((byte[])cmdState.ReturnValue);
}, null);
}
catch (Exception)
{
//sh.OnReceiveDataCallback = original;
return false;
}
return true;
}
示例11: RunCommand
private void RunCommand(Command command)
{
_content = EnsureContent(_content);
_negativeWords = EnsureNegativeWords(_negativeWords);
_inputOutput.Clear();
_contentProcessor.Run(command, _content, _negativeWords);
}
示例12: GenreItem
public GenreItem(Library.GalleryItem title, IModelItem owner, List<TitleFilter> filter)
: base(owner)
{
this.Description = title.Name;
this.DefaultImage=title.MenuCoverArt;
this.Metadata = string.Format("{0} titles", title.ForcedCount);
this.Invoked += delegate(object sender, EventArgs args)
{
//am I being silly here copying this?
List<TitleFilter> newFilter = new List<TitleFilter>();
foreach (TitleFilter filt in filter)
{
newFilter.Add(filt);
}
newFilter.Add(new TitleFilter(title.Category.FilterType, title.Name));
OMLProperties properties = new OMLProperties();
properties.Add("Application", OMLApplication.Current);
properties.Add("I18n", I18n.Instance);
Command CommandContextPopOverlay = new Command();
properties.Add("CommandContextPopOverlay", CommandContextPopOverlay);
Library.Code.V3.GalleryPage gallery = new Library.Code.V3.GalleryPage(newFilter, title.Description);
properties.Add("Page", gallery);
OMLApplication.Current.Session.GoToPage(@"resx://Library/Library.Resources/V3_GalleryPage", properties);
};
}
示例13: MainWindowViewModel
/// <summary>
/// Initializes a new instance of the <see cref="MainWindowViewModel"/> class.
/// </summary>
public MainWindowViewModel()
: base()
{
HomeViewCommand = new Command(OnHomeViewCommandExecute, OnHomeViewCommandCanExecute);
AddReport = new Command(OnAddReportExecute, OnAddReportCanExecute);
CurrentViewModel = new HomeViewModel();
}
示例14: PerformClickShouldExecuteCommand
public void PerformClickShouldExecuteCommand()
{
var clicked = false;
var command = new Command<string>(
p =>
{
Assert.Null( p );
clicked = true;
} );
var target = new ClickableItem<string>( "test", command );
target.PerformClick();
Assert.True( clicked );
clicked = false;
command = new Command<string>(
p =>
{
Assert.Equal( "test2", p );
clicked = true;
} );
target = new ClickableItem<string>( "test", command );
target.PerformClick( "test2" );
Assert.True( clicked );
}
示例15: ExitInnerBlock
public override void ExitInnerBlock( Command command, Thread thread, Scope scope )
{
if ( new TLBit( command.ParamExpression.Evaluate( scope ) ).Value )
thread.EnterBlock( command.InnerBlock );
else
thread.Advance();
}