Beispiel #1
0
        public void ReadNonExistingFileTest()
        {
            KbdFile kbd = new KbdFile(":asd?$#");
            Assert.IsFalse(kbd.Read());

            kbd = new KbdFile("C:/nonexistingFile.kbd");
            Assert.IsFalse(kbd.Read());
        }
Beispiel #2
0
        public void AddNewActionTest()
        {
            KbdFile kbd = new KbdFile(kbdFile);
            Assert.IsTrue(kbd.Read());

            String macroName = "test";
            String macroCategory = "TestCat";
            Keys keys = Keys.A;
            Assert.IsTrue(kbd.AddAction(macroName, macroCategory, keys, true));
            KeyboardAction action = kbd.Actions.Find(a => a.TableId == KbdFile.MacroTableId && a.Keys == keys && a.MacroName == macroName && a.MacroCategory == macroCategory);
            Assert.IsNotNull(action);
        }
Beispiel #3
0
        public void AddExistingActionTest()
        {
            KbdFile kbd = new KbdFile(kbdFile);
            Assert.IsTrue(kbd.Read());

            String macroName = "test";
            String macroCategory = "TestCat";
            Keys keys = Keys.H;

            //Test adding exactly existing action.
            Assert.IsFalse(kbd.AddAction("toggleOutliner", "Outliner", Keys.H, true));

            //Test with replace=false.
            Assert.IsFalse(kbd.AddAction(macroName, macroCategory, keys, false));
            KeyboardAction action = kbd.Actions.Find(a => a.TableId == KbdFile.MacroTableId && a.Keys == keys && a.MacroName == macroName && a.MacroCategory == macroCategory);
            Assert.IsNull(action);

            //Test with replace=true.
            Assert.IsTrue(kbd.AddAction(macroName, macroCategory, keys, true));
            action = kbd.Actions.Find(a => a.TableId == KbdFile.MacroTableId && a.Keys == keys && a.MacroName == macroName && a.MacroCategory == macroCategory);
            Assert.IsNotNull(action);
        }
Beispiel #4
0
        public void WriteTest()
        {
            KbdFile kbd = new KbdFile(kbdFile);
            Assert.IsTrue(kbd.Read());

            kbd.File = TestHelperMethods.GetOutputDirectory() + "test.kbd";
            Assert.IsTrue(kbd.Write());
            Assert.IsTrue(TestHelperMethods.CompareFiles(kbdFile, kbd.File));
        }
Beispiel #5
0
        public void RemoveActionTest()
        {
            KbdFile kbd = new KbdFile(kbdFile);
            Assert.IsTrue(kbd.Read());

            Assert.AreEqual(1, kbd.RemoveAction("toggleOutliner", "Outliner"));
            Assert.AreEqual(0, kbd.RemoveAction("toggleOutliner", "Outliner"));
        }
Beispiel #6
0
 public void ReadTest()
 {
     KbdFile kbd = new KbdFile(kbdFile);
     Assert.IsTrue(kbd.Read());
 }
Beispiel #7
0
 public void ReadNullTest()
 {
     KbdFile kbd = new KbdFile(null);
     Assert.IsFalse(kbd.Read());
 }
        /// <summary>
        /// Removes the hotkey assignment.
        /// </summary>
        public override bool Undo(Installer installer)
        {
            KbdFile kbd = new KbdFile(KbdFile.MaxGetActiveKbdFile());
            if (!kbd.Read())
            return false;

            kbd.RemoveAction(this.MacroName, this.MacroCategory);

            if (!kbd.Write())
            return false;

            kbd.MaxLoadKbdFile();
            return true;
        }
        //TODO: test in 3dsmax.
        /// <summary>
        /// Assigns the hotkey to the macroscript.
        /// </summary>
        public override bool Do(Installer installer)
        {
            KbdFile kbd = new KbdFile(KbdFile.MaxGetActiveKbdFile());
            if (!kbd.Read())
            return false;
            if (kbd.AddAction(this.MacroName, this.MacroCategory, this.Keys))
            {
            if (!kbd.Write())
                return false;

            kbd.MaxLoadKbdFile();
            }
            return true;
        }