public static void AddCommandItem(this ItemCollection items, string header, Action <object> action, Predicate <object> canExecute = null, string buttonLabel = null) => items.Add(new MenuItem { Header = header, Command = R2Command.Relay(action, canExecute, buttonLabel) });
internal void ProcessInputs(int?qty, string barcodeText) { if (!qty.HasValue) { return; } if (!TryParseBarcode(barcodeText, out ulong bCode)) { return; } var skuDesc = _skus.FindDescription(bCode); if (skuDesc.IsBlank()) { Alerter.ShowError("Unregistered Barcode", $"Barcode is not in Products Master List:{L.f}“{bCode}”"); return; } var row = new ItemCountRow { TimeScanned = DateTime.Now, Quantity = qty.Value, Barcode = bCode, Description = skuDesc, }; row.DeleteCmd = R2Command.Relay(() => ItemCounts.Remove(row)); ItemCounts.Insert(0, row); }
private void EncodeNewDraft() { SaveDraftCmd = R2Command.Async(ExecuteSaveDraft, _ => CanSave(), $"Save {TypeDescription}"); Draft = new TDraft(); SetNewDraftDefaults(Draft); this.Show <TWindow>(showModal: true); }
public PreviousVerTabVM(IPackagePartManager packagePartManager) { _partsMgr = packagePartManager; GetVersionsCmd = R2Command.Async(GetVersions, _ => !Filename.IsBlank()); }
public JVsByDateRow(DateTime date, MainWindowVM2 mainWindow) { Date = date; MainWindow = mainWindow; RefreshCmd = R2Command.Async(FillBothCells, _ => !IsBusy); UpdateRntCmd = R2Command.Async(UpdateRnt, _ => CanUpdateRnt(), "Import"); }
public R2AppUpdaterBase(ILocalPackageFileUpdater localPackageFileUpdater, IFileSystemAccesor fileSystemAccesor) { _fs = fileSystemAccesor; _r2Upd8r = localPackageFileUpdater; _r2Upd8r.SetTargetFile(_fs.CurrentExeFile); _r2Upd8r.StatusChanged += (s, e) => SetStatus(e); _r2Upd8r.TargetUpdated += (s, e) => _updatesInstalled?.Raise(); RelaunchCmd = R2Command.Relay(RelaunchApp); RelaunchCmd.OverrideEnabled = false; StatusChanged += (s, e) => { Logs.Add(e); LogText = string.Join(L.f, Logs); }; Logs.MaxCount = 20; UpdatesInstalled += (s, e) => { OnUpdateInstalled?.Invoke(); RelaunchCmd.OverrideEnabled = true; CommandManager.InvalidateRequerySuggested(); if (AutoRelaunchOnUpdate) { RelaunchCmd.ExecuteIfItCan(); } }; }
public MainWindowVmBase() { _exeVer = CurrentExe.GetVersion(); ExitCmd = R2Command.Async(_ => ExitApp(false)); RelaunchCmd = R2Command.Async(_ => ExitApp(true)); AppendToCaption("..."); }
public DesignTimeDataVM() { CountsTally.Swap(CreateSampleItemCounts()); InventoryArea = Common.API.InventoryArea.Unknown; RefreshCmd = R2Command.Relay(() => { }); SubmitCmd = R2Command.Relay(() => { }); }
public AllocationsListVM() { AddDebitCmd = R2Command.Relay(_ => AddEntry(-1), null, "Add Debit entry"); AddCreditCmd = R2Command.Relay(_ => AddEntry(+1), null, "Add Credit entry"); ItemOpened += AllocationsListVM_ItemOpened; ItemDeleted += AllocationsListVM_ItemDeleted; }
public PackageCheckerVM(IR2PreUploadChecker preUploadChecker) { _preCheckr = preUploadChecker; CheckPackageCmd = R2Command.Async(CheckUploadability, _ => Package != null); }
public MainSenderWindowVM(ChangeSenderSettings changeSenderSettings) : base() { Config = changeSenderSettings; WatchAllCmd = R2Command.Relay(StartWatchingAll); WatchAllCmd.ExecuteIfItCan(); }
public MainWindowVMBase(TArg appArguments) { AppArgs = appArguments; RefreshCmd = R2Command.Async(DoRefresh, _ => !IsBusy, "Refresh"); CloseWindowCmd = R2Command.Relay(CloseWindow, null, "Close Window"); SetCaption($"as {AppArgs?.Credentials?.NameAndRole ?? "Anonymous"}"); }
internal PopUpInput(string caption, string message) { Caption = $" {caption}"; Message = message; Window = InitializeWindow(); SubmitCmd = R2Command.Relay(_ => Close(true), _ => CanSubmit(), "Submit"); }
public FundReqsListVM(ITenantDBsDir dir) : base(dir.Vouchers.ActiveRequests, dir, false) { Caption = "For Cheque Preparation"; Crud = new FundRequestCrudVM(dir); PrintVoucherCmd = R2Command.Relay(PrintVoucher, null, "Print Voucher Request"); }
public LeaseRowVM(LeaseDTO leaseDTO, MainWindowVM2 mainWindowVM2) { Lease = leaseDTO; MainWindow = mainWindowVM2; RefreshCmd = R2Command.Async(LoadRntCell, _ => !IsBusy); UpdateRntCmd = R2Command.Async(UpdateRntDB, _ => !IsBusy, "Update RNT"); }
public StallsListVM(MainWindowVM mainWindowVM, AppArguments appArguments) : base(appArguments.MarketState.Stalls, appArguments, false) { _main = mainWindowVM; Crud = new StallCrudVM(appArguments); _stallIdToLeases = GetStallsLookup(); AddMultipleCmd = R2Command.Async(AddMultipleStalls, _ => !_main.IsBusy, "Add Multiple Stalls"); }
public ApprovalRequesterVM(MainWindowVM mainWindowVM) { _main = mainWindowVM; FolderPath = FindFolderPath(_main); RequestKey = _main.Date.ToString("yyyy-MM-dd"); CancelCmd = R2Command.Relay(DoCancel); }
public static MenuItem CreateCloseAllCmd(string exePath) => new MenuItem { Header = "Close All Instances", Command = R2Command.Relay( _ => CloseAllInstances(exePath), _ => CountInstances(exePath) > 0) };
public ActiveLeasesVM(AppArguments appArguments) : base(appArguments.MarketState.ActiveLeases, appArguments, false) { Crud = new LeaseCrudVM(AppArgs.MarketState.ActiveLeases, AppArgs); AddStallToTenantCmd = R2Command.Relay(AddStallToTenant, _ => Crud.CanEncodeNewDraft(), "Add another Stall to this Tenant"); EditThisLeaseCmd = R2Command.Relay(EditThisLease, _ => CanEditRecord(Rows.CurrentItem?.DTO), "Edit this Lease"); EditTenantInfoCmd = R2Command.Relay(EditThisLease, _ => AppArgs.CanEditTenantInfo(false), "Edit Tenant Info"); TerminateThisLeaseCmd = R2Command.Relay(TerminateThisLease, _ => AppArgs.CanTerminateteLease(false), "Terminate this Lease"); }
public CollectorsMainVM(ITenantDBsDir appArguments) : base(appArguments) { var mkt = appArguments.MarketState; Rows = new MainListVM(mkt.Collectors, appArguments); ToolBar = new MainToolbarVM(this); EncodeNewDraftCmd = R2Command.Relay(EncodeNewDraft); }
public FilteredListVMBase(MainWindowVM mainWindowVM, ITenantDBsDir dir) : base(null, dir, false) { Main = mainWindowVM; EncodeNewDraftCmd = CreateEncodeNewDraftCmd(dir); PrintCmd = R2Command.Relay(() => _printRequested?.Raise(), null, "Print"); FillSectionsList(); }
public DailyTransactionRow(DateTime date, MainWindowVM mainWindowVM) { Date = date; MainWindow = mainWindowVM; RefreshCmd = R2Command.Async(FillBothCells, _ => !IsBusy); QueryByfCmd = R2Command.Async(FillByfCell, _ => !IsBusy, "Query BYF"); UpdateRntCmd = R2Command.Async(this.UpdateRnt, _ => this.CanUpdateRnt(), "Update RNT"); }
private void CreateCommands() { StartUploadCmd = R2Command.Async(StartUpload, x => CanUpload(), "Upload Package"); StopUploadCmd = R2Command.Relay(StopUpload, x => _pkgUploadr.IsUploading, "stop uploading"); }
public bool?EditCurrentRecord(TDraft currentItem) { SaveDraftCmd = R2Command.Async(ExecuteUpdateRecord, _ => CanSave(), $"Save {TypeDescription}"); //Draft = new TDraft(); //LoadValuesToDraft(currentItem, Draft); Draft = CreateDraftFromRecord(currentItem); return(this.Show <TWindow>(showModal: true)); }
public PeriodRowVM(DateTime date, MainWindowVM2 mainWindowVM2) { Date = date; MainWindow = mainWindowVM2; RefreshCmd = R2Command.Async(FillBothCells, _ => !IsBusy); QueryByfCmd = R2Command.Async(FillByfCell, _ => !IsBusy, "Query BYF"); UpdateRntCmd = R2Command.Async(_ => this.UpdateRNT(Date), _ => CanUpdateRnt(), "Update RNT"); }
public ConverterRowBase(MainWindowVM2 mainWindowVM2) { Main = mainWindowVM2; RefreshCmd = R2Command.Async(this.GetDifferences, _ => !IsBusy, "Get Diffs"); UpdateRntCmd = R2Command.Async(this.UpdateRnt, _ => this.CanUpdateRnt(), "Update RNT"); Remediate1Cmd = CreateRemediate1Cmd(); Remediate2Cmd = CreateRemediate2Cmd(); }
public SectionRowInspectorVM(SectionColxnsRow sectionColxnsRow, ITenantDBsDir dir) : base(dir) { MainRow = sectionColxnsRow; EditPRNumberCmd = R2Command.Relay(_ => EditPRNumber(_), _ => CanEditPRNumber(), "Edit PR Number"); MainRow.Details.ItemOpened += (s, e) => SoaViewer.Show(e.Lease, dir); SetCaption($"Collections from “{MainRow?.Section}” by {MainRow.Collector}"); }
public async Task RunAsync() { R2Command.s_StartDateTime = DateTime.Now; RandomizeChatterThreshold(); RandomizeRareChatterThreshold(); RandomizeMythicChatterThreshold(); var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = await sr.ReadToEndAsync().ConfigureAwait(false); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); m_Prefix = configJson.Prefix; var config = new DiscordConfiguration { Token = configJson.Token, TokenType = TokenType.Bot, AutoReconnect = true, //LogLevel = LogLevel.Debug, //UseInternalLogHandler = true, }; m_Client = new DiscordClient(config); m_Client.UseVoiceNext(); m_Client.Ready += OnClientReady; m_Client.MessageCreated += OnMessageCreated; m_Client.MessageCreated += CheckForPlaySyntax; m_Client.MessageCreated += Chatter; m_Client.MessageUpdated += OnMessageUpdated; m_Client.MessageUpdated += CheckUpdatedMessageForPlaySyntax; var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.Prefix }, EnableMentionPrefix = true, EnableDms = true, // maybe change this to allow commands via PM DmHelp = true, IgnoreExtraArguments = true, }; m_Commands = m_Client.UseCommandsNext(commandsConfig); m_Commands.RegisterCommands <R2Command>(); m_Commands.CommandExecuted += OnCommandExecuted; await m_Client.ConnectAsync(); R2Command.LoadSavedData(); await Task.Delay(-1); }
private void EncodeNewDraft() { SaveDraftCmd = R2Command.Async(ExecuteSaveDraft, _ => CanSave(), $"Save {TypeDescription}"); Draft = GetNewDraft(); if (Draft != null) { this.Show <TWindow>(showModal: true); } }
public AdHocJobCmdsVM(MainWindowVM mainWindowVM) { _main = mainWindowVM; _dir = _main.AppArgs; AdHocJobCmd1 = R2Command.Relay(_ => RunAdHoc(1), _ => _dir.CanRunAdHocTask(false), "Run Ad Hoc Command 1"); AdHocJobCmd2 = R2Command.Relay(_ => RunAdHoc(2), _ => _dir.CanRunAdHocTask(false), "Run Ad Hoc Command 2"); AdHocJobCmd3 = R2Command.Relay(_ => RunAdHoc(3), _ => _dir.CanRunAdHocTask(false), "Run Ad Hoc Command 3"); }