Example #1
0
 public static void SaveKeyBindings(KeyBindings kb)
 {
     using (FileStream fs = new FileStream(kb.FilePath, FileMode.Create)) {
         XmlSerializer serializer = new XmlSerializer(typeof(KeyBindings));
         serializer.Serialize(fs, kb);
     }
 }
Example #2
0
        public KeyBindingWidget(Gtk.Window parent)
        {
            //parentWindow = parent;
            this.Build();

            /*if(!isRequired){
                cbKeyBinding.AppendText(NOTHING);
                cbKeyBinding.Active = 0;
            }*/

            cbKeyBinding.AppendText(WIN);
            cbKeyBinding.AppendText(MACOSX);
            cbKeyBinding.AppendText(JAVA);
            cbKeyBinding.AppendText(VisualC);

            if(MainClass.Platform.IsMac){
                cbKeyBinding.Active = 1;
            } else {
                cbKeyBinding.Active = 0;
            }

            keymap.KeysChanged += delegate {
                groupZeroMappings.Clear ();
            };

            lblMessage.Text = "";
            //string file = System.IO.Path.Combine(MainClass.Paths.ConfingDir, "keybinding");
            keyBindFile = MainClass.KeyBinding;//KeyBindings.OpenKeyBindings(file);
            //entrAccel.InvisibleChar = 'â—Ź';

            //curentBind =keyBindFile.

            TreeViewColumn col = new TreeViewColumn ();
            col.Title = MainClass.Languages.Translate("name");
            col.Spacing = 4;
            CellRendererText crp = new CellRendererText ();
            col.PackStart (crp, false);
            col.AddAttribute (crp, "text", nameCol);
            col.AddAttribute (crp, "weight", boolCol);

            tvKeyBind.AppendColumn(col);
            //tvKeyBind.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 0);
            tvKeyBind.AppendColumn(MainClass.Languages.Translate("description"), new Gtk.CellRendererText(), "text", descrCol);
            tvKeyBind.AppendColumn(MainClass.Languages.Translate("key"), new Gtk.CellRendererText(), "text", keyCol);
            tvKeyBind.Model = keybStore;
            tvKeyBind.EnableSearch = false;

            curentBind = MainClass.Tools.Clone<KeyBindingSection>(keyBindFile.KeyBindingSection);

            foreach(KeyBindingSection kbs in  curentBind){

                TreeIter tiParent = keybStore.AppendValues(kbs.Name,"","",(int) Pango.Weight.Bold,null);
                foreach(KeyBinding kb in kbs.KeyBinding){
                    keybStore.AppendValues(tiParent,kb.Name,kb.Description,kb.Key,(int) Pango.Weight.Normal,kb);
                }
            }

            tvKeyBind.ExpandAll();
            tvKeyBind.ColumnsAutosize ();

            entrAccel.Sensitive = true;
            btnAccelAply.Sensitive = true;

            tvKeyBind.Selection.Changed += OnKeysTreeViewSelectionChange;
        }
Example #3
0
        public static KeyBindings OpenKeyBindings(string filePath)
        {
            if (System.IO.File.Exists(filePath)) {

                try {
                    using (FileStream fs = File.OpenRead(filePath)) {
                        XmlSerializer serializer = new XmlSerializer(typeof(KeyBindings));
                        KeyBindings s = (KeyBindings)serializer.Deserialize(fs);
                        s.FilePath= filePath;
                        return s;
                    }
                } catch (Exception ex) {

                    throw ex;
                    /*MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, \"Error\", \"Settings file is corrupted!\", Gtk.MessageType.Error);
                    ms.ShowDialog();
                    return new Settings();*/
                }
            } else {
                KeyBindings kb= new KeyBindings(filePath);
                kb.KeyBindingSection = new List<KeyBindingSection>();

                kb.KeyBindingSection.Add(new KeyBindingSection("section_name"));
                kb.KeyBindingSection[0].KeyBinding.Add(new KeyBinding("name","description","action","key"));
                //kb.KeyBinding
                return kb;
                /*MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", "Settings file does not exist!", Gtk.MessageType.Error);
                ms.ShowDialog();
                return new Settings();*/
            }
        }
Example #4
0
        protected void OnBtnAccelAply1Clicked(object sender, System.EventArgs e)
        {
            string active = cbKeyBinding.ActiveText;
            string file = System.IO.Path.Combine(MainClass.Paths.SettingDir, "keybinding");

            switch (active) {
            case WIN:{
                KeyBindings.CreateKeyBindingsWin(file);
                break;
            }
            case MACOSX:{
                KeyBindings.CreateKeyBindingsMac(file);
                break;
            }
            case JAVA:{
                KeyBindings.CreateKeyBindingsJava(file);
                break;
            }
            case VisualC:{
                KeyBindings.CreateKeyBindingsVisualC(file);
                break;
            }
            default:
                break;
            }
            keyBindFile = MainClass.KeyBinding;

            curentBind = MainClass.Tools.Clone<KeyBindingSection>(keyBindFile.KeyBindingSection);
            keybStore.Clear();
            foreach(KeyBindingSection kbs in  curentBind){

                TreeIter tiParent = keybStore.AppendValues(kbs.Name,"","",(int) Pango.Weight.Bold,null);
                foreach(KeyBinding kb in kbs.KeyBinding){
                    keybStore.AppendValues(tiParent,kb.Name,kb.Description,kb.Key,(int) Pango.Weight.Normal,kb);
                }
            }

            tvKeyBind.ExpandAll();
            tvKeyBind.ColumnsAutosize ();
            //MainClass.Settings.SaveSettings();
        }