コード例 #1
0
ファイル: FormMain.cs プロジェクト: orf53975/GitForce
        /// <summary>
        /// Load a workspace selected by the last recently used menu
        /// </summary>
        private void WorkspaceLoadLruMenuItem(object sender, EventArgs e)
        {
            string name = (sender as ToolStripMenuItem).Tag as string;

            // Save existing workspace before trying to load a new one
            if (ClassWorkspace.Save(null))
            {
                if (ClassWorkspace.Load(name))
                {
                    App.DoRefresh();
                }
                else
                {
                    if (MessageBox.Show("The specified workspace file cannot be loaded, or the loading was cancelled." + Environment.NewLine + "Do you want to remove it from the list of recently used workspaces?",
                                        "Load Workspace", MessageBoxButtons.YesNo, MessageBoxIcon.Error) != DialogResult.Yes)
                    {
                        return;
                    }
                    // Remove the workspace file from the LRU list
                    var lru = ClassWorkspace.GetLRU();
                    lru.Remove(name);
                    ClassWorkspace.SetLRU(lru);
                }
            }
        }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: orf53975/GitForce
 /// <summary>
 /// Save current workspace
 /// </summary>
 private void WorkspaceSaveMenuItem(object sender, EventArgs e)
 {
     if (saveWk.ShowDialog() == DialogResult.OK)
     {
         ClassWorkspace.Save(saveWk.FileName);
     }
 }
コード例 #3
0
ファイル: FormMain.cs プロジェクト: Celebrate/GitForce
        public void BuildFileMenu()
        {
            menuMainFile.DropDownItems.Clear();
            menuMainFile.DropDownItems.AddRange(PanelView.GetContextMenu(menuMainFile.DropDown));

            // Add the workspace menu items
            ToolStripMenuItem mWkCreate = new ToolStripMenuItem("Create Workspace", null, WorkspaceCreateMenuItem);
            ToolStripMenuItem mWkClear  = new ToolStripMenuItem("Clear Workspace", null, WorkspaceClearMenuItem);
            ToolStripMenuItem mWkImport = new ToolStripMenuItem("Import Workspace...", null, WorkspaceImportMenuItem);
            ToolStripMenuItem mWkLoad   = new ToolStripMenuItem("Load Workspace...", null, WorkspaceLoadMenuItem);
            ToolStripMenuItem mWkSave   = new ToolStripMenuItem("Save Workspace As...", null, WorkspaceSaveMenuItem);
            ToolStripMenuItem mWkLru    = new ToolStripMenuItem("Recent Workspaces", null, WorkspaceLoadLruMenuItem);
            ToolStripMenuItem mExit     = new ToolStripMenuItem("Exit", null, MenuExit, Keys.Alt | Keys.F4);

            // Fill in the last recently used workspace list of items
            List <string> lru = ClassWorkspace.GetLRU();

            foreach (var file in lru)
            {
                mWkLru.DropDownItems.Add(new ToolStripMenuItem(file, null, WorkspaceLoadLruMenuItem)
                {
                    Tag = file
                });
            }
            mWkLru.Enabled  = lru.Count > 0;
            mWkSave.Enabled = App.Repos.Current != null;

            menuMainFile.DropDownItems.AddRange(new ToolStripItem[] {
                new ToolStripSeparator(),
                mWkCreate, mWkClear, mWkImport, mWkLoad, mWkSave, mWkLru,
                new ToolStripSeparator(),
                mExit
            });
        }
コード例 #4
0
ファイル: FormMain.cs プロジェクト: Celebrate/GitForce
        /// <summary>
        /// Main form initialization method performs operations that may need the main
        /// window to have already been shown since we may invoke its UI handlers
        /// </summary>
        public void Initialize()
        {
            // Load default set of repositories
            ClassWorkspace.Load(null);

            // Load custom tools
            App.CustomTools = ClassCustomTools.Load(DefaultCustomToolsFile);

            // If there are no tools on the list, find some local tools and add them
            if (App.CustomTools.Tools.Count == 0)
            {
                App.CustomTools.Tools.AddRange(ClassCustomTools.FindLocalTools());
            }

            // If there is no current repo, switch the right panel view to Repos
            // Otherwise, restore the last view panel
            ChangeRightPanel(App.Repos.Current == null ?
                             "Repos" :
                             Properties.Settings.Default.viewRightPanel);

            // Usability improvement: When starting the app, check if the global user name
            // and email are defined and if not, open the settings dialog. This helps when
            // starting the app for the first time.
            if (string.IsNullOrEmpty(ClassConfig.GetGlobal("user.name")) &&
                string.IsNullOrEmpty(ClassConfig.GetGlobal("user.email")))
            {
                MenuOptions(null, null);
            }
        }
コード例 #5
0
ファイル: FormMain.cs プロジェクト: orf53975/GitForce
 /// <summary>
 /// Clear current workspace
 /// </summary>
 private void WorkspaceClearMenuItem(object sender, EventArgs e)
 {
     // Clear current workspace
     if (MessageBox.Show("Current workspace will be cleared from all git repositories. Continue?",
                         "Clear Workspace", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         ClassWorkspace.Clear();
     }
 }
コード例 #6
0
ファイル: FormMain.cs プロジェクト: orf53975/GitForce
 /// <summary>
 /// Select and load a specific workspace
 /// </summary>
 private void WorkspaceLoadMenuItem(object sender, EventArgs e)
 {
     if (loadWk.ShowDialog() == DialogResult.OK)
     {
         // Save existing workspace before trying to load a new one
         if (ClassWorkspace.Save(null))
         {
             if (ClassWorkspace.Load(loadWk.FileName))
             {
                 App.DoRefresh();
             }
         }
     }
 }
コード例 #7
0
ファイル: FormMain.cs プロジェクト: orf53975/GitForce
 private void FormMainDragDrop(object sender, DragEventArgs e)
 {
     string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
     if (files.Count() == 1 && Path.GetExtension(files[0]) == ".giw")
     {
         // Save the current workspace and load the one user dropped in
         if (ClassWorkspace.Save(null))
         {
             if (ClassWorkspace.Load(files[0]))
             {
                 App.DoRefresh();
             }
         }
     }
 }
コード例 #8
0
ファイル: FormMain.cs プロジェクト: orf53975/GitForce
 /// <summary>
 /// Create a new workspace at the specified (workspace) file location
 /// </summary>
 private void WorkspaceCreateMenuItem(object sender, EventArgs e)
 {
     // Save existing workspace before trying to create a new one
     if (ClassWorkspace.Save(null))
     {
         // Ask user to select a new workspace file name
         if (createWk.ShowDialog() == DialogResult.OK)
         {
             // Create a new workspace by saving an empty one and then reloading it
             ClassWorkspace.Clear();
             ClassWorkspace.Save(createWk.FileName);
             ClassWorkspace.Load(createWk.FileName);
             App.DoRefresh();
         }
     }
 }
コード例 #9
0
ファイル: FormMain.cs プロジェクト: orf53975/GitForce
        /// <summary>
        /// Main form initialization method performs operations that may need the main
        /// window to have already been shown since we may invoke its UI handlers
        /// </summary>
        public bool Initialize()
        {
            // Load default set of repositories
            // If this is the first time run, initialize the default workspace file name
            if (string.IsNullOrEmpty(Properties.Settings.Default.WorkspaceFile))
            {
                Properties.Settings.Default.WorkspaceFile = Path.Combine(App.AppHome, "repos.giw");
            }
            string name = Properties.Settings.Default.WorkspaceFile;

            if (File.Exists(name))              // Even if the workspace does not exist at this point
            {
                if (!ClassWorkspace.Load(name)) // still use it's name and continue running since it
                {
                    return(false);              // will be saved on a program exit
                }
            }
            // Load custom tools
            App.CustomTools = ClassCustomTools.Load(DefaultCustomToolsFile);

            // If there are no tools on the list, find some local tools and add them
            if (App.CustomTools.Tools.Count == 0)
            {
                App.CustomTools.Tools.AddRange(ClassCustomTools.FindLocalTools());
            }

            // If there is no current repo, switch the right panel view to Repos
            // Otherwise, restore the last view panel
            ChangeRightPanel(App.Repos.Current == null ?
                             "Repos" :
                             Properties.Settings.Default.viewRightPanel);

            // Usability improvement: When starting the app, check if the global user name
            // and email are defined and if not, open the settings dialog. This helps when
            // starting the app for the first time.
            if (string.IsNullOrEmpty(ClassConfig.GetGlobal("user.name")) &&
                string.IsNullOrEmpty(ClassConfig.GetGlobal("user.email")))
            {
                MenuOptions(null, null);
            }
            return(true);
        }
コード例 #10
0
ファイル: FormMain.cs プロジェクト: orf53975/GitForce
        /// <summary>
        /// Form is closing
        /// </summary>
        private void FormMainFormClosing(object sender, FormClosingEventArgs e)
        {
            // Remove the print status handler
            App.PrintStatusMessage -= PrintStatus;

            // Store geometry of _this_ window
            ClassWinGeometry.Save(this);

            // Save custom tools to their default location
            App.CustomTools.Save(DefaultCustomToolsFile);

            // Close the log windown manually in order to save its geometry
            App.Log.FormClosing -= LogWindowToolStripMenuItemClick;
            App.Log.Close();

            // Save windows geometry database
            ClassWinGeometry.SaveGeometryDatabase();

            // Save current workspace
            ClassWorkspace.Save(null);

            // Remove all outstanding temp files
            ClassGlobals.RemoveTempFiles();
        }
コード例 #11
0
        /// <summary>
        /// Main form initialization method performs operations that may need the main
        /// window to have already been shown since we may invoke its UI handlers
        /// Optionally, open an existing git repo at the path given in the initRepo argument
        /// </summary>
        public bool Initialize(string initRepo)
        {
            // Load default set of repositories
            // If this is the first time run, initialize the default workspace file name
            if (string.IsNullOrEmpty(Properties.Settings.Default.WorkspaceFile))
            {
                Properties.Settings.Default.WorkspaceFile = Path.Combine(App.AppHome, "repos.giw");
            }
            string name = Properties.Settings.Default.WorkspaceFile;

            if (File.Exists(name))              // Even if the workspace does not exist at this point
            {
                if (!ClassWorkspace.Load(name)) // still use it's name and continue running since it
                {
                    return(false);              // will be saved on a program exit
                }
            }
            // Load custom tools
            App.CustomTools = ClassCustomTools.Load(DefaultCustomToolsFile);

            // If there are no tools on the list, find some local tools and add them
            if (App.CustomTools.Tools.Count == 0)
            {
                App.CustomTools.Tools.AddRange(ClassCustomTools.FindLocalTools());
            }

            // If there is no current repo, switch the right panel view to Repos
            // Otherwise, restore the last view panel
            ChangeRightPanel(App.Repos.Current == null ?
                             "Repos" :
                             Properties.Settings.Default.viewRightPanel);

            // The user requested to open a specific repo with the --repo command line argument
            if (initRepo != null)
            {
                try
                {
                    ClassRepo repo = App.Repos.Find(initRepo);
                    if (repo == null)
                    {
                        repo = App.Repos.Add(ClassCommandLine.initRepo);
                    }
                    App.Repos.SetCurrent(repo);
                    ChangeRightPanel("Revisions"); // Set the right pane to "Revisions" tab
                    App.PrintStatusMessage("Opening repo " + repo, MessageType.General);
                }
                catch (Exception ex)
                {
                    App.PrintLogMessage("Unable to open repo: " + ex.Message, MessageType.Error);
                    App.PrintStatusMessage(ex.Message, MessageType.Error);
                }
            }

            // Usability improvement: When starting the app, check if the global user name
            // and email are defined and if not, open the settings dialog. This helps when
            // starting the app for the first time.
            if (string.IsNullOrEmpty(ClassConfig.GetGlobal("user.name")) &&
                string.IsNullOrEmpty(ClassConfig.GetGlobal("user.email")))
            {
                MenuOptions(null, null);
            }

            return(true);
        }