Ejemplo n.º 1
0
        private void OnSettingAuthor(object sender, EventArgs e)
        {
            DoubleInput conform = new DoubleInput();

            conform.Text          = "Git author setting";
            conform.label1.Text   = "Username";
            conform.label2.Text   = "E-mail";
            conform.ConfirmEvent += (sd, author, email) => {
                if (author == "")
                {
                    MessageBox.Show("Username can't be empty.");
                    return;
                }
                if (email == "")
                {
                    MessageBox.Show("E-mail can't be empty.");
                    return;
                }
                string reg = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
                Regex  r   = new Regex(reg);
                if (!r.IsMatch(email))
                {
                    MessageBox.Show("E-mail is not a email.");
                    return;
                }

                GH_SettingsServer sserver = new GH_SettingsServer("ggit");
                sserver.SetValue("author", author);
                sserver.SetValue("email", email);
                sserver.WritePersistentSettings();

                conform.Close();
            };
            conform.Show(ActiveCanvas.FindForm());
        }
Ejemplo n.º 2
0
        private void OnClone(object sender, EventArgs e)
        {
            DoubleInput cloneForm = new DoubleInput();

            cloneForm.Text = "Clone remote repository";

            cloneForm.label1.Text = "Remote Url";
            cloneForm.label2.Text = "Local Path";

            cloneForm.input2.Cursor   = Cursors.Hand;
            cloneForm.input2.Text     = "Click me !";
            cloneForm.input2.ReadOnly = true;
            cloneForm.input2.Click   += (ed, eg) =>
            {
                if (cloneForm.input1.Text == "")
                {
                    MessageBox.Show("No remote url found");
                    return;
                }
                FolderBrowserDialog folder = new FolderBrowserDialog();
                DialogResult        res    = folder.ShowDialog();
                if (res == DialogResult.OK || res == DialogResult.Yes)
                {
                    Uri    uri  = new Uri(cloneForm.input1.Text);
                    string name = uri.Segments[uri.Segments.Length - 1].TrimEnd('/').Split('.')[0];
                    cloneForm.input2.Text = Path.Combine(@folder.SelectedPath, name);
                }
            };

            cloneForm.Show();

            cloneForm.ConfirmEvent += async(sd, url, path) =>
            {
                LoadingForm loadingForm = new LoadingForm();
                loadingForm.Show(ActiveCanvas.FindForm());
                await Task.Run(() => CloneRepository(url, path));

                loadingForm.Close();
                cloneForm.Close();
                Uri    uri  = new Uri(url);
                string name = uri.Segments[uri.Segments.Length - 1].TrimEnd('/').Split('.')[0];
                MessageBox.Show(string.Format("{0} is Cloned to {1}", name, path));
            };
        }
Ejemplo n.º 3
0
        private void OnDocumentCommit(object sender, EventArgs e)
        {
            if (getSignature() == null)
            {
                MessageBox.Show(string.Format("Please tell git who you are!"));
                DoubleInput conform = new DoubleInput();
                conform.Show(ActiveCanvas.FindForm());
                return;
            }
            if (ActiveCanvas.Document == null)
            {
                return;
            }
            bool isModified = ActiveCanvas.Document.IsModified;

            if (isModified)
            {
                MessageBox.Show(string.Format("Please save this document first!"));
            }
            else
            {
                string     docPath    = ActiveCanvas.Document.FilePath;
                CommitForm commitForm = new CommitForm(docPath);
                try
                {
                    using (var repo = new Repository(getWorkDir(docPath)))
                    {
                        if (!repo.RetrieveStatus().IsDirty)
                        {
                            MessageBox.Show("Nothing To Commit !");
                        }
                        else
                        {
                            commitForm.Show(ActiveCanvas.FindForm());
                        }
                    }
                }
                catch
                {
                }
            }
        }