public static object ProcessResult(object result, ActionExecutionContext context = null) { IEnumerator <IResult> actions = null; if (result is IResult) { result = new[] { (IResult)result }; } if (result is IEnumerable <IResult> ) { result = ((IEnumerable <IResult>)result).GetEnumerator(); } if (result is IEnumerator <IResult> ) { actions = result as IEnumerator <IResult>; } if (actions != null) { Coroutine.BeginExecute(actions, context); } return(result); }
PrintResult IPrintable.Print() { var docs = new List <BaseDocument>(); if (!IsView) { var printItems = PrintMenuItems.Where(i => i.IsChecked).ToList(); if (!printItems.Any()) { printItems.Add(PrintMenuItems.First()); } foreach (var item in printItems) { if ((string)item.Header == "Списание") { docs.Add(new WriteoffDocument(Lines.ToArray())); } if ((string)item.Header == "Акт списания") { docs.Add(new WriteoffActDocument(Lines.ToArray())); } } return(new PrintResult(DisplayName, docs, PrinterName)); } if (String.IsNullOrEmpty(LastOperation) || LastOperation == "Списание") { Coroutine.BeginExecute(Print().GetEnumerator()); } if (LastOperation == "Акт списания") { Coroutine.BeginExecute(PrintAct().GetEnumerator()); } return(null); }
protected override void OnStartup(object sender, StartupEventArgs e) { Coroutine.BeginExecute(kernel .Get <SettingsLoaderViewModel>() .Load(() => DisplayRootViewFor <MainShellViewModel>()) .GetEnumerator()); }
public void OpenEditorTo(DimensionViewModel source) { // hacky, but i love it. var enumerator = new IResult[] { new OpenEditorTo(source.World, (int)source.Dimension) }.AsEnumerable(); Coroutine.BeginExecute(enumerator.GetEnumerator()); }
protected override void OnActivate() { base.OnActivate(); Events.Subscribe(this); string registry = @"Software\Technische Universität München\Table Tennis Analysis\Secure"; Secure scr = new Secure(Secure.Mode.Date); bool validVersion = scr.Algorithm("xyz", registry); if (validVersion != true) { this.TryClose(); } if (this.ActiveItem == null) { ActivateItem(new WelcomeViewModel(MatchManager)); } var userTto = AppBootstrapper.UserTto; if (userTto != null) { Coroutine.BeginExecute(MatchManager.OpenMatch(userTto).GetEnumerator()); } }
internal static void InvokeAction(ActionExecutionContext context) { var decorators = context.GetFilters() .OfType <IDecorateCoroutineFilter>() .ToArray(); // Use the default behaviour when no decorators are found if (!decorators.Any()) { BaseInvokeAction(context); return; } var values = MessageBinder.DetermineParameters(context, context.Method.GetParameters()); var returnValue = context.Method.Invoke(context.Target, values); IEnumerable <IResult> coroutine; if (returnValue is IResult) { coroutine = new[] { returnValue as IResult }; } else if (returnValue is IEnumerable <IResult> ) { coroutine = returnValue as IEnumerable <IResult>; } else { return; } coroutine = decorators.Aggregate(coroutine, (current, decorator) => decorator.Decorate(current, context)); Coroutine.BeginExecute(coroutine.GetEnumerator(), context); }
public PrintResult Print() { var docs = new List <BaseDocument>(); if (!IsView) { var printItems = PrintMenuItems.Where(i => i.IsChecked).ToList(); if (!printItems.Any()) { printItems.Add(PrintMenuItems.First()); } foreach (var item in printItems) { if ((string)item.Header == DisplayName) { docs.Add(new CatalogOfferDocument(ViewHeader, GetPrintableOffers())); } } return(new PrintResult(DisplayName, docs, PrinterName)); } if (String.IsNullOrEmpty(LastOperation) || LastOperation == DisplayName) { Coroutine.BeginExecute(PrintPreview().GetEnumerator()); } return(null); }
/// <summary> /// Gets executed when the start button is clicked and tries then to generate the playfield /// </summary> public void StartGame() { Coroutine.BeginExecute(GeneratePlayfield.GetEnumerator()); _eventAggregator.PublishOnUIThread(message: true); _playfield.Status = Enums.PlayfieldStatus.InProgress; _playfieldViewModel.Refresh(); }
protected override void OnStartup(object sender, StartupEventArgs e) { Coroutine.BeginExecute(kernel .Get <SettingsLoaderViewModel>() .Load(OnSettingsLoaded) .GetEnumerator()); }
public EditDisplacementDoc() { InitializeComponent(); Loaded += (sender, args) => { Lines.Focus(); }; Keyboard.AddPreviewKeyDownHandler(this, (sender, args) => { IEnumerable <IResult> results = null; if (args.Key == Key.Insert) { results = Model.Add(); args.Handled = true; } else if (args.Key == Key.Delete) { Model.Delete(); args.Handled = true; } if (results != null) { Coroutine.BeginExecute(results.GetEnumerator(), new ActionExecutionContext { View = this }); args.Handled = true; } }); }
/// <summary> /// Defines the method to be called when the command is invoked. /// </summary> /// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param> public void Execute(object parameter) { var method = DynamicDelegate.From(context.Method); var returnValue = method(context.Target, new object[0]); var task = returnValue as System.Threading.Tasks.Task; if (task != null) { returnValue = task.AsResult(); } var result = returnValue as IResult; if (result != null) { returnValue = new[] { result }; } var enumerable = returnValue as IEnumerable <IResult>; if (enumerable != null) { returnValue = enumerable.GetEnumerator(); } var enumerator = returnValue as IEnumerator <IResult>; if (enumerator != null) { Coroutine.BeginExecute(enumerator, context); } }
protected override async void OnDeactivate(bool close) { if (MatchManager.MatchModified) { var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "Save and Close", NegativeButtonText = "Cancel", FirstAuxiliaryButtonText = "Close Without Saving", AnimateShow = true, AnimateHide = false }; var result = await DialogCoordinator.ShowMessageAsync(this, "Close Window?", "You didn't save your changes?", MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary, mySettings); bool _shutdown = result == MessageDialogResult.Affirmative; if (_shutdown) { Coroutine.BeginExecute(MatchManager.SaveMatch().GetEnumerator(), new CoroutineExecutionContext() { View = this.GetView() }); Application.Current.Shutdown(); } } this.DeactivateItem(Player1InformationView, close); this.DeactivateItem(Player2InformationView, close); events.Unsubscribe(this); }
/// <summary> /// Download postings if they are outdated for current filter period. /// </summary> public void Update() { if (IsOutdated) { Coroutine.BeginExecute(DownloadAllTransactions().GetEnumerator()); } }
public override Task <bool> CanCloseAsync(CancellationToken cancellationToken) { var tcs = new TaskCompletionSource <bool>(); Coroutine.BeginExecute(CanCloseAsync().GetEnumerator(), null, (s, e) => tcs.SetResult(!e.WasCancelled)); return(tcs.Task); }
private void Processerror(string valueMessage) { _logManager.WriteError(1160, valueMessage); MensagemPopup = valueMessage; Coroutine.BeginExecute(ShowDialogGetResult().GetEnumerator()); }
PrintResult IPrintable.Print() { var docs = new List <BaseDocument>(); if (!IsView) { var printItems = PrintMenuItems.Where(i => i.IsChecked).ToList(); if (!printItems.Any()) { printItems.Add(PrintMenuItems.First()); } foreach (var item in printItems) { if ((string)item.Header == DisplayName) { docs.Add(new CheckDocument(Items.Value.ToArray())); } if ((string)item.Header == "Акт возврата") { docs.Add(new ReturnActDocument(Items.Value.Where(x => x.CheckType == CheckType.CheckReturn).ToArray())); } } return(new PrintResult(DisplayName, docs, PrinterName)); } if (String.IsNullOrEmpty(LastOperation) || LastOperation == DisplayName) { Coroutine.BeginExecute(PrintChecks().GetEnumerator()); } if (LastOperation == "Акт возврата") { Coroutine.BeginExecute(PrintReturnAct().GetEnumerator()); } return(null); }
public PrintResult Print() { var docs = new List <BaseDocument>(); if (!IsView) { var printItems = PrintMenuItems.Where(i => i.IsChecked).ToList(); if (!printItems.Any()) { printItems.Add(PrintMenuItems.First()); } foreach (var item in printItems) { if ((string)item.Header == DisplayName) { //порядок сортировки должен быть такой же как в таблице var lines = GetItemsFromView <IOrderLine>("Lines") ?? Lines.Value; docs.Add(new OrderDocument(Order.Value, lines)); } } return(new PrintResult(DisplayName, docs, PrinterName)); } if (String.IsNullOrEmpty(LastOperation) || LastOperation == DisplayName) { Coroutine.BeginExecute(PrintPreview().GetEnumerator()); } return(null); }
PrintResult IPrintable.Print() { var docs = new List <BaseDocument>(); if (!IsView) { var printItems = PrintMenuItems.Where(i => i.IsChecked).ToList(); if (!printItems.Any()) { printItems.Add(PrintMenuItems.First()); } foreach (var item in printItems) { if ((string)item.Header == DisplayName) { docs.Add(new ShelfLifeDocument(Items.Value.ToArray(), GetVisibilityDic())); } } return(new PrintResult(DisplayName, docs, PrinterName)); } if (String.IsNullOrEmpty(LastOperation) || LastOperation == DisplayName) { Coroutine.BeginExecute(Print().GetEnumerator()); } return(null); }
PrintResult IPrintable.Print() { var docs = new List <BaseDocument>(); if (!IsView) { var printItems = PrintMenuItems.Where(i => i.IsChecked).ToList(); if (!printItems.Any()) { printItems.Add(PrintMenuItems.First()); } foreach (var item in printItems) { if ((string)item.Header == "Возврат товара") { docs.Add(new ReturnToSuppliersDetailsDocument(Lines.ToArray(), Doc, Session.Query <WaybillSettings>().First())); } if ((string)item.Header == "Возврат ярлык") { docs.Add(new ReturnLabel(Doc, Session.Query <WaybillSettings>().First())); } if ((string)item.Header == "Возврат счет-фактура") { docs.Add(new ReturnInvoice(Doc, Session.Query <WaybillSettings>().First())); } if ((string)item.Header == "Возврат товарная накладная") { docs.Add(new ReturnWaybill(Doc, Session.Query <WaybillSettings>().First(), Session.Query <User>().First())); } if ((string)item.Header == "Акт о расхождении") { docs.Add(new ReturnDivergenceAct(Doc, Session.Query <WaybillSettings>().First())); } } return(new PrintResult(DisplayName, docs, PrinterName)); } if (String.IsNullOrEmpty(LastOperation) || LastOperation == "Возврат товара") { Coroutine.BeginExecute(Print().GetEnumerator()); } if (LastOperation == "Возврат ярлык") { Coroutine.BeginExecute(PrintReturnLabel().GetEnumerator()); } if (LastOperation == "Возврат счет-фактура") { Coroutine.BeginExecute(PrintReturnInvoice().GetEnumerator()); } if (LastOperation == "Возврат товарная накладная") { Coroutine.BeginExecute(PrintReturnWaybill().GetEnumerator()); } if (LastOperation == "Акт о расхождении") { Coroutine.BeginExecute(PrintReturnDivergenceAct().GetEnumerator()); } return(null); }
// NOTE: Notification by using the event aggregator. This could also be done with the Event Broker protected override void OnDeactivate(bool close) { base.OnDeactivate(close); UserNameChosen message = this.ToUserNameChosen(); Coroutine.BeginExecute(this.Actions().Notify(message).GetEnumerator()); }
public void Both() { Coroutine.BeginExecute(CountPrimes().GetEnumerator(), new CoroutineExecutionContext() { Target = this }); Coroutine.BeginExecute(StartGame().GetEnumerator()); }
private async Task Initialize() { //Initialize only once if (this._isInitialized) { return; } this._isInitialized = true; //Caliburn Micro Setup PlatformProvider.Current = new UwCorePlatformProvider(); EventAggregator.HandlerResultProcessing = (target, result) => { var task = result as Task; if (task != null) { result = new IResult[] { task.AsResult() }; } var coroutine = result as IEnumerable <IResult>; if (coroutine != null) { var viewAware = target as IViewAware; var view = viewAware?.GetView(); var context = new CoroutineExecutionContext { Target = target, View = view }; Coroutine.BeginExecute(coroutine.GetEnumerator(), context); } }; AssemblySource.Assemblies.AddRange(this.SelectAssemblies()); //Attach to application events this.Resuming += this.OnResuming; this.Suspending += this.OnSuspending; this.UnhandledException += this.OnUnhandledException; //Configure this.ConfigureContainer(); this.ConfigureLogging(); this.Configure(); //Setup IoC IoC.GetInstance = (service, key) => this._container.IsRegistered(service) ? this._container.Resolve(service) : Activator.CreateInstance(service); IoC.GetAllInstances = service => ((IEnumerable)this._container.Resolve(typeof(IEnumerable <>).MakeGenericType(service))).OfType <object>(); IoC.BuildUp = instance => this._container.InjectUnsetProperties(instance); //Restore state await this._container.Resolve <IApplicationStateService>().RestoreStateAsync(); }
PrintResult IPrintable.Print() { var docs = new List <BaseDocument>(); if (!IsView) { var printItems = PrintMenuItems.Where(i => i.IsChecked).ToList(); if (!printItems.Any()) { printItems.Add(PrintMenuItems.First()); } foreach (var item in printItems) { if ((string)item.Header == "Товарные запасы") { docs.Add(new StockDocument(Items.Value.ToArray())); } if ((string)item.Header == "Ярлыки") { Tags(); } if ((string)item.Header == "Товары со сроком годности") { var stocks = Items.Value.Where(s => !String.IsNullOrEmpty(s.Period)).ToList(); var per = new DialogResult(new SelectStockPeriod(stocks, Name)); per.Execute(null); } if ((string)item.Header == "Товары со сроком годности менее 1 месяца") { docs.Add(new StockLimitMonthDocument(Items.Value.Where(s => s.Exp < DateTime.Today.AddMonths(1)).ToArray(), "Товары со сроком годности менее 1 месяца", Name)); } } return(new PrintResult(DisplayName, docs, PrinterName)); } if (string.IsNullOrEmpty(LastOperation) || LastOperation == "Товарные запасы") { Coroutine.BeginExecute(Print().GetEnumerator()); } if (LastOperation == "Ярлыки") { Tags(); } if (LastOperation == "Товары со сроком годности") { Coroutine.BeginExecute(PrintStockLimit().GetEnumerator()); } if (LastOperation == "Товары со сроком годности менее 1 месяца") { Coroutine.BeginExecute(PrintStockLimitMonth().GetEnumerator()); } return(null); }
//static string Abbreviate(Key key) //{ // switch (key) // { // case Key.Back: // return "Backspace"; // case Key.Escape: // return "Esc"; // case Key.None: // return string.Empty; // } // return null; //} #endif void OnKeyUp(object s, KeyEventArgs e) { foreach (var shortcut in shortcuts) { if (e.Key == shortcut.Key && Keyboard.Modifiers == shortcut.Modifers) { if (shortcut.CanExecute) { Coroutine.BeginExecute(shortcut.Execute()); } break; } } }
public Frontend2() { DisplayName = "Регистрация продаж"; InitFields(); Status.Value = "Готов к работе(F1 для справки)"; Lines = new ReactiveCollection <CheckLine>(); CheckLinesForReturn = new List <CheckLine>(); Warning = new InlineEditWarning(Scheduler, Manager); OnCloseDisposable.Add(SearchBehavior = new SearchBehavior(Env)); SearchBehavior.ActiveSearchTerm.Where(x => !String.IsNullOrEmpty(x)) .Subscribe(x => Coroutine.BeginExecute(Enter().GetEnumerator())); CurrentCatalog.Select(x => x?.Name?.Description != null) .Subscribe(CanShowDescription); }
protected virtual void StartRuntime() { EventAggregator.HandlerResultProcessing = (target, result) => { var task = result as System.Threading.Tasks.Task; if (task != null) { result = new IResult[] { task.AsResult() }; } var coroutine = result as IEnumerable <IResult>; if (coroutine != null) { var viewAware = target as IViewAware; var view = viewAware != null?viewAware.GetView() : null; var context = new CoroutineExecutionContext { Target = target, View = view }; Coroutine.BeginExecute(coroutine.GetEnumerator(), context); } }; AssemblySourceCache.Install(); foreach (var ambly in SelectAssemblies()) { try { //过滤掉win32非托管dll string[] errors = new string[] { "CSkin", "Em.MCIFrameWork", "Itenso" }; if (errors.FirstOrDefault(x => ambly.FullName.Contains(x)) == null) { AssemblySource.Instance.Add(ambly); } } catch { } } ; if (useApplication) { Application = Application.Current; PrepareApplication(); } Configure(); IoC.GetInstance = GetInstance; IoC.GetAllInstances = GetAllInstances; IoC.BuildUp = BuildUp; }
/// <summary> /// Determines whether the view model can be closed. /// </summary> /// <param name="callback">Called to perform the closing</param> public override void CanClose(System.Action <bool> callback) { var context = new CoroutineExecutionContext() { Target = this, View = this.GetView() as DependencyObject, }; Coroutine.BeginExecute( this.PrepareClose().GetEnumerator(), context, (sender, args) => { callback(args.WasCancelled != true); }); }
public override void Execute(ActionExecutionContext context) { IConductor conductor = _locateConductor(context); TItem item = _locateItem(context); if (_initialize != null) { _initialize(item); } AddCloseHandlers(item, context); Coroutine.BeginExecute(ActivateItem(conductor, item).GetEnumerator(), context, (sender, args) => OnCompleted(args.Error, args.WasCancelled)); }
public PrintResult Print() { var docs = new List <BaseDocument>(); if (!IsView) { var printItems = PrintMenuItems.Where(i => i.IsChecked).ToList(); if (!printItems.Any()) { printItems.Add(PrintMenuItems.First()); } foreach (var item in printItems) { if ((string)item.Header == DisplayName) { if (!User.CanPrint <Awaited, AwaitedItem>() || Address == null) { continue; } var items = GetItemsFromView <AwaitedItem>("Items") ?? Items.Value; docs.Add(new AwaitedDocument(items)); } if ((string)item.Header == "Сводный прайс-лист") { if (!User.CanPrint <Awaited, Offer>() || CurrentCatalog.Value == null) { continue; } var items = GetPrintableOffers(); docs.Add(new CatalogOfferDocument(CurrentCatalog.Value.Name.Name, items)); } } return(new PrintResult(DisplayName, docs, PrinterName)); } if (String.IsNullOrEmpty(LastOperation) || LastOperation == DisplayName) { Coroutine.BeginExecute(PrintPreview().GetEnumerator()); } if (LastOperation == "Сводный прайс-лист") { Coroutine.BeginExecute(PrintPreviewCatalogOffer().GetEnumerator()); } return(null); }
/// <summary> /// Defines the method to be called when the command is invoked. /// </summary> /// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param> public void Execute(object parameter) { var target = targetReference.Target; if (target == null) { return; } var execute = DynamicDelegate.From(method); var returnValue = execute(target, new object[0]); var task = returnValue as System.Threading.Tasks.Task; if (task != null) { returnValue = task.AsResult(); } var result = returnValue as IResult; if (result != null) { returnValue = new[] { result }; } var enumerable = returnValue as IEnumerable <IResult>; if (enumerable != null) { returnValue = enumerable.GetEnumerator(); } var enumerator = returnValue as IEnumerator <IResult>; if (enumerator != null) { var context = new CoroutineExecutionContext { Target = target, }; Coroutine.BeginExecute(enumerator, context); } }