public BaseEncoder GetEncoder(EncoderTypes encoderType) { BaseEncoder encoder = null; switch (encoderType) { case EncoderTypes.CrockfordLower: encoder = new CrockfordLowerEncoder(); break; case EncoderTypes.CrockfordMixed: encoder = new CrockfordMixedEncoder(); break; case EncoderTypes.ZBase32: encoder = new ZBase32Encoder(); break; case EncoderTypes.Hexadecimal: encoder = new HexadecimalEncoder(); break; case EncoderTypes.UnicodeSymbols: encoder = new UnicodeSymbolsEncoder(); break; default: throw new ArgumentException("Encoder type not registered"); } return encoder; }
public static IImageEncoder GetEncoder(EncoderTypes encoderType) { IImageEncoder encoder; switch (encoderType) { case EncoderTypes.Png: encoder = new PngEncoder(); break; case EncoderTypes.Jpeg: encoder = new JpegEncoder(); break; default: throw new ArgumentException($"Encoder '{ encoderType }' not found!"); } ; return(encoder); }
/// <summary> /// Encode an integer and specify one of the builtin encoders /// </summary> /// <param name="value">Value to be encoded</param> /// <param name="encoderType">The encoder to be used</param> /// <returns>An integer encoded to a string</returns> public static string Encode(ulong value, EncoderTypes encoderType) { EncoderFactory factory = new EncoderFactory(); BaseEncoder encoder = factory.GetEncoder(encoderType); return encoder.Encode(value); }
/// <summary> /// Decode a string and specify one of the builtin encoders /// </summary> /// <param name="encodedValue">The encoded string</param> /// <param name="encoderType">The encoder used on this string</param> /// <returns>A converted integer</returns> public static ulong Decode(string encodedValue, EncoderTypes encoderType) { EncoderFactory factory = new EncoderFactory(); BaseEncoder encoder = factory.GetEncoder(encoderType); return encoder.Decode(encodedValue); }
public MainSettingsModel(LocalSettingsService localSettings, CoreData coreData, StreamSettingsModel streamSettings, ConnectionService connectionService, TranscodingModel transcoding) { CoreData = coreData; StreamSettings = streamSettings; Transcoding = transcoding; _connectionService = connectionService; AutoLogon.SilentValue = localSettings.Settings.AutoLogon; // TODO: what is is not registred and not save password AutoLogon.OnChange = async(o, n) => await localSettings.ChangeSettingsUnconditionally(s => s.AutoLogon = n); CurrentStreamingToCloudBehavior.Value = StreamingToCloudBehaviors.First(s => s.Value == default); CurrentEncoderType.Value = EncoderTypes.First(s => s.Value == default); CurrentEncoderQuality.Value = EncoderQualities.First(s => s.Value == default); CurrentTopMostMode.Value = TopMostModes.First(s => s.Value == TopMostMode.WhenCompact); CurrentVpnBehavior.Value = VpnBehaviors.First(s => s.Value == default); CurrentRendererType.Value = RendererTypes.First(s => s.Value == default); CurrentBlenderType.Value = BlenderTypes.First(s => s.Value == default); CurrentRecordingFormat.Value = RecordingFormats.First(s => s.Value == default); CurrentStreamingToCloudBehavior.OnChange = (o, n) => coreData.Settings.StreamingToCloud = n.Value; CurrentEncoderType.OnChange = (o, n) => coreData.Settings.EncoderType = n.Value; CurrentEncoderQuality.OnChange = (o, n) => coreData.Settings.EncoderQuality = n.Value; CurrentTopMostMode.OnChange = (o, n) => { coreData.ThisDevice.DeviceSettings.DisableTopMost = TopMostModeConverter.GetDisableTopMost(n.Value); coreData.ThisDevice.DeviceSettings.TopMostExtendedMode = TopMostModeConverter.GetTopMostExtendedMode(n.Value); }; CurrentRecordingFormat.OnChange = (o, n) => coreData.Settings.RecordingFormat = n.Value; CurrentVpnBehavior.OnChange = (o, n) => coreData.ThisDevice.DeviceSettings.VpnBehavior = n.Value; CurrentRendererType.OnChange = (o, n) => coreData.ThisDevice.DeviceSettings.RendererType = n.Value; CurrentBlenderType.OnChange = (o, n) => coreData.ThisDevice.DeviceSettings.BlenderType = n.Value; HardwareAdapter.OnChange = (o, n) => coreData.ThisDevice.DeviceSettings.RendererAdapter = n; PreferNalHdr.OnChange = (o, n) => coreData.Settings.PreferNalHdr = n; EnableQsvNv12Optimization.OnChange = (o, n) => coreData.Settings.DisableQsvNv12Optimization = !n; CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.StreamingToCloud, (s, c, p) => CurrentStreamingToCloudBehavior.SilentValue = StreamingToCloudBehaviors.FirstOrDefault(r => r.Value == CoreData.Settings.StreamingToCloud)); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.EncoderType, (s, c, p) => CurrentEncoderType.SilentValue = EncoderTypes.FirstOrDefault(r => r.Value == CoreData.Settings.EncoderType)); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.EncoderQuality, (s, c, p) => CurrentEncoderQuality.SilentValue = EncoderQualities.FirstOrDefault(r => r.Value == CoreData.Settings.EncoderQuality)); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.PreferNalHdr, (s, c, p) => PreferNalHdr.SilentValue = CoreData.Settings.PreferNalHdr); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.DisableQsvNv12Optimization, (s, c, p) => EnableQsvNv12Optimization.SilentValue = !CoreData.Settings.DisableQsvNv12Optimization); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.RecordingFormat, (s, c, p) => CurrentRecordingFormat.SilentValue = RecordingFormats.FirstOrDefault(r => r.Value == CoreData.Settings.RecordingFormat)); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.DisableTopMost, (s, c, p) => UpdateTopMost()); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.TopMostExtendedMode, (s, c, p) => UpdateTopMost()); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.VpnBehavior, (s, c, p) => CurrentVpnBehavior.SilentValue = VpnBehaviors.FirstOrDefault(r => r.Value == CoreData.ThisDevice.DeviceSettings.VpnBehavior)); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.RendererType, (s, c, p) => CurrentRendererType.SilentValue = RendererTypes.FirstOrDefault(r => r.Value == CoreData.ThisDevice.DeviceSettings.RendererType)); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.BlenderType, (s, c, p) => CurrentBlenderType.SilentValue = BlenderTypes.FirstOrDefault(r => r.Value == CoreData.ThisDevice.DeviceSettings.BlenderType)); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.RendererAdapter, (s, c, p) => { if (HardwareAdapters != null) { HardwareAdapter.SilentValue = HardwareAdapters.Contains(CoreData.ThisDevice.DeviceSettings.RendererAdapter) ? CoreData.ThisDevice.DeviceSettings.RendererAdapter : HardwareAdapters.FirstOrDefault(); } }); }
public override bool Configure() { bool result = false; if (null == this.FaultReason) { result = true; // common configuration result &= base.Configure(); if (0x00010196 == this.DeviceType) { this.encoderType = EncoderTypes.singleTurn; result = true; result &= this.SetTPDOMapCount(1, 0); result &= this.SetTPDOType(1, 255); result &= this.SetTPDOEventTime(1, 100); result &= this.SetTPDOMap(1, 1, 0x6004, 0, 4); result &= this.SetTPDOMap(1, 2, 0x6030, 1, 2); result &= this.SetTPDOMapCount(1, 2); } else if (0x00020196 == this.DeviceType) { this.encoderType = EncoderTypes.multiTurn; result = true; result &= this.SetTPDOMapCount(1, 0); result &= this.SetTPDOType(1, 255); result &= this.SetTPDOEventTime(1, 500); result &= this.SetTPDOMap(1, 1, 0x6004, 0, 4); result &= this.SetTPDOMap(1, 2, 0x6030, 1, 2); result &= this.SetTPDOMapCount(1, 2); } else if (0x000B0196 == this.DeviceType) { this.encoderType = EncoderTypes.multiTurn; result = true; result &= this.SetTPDOMapCount(1, 0); result &= this.SetTPDOEnable(1, false); result &= this.SetTPDOType(1, 254); result &= this.SetTPDOInhibitTime(1, 250); // TPDO must be disabled before setting inhibit time result &= this.SetTPDOEnable(1, true); result &= this.SetTPDOMap(1, 1, 0x6004, 0, 4); result &= this.SetTPDOMap(1, 2, 0x6030, 1, 2); result &= this.SetTPDOMapCount(1, 2); } else { this.encoderType = EncoderTypes.unknown; this.Fault("unsupported encoder"); } } return (result); }