public ActionResult DeleteConfirmed(int id) { //Ir buscar o User e o Clip a base de dados Utilizadores user = db.Utilizadores.SingleOrDefault(u => u.Email.Equals(User.Identity.Name)); Clips clips = db.Clips.Find(id); //Se for Admin pode apagar qualquer Clip antes da verificacao do User == null && comment == null //porque o admin nao e um Utilizador normal da aplicação if (User.IsInRole("Admin")) { db.Clips.Remove(clips); db.SaveChanges(); } //Verifica se tanto o user como o clip existem e retorna 404 se nao encontrar algum dos dois if (user == null || clips == null) { return(HttpNotFound()); } //Verificar se o utilizador Autenticado e mesmo o dono do Clips, se for autoriza-se e concretiza-se a remoção if (user.ID.Equals(clips.UserFK)) { db.Clips.Remove(clips); db.SaveChanges(); //return RedirectToAction("Index"); } else { //Erro porque o comment nao e dele } return(View(clips)); }
public bool AddClip(Clipboard.Clip clip) { // Check if a clip with the same content exists in the last clips. var equalClips = Clips.Take(10).Where(vm => vm.Clip.Content == clip.Content); if (equalClips.Count() > 0) { // If a clip with the same content already exists, just update the creation time. // TODO: Possibly refresh list view to push clip to top. equalClips.First().Clip.Created = DateTime.Now; return false; } var viewModel = new ClipViewModel(clip); viewModel.PropertyChanged += OnClipViewModelPropChanged; if (Clips.Count >= ClipLimit && ClipLimit > 0) { // If the limit is reached, throw out the oldest one. // Make sure it is not pinned. var first = Clips.Where((c) => !c.Pinned).First(); Clips.Remove(first); } Clips.Add(viewModel); return true; }
public async Task <IActionResult> PutClips(string id, Clips clips) { if (id != clips.id) { return(BadRequest()); } _context.Entry(clips).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClipsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Create([Bind(Include = "ContComment")] Comments comments, int id) { if (ModelState.IsValid) { //Buscar o User associado e o clip Utilizadores user = db.Utilizadores.SingleOrDefault(u => u.Email.Equals(User.Identity.Name)); Clips clip = db.Clips.Find(id); //retorna uma view de erro se nao encontrar o user ou o clip if (user == null || clip == null) { return(HttpNotFound()); } //Criar o comentario var comment = new Comments { ContComment = comments.ContComment, DateComment = DateTime.UtcNow, ClipsFK = clip.ID, UtilizadoresFK = user.ID }; //Adiciona a base de dados e Guarda db.Comments.Add(comment); db.SaveChanges(); return(View()); } //Se o modelo nao tiver valiado apresentar erro return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public void RemoveClip(AtomAnimationClip clip) { Clips.Remove(clip); clip.Dispose(); ClipsListChanged.Invoke(); OnAnimationModified(); }
public void Copy(FootstepAudioDataObject _audio) { if (_audio == null) { return; } Interval = _audio.Interval; Enabled = _audio.Enabled; Foldout = _audio.Foldout; MaxDistance = _audio.MaxDistance; MinDistance = _audio.MinDistance; DistanceMaximum = _audio.DistanceMaximum; MaxPitch = _audio.MaxPitch; MinPitch = _audio.MinPitch; PitchMaximum = _audio.PitchMaximum; RolloffMode = _audio.RolloffMode; Volume = _audio.Volume; MixerGroup = _audio.MixerGroup; Clips.Clear(); foreach (AudioClip _clip in _audio.Clips) { Clips.Add(_clip); } }
private void LoadAsset(AVUrlAsset asset, string[] assetKeysToLoadandTest, DispatchGroup dispatchGroup) { dispatchGroup.Enter(); asset.LoadValuesAsynchronously(assetKeysToLoadandTest, () => { foreach (string key in assetKeysToLoadandTest) { NSError error; if (asset.StatusOfValue(key, out error) == AVKeyValueStatus.Failed) { Console.Error.WriteLine("Key value loading failed for key" + key + " with error: " + error.ToString()); dispatchGroup.Leave(); } } if (!asset.Composable) { Console.Error.WriteLine("Asset is not composable"); dispatchGroup.Leave(); } Clips.Add(asset); CMTimeRange timeRange = new CMTimeRange() { Start = CMTime.FromSeconds(0, 1), Duration = CMTime.FromSeconds(5, 1) }; ClipTimeRanges.Add(NSValue.FromCMTimeRange(timeRange)); dispatchGroup.Leave(); }); }
public Boolean validate(HttpPostedFileBase file) { //se normal get last post datetime adicionar 7 dias if (User.IsInRole("Normal")) { Utilizadores user1 = db.Utilizadores.SingleOrDefault(u => u.Email.Equals(User.Identity.Name)); Clips lastClip = user1.ListClips.Last(); DateTime validade = lastClip.DateClip.AddDays(7); if (DateTime.Now >= validade && file.ContentLength < 10485760) { return(true); } else { return(false); } } if (User.IsInRole("Premium")) { Utilizadores user1 = db.Utilizadores.SingleOrDefault(u => u.Email.Equals(User.Identity.Name)); Clips lastClip = user1.ListClips.Last(); DateTime validade = lastClip.DateClip.AddDays(7); if (file.ContentLength < (10485760) * (2)) { return(true); } else { return(false); } } //se nao é nenhum dos roles return(false); }
public override void SetDefaults(VehicleController vc) { base.SetDefaults(vc); baseVolume = 0.8f; basePitch = 1f; if (Clip == null || Clips.Count == 0) { AudioClip blinkerOn = Resources.Load(VehicleController.DEFAULT_RESOURCES_PATH + "Sound/BlinkerOn") as AudioClip; if (blinkerOn == null) { Debug.LogWarning( $"Audio Clip for sound component {GetType().Name} could not be loaded from resources. Source will not play."); } else { Clips.Add(blinkerOn); } AudioClip blinkerOff = Resources.Load(VehicleController.DEFAULT_RESOURCES_PATH + "Sound/BlinkerOff") as AudioClip; if (blinkerOff == null) { Debug.LogWarning( $"Audio Clip for sound component {GetType().Name} could not be loaded from resources. Source will not play."); } else { Clips.Add(blinkerOff); } } }
/// <summary> /// Creates an Instance of the TwitchAPI Class. /// </summary> /// <param name="logger">Instance Of Logger, otherwise no logging is used, </param> /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used. </param> public TwitchAPI(ILoggerFactory loggerFactory = null, IRateLimiter rateLimiter = null, IHttpCallHandler http = null) { _logger = loggerFactory?.CreateLogger <TwitchAPI>(); _http = http ?? new TwitchHttpClient(loggerFactory?.CreateLogger <TwitchHttpClient>()); _rateLimiter = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance(); Analytics = new Analytics(this); Auth = new Auth(this); Badges = new Badges(this); Bits = new Bits(this); ChannelFeeds = new ChannelFeeds(this); Channels = new Channels(this); Chat = new Chat(this); Clips = new Clips(this); Collections = new Collections(this); Communities = new Communities(this); Entitlements = new Entitlements(this); Games = new Games(this); Ingests = new Ingests(this); Root = new Root(this); Search = new Search(this); Streams = new Streams(this); Teams = new Teams(this); ThirdParty = new ThirdParty(this); Undocumented = new Undocumented(this); Users = new Users(this); Videos = new Videos(this); Webhooks = new Webhooks(this); Debugging = new Debugging(); Settings = new ApiSettings(this); _jsonSerializer = new TwitchLibJsonSerializer(); }
public void DeleteClip(int _index) { if (_index >= 0 && _index < Clips.Count) { Clips.RemoveAt(_index); } }
public void Copy(AudioObject _audio) { base.Copy(_audio); SetImpulseData(_audio); Enabled = _audio.Enabled; Foldout = _audio.Foldout; Loop = _audio.Loop; Break = _audio.Break; StopAtEnd = _audio.StopAtEnd; MaxDistance = _audio.MaxDistance; MinDistance = _audio.MinDistance; DistanceMaximum = _audio.DistanceMaximum; MaxPitch = _audio.MaxPitch; MinPitch = _audio.MinPitch; PitchMaximum = _audio.PitchMaximum; RolloffMode = _audio.RolloffMode; Volume = _audio.Volume; MixerGroup = _audio.MixerGroup; Clips.Clear(); foreach (AudioClip _clip in _audio.Clips) { Clips.Add(_clip); } }
public void AddClip(AudioClip _clip) { if (_clip != null) { Clips.Add(_clip); } }
/// <summary> /// Creates an Instance of the TwitchAPI Class. /// </summary> /// <param name="logger">Instance Of Logger, otherwise no logging is used, </param> /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used. </param> public TwitchAPI(ILogger <TwitchAPI> logger = null, IRateLimiter rateLimiter = null) { _logger = logger; _http = new HttpClient(new TwitchLibCustomHttpMessageHandler(new HttpClientHandler(), _logger)); _rateLimiter = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance(); Auth = new Auth(this); Blocks = new Blocks(this); Badges = new Badges(this); Bits = new Bits(this); ChannelFeeds = new ChannelFeeds(this); Channels = new Channels(this); Chat = new Chat(this); Clips = new Clips(this); Collections = new Collections(this); Communities = new Communities(this); Follows = new Follows(this); Games = new Games(this); Ingests = new Ingests(this); Root = new Root(this); Search = new Search(this); Streams = new Streams(this); Subscriptions = new Subscriptions(this); Teams = new Teams(this); ThirdParty = new ThirdParty(this); Undocumented = new Undocumented(this); Users = new Users(this); Videos = new Videos(this); Webhooks = new Webhooks(this); Debugging = new Debugging(); Settings = new ApiSettings(this); _jsonSerializer = new TwitchLibJsonSerializer(); }
public override global::System.Data.DataSet Clone() { Clips cln = ((Clips)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public void PlayClip(Clips clip, AudioSource source = null) { if (source == null) { source = primaryAudioSource; } PlayClip(clip, 1.0f, 0.3f, source); }
protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container) { YAMLMappingNode node = base.ExportYAMLRoot(container); node.Add("m_Controller", Controller.ExportYAML(container)); node.Add("m_Clips", Clips.ExportYAML(container)); return(node); }
protected override YAMLMappingNode ExportYAMLRoot(IAssetsExporter exporter) { YAMLMappingNode node = base.ExportYAMLRoot(exporter); node.Add("m_Controller", Controller.ExportYAML(exporter)); node.Add("m_Clips", Clips.ExportYAML(exporter)); return(node); }
private void OnClipViewModelPropChanged(object sender, PropertyChangedEventArgs e) { var cvm = sender as ClipViewModel; if (e.PropertyName == "Clip" && cvm.Clip == null) { Clips.Remove(cvm); } }
public virtual void InsertClip(Clip clip) { if (Clips.Any(c => c.Ordering == clip.Ordering)) { throw new InvalidOperationException(); } Clips.Add(clip); }
public void AddClip(AtomAnimationClip clip) { clip.AnimationSettingsModified.AddListener(OnAnimationSettingsModified); clip.onAnimationKeyframesModified.AddListener(OnAnimationModified); clip.onTargetsListChanged.AddListener(OnAnimationModified); clip.onTargetsSelectionChanged.AddListener(OnTargetsSelectionChanged); Clips.Add(clip); ClipsListChanged.Invoke(); }
/************************************************************************************************************************/ /// <summary> /// Sorts all states so that their thresholds go from lowest to highest. /// <para></para> /// This method uses Bubble Sort which is inefficient for large numbers of states. /// </summary> public void SortByThresholds() { var thresholdCount = Thresholds.Length; if (thresholdCount <= 1) { return; } var speedCount = Speeds.Length; var syncCount = SynchroniseChildren.Length; var previousThreshold = Thresholds[0]; for (int i = 1; i < thresholdCount; i++) { var threshold = Thresholds[i]; if (threshold >= previousThreshold) { previousThreshold = threshold; continue; } Thresholds.Swap(i, i - 1); Clips.Swap(i, i - 1); if (i < speedCount) { Speeds.Swap(i, i - 1); } if (i == syncCount && !SynchroniseChildren[i - 1]) { var sync = SynchroniseChildren; Array.Resize(ref sync, ++syncCount); sync[i - 1] = true; sync[i] = false; SynchroniseChildren = sync; } else if (i < syncCount) { SynchroniseChildren.Swap(i, i - 1); } if (i == 1) { i = 0; previousThreshold = float.NegativeInfinity; } else { i -= 2; previousThreshold = Thresholds[i]; } } }
public void ChangeAnimation(string animationName) { var clip = Clips.FirstOrDefault(c => c.AnimationName == animationName); if (clip == null) { throw new NullReferenceException($"Could not find animation '{animationName}'. Found animations: '{string.Join("', '", Clips.Select(c => c.AnimationName).ToArray())}'."); } var targetAnim = _unityAnimation[animationName]; var time = Time; if (_isPlaying) { if (HasAnimatableControllers()) { targetAnim.time = 0f; targetAnim.enabled = true; targetAnim.weight = 0f; _unityAnimation.Blend(Current.AnimationName, 0f, Current.BlendDuration); _unityAnimation.Blend(animationName, 1f, Current.BlendDuration); } if (Current.AnimationPattern != null) { // Let the loop finish during the transition Current.AnimationPattern.SetBoolParamValue("loopOnce", true); } _previousClip = Current; _blendingTimeLeft = _blendingDuration = Current.BlendDuration; } var previous = Current; Current = clip; _animState = targetAnim; if (_isPlaying) { DetermineNextAnimation(_playTime); if (Current.AnimationPattern != null) { Current.AnimationPattern.SetBoolParamValue("loopOnce", false); Current.AnimationPattern.ResetAndPlay(); } } else { Time = 0f; Sample(); CurrentAnimationChanged.Invoke(new CurrentAnimationChangedEventArgs { Before = previous, After = Current }); } }
public MockClipList() { AddClip(new Clipboard.Clip("AlternationCount=\"{Binding Items.Count, RelativeSource={RelativeSource Self}}\"")); var pinnedClip = new Clipboard.Clip("rgba(255, 2, 50, .3)"); var clipVM = new ClipViewModel(pinnedClip); clipVM.Pinned = true; Clips.Add(clipVM); AddClip(new Clipboard.Clip("#0bb")); }
public void PlayClipVaryPitch(Clips clip, AudioSource source = null) { if (source == null) { source = primaryAudioSource; } float pitch = Random.Range(0.8f, 1.2f); PlayClip(clip, pitch, 0.3f, source); }
public ActionResult Create(HttpPostedFileBase fileupload, ClipsDTO clips, string[] categoriasEscolhidas) { Utilizadores user = db.Utilizadores.SingleOrDefault(u => u.Email.Equals(User.Identity.Name)); //se o ficjheiro recebido nao for nulo, se o user nao for nulo e a publicaçao for valida entao pode criar clip if (fileupload != null && user != null && validate(fileupload)) { string fileName = Path.GetFileName(fileupload.FileName); string cont = fileupload.ContentType; string path = Server.MapPath("~/App_Data/Videos/" + fileName); fileupload.SaveAs(path); /// avalia se o array com a lista das escolhas de objetos de B associados ao objeto do tipo A /// é nula, ou não. /// Só poderá avanção se NÃO for nula if (categoriasEscolhidas == null) { ModelState.AddModelError("", "Necessita escolher pelo menos um valor de B para associar ao seu objeto de A."); // gerar a lista de objetos de B que podem ser associados a A ViewBag.ListCategories = db.Categories.OrderBy(b => b.ID).ToList(); // devolver controlo à View return(View(clips)); } // criar uma lista com os objetos escolhidos de B List <Categories> listCategories = new List <Categories>(); foreach (string item in categoriasEscolhidas) { //procurar o objeto de B Categories category = db.Categories.Find(Convert.ToInt32(item)); // adicioná-lo à lista listCategories.Add(category); } if (ModelState.IsValid) { var clip = new Clips { TitleClip = clips.TitleClip, PathClip = path, DateClip = DateTime.Now, UserFK = user.ID, ListCategories = listCategories }; db.Clips.Add(clip); db.SaveChanges(); return(RedirectToAction("Index")); } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(RedirectToAction("Index", "Home")); }
public AudioClip GetClip(Clips clip) { AudioObject obj; if (clips.TryGetValue(clip, out obj)) { return(obj.clip); } return(null); }
public float GetClipLength(Clips clip) { AudioObject obj; if (clips.TryGetValue(clip, out obj)) { return(obj.clip.length); } return(0); }
public void PlayClip(Clips clip, float pitch, float volume, AudioSource source = null) { if (source == null) { source = primaryAudioSource; } audioClip = audioLibrary[clip]; source.pitch = pitch; source.clip = audioClip; source.PlayOneShot(audioClip, volume); }
protected string GetNewAnimationName() { for (var i = Clips.Count + 1; i < 999; i++) { var animationName = "Anim " + i; if (!Clips.Any(c => c.AnimationName == animationName)) { return(animationName); } } return(Guid.NewGuid().ToString()); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { Clips ds = new Clips(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); Clips ds = new Clips(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "BoardDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }