public void Perform(PossibleMatch Match, Actor Actor) { var speechBuilder = new StringBuilder(); speechBuilder.Append(Actor.Short); if (EmoteType == EmoteTypes.Speech) { speechBuilder.Append(": \""); } else { speechBuilder.Append(" "); } for (var node = Match.Arguments["SPEECH"] as LinkedListNode <String>; node != null; node = node.Next) { speechBuilder.Append(node.Value); speechBuilder.Append(" "); } speechBuilder.Remove(speechBuilder.Length - 1, 1); if (EmoteType == EmoteTypes.Speech) { speechBuilder.Append("\"\r\n"); } else { speechBuilder.Append("\r\n"); } Mud.SendEventMessage(Actor, EventMessageScope.Local, speechBuilder.ToString()); }
public void Perform(PossibleMatch Match, Actor Actor) { var direction = Match.Arguments["DIRECTION"] as Direction?; var location = Actor.Location as Room; var link = location.Links.FirstOrDefault(l => l.Direction == direction.Value); if (link == null) { Mud.SendEventMessage(Actor, EventMessageScope.Single, "You can't go that way.\r\n"); } else { if (link.Door != null) { if (!link.Door.Open) { Mud.SendEventMessage(Actor, EventMessageScope.Single, "The door is closed."); return; } } Mud.SendEventMessage(Actor, EventMessageScope.Single, "You went " + direction.Value.ToString().ToLower() + ".\r\n"); Mud.SendEventMessage(Actor, EventMessageScope.External, Actor.Short + " went " + direction.Value.ToString().ToLower() + "\r\n"); var destination = Mud.GetObject(link.Destination) as Room; if (destination == null) { throw new InvalidOperationException("Link does not lead to room."); } Thing.Move(Actor, destination); Mud.EnqueuClientCommand(Actor.ConnectedClient, "look"); } }
public void Perform(PossibleMatch Match, Actor Actor) { var target = Match.Arguments["TARGET"] as Thing; if (target == null) { if (Actor.ConnectedClient != null) Actor.ConnectedClient.Send("Drop what again?\r\n"); } else { if (!Object.ReferenceEquals(target.Location, Actor)) { Actor.ConnectedClient.Send("You aren't holding that.\r\n"); return; } var dropRules = target as IDropRules; if (dropRules != null && !dropRules.CanDrop(Actor)) { Actor.ConnectedClient.Send("You can't drop that.\r\n"); return; } Mud.SendEventMessage(Actor, EventMessageScope.Single, "You drop " + target.Short + "\r\n"); Mud.SendEventMessage(Actor, EventMessageScope.External, Actor.Short + " drops " + target.Short + "\r\n"); Thing.Move(target, Actor.Location); } }
public void Perform(PossibleMatch Match, Actor Actor) { if (Actor.ConnectedClient != null) { Actor.ConnectedClient.Send(Message); } }
public void Perform(PossibleMatch Match, Actor Actor) { if (Actor.ConnectedClient == null) return; Object target = null; if (Match.Arguments.ContainsKey("TARGET")) target = Match.Arguments["TARGET"]; else target = Actor.Location; var data = new StringBuilder(); data.Append(target.GetType().Name); data.Append("\r\n"); foreach (var field in target.GetType().GetFields()) { data.Append(field.FieldType.Name); data.Append(" "); data.Append(field.Name); data.Append(" = "); var value = field.GetValue(target); if (value == null) data.Append("null"); else data.Append(value.ToString()); data.Append("\r\n"); } Actor.ConnectedClient.Send(data.ToString()); }
public void Perform(PossibleMatch Match, Actor Actor) { if (Actor.ConnectedClient == null) { return; } var builder = new StringBuilder(); if (Actor.Inventory.Count == 0) { builder.Append("You have nothing."); } else { builder.Append("You are carrying..\r\n"); foreach (var item in Actor.Inventory) { builder.Append(" "); builder.Append(item.Short); builder.Append("\r\n"); } } Mud.SendEventMessage(Actor, EventMessageScope.Single, builder.ToString()); }
public void Perform(PossibleMatch Match, Actor Actor) { var target = Match.Arguments["TARGET"] as Thing; if (target == null) { if (Actor.ConnectedClient != null) { Actor.ConnectedClient.Send("Take what again?\r\n"); } } else { var takeRules = target as ITakeRules; if (takeRules != null && !takeRules.CanTake(Actor)) { Actor.ConnectedClient.Send("You can't take that.\r\n"); return; } Mud.SendEventMessage(Actor, EventMessageScope.Single, "You take " + target.Short + "\r\n"); Mud.SendEventMessage(Actor, EventMessageScope.External, Actor.Short + " takes " + target.Short + "\r\n"); Thing.Move(target, Actor); } }
public void Perform(PossibleMatch Match, Actor Actor) { var direction = Match.Arguments["DIRECTION"] as Direction?; var location = Actor.Location as Room; var link = location.Links.FirstOrDefault(l => l.Direction == direction.Value); if (link == null) Mud.SendEventMessage(Actor, EventMessageScope.Single, "You can't go that way.\r\n"); else { if (link.Door != null) { if (!link.Door.Open) { Mud.SendEventMessage(Actor, EventMessageScope.Single, "The door is closed."); return; } } Mud.SendEventMessage(Actor, EventMessageScope.Single, "You went " + direction.Value.ToString().ToLower() + ".\r\n"); Mud.SendEventMessage(Actor, EventMessageScope.External, Actor.Short + " went " + direction.Value.ToString().ToLower() + "\r\n"); var destination = Mud.GetObject(link.Destination) as Room; if (destination == null) throw new InvalidOperationException("Link does not lead to room."); Thing.Move(Actor, destination); Mud.EnqueuClientCommand(Actor.ConnectedClient, "look"); } }
public void Perform(PossibleMatch Match, Actor Actor) { var target = Match.Arguments["TARGET"] as Thing; if (target == null) { if (Actor.ConnectedClient != null) { Actor.ConnectedClient.Send("Drop what again?\r\n"); } } else { if (!Object.ReferenceEquals(target.Location, Actor)) { Actor.ConnectedClient.Send("You aren't holding that.\r\n"); return; } var dropRules = target as IDropRules; if (dropRules != null && !dropRules.CanDrop(Actor)) { Actor.ConnectedClient.Send("You can't drop that.\r\n"); return; } Mud.SendEventMessage(Actor, EventMessageScope.Single, "You drop " + target.Short + "\r\n"); Mud.SendEventMessage(Actor, EventMessageScope.External, Actor.Short + " drops " + target.Short + "\r\n"); Thing.Move(target, Actor.Location); } }
public void Perform(PossibleMatch Match, Actor Actor) { var location = Actor.Location as Room; if (location == null) { throw new InvalidOperationException("Error: Actor not in room."); } if (Actor.ConnectedClient != null) { var builder = new StringBuilder(); builder.Append(location.Short); builder.Append("\r\n"); builder.Append(location.Long.Expand(Actor, location)); builder.Append("\r\n"); //Display objects in room if (location.Contents.Count > 0) { builder.Append("Also here: " + String.Join(",", location.Contents.Select(t => t.Short))); } else { builder.Append("There is nothing here."); } builder.Append("\r\n"); //Display exits from room if (location.Links.Count > 0) { builder.Append("Obvious exits: "); for (int i = 0; i < location.Links.Count; ++i) { var l = location.Links[i]; builder.Append(l.Direction.ToString().ToLower()); if (l.Door != null) { builder.Append(" [through "); builder.Append(l.Door.Short); builder.Append("]"); } if (i != location.Links.Count - 1) { builder.Append(", "); } } builder.AppendLine("\r\n"); } Mud.SendEventMessage(Actor, EventMessageScope.Single, builder.ToString()); } }
public void Perform(PossibleMatch Match, Actor Actor) { var target = Match.Arguments["TARGET"] as Thing; var destination = Match.Arguments["DESTINATION"].ToString(); var room = Mud.GetObject(destination); if (room != null) Thing.Move(target, room); }
public void Perform(PossibleMatch Match, Actor Actor) { var target = Match.Arguments["TARGET"] as Thing; var destination = Match.Arguments["DESTINATION"].ToString(); var room = Mud.GetObject(destination); if (room != null) { Thing.Move(target, room); } }
public void Perform(PossibleMatch Match, Actor Actor) { var target = Match.Arguments["TARGET"] as IDescribed; if (Actor.ConnectedClient != null) { if (target == null) Mud.SendEventMessage(Actor, EventMessageScope.Single, "That object is indescribeable.\r\n"); else Mud.SendEventMessage(Actor, EventMessageScope.Single, target.Long.Expand(Actor, target as MudObject) + "\r\n"); } }
public void Perform(PossibleMatch Match, Actor Actor) { var location = Actor.Location as Room; if (location == null) throw new InvalidOperationException("Error: Actor not in room."); if (Actor.ConnectedClient != null) { var builder = new StringBuilder(); builder.Append(location.Short); builder.Append("\r\n"); builder.Append(location.Long.Expand(Actor, location)); builder.Append("\r\n"); //Display objects in room if (location.Contents.Count > 0) builder.Append("Also here: " + String.Join(",", location.Contents.Select(t => t.Short))); else builder.Append("There is nothing here."); builder.Append("\r\n"); //Display exits from room if (location.Links.Count > 0) { builder.Append("Obvious exits: "); for (int i = 0; i < location.Links.Count; ++i) { var l = location.Links[i]; builder.Append(l.Direction.ToString().ToLower()); if (l.Door != null) { builder.Append(" [through "); builder.Append(l.Door.Short); builder.Append("]"); } if (i != location.Links.Count - 1) builder.Append(", "); } builder.AppendLine("\r\n"); } Mud.SendEventMessage(Actor, EventMessageScope.Single, builder.ToString()); } }
public PossibleMatch With(params object[] options) { if (options.Length != Values.Length) { throw new ArgumentException("Too many options provided, Length of options must match pattern length"); } var possibleMatch = new PossibleMatch(this, options); if (possibleMatch.IsMatch) { _AtLeastOneMatchFound = true; } return(possibleMatch); }
protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { if (value == null) { base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); return; } PossibleMatch match = (PossibleMatch)value; // draw the native combo first, we are just painting on top of it, not redrawing from scratch base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, match.Movie.Title, errorText, cellStyle, advancedBorderStyle, paintParts); string yearText = "(" + match.Movie.Year + ")"; string altTitleText = "as " + match.Result.AlternateTitle; string providerName = match.Movie.PrimarySource == null ? string.Empty : match.Movie.PrimarySource.Provider.Name; // figure basic positioning SizeF providerSize = graphics.MeasureString(providerName, DataGridView.Font); SizeF titleSize = graphics.MeasureString(match.Movie.Title, DataGridView.Font); SizeF yearSize = graphics.MeasureString(yearText, DataGridView.Font); int providerPosition = (int)(cellBounds.X + cellBounds.Width - providerSize.Width - 25); int yearPosition = (int)(cellBounds.X + titleSize.Width); int altTitlePosition = (int)(cellBounds.X + titleSize.Width + yearSize.Width); // draw year RectangleF yearRect = new RectangleF(cellBounds.X + titleSize.Width, cellBounds.Y + 4, cellBounds.Width - providerSize.Width - 25, cellBounds.Height); graphics.DrawString(yearText, DataGridView.Font, SystemBrushes.ControlDark, yearRect); // draw alternate title if needed if (match.Result.AlternateTitleUsed()) { graphics.DrawString(altTitleText, DataGridView.Font, SystemBrushes.ControlDark, altTitlePosition, cellBounds.Y + 4); } // draw data provider if needed if (!string.IsNullOrEmpty(providerName)) { bool uncertainMatch = match.Result.TitleScore > 0 || match.Result.YearScore > 0; if (MovingPicturesCore.Settings.AlwaysDisplayProviderTags || !match.Result.FromTopSource || (uncertainMatch && match.HasMultipleSources)) { graphics.FillRectangle(SystemBrushes.ControlLight, providerPosition + 1, cellBounds.Y + 4, providerSize.Width + 1, cellBounds.Height - 10); graphics.DrawString(providerName, DataGridView.Font, SystemBrushes.ControlDark, providerPosition + 1, cellBounds.Y + 4); } } }
public void Perform(PossibleMatch Match, Actor Actor) { if (Actor.ConnectedClient != null) { var builder = new StringBuilder(); foreach (var command in Mud.ParserCommandHandler.Parser.Commands) { builder.Append(command.Matcher.Emit()); builder.Append(" -- "); builder.Append(command.HelpText); builder.Append("\r\n"); } Mud.SendEventMessage(Actor, EventMessageScope.Single, builder.ToString()); } }
public void Perform(PossibleMatch Match, Actor Actor) { var target = Match.Arguments["TARGET"] as IDescribed; if (Actor.ConnectedClient != null) { if (target == null) { Mud.SendEventMessage(Actor, EventMessageScope.Single, "That object is indescribeable.\r\n"); } else { Mud.SendEventMessage(Actor, EventMessageScope.Single, target.Long.Expand(Actor, target as MudObject) + "\r\n"); } } }
public void Perform(PossibleMatch Match, Actor Actor) { if (Actor.ConnectedClient != null) { var builder = new StringBuilder(); foreach (var command in Mud.ParserCommandHandler.Parser.Commands) { builder.Append(command.Matcher.Emit()); builder.Append(" -- "); builder.Append(command.HelpText); builder.Append("\r\n"); } Mud.SendEventMessage(Actor, EventMessageScope.Single, builder.ToString()); } }
protected override void OnDrawItem(DrawItemEventArgs e) { // draw the basic combo chrome (no text) base.OnDrawItem(e); e.DrawBackground(); e.DrawFocusRectangle(); // bail if we have nothing to paint if (e.Index < 0 || e.Index >= this.Items.Count) { return; } PossibleMatch match = (PossibleMatch)this.Items[e.Index]; string yearText = "(" + match.Movie.Year + ")"; string altTitleText = "as " + match.Result.AlternateTitle; // figure basic positioning SizeF providerSize = e.Graphics.MeasureString(match.Movie.PrimarySource.Provider.Name, e.Font); SizeF titleSize = e.Graphics.MeasureString(match.Movie.Title, e.Font); SizeF yearSize = e.Graphics.MeasureString(yearText, e.Font); RectangleF titleRect = new RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - (providerSize.Width + 3), e.Bounds.Height); int altTitlePosition = (int)(e.Bounds.X + titleSize.Width + yearSize.Width + 5); int providerPosition = (int)(e.Bounds.X + e.Bounds.Width - providerSize.Width - 3); // paint title using (Brush titleBrush = new SolidBrush(e.ForeColor)) { e.Graphics.DrawString(match.Movie.Title, e.Font, titleBrush, titleRect); } // paint year RectangleF yearRect = new RectangleF(Bounds.X + titleSize.Width + 5, e.Bounds.Y, e.Bounds.Width - (providerSize.Width + 3), e.Bounds.Height); e.Graphics.DrawString("(" + match.Movie.Year + ")", e.Font, SystemBrushes.ControlDark, yearRect); // paint alternate title if needed if (match.Result.AlternateTitleUsed()) { e.Graphics.DrawString(altTitleText, e.Font, SystemBrushes.ControlDark, altTitlePosition, e.Bounds.Y); } // paint provider e.Graphics.FillRectangle(SystemBrushes.ControlLight, providerPosition + 1, e.Bounds.Y + 1, providerSize.Width, e.Bounds.Height - 3); e.Graphics.DrawRectangle(SystemPens.ControlDark, providerPosition + 1, e.Bounds.Y + 1, providerSize.Width, e.Bounds.Height - 3); e.Graphics.DrawString(match.Movie.PrimarySource.Provider.Name, e.Font, SystemBrushes.ControlDark, providerPosition + 1, e.Bounds.Y); }
public override bool Equals(object obj) { if (obj == null) { return(false); } PossibleMatch objAsPart = obj as PossibleMatch; if (objAsPart == null) { return(false); } else { return(Equals(objAsPart)); } }
public bool Contains(PossibleMatch other) { if (other.MatchObjects.Count >= MatchObjects.Count) { return(false); } int matchingIndex = MatchObjects.FindIndex(obj => obj.Equals(other.MatchObjects.First())); if (matchingIndex == -1 || MatchObjects.Count - matchingIndex < other.MatchObjects.Count) { return(false); } GridObject[] matchObjectsPart = new GridObject[other.MatchObjects.Count()]; MatchObjects.CopyTo(matchingIndex, matchObjectsPart, 0, other.MatchObjects.Count() + matchingIndex - 1); return(new List <GridObject> (matchObjectsPart).SequenceEqual(other.MatchObjects)); }
private void manualAssignButton_Click(object sender, EventArgs e) { unapprovedGrid.EndEdit(); foreach (DataGridViewRow currRow in unapprovedGrid.SelectedRows) { MovieMatch selectedMatch = (MovieMatch)currRow.DataBoundItem; ManualAssignPopup popup = new ManualAssignPopup(selectedMatch); popup.ShowDialog(this); if (popup.DialogResult == DialogResult.OK) { // create a movie with the user supplied information DBMovieInfo movie = new DBMovieInfo(); movie.Title = popup.Title; movie.Year = popup.Year.GetValueOrDefault(0); // update the match PossibleMatch selectedMovie = new PossibleMatch(); selectedMovie.Movie = movie; MatchResult result = new MatchResult(); result.TitleScore = 0; result.YearScore = 0; result.ImdbMatch = true; selectedMovie.Result = result; selectedMatch.PossibleMatches.Add(selectedMovie); selectedMatch.Selected = selectedMovie; ThreadStart actions = delegate { // Manually Assign Movie MovingPicturesCore.Importer.ManualAssign(selectedMatch); }; Thread thread = new Thread(actions); thread.Name = "ManualUpdateThread"; thread.IsBackground = true; thread.Start(); } } }
public void Perform(PossibleMatch Match, Actor Actor) { if (Actor.ConnectedClient == null) { return; } Object target = null; if (Match.Arguments.ContainsKey("TARGET")) { target = Match.Arguments["TARGET"]; } else { target = Actor.Location; } var data = new StringBuilder(); data.Append(target.GetType().Name); data.Append("\r\n"); foreach (var field in target.GetType().GetFields()) { data.Append(field.FieldType.Name); data.Append(" "); data.Append(field.Name); data.Append(" = "); var value = field.GetValue(target); if (value == null) { data.Append("null"); } else { data.Append(value.ToString()); } data.Append("\r\n"); } Actor.ConnectedClient.Send(data.ToString()); }
public void Perform(PossibleMatch Match, Actor Actor) { if (Actor.ConnectedClient == null) return; var builder = new StringBuilder(); if (Actor.Inventory.Count == 0) builder.Append("You have nothing."); else { builder.Append("You are carrying..\r\n"); foreach (var item in Actor.Inventory) { builder.Append(" "); builder.Append(item.Short); builder.Append("\r\n"); } } Mud.SendEventMessage(Actor, EventMessageScope.Single, builder.ToString()); }
public void Perform(PossibleMatch Match, Actor Actor) { var target = Match.Arguments["TARGET"] as Thing; if (target == null) { if (Actor.ConnectedClient != null) Actor.ConnectedClient.Send("Take what again?\r\n"); } else { var takeRules = target as ITakeRules; if (takeRules != null && !takeRules.CanTake(Actor)) { Actor.ConnectedClient.Send("You can't take that.\r\n"); return; } Mud.SendEventMessage(Actor, EventMessageScope.Single, "You take " + target.Short + "\r\n"); Mud.SendEventMessage(Actor, EventMessageScope.External, Actor.Short + " takes " + target.Short + "\r\n"); Thing.Move(target, Actor); } }
public List <MudObject> GetObjects(PossibleMatch State, MatchContext Context) { NPC source = null; if (!String.IsNullOrEmpty(LocutorArgument)) { source = State[LocutorArgument] as NPC; } else if (Context.ExecutingActor.HasProperty <NPC>("interlocutor")) { source = Context.ExecutingActor.GetProperty <NPC>("interlocutor"); } if (source != null) { if (source.HasProperty <List <MudObject> >("conversation-topics")) { return(new List <MudObject>(source.GetProperty <List <MudObject> >("conversation-topics").Where(t => Core.GlobalRules.ConsiderCheckRuleSilently("topic available?", Context.ExecutingActor, source, t) == CheckResult.Allow))); } } return(new List <MudObject>()); }
public void Add(PossibleMatch possibleMatch) { List <PossibleMatch> value; if (LookupMatchesBySwitch.TryGetValue(possibleMatch.Switch, out value)) { if (!value.Any(otherMatch => otherMatch.EqualsOrContains(possibleMatch))) { IEnumerable <PossibleMatch> smaller = value.Where(otherMatch => possibleMatch.Contains(otherMatch)); foreach (PossibleMatch smallerMatch in smaller) { value.Remove(smallerMatch); } value.Add(possibleMatch); } } else { value = new List <PossibleMatch> (); value.Add(possibleMatch); LookupMatchesBySwitch.Add(possibleMatch.Switch, value); } }
public void Perform(PossibleMatch Match, Actor Actor) { var speechBuilder = new StringBuilder(); speechBuilder.Append(Actor.Short); if (EmoteType == EmoteTypes.Speech) speechBuilder.Append(": \""); else speechBuilder.Append(" "); for (var node = Match.Arguments["SPEECH"] as LinkedListNode<String>; node != null; node = node.Next) { speechBuilder.Append(node.Value); speechBuilder.Append(" "); } speechBuilder.Remove(speechBuilder.Length - 1, 1); if (EmoteType == EmoteTypes.Speech) speechBuilder.Append("\"\r\n"); else speechBuilder.Append("\r\n"); Mud.SendEventMessage(Actor, EventMessageScope.Local, speechBuilder.ToString()); }
public PossibleMatch(PossibleMatch original) { Controller = original.Controller; Switch = original.Switch.Duplicate(); MatchObjects = new List <GridObject> (original.MatchObjects); }
public void Perform(PossibleMatch Match, Actor Actor) { if (Actor.ConnectedClient != null) Actor.ConnectedClient.Send(Message); }
public PossibleMatches PossibleMatches() { if (CachedPossibleMatches == null) { CachedPossibleMatches = new PossibleMatches(); foreach (List <Vector3> row in grid.Successions()) { bool isAtEndOfMatch = false; PossibleMatch currentMatch = new PossibleMatch(this); PossibleMatch nextMatch = null; foreach (Vector3 point in row) { GridObject currentObject = grid.ObjectAt(point); if (nextMatch == null || !nextMatch.MatchObjects.Contains(currentObject)) { bool currentMatchFromNextMatch = false; if (nextMatch != null) { if (nextMatch.MatchObjects.Count > 0) { Debug.Log("setting current match from next match. next match start " + nextMatch.MatchObjects.First().Position() + " next match end: " + nextMatch.MatchObjects.Last().Position() + " current object: " + currentObject.Position()); } else { Debug.Log("EMPTY: setting current match from next match EMPTY"); } currentMatch = nextMatch; nextMatch = null; currentMatchFromNextMatch = true; } if (currentMatch.Matches(currentObject)) { currentMatch.AddMatch(currentObject); } else { isAtEndOfMatch = true; } int trailingIndex = row.IndexOf(point); if (row.Count() == trailingIndex) { isAtEndOfMatch = true; } // split if (isAtEndOfMatch) { bool foundSplit = false; if (trailingIndex + 1 < row.Count()) { GridObject nextNextObj = grid.ObjectAt(row.ElementAt(trailingIndex + 1)); if (currentMatch.Matches(nextNextObj)) { PossibleMatch splitMatch = currentMatch.Duplicate(); splitMatch.Switch.Inhibitor = currentObject; splitMatch.AddMatch(nextNextObj); List <GridObject> perpMatches = new List <GridObject> (); foreach (GridObject matchObj in grid.AdjacentGridObjects(currentObject)) { if (splitMatch.Matches(matchObj)) { perpMatches.Add(matchObj); } } // if we have a perpendicular match, see if there's enough for a split if (perpMatches.Count() > 0) { int sequenceIndex = trailingIndex; bool isAtEnd = false; nextMatch = new PossibleMatch(this); nextMatch.AddMatch(nextNextObj); while (!isAtEnd) { sequenceIndex = sequenceIndex + 1; if (sequenceIndex < row.Count()) { nextNextObj = grid.ObjectAt(row.ElementAt(sequenceIndex)); if (splitMatch.Matches(nextNextObj)) { splitMatch.AddMatch(nextNextObj); nextMatch.AddMatch(nextNextObj); } else { isAtEnd = true; } } else { isAtEnd = true; } } if (splitMatch.HasPotentialPossibleMatch()) { foundSplit = true; foreach (GridObject matchObj in perpMatches) { PossibleMatch perpMatch = splitMatch.Duplicate(); perpMatch.Switch.Trigger = matchObj; CachedPossibleMatches.Add(perpMatch); } } } } } if (currentMatch.HasPotentialPossibleMatch()) { // leading if (!currentMatchFromNextMatch) { int leadingIndex = row.FindIndex(pt => pt == currentMatch.MatchObjects.First().Position()) - 1; if (leadingIndex >= 0) { GridObject leadingObj = grid.ObjectAt(row.ElementAt(leadingIndex)); foreach (GridObject matchObj in grid.AdjacentGridObjects(leadingObj)) { if (currentMatch.Matches(matchObj)) { PossibleMatch leadingMatch = currentMatch.Duplicate(); leadingMatch.Switch.Inhibitor = leadingObj; leadingMatch.Switch.Trigger = matchObj; CachedPossibleMatches.Add(leadingMatch); } } } } // trailing if (!foundSplit) { foreach (GridObject matchObj in grid.AdjacentGridObjects(currentObject)) { if (currentMatch.Matches(matchObj)) { PossibleMatch trailingMatch = currentMatch.Duplicate(); trailingMatch.Switch.Inhibitor = currentObject; trailingMatch.Switch.Trigger = matchObj; CachedPossibleMatches.Add(trailingMatch); } } } } isAtEndOfMatch = false; currentMatch = new PossibleMatch(this); currentMatch.AddMatch(currentObject); } } } // have to check if the final match is big enough } } return(CachedPossibleMatches); }
private void manualAssignButton_Click(object sender, EventArgs e) { unapprovedGrid.EndEdit(); foreach (DataGridViewRow currRow in unapprovedGrid.SelectedRows) { MusicVideoMatch selectedMatch = (MusicVideoMatch)currRow.DataBoundItem; DBLocalMedia mediaToPlay = selectedMatch.LocalMedia[0]; if (mediaToPlay.State != MediaState.Online) mediaToPlay.Mount(); while (mediaToPlay.State != MediaState.Online) { Thread.Sleep(1000); }; ManualAssignPopup popup = new ManualAssignPopup(selectedMatch); popup.ShowDialog(this); if (popup.DialogResult == DialogResult.OK) { // create a musicvideo with the user supplied information DBTrackInfo mv = new DBTrackInfo(); mv.Track = popup.Track; if (popup.Album.Trim().Length > 0) { DBAlbumInfo db1 = DBAlbumInfo.Get(popup.Album); if (db1 == null) db1 = new DBAlbumInfo(); db1.Album = popup.Album; mv.AlbumInfo.Add(db1); } DBArtistInfo db2 = DBArtistInfo.Get(popup.Artist); if (db2 == null) { db2 = new DBArtistInfo(); db2.Artist = popup.Artist; } mv.ArtistInfo.Add(db2); foreach (DBSourceInfo r1 in mvCentralCore.DataProviderManager.AllSources) { if (r1.Provider is ManualProvider) { mv.PrimarySource = r1; mv.ArtistInfo[0].PrimarySource = r1; if (mv.AlbumInfo != null && mv.AlbumInfo.Count > 0) mv.AlbumInfo[0].PrimarySource = r1; } } // We have DVD and set to split DVD into chapters // This is a great idea that falls flat for two reasons.. // 1. There is not decent source of DVD/Track info // 2. Even if the tracks were split out and named I have yet to find a method of playing a single track from a DVD // For now will skip this bool dothisCodeBlock = false; // Split the DVD into chapters if (selectedMatch.LocalMedia[0].IsDVD && cbSplitDVD.Checked && dothisCodeBlock) { string videoPath = mediaToPlay.GetVideoPath(); if (videoPath == null) videoPath = selectedMatch.LongLocalMediaString; string pathlower = Path.GetDirectoryName(videoPath).ToLower(); pathlower = pathlower.Replace("\\video_ts", ""); pathlower = pathlower.Replace("\\adv_obj", ""); pathlower = pathlower.Replace("\\bdmv", ""); if (pathlower.Length < 3) pathlower = pathlower + "\\"; ChapterExtractor ex = Directory.Exists(Path.Combine(pathlower, "VIDEO_TS")) ? new DvdExtractor() as ChapterExtractor : Directory.Exists(Path.Combine(pathlower, "ADV_OBJ")) ? new HddvdExtractor() as ChapterExtractor : Directory.Exists(Path.Combine(Path.Combine(pathlower, "BDMV"), "PLAYLIST")) ? new BlurayExtractor() as ChapterExtractor : null; if (ex != null) { List<ChapterInfo> rp = ex.GetStreams(pathlower, 1); if (mediaToPlay.IsMounted) { mediaToPlay.UnMount(); while (mediaToPlay.IsMounted) { Thread.Sleep(1000); }; } foreach (ChapterInfo ci in rp) { foreach (ChapterEntry c1 in ci.Chapters) { //skip menus/small crap // if (c1.Time.TotalSeconds < 20) continue; DBTrackInfo db1 = new DBTrackInfo(); db1.Copy(mv); db1.TitleID = ci.TitleID; db1.Track = "Chapter " + ci.TitleID.ToString("##") + " - " + c1.chId.ToString("##"); db1.Chapter = "Chapter " + c1.chId.ToString("##"); db1.ChapterID = c1.chId; db1.PlayTime = c1.Time.ToString(); db1.OffsetTime = c1.OffsetTime.ToString(); db1.ArtistInfo.Add(mv.ArtistInfo[0]); if (mv.AlbumInfo != null && mv.AlbumInfo.Count > 0) db1.AlbumInfo.Add(mv.AlbumInfo[0]); db1.LocalMedia.Add(selectedMatch.LocalMedia[0]); db1.Commit(); } } selectedMatch.LocalMedia[0].UpdateMediaInfo(); selectedMatch.LocalMedia[0].Commit(); mvStatusChangedListener(selectedMatch, MusicVideoImporterAction.COMMITED); // ReloadList(); return; } } // update the match PossibleMatch selectedMV = new PossibleMatch(); selectedMV.MusicVideo = mv; MatchResult result = new MatchResult(); result.TitleScore = 0; result.YearScore = 0; result.MdMatch = true; selectedMV.Result = result; selectedMatch.PossibleMatches.Add(selectedMV); selectedMatch.Selected = selectedMV; ThreadStart actions = delegate { // Manually Assign Movie mvCentralCore.Importer.ManualAssign(selectedMatch); }; Thread thread = new Thread(actions); thread.Name = "ManualUpdateThread"; thread.Start(); } } }
public bool EqualsOrContains(PossibleMatch other) { return(Equals(other) || Contains(other)); }
public List <MudObject> GetObjects(PossibleMatch State, MatchContext Context) { return(new List <MudObject>(ChatChannel.ChatChannels)); }
public bool SameMove(PossibleMatch other) { return(Switch.Equals(other.Switch)); }
public bool Equals(PossibleMatch other) { return(SameMove(other) && MatchObjects.SequenceEqual(other.MatchObjects)); }
public List <MudObject> GetObjects(PossibleMatch State, MatchContext Context) { return(new List <MudObject>(Clients.ConnectedClients.Where(c => c is NetworkClient && (c as NetworkClient).IsLoggedOn).Select(c => c.Player))); }