Пример #1
0
        public Form1()
        {
            InitializeComponent();

            RegistryLoad();

            WordCount    = wf.WordsCount;
            currentRound = new REWRound("current", WordCount);

            wf.Edit              = false;
            wf.Move             += wf_Move;
            wf.WordFieldChanged += wf_WordFieldChanged;
            wf.KeyDown          += wf_KeyDown;
            wf.Show();
            wf.StoreOrigParameters();

            pf.Edit            = false;
            pf.Text            = "Show";
            pf.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
            pf.BackColor       = Color.Black;
            pf.KeyDown        += pf_KeyDown;
            pf.Show();
            pf.StoreOrigParameters();

            timer1.Start();

            sp = new SoundPlayer(Properties.Resources.Ding);
        }
Пример #2
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int sel = listBox1.SelectedIndex;


            if ((sel >= 0) && (sel < listBox1.Items.Count))
            {
                wf.Edit = true;

                // Загрузка данных раунда
                REWRound rr = listBox1.Items[sel] as REWRound;

                for (int i = 0; i < WordCount; i++)
                {
                    currentRound.SetAt(rr.GetTxtAt(i), rr.GetStateAt(i), i);
                }
            }
            else
            {
                wf.Edit = false;

                // Очистка данных раунда
                for (int i = 0; i < WordCount; i++)
                {
                    currentRound.SetAt("", false, i);
                }
            }

            RefreshEditor();
            RefreshWordForm();
            oldSelected = sel;
        }
Пример #3
0
 public static void SaveRound(REWRound rr, ProjFileStream pfs)
 {
     pfs.WriteString(rr.roundName);
     for (int i = 0; i < rr.WordsCount; i++)
     {
         pfs.WriteString(rr.words[i]);
         pfs.WriteBool(rr.states[i]);
     }
 }
Пример #4
0
        private void newRoundToolStripMenuItem_Click(object sender, EventArgs e)
        {
            roundCounter++;
            REWRound rr = new REWRound("Round " + roundCounter.ToString(), WordCount);

            listBox1.Items.Add(rr);
            listBox1.SelectedIndex = listBox1.Items.Count - 1;

            Saved = false;
        }
Пример #5
0
        private void SaveProject()
        {
            ProjFileStream pfs = new ProjFileStream(filename, FileMode.Create, FileAccess.Write);

            WriteFont(visFont, visCol, pfs);    // Видимый шрифт
            WriteFont(unvFont, unvCol, pfs);    // Невидимый шрифт
            pfs.WriteInt(WordCount);            // Количество слов. Должно совпадать при загрузке!
            pfs.WriteInt(listBox1.Items.Count); // Количество заданий
            for (int i = 0; i < listBox1.Items.Count; i++)
            {
                REWRound.SaveRound((REWRound)listBox1.Items[i], pfs);
            }

            pfs.Close();

            Saved = true;
        }
Пример #6
0
        public static REWRound LoadRound(ProjFileStream pfs, int fileCount, int maxCount)
        {
            string   name = pfs.ReadString();
            REWRound rr   = new REWRound(name, maxCount);

            for (int i = 0; i < fileCount; i++)
            {
                string wrd = pfs.ReadString();
                bool   stt = pfs.ReadBool();
                if (i < maxCount)
                {
                    rr.SetAt(wrd, stt, i);
                }
            }

            return(rr);
        }
Пример #7
0
        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (listBox1.SelectedIndex >= 0)
            {
                int             sel = listBox1.SelectedIndex;
                RoundNameDialog rnd = new RoundNameDialog();
                rnd.RoundName = listBox1.Items[sel].ToString();
                if (rnd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    REWRound rr = (REWRound)listBox1.Items[sel];
                    rr.RoundName        = rnd.RoundName;
                    listBox1.Items[sel] = rr;
                    //((REWRound)(listBox1.Items[sel])).RoundName = rnd.RoundName;
                }

                Saved = false;
            }
        }
Пример #8
0
        private void OpenProject()
        {
            listBox1.Items.Clear();
            wf.ClearForm();
            pf.ClearForm();

            ProjFileStream pfs = new ProjFileStream(filename, FileMode.Open, FileAccess.Read);

            // Видимый шрифт
            visFont     = ReadFont(pfs, ref visCol);
            wf.VisFont  = visFont;
            pf.VisFont  = visFont;
            wf.VisColor = visCol;
            pf.VisColor = visCol;

            // Невидимый шрифт
            unvFont     = ReadFont(pfs, ref unvCol);
            wf.UnvFont  = unvFont;
            pf.UnvFont  = unvFont;
            wf.UnvColor = unvCol;
            pf.UnvColor = unvCol;

            // Количество слов. Должно совпадать!
            int localWC = pfs.ReadInt();

            // Количество заданий
            int localCNT = pfs.ReadInt();

            roundCounter = localCNT;
            for (int i = 0; i < localCNT; i++)
            {
                listBox1.Items.Add(REWRound.LoadRound(pfs, localWC, WordCount));
            }

            if (listBox1.Items.Count > 0)
            {
                listBox1.SelectedIndex = 0;
            }

            pfs.Close();

            Saved = true;
        }
Пример #9
0
        private void insertRoundToolStripMenuItem_Click(object sender, EventArgs e)
        {
            roundCounter++;
            REWRound rr = new REWRound("Round " + roundCounter.ToString(), WordCount);

            if (listBox1.SelectedIndex >= 0)
            {
                int sel = listBox1.SelectedIndex;
                listBox1.Items.Insert(sel, rr);
                listBox1.SelectedIndex = sel;
            }
            else
            {
                listBox1.Items.Add(rr);
                listBox1.SelectedIndex = listBox1.Items.Count - 1;
            }

            Saved = false;
        }
Пример #10
0
        private void listBox1_DragDrop(object sender, DragEventArgs e)
        {
            // The mouse locations are relative to the screen, so they must be
            // converted to client coordinates.
            Point clientPoint = listBox1.PointToClient(new Point(e.X, e.Y));

            // Get the row index of the item the mouse is below.
            rowIndexOfItemUnderMouseToDrop = listBox1.IndexFromPoint(clientPoint.X, clientPoint.Y);
            if (rowIndexOfItemUnderMouseToDrop < 0)
            {
                rowIndexOfItemUnderMouseToDrop = listBox1.Items.Count - 1;
            }
            // If the drag operation was a move then remove and insert the row.
            if (e.Effect == DragDropEffects.Move)
            {
                REWRound rowToMove = e.Data.GetData(
                    typeof(REWRound)) as REWRound;
                listBox1.Items.RemoveAt(rowIndexFromMouseDown);
                listBox1.Items.Insert(rowIndexOfItemUnderMouseToDrop, rowToMove);
                listBox1.SelectedIndex = rowIndexOfItemUnderMouseToDrop;
            }

            Saved = false;
        }