Esempio n. 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int x, y, w, h;

            x = Math.Min(sx, cx);
            y = Math.Min(sy, cy);

            if (x < 0 || y < 0)
            {
                return;
            }

            w = Math.Max(sx, cx) - x;
            h = Math.Max(sy, cy) - y;

            if (curr == null)
            {
                rekts.Add(new Dummy.RektButton()
                {
                    rekt = new Rectangle(x, y, w, h), kb = new Dummy.Keybinding()
                });
            }
            else
            {
                curr.rekt.X      = x;
                curr.rekt.Y      = y;
                curr.rekt.Width  = w;
                curr.rekt.Height = h;

                curr = null;
            }

            sx = -1; sy = -1; cx = 0; cy = 0;
        }
Esempio n. 2
0
        private void btnCfgLoad_Click(object sender, EventArgs e)
        {
            dmy.rekts.Clear();

            if (File.Exists("3dsp.bin"))
            {
                using (FileStream fs = File.OpenRead("3dsp.bin"))
                {
                    while (true)
                    {
                        byte nth = (byte)fs.ReadByte();
                        if (nth == 0xFF)
                        {
                            break;
                        }

                        Dummy.Keybinding kb = dmy.bindings[nth];
                        kb.Import(fs);
                    }

                    int i = fs.ReadByte();

                    while (i > 0)
                    {
                        Dummy.RektButton rb = new Dummy.RektButton();
                        rb.Import(fs);
                        dmy.rekts.Add(rb);
                        i--;
                    }
                }

                btnCfgSave.PerformClick();
                Application.DoEvents();

                KeyconfigExport(new Ini(path));

                File.Delete("3dsp.bin");

                btnCfgLoad.PerformClick();

                return;
            }

            Ini ini = new Ini("3dsp.ini");

            Ini.IniSection sect = null;

            sect          = ini.GetSection("general");
            textIP.Text   = sect.Read("IP", dmy.ipaddr);
            numPort.Value = (UInt16)sect.ReadInt("port", dmy.port);
            path          = sect.Read("kconf", path);

            KeyconfigImport(ini);

            if (File.Exists(path))
            {
                KeyconfigImport(new Ini(path));
            }
        }
Esempio n. 3
0
        private void KeyconfigImport(Ini ini)
        {
            Ini.IniSection sect = ini.GetSection("general");

            dmy.abs  = sect.ReadInt("abs", dmy.abs ? 1 : 0) == 0 ? false : true;
            dmy.divx = sect.ReadInt("divx", dmy.divx);
            dmy.divy = sect.ReadInt("divy", dmy.divy);

            try
            {
                int wat = Convert.ToInt32(sect.Read("altk", ""), 16);
                dmy.altkey = wat;
            }
            catch { }

            dmy.mmode = sect.ReadInt("mmode", dmy.mmode);


            foreach (Dummy.Keybinding kb in dmy.bindings)
            {
                if (kb == null)
                {
                    continue;
                }
                kb.edown.Clear();
                kb.eheld.Clear();
                kb.eup.Clear();
            }
            dmy.rekts.Clear();

            int cnt = sect.ReadInt("rekts");

            for (int i = 0; i != 32; i++)
            {
                sect = ini.GetSection("Keys/" + i);

                IniToKeybind(sect, dmy.bindings[i]);
            }

            for (int i = 0; i != cnt; i++)
            {
                sect = ini.GetSection("Rekt/" + i);

                Rectangle?rect = sect.ReadStruct <Rectangle>("bnd");
                if (!rect.HasValue)
                {
                    continue;
                }

                Dummy.RektButton rekt = new Dummy.RektButton();
                rekt.kb   = new Dummy.Keybinding();
                rekt.rekt = rect.Value;
                IniToKeybind(sect, rekt.kb);

                dmy.rekts.Add(rekt);
            }
        }
Esempio n. 4
0
        void imgAlt_MouseDown(object sender, MouseEventArgs e)
        {
            if (mode == Mode.SELECT)
            {
                UpdateSel(true);
                sx = e.X;
                sy = e.Y;
                cx = sx;
                cy = sy;
            }
            else if (mode == Mode.DEL)
            {
                Dummy.RektButton sel = null;

                Rectangle cur = new Rectangle(e.X, e.Y, 1, 1);
                foreach (Dummy.RektButton rekt in rekts)
                {
                    if (rekt.rekt.IntersectsWith(cur))
                    {
                        sel = rekt;
                        break;
                    }
                }

                if (sel == null)
                {
                    return;
                }

                if (MessageBox.Show("Are you sure you want to delet that?", "Confirmation", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                rekts.Remove(sel);
                this.Invalidate(true);
            }
            else if (mode == Mode.EDIT)
            {
                Dummy.RektButton sel = null;

                Rectangle cur = new Rectangle(e.X, e.Y, 1, 1);
                foreach (Dummy.RektButton rekt in rekts)
                {
                    if (rekt.rekt.IntersectsWith(cur))
                    {
                        sel = rekt;
                        break;
                    }
                }

                if (sel == null)
                {
                    return;
                }

                using (FormBuilder fm = new FormBuilder("ALT", sel.kb.edown, sel.kb.eup, sel.kb.eheld))
                {
                    fm.ShowDialog();
                }
            }
            else if (mode == Mode.POS)
            {
                curr = null;

                Rectangle cur = new Rectangle(e.X, e.Y, 1, 1);
                foreach (Dummy.RektButton rekt in rekts)
                {
                    if (rekt.rekt.IntersectsWith(cur))
                    {
                        curr = rekt;
                        break;
                    }
                }

                if (curr == null)
                {
                    return;
                }

                sx = curr.rekt.X;
                sy = curr.rekt.Y;
                cx = curr.rekt.Right;
                cy = curr.rekt.Bottom;
            }
        }