Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();
            DestinationPathTextBox.Text = DestinationFolderPath;

            if (StaticVariables.SelectedFiles.Length > 0)
            {
                DefaultSourcePath = Path.GetDirectoryName(StaticVariables.SelectedFiles[0]);
            }

            var projects = new List <TemplateProject>();
            //var sourcePath = Environment.GetCommandLineArgs()[1];
            var sourcePath = DefaultSourcePath;
            var folders    = Directory.GetDirectories(sourcePath);
            var files      = Directory.GetFiles(sourcePath);

            var selectedfiles   = new List <TemplateProject>();
            var selectedfolders = new List <TemplateProject>();

            foreach (var relativepathtempl in folders)
            {
                var proj = new TemplateProject(
                    Path.GetFileName(relativepathtempl),
                    Path.GetFullPath(relativepathtempl),
                    FileOrFolder.Folder);
                projects.Add(proj);
                if (StaticVariables.SelectedFiles.Contains(relativepathtempl))
                {
                    selectedfolders.Add(proj);
                }
            }

            foreach (var relativepathtempl in files)
            {
                if (relativepathtempl.EndsWith(".gitingnore"))
                {
                    continue;
                }

                var proj = new TemplateProject(
                    Path.GetFileName(relativepathtempl),
                    Path.GetFullPath(relativepathtempl),
                    FileOrFolder.File);
                projects.Add(proj);

                if (StaticVariables.SelectedFiles.Contains(relativepathtempl))
                {
                    selectedfiles.Add(proj);
                }
            }

            ListBoxTest.ItemsSource = projects;
            foreach (var selecteditem in selectedfiles.Concat(selectedfolders))
            {
                ListBoxTest.SelectedItems.Add(selecteditem);
            }

            ListBoxTest.Focus();
        }