private int GetStartIndex(int position) { var target = new TagWrapper(Span.FromBounds(position, int.MaxValue)); var index = this.tagWrappers.BinarySearch(target, StartComparer.Instance); int result; if (index >= 0) { result = index; } else { result = ~index - 1; if (result >= 0 && this.tagWrappers[result].Span.End <= position) { result++; } else { result = Math.Max(0, result); } } return(result); }
private void OnAddTagExecute(string tagTitle) { if (!string.IsNullOrWhiteSpace(tagTitle)) { var tag = _repository.GetTagByTitle(tagTitle); var wrapper = new TagWrapper(tag); Tags.Add(wrapper); wrapper.PropertyChanged += Wrapper_PropertyChanged; ArchiveEntity.Model.Tags.Add(wrapper.Model); HasChanges = ArchiveEntity != null && !ArchiveEntity.HasErrors; } }
private void InitializeTags(ICollection <Tag> tags) { foreach (var wrapper in Tags) { wrapper.PropertyChanged -= Wrapper_PropertyChanged; } Tags.Clear(); foreach (var tag in tags) { tag.TagTitle = tag.TagTitle.Trim(); var wrapper = new TagWrapper(tag); Tags.Add(wrapper); wrapper.PropertyChanged += Wrapper_PropertyChanged; } }
public void Update(string rawMessage) { Message message = new Message(rawMessage); string fileName = Path.Combine("Maps", $"{message.Zone}-{message.Z}.png"); if (_oldMapFileName != fileName) //don't bother reloading the map if it will be the same { if (!File.Exists(fileName)) { RequestMap(fileName); return; } else { //request validation the file we have is the latest if (!ValidateAssets.AssetHashes.ContainsKey(fileName) && File.Exists(fileName)) { TagWrapper tagWrapper = new TagWrapper(); _telnetHandler.OutQueue.Enqueue($"VALIDATEASSET|{ fileName}"); } Image oldImage = pictureBox_Map.Image; Image map; using (MemoryStream ms = new MemoryStream(new FileIO().ReadBytes(fileName))) { map = Image.FromStream(ms); } using (Graphics g = Graphics.FromImage(map)) { Brush brush = new SolidBrush(Color.Red); g.FillRectangle(brush, int.Parse(message.X), ReverseY(int.Parse(message.Y), map) - 10, 10, 10); } pictureBox_Map.Image = map; oldImage?.Dispose(); } } }
private void OnDeleteTagExecute(string tagTitle) { TagWrapper tag = ArchiveEntity.Tags.Where(x => x.TagTitle == tagTitle).First(); var result = MessageDialogService.ShowOKCancelDialog($"Удалить метку {tagTitle}?", $"Удалить метку {tagTitle}?"); if (result == MessageDialogResult.OK) { if (tag != null) { ArchiveEntity.Tags.Remove(tag); tag.PropertyChanged -= Wrapper_PropertyChanged; var wrapper = Tags.Where(x => x.TagTitle == tagTitle).First(); Tags.Remove(wrapper); _repository.RemoveTag(ArchiveEntity.ArchiveEntityKey, tagTitle); HasChanges = ArchiveEntity != null && !ArchiveEntity.HasErrors; } } // RemoveItemFromEntityCollection(_fileOnDriveDataProvider.RemoveTagFromEntity, TagKey); }
private int GetEndIndex(int position) { var target = new TagWrapper(Span.FromBounds(0, position)); var index = this.tagWrappers.BinarySearch(target, EndComparer.Instance); int result; if (index >= 0) { result = index + 1; } else { result = ~index; if (result < this.tagWrappers.Length && this.tagWrappers[result].Span.Start < position) { result = Math.Min(this.tagWrappers.Length, result + 1); } } return(result); }