Exemplo n.º 1
0
        internal CmdReturn GitGetLocalRepoFiles()
        {
            CmdReturn cmdReturn = ExecuteProcess(workingDirectory, "git ls-tree --full-tree -r HEAD", false);

            cmdReturn.fileList = ParseGetRepoFilesStdout(cmdReturn.stdout);
            return(cmdReturn);
        }
Exemplo n.º 2
0
        internal CmdReturn GitStatus()
        {
            CmdReturn cmdReturn = ExecuteProcess(workingDirectory, "git status", false);

            cmdReturn.fileList = ParseGitStatusStdout(cmdReturn.stdout);
            return(cmdReturn);
        }
Exemplo n.º 3
0
        internal CmdReturn GitGetRemoteRepoFiles()
        {
            ExecuteProcess(workingDirectory, "git fetch", true);
            CmdReturn cmdReturn = ExecuteProcess(workingDirectory, "git ls-tree --full-tree -r origin", false);

            cmdReturn.fileList = ParseGetRepoFilesStdout(cmdReturn.stdout);
            return(cmdReturn);
        }
Exemplo n.º 4
0
        internal CmdReturn ExecuteProcess(String directory, String command, bool needToInputPassword)
        {
            Process          process   = new System.Diagnostics.Process();
            ProcessStartInfo startInfo = new ProcessStartInfo();

            /*if (needToInputPassword)
             * {
             *  // The terminal is displayed, only used for sending the password to the terminal.
             *  // As in, can't find a way to hide the window AND send the password successfully.
             *  startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
             * }
             * else
             * {*/
            // Make it so the terminal isn't displayed on the screen when executing commands
            startInfo.CreateNoWindow = true;
            //}

            // The cmd terminal
            startInfo.FileName = "cmd.exe";
            Directory.SetCurrentDirectory(directory);

            startInfo.Arguments = "/C " + command;
            process.StartInfo   = startInfo;

            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardInput  = true;

            CmdReturn cmdReturn = new CmdReturn();

            process.Start();

            // For debugging purposes, do not delete!
            Process[] processlist = Process.GetProcesses();
            foreach (Process theprocess in processlist)
            {
                //todo: uncomment this
                //Console.WriteLine("Process: {0} ID: {1} MainWindowHandle: {2}", process.ProcessName, process.Id, process.MainWindowHandle);
            }

            /*if (needToInputPassword)
             * {
             *  cmdReturn.inputSuccess = SendPasswordToStdin();
             * }*/

            cmdReturn.stdout = ParseStdOut(process.StandardOutput.ReadToEnd());
            process.WaitForExit();
            cmdReturn.exitCode = process.ExitCode;
            process.Close();

            return(cmdReturn);
        }
Exemplo n.º 5
0
        internal CmdReturn ExecuteProcess(String directory, String command, bool needToInputPassword)
        {
            Process process = new System.Diagnostics.Process();
            ProcessStartInfo startInfo = new ProcessStartInfo();

            /*if (needToInputPassword)
            {
                // The terminal is displayed, only used for sending the password to the terminal.
                // As in, can't find a way to hide the window AND send the password successfully.
                startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
            }
            else
            {*/
                // Make it so the terminal isn't displayed on the screen when executing commands
                startInfo.CreateNoWindow = true;
            //}

            // The cmd terminal
            startInfo.FileName = "cmd.exe";
            Directory.SetCurrentDirectory(directory);

            startInfo.Arguments = "/C " + command;
            process.StartInfo = startInfo;

            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardInput = true;

            CmdReturn cmdReturn = new CmdReturn();
            process.Start();

            // For debugging purposes, do not delete!
            Process[] processlist = Process.GetProcesses();
            foreach (Process theprocess in processlist)
            {
                //todo: uncomment this
                //Console.WriteLine("Process: {0} ID: {1} MainWindowHandle: {2}", process.ProcessName, process.Id, process.MainWindowHandle);
            }

            /*if (needToInputPassword)
            {
                cmdReturn.inputSuccess = SendPasswordToStdin();
            }*/

            cmdReturn.stdout = ParseStdOut(process.StandardOutput.ReadToEnd());
            process.WaitForExit();
            cmdReturn.exitCode = process.ExitCode;
            process.Close();

            return cmdReturn;
        }
Exemplo n.º 6
0
        private void drawRemoteRepository()
        {
            Terminal      myTerminal           = new Terminal();
            CmdReturn     remoteRepositoryList = myTerminal.GitGetRemoteRepoFiles();
            List <String> rrList = remoteRepositoryList.fileList;

            RR_inkCanvas.Children.Clear();

            //List<String> rrList = new List<string>();


            /*
             * rrList.Add("one.cs");
             * rrList.Add("two.pdf");
             * rrList.Add("three.doc");
             * rrList.Add("four.txt");
             * rrList.Add("five.psp");
             * rrList.Add("six.ppt");
             * rrList.Add("seven.docx");
             * rrList.Add("eight.txt");
             *
             *
             * */

            int count = rrList.Count;

            System.Windows.Controls.Image[]     images     = new System.Windows.Controls.Image[count];
            System.Windows.Controls.TextBlock[] textBlocks = new TextBlock[count];

            for (int i = 0; i < count; i++)
            {
                images[i]     = new System.Windows.Controls.Image();
                textBlocks[i] = new TextBlock();
            }



            // TOGGLE THESE VALUES FOR DISPLAYING:
            int IMAGE_WIDTH         = 40;              // Width of image?
            int IMAGE_HEIGHT        = 40;              // Height of image?
            int INITIAL_TOP_MARGIN  = 80;              // initial top margin of files displayed
            int INITIAL_LEFT_MARGIN = 80;              // initial left margin
            int ROW                = 6;                // How many rows to be displayed?
            int COLUMN             = 6;                // How many columns to be displayed?
            int HORIZONTAL_SPACING = 90;               // horizontal spacing between each icon
            int VERTICAL_SPACING   = 80;               // vertical spacing between each icon

            // for all the files
            for (int i = 0; i < count; i++)
            {
                String   filename  = rrList[i];
                FileInfo temp      = new FileInfo(filename);
                String   extension = temp.Extension.ToString();

                //Console.WriteLine(filename + " " + extension);

                Icon icon = IconReader.GetFileIcon(extension, IconReader.IconSize.Large, false);

                // do complicated shit to get the image into bImag
                MemoryStream          ms   = new MemoryStream();
                System.Drawing.Bitmap dImg = icon.ToBitmap();
                dImg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                System.Windows.Media.Imaging.BitmapImage bImg = new System.Windows.Media.Imaging.BitmapImage();
                bImg.BeginInit();
                bImg.StreamSource = new MemoryStream(ms.ToArray());
                bImg.EndInit();

                // settings for images
                images[i].Source = bImg;
                images[i].Height = IMAGE_HEIGHT;
                images[i].Width  = IMAGE_WIDTH;

                // settings for textblocks
                textBlocks[i].Text          = filename;
                textBlocks[i].Foreground    = new SolidColorBrush(Colors.White);
                textBlocks[i].Background    = new SolidColorBrush(Colors.Black);
                textBlocks[i].Width         = IMAGE_WIDTH * 2;
                textBlocks[i].TextAlignment = TextAlignment.Center;

                // place the image and the textblocks on the inkCanvas

                /*
                 * System.Windows.Controls.InkCanvas.SetTop(images[i], (i / COLUMN) * HORIZONTAL_SPACING + INITIAL_TOP_MARGIN);
                 * System.Windows.Controls.InkCanvas.SetTop(textBlocks[i], (i / COLUMN) * HORIZONTAL_SPACING + INITIAL_TOP_MARGIN + IMAGE_HEIGHT + 10);
                 *
                 * System.Windows.Controls.InkCanvas.SetLeft(images[i], (i % (ROW - 1)) * VERTICAL_SPACING + INITIAL_LEFT_MARGIN);
                 * System.Windows.Controls.InkCanvas.SetLeft(textBlocks[i], (i % (ROW - 1)) * VERTICAL_SPACING + INITIAL_LEFT_MARGIN - 20);
                 */

                System.Windows.Controls.InkCanvas.SetLeft(images[i], (i % COLUMN) * HORIZONTAL_SPACING + INITIAL_LEFT_MARGIN);
                System.Windows.Controls.InkCanvas.SetLeft(textBlocks[i], (i % COLUMN) * HORIZONTAL_SPACING + INITIAL_LEFT_MARGIN - 20);

                System.Windows.Controls.InkCanvas.SetTop(images[i], (i / (COLUMN)) * VERTICAL_SPACING + INITIAL_TOP_MARGIN);
                System.Windows.Controls.InkCanvas.SetTop(textBlocks[i], (i / (COLUMN)) * VERTICAL_SPACING + INITIAL_TOP_MARGIN + IMAGE_HEIGHT + 10);

                // Add IT! AWW YEAAA
                RR_inkCanvas.Children.Add(images[i]);
                RR_inkCanvas.Children.Add(textBlocks[i]);
            }
        }