当前位置: 首页>>代码示例>>C#>>正文


C# Command类代码示例

本文整理汇总了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);
        }
开发者ID:hispafox,项目名称:DNA.Patterns,代码行数:31,代码来源:CommandPatternTest.cs

示例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 );
 }
开发者ID:nico-izo,项目名称:KOIB,代码行数:7,代码来源:Xsocks.cs

示例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;
        }
开发者ID:XnainA,项目名称:app-crm,代码行数:60,代码来源:LeadListHeaderView.cs

示例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);
				}

			});

		}
开发者ID:joagwa,项目名称:EasyTechy,代码行数:28,代码来源:LoginPageViewModel.cs

示例5: DXToolStripMenuItem

        public DXToolStripMenuItem(String name, Command cmd)
            : base()
        {
            ci = new CommandInterface(name, cmd, this);

            this.Click += new EventHandler(cmd.executeEvent);
        }
开发者ID:BackupTheBerlios,项目名称:opendx2,代码行数:7,代码来源:DXToolStripMenuItem.cs

示例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;
 }
开发者ID:gerzo,项目名称:x10,代码行数:15,代码来源:ExtendedMessage.cs

示例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);
        }
开发者ID:T1Easyware,项目名称:Soheil,代码行数:27,代码来源:FishBoneNodeActionPlansVM.cs

示例8: EmployeeMainPropertiesViewModel

        public EmployeeMainPropertiesViewModel(Employee employee)
        {
            _departmentRepository = new DepartmentRepository();
            _employee = employee;

            ChangeDepartmentCommand = new Command(ChangeDepartment);
        }
开发者ID:mdcruz,项目名称:NorthwindAutomation,代码行数:7,代码来源:EmployeeMainPropertiesViewModel.cs

示例9: AsyncRequest

 public override FutureResponse AsyncRequest(Command command)
 {
     lock(transmissionLock)
     {
         return base.AsyncRequest(command);
     }
 }
开发者ID:ThorTech,项目名称:apache-nms,代码行数:7,代码来源:MutexTransport.cs

示例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;
        }
开发者ID:AlbinoDrought,项目名称:TheForlorn,代码行数:25,代码来源:WatchForm.cs

示例11: RunCommand

 private void RunCommand(Command command)
 {
     _content = EnsureContent(_content);
     _negativeWords = EnsureNegativeWords(_negativeWords);
     _inputOutput.Clear();
     _contentProcessor.Run(command, _content, _negativeWords);
 }
开发者ID:skirmamack,项目名称:Euromoney.RecruitmentTest,代码行数:7,代码来源:ContentProcessorLauncher.cs

示例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);
            };
        }
开发者ID:peeboo,项目名称:open-media-library,代码行数:27,代码来源:GenreItem.cs

示例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();
 }
开发者ID:da991319,项目名称:GenericFileTransferCatel,代码行数:10,代码来源:MainWindowViewModel.cs

示例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 );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:25,代码来源:ClickableItemTTest.cs

示例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();
 }
开发者ID:Metapyziks,项目名称:ThreadedLanguageExp,代码行数:7,代码来源:CmdWhl.cs


注:本文中的Command类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。