Esempio n. 1
0
        public void AddModule(IGenericMenuCallback callback)
        {
            String name = callback.RequestString("Add Module", "Name for new module:");

            if (name != null)
            {
                bool           success;
                Transaction    xn   = new Transaction();
                IProjectAccess proj = xn.RequestWriteAccess(window.Project);
                using (xn.Start()) {
                    ProjectModule cur = proj.GetModule(name);
                    if (cur == null)
                    {
                        success = true;
                        proj.AddModule(name, new LayoutModel());
                    }
                    else
                    {
                        success = false;
                    }
                }
                if (!success)
                {
                    callback.Notify("Cannot Add", "Cannot add second module of same name.");
                }
            }
        }
Esempio n. 2
0
        public void RemoveModule(IGenericMenuCallback callback)
        {
            ProjectModule  toRemove      = window.CurrentModule;
            Transaction    xn            = new Transaction();
            IProjectAccess proj          = xn.RequestWriteAccess(window.Project);
            int            failureReason = 0;

            using (xn.Start()) {
                IEnumerator <ProjectModule> mods = proj.GetModules().GetEnumerator();
                int size;
                if (!mods.MoveNext())
                {
                    size = 0;
                }
                else
                {
                    if (!mods.MoveNext())
                    {
                        size = 1;
                    }
                    else
                    {
                        size = 2;
                    }
                }
                if (size == 1)
                {
                    failureReason = 1;
                }
                else
                {
                    bool success = proj.RemoveModule(toRemove);
                    if (!success)
                    {
                        failureReason = 2;
                    }
                }
            }
            if (failureReason == 1)
            {
                callback.Notify("Cannot Remove", "Cannot remove only module in project.");
            }
            else if (failureReason == 2)
            {
                callback.Notify("Cannot Remove", "Module not found within project.");
            }
        }
Esempio n. 3
0
        public void RenameModule(IGenericMenuCallback callback)
        {
            ProjectModule toRename = window.CurrentModule;
            String        name     = callback.RequestString("Rename Module", "New name for module:");

            if (name != null)
            {
                name = name.Trim();
                if (name == "")
                {
                    callback.Notify("Cannot Rename", "Module cannot have an empty name.");
                }
                else
                {
                    bool           success;
                    Transaction    xn   = new Transaction();
                    IProjectAccess proj = xn.RequestWriteAccess(window.Project);
                    using (xn.Start()) {
                        ProjectModule cur = proj.GetModule(name);
                        if (cur == null)
                        {
                            success = true;
                            proj.SetModuleName(toRename, name);
                        }
                        else
                        {
                            success = false;
                        }
                    }
                    if (!success)
                    {
                        callback.Notify("Cannot Rename", "Cannot add second module of same name.");
                    }
                }
            }
        }
Esempio n. 4
0
 public void Execute(IGenericMenuCallback callback)
 {
     action(callback);
 }