static void Project64Console() { // Source: https://www.pokemonemulators.com/project64/ ReportStart(); string url = @"https://i.imgur.com/zzCG56R.png"; using (Bitmap input = DownloadImage(url)) { IAsciifier asciifier = Asciifier.SectionedColor; asciifier.MaxDegreeOfParallelism = MaxCores; // Text ICharacterSet charset = CharacterSets.Bitmap; IAsciifyFont font = new BitmapAsciifyFont("Terminal", new Size(8, 12), charset); // Color Color background = Color.Black; AsciifyPalette palette = AsciifyPalette.WindowsConsole; // Asciify asciifier.Initialize(font, charset, palette); using (Bitmap prepared = asciifier.PrepareImage(input, 2, background)) using (Bitmap output = asciifier.AsciifyImage(prepared)) output.OpenInMSPaint(); } ReportEnd(); }
public override BattlegroundRelation Enqueue(ICharacterSet chrs) { BattlegroundRelation battlegroundRelation = base.Enqueue(chrs); ((GlobalBattlegroundQueue)this.ParentQueue).CheckBGCreation(); return(battlegroundRelation); }
public BattlegroundRelation(BattlegroundTeamQueue queue, ICharacterSet participants, bool isEnqueued) { this._queue = queue; this._participants = participants; this.IsEnqueued = isEnqueued; this._created = DateTime.Now; }
/// <summary> /// Make sure that Battleground.HasQueue is true before calling this method. /// Adds the given set of Characters to this team's queue. /// Will invite immediately if there are enough open slots and /// <see cref="WCell.RealmServer.Battlegrounds.Battleground.IsAddingPlayers"/> is true. /// </summary> /// <param name="chrs"></param> public BattlegroundRelation Enqueue(ICharacterSet chrs) { _battleground.EnsureContext(); var relation = new BattlegroundRelation(Queue, chrs); var shouldInvite = _battleground.IsAddingPlayers && chrs.CharacterCount <= OpenPlayerSlotCount; if (!shouldInvite) { Queue.Enqueue(relation); } else { ReservedSlots += chrs.CharacterCount; relation.IsEnqueued = false; } chrs.ForeachCharacter(chr => chr.ExecuteInContext(() => { var index = chr.Battlegrounds.AddRelation(relation); if (shouldInvite) { chr.Battlegrounds.InviteTo(this, index, relation); } })); return(relation); }
public BattlegroundRelation(BattlegroundTeamQueue queue, ICharacterSet participants, bool isEnqueued) { _queue = queue; _participants = participants; IsEnqueued = isEnqueued; _created = DateTime.Now; }
/// <summary> /// Make sure that Battleground.HasQueue is true before calling this method. /// Adds the given set of Characters to this team's queue. /// Will invite immediately if there are enough open slots and /// <see cref="P:WCell.RealmServer.Battlegrounds.Battleground.IsAddingPlayers" /> is true. /// </summary> /// <param name="chrs"></param> public BattlegroundRelation Enqueue(ICharacterSet chrs) { this._battleground.EnsureContext(); BattlegroundRelation relation = new BattlegroundRelation(this.Queue, chrs); bool shouldInvite = this._battleground.IsAddingPlayers && chrs.CharacterCount <= this.OpenPlayerSlotCount; if (!shouldInvite) { this.Queue.Enqueue(relation); } else { this.ReservedSlots += chrs.CharacterCount; relation.IsEnqueued = false; } chrs.ForeachCharacter((Action <Character>)(chr => chr.ExecuteInContext((Action)(() => { int queueIndex = chr.Battlegrounds.AddRelation(relation); if (!shouldInvite) { return; } chr.Battlegrounds.InviteTo(this, queueIndex, relation); })))); return(relation); }
public MorseCodeEngine(MorseCodeEngineConfiguration configuration, ICharacterSet morseCharacterSet, IDisplayEngine displayEngine) { _configuration = configuration; MorseCharacterSet = morseCharacterSet; ProcessCharacterSet(MorseCharacterSet); DisplayEngine = displayEngine; }
static void EyeBlackAndWhite() { // Source: https://mathematica.stackexchange.com/questions/42638/creating-an-image-from-data-not-in-grayscale ReportStart(); string url = @"http://i.stack.imgur.com/397vv.png"; using (Bitmap input = DownloadImage(url)) { IAsciifier asciifier = Asciifier.DotIntensity; //asciifier.AllFactor asciifier.MaxDegreeOfParallelism = MaxCores; // Text ICharacterSet charset = CharacterSets.Default; IAsciifyFont font = new TrueTypeAsciifyFont("Lucida Console", 10, FontStyle.Bold, charset, true); // Color asciifier.ColorLow = Gray(130); //asciifier.ColorHigh = Gray(220); Color background = Color.Gray; //List<Color> colors = PaletteChooser.FindMainColorsByLab(input, 256, 1.5); //colors = PaletteChooser.FindMainColorsByHsb(input, 256, 0.1f, 0.001f, 0.001f); //AsciifyPalette palette = new AsciifyPalette(colors, background: background); //List<Color> colors = PaletteChooser.FindMainColorsByLab(input, 16, 14); //colors = PaletteChooser.FindMainColorsByHsb(input, 256, 0.1f, 0.001f, 0.001f); AsciifyPalette palette = AsciifyPalette.BlackOnWhite; // Asciify asciifier.Initialize(font, charset, palette); using (Bitmap prepared = asciifier.PrepareImage(input, 3, background)) using (Bitmap output = asciifier.AsciifyImage(prepared)) output.OpenInMSPaint(); } ReportEnd(); }
static void MakinaRoger() { // Source: Grisaia no Kajitsu ReportStart(); string url = @"https://i.imgur.com/KDxsmOd.png"; using (Bitmap input = DownloadImage(url)) { IAsciifier asciifier = Asciifier.SectionedColor; asciifier.MaxDegreeOfParallelism = MaxCores; // Text ICharacterSet charset = CharacterSets.Default; IAsciifyFont font = new TrueTypeAsciifyFont("Lucida Console", 10, FontStyle.Bold, charset, true); // Color Color background = DiscordDark; List <Color> colors = PaletteChooser.FindMainColorsByLab(input, 256, 7); AsciifyPalette palette = new AsciifyPalette(colors, background: background); // Asciify asciifier.Initialize(font, charset, palette); using (Bitmap prepared = asciifier.PrepareImage(input, 1, background)) using (Bitmap output = asciifier.AsciifyImage(prepared)) output.OpenInMSPaint(); } ReportEnd(); }
/// <summary>Enqueues the given Character(s) for the given side</summary> public BattlegroundRelation Enqueue(ICharacterSet chrs, BattlegroundSide side) { BattlegroundTeamQueue teamQueue = this.GetTeamQueue(side); BattlegroundRelation request = new BattlegroundRelation(teamQueue, chrs); teamQueue.Enqueue(request); return(request); }
public override BattlegroundRelation Enqueue(ICharacterSet chrs) { var relation = base.Enqueue(chrs); ((GlobalBattlegroundQueue)ParentQueue).CheckBGCreation(); return relation; }
public virtual BattlegroundRelation Enqueue(ICharacterSet chrs) { BattlegroundRelation request = new BattlegroundRelation(this, chrs); chrs.ForeachCharacter((Action <Character>)(chr => chr.ExecuteInContext((Action)(() => chr.Battlegrounds.AddRelation(request))))); this.Enqueue(request); return(request); }
/// <summary> /// Enqueues the given Character(s) for the given side /// </summary> public BattlegroundRelation Enqueue(ICharacterSet chrs, BattlegroundSide side) { var queue = GetTeamQueue(side); var request = new BattlegroundRelation(queue, chrs); queue.Enqueue(request); return(request); }
public BitmapAsciifyFont(BitmapFont font, ICharacterSet ranges = null) { Font = font; Size = font.Size; if (ranges == null) { ranges = CharacterSets.Bitmap; } CharacterSet = ranges; }
public BattlegroundRelation Enqueue(Character chr, bool asGroup) { ICharacterSet characterSet = this.GetCharacterSet(chr, asGroup); if (characterSet != null) { return(this.Enqueue(characterSet)); } return((BattlegroundRelation)null); }
public CharacterSetCheckBox(ICharacterSet set) { if (set == null) throw new ArgumentNullException("set"); _set = set; MinWidth = 300; Content = set.Name; Margin = new Thickness(0); }
public virtual BattlegroundRelation Enqueue(ICharacterSet chrs) { var request = new BattlegroundRelation(this, chrs); chrs.ForeachCharacter(chr => chr.ExecuteInContext(() => { chr.Battlegrounds.AddRelation(request); })); Enqueue(request); return(request); }
private static string GenerateStringCode(int length, ICharacterSet characterSet) { var result = new char[length]; var i = 0; foreach (var c in GenerateCodeInternal(length, characterSet)) { result[i++] = c; } return(new string(result)); }
public static ICharacterSet ToUpper(this ICharacterSet set) { var result = new char[set.Count]; var i = 0; foreach (var c in set) { result[i++] = Char.ToUpperInvariant(c); } return(FromChars(result)); }
public CharacterSetCheckBox(ICharacterSet set) { if (set == null) { throw new ArgumentNullException("set"); } _set = set; MinWidth = 300; Content = set.Name; Margin = new Thickness(0); }
public CharacterDialog(string title) : base(Font.MediumFont, title, Lcd.Width, Lcd.Height-22) { characterInnerBox = new Point(characterSize, characterSize); characterOutherBox = new Point(characterInnerBox.X + 2* characterEdge, characterInnerBox.Y + 2* characterEdge); alfabetSet = new ICharacterSet[]{new SmallLetters(), new BigLetters()}; symboleSet = new ICharacterSet[]{new NumbersAndSymbols(), new NumbersAndSymbols2()}; selectedSet = alfabetSet[selectedSetIndex]; setTypeString = symboleSetString; resultRect = new Rectangle(new Point(innerWindow.P1.X+characterEdge, innerWindow.P2.Y - (int)Font.MediumFont.maxHeight -1 ), new Point(innerWindow.P2.X-characterEdge, innerWindow.P2.Y -1)); resultRectSmall = new Rectangle(new Point(innerWindow.P1.X+characterEdge, innerWindow.P2.Y - (int)Font.SmallFont.maxHeight -1 ), new Point(innerWindow.P2.X-characterEdge, innerWindow.P2.Y -1)); lineRect = new Rectangle(new Point(innerWindow.P1.X+characterEdge, innerWindow.P2.Y - 2*((int)Font.SmallFont.maxHeight -1 )), new Point(innerWindow.P2.X-characterEdge, innerWindow.P2.Y -((int)Font.SmallFont.maxHeight -1 ))); resultString = ""; }
public CharacterDialog(Lcd lcd, Buttons btns, string title) : base(Font.MediumFont, lcd, btns, title, Lcd.Width, Lcd.Height - 22) { characterInnerBox = new Point(characterSize, characterSize); characterOutherBox = new Point(characterInnerBox.X + 2 * characterEdge, characterInnerBox.Y + 2 * characterEdge); alfabetSet = new ICharacterSet[] { new SmallLetters(), new BigLetters() }; symboleSet = new ICharacterSet[] { new NumbersAndSymbols(), new NumbersAndSymbols2() }; selectedSet = alfabetSet[selectedSetIndex]; setTypeString = symboleSetString; resultRect = new Rectangle(new Point(dialogWindowInner.P1.X + characterEdge, dialogWindowInner.P2.Y - (int)Font.MediumFont.maxHeight - 1), new Point(dialogWindowInner.P2.X - characterEdge, dialogWindowInner.P2.Y - 1)); resultRectSmall = new Rectangle(new Point(dialogWindowInner.P1.X + characterEdge, dialogWindowInner.P2.Y - (int)Font.SmallFont.maxHeight - 1), new Point(dialogWindowInner.P2.X - characterEdge, dialogWindowInner.P2.Y - 1)); lineRect = new Rectangle(new Point(dialogWindowInner.P1.X + characterEdge, dialogWindowInner.P2.Y - 2 * ((int)Font.SmallFont.maxHeight - 1)), new Point(dialogWindowInner.P2.X - characterEdge, dialogWindowInner.P2.Y - ((int)Font.SmallFont.maxHeight - 1))); resultString = ""; }
/// <summary> /// Generates the password for a new entry. /// </summary> /// <returns></returns> public static string NewEntry() { var sets = new ICharacterSet[] { new UpperCaseSet(), new LowerCaseSet(), new DigitsSet(), } .SelectMany(x => x.Characters) .ToArray(); return new GenerationResults(sets, 20) .Generate(); }
/// <summary> /// Generates the password for a new entry. /// </summary> /// <returns></returns> public static string NewEntry() { var sets = new ICharacterSet[] { new UpperCaseSet(), new LowerCaseSet(), new DigitsSet(), } .SelectMany(x => x.Characters) .ToArray(); return(new GenerationResults(sets, 20) .Generate()); }
private static IEnumerable <char> GenerateCodeInternal(int length, ICharacterSet characterSet) { var setCount = characterSet.Count; if (setCount < 2) { throw new ApplicationException("The set must have at least two characters"); } for (int i = 0; i < length; i++) { yield return(characterSet[_random.Next(0, setCount)]); } }
public static bool Validate(this ICharacterSet set, string s) { if (String.IsNullOrEmpty(s)) { return(true); } for (var i = 0; i < s.Length; i++) { if (!set.Contains(s[i])) { return(false); } } return(true); }
public TrueTypeAsciifyFont(string name, Size size, FontStyle style, ICharacterSet range = null, bool removeNonMonospace = false) { if (range == null) { range = CharacterSets.Default; } Family = name; Style = style; Size = size; CharacterSet = range; CalculateFontSize(removeNonMonospace); CalculateOffset(); //CalculateMaxIntensity(); }
protected void DoTryJoin(Character chr, bool asGroup, BattlegroundSide side) { this.EnsureContext(); if (!chr.IsInWorld || !this.IsOpen) { return; } BattlegroundTeam team = this.GetTeam(side); ICharacterSet characterSet = this._instanceQueue.GetTeamQueue(side).GetCharacterSet(chr, asGroup); if (characterSet == null) { return; } team.Enqueue(characterSet); }
private bool ChangeSetType () { selectedSetIndex = 0; if (showAlfabet) { selectedSet = symboleSet [selectedSetIndex]; showAlfabet = false; setTypeString = alfabetSetString; } else { selectedSet = alfabetSet [selectedSetIndex]; showAlfabet = true; setTypeString = symboleSetString; } return false; }
public int Invite(ICharacterSet chrs) { int added = 0; this.ReservedSlots += chrs.CharacterCount; chrs.ForeachCharacter((Action <Character>)(chr => { if (!chr.IsInWorld) { return; } chr.ExecuteInContext((Action)(() => chr.Battlegrounds.InviteTo(this))); ++added; })); return(added); }
public int Invite(ICharacterSet chrs) { var added = 0; ReservedSlots += chrs.CharacterCount; chrs.ForeachCharacter(chr => { if (chr.IsInWorld) { chr.ExecuteInContext(() => { chr.Battlegrounds.InviteTo(this); }); ++added; } }); return(added); }
private bool ChangeSetType() { selectedSetIndex = 0; if (showAlfabet) { selectedSet = symboleSet [selectedSetIndex]; showAlfabet = false; setTypeString = alfabetSetString; } else { selectedSet = alfabetSet [selectedSetIndex]; showAlfabet = true; setTypeString = symboleSetString; } return(false); }
private bool PreviousSet() { if (showAlfabet) { selectedSetIndex--; if (selectedSetIndex < 0) { selectedSetIndex = alfabetSet.Length - 1; } selectedSet = alfabetSet[selectedSetIndex]; } else { selectedSetIndex--; if (selectedSetIndex < 0) { selectedSetIndex = symboleSet.Length - 1; } selectedSet = symboleSet[selectedSetIndex]; } return(false); }
private bool NextSet() { if (showAlfabet) { selectedSetIndex++; if (selectedSetIndex >= alfabetSet.Length) { selectedSetIndex = 0; } selectedSet = alfabetSet[selectedSetIndex]; } else { selectedSetIndex++; if (selectedSetIndex >= symboleSet.Length) { selectedSetIndex = 0; } selectedSet = symboleSet[selectedSetIndex]; } return(false); }
internal void ProcessCharacterSet(ICharacterSet characterSet) { _workingConverter = new Dictionary <char, List <int> >(); var dotDash = new Dictionary <char, int> { { '.', _configuration.DotLengthInMilliseconds }, { '-', _configuration.DashLengthInMilliseconds } }; MorseCharacterSet.CharacterList.ForEach(x => { var morseCharArray = x.Morse.ToCharArray(); List <int> parsedMorse = morseCharArray.ToList().Select(character => { if (!dotDash.ContainsKey(character)) { throw new ArgumentOutOfRangeException("CharacterMapping", x, string.Format("CharacterMapping contains an invalid character of {0}", character)); } return(dotDash[character]); }).ToList(); _workingConverter.Add(x.Character, parsedMorse); }); }
static void PsychoPassGrayscale() { // Source: http://www.nerdgasmneeds.com/2016/02/new-psycho-pass-dominator-replica-video.html ReportStart(); string url = @"http://www.nerdgasmneeds.com/wp/wp-content/uploads/2016/02/psycho-pass-dominator-art-03.png"; using (Bitmap input = DownloadImage(url, nameof(PsychoPass))) { ISectionedAsciifier asciifier = Asciifier.SectionedIntensity; //asciifier.AllFactor asciifier.MaxDegreeOfParallelism = MaxCores; // Text ICharacterSet charset = CharacterSets.Default; IAsciifyFont font = new TrueTypeAsciifyFont("Lucida Console", 10, FontStyle.Bold, charset, true); //ICharacterSet charset = CharacterSets.Bitmap; //IAsciifyFont font = new BitmapAsciifyFont("Terminal", new Size(8, 12), charset); // Color asciifier.ColorLow = Gray(10); asciifier.ColorHigh = Gray(230); Color background = Color.Black; //List<Color> colors = PaletteChooser.FindMainColorsByLab(input, 256, 1.5); //colors = PaletteChooser.FindMainColorsByHsb(input, 256, 0.1f, 0.001f, 0.001f); //AsciifyPalette palette = new AsciifyPalette(colors, background: background); //List<Color> colors = PaletteChooser.FindMainColorsByLab(input, 16, 14); //colors = PaletteChooser.FindMainColorsByHsb(input, 256, 0.1f, 0.001f, 0.001f); AsciifyPalette palette = AsciifyPalette.FromGrayscale(0, 255, 16, background: background); // Asciify asciifier.Initialize(font, charset, palette); using (Bitmap prepared = asciifier.PrepareImage(input, 1.5, background)) using (Bitmap output = asciifier.AsciifyImage(prepared)) output.OpenInMSPaint(); } ReportEnd(); }
public void AddCharacterSet(ICharacterSet characterSet) { if (characterSet == null) throw new ArgumentNullException("characterSet"); byName.Add(characterSet.Name, characterSet); if (characterSet.ByteOrderMark != null) { var length = characterSet.ByteOrderMark.Length; if (!byLengthAndBom.ContainsKey(length)) byLengthAndBom.Add(length, new Dictionary<byte[], ICharacterSet> { { characterSet.ByteOrderMark, characterSet } }); else byLengthAndBom[length].Add(characterSet.ByteOrderMark, characterSet); } }
/// <summary> /// Make sure that Battleground.HasQueue is true before calling this method. /// Adds the given set of Characters to this team's queue. /// Will invite immediately if there are enough open slots and /// <see cref="WCell.RealmServer.Battlegrounds.Battleground.IsAddingPlayers"/> is true. /// </summary> /// <param name="chrs"></param> public BattlegroundRelation Enqueue(ICharacterSet chrs) { _battleground.EnsureContext(); var relation = new BattlegroundRelation(Queue, chrs); var shouldInvite = _battleground.IsAddingPlayers && chrs.Count <= OpenPlayerSlotCount; if (!shouldInvite) { Queue.Enqueue(relation); } else { ReservedSlots += chrs.Count; relation.IsEnqueued = false; } chrs.ForeachCharacter(chr => chr.ExecuteInContext(() => { var index = chr.Battlegrounds.AddRelation(relation); if (shouldInvite) { chr.Battlegrounds.InviteTo(this, index, relation); } })); return relation; }
public int Invite(ICharacterSet chrs) { var added = 0; ReservedSlots += chrs.Count; chrs.ForeachCharacter(chr => { if (chr.IsInWorld) { chr.ExecuteInContext(() => { chr.Battlegrounds.InviteTo(this); }); ++added; } }); return added; }
public virtual BattlegroundRelation Enqueue(ICharacterSet chrs) { var request = new BattlegroundRelation(this, chrs); chrs.ForeachCharacter(chr => chr.ExecuteInContext(() => { chr.Battlegrounds.AddRelation(request); })); Enqueue(request); return request; }
private bool PreviousSet() { if (showAlfabet) { selectedSetIndex--; if(selectedSetIndex < 0) selectedSetIndex = alfabetSet.Length-1; selectedSet = alfabetSet[selectedSetIndex]; } else { selectedSetIndex--; if(selectedSetIndex < 0) selectedSetIndex = symboleSet.Length-1; selectedSet = symboleSet[selectedSetIndex]; } return false; }
private bool NextSet() { if (showAlfabet) { selectedSetIndex++; if(selectedSetIndex >= alfabetSet.Length) selectedSetIndex = 0; selectedSet = alfabetSet[selectedSetIndex]; } else { selectedSetIndex++; if(selectedSetIndex >= symboleSet.Length) selectedSetIndex = 0; selectedSet = symboleSet[selectedSetIndex]; } return false; }
public BattlegroundRelation(BattlegroundTeamQueue queue, ICharacterSet participants) : this(queue, participants, true) { }