Advertisement
Guest User

FontChangerIssue

a guest
Jul 3rd, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.62 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using System.Text.RegularExpressions;
  12.  
  13. namespace SteamFontChanger
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         int newFont = 16;
  18.         int prevFont;
  19.         string line;
  20.         string oldFont = "      font-size=";
  21.         string filePath = "readme.txt";
  22.         string startLine = "friends_chat_text";
  23.         string fontLine = "     font-size=";
  24.         string endLine = "friends_chat_accountid";
  25.         string newFontS;
  26.  
  27.         public Form1()
  28.         {
  29.             InitializeComponent();
  30.             System.IO.StreamReader prevFontRead = new System.IO.StreamReader("C:\\Users\\chris\\Desktop\\SteamFontSize\\prevfont.txt");
  31.             prevFont = int.Parse(prevFontRead.ReadLine());
  32.             oldFont = "     font-size=" + prevFont;
  33.             prevLabel.Text = "Previous " + oldFont;
  34.         }
  35.  
  36.         /// <summary>
  37.         /// Edits the text in a file
  38.         /// </summary>
  39.  
  40.  
  41.     //v the below code
  42.         private void editText()
  43.         {
  44.             System.IO.StreamReader read = new System.IO.StreamReader(filePath);
  45.             StringBuilder write = new StringBuilder(filePath);
  46.  
  47.             while ((line = read.ReadLine()) != null)
  48.             {
  49.                 if (startLine == read.ReadLine())
  50.                 {
  51.                     while ((line = read.ReadLine()) != endLine)
  52.                     {
  53.                         write.Replace(oldFont, newFontS);
  54.                     }
  55.                 }
  56.             }
  57.             MessageBox.Show("Done!");
  58.         }
  59.         // ^ the above code ^
  60.  
  61.  
  62.  
  63.         private void changeFont_Click(object sender, EventArgs e)
  64.         {
  65.             MessageBox.Show("If you have not done so, exit steam completely.");
  66.             if (filePath != "readme.txt")
  67.             {
  68.                 newFontS = fontLine + newFont.ToString();
  69.                 editText();
  70.             }
  71.             else
  72.             {
  73.                 MessageBox.Show("Error: " + filePath + " is not a valid path, did you change the path?");
  74.             }
  75.  
  76.         }
  77.  
  78.         private void textPath_TextChanged(object sender, EventArgs e)
  79.         {
  80.             filePath = textPath.Text + "\\steam\\resource\\styles\\steam.txt";
  81.         }
  82.  
  83.         private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  84.         {
  85.             //trying to get variable from box
  86.             newFont = Convert.ToInt32(fontBox.Value);
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement