Exemplo n.º 1
0
 private void Wp_MouseClick(object sender, MouseEventArgs e)
 {
     MainFrm.GetMainForm().ChangeBackground((String)((PictureBox)sender).Tag);
 }
Exemplo n.º 2
0
        public MainFrm()
        {
            pfont = new PrivateFontCollection();
            pfont.AddFontFile(".\\acr.ttf");

            InitializeComponent();

            DateTime installTime = GetWindowsInstallationDateTime(Environment.MachineName);
            DateTime currentDate = DateTime.Now;

            rand = new Random((currentDate - installTime).Milliseconds);

            if (File.Exists("./save.txt"))
            {
                using (TextReader tr = new StreamReader(File.Open("./save.txt", FileMode.Open)))
                {
                    highscore = int.Parse(tr.ReadLine());
                    losses    = int.Parse(tr.ReadLine());
                    bgName    = tr.ReadLine();
                }
            }

            FontFamily pf = pfont.Families.First();

            scoreFont  = new Font(pf, 14);
            scoreMed   = new Font(pf, 12);
            scoreSmall = new Font(pf, 9);

            using (Graphics g = this.CreateGraphics())
            {
                String scoreText = String.Format("Highscore:{0} Losses:{1}", highscore, losses);

                SizeF strSize = g.MeasureString(scoreText, scoreFont);

                scoreBox = new Rectangle(0, ClientSize.Height - (int)(strSize.Height + 4), ClientSize.Width, (int)strSize.Height + 4);

                SizeF bgSel = g.MeasureString("Options", scoreSmall);

                bgSelRect = new Rectangle(0, scoreBox.Top - ((int)bgSel.Height + 4), (int)bgSel.Width + 4, (int)bgSel.Height + 4);
            }

            DoubleBuffered = true;

            tehFrame = (Image)Resources.ResourceManager.GetObject(bgName); //Return an object from the image chan1.png in the project

            if (tehFrame.PropertyIdList.Contains(0x5100))
            {
                PropertyItem item = tehFrame.GetPropertyItem(0x5100);

                int delay = (item.Value[0] + item.Value[1] * 256) * 10;

                gifTime = new System.Timers.Timer(delay);

                gifTime.Elapsed += DoGIF;

                gifTime.Start();
            }

            optionsPanel = new OptionsPanel();

            optionsPanel.Width  = (int)(ClientSize.Width * 0.8);
            optionsPanel.Height = (int)(ClientSize.Height * 0.8);

            optionsPanel.Location = new Point(ClientSize.Width / 2 - optionsPanel.Width / 2,
                                              ClientSize.Height / 2 - optionsPanel.Height / 2);

            optionsPanel.Visible = false;

            this.Controls.Add(optionsPanel);

            gFrame = this;
        }