Exemplo n.º 1
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
        /// </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);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Implements a deep copy of the whole class.
 /// </summary>
 public ClassCustomTools Copy()
 {
     ClassCustomTools ct = new ClassCustomTools();
     foreach (var classTool in Tools)
         ct.Tools.Add((ClassTool)classTool.Clone());
     return ct;
 }
Exemplo n.º 3
0
        public FormCustomizeTools(ClassCustomTools customTools)
        {
            InitializeComponent();
            ClassWinGeometry.Restore(this);

            CustomTools = customTools.Copy();
            RefreshList(0);
        }
Exemplo n.º 4
0
        public FormCustomizeTools(ClassCustomTools customTools)
        {
            InitializeComponent();
            ClassWinGeometry.Restore(this);

            CustomTools = customTools.Copy();
            RefreshList(0);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Implements a deep copy of the whole class.
        /// </summary>
        public ClassCustomTools Copy()
        {
            ClassCustomTools ct = new ClassCustomTools();

            foreach (var classTool in Tools)
            {
                ct.Tools.Add((ClassTool)classTool.Clone());
            }
            return(ct);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Import a set of custom tools from a file
 /// </summary>
 private void ImportToolMenuItemClick(object sender, EventArgs e)
 {
     if (openTools.ShowDialog() == DialogResult.OK)
     {
         ClassCustomTools newTools = ClassCustomTools.Load(openTools.FileName);
         if (newTools != null)
         {
             App.CustomTools = newTools;
             App.PrintStatusMessage("Loaded custom tools from " + openTools.FileName, MessageType.General);
         }
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Load a set of tools from a given file into the current tool-set.
 /// Returns a new class structure containing all the tools if the tools loaded correctly.
 /// If load failed, return empty class and print the error message to a main pane.
 /// </summary>
 public static ClassCustomTools Load(string name)
 {
     ClassCustomTools ct = new ClassCustomTools();
     try
     {
         XmlSerializer deserializer = new XmlSerializer(typeof(ClassCustomTools));
         using (TextReader textReader = new StreamReader(name))
         {
             ct = (ClassCustomTools)deserializer.Deserialize(textReader);
         }
     }
     catch (Exception ex)
     {
         App.PrintStatusMessage("Error loading custom tools: " + ex.Message, MessageType.Error);
     }
     return ct;
 }
Exemplo n.º 8
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
        /// </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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Load a set of tools from a given file into the current tool-set.
        /// Returns a new class structure containing all the tools if the tools loaded correctly.
        /// If load failed, return empty class and print the error message to a main pane.
        /// </summary>
        public static ClassCustomTools Load(string name)
        {
            App.PrintStatusMessage("Loading custom tools: " + name, MessageType.General);
            ClassCustomTools ct = new ClassCustomTools();

            try
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(ClassCustomTools));
                using (TextReader textReader = new StreamReader(name))
                {
                    ct = (ClassCustomTools)deserializer.Deserialize(textReader);
                }
            }
            catch (Exception ex)
            {
                // It is OK not to find custom tools file (for example, the app is being run the very first time)
                // All other errors are being reported
                if (!(ex is FileNotFoundException))
                {
                    App.PrintStatusMessage("Error loading custom tools: " + ex.Message, MessageType.Error);
                }
            }
            return(ct);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Load a set of tools from a given file into the current tool-set.
 /// Returns a new class structure containing all the tools if the tools loaded correctly.
 /// If load failed, return empty class and print the error message to a main pane.
 /// </summary>
 public static ClassCustomTools Load(string name)
 {
     App.PrintStatusMessage("Loading custom tools: " + name, MessageType.General);
     ClassCustomTools ct = new ClassCustomTools();
     try
     {
         XmlSerializer deserializer = new XmlSerializer(typeof(ClassCustomTools));
         using (TextReader textReader = new StreamReader(name))
         {
             ct = (ClassCustomTools)deserializer.Deserialize(textReader);
         }
     }
     catch (Exception ex)
     {
         // It is OK not to find custom tools file (for example, the app is being run the very first time)
         // All other errors are being reported
         if (!(ex is FileNotFoundException))
             App.PrintStatusMessage("Error loading custom tools: " + ex.Message, MessageType.Error);
     }
     return ct;
 }