private void ParseTextStyleMappings() { this.parsedTextStyles = new Dictionary <string, CharFont[]>(); var textStyleMappings = rootElement.Element("TextStyleMappings"); if (textStyleMappings == null) { throw new InvalidOperationException("Cannot find TextStyleMappings element."); } foreach (var mappingElement in textStyleMappings.Elements("TextStyleMapping")) { var textStyleName = mappingElement.AttributeValue("name"); var charFonts = new CharFont[3]; foreach (var mapRangeElement in mappingElement.Elements("MapRange")) { var fontId = mapRangeElement.AttributeInt32Value("fontId"); var character = mapRangeElement.AttributeInt32Value("start"); var code = mapRangeElement.AttributeValue("code"); var codeMapping = rangeTypeMappings[code]; charFonts[(int)codeMapping] = new CharFont((char)character, fontId); } this.parsedTextStyles.Add(textStyleName, charFonts); } }
public SimpleWrite(CharFont font, String text, Vec2 at, float size) { this.font = font; this.text = text; this.at = at; this.size = size; }
public SimpleWrite(CharFont font, String text) { this.font = font; this.text = text; this.at = DefaultAt; this.size = DefaultSize; }
/// <summary> /// Creates a text sequence for a peptide sequence with modifications /// </summary> private static TextSequence CreateTextSequence(StringBuilder sb, CharFont charFont) { return(new TextSequence { Text = sb.ToString(), Font = charFont.Font, Color = charFont.Color }); }
/// <summary> /// Calculates whether there's enough screen area to draw the specified text and stuff /// </summary> /// <param name="text">The text to check</param> /// <param name="at">The location the text will be drawed at</param> /// <param name="size">The size of the text</param> /// <returns>Whether there's enough screen are to draw with the specified data</returns> public static bool IsSizeOk(CharFont font, String text, Vec2 at, float size) { Vec2 s; if (font.CalculateDrawWrappedSize(text, at, size, Stuff.ScreenWidth - at.X - WrapLessX, out s)) { return(at.Y + s.Y < Stuff.ScreenHeight - WrapLessY); } return(false); }
public void BindFont(CharFont cf) { SelectFont = cf; if (cf.GetName() == "HuaKang") { Type = HuaKang; Name = "HuaKang"; } Binded = true; }
/// <summary> /// Creates a SimpleWrite action with the specified CharFont and text. The size is /// calculated based on needed drawing area but wont exceed SimpleWrite.DefaultSize /// </summary> public static SimpleWrite CreateSimpleWrite(CharFont font, String text) { // suck it, optimization. Let's just f*****g try lowering the size slightly until it's good enough. float size = SimpleWrite.DefaultSize; while (!SimpleWrite.IsSizeOk(Program.font, text, SimpleWrite.DefaultAt, size)) { size -= 2; } return(new SimpleWrite(Program.font, text, size)); }
public DrawUndistortedChar(CharFont font, Vec2 min, Vec2 max, char c) { this.c = c; character = font.chars[c]; Vec2 size = new Vec2(max.X - min.X, max.Y - min.Y); scale = Math.Min(size.X / character.Width, size.Y / character.Height) * 0.925f; Vec2 center = new Vec2(min.X + size.X * 0.5f, min.Y + size.Y * 0.5f); at = new Vec2(center.X - character.Width * scale * 0.5f, center.Y - character.Height * scale * 0.5f); }
/// <summary> /// This method should be called when the application starts /// </summary> /// <param name="font">The CharFont to use to create the IActions</param> public static void Init(CharFont font) { actions = new IAction[] { CreateSimpleWrite(font, "Esta compu ha sido hackeada por la FBI!"), CreateSimpleWrite(font, "Somos Annonymous, hackeamos compus de ort. yey :D"), CreateSimpleWrite(font, "Un programa que escribe solo en paint? Ah ni tikero..."), CreateSimpleWrite(font, "No se me ocurre que mas poner que escriba este programa"), CreateSimpleWrite(font, "Buenos dias a todos los alumnos de ort! Suerte aprobando ranzo."), CreateSimpleWrite(font, "Necesitas clases de matematica? Llama a X:\nX=50x+33sin(50y)-30"), new DrawUndistortedChar(font, (char)1), new DrawUndistortedChar(font, (char)3), new DrawUndistortedChar(font, (char)4), CreateSimpleWrite(font, "Mandenme un mail y escribo lo que me digan!!!"), CreateSimpleWrite(font, "Daaleee, nadie me va a mandar nada? No sean asi...") //CreateSimpleWrite(font, ""), }; }
public FixedCharAtom(SourceSpan source, CharFont charFont) : base(source) { this.CharFont = charFont; }
public bool IsSameDisplay(CharFont charFont) { return ReferenceEquals(Font, charFont.Font) && Equals(Color, charFont.Color); }
/// <summary> /// Creates a text sequence for a peptide sequence with modifications /// </summary> private static TextSequence CreateTextSequence(StringBuilder sb, CharFont charFont) { return new TextSequence { Text = sb.ToString(), Font = charFont.Font, Color = charFont.Color }; }
public static TextSequence[] CreateTextSequences(PeptideDocNode nodePep, SrmSettings settings, string label, IDeviceContext g, ModFontHolder fonts) { // Store text and font information for all label types bool heavyMods = false; var listTypeSequences = new List<TextSequence> { CreateTypeTextSequence(nodePep, settings, IsotopeLabelType.light, fonts) }; foreach (var labelType in settings.PeptideSettings.Modifications.GetHeavyModificationTypes()) { // Only color for the label types actually measured in this peptide if (!nodePep.HasChildType(labelType)) continue; var textSequence = CreateTypeTextSequence(nodePep, settings, labelType, fonts); listTypeSequences.Add(textSequence); heavyMods = (heavyMods || textSequence != null); } // Calculate text sequence values for the peptide display string var listTextSequences = new List<TextSequence>(); if (nodePep.Peptide.IsCustomIon) listTextSequences.Add(CreatePlainTextSequence(nodePep.CustomIon.DisplayName, fonts)); // If no modifications, use a single plain text sequence else if (!heavyMods && !listTypeSequences[0].Text.Contains("[")) // Not L10N: For identifying modifications listTextSequences.Add(CreatePlainTextSequence(label, fonts)); else { string pepSequence = nodePep.Peptide.Sequence; int startPep = label.IndexOf(pepSequence, StringComparison.Ordinal); int endPep = startPep + pepSequence.Length; // Add prefix plain-text if necessary if (startPep > 0) { string prefix = label.Substring(0, startPep); listTextSequences.Add(CreatePlainTextSequence(prefix, fonts)); } // Enumerate amino acid characters coallescing their font information // into text sequences. var prevCharFont = new CharFont('.', fonts.Plain, Color.Black); // Not L10N: Amino acid format var indexes = new int[listTypeSequences.Count]; CharFont charFont; var sb = new StringBuilder(); while ((charFont = GetCharFont(indexes, listTypeSequences, fonts)) != null) { if (!charFont.IsSameDisplay(prevCharFont) && sb.Length > 0) { listTextSequences.Add(CreateTextSequence(sb, prevCharFont)); sb.Remove(0, sb.Length); } sb.Append(charFont.Character); prevCharFont = charFont; } // Add the last segment if (sb.Length > 0) listTextSequences.Add(CreateTextSequence(sb, prevCharFont)); // Add suffix plain-text if necessary if (endPep < label.Length) { string suffix = label.Substring(endPep); listTextSequences.Add(CreatePlainTextSequence(suffix, fonts)); } } if (g != null) { // Calculate placement for each text sequence int textRectWidth = 0; foreach (var textSequence in listTextSequences) { Size sizeMax = new Size(int.MaxValue, int.MaxValue); textSequence.Position = textRectWidth; textSequence.Width = TextRenderer.MeasureText(g, textSequence.Text, textSequence.Font, sizeMax, FORMAT_TEXT_SEQUENCE). Width; textRectWidth += textSequence.Width; } } return listTextSequences.ToArray(); }
void initialize() { textfont = new TextFontEx(texturemanager); initializeSprite(); }
public WriteRemoveWrite(CharFont font, String txt1, float size1, String txt2, float size2) { first = new SimpleWrite(font, txt1, size1); second = new SimpleWrite(font, txt2, size2); }
public bool IsSameDisplay(CharFont charFont) { return(ReferenceEquals(Font, charFont.Font) && Equals(Color, charFont.Color)); }
public DrawUndistortedChar(CharFont font, char c) : this(font, SimpleWrite.DefaultAt, new Vec2(Stuff.ScreenWidth - 30, Stuff.ScreenHeight - 127), c) { }
public FontWriterTool(CharFont c) { SelectFont = c; Binded = true; }
public static TextSequence[] CreateTextSequences(PeptideDocNode nodePep, SrmSettings settings, string label, IDeviceContext g, ModFontHolder fonts) { // Store text and font information for all label types bool heavyMods = false; var listTypeSequences = new List <TextSequence> { CreateTypeTextSequence(nodePep, settings, IsotopeLabelType.light, fonts) }; foreach (var labelType in settings.PeptideSettings.Modifications.GetHeavyModificationTypes()) { // Only color for the label types actually measured in this peptide if (!nodePep.HasChildType(labelType)) { continue; } var textSequence = CreateTypeTextSequence(nodePep, settings, labelType, fonts); listTypeSequences.Add(textSequence); heavyMods = (heavyMods || textSequence != null); } // Calculate text sequence values for the peptide display string var listTextSequences = new List <TextSequence>(); if (nodePep.Peptide.IsCustomIon) { listTextSequences.Add(CreatePlainTextSequence(nodePep.CustomIon.DisplayName, fonts)); } // If no modifications, use a single plain text sequence else if (!heavyMods && !listTypeSequences[0].Text.Contains("[")) // Not L10N: For identifying modifications { listTextSequences.Add(CreatePlainTextSequence(label, fonts)); } else { string pepSequence = nodePep.Peptide.Sequence; int startPep = label.IndexOf(pepSequence, StringComparison.Ordinal); int endPep = startPep + pepSequence.Length; // Add prefix plain-text if necessary if (startPep > 0) { string prefix = label.Substring(0, startPep); listTextSequences.Add(CreatePlainTextSequence(prefix, fonts)); } // Enumerate amino acid characters coallescing their font information // into text sequences. var prevCharFont = new CharFont('.', fonts.Plain, Color.Black); // Not L10N: Amino acid format var indexes = new int[listTypeSequences.Count]; CharFont charFont; var sb = new StringBuilder(); while ((charFont = GetCharFont(indexes, listTypeSequences, fonts)) != null) { if (!charFont.IsSameDisplay(prevCharFont) && sb.Length > 0) { listTextSequences.Add(CreateTextSequence(sb, prevCharFont)); sb.Remove(0, sb.Length); } sb.Append(charFont.Character); prevCharFont = charFont; } // Add the last segment if (sb.Length > 0) { listTextSequences.Add(CreateTextSequence(sb, prevCharFont)); } // Add suffix plain-text if necessary if (endPep < label.Length) { string suffix = label.Substring(endPep); listTextSequences.Add(CreatePlainTextSequence(suffix, fonts)); } } if (g != null) { // Calculate placement for each text sequence int textRectWidth = 0; foreach (var textSequence in listTextSequences) { Size sizeMax = new Size(int.MaxValue, int.MaxValue); textSequence.Position = textRectWidth; textSequence.Width = TextRenderer.MeasureText(g, textSequence.Text, textSequence.Font, sizeMax, FORMAT_TEXT_SEQUENCE). Width; textRectWidth += textSequence.Width; } } return(listTextSequences.ToArray()); }
// This method processes the main program. Main() ends up keeping track of whether it should kill // the program while this guy does all the actual hard work of drawing, checking mails, etc. static void ProcessStuff() { Stuff.Init(); Account.Init(); // Loads the font into memory from the .map files font = new CharFont("CharFiles/MizConsole/"); Actions.Actions.Init(font); Thread.Sleep(1000); HwndObject obj; if (GetPaintHwnd(out obj)) { Console.ForegroundColor = Colors.Success; Console.WriteLine("[Program] Paint Hwnd found! using: " + obj.Text); obj.Activate(); WindowScrape.Static.HwndInterface.ShowWindow(obj.Hwnd, 3); } else { Console.ForegroundColor = Colors.Message; Console.WriteLine("[Program] Paint Hwnd not found."); Input.OpenPaint(); if (!ForceGetPaintHwnd(out obj)) { Console.ForegroundColor = Colors.Error; Console.WriteLine("[Program] ERROR: Can't find Paint Hwnd. Process aborted."); return; } } Thread.Sleep(1000); if (obj.Location.X > 10 && obj.Location.Y > 10 && obj.Size.Width < Stuff.ScreenWidth - 50 && obj.Size.Height < Stuff.ScreenHeight - 50) { Console.ForegroundColor = Colors.Message; Console.WriteLine("Paint window not maximized, maximizing..."); Input.MoveTo(new Point(obj.Location.X + obj.Size.Width - 69, obj.Location.Y + 3)); Input.RegisterClick(); Thread.Sleep(100); } watch = Stopwatch.StartNew(); queue = new Queue <IAction>(64); Console.ForegroundColor = Colors.Success; Console.WriteLine("Stopwatch started. Entering main loop..."); Input.PaintSelectBrush(); new SimpleWrite(font, "Welcome to PaintDrawer! What shall I draw for you, kind sir?", 70).Act(); System.Text.StringBuilder build = new System.Text.StringBuilder(256); for (int i = 32; i < CharFont.MaxCharNumericValue; i++) { if (font.DoesCharExist((char)i)) { build.Append((char)i); } } new SimpleWrite(font, build.ToString(), 70).Act(); Actions.Actions.CreateSimpleWrite(font, "Este es un mensaje especial! Estas durmiendo en un estado de coma, metimos esto en tu cabeza pero no sabemos a donde va a terminar, no tenemos idea que hacer con vos, por favor despertate! no porque te extrañemos pero yo que se...").Act(); LastDraw = -60; while (true) { Account.AddNewToQueue(queue); if (queue.Count == 0 && Time - LastDraw > 5 * 60) { // More than X minutes passed since the last draw! Let's add something random then... queue.Enqueue(Actions.Actions.RandomAction); } if (queue.Count != 0 && Time - LastDraw > 1 * 60) { // Give all texts at least a minute before erasing 'em... and drawing something else Input.PaintClearImage(); Input.PaintSelectBrush(); LastDraw = Time; queue.Dequeue().Act(); } else { Thread.Sleep(2000); } } }
public FixedCharAtom(CharFont charFont) => CharFont = charFont;