/// <summary> /// Media Constructs a libvlc Media instance /// </summary> /// <param name="instance">A libvlc instance</param> /// <param name="mrl">A path, location, or node name, depending on the 3rd parameter</param> /// <param name="type">The type of the 2nd argument. \sa{FromType}</param> public Media(Instance instance, string mrl, FromType type) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } if (string.IsNullOrEmpty(mrl)) { throw new ArgumentNullException(nameof(mrl)); } switch (type) { case FromType.FromLocation: NativeReference = Internal.LibVLCMediaNewLocation(instance.NativeReference, mrl); break; case FromType.FromPath: NativeReference = Internal.LibVLCMediaNewPath(instance.NativeReference, mrl); break; case FromType.AsNode: NativeReference = Internal.LibVLCMediaNewAsNode(instance.NativeReference, mrl); break; } if (NativeReference == IntPtr.Zero) { throw new ArgumentException($"Failed to construct media for {mrl} of type {type}"); } }
public static string GetAvatarUrl(string avatar, AvatarSize size, FromType fromType) { if (string.IsNullOrWhiteSpace(avatar) || avatar == "default.png") { return(null); } else { switch (fromType) { case FromType.User: { string ext = Path.GetExtension(avatar); string name = Path.GetFileNameWithoutExtension(avatar); return(DataSource.ApiUserMeData.Config.Box.AvatarUrl + name + "_" + (int)size + "x" + (int)size + ext); } case FromType.Service: case FromType.Addition: return(DataSource.ApiUserMeData.Config.Box.ServiceUrl + avatar); default: throw new NotImplementedException(); } } }
public Principal GetPrinciple(FromType fromType) { string user; switch (fromType) { case FromType.Web: user = Principal.GetLogin(HttpContext.Current.User.Identity.Name); user = user == string.Empty ? Principal.GetLogin(Environment.UserName) : user; break; case FromType.WebDav: user = ((IIdentity)Thread.GetData(Thread.GetNamedDataSlot(WebDavServer.HttpUser))).Name; break; default: throw new Exception("No Enum Set"); } Principal p = (Principal)GetCachedObject(user); if (p != null) { return(p); } p = new Principal(user); AddCacheObject(user, p, TimeSpan.FromMinutes(60)); return(p); }
static IntPtr SelectNativeCtor(LibVLC libVLC, string mrl, FromType type) { if (libVLC == null) { throw new ArgumentNullException(nameof(libVLC)); } if (string.IsNullOrEmpty(mrl)) { throw new ArgumentNullException(nameof(mrl)); } switch (type) { case FromType.FromLocation: return(Native.LibVLCMediaNewLocation(libVLC.NativeReference, mrl)); case FromType.FromPath: return(Native.LibVLCMediaNewPath(libVLC.NativeReference, mrl)); case FromType.AsNode: return(Native.LibVLCMediaNewAsNode(libVLC.NativeReference, mrl)); default: return(IntPtr.Zero); } }
public void DateFliter( DateType dateType, FromType fromType, // For date (fromType=0) or for Period (fromType=1) string startDate, string endDate, PeriodBack fromBack, PeriodAhead toAhead ) { ComboBox Drp = advanceSearch.Get <ComboBox>(SearchCriteria.ByAutomationId("cboDateType")); Drp.Items[(int)dateType].Select(); Console.WriteLine(Drp.SelectedItemText.ToString()); switch (fromType) { case FromType.Date: advanceSearch.Get <RadioButton>(SearchCriteria.ByAutomationId("rdbDate")).Click(); DateTimePicker stDate = advanceSearch.Get <DateTimePicker>(SearchCriteria.ByAutomationId("dteStartDate")); stDate.Get(SearchCriteria.ByAutomationId("txtDateTime")).SetValue(startDate); DateTimePicker edDate = advanceSearch.Get <DateTimePicker>(SearchCriteria.ByAutomationId("dteEndDate")); edDate.Get(SearchCriteria.ByAutomationId("txtDateTime")).SetValue(endDate); break; case FromType.Period: ComboBox Drp2 = advanceSearch.Get <ComboBox>(SearchCriteria.ByAutomationId("cboFromPeriod")); Drp2.Items[(int)fromBack].Select(); ComboBox Drp3 = advanceSearch.Get <ComboBox>(SearchCriteria.ByAutomationId("cboToPeriod")); Drp3.Items[(int)toAhead].Select(); break; } }
/// <summary> /// Deploys this instance. /// </summary> public void Deploy(PropertyMapGenerationOptions __options = PropertyMapGenerationOptions.none) { if (__options != PropertyMapGenerationOptions.none) { Options = __options; } if (FromType.hasParameterlessConstructor()) { FromDefaultInstance = FromType.getInstance(null); } if (ToType.hasParameterlessConstructor()) { ToDefaultInstance = ToType.getInstance(null); } if (Options.HasFlag(PropertyMapGenerationOptions.doAutoMapping)) { // fromProps.Select(x => toProps.ContainsKey(x.Key)); if (Options.HasFlag(PropertyMapGenerationOptions.matchName)) { List <String> matchFromList = fromProps.Keys.Where(x => toProps.ContainsKey(x)).ToList(); foreach (var k in matchFromList) { PropertyMapLink link = PropertyMapLink.Create(fromProps[k], toProps[k], this); if (link != null) { Links.Add(link); } } } } }
static IntPtr SelectNativeCtor(LibVLC libVLC, string mrl, FromType type) { if (libVLC == null) { throw new ArgumentNullException(nameof(libVLC)); } if (string.IsNullOrEmpty(mrl)) { throw new ArgumentNullException(nameof(mrl)); } var mrlPtr = Utf8StringMarshaler.GetInstance().MarshalManagedToNative(mrl); if (mrlPtr == IntPtr.Zero) { throw new ArgumentException($"error marshalling {mrl} to UTF-8 for native interop"); } switch (type) { case FromType.FromLocation: return(Native.LibVLCMediaNewLocation(libVLC.NativeReference, mrlPtr)); case FromType.FromPath: return(Native.LibVLCMediaNewPath(libVLC.NativeReference, mrlPtr)); case FromType.AsNode: return(Native.LibVLCMediaNewAsNode(libVLC.NativeReference, mrlPtr)); default: return(IntPtr.Zero); } }
/*** * Converts all the JunimoHuts in the Farm from FromType to ToType ***/ private static void ConvertJunimoHuts <FromType, ToType>() where ToType : JunimoHut where FromType : JunimoHut { Farm f = Game1.getFarm(); List <Building> buildings = f.buildings; for (int i = 0; i < buildings.Count; i++) { if (buildings[i] is FromType) { FromType oldHut = (buildings[i] as FromType); //Kill all junimos before removing the building. foreach (JunimoHarvester harvester in oldHut.myJunimos) { f.characters.Remove(harvester); } oldHut.myJunimos.Clear(); ToType newHut = (ToType)Activator.CreateInstance(typeof(ToType), new object[] { new BluePrint("Junimo Hut"), new Vector2(oldHut.tileX, oldHut.tileY) }); newHut.daysOfConstructionLeft = oldHut.daysOfConstructionLeft; newHut.output = oldHut.output; buildings[i] = newHut; } } }
public override bool Equals(object obj) { if (!(obj is TypeConversionSymbol symbol)) { return(false); } return(FromType.Equals(symbol.FromType) && ToType.Equals(symbol.ToType)); }
/// <summary> /// 提交流水 /// </summary> /// <param name="stocks"></param> /// <param name="batchNo"></param> /// <param name="fromType"></param> public void SubmitRecord(List <TModel> stocks, string batchNo, FromType fromType) { foreach (TModel c in stocks) { c.BatchNo = batchNo; c.OperateTypeFrom = fromType; c.Num = Math.Abs(c.Num); } BatchInsert(stocks); }
public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hash = 17; // Suitable nullity checks etc, of course :) hash = hash * 23 + FromType.GetHashCode(); hash = hash * 23 + ToType.GetHashCode(); return(hash); } }
public static BitmapImage GetAvatarBitmap(string avatar, AvatarSize size, FromType fromType) { string url = GetAvatarUrl(avatar, size, fromType); if (string.IsNullOrWhiteSpace(url)) { return(null); } else { return(new BitmapImage(new Uri(url))); } }
public override int GetHashCode() { unchecked { var hashCode = Id; hashCode = (hashCode * 397) ^ StartDate.GetHashCode(); hashCode = (hashCode * 397) ^ EndDate.GetHashCode(); hashCode = (hashCode * 397) ^ FromType.GetHashCode(); hashCode = (hashCode * 397) ^ ToType.GetHashCode(); hashCode = (hashCode * 397) ^ (FromValue != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(FromValue) : 0); hashCode = (hashCode * 397) ^ (ToValue != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(ToValue) : 0); hashCode = (hashCode * 397) ^ (TimeAndDows != null ? TimeAndDows.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { int hashCode = 0; if (FromType != null) { hashCode ^= FromType.GetHashCode(); } if (EdgeInfo != null) { hashCode ^= EdgeInfo.GetHashCode(); } return(hashCode); }
public void DateUsage(FromType fromType, string usageStartDate, string usageEndDate, PeriodBack fromBack, PeriodAhead toAhead) { switch (fromType) { case FromType.Date: DateTimePicker stDate = advanceSearch.Get <DateTimePicker>(SearchCriteria.ByAutomationId("dteUsageDateFrom")); stDate.Get(SearchCriteria.ByAutomationId("txtDateTime")).SetValue(usageStartDate); DateTimePicker edDate = advanceSearch.Get <DateTimePicker>(SearchCriteria.ByAutomationId("dteUsageDateTo")); stDate.Get(SearchCriteria.ByAutomationId("txtDateTime")).SetValue(usageEndDate); break; case FromType.Period: ComboBox Drp2 = advanceSearch.Get <ComboBox>(SearchCriteria.ByAutomationId("cboUsagePeriodFrom")); Drp2.Items[(int)fromBack].Select(); ComboBox Drp3 = advanceSearch.Get <ComboBox>(SearchCriteria.ByAutomationId("cboUsagePeriodTo")); Drp3.Items[(int)toAhead].Select(); break; } }
static IntPtr SelectNativeCtor(LibVLC libVLC, string mrl, FromType type) { if (libVLC == null) { throw new ArgumentNullException(nameof(libVLC)); } if (string.IsNullOrEmpty(mrl)) { throw new ArgumentNullException(nameof(mrl)); } var mrlPtr = mrl.ToUtf8(); if (mrlPtr == IntPtr.Zero) { throw new ArgumentException($"error marshalling {mrl} to UTF-8 for native interop"); } IntPtr result; switch (type) { case FromType.FromLocation: result = Native.LibVLCMediaNewLocation(libVLC.NativeReference, mrlPtr); break; case FromType.FromPath: result = Native.LibVLCMediaNewPath(libVLC.NativeReference, mrlPtr); break; case FromType.AsNode: result = Native.LibVLCMediaNewAsNode(libVLC.NativeReference, mrlPtr); break; default: result = IntPtr.Zero; break; } Marshal.FreeHGlobal(mrlPtr); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="Principal" /> class. /// </summary> internal Principal(FromType fromType) { string networkUsername; switch (fromType) { case FromType.Web: networkUsername = GetLogin(HttpContext.Current.User.Identity.Name); networkUsername = networkUsername == string.Empty ? GetLogin(Environment.UserName) : networkUsername; Load(networkUsername); break; case FromType.WebDav: networkUsername = ((IIdentity)Thread.GetData(Thread.GetNamedDataSlot(WebDavServer.HttpUser))).Name; Load(networkUsername); break; } }
public override int GetHashCode() { int hashcode = 157; unchecked { if (__isset.message) { hashcode = (hashcode * 397) + Message.GetHashCode(); } if (__isset.fromType) { hashcode = (hashcode * 397) + FromType.GetHashCode(); } if (__isset.squareMessageRevision) { hashcode = (hashcode * 397) + SquareMessageRevision.GetHashCode(); } } return(hashcode); }
public static void OpenUI(ExitTeamCallback callback = null, FromType type = FromType.FromMainUI) { if (_mInstance == null) { Object prefab = PrefabLoader.loadFromPack("ZQ/TeamUI"); if (prefab != null) { GameObject obj = Instantiate(prefab) as GameObject; RED.AddChild(obj, DBUIController.mDBUIInstance._bottomRoot); _mInstance = obj.GetComponent <TeamUI> (); } } else { _mInstance.SetShow(true); } _mInstance.mSelectIndex = 0; SQYUIManager.getInstance().opIndex = 0; _mInstance.m_type = type; _mInstance.m_callBack = callback; }
public Principal GetPrinciple(FromType fromType) { string user; switch (fromType) { case FromType.Web: user = Principal.GetLogin(HttpContext.Current.User.Identity.Name); user = user == string.Empty ? Principal.GetLogin(Environment.UserName) : user; break; case FromType.WebDav: user = ((IIdentity) Thread.GetData(Thread.GetNamedDataSlot(WebDavServer.HttpUser))).Name; break; default: throw new Exception("No Enum Set"); } Principal p = (Principal) GetCachedObject(user); if (p != null) return p; p = new Principal(user); AddCacheObject(user, p, TimeSpan.FromMinutes(60)); return p; }
public override string ToString() { var sb = new StringBuilder("SquareMessage("); bool __first = true; if (Message != null && __isset.message) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Message: "); Message.ToString(sb); } if (__isset.fromType) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("FromType: "); FromType.ToString(sb); } if (__isset.squareMessageRevision) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("SquareMessageRevision: "); SquareMessageRevision.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
/// <summary> /// Gets music properties for a given storage file. /// </summary> /// <param name="libVLC">LibVLC Instance.</param> /// <param name="path">Item to be parsed.</param> /// <param name="type">Item type.</param> /// <returns>Music MediaProperties.</returns> public static async Task <TrackItem> GetMusicPropertiesAsync(LibVLC libVLC, string path, FromType type = FromType.FromPath) { return(await GetMusicPropertiesAsync(libVLC, new TrackItem() { Path = path }, type).ConfigureAwait(false)); }
/// <summary> /// Gets music properties for a given storage file. /// </summary> /// <param name="libVLC">LibVLC Instance.</param> /// <param name="mP">Item to be parsed.</param> /// <param name="type">Item type.</param> /// <returns>Music MediaProperties.</returns> public static async Task <TrackItem> GetMusicPropertiesAsync(LibVLC libVLC, TrackItem mP, FromType type) { var media = new LibVLCSharp.Shared.Media(libVLC, mP.Path, type); var parseStatus = await media.Parse(MediaParseOptions.ParseLocal& MediaParseOptions.FetchLocal).ConfigureAwait(false); if (parseStatus == MediaParsedStatus.Failed) { throw new ParseMediaException($"Could not parse {mP.Path}"); } mP.AlbumArtist = media.Meta(MetadataType.AlbumArtist); mP.Artist = media.Meta(MetadataType.Artist); mP.Album = media.Meta(MetadataType.Album); mP.Title = media.Meta(MetadataType.Title); mP.AlbumArt = media.Meta(MetadataType.ArtworkURL); var yearString = media.Meta(MetadataType.Date); var year = 0; if (int.TryParse(yearString, out year)) { mP.Year = year; } var durationLong = media.Duration; TimeSpan duration = TimeSpan.FromMilliseconds(durationLong); mP.Duration = duration; var trackNbString = media.Meta(MetadataType.TrackNumber); uint trackNbInt = 0; uint.TryParse(trackNbString, out trackNbInt); mP.Tracknumber = trackNbInt; var discNb = media.Meta(MetadataType.DiscNumber); if (discNb != null && discNb.Contains("/")) { // if discNb = "1/2" var discNumDen = discNb.Split('/'); if (discNumDen.Any()) { discNb = discNumDen[0]; } } int.TryParse(discNb, out int discNbInt); mP.DiscNumber = discNbInt; var genre = media.Meta(MetadataType.Genre); mP.Genre = genre; return(mP); }
/// <summary> /// Initializes a new instance of the <see cref="Principal" /> class. /// </summary> internal Principal(FromType fromType) { string networkUsername; switch (fromType) { case FromType.Web: networkUsername = GetLogin(HttpContext.Current.User.Identity.Name); networkUsername = networkUsername == string.Empty ? GetLogin(Environment.UserName) : networkUsername; Load(networkUsername); break; case FromType.WebDav: networkUsername = ((IIdentity) Thread.GetData(Thread.GetNamedDataSlot(WebDavServer.HttpUser))).Name; Load(networkUsername); break; } }
/// <summary> /// Media Constructs a libvlc Media instance /// </summary> /// <param name="libVLC">A libvlc instance</param> /// <param name="mrl">A path, location, or node name, depending on the 3rd parameter</param> /// <param name="type">The type of the 2nd argument. \sa{FromType}</param> public Media(LibVLC libVLC, string mrl, FromType type = FromType.FromPath) : base(() => SelectNativeCtor(libVLC, mrl, type), Native.LibVLCMediaRelease) { }
private void Init() { _mediaPlayer?.Dispose(); _videoFormat = VideoFormat; _lockCB = LockVideo; _unlockCB = UnlockVideo; _displayCB = DisplayVideo; //_cleanupVideoCB = CleanupVideo; _audioSetup = AudioSetup; _processAudio = ProcessAudio; _cleanupAudio = CleanupAudio; _pauseAudio = PauseAudio; _resumeAudio = ResumeAudio; _flushAudio = FlushAudio; _drainAudio = DrainAudio; string overrideURL = null; if (_camera != null) { switch (_camera.Camobject.settings.sourceindex) { case 9: var od = _camera.ONVIFDevice; if (od != null) { var ep = od.StreamEndpoint; if (ep != null) { var u = ep.Uri.Uri; overrideURL = u; } } break; } } FromType ftype = FromType.FromLocation; Seekable = false; var murl = overrideURL ?? Source; if (string.IsNullOrEmpty(murl)) { throw new Exception("Video source is empty"); } try { var p = Path.GetFullPath(overrideURL ?? Source); Seekable = !string.IsNullOrEmpty(p); if (Seekable) { ftype = FromType.FromPath; } } catch (Exception) { Seekable = false; } using (var media = new Media(LibVLC, murl, ftype)) { Duration = Time = 0; foreach (var opt in _options) { media.AddOption(opt); } _mediaPlayer = new MediaPlayer(media); _mediaPlayer.SetVideoFormatCallbacks(_videoFormat, null);// _cleanupVideoCB); _mediaPlayer.SetVideoCallbacks(_lockCB, _unlockCB, _displayCB); _mediaPlayer.TimeChanged += _mediaPlayer_TimeChanged; _mediaPlayer.EnableHardwareDecoding = false; _mediaPlayer.SetAudioFormatCallback(_audioSetup, _cleanupAudio); _mediaPlayer.SetAudioCallbacks(_processAudio, _pauseAudio, _resumeAudio, _flushAudio, _drainAudio); _mediaPlayer.EncounteredError += (sender, e) => { ErrorHandler?.Invoke("VLC Error"); _res = ReasonToFinishPlaying.VideoSourceError; }; _mediaPlayer.EndReached += (sender, e) => { _res = ReasonToFinishPlaying.VideoSourceError; }; _mediaPlayer.Stopped += (sender, e) => { Logger.LogMessage("VLC stopped"); Task.Run(() => { Debug.WriteLine("CLEANUP"); IsRunning = false; _stopping = false; _stopped?.Set(); PlayingFinished?.Invoke(this, new PlayingFinishedEventArgs(_res)); AudioFinished?.Invoke(this, new PlayingFinishedEventArgs(_res)); }); }; } _lastTimeUpdate = DateTime.UtcNow; _mediaPlayer.Play(); }
public override int GetHashCode() { return ((FromType.GetHashCode() * 17) + ToType.GetHashCode()); }
/// <summary> /// Create the CallingParameter. /// </summary> /// <param name="name">The name of the parameter.</param> /// <param name="parameterType">The type of the parameter.</param> /// <param name="fromType">The From type of this parameter.</param> public CallingParameter(string name, Type parameterType, FromType fromType) { Name = name; ParameterType = parameterType; FromType = fromType; }
/// <summary> /// Media Constructs a libvlc Media instance /// </summary> /// <param name="libVLC">A libvlc instance</param> /// <param name="mrl">A path, location, or node name, depending on the 3rd parameter</param> /// <param name="type">The type of the 2nd argument.</param> /// <param name="options">the libvlc options</param> public Media(LibVLC libVLC, string mrl, FromType type = FromType.FromPath, params string[] options) : this(() => SelectNativeCtor(libVLC, mrl, type), Native.LibVLCMediaRelease, options) { }
/// <summary> /// Gets video properties for a given storage file. /// </summary> /// <param name="libVLC">LibVLC Instance.</param> /// <param name="path">Item to be parsed.</param> /// <param name="type">Item type.</param> /// <returns>Music MediaProperties.</returns> public static Task <VideoItem> GetVideoPropertiesAsync(LibVLC libVLC, string path, FromType type = FromType.FromPath) { return(GetVideoPropertiesAsync(libVLC, new VideoItem() { Path = path }, type)); }
/// <summary> /// Gets video properties for a given storage file. /// </summary> /// <param name="libVLC">LibVLC Instance.</param> /// <param name="mP">Item to be parsed.</param> /// <param name="type">Item type.</param> /// <returns>Music MediaProperties.</returns> public static async Task <VideoItem> GetVideoPropertiesAsync(LibVLC libVLC, VideoItem mP, FromType type) { var media = new LibVLCSharp.Shared.Media(libVLC, mP.Path, type); var parseStatus = await media.Parse(MediaParseOptions.ParseLocal& MediaParseOptions.FetchLocal).ConfigureAwait(false); if (parseStatus == MediaParsedStatus.Failed) { throw new ParseMediaException($"Could not parse {mP.Path}"); } mP.Title = media.Meta(MetadataType.Title); var showName = media.Meta(MetadataType.ShowName); if (string.IsNullOrEmpty(showName)) { showName = media.Meta(MetadataType.Artist); } if (!string.IsNullOrEmpty(showName)) { mP.ShowTitle = showName; } var episodeString = media.Meta(MetadataType.Episode); if (string.IsNullOrEmpty(episodeString)) { episodeString = media.Meta(MetadataType.TrackNumber); } var episode = 0; if (!string.IsNullOrEmpty(episodeString) && int.TryParse(episodeString, out episode)) { mP.Episode = episode; } var episodesTotal = 0; var episodesTotalString = media.Meta(MetadataType.TrackTotal); if (!string.IsNullOrEmpty(episodesTotalString) && int.TryParse(episodesTotalString, out episodesTotal)) { mP.Episodes = episodesTotal; } var videoTrack = media.Tracks.FirstOrDefault(x => x.TrackType == TrackType.Video); mP.Width = videoTrack.Data.Video.Width; mP.Height = videoTrack.Data.Video.Height; var durationLong = media.Duration; var duration = TimeSpan.FromMilliseconds(durationLong); mP.Duration = duration; return(mP); }
protected virtual void DeployTypes() { fromProps = FromType.GetProperties(BindingFlags.Instance | BindingFlags.Public).ToDictionary(x => x.Name); toProps = ToType.GetProperties(BindingFlags.Instance | BindingFlags.Public).ToDictionary(x => x.Name); }