Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// Kreiärt ä Render-Graph fir jedä Input-Tip und bindet si as
        /// virtueuä DMD.
        /// </summary>
        private void SetupGraphs()
        {
            var renderers = new List <IDestination>();

            if (_config.PinDmd1.Enabled)
            {
                var pinDmd1 = PinDmd1.GetInstance();
                if (pinDmd1.IsAvailable)
                {
                    renderers.Add(pinDmd1);
                    Logger.Info("Added PinDMDv1 renderer.");
                }
            }
            if (_config.PinDmd2.Enabled)
            {
                var pinDmd2 = PinDmd2.GetInstance();
                if (pinDmd2.IsAvailable)
                {
                    renderers.Add(pinDmd2);
                    Logger.Info("Added PinDMDv2 renderer.");
                }
            }
            if (_config.PinDmd3.Enabled)
            {
                var pinDmd3 = PinDmd3.GetInstance(_config.PinDmd3.Port);
                if (pinDmd3.IsAvailable)
                {
                    renderers.Add(pinDmd3);
                    Logger.Info("Added PinDMDv3 renderer.");
                }
            }
            if (_config.Pin2Dmd.Enabled)
            {
                var pin2Dmd = Pin2Dmd.GetInstance();
                if (pin2Dmd.IsAvailable)
                {
                    renderers.Add(pin2Dmd);
                    Logger.Info("Added PIN2DMD renderer.");
                }
            }
            if (_config.VirtualDmd.Enabled)
            {
                renderers.Add(_dmd.Dmd);
                Logger.Info("Added VirtualDMD renderer.");
            }
            if (_config.Video.Enabled)
            {
                var rootPath = "";
                if (_config.Video.Path.Length == 0 || !Path.IsPathRooted(_config.Video.Path))
                {
                    rootPath = AssemblyPath;
                }
                if (Directory.Exists(Path.Combine(rootPath, _config.Video.Path)))
                {
                    renderers.Add(new VideoOutput(Path.Combine(rootPath, _config.Video.Path, _gameName + ".avi")));
                    Logger.Info("Added video renderer.");
                }
                else if (Directory.Exists(Path.GetDirectoryName(Path.Combine(rootPath, _config.Video.Path))) && _config.Video.Path.Length > 4 && _config.Video.Path.EndsWith(".avi"))
                {
                    renderers.Add(new VideoOutput(Path.Combine(rootPath, _config.Video.Path)));
                    Logger.Info("Added video renderer.");
                }
                else
                {
                    Logger.Warn("Ignoring video renderer for non-existing path \"{0}\"", _config.Video.Path);
                }
            }
            if (_config.VpdbStream.Enabled)
            {
                renderers.Add(new VpdbStream {
                    EndPoint = _config.VpdbStream.EndPoint
                });
            }
            if (_config.BrowserStream.Enabled)
            {
                renderers.Add(new BrowserStream(_config.BrowserStream.Port));
            }

            if (renderers.Count == 0)
            {
                Logger.Error("No renderers found, exiting.");
                return;
            }

            Logger.Info("Transformation options: Resize={0}, HFlip={1}, VFlip={2}", _config.Global.Resize, _config.Global.FlipHorizontally, _config.Global.FlipVertically);

            // 2-bit graph
            if (_colorize && _gray2Colorizer != null)
            {
                _graphs.Add(new RenderGraph {
                    Name             = "2-bit Colored VPM Graph",
                    Source           = _vpmGray2Source,
                    Destinations     = renderers,
                    Converter        = _gray2Colorizer,
                    Resize           = _config.Global.Resize,
                    FlipHorizontally = _config.Global.FlipHorizontally,
                    FlipVertically   = _config.Global.FlipVertically
                });
            }
            else
            {
                _graphs.Add(new RenderGraph {
                    Name             = "2-bit VPM Graph",
                    Source           = _vpmGray2Source,
                    Destinations     = renderers,
                    Resize           = _config.Global.Resize,
                    FlipHorizontally = _config.Global.FlipHorizontally,
                    FlipVertically   = _config.Global.FlipVertically
                });
            }

            // 4-bit graph
            if (_colorize && _gray4Colorizer != null)
            {
                _graphs.Add(new RenderGraph {
                    Name             = "4-bit Colored VPM Graph",
                    Source           = _vpmGray4Source,
                    Destinations     = renderers,
                    Converter        = _gray4Colorizer,
                    Resize           = _config.Global.Resize,
                    FlipHorizontally = _config.Global.FlipHorizontally,
                    FlipVertically   = _config.Global.FlipVertically
                });
            }
            else
            {
                _graphs.Add(new RenderGraph {
                    Name             = "4-bit VPM Graph",
                    Source           = _vpmGray4Source,
                    Destinations     = renderers,
                    Resize           = _config.Global.Resize,
                    FlipHorizontally = _config.Global.FlipHorizontally,
                    FlipVertically   = _config.Global.FlipVertically
                });
            }

            // rgb24 graph
            _graphs.Add(new RenderGraph {
                Name             = "RGB24-bit VPM Graph",
                Source           = _vpmRgb24Source,
                Destinations     = renderers,
                Resize           = _config.Global.Resize,
                FlipHorizontally = _config.Global.FlipHorizontally,
                FlipVertically   = _config.Global.FlipVertically
            });

            if (_colorize && (_gray2Colorizer != null || _gray4Colorizer != null))
            {
                Logger.Info("Just clearing palette, colorization is done by converter.");
                _graphs.ClearColor();
            }
            else if (_colorize && _palette != null)
            {
                Logger.Info("Applying palette to render graphs.");
                _graphs.ClearColor();
                _graphs.SetPalette(_palette);
            }
            else
            {
                Logger.Info("Applying default color to render graphs ({0}).", _color);
                _graphs.ClearPalette();
                _graphs.SetColor(_color);
            }

            _graphs.Init().StartRendering();
        }
        public MainWindow()
        {
            InitializeComponent();
            Closing += OnWindowClosing;

            var title   = (AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false).FirstOrDefault();
            var version = (AssemblyInformationalVersionAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false).FirstOrDefault();

            Title = $"{title?.Title} v{version?.InformationalVersion}";


            // define renderers
            var renderers = new List <IDestination> {
                VirtualDmd
            };

            Console.AppendText("Added VirtualDMD renderer.\n");

            try {
                var pinDmd = PinDmd3.GetInstance();
                if (pinDmd.IsAvailable)
                {
                    renderers.Add(pinDmd);
                    Console.AppendText($"Added PinDMDv3 renderer.\n");
                    Console.AppendText($"PinDMDv3 detected at {pinDmd.DmdWidth}x{pinDmd.DmdHeight}\n");
                    Console.AppendText($"Firmware: {pinDmd.Firmware}\n");
                }
                else
                {
                    Console.AppendText("PinDMDv3 not connected.\n");
                }
                var pin2Dmd = Pin2Dmd.GetInstance();
                if (pin2Dmd.IsAvailable)
                {
                    renderers.Add(pin2Dmd);
                    Console.AppendText($"Added PIN2DMD renderer.\n");
                }
                else
                {
                    Console.AppendText("PIN2DMD not connected.\n");
                }
                var pinDmd2 = PinDmd2.GetInstance();
                if (pinDmd2.IsAvailable)
                {
                    renderers.Add(pinDmd2);
                    Console.AppendText($"Added PinDMDv2 renderer.\n");
                }
                else
                {
                    Console.AppendText("PinDMDv2 not connected.\n");
                }
                var pinDmd1 = PinDmd1.GetInstance();
                if (pinDmd1.IsAvailable)
                {
                    renderers.Add(pinDmd1);
                    Console.AppendText($"Added PinDMDv1 renderer.\n");
                }
                else
                {
                    Console.AppendText("PinDMDv1 not connected.\n");
                }
            } catch (DllNotFoundException e) {
                Console.AppendText("A DLL was not found. It's possible that Windows blocked it.\n");
                Console.AppendText("Go look for it in the installation folder. If it's there, right-click, \"Properties\" and \"unblock\".\n");
                Console.AppendText("Then restart the app.\n");
                Console.AppendText("Message: " + e.Message + "\n");
            }

            // define sources
            var grabber = new ScreenGrabber {
                FramesPerSecond = 15
            };

            _pbfxGrabber = new PBFX2Grabber {
                FramesPerSecond = 25
            };
            _tpaGrabber = new TPAGrabber {
                FramesPerSecond = 15
            };

            // define processors
            _pbfxGridProcessor = new GridProcessor {
                Enabled = true, Spacing = 1
            };
            _tpaGridProcessor = new GridProcessor {
                Enabled = true, Spacing = 0, CropRight = 0, CropBottom = 1
            };

            // chain them up
            _screenGraph = new RenderGraph {
                Source       = grabber,
                Destinations = renderers,
                //Processors = new List<AbstractProcessor> { transformationProcessor, monochromeProcessor }
            };
            _pbfxGraph = new RenderGraph {
                Source       = _pbfxGrabber,
                Destinations = renderers,
                //Processors = new List<AbstractProcessor> { _pbfxGridProcessor, transformationProcessor, _pbfxShadeProcessor }
            };
            _tpaGraph = new RenderGraph {
                Source       = _tpaGrabber,
                Destinations = renderers,
                //Processors = new List<AbstractProcessor> { transformationProcessor, _tpaShadeProcessor }
            };

            // init grabber window and link it to grabber
            _grabberWindow = new GrabberWindow()
            {
                Left   = Properties.Settings.Default.GrabLeft,
                Top    = Properties.Settings.Default.GrabTop,
                Width  = Properties.Settings.Default.GrabWidth,
                Height = Properties.Settings.Default.GrabHeight,
            };
            _grabberWindow.WhenPositionChanges.Subscribe(rect => {
                grabber.Move(rect);
                Properties.Settings.Default.GrabLeft   = rect.X;
                Properties.Settings.Default.GrabTop    = rect.Y;
                Properties.Settings.Default.GrabWidth  = rect.Width;
                Properties.Settings.Default.GrabHeight = rect.Height;
                Properties.Settings.Default.Save();
            });

            PreviewKeyDown += _grabberWindow.HotKey;
            PreviewKeyUp   += _grabberWindow.HotKey;
            PreviewKeyDown += HotKey;

            // grid preview images
            _pbfxGridProcessor.WhenProcessed.Subscribe(bmp => {
                ProcessedGrid.Dispatcher.Invoke(() => {
                    ProcessedGrid.Source = bmp;
                });
            });
        }
Esempio n. 5
0
        protected List <IDestination> GetRenderers(IConfiguration config)
        {
            var renderers = new List <IDestination>();

            if (config.PinDmd1.Enabled)
            {
                var pinDmd1 = PinDmd1.GetInstance();
                if (pinDmd1.IsAvailable)
                {
                    renderers.Add(pinDmd1);
                    Logger.Info("Added PinDMDv1 renderer.");
                }
                else
                {
                    Logger.Warn("Device {0} is not available.", PinDMDv1);
                }
            }

            if (config.PinDmd2.Enabled)
            {
                var pinDmd2 = PinDmd2.GetInstance();
                if (pinDmd2.IsAvailable)
                {
                    renderers.Add(pinDmd2);
                    Logger.Info("Added PinDMDv2 renderer.");
                }
                else
                {
                    Logger.Warn("Device {0} is not available.", PinDMDv2);
                }
            }

            if (config.PinDmd3.Enabled)
            {
                var pinDmd3 = PinDmd3.GetInstance(config.PinDmd3.Port);
                if (pinDmd3.IsAvailable)
                {
                    renderers.Add(pinDmd3);
                    Logger.Info("Added PinDMDv3 renderer.");
                }
                else
                {
                    Logger.Warn("Device {0} is not available.", PinDMDv3);
                }
            }

            if (config.Pin2Dmd.Enabled)
            {
                var pin2Dmd = Pin2Dmd.GetInstance(config.Pin2Dmd.Delay);
                if (pin2Dmd.IsAvailable)
                {
                    renderers.Add(pin2Dmd);
                    Logger.Info("Added PIN2DMD renderer.");
                }
                else
                {
                    Logger.Warn("Device {0} is not available.", PIN2DMD);
                }
            }

            if (config.Pixelcade.Enabled)
            {
                var pixelcade = Pixelcade.GetInstance(config.Pixelcade.Port, config.Pixelcade.ColorMatrix);
                if (pixelcade.IsAvailable)
                {
                    renderers.Add(pixelcade);
                    Logger.Info("Added Pixelcade renderer.");
                }
                else
                {
                    Logger.Warn("Device Pixelcade is not available.");
                }
            }

            if (config.VirtualDmd.Enabled)
            {
                renderers.Add(ShowVirtualDmd(config.VirtualDmd));
                Logger.Info("Added virtual DMD renderer.");
            }

            if (config.VirtualAlphaNumericDisplay.Enabled)
            {
                renderers.Add(VirtualAlphanumericDestination.GetInstance(CurrentDispatcher, config.VirtualAlphaNumericDisplay.Style, config as Configuration));
                Logger.Info("Added virtual Alphanumeric renderer.");
            }

            if (config.NetworkStream.Enabled)
            {
                try {
                    renderers.Add(NetworkStream.GetInstance(config.NetworkStream));
                    Logger.Info("Added websocket client renderer.");
                } catch (Exception e) {
                    Logger.Warn("Network stream disabled: {0}", e.Message);
                }
            }

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

            foreach (var renderer in renderers)
            {
                var rgb24 = renderer as IRgb24Destination;
                rgb24?.SetColor(config.Global.DmdColor);
            }
            _config = config;
            return(renderers);
        }
Esempio n. 6
0
        /// <summary>
        /// Kreiärt ä Render-Graph fir jedä Input-Tip und bindet si as
        /// virtueuä DMD.
        /// </summary>
        private void SetupGraphs()
        {
            _graphs.Dispose();

            ReportingTags.Clear();
            ReportingTags.Add(Process.GetCurrentProcess().ProcessName);
#if PLATFORM_X86
            ReportingTags.Add("x86");
#elif PLATFORM_X64
            ReportingTags.Add("x64");
#endif
            ReportingTags.Add("In:DmdDevice");
            ReportingTags.Add("Game:" + _gameName);


            var renderers = new List <IDestination>();
            if (_config.PinDmd1.Enabled)
            {
                var pinDmd1 = PinDmd1.GetInstance();
                if (pinDmd1.IsAvailable)
                {
                    renderers.Add(pinDmd1);
                    Logger.Info("Added PinDMDv1 renderer.");
                    ReportingTags.Add("Out:PinDMDv1");
                }
            }
            if (_config.PinDmd2.Enabled)
            {
                var pinDmd2 = PinDmd2.GetInstance();
                if (pinDmd2.IsAvailable)
                {
                    renderers.Add(pinDmd2);
                    Logger.Info("Added PinDMDv2 renderer.");
                    ReportingTags.Add("Out:PinDMDv2");
                }
            }
            if (_config.PinDmd3.Enabled)
            {
                var pinDmd3 = PinDmd3.GetInstance(_config.PinDmd3.Port);
                if (pinDmd3.IsAvailable)
                {
                    renderers.Add(pinDmd3);
                    Logger.Info("Added PinDMDv3 renderer.");
                    ReportingTags.Add("Out:PinDMDv3");
                }
            }
            if (_config.ZeDMD.Enabled)
            {
                var zeDmd = ZeDMD.GetInstance();
                if (zeDmd.IsAvailable)
                {
                    renderers.Add(zeDmd);
                    Logger.Info("Added ZeDMD renderer.");
                    ReportingTags.Add("Out:ZeDMD");
                }
            }
            if (_config.Pin2Dmd.Enabled)
            {
                var pin2Dmd = Pin2Dmd.GetInstance(_config.Pin2Dmd.Delay);
                if (pin2Dmd.IsAvailable)
                {
                    renderers.Add(pin2Dmd);
                    Logger.Info("Added PIN2DMD renderer.");
                    ReportingTags.Add("Out:PIN2DMD");
                }

                var pin2DmdXl = Pin2DmdXl.GetInstance(_config.Pin2Dmd.Delay);
                if (pin2DmdXl.IsAvailable)
                {
                    renderers.Add(pin2DmdXl);
                    Logger.Info("Added PIN2DMD XL renderer.");
                    ReportingTags.Add("Out:PIN2DMDXL");
                }

                var pin2DmdHd = Pin2DmdHd.GetInstance(_config.Pin2Dmd.Delay);
                if (pin2DmdHd.IsAvailable)
                {
                    renderers.Add(pin2DmdHd);
                    Logger.Info("Added PIN2DMD HD renderer.");
                    ReportingTags.Add("Out:PIN2DMDHD");
                }
            }
            if (_config.Pixelcade.Enabled)
            {
                var pixelcade = Pixelcade.GetInstance(_config.Pixelcade.Port, _config.Pixelcade.ColorMatrix);
                if (pixelcade.IsAvailable)
                {
                    renderers.Add(pixelcade);
                    Logger.Info("Added Pixelcade renderer.");
                    ReportingTags.Add("Out:Pixelcade");
                }
            }
            if (_config.VirtualDmd.Enabled)
            {
                renderers.Add(_virtualDmd.Dmd);
                Logger.Info("Added VirtualDMD renderer.");
                ReportingTags.Add("Out:VirtualDMD");
            }
            if (_config.VirtualAlphaNumericDisplay.Enabled)
            {
                _alphaNumericDest = VirtualAlphanumericDestination.GetInstance(Dispatcher.CurrentDispatcher, _config.VirtualAlphaNumericDisplay.Style, _config);
                renderers.Add(_alphaNumericDest);
                Logger.Info("Added virtual alphanumeric renderer.");
                ReportingTags.Add("Out:VirtualAlphaNum");
            }
            if (_config.Video.Enabled)
            {
                var rootPath = "";
                if (_config.Video.Path.Length == 0 || !Path.IsPathRooted(_config.Video.Path))
                {
                    rootPath = AssemblyPath;
                }
                if (Directory.Exists(Path.Combine(rootPath, _config.Video.Path)))
                {
                    renderers.Add(new VideoOutput(Path.Combine(rootPath, _config.Video.Path, _gameName + ".avi"), _config.Global.ScaleToHd));
                    Logger.Info("Added video renderer.");
                    ReportingTags.Add("Out:Video");
                }
                else if (Directory.Exists(Path.GetDirectoryName(Path.Combine(rootPath, _config.Video.Path))) && _config.Video.Path.Length > 4 && _config.Video.Path.EndsWith(".avi"))
                {
                    renderers.Add(new VideoOutput(Path.Combine(rootPath, _config.Video.Path), _config.Global.ScaleToHd));
                    Logger.Info("Added video renderer.");
                    ReportingTags.Add("Out:Video");
                }
                else
                {
                    Logger.Warn("Ignoring video renderer for non-existing path \"{0}\"", _config.Video.Path);
                }
            }
            if (_config.PinUp.Enabled)
            {
                try {
                    var pinupOutput = new PinUpOutput(_gameName);
                    if (pinupOutput.IsAvailable)
                    {
                        renderers.Add(pinupOutput);
                        Logger.Info("Added PinUP renderer.");
                        ReportingTags.Add("Out:PinUP");
                    }
                } catch (Exception e) {
                    Logger.Warn("Error opening PinUP output: {0}", e.Message);
                }
            }
            if (_config.Gif.Enabled)
            {
                var rootPath = "";
                var dirPath  = Path.GetDirectoryName(_config.Gif.Path);
                if (string.IsNullOrEmpty(dirPath) || !Path.IsPathRooted(_config.Video.Path))
                {
                    rootPath = AssemblyPath;
                }
                var path = Path.Combine(rootPath, _config.Gif.Path);
                if (Directory.Exists(Path.GetDirectoryName(path)))
                {
                    renderers.Add(new GifOutput(path));
                    Logger.Info("Added animated GIF renderer, saving to {0}", path);
                    ReportingTags.Add("Out:GIF");
                }
                else
                {
                    Logger.Warn("Ignoring animated GIF renderer for non-existing path \"{0}\"", Path.GetDirectoryName(path));
                }
            }
            if (_config.VpdbStream.Enabled)
            {
                renderers.Add(new VpdbStream {
                    EndPoint = _config.VpdbStream.EndPoint
                });
                Logger.Info("Added VPDB stream renderer.");
                ReportingTags.Add("Out:VpdbStream");
            }
            if (_config.BrowserStream.Enabled)
            {
                renderers.Add(new BrowserStream(_config.BrowserStream.Port, _gameName));
                Logger.Info("Added browser stream renderer.");
                ReportingTags.Add("Out:BrowserStream");
            }
            if (_config.NetworkStream.Enabled)
            {
                renderers.Add(NetworkStream.GetInstance(_config.NetworkStream, _gameName));
                Logger.Info("Added network stream renderer.");
                ReportingTags.Add("Out:NetworkStream");
            }

            if (renderers.Count == 0)
            {
                Logger.Error("No renderers found, exiting.");
                return;
            }

            Logger.Info("Transformation options: Resize={0}, HFlip={1}, VFlip={2}", _config.Global.Resize, _config.Global.FlipHorizontally, _config.Global.FlipVertically);

            // 2-bit graph
            if (_colorize && _gray2Colorizer != null)
            {
                _graphs.Add(new RenderGraph {
                    Name             = "2-bit Colored VPM Graph",
                    Source           = _vpmGray2Source,
                    Destinations     = renderers,
                    Converter        = _gray2Colorizer,
                    Resize           = _config.Global.Resize,
                    FlipHorizontally = _config.Global.FlipHorizontally,
                    FlipVertically   = _config.Global.FlipVertically,
                    ScalerMode       = _config.Global.ScalerMode
                });
                ReportingTags.Add("Color:Gray2");
            }
            else
            {
                _graphs.Add(new RenderGraph {
                    Name             = "2-bit VPM Graph",
                    Source           = _vpmGray2Source,
                    Destinations     = renderers,
                    Resize           = _config.Global.Resize,
                    FlipHorizontally = _config.Global.FlipHorizontally,
                    FlipVertically   = _config.Global.FlipVertically,
                    ScalerMode       = _config.Global.ScalerMode
                });
            }

            // 4-bit graph
            if (_colorize && _gray4Colorizer != null)
            {
                _graphs.Add(new RenderGraph {
                    Name             = "4-bit Colored VPM Graph",
                    Source           = _vpmGray4Source,
                    Destinations     = renderers,
                    Converter        = _gray4Colorizer,
                    Resize           = _config.Global.Resize,
                    FlipHorizontally = _config.Global.FlipHorizontally,
                    FlipVertically   = _config.Global.FlipVertically,
                    ScalerMode       = _config.Global.ScalerMode
                });
                ReportingTags.Add("Color:Gray4");
            }
            else
            {
                _graphs.Add(new RenderGraph {
                    Name             = "4-bit VPM Graph",
                    Source           = _vpmGray4Source,
                    Destinations     = renderers,
                    Resize           = _config.Global.Resize,
                    FlipHorizontally = _config.Global.FlipHorizontally,
                    FlipVertically   = _config.Global.FlipVertically,
                    ScalerMode       = _config.Global.ScalerMode
                });
            }

            // rgb24 graph
            _graphs.Add(new RenderGraph {
                Name             = "RGB24-bit VPM Graph",
                Source           = _vpmRgb24Source,
                Destinations     = renderers,
                Resize           = _config.Global.Resize,
                FlipHorizontally = _config.Global.FlipHorizontally,
                FlipVertically   = _config.Global.FlipVertically,
                ScalerMode       = _config.Global.ScalerMode
            });

            // alphanumeric graph
            _graphs.Add(new RenderGraph {
                Name             = "Alphanumeric VPM Graph",
                Source           = _vpmAlphaNumericSource,
                Destinations     = renderers,
                Resize           = _config.Global.Resize,
                FlipHorizontally = _config.Global.FlipHorizontally,
                FlipVertically   = _config.Global.FlipVertically,
                ScalerMode       = _config.Global.ScalerMode
            });

            if (_colorize && (_gray2Colorizer != null || _gray4Colorizer != null))
            {
                Logger.Info("Just clearing palette, colorization is done by converter.");
                _graphs.ClearColor();
            }
            else if (_colorize && _palette != null)
            {
                Logger.Info("Applying palette to render graphs.");
                _graphs.ClearColor();
                if (_coloring != null)
                {
                    _graphs.SetPalette(_palette, _coloring.DefaultPaletteIndex);
                }
                else
                {
                    _graphs.SetPalette(_palette, -1);
                }
            }
            else
            {
                Logger.Info("Applying default color to render graphs ({0}).", _color);
                _graphs.ClearPalette();
                _graphs.SetColor(_color);
            }

            _graphs.Init().StartRendering();
        }
Esempio n. 7
0
        protected List <IFrameDestination> GetRenderers(BaseOptions options)
        {
            var renderers = new List <IFrameDestination>();

            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();
                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();
            }
            return(renderers);
        }