protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var displayAdapter = new DisplayAdapter(); displayAdapter.Run(); }
/// <summary> /// Returns the corresponding <see cref="DisplayDevice"/> instance /// </summary> /// <returns>An instance of <see cref="DisplayDevice"/>, or null</returns> public DisplayDevice ToDisplayDevice() { return (DisplayAdapter.GetDisplayAdapters() .SelectMany(adapter => adapter.GetDisplayDevices()) .FirstOrDefault(device => device.DevicePath.Equals(DevicePath))); }
/// <summary> /// Shows document subtotal to cashier. /// Two types: /// First: If customer autho. adjustment is active;show document subtotal wtih the discounted value. /// Second: If customer autho is not active; show only discounted value. /// </summary> /// <returns> ///Document state:DocumentOpen,DocumentSubtotal or DocumentPayment. ///</returns> public static DocumentState Instance() { if (cr.Document.IsEmpty) { return(state); } String strMessage = String.Format("{0}\n{1:C}", PosMessage.SUBTOTAL, new Number(cr.Document.BalanceDue)); if (cr.Document.Status == DocumentStatus.Active) { PromotionDocument doc = new PromotionDocument(cr.Document, null, PromotionType.Document); if (doc.HasAdjustment) { strMessage = DisplayAdapter.AmountPairFormat(PosMessage.SUBTOTAL, cr.Document.BalanceDue, PosMessage.DISCOUNTED, doc.BalanceDue); DisplayAdapter.Both.Show(strMessage); return(state); } } DisplayAdapter.Both.Show(strMessage); if (!(cr.Document.State is DocumentPaying || cr.Document.State is DocumentSubTotal)) { bool hardcopy = cr.DataConnector.CurrentSettings.GetProgramOption(Setting.PrintSubtTotal) == PosConfiguration.ON; cr.Printer.PrintSubTotal(cr.Document, hardcopy); } DisplayAdapter.Customer.Show("{0}\n{1:C}", PosMessage.SUBTOTAL, new Number(cr.Document.BalanceDue)); return(state); }
public void SetUp() { var restaurants = new List <Restaurant>() { new Restaurant { Name = "Milliways", CuisineTypes = new List <CuisineType>() { new CuisineType { Name = "Gourmet" }, new CuisineType { Name = "Dim Sum" }, new CuisineType { Name = "English Breakfast" } }, RatingAverage = "5" } }; _displaySpy = new Mock <IDisplay>(); var displayAdapter = new DisplayAdapter(_displaySpy.Object); displayAdapter.Display(restaurants); }
public frmMonitor(DisplayAdapter adapter) { InitializeComponent(); this.adapter = adapter; monitor.Adapter = adapter; }
/// <summary> /// Returns the corresponding DisplayDevice instances /// </summary> /// <returns>An enumerable list of DisplayDevices</returns> public IEnumerable <DisplayDevice> ToDisplayDevices() { return (DisplayAdapter.GetDisplayAdapters() .SelectMany(adapter => adapter.GetDisplayDevices()) .Where(device => device.DisplayName.Equals(DisplayName))); }
public static IState RepeatDocument(string barcode) { SalesDocument doc = cr.Document.GetDocumentByBarcode(barcode); System.Threading.Thread.Sleep(250); if (doc != null && doc.Items.Count > 0) { String label = DisplayAdapter.DocumentFormat(doc); Confirm e = new Confirm(label, new StateInstance <Hashtable>(RepeatConfirmed), new StateInstance(Continue)); e.Data["Document"] = doc; return(ConfirmCashier.Instance(e)); } else { return(AlertCashier.Instance(new Confirm(PosMessage.BARCODE_NOTFOUND, new StateInstance(Continue)))); } }
private static IDisplayAdapter BuildAdapter(ManagementBaseObject mo) { var adapter = new DisplayAdapter(); foreach (var property in mo.Properties) { if (property.Name == "Caption") { adapter.Name = (property.Value?.ToString()) ?? ""; } if (property.Name == "DriverVersion") { adapter.DriverVersion = (property.Value?.ToString()) ?? ""; } if (property.Name == "DisplayFrequency") { adapter.Frequency = (property.Value?.ToString()) ?? ""; } } return(adapter); }
static void Main(string[] args) { string outCode = "SE19"; if (0 < args.Length) { outCode = args[0]; } if (string.IsNullOrEmpty(outCode)) { outCode = "SE19"; } var jeApi = new JeApiClient(); var restaurants = jeApi.GetRestaurantsFor(outCode); var displayAdapter = new DisplayAdapter(new ConsoleDisplay()); displayAdapter.Display(restaurants.Restaurants); Console.WriteLine(); Console.WriteLine("PRESS ANY KEY TO EXIT"); Console.ReadLine(); }
private static IState CalculateTotal(PaymentInfo pInfo) { paymentInfo = pInfo; Decimal balanceDue = 0; if (!(cr.Document.CanEmpty)) { PaymentInfo currentPaymentInfo = paymentInfo.Clone(); if (currentPaymentInfo.Amount == 0) { currentPaymentInfo.Amount = cr.Document.BalanceDue; } promoDocument = new PromotionDocument(cr.Document, currentPaymentInfo, PromotionType.Document); if (promoDocument.HasAdjustment) { balanceDue = promoDocument.BalanceDue; } else { balanceDue = cr.Document.BalanceDue; } if (!(cr.State is PaymentAfterTotalAdjustment)) { cancelState = States.Start.Instance; } } else { balanceDue = cr.Document.BalanceDue; } // Ýf payment is point payment, dont gain point so clear it if (paymentInfo is CreditPaymentInfo && ((CreditPaymentInfo)paymentInfo).Credit.IsPointPayment) { if (promoDocument != null && promoDocument.Points != null && promoDocument.Points.Count > 0) { promoDocument.Points.Clear(); } // And if point payment amount bigger than balanceDue, fix it if (paymentInfo.Amount > balanceDue) { paymentInfo.Amount = balanceDue; } } if (paymentInfo.Amount == 0) { if (paymentInfo is CurrencyPaymentInfo) { decimal dec = Math.Round(balanceDue / ((CurrencyPaymentInfo)paymentInfo).ExchangeRate, 2); paymentInfo.Amount = Math.Round(dec * ((CurrencyPaymentInfo)paymentInfo).ExchangeRate, 2); //paymentInfo.Amount = Math.Truncate(100 * (dec * ((CurrencyPaymentInfo)paymentInfo).ExchangeRate)) / 100; } else { paymentInfo.Amount = balanceDue; } } //TODO This crap should be in HYDisplay DisplayAdapter.Customer.Show(PosMessage.SUBTOTAL, balanceDue); return(cr.State = States.ConfirmPayment.Instance(DisplayAdapter.AmountPairFormat(PosMessage.TOTAL, balanceDue, paymentInfo.ToString(), paymentInfo.Amount), new StateInstance <Decimal>(Pay), new StateInstance(cancelState))); }
private static void DeviceContext() { var navigation = new Dictionary <object, Action> { { "DeviceContext: Display Adapters", () => ConsoleNavigation.PrintObject(DisplayAdapter.GetDisplayAdapters().ToArray(), display => ConsoleNavigation.PrintObject(display.GetDisplayDevices(), "Display.GetDisplayDevices()"), "DisplayAdapter.GetDisplayAdapters()", "Select an adapter to show connected devices.") }, { "DeviceContext: Connected Displays", () => ConsoleNavigation.PrintObject(Display.GetDisplays().ToArray(), display => ConsoleNavigation.PrintObject(display.CurrentSetting, () => { ConsoleNavigation.PrintObject( display.GetPossibleSettings() .OrderByDescending( setting => (ulong)setting.Resolution.Height * (ulong)setting.Resolution.Width) .Take(10) .ToArray(), setting => { display.SetSettings(new DisplaySetting(setting), true); }, "Display.GetValidSettings()", "Select a display setting to apply and enable."); }, "Display.CurrentSetting", ""), "Display.GetDisplays()", "Select a display to show current settings.") }, { "DeviceContext: Disconnected Displays", () => ConsoleNavigation.PrintObject(UnAttachedDisplay.GetUnAttachedDisplays().ToArray(), display => { ConsoleNavigation.PrintObject( display.GetPossibleSettings() .OrderByDescending( setting => (ulong)setting.Resolution.Height * (ulong)setting.Resolution.Width) .Take(10) .ToArray(), setting => { display.Enable(new DisplaySetting(setting)); DisplaySetting.ApplySavedSettings(); }, "Display.GetValidSettings()", "Select a display setting to apply and enable."); }, "UnAttachedDisplay.GetUnAttachedDisplays()", "Select an unattached display to show possible display settings to activate.") }, { "DeviceContext: Disable All Except Primary", () => { var displays = Display.GetDisplays().ToArray(); foreach (var display in displays.Where(display => !display.IsGDIPrimary)) { display.Disable(false); } DisplaySetting.ApplySavedSettings(); } }, { "DeviceContext: Enable All", () => { var displays = UnAttachedDisplay.GetUnAttachedDisplays().ToArray(); foreach (var display in displays) { display.Enable(new DisplaySetting(display.GetPreferedSetting())); } DisplaySetting.ApplySavedSettings(); } } }; ConsoleNavigation.PrintNavigation(navigation, "DeviceContext functions", "Select a DeviceContext sample."); }
public MonitorControl() { adapter = null; Paint += MonitorControl_Paint; }
/// <summary> /// Gets the corresponding DisplayAdapter instance /// </summary> /// <returns>An instance of DisplayAdapter, or null</returns> public DisplayAdapter ToDisplayAdapter() { return (DisplayAdapter.GetDisplayAdapters() .FirstOrDefault(adapter => DevicePath.StartsWith("\\\\?\\" + adapter.DevicePath.Replace("\\", "#")))); }
private static void Main(string[] args) { _writer = new StreamWriter(new FileStream( string.Format("HeliosDisplayManagement.Reporting.{0}.log", Process.GetCurrentProcess().Id), FileMode.CreateNew)); try { Dump(DisplayAdapter.GetDisplayAdapters(), "WindowsDisplayAPI.DisplayAdapter.GetDisplayAdapters()"); } catch (Exception e) { WriteException(e); } try { Dump(Display.GetDisplays(), "WindowsDisplayAPI.Display.GetDisplays()", new[] { new Tuple <Func <Display, object>, string>(display => display.GetPossibleSettings(), "GetPossibleSettings()") }); } catch (Exception e) { WriteException(e); } try { Dump(UnAttachedDisplay.GetUnAttachedDisplays(), "WindowsDisplayAPI.UnAttachedDisplay.GetUnAttachedDisplays()"); } catch (Exception e) { WriteException(e); } try { Dump(PathDisplayAdapter.GetAdapters(), "WindowsDisplayAPI.DisplayConfig.PathDisplayAdapter.GetAdapters()", new[] { new Tuple <Func <PathDisplayAdapter, object>, string>(adapter => adapter.ToDisplayAdapter(), "ToDisplayAdapter()") }); } catch (Exception e) { WriteException(e); } try { Dump(PathDisplaySource.GetDisplaySources(), "WindowsDisplayAPI.DisplayConfig.PathDisplaySource.GetDisplaySources()", new[] { new Tuple <Func <PathDisplaySource, object>, string>(source => source.ToDisplayDevices(), "ToDisplayDevices()") }); } catch (Exception e) { WriteException(e); } try { Dump(PathDisplayTarget.GetDisplayTargets(), "WindowsDisplayAPI.DisplayConfig.PathDisplayTarget.GetDisplayTargets()", new[] { new Tuple <Func <PathDisplayTarget, object>, string>(target => target.ToDisplayDevice(), "ToDisplayDevice()") }); } catch (Exception e) { WriteException(e); } try { if (PathInfo.IsSupported) { Dump(PathInfo.GetActivePaths(), "WindowsDisplayAPI.DisplayConfig.PathInfo.GetActivePaths()", null, 2); } } catch (Exception e) { WriteException(e); } try { Dump(LogicalGPU.GetLogicalGPUs(), "NvAPIWrapper.GPU.LogicalGPU.GetLogicalGPUs()", null, 1); } catch (Exception e) { WriteException(e); } try { Dump(PhysicalGPU.GetPhysicalGPUs(), "NvAPIWrapper.GPU.PhysicalGPU.GetPhysicalGPUs()"); } catch (Exception e) { WriteException(e); } try { Dump(NvAPIWrapper.Display.Display.GetDisplays(), "NvAPIWrapper.Display.Display.GetDisplays()", new[] { new Tuple <Func <NvAPIWrapper.Display.Display, object>, string>( display => display.GetSupportedViews(), "GetSupportedViews()") }); } catch (Exception e) { WriteException(e); } try { Dump(NvAPIWrapper.Display.UnAttachedDisplay.GetUnAttachedDisplays(), "NvAPIWrapper.Display.UnAttachedDisplay.GetUnAttachedDisplays()"); } catch (Exception e) { WriteException(e); } try { Dump(NvAPIWrapper.Display.PathInfo.GetDisplaysConfig(), "NvAPIWrapper.Display.PathInfo.GetDisplaysConfig()", null, 3); } catch (Exception e) { WriteException(e); } try { Dump(GridTopology.GetGridTopologies(), "NvAPIWrapper.Mosaic.GridTopology.GetGridTopologies()", null, 3); } catch (Exception e) { WriteException(e); } try { Dump(Profile.GetAllProfiles(), "HeliosDisplayManagement.Shared.Profile.GetAllProfiles()", null, 99); } catch (Exception e) { WriteException(e); } _writer.Flush(); _writer.Close(); _writer.Dispose(); Console.WriteLine(@"Done, press enter to exit."); Console.ReadLine(); }