Beispiel #1
0
        public void RecentAll(IList <RecentFile> lRecentFile, IList <RecentFile> lRecentProject, IList <RecentFile> lRecentWorkspace)
        {
            ui.InsertActionGroup(dynGroupAll, 0);
            mergeIdAll = ui.NewMergeId();

            int i = 0;

            foreach (RecentFile rf in lRecentFile)
            {
                string     name   = "RecentAll" + i;
                string     label  = String.Format("_{0} {1}", i, rf.DisplayName.Replace("_", "__"));
                Gtk.Action action = new Gtk.Action(name, label);

                string fileName = rf.FileName;
                action.Activated += delegate(object sender, EventArgs e) {
                    MainClass.MainWindow.OpenFile(fileName, false);
                };
                dynGroupAll.Add(action);
                ui.AddUi(mergeIdAll, "/menubar/FileAction/RecentAll", name, name, UIManagerItemType.Menuitem, false);
                i++;
            }
            if (i > 0)
            {
                ui.AddUi(mergeIdAll, "/menubar/FileAction/RecentAll", "separatorAll11", "", UIManagerItemType.Separator, false);
            }
            int j = i;

            /*
             * foreach (RecentFile rf in lRecentProject) {
             * string name = "RecentAll" + i;
             * string label = String.Format("_{0} {1}", i, rf.DisplayName.Replace("_","__"));
             * Gtk.Action action = new Gtk.Action(name, label);
             *
             * string fileName = rf.FileName;
             * action.Activated += delegate(object sender, EventArgs e) {
             *      MainClass.MainWindow.OpenFile(fileName,true);
             * };
             * dynGroupAll.Add(action);
             * ui.AddUi(mergeIdAll, "/menubar/FileAction/RecentAll", name, name, UIManagerItemType.Menuitem, false);
             * i++;
             * }
             * ui.AddUi(mergeIdAll,"/menubar/FileAction/RecentAll","separatorAll12","",UIManagerItemType.Separator, false);
             * i++;*/

            foreach (RecentFile rf in lRecentWorkspace)
            {
                string     name   = "RecentAll" + i;
                string     label  = String.Format("_{0} {1}", i, rf.DisplayName.Replace("_", "__"));
                Gtk.Action action = new Gtk.Action(name, label);

                string fileName = rf.FileName;
                action.Activated += delegate(object sender, EventArgs e) {
                    Workspace.Workspace workspace = Workspace.Workspace.OpenWorkspace(fileName);
                    if (workspace != null)
                    {
                        MainClass.MainWindow.ReloadWorkspace(workspace, true, true);
                    }
                };
                dynGroupAll.Add(action);
                ui.AddUi(mergeIdAll, "/menubar/FileAction/RecentAll", name, name, UIManagerItemType.Menuitem, false);
                i++;
            }
            if (i > j)
            {
                ui.AddUi(mergeIdAll, "/menubar/FileAction/RecentAll", "separatorAll13", "", UIManagerItemType.Separator, false);
            }

            string nameCF  = "ClearFile";
            string labelCF = String.Format("Clear Menu");

            Gtk.Action actionCF = new Gtk.Action(nameCF, labelCF);
            actionCF.Activated += delegate(object sender, EventArgs e) {
                MainClass.Settings.RecentFiles.ClearFiles();
                MainClass.Settings.RecentFiles.ClearProjects();
                MainClass.Settings.RecentFiles.ClearWorkspace();
                //ClearRecentAll();
                RefreshRecentAll(MainClass.Settings.RecentFiles.GetFiles(),
                                 MainClass.Settings.RecentFiles.GetProjects(),
                                 MainClass.Settings.RecentFiles.GetWorkspace());
            };
            dynGroupAll.Add(actionCF);
            ui.AddUi(mergeIdAll, "/menubar/FileAction/RecentAll", nameCF, nameCF, UIManagerItemType.Menuitem, false);
        }
Beispiel #2
0
        public void RefreshRecentAll(IList <RecentFile> lRecentFile, IList <RecentFile> lRecentProject, IList <RecentFile> lRecentWorkspace)
        {
            //ui.RemoveUi(mergeIdAll);
            //ui.RemoveActionGroup(dynGroupAll);
            Menu subMenu = new Menu();


            MenuItem miR = (MenuItem)this.GetWidget("/menubar/FileAction/RecentAll");

            if (miR != null)
            {
                miR.Submenu = subMenu;
            }


            //dynGroupAll = new ActionGroup("RecentAll");
            //ui.InsertActionGroup(dynGroupAll, 0);

            int i = 0;

            foreach (RecentFile rf in lRecentFile)
            {
                string name  = "RecentAll" + i;
                string label = String.Format("_{0} {1}", i, rf.DisplayName.Replace("_", "__"));


                MenuItem mi = new MenuItem(label);
                mi.Name = name;
                string fileName = rf.FileName;
                mi.Activated += delegate(object sender, EventArgs e) {
                    MainClass.MainWindow.OpenFile(fileName, true);
                };
                i++;
                subMenu.Add(mi);
            }
            if (i > 0)
            {
                subMenu.Add(new SeparatorMenuItem());
            }
            int j = i;

            /*foreach (RecentFile rf in lRecentProject) {
             *      string name = "RecentAll" + i;
             *      string label = String.Format("_{0} {1}", i, rf.DisplayName.Replace("_","__"));
             *      Gtk.Action action = new Gtk.Action(name, label);
             *
             *      string fileName = rf.FileName;
             *      action.Activated += delegate(object sender, EventArgs e) {
             *              MainClass.MainWindow.OpenFile(fileName,true);
             *      };
             *      dynGroupAll.Add(action);
             *      ui.AddUi(mergeIdAll, "/menubar/FileAction/RecentAll", name, name, UIManagerItemType.Menuitem, false);
             *      i++;
             * }
             * ui.AddUi(mergeIdAll,"/menubar/FileAction/RecentAll","separatorAll12","",UIManagerItemType.Separator, false);
             *      i++;*/

            foreach (RecentFile rf in lRecentWorkspace)
            {
                string name  = "RecentAll" + i;
                string label = String.Format("_{0} {1}", i, rf.DisplayName.Replace("_", "__"));

                MenuItem mi = new MenuItem(label);
                mi.Name = name;
                string fileName = rf.FileName;
                mi.Activated += delegate(object sender, EventArgs e) {
                    Workspace.Workspace workspace = Workspace.Workspace.OpenWorkspace(fileName);
                    if (workspace != null)
                    {
                        MainClass.MainWindow.ReloadWorkspace(workspace, true, true);
                    }
                };
                i++;
                subMenu.Add(mi);
            }

            if (i > j)
            {
                subMenu.Add(new SeparatorMenuItem());
            }

            string nameCF  = "ClearFile";
            string labelCF = String.Format("Clear Menu");

            MenuItem miCF = new MenuItem(labelCF);

            miCF.Name       = nameCF;
            miCF.Activated += delegate(object sender, EventArgs e) {
                MainClass.Settings.RecentFiles.ClearFiles();
                MainClass.Settings.RecentFiles.ClearProjects();
                MainClass.Settings.RecentFiles.ClearWorkspace();
                RefreshRecentAll(MainClass.Settings.RecentFiles.GetFiles(),
                                 MainClass.Settings.RecentFiles.GetProjects(),
                                 MainClass.Settings.RecentFiles.GetWorkspace());
            };
            i++;
            subMenu.Add(miCF);

            miR.ShowAll();
        }
Beispiel #3
0
        internal static Workspace CreateWorkspace(string filePath, string workspaceName, string workspaceOutput, string workspaceRoot, bool copyLibs)
        {
            Workspace workspace = new Workspace();

            workspace.FilePath = filePath;
            workspace.RootDirectory = workspaceRoot;
            workspace.OutputDirectory = workspaceOutput;
            workspace.Name = workspaceName;

            if (!Directory.Exists(workspace.RootDirectory)){
                try {
                    Directory.CreateDirectory(workspace.RootDirectory);
                }catch(Exception ex){
                    throw new Exception(MainClass.Languages.Translate("cannot_create_root",workspace.RootDirectory) + "\n"+ ex.Message);

                    /*MessageDialogs md =
                        new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_create_root",workspace.RootDirectory), ex.Message, Gtk.MessageType.Error);
                    md.ShowDialog();
                    return null;*/
                }
            }

            if (!Directory.Exists(workspace.OutputMaskToFullPath)){
                try {
                    Directory.CreateDirectory(workspace.OutputMaskToFullPath);
                }catch{

                }
            }
            //Console.WriteLine("MainClass.Settings.LibDirectory -> {0}",MainClass.Settings.LibDirectory);
            if (!Directory.Exists(MainClass.Settings.LibDirectory)){
                throw new Exception(MainClass.Languages.Translate("invalid_lids_dir",MainClass.Settings.LibDirectory) );
                    /*MessageDialogs md =
                        new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_lids_dir",MainClass.Settings.LibDirectory),"", Gtk.MessageType.Error);
                    md.ShowDialog();
                    return null;*/
            }

            if (copyLibs)
                MainClass.Tools.CopyDirectory(MainClass.Settings.LibDirectory, workspace.RootDirectory, true, true);
            else
            {
                MainClass.Tools.CreateLinks(MainClass.Settings.LibDirectory, workspace.RootDirectory, true, false);
            }
            workspace.SaveWorkspace();

            return workspace;
        }