Ejemplo n.º 1
0
        public Globals GetGlobalVariables()
        {
            // initialize
            Globals dataReturn = new Globals();

            dataReturn.Failed = false;
            WorkingEnvironment enviromentData = new WorkingEnvironment();

            // Get environment info
            enviromentData = enviromentData.EnvironmentInfo();

            // Pick input data path to return based on environment found
            switch (enviromentData.UserDomainName)
            {
            case "AT100440":
                dataReturn.DataPath = @"C:\Users\dev1\Source\Repos\AoC_2020\Data Input\";
                break;

            case "COLUMBUS":
                dataReturn.DataPath = @"D:\Users\U.6076325\source\Repos\AoC_2020\Data Input\";
                break;

            default:
                dataReturn.Failed = true;
                break;
            }
            return(dataReturn);
        }
Ejemplo n.º 2
0
 private void OnRecentRepositoriesListItemActivated(object sender, ItemEventArgs e)
 {
     if (e.Item is RecentRepositoryListItem item)
     {
         if (WorkingEnvironment.OpenRepository(item.DataContext.Path))
         {
             if (_factory.CloseAfterRepositoryLoad)
             {
                 Close();
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void OnLocalRepositoriesListItemActivated(object sender, ItemEventArgs e)
        {
            var item = e.Item as RepositoryListItem;

            if (item != null)
            {
                if (WorkingEnvironment.OpenRepository(item.DataContext.Path))
                {
                    if (_factory.CloseAfterRepositoryLoad)
                    {
                        Close();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void _btnAddLocalRepo_LinkClicked(object sender, EventArgs e)
        {
            var path = Utility.ShowPickFolderDialog(this);

            if (!string.IsNullOrWhiteSpace(path))
            {
                var prov = WorkingEnvironment.FindProviderForDirectory(path);
                if (prov == null)
                {
                    GitterApplication.MessageBoxService.Show(
                        this,
                        Resources.ErrPathIsNotValidRepository.UseAsFormat(path),
                        Resources.ErrInvalidPath,
                        MessageBoxButton.Close,
                        MessageBoxIcon.Error);
                    return;
                }
                var item = new RepositoryListItem(new RepositoryLink(path, prov.Name));
                _lstLocalRepositories.Items.Add(item);
            }
        }
Ejemplo n.º 5
0
        public override bool Execute()
        {
            var provider = SelectedValue;

            if (provider == null)
            {
                return(false);
            }
            if (!base.Execute())
            {
                return(false);
            }
            var initDialog = SelectedControl as IRepositoryInitDialog;

            if (initDialog != null)
            {
                var repositoryPath = initDialog.RepositoryPath.Value;
                WorkingEnvironment.BeginInvoke(
                    new Func <string, bool>(WorkingEnvironment.OpenRepository),
                    new object[] { repositoryPath });
            }
            return(true);
        }
Ejemplo n.º 6
0
 private void OnLocalRepositoriesDragDrop(object sender, DragEventArgs e)
 {
     if (e.Effect != DragDropEffects.None)
     {
         if (e.Data.GetDataPresent(DataFormats.FileDrop))
         {
             var data = (string[])(e.Data.GetData(DataFormats.FileDrop));
             for (int i = 0; i < data.Length; ++i)
             {
                 var di = new DirectoryInfo(data[i]);
                 if (di.Exists)
                 {
                     var path = di.FullName;
                     if (!IsPresentInLocalRepositoryList(path))
                     {
                         var provider = WorkingEnvironment.FindProviderForDirectory(data[i]);
                         if (provider != null)
                         {
                             var link  = new RepositoryLink(path, provider.Name);
                             var point = _lstLocalRepositories.PointToClient(new Point(e.X, e.Y));
                             CustomListBoxItemsCollection itemsCollection;
                             var index = _lstLocalRepositories.GetInsertIndexFormPoint(point.X, point.Y, false, out itemsCollection);
                             if (index != -1)
                             {
                                 itemsCollection.Insert(index, new RepositoryListItem(link));
                             }
                         }
                     }
                 }
             }
         }
         else if (e.Data.GetDataPresent(typeof(RepositoryListItem)))
         {
             var itemToMove = (RepositoryListItem)e.Data.GetData(typeof(RepositoryListItem));
             var point      = _lstLocalRepositories.PointToClient(new Point(e.X, e.Y));
             CustomListBoxItemsCollection itemsCollection;
             var index = _lstLocalRepositories.GetInsertIndexFormPoint(point.X, point.Y, false, out itemsCollection);
             if (index == -1)
             {
                 return;
             }
             var currentIndex = _lstLocalRepositories.Items.IndexOf(itemToMove);
             if (index == currentIndex)
             {
                 return;
             }
             if (currentIndex == -1)
             {
                 itemsCollection.Insert(index, itemToMove);
             }
             else
             {
                 if (index > _lstLocalRepositories.Items.Count - 1)
                 {
                     --index;
                 }
                 itemToMove.Remove();
                 itemsCollection.Insert(index, itemToMove);
             }
         }
         else if (e.Data.GetDataPresent(typeof(RecentRepositoryListItem)))
         {
             var itemToMove = (RecentRepositoryListItem)e.Data.GetData(typeof(RecentRepositoryListItem));
             var path       = itemToMove.DataContext.Path;
             if (IsPresentInLocalRepositoryList(path))
             {
                 return;
             }
             var point = _lstLocalRepositories.PointToClient(new Point(e.X, e.Y));
             CustomListBoxItemsCollection itemsCollection;
             var index = _lstLocalRepositories.GetInsertIndexFormPoint(point.X, point.Y, false, out itemsCollection);
             if (index == -1)
             {
                 return;
             }
             var itemToInsert = new RepositoryListItem(new RepositoryLink(path, string.Empty));
             itemsCollection.Insert(index, itemToInsert);
         }
     }
 }