public bool CheckCompatibility(ScreenContainerContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } return(context.Session.IsMaster()); }
private void BuildScreens() { var extensionInfoList = _sessionContext.ExtensionManager.SelectExtensionInfoListByTag(ExtensionCatalog.Tags .TopScreen); mTabControl.SuspendLayout(); // SuspendLayout foreach (Control control in mTabControl.Controls.Cast <Control>().ToList()) { control.Dispose(); } mTabControl.Controls.Clear(); foreach (var extensionInfo in extensionInfoList) { var screenProvider = _sessionContext.ExtensionManager.TryGetTopScreenProvider(extensionInfo.Id); if (null == screenProvider) { continue; } var screenContainerContext = new ScreenContainerContext(_sessionContext, this); if (!screenProvider.CheckCompatibility(screenContainerContext)) { continue; } var control = screenProvider.GetScreen(screenContainerContext); control.Dock = DockStyle.Fill; var tabPage = new TabPage(Translator.Instance.Translate("Screens", extensionInfo.Name)) { UseVisualStyleBackColor = true }; tabPage.Controls.Add(control); mTabControl.Controls.Add(tabPage); } mTabControl.ResumeLayout(); // ResumeLayout }
public Control GetScreen(ScreenContainerContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); _screen = new ListScreen { Dock = DockStyle.Fill }; _screen.RefreshCallback += () => { SoundPlayer soundPlayer = new SoundPlayer(Resources.payment); soundPlayer.Play(); return(new List <ListItemContent>()); }; ErrorFormDisplayHelper.ApplyErrorAction(context.ExtensionManager, _screen); //_screen.ApplyTemplate(template); return(_screen); }
public Control GetScreen(ScreenContainerContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); var origin = new AccountListScreenOrigin(context, ExtensionCatalog.TrustsScreen) { MenuItemsTagName = ExtensionCatalog.Tags.TrustExtension, CommandBarTagName = ExtensionCatalog.Tags.TrustsScreenExtension }; var template = AccountDisplayHelper.LoadListScreenTemplate(origin); _screen = new ListScreen { Dock = DockStyle.Fill }; ErrorFormDisplayHelper.ApplyErrorAction(context.ExtensionManager, _screen); EventBroker.TrustChanged += EventBrokerOnTrustChanged; _screen.Disposed += (sender, args) => { EventBroker.TrustChanged -= EventBrokerOnTrustChanged; }; _screen.ApplyTemplate(template); // Команда Refresh _screen.RefreshCallback += () => SelectTrusts(true); _screen.MenuItemResolver = (entity, command) => { var trust = _screen.CurrentEntity as ITrust; if (null == trust) { return(false); } var trustContext = new TrustContext(context, trust); if (command.Equals(ExtensionCatalog.CopyPurseNumber)) { return(true); } var formProvider = context.ExtensionManager.TryGetTrustFormProvider(command); return(formProvider?.CheckCompatibility(trustContext) ?? false); }; // Обработка событий. _screen.ServiceCommand += (sender, args) => { string command = args.Command; if (null == command) { throw new InvalidOperationException("null == command"); } switch (command) { case "BeginRefresh": context.ScreenContainer.OnStartProgress(); break; case "EndRefresh": context.ScreenContainer.OnStopProgress(); break; default: { var trust = args.Argument as ITrust; // Кнопки if (null == trust) { var formProvider = context.ExtensionManager.TryGetTopFormProvider(command); formProvider?.GetForm(context).Show(context.ScreenContainer); } else { if (command.Equals(TunableList.CellMouseDoubleClickCommandName)) { command = ExtensionCatalog.UpdateTrust; } var trustContext = new TrustContext(context, trust); // Системная if (command.Equals(ExtensionCatalog.CopyPurseNumber)) { var actionProvider = context.ExtensionManager.TryGetTrustActionProvider(command); actionProvider?.RunAction(trustContext); } else { var formProvider = context.ExtensionManager.TryGetTrustFormProvider(command); formProvider?.GetForm(trustContext).Show(context.ScreenContainer); } } } break; } }; _screen.DisplayContent(SelectTrusts(false)); return(_screen); }
public bool CheckCompatibility(ScreenContainerContext context) { return(true); }
public Control GetScreen(ScreenContainerContext context) { return(new UserControl1(context.Session)); }
public Control GetScreen(ScreenContainerContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } var origin = new FilterOrigin(context.ExtensionManager, ExtensionCatalog.IncomingInvoiceFilterScreen) { MenuItemsTagName = ExtensionCatalog.Tags.IncomingInvoiceExtension, CommandBarTagName = ExtensionCatalog.Tags.IncomingInvoiceFilterExtension, ColumnsSettings = context.Session.SettingsService.GetSettings().IncomingInvoiceSettings }; var template = FilterDisplayHelper.LoadFilterScreenTemplate(origin); // Отключаем кнопки. foreach (var buttonTemplate in template.CommandButtons) { var formProvider = context.ExtensionManager.TryGetTopFormProvider(buttonTemplate.Command); if (!(formProvider?.CheckCompatibility(context) ?? false)) { buttonTemplate.Enabled = false; } } var screen = new FilterScreen(); ErrorFormDisplayHelper.ApplyErrorAction(context.ExtensionManager, screen); var now = DateTime.Now; var incomeValuesWrapper = new IncomingInvoiceFilterFormValuesWrapper { Control1FromTime = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, DateTimeKind.Local), Control2ToTime = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59, DateTimeKind.Local) }; screen.ApplyTemplate(template); screen.ApplyShapeValues(incomeValuesWrapper.CollectIncomeValues()); // Меню screen.MenuItemResolver = (entity, command) => { var invoice = screen.CurrentEntity as IIncomingInvoice; if (null == invoice) { return(false); } var invoiceContext = new IncomingInvoiceContext(context, invoice); var formProvider = context.ExtensionManager.TryGetIncomingInvoiceFormProvider(command); return(formProvider?.CheckCompatibility(invoiceContext) ?? false); }; // Обработка событий. screen.ServiceCommand += (sender, args) => { string command = args.Command; if (null == command) { throw new InvalidOperationException("null == command"); } if (command.StartsWith("CellContentClick:", StringComparison.Ordinal)) { return; } if (FilterScreen.BeginUpdateServiceCommand.Equals(args.Command)) { context.ScreenContainer.OnStartProgress(); return; } if (FilterScreen.EndUpdateServiceCommand.Equals(args.Command)) { context.ScreenContainer.OnStopProgress(); return; } if (FilterScreen.DisplayContentServiceCommand.Equals(args.Command)) { return; } if (command.StartsWith("CellMouseDoubleClick:", StringComparison.Ordinal)) { command = ExtensionCatalog.Details; } var form = screen.FindForm(); var invoice = args.Argument as IIncomingInvoice; // Кнопки if (null == invoice) { var formProvider = context.ExtensionManager.TryGetTopFormProvider(command); formProvider?.GetForm(context).Show(form); } else { // Системная var formProvider = context.ExtensionManager.TryGetIncomingInvoiceFormProvider(command); formProvider?.GetForm(new IncomingInvoiceContext(context, invoice)) .Show(form); } }; // Команда Refresh screen.WorkCallback = list => { var valuesWrapper = new IncomingInvoiceFilterFormValuesWrapper(list); var invoiceService = context.UnityContainer.Resolve <IInvoiceService>(); var invoices = invoiceService.SelectIncomingInvoices(valuesWrapper.Control1FromTime.ToUniversalTime(), valuesWrapper.Control2ToTime.ToUniversalTime(), true); var gridRowContentList = new List <GridRowContent>(); var operationSettings = context.Session.SettingsService.GetSettings().OperationSettings; decimal paid = 0; decimal notPaid = 0; decimal refused = 0; foreach (var invoice in invoices) { var gridRowContent = new GridRowContent(invoice.PrimaryId.ToString(), invoice); switch (invoice.State) { case InvoiceState.Paid: Paid: gridRowContent.ForeColor = operationSettings.OutcomeForeColor; gridRowContent.SelectionForeColor = operationSettings.OutcomeForeColor; break; case InvoiceState.PaidWithProtection: gridRowContent.BackColor = operationSettings.ProtectedColor; gridRowContent.SelectionBackColor = ColorUtility.CalculateSelectionColor(operationSettings.ProtectedColor); goto Paid; case InvoiceState.Refusal: gridRowContent.Strikeout = true; break; } switch (invoice.State) { case InvoiceState.NotPaid: notPaid += invoice.Amount; break; case InvoiceState.PaidWithProtection: case InvoiceState.Paid: paid += invoice.Amount; break; case InvoiceState.Refusal: refused += invoice.Amount; break; default: throw new ArgumentOutOfRangeException(); } gridRowContentList.Add(gridRowContent); } var chartPoint1 = new ChartPoint( Translator.Instance.Translate(ExtensionCatalog.IncomingInvoiceFilterScreen, "Paid"), (double)paid); var chartPoint2 = new ChartPoint( Translator.Instance.Translate(ExtensionCatalog.IncomingInvoiceFilterScreen, "Not paid"), (double)notPaid); var chartPoint3 = new ChartPoint( Translator.Instance.Translate(ExtensionCatalog.IncomingInvoiceFilterScreen, "Refused"), (double)refused); var filterScreenContent = new FilterScreenContent(); filterScreenContent.RowContentList.AddRange(gridRowContentList); if (paid > 0) { filterScreenContent.ChartPoints.Add(chartPoint1); } if (notPaid > 0) { filterScreenContent.ChartPoints.Add(chartPoint2); } if (refused > 0) { filterScreenContent.ChartPoints.Add(chartPoint3); } return(filterScreenContent); }; return(screen); }