/// <summary> /// Moves on a single character rectangle's animation. /// </summary> private bool doAnimateRect(CharRect cr) { if (cr.AnimState == 0) { return(false); } // Lighting up if (cr.AnimState == 1) { cr.AnimVal += 0.125F; if (cr.AnimVal > 1) { cr.AnimVal = 1; cr.AnimState = 0; } } // Cooling down else { cr.AnimVal -= 0.125F; if (cr.AnimVal < 0) { cr.AnimVal = 0; cr.AnimState = 0; } } return(true); }
/// <summary> /// Copies character rectangles out of their container in a thread-safe way. /// </summary> /// <returns></returns> private CharRect[] getCharRects() { CharRect[] rects = new CharRect[charRects.Count]; lock (animLO) { for (int i = 0; i != rects.Length; ++i) { CharRect cr = charRects[i]; rects[i] = new CharRect { Rect = cr.Rect, AnimState = cr.AnimState, AnimVal = cr.AnimVal }; } } return(rects); }
/// <summary> /// Launches/changes animation to show hover background. /// </summary> /// <param name="ix">Index of rectangle with hover, or -1.</param> private void doAnimate(int ix) { bool needTimer = false; if (ix != -1 && ix >= items.Length) { ix = -1; } lock (animLO) { for (int i = 0; i != charRects.Count; ++i) { CharRect cr = charRects[i]; // This is current hover if (i == ix) { // Rectangle is not fully highlighted: start animation if (cr.AnimVal != 1) { cr.AnimState = 1; } } // Rectangle is not hovered over. Need to turn off? else { if (cr.AnimVal != 0 || ix == -1) { cr.AnimState = -1; } } // Timer is needed if anything is animating. needTimer |= cr.AnimState != 0; } } if (needTimer) { SubscribeToTimer(); } }
bool FindPrintWord(Bitmap bmp_menu_in) { System.Drawing.Pen pen = new System.Drawing.Pen(new SolidBrush(System.Drawing.Color.Red)); System.Drawing.Pen pen_green = new System.Drawing.Pen(new SolidBrush(System.Drawing.Color.Green)); System.Drawing.Pen pen_yell = new System.Drawing.Pen(new SolidBrush(System.Drawing.Color.Yellow)); pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; pen_green.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; List <string> arrAddLetters = new List <string>(); arrAddLetters.Add("Pr"); arrAddLetters.Add("ri"); arrAddLetters.Add("nt"); //listBox1.Items.Clear(); Bitmap bmp_menu = null; for (int k = 0; k < 2; k++) { bmp_menu = bmp_menu_in.Clone(new System.Drawing.Rectangle(0, 0, bmp_menu_in.Width, bmp_menu_in.Height), bmp_menu_in.PixelFormat); Graphics gr = Graphics.FromImage(bmp_menu); recogn.LoadBmp(bmp_menu, k == 1); CharRow row = recogn.Recognize("Print", arrAddLetters); gr.DrawRectangle(pen_yell, recogn.m_cut_menu_rect); for (int i = 0; i < recogn.lines.Count; i++) { gr.DrawLine(pen_green, 0, recogn.lines[i], bmp_menu.Width - 1, recogn.lines[i]); } if (row != null) { gr.DrawRectangle(pen, row.m_FullRect); gr.Flush(); return(true); } else { string word = string.Empty; for (int i = 0; i < recogn.chars_row.Count; i++) { CharRow letters = recogn.chars_row[i]; for (int j = 0; j < letters.Count; j++) { CharRect letter = letters[j]; gr.DrawRectangle(pen, letter.m_rect); word += letter.LetterString; } //listBox1.Items.Add(word); } gr.Flush(); } } return(false); }
/// <summary> /// Copies character rectangles out of their container in a thread-safe way. /// </summary> /// <returns></returns> private CharRect[] getCharRects() { CharRect[] rects = new CharRect[charRects.Count]; lock (animLO) { for (int i = 0; i != rects.Length; ++i) { CharRect cr = charRects[i]; rects[i] = new CharRect { Rect = cr.Rect, AnimState = cr.AnimState, AnimVal = cr.AnimVal }; } } return rects; }
/// <summary> /// Moves on a single character rectangle's animation. /// </summary> private bool doAnimateRect(CharRect cr) { if (cr.AnimState == 0) return false; // Lighting up if (cr.AnimState == 1) { cr.AnimVal += 0.125F; if (cr.AnimVal > 1) { cr.AnimVal = 1; cr.AnimState = 0; } } // Cooling down else { cr.AnimVal -= 0.125F; if (cr.AnimVal < 0) { cr.AnimVal = 0; cr.AnimState = 0; } } return true; }
public int sceFontGetCharImageRect(FontHandle FontHandle, ushort CharCode, CharRect* CharRectPointer) { throw (new NotImplementedException()); }