Example #1
0
        public void LoadLayout(ClLayoutContainer input)
        {
            if (this.initalized)
            {
                var cLay = 0;
                foreach (var kd in input.KeyDatas)
                {
                    if (kd.Z > cLay)
                    {
                        cLay = kd.Z;
                    }
                }
                while (this.Layers.Count < cLay + 1)
                {
                    var lay = new UCLayer(this.Keyboard, input, this.Layers.Count);
                    this.Layers.Add(lay);
                    this.SLMain.Items.Add(lay);
                }

                while (this.Layers.Count > cLay + 1)
                {
                    this.SLMain.Items.RemoveAt(this.Layers.Count - 1);
                    this.Layers.RemoveAt(this.Layers.Count - 1);
                }

                foreach (var lay in this.Layers)
                {
                    lay.LoadLayout(input);
                }
                this.BtnSave.Text = "Save Layout*";
            }
        }
Example #2
0
 public UCLayer(ClKeyboard keyboard, ClLayoutContainer layout, int layer)
 {
     InitializeComponent();
     this.Layer       = layer;
     this.LTitle.Text = "Layer " + layer;
     this.Buttons     = new List <Button>();
     foreach (var bi in keyboard.Buttons)
     {
         var btn = new Button();
         btn.Text = "Null";
         btn.Tag  = bi.X + "_" + bi.Y + "_" + this.Layer + "_" + bi.Command;
         btn.Size = new Size(bi.GW, bi.GH);
         this.Buttons.Add(btn);
         this.PLMain.Add(btn, new Point(bi.GX, bi.GY));
         if (this.PLMain.Size.Width < bi.GX + bi.GW)
         {
             this.PLMain.Size = new Size(bi.GX + bi.GW, this.PLMain.Size.Height);
         }
         if (this.PLMain.Size.Height < bi.GY + bi.GH)
         {
             this.PLMain.Size = new Size(this.PLMain.Size.Width, bi.GY + bi.GH);
         }
         btn.Click   += (sender, e) => PressedKey(sender, e);
         btn.KeyDown += (sender, e) => KeyboardInput(sender, e);
     }
     LoadLayout(layout);
     InitHandle();
 }
Example #3
0
 public UCKeyboard(ClKeyboard keyboard, ClLayoutContainer layout)
 {
     InitializeComponent();
     this.Keyboard   = keyboard;
     this.Layers     = new List <UCLayer>();
     this.initalized = true;
     LoadLayout(layout);
     this.SavePath         = "<UNSAVED LAYOUT>";
     this.LLayoutName.Text = "<UNSAVED LAYOUT>";
     InitHandle();
 }
Example #4
0
        public ClLayoutContainer(ClLayoutContainer input)
        {
            this.KeyDatas = new List <ClKeyData>();
            foreach (var kd in input.KeyDatas)
            {
                this.KeyDatas.Add(new ClKeyData(kd));
            }

            this.AddonDatas = new List <ClAdditionalData>();
            foreach (var ad in input.AddonDatas)
            {
                this.AddonDatas.Add(ad);
            }
        }
Example #5
0
        public ClLayoutContainer GenerateLayout()
        {
            var newLay = new ClLayoutContainer();

            foreach (var bi in this.Buttons)
            {
                var kd = new ClKeyData();
                kd.X       = bi.X;
                kd.Y       = bi.Y;
                kd.Z       = 0;
                kd.Command = bi.Command;
                kd.Key     = new ClKey();
                newLay.KeyDatas.Add(kd);
            }

            return(newLay);
        }
Example #6
0
 public void LoadLayout(ClLayoutContainer input)
 {
     foreach (var btn in this.Buttons)
     {
         foreach (var kd in input.KeyDatas)
         {
             var arr = btn.Tag.ToString().Split('_');
             var x   = Convert.ToInt32(arr[0]);
             var y   = Convert.ToInt32(arr[1]);
             var z   = Convert.ToInt32(arr[2]);
             var com = Convert.ToInt32(arr[3]);
             if ((kd.X == x) && (kd.Y == y) && (kd.Z == z) && (kd.Command == com))
             {
                 btn.Text    = MdSessionData.CurrentInputMethod.GetDisplay(kd.Key.DisplayID);
                 btn.ToolTip = btn.Text;
             }
         }
     }
 }
Example #7
0
        public static void Init()
        {
            MdConfig.Init();
            CurrentKeyboardType = new ClKeyboard();
            CurrentLayout       = new ClLayoutContainer();
            CurrentKeyboardUI   = new UCKeyboard();
            KeyMenuKey          = new ClKey();
            CurrentInputMethod  = new ClDisplayCharacterContainer();
            KeyGroup            = new ClKeyGroup();
            SP = new SerialPort();

            if (File.Exists("favicon.ico"))
            {
                WindowIcon = new Icon(Path.Combine(MdConstant.root, MdConstant.N_ICON));
            }


            CurrentInputMethod = MdConfig.Main.GetCurrentInputMethod();
            KeyGroup           = MdCore.Deserialize <ClKeyGroup>(Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYGROUP, "Core" + MdConstant.E_KEYGROUP));
        }