Ejemplo n.º 1
0
 /// <summary>
 /// Bind to the specific GitClient object
 /// </summary>
 internal GitClientUpdater(IProjectWatcher projectWatcher, Func <Action <string>, Task> onUpdate,
                           Func <string, string, bool> isMyProject)
 {
     _onUpdate       = onUpdate;
     _isMyProject    = isMyProject;
     _projectWatcher = projectWatcher;
 }
Ejemplo n.º 2
0
 public static Bitmap GetStatusIconFor( IProjectWatcher watcher )
 {
     return watcher.IsDirty
         ? Resources.CommitMonkeyAlert
         : Resources.CommitMonkey
         ;
 }
 public ProjectStatusLineControl( IProjectWatcher watcher, EventHandler toremove )
 {
     Watcher = watcher;
     ClientSize = new Size(400,300);
     var icon = Program.GetStatusIconFor(Watcher);
     Controls.Add( _StatusIcon = new PictureBox()
         { ClientSize = icon.Size
         , Location   = new Point(0,0)
         , Image      = icon
         , SizeMode   = PictureBoxSizeMode.AutoSize
         });
     Controls.Add( _Button = new Button()
         { ClientSize = Resources.Eraser.Size
         , Location   = new Point(19,0)
         , Image      = Resources.Eraser
         , FlatStyle  = FlatStyle.Flat
         });
     _Button.FlatAppearance.BorderSize = 0;
     _Button.Click += toremove;
     Controls.Add( _PathLabel = new Label()
         { AutoSize   = true
         , ClientSize = new Size(100,16)
         , Location   = new Point(38,0)
         , TextAlign  = ContentAlignment.MiddleLeft
         , Text       = Watcher.Path.Replace("&","&&")
         });
     UpdateControlPositions();
     Watcher.IsDirtyChanged += Watcher_IsDirtyChanged;
     Watcher_IsDirtyChanged(Watcher);
 }
 void Watchers_WatcherAdded(IProjectWatcher watcher)
 {
     int top = (Lines.Count == 0 ? 0 : Lines[Lines.Count-1].Bottom) + 3;
     var ctrl = new ProjectStatusLineControl(watcher,(sender,args) => Watchers.Remove(watcher))
         { Top = top
         , Left = 3
         };
     Lines.Add(ctrl);
     Controls.Add(ctrl);
     RedoLayout();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a factory
        /// Throws ArgumentException if passed ParentFolder does not exist
        /// </summary>
        public GitClientFactory(string parentFolder, IProjectWatcher projectWatcher)
        {
            if (!Directory.Exists(parentFolder))
            {
                throw new ArgumentException("Bad \"" + parentFolder + "\" argument");
            }

            ParentFolder   = parentFolder;
            ProjectWatcher = projectWatcher;

            Trace.TraceInformation(String.Format("[GitClientFactory] Created GitClientFactory for parentFolder {0}",
                                                 parentFolder));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Construct GitClient with a path that either does not exist or it is empty or points to a valid git repository
        /// Throws ArgumentException if requirements on `path` argument are not met
        /// </summary>
        internal GitClient(string hostname, string projectname, string path, IProjectWatcher projectWatcher)
        {
            if (!canClone(path) && !isValidRepository(path))
            {
                throw new ArgumentException("Path \"" + path + "\" already exists but it is not a valid git repository");
            }

            _hostName    = hostname;
            _projectName = projectname;
            Path         = path;
            Updater      = new GitClientUpdater(projectWatcher,
                                                async(reportProgress) =>
            {
                if (_descriptor != null)
                {
                    CancelAsyncOperation();

                    while (_descriptor != null)
                    {
                        await Task.Delay(50);
                    }
                }

                if (canClone(Path))
                {
                    string arguments = "clone --progress " + _hostName + "/" + _projectName + " " + Path;
                    await run_async(arguments, reportProgress);
                    return;
                }

                await(Task) run_in_path(() =>
                {
                    string arguments = "fetch --progress";
                    return(run_async(arguments, reportProgress));
                }, Path);
            },
                                                (hostNameToCheck, projectNameToCheck) =>
            {
                return(_hostName == hostNameToCheck && _projectName == projectNameToCheck);
            });

            Trace.TraceInformation(String.Format("[GitClient] Created GitClient at path {0} for host {1} and project {2}",
                                                 path, hostname, projectname));
        }
 void Watcher_IsDirtyChanged( IProjectWatcher watcher )
 {
     RedoLayout();
 }
 void Watchers_WatcherRemoved(IProjectWatcher watcher)
 {
     var ctrl = Lines.Find( (line) => line.Watcher == watcher );
     Lines.Remove(ctrl);
     Controls.Remove(ctrl);
     RedoLayout();
 }
 void Watcher_IsDirtyChanged( IProjectWatcher watcher )
 {
     Debug.Assert( Watcher == watcher );
     _StatusIcon.Image = Program.GetStatusIconFor(Watcher);
     UpdateControlPositions();
 }