public CommitView(GitViewModel gitViewModel, IList selectedFiles)
        {
            var commitViewModel = new CommitViewModel();

            commitViewModel._gitViewModel  = gitViewModel;
            commitViewModel._selectedFiles = selectedFiles;
            commitViewModel.CloseAction    = () =>
            {
                this.Close();
            };
            this.DataContext = commitViewModel;
            InitializeComponent();
        }
Exemple #2
0
        public MasterViewModel(GitViewModel gitViewModel, FileAndFolderBrowserViewModel fileAndFolderBrowserViewModel, LockedFilesViewModel lockedFilesViewModel)
        {
            _gitViewModel                  = gitViewModel;
            _lockedFilesViewModel          = lockedFilesViewModel;
            _fileAndFolderBrowserViewModel = fileAndFolderBrowserViewModel;

            // Used to refresh the files/folders that exist on the serevr after git has pulled/pushed new ones
            //new Task(() =>
            //{
            //    while (true)
            //    {
            //        var selectedFolder = SelectedFolder;
            //        _fileAndFolderBrowserViewModel.UpdateFilesAndFolders();
            //        SelectedFolder = selectedFolder;
            //        OnPropertyChanged(nameof(FolderList));
            //        System.Threading.Thread.Sleep(10000);
            //    }
            //}).Start();
        }
        private void RunConsoleCommand(string command)
        {
            isGit = true;
            if (!string.IsNullOrWhiteSpace(command) &&
                (commandHistory.Count == 0 || commandHistory.Last() != command))
            {
                commandHistory.Add(command);
                commandIdx = commandHistory.Count - 1;
            }

            if (!ProcessInternalCommand(command))
            {
                if (command == "git")
                {
                    //command = "/C \"\"" + GitExePath + "\"";
                    GitViewModel.OpenGitBash();
                    return;
                }
                else if (command.StartsWith("git "))
                {
                    command = command.Substring(4);
                    command = "/C \"\"" + GitExePath + "\" " + command + "\"";
                }
                else
                {
                    command = "/C " + command;
                    isGit   = false;
                }

                ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe");
                startInfo.Arguments = command;
                //startInfo.RedirectStandardInput = true;
                startInfo.RedirectStandardError  = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.UseShellExecute        = false;
                startInfo.CreateNoWindow         = true;
                startInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                startInfo.ErrorDialog            = false;
                startInfo.WorkingDirectory       = WorkingDirectory;

                using (Process process = Process.Start(startInfo))
                    using (ManualResetEvent mreOut = new ManualResetEvent(false), mreErr = new ManualResetEvent(false))
                    {
                        flag = 0;

                        //new ReadOutput(process.StandardOutput, mreOut, (c) =>
                        //{
                        //    Action act = () =>
                        //    {
                        //        TextRange range = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);
                        //        range.Text = c.ToString();
                        //        this.richTextBox1.CaretPosition = this.richTextBox1.CaretPosition.DocumentEnd;
                        //        //this.richTextBox1.AppendText(c.ToString());
                        //    };
                        //    this.Dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle);
                        //});

                        process.OutputDataReceived += (o, e) =>
                        {
                            if (e.Data == null)
                            {
                                mreOut.Set();
                                Done();
                            }
                            else
                            {
                                WriteOutput(e.Data);
                            }
                        };
                        process.BeginOutputReadLine();

                        process.ErrorDataReceived += (o, e) =>
                        {
                            if (e.Data == null)
                            {
                                mreErr.Set();
                                Done();
                            }
                            else
                            {
                                WriteError(e.Data);
                            }
                        };
                        process.BeginErrorReadLine();

                        //string line = "git status";
                        ////while (input != null && null != (line = input.ReadLine()))
                        //process.StandardInput.WriteLine(line);
                        //process.StandardInput.Close();

                        process.WaitForExit();
                        mreOut.WaitOne();
                        mreErr.WaitOne();

                        //var code = process.ExitCode;
                    }
            }
        }
 public PendingChanges()
 {
     InitializeComponent();
     this.service = GitViewModel.Current;
 }
Exemple #5
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     this.service = GitViewModel.Current;
 }