Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GameDetail.cs « Components « UI - github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d44cd9d7e9af3f164e64dd5dc1031f21de704707 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace com.clusterrr.hakchi_gui.UI.Components
{
    public partial class GameDetail : UserControl
    {
        public GameDetail()
        {
            InitializeComponent();

            // Little tweak for easy translation
            var tbl = textBoxName.Left;
            textBoxName.Left = labelName.Left + labelName.Width;
            textBoxName.Width -= textBoxName.Left - tbl;
            maskedTextBoxReleaseDate.Left = label1.Left + label1.Width + 3;
            tbl = textBoxPublisher.Left;
            textBoxPublisher.Left = label2.Left + label2.Width;
            textBoxPublisher.Width -= textBoxPublisher.Left - tbl;
        }
        private NesMiniApplication currentApp;
        public void SetGame(NesMiniApplication app)
        {
            currentApp = app;
            ReloadInfo();
        }
        private void Disable()
        {
            buttonBrowseImage.Enabled = false;
            buttonGoogle.Enabled = false;
            groupBoxOptions.Enabled = false;
        }
        private void Enable()
        {
            buttonBrowseImage.Enabled = true;
            buttonGoogle.Enabled = true;
            groupBoxOptions.Enabled = true;
        }
        private void ReloadInfo()
        {
            if (currentApp == null)
            {

                groupBoxOptions.Visible = true;
                groupBoxOptions.Enabled = false;
                labelID.Text = "ID: ";
                textBoxName.Text = "";
                radioButtonOne.Checked = true;
                radioButtonTwo.Checked = false;
                radioButtonTwoSim.Checked = false;
                maskedTextBoxReleaseDate.Text = "";
                textBoxPublisher.Text = "";
                textBoxArguments.Text = "";
                pictureBoxArt.Image = null;
                buttonBrowseImage.Enabled = false;
                buttonGoogle.Enabled = false;
            }
            else
            {
              

                groupBoxOptions.Visible = true;
                labelID.Text = "ID: " + currentApp.Code;
                textBoxName.Text = currentApp.Name;
                if (currentApp.Simultaneous && currentApp.Players == 2)
                    radioButtonTwoSim.Checked = true;
                else if (currentApp.Players == 2)
                    radioButtonTwo.Checked = true;
                else
                    radioButtonOne.Checked = true;
                maskedTextBoxReleaseDate.Text = currentApp.ReleaseDate;
                textBoxPublisher.Text = currentApp.Publisher;
                if (currentApp is NesGame)
                    textBoxArguments.Text = (currentApp as NesGame).Args;
                else if (currentApp is FdsGame)
                    textBoxArguments.Text = (currentApp as FdsGame).Args;
                else
                    textBoxArguments.Text = currentApp.Command;
                if (System.IO.File.Exists(currentApp.IconPath))
                    pictureBoxArt.Image = NesMiniApplication.LoadBitmap(currentApp.IconPath);
                else
                    pictureBoxArt.Image = null;
                buttonShowGameGenieDatabase.Enabled = textBoxGameGenie.Enabled = currentApp is NesGame;
                textBoxGameGenie.Text = (currentApp is NesGame) ? (currentApp as NesGame).GameGenie : "";
                groupBoxOptions.Enabled = true;
             
                if(currentApp.GetType() != typeof(NesDefaultGame))
                {
                    Enable();
                }
                else
                {
                    Disable();
                }
            }
        }

        private void textBoxName_TextChanged(object sender, EventArgs e)
        {
          
            if (currentApp == null || !(currentApp is NesMiniApplication)) return;
            var game = (currentApp as NesMiniApplication);
            game.Name = textBoxName.Text;
        }

        private void radioButtonOne_CheckedChanged(object sender, EventArgs e)
        {
          
            if (currentApp == null || !(currentApp is NesMiniApplication)) return;
            var game = (currentApp as NesMiniApplication);
            game.Players = (byte)(radioButtonOne.Checked ? 1 : 2);
            game.Simultaneous = radioButtonTwoSim.Checked;
        }

        private void textBoxPublisher_TextChanged(object sender, EventArgs e)
        {
           
            if (currentApp == null || !(currentApp is NesMiniApplication)) return;
            var game = (currentApp as NesMiniApplication);
            game.Publisher = textBoxPublisher.Text.ToUpper();
        }

        private void textBoxArguments_TextChanged(object sender, EventArgs e)
        {
            
            if (currentApp == null || !(currentApp is NesMiniApplication)) return;
            var game = (currentApp as NesMiniApplication);
            if (game is NesGame)
                (game as NesGame).Args = textBoxArguments.Text;
            else if (game is FdsGame)
                (game as FdsGame).Args = textBoxArguments.Text;
            else
                game.Command = textBoxArguments.Text;
        }

        private void maskedTextBoxReleaseDate_TextChanged(object sender, EventArgs e)
        {
            if (currentApp == null || !(currentApp is NesMiniApplication)) return;
            var game = (currentApp as NesMiniApplication);
            game.ReleaseDate = maskedTextBoxReleaseDate.Text;
        }

        private void textBoxGameGenie_TextChanged(object sender, EventArgs e)
        {
            if (currentApp == null || !(currentApp is NesGame)) return;
            var game = (currentApp as NesGame);
            game.GameGenie = textBoxGameGenie.Text;
        }

        private void buttonShowGameGenieDatabase_Click(object sender, EventArgs e)
        {
            if (!(currentApp is NesGame)) return;
            NesGame nesGame = currentApp as NesGame;
            GameGenieCodeForm lFrm = new GameGenieCodeForm(nesGame);
            if (lFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                textBoxGameGenie.Text = nesGame.GameGenie;
        }

        public void SetImageForSelectedGame(string fileName)
        {
        
            if (currentApp == null || !(currentApp is NesMiniApplication)) return;
            var game = (currentApp as NesMiniApplication);
            game.Image = NesMiniApplication.LoadBitmap(fileName);
            SetGame(game);
           
        }

        private void buttonBrowseImage_Click(object sender, EventArgs e)
        {
            openFileDialogImage.Filter = Properties.Resources.Images + " (*.bmp;*.png;*.jpg;*.jpeg;*.gif)|*.bmp;*.png;*.jpg;*.jpeg;*.gif|" + Properties.Resources.AllFiles + "|*.*";
            if (openFileDialogImage.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SetImageForSelectedGame(openFileDialogImage.FileName);
            }
        }

        private void buttonGoogle_Click(object sender, EventArgs e)
        {
            if (currentApp == null || !(currentApp is NesMiniApplication)) return;
            var game = (currentApp as NesMiniApplication);
            var googler = new ImageGooglerForm(game);
            if (googler.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                game.Image = googler.Result;
                SetGame(game);
            }
        }
    }
}