Example #1
0
        private static IDestination ShowVirtualDmd(BaseOptions options)
        {
            if (options.VirtualDmdPosition.Length != 3 && options.VirtualDmdPosition.Length != 4)
            {
                throw new InvalidOptionException("Argument --virtual-position must have three or four values: \"<Left> <Top> <Width> [<Height>]\".");
            }
            if (options.VirtualDmdDotSize <= 0 || options.VirtualDmdDotSize > 2)
            {
                throw new InvalidOptionException("Argument --virtual-dotsize must be larger than 0 and smaller than 10.");
            }
            int height; bool ignoreAr;

            if (options.VirtualDmdPosition.Length == 4)
            {
                height   = options.VirtualDmdPosition[3];
                ignoreAr = true;
            }
            else
            {
                height   = (int)((double)options.VirtualDmdPosition[2] / 4);
                ignoreAr = false;
            }
            var dmd = new VirtualDmd {
                AlwaysOnTop       = options.VirtualDmdOnTop,
                GripColor         = options.VirtualDmdHideGrip ? Brushes.Transparent : Brushes.White,
                Left              = options.VirtualDmdPosition[0],
                Top               = options.VirtualDmdPosition[1],
                Width             = options.VirtualDmdPosition[2],
                Height            = height,
                IgnoreAspectRatio = ignoreAr,
                DotSize           = options.VirtualDmdDotSize
            };
            var thread = new Thread(() => {
                // Create our context, and install it:
                SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(CurrentDispatcher));

                // create the window
                dmd.Dispatcher.Invoke(() => {
                    dmd.Dmd.Init();
                    dmd.Show();
                });

                // Start the Dispatcher Processing
                Run();
            });

            // On closing the window, shut down the dispatcher associated with the thread.
            // This will allow the thread to exit after the window is closed and all of
            // the events resulting from the window close have been processed.
            dmd.Closed += (s, e) => Dispatcher.FromThread(thread).BeginInvokeShutdown(DispatcherPriority.Background);

            // run the thread
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            return(dmd.Dmd);
        }
Example #2
0
        private static IDestination ShowVirtualDmd(BaseOptions options)
        {
            if (options.VirtualDmdPosition.Length != 3 && options.VirtualDmdPosition.Length != 4)
            {
                throw new InvalidOptionException("Argument --virtual-position must have three or four values: \"<Left> <Top> <Width> [<Height>]\".");
            }
            int height; bool ignoreAr;

            if (options.VirtualDmdPosition.Length == 4)
            {
                height   = options.VirtualDmdPosition[3];
                ignoreAr = true;
            }
            else
            {
                height   = (int)((double)options.VirtualDmdPosition[2] / 4);
                ignoreAr = false;
            }
            var dmd = new VirtualDmd {
                AlwaysOnTop       = options.VirtualDmdOnTop,
                GripColor         = options.VirtualDmdHideGrip ? Brushes.Transparent : Brushes.White,
                Left              = options.VirtualDmdPosition[0],
                Top               = options.VirtualDmdPosition[1],
                Width             = options.VirtualDmdPosition[2],
                Height            = height,
                IgnoreAspectRatio = ignoreAr
            };
            var thread = new Thread(() => {
                // Create our context, and install it:
                SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(CurrentDispatcher));

                // When the window closes, shut down the dispatcher
                dmd.Closed += (s, e) => CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);
                dmd.Dispatcher.Invoke(() => {
                    dmd.Dmd.Init();
                    dmd.Show();
                });

                // Start the Dispatcher Processing
                Run();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            return(dmd.Dmd);
        }
Example #3
0
        protected List <IDestination> GetAvailableRenderers(BaseOptions options)
        {
            var renderers = new List <IDestination>();

            try {
                var pinDmd1 = PinDmd1.GetInstance();
                var pinDmd2 = PinDmd2.GetInstance();
                var pinDmd3 = PinDmd3.GetInstance(options.Port);
                var pin2Dmd = Pin2Dmd.GetInstance();

                if (pinDmd1.IsAvailable)
                {
                    renderers.Add(pinDmd1);
                    Logger.Info("Added PinDMDv1 renderer.");
                }
                if (pinDmd2.IsAvailable)
                {
                    renderers.Add(pinDmd2);
                    Logger.Info("Added PinDMDv2 renderer.");
                }
                if (pinDmd3.IsAvailable)
                {
                    renderers.Add(pinDmd3);
                    Logger.Info("Added PinDMDv3 renderer.");
                }
                if (pin2Dmd.IsAvailable)
                {
                    renderers.Add(pin2Dmd);
                    Logger.Info("Added PIN2DMD renderer.");
                }
                if (!options.NoVirtualDmd)
                {
                    renderers.Add(ShowVirtualDmd(options));
                    Logger.Info("Added VirtualDMD renderer.");
                }
                else
                {
                    Logger.Debug("VirtualDMD disabled.");
                }
            } catch (DllNotFoundException e) {
                Logger.Error(e, "Error loading DLL.");
                return(renderers);
            }
            return(renderers);
        }
Example #4
0
 public PinUpOptions(BaseOptions options)
 {
     _options = options;
 }
Example #5
0
 public NetworkOptions(BaseOptions options)
 {
     _options = options;
 }
Example #6
0
 public BitmapOptions(BaseOptions options)
 {
     _options = options;
 }
Example #7
0
 public PixelcadeOptions(BaseOptions options)
 {
     _options = options;
 }
Example #8
0
 public Pin2DmdOptions(BaseOptions options)
 {
     _options = options;
 }
Example #9
0
 public PinDmd3Options(BaseOptions options)
 {
     _options = options;
 }
Example #10
0
 public VirtualAlphaNumericDisplayOptions(BaseOptions options)
 {
     _options = options;
 }
Example #11
0
 public VirtualDmdOptions(BaseOptions options)
 {
     _options = options;
 }
Example #12
0
 public GlobalConfig(BaseOptions options)
 {
     _options = options;
 }
Example #13
0
        protected List <IDestination> GetRenderers(BaseOptions options)
        {
            var renderers = new List <IDestination>();

            switch (options.Destination)
            {
            case Auto:
                renderers = GetAvailableRenderers(options);
                break;

            case PinDMDv1:
                var pinDmd1 = PinDmd1.GetInstance();
                if (pinDmd1.IsAvailable)
                {
                    renderers.Add(pinDmd1);
                    Logger.Info("Added PinDMDv1 renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PinDMDv1.ToString());
                }
                break;

            case PinDMDv2:
                var pinDmd2 = PinDmd2.GetInstance();
                if (pinDmd2.IsAvailable)
                {
                    renderers.Add(pinDmd2);
                    Logger.Info("Added PinDMDv2 renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PinDMDv2.ToString());
                }
                break;

            case PinDMDv3:
                var pinDmd3 = PinDmd3.GetInstance(options.Port);
                if (pinDmd3.IsAvailable)
                {
                    renderers.Add(pinDmd3);
                    Logger.Info("Added PinDMDv3 renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PinDMDv3.ToString());
                }
                break;

            case PIN2DMD:
                var pin2Dmd = Pin2Dmd.GetInstance();
                if (pin2Dmd.IsAvailable)
                {
                    renderers.Add(pin2Dmd);
                    Logger.Info("Added PIN2DMD renderer.");
                }
                else
                {
                    throw new DeviceNotAvailableException(PIN2DMD.ToString());
                }
                break;

            case Virtual:
                renderers.Add(ShowVirtualDmd(options));
                Logger.Info("Added VirtualDMD renderer.");

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (renderers.Count == 0)
            {
                throw new NoRenderersAvailableException();
            }

            if (!ColorUtil.IsColor(options.RenderColor))
            {
                throw new InvalidOptionException("Argument --color must be a valid RGB color. Example: \"ff0000\".");
            }
            foreach (var renderer in renderers)
            {
                var rgb24 = renderer as IRgb24Destination;
                rgb24?.SetColor(ColorUtil.ParseColor(options.RenderColor));
            }
            _options = options;
            return(renderers);
        }
Example #14
0
 public ZeDMDOptions(BaseOptions options)
 {
     _options = options;
 }