Exemplo n.º 1
0
        public void CTorTest()
        {
            cui = new CuiFile();
             Assert.AreEqual(String.Empty, cui.File, "Empty ctor should set File to String.Empty");
             Assert.IsNotNull(cui.Toolbars, "Empty ctor should initialize toolbars property");
             Assert.AreEqual(0, cui.Toolbars.Count, "Empty ctor should create Toolbars property with count 0");

             cui = new CuiFile("testfile");
             Assert.AreEqual("testfile", cui.File, "File property should be set");
             Assert.IsNotNull(cui.Toolbars, "Toolbars property should be initialized");
             Assert.AreEqual(0, cui.Toolbars.Count, "Toolbars property count should be 0");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new toolbar.
        /// </summary>
        public override bool Do(Installer installer)
        {
            //TODO: save config before reading (to catch modifications made in current session).
            CuiFile cui = new CuiFile(CuiFile.MaxGetActiveCuiFile());
            if (!cui.Read())
                return false;

            if (!cui.ContainsToolbar(this.ToolbarName))
            {
               cui.AddToolbar(this.ToolbarName, 5, 0); //TODO: Store size somewhere in action?

               if (!cui.Write())
                  return false;
               else
                  cui.MaxLoadCuiFile();
            }

            return true;
        }
        /// <summary>
        /// Remove a button from a toolbar.
        /// </summary>
        public override bool Undo(Installer installer)
        {
            CuiFile cui = new CuiFile(CuiFile.MaxGetActiveCuiFile());
            if (!cui.Read())
                return false;

            Int32 numRemoved = 0;
            foreach (CuiToolbar toolbar in cui.Toolbars)
            {
               numRemoved += toolbar.RemoveButton(this.MacroName, this.MacroCategory);
            }

            if (numRemoved > 0)
            {
               if (!cui.Write())
                  return false;
               else
                  cui.MaxLoadCuiFile();
            }

            return true;
        }
        /// <summary>
        /// Create a button on a toolbar.
        /// </summary>
        public override bool Do(Installer installer)
        {
            //TODO: save config before reading (to catch modifications made in current session).
            CuiFile cui = new CuiFile(CuiFile.MaxGetActiveCuiFile());
            if (!cui.Read())
                return false;

            CuiToolbar toolbar = cui.GetToolbar(this.ToolbarName);
            if (toolbar != null)
            {
               toolbar.AddButton(this.MacroName, this.MacroCategory, this.TooltipText, this.ButtonText);
               if (cui.Write())
                  cui.MaxLoadCuiFile();
               else
                  return false;
            }

            return true;
        }
        /// <summary>
        /// Creates a separator on the toolbar.
        /// </summary>
        public override bool Do(Installer installer)
        {
            //TODO: save config before reading (to catch modifications made in current session).
            CuiFile cui = new CuiFile(CuiFile.MaxGetActiveCuiFile());
            if (!cui.Read())
                return false;

            CuiToolbar toolbar = cui.GetToolbar(this.ToolbarName);
            if (toolbar != null)
            {
               toolbar.AddSeparator();
               if (cui.Write())
                  cui.MaxLoadCuiFile();  //TODO: Find way to not have to hard-reload for every action. (Post-install event?)
               else
                  return false;
            }

            return true;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Removes the created toolbar.
        /// </summary>
        public override bool Undo(Installer installer)
        {
            CuiFile cui = new CuiFile(CuiFile.MaxGetActiveCuiFile());
            if (!cui.Read())
                return false;

            if (cui.RemoveToolbar(this.ToolbarName))
            {
                if (!cui.Write())
                    return false;
                else
                    cui.MaxLoadCuiFile();
            }

            return true;
        }
Exemplo n.º 7
0
 public void TestInit()
 {
     cui = new CuiFile();
      FileStream stream = new FileStream(cuiFile, FileMode.Open);
      Assert.IsTrue(cui.Read(stream), "Read cui file");
      stream.Close();
 }