/// <summary> /// Définit si l'animation de chargement soit s'afficher ou non /// </summary> /// <param name="panel">Panel dans lequel insérer l'animation de chargement, null si pas de chargement</param> public void SetLoading(Panel panel) { // débute le chargement if (panel != null && _pageLoaded == false) // si on active le chargement { if (_waiting == null) { _waiting = new Waiting(); // crée le control si pas encore fait } _waiting.Name = "waiting"; // nom permettant de le supprimer plus facilement _waiting.Location = new Point( (panel.Width - _waiting.Width) / 2, (panel.Height - _waiting.Height) / 2 ); panel.Controls.Add(_waiting); // ajout l'animation de chargement au panel _page.FlatDataGridView.DataSourceChanged(DataAddedToDgv); // méthode de callback à appeler lorsque les données sont chargées (fin du chargement) _page.FlatDataGridView.Visible = false; // désactive la dgv durant le chargement } // fin du chargement et présence de donnée else if (_page.FlatDataGridView.Rows.Count != 0 && _pageLoaded) { _waiting.Dispose(); // retire l'animation de chargement _page.FlatDataGridView.Visible = true; // affiche les données } // fin du chargement et absence de donnée else if (_page.FlatDataGridView.Rows.Count == 0 && _pageLoaded) { Control parent; if (!_waiting.IsDisposed) { parent = _waiting.Parent; _waiting.Dispose(); _labelNoItem = new FlatLabel() { ForeColor = Theme.BackLight, AutoSize = true, Font = new Font(Theme.Font.FontFamily, 24, FontStyle.Bold), Text = @"Aucune tâche à afficher" }; parent.Controls.Add(_labelNoItem); } else { parent = _labelNoItem.Parent; } _labelNoItem.Left = (parent.Width - _labelNoItem.Width) / 2; _labelNoItem.Top = (parent.Height - _labelNoItem.Height) / 2; } }
void InitState(State s) { state = s; // stateが変わった時の初期化処理 switch (s) { case State.waiting: waiting = new Waiting(); waiting.Init(); break; case State.playing: if (waiting != null) { waiting.Dispose(); } WWWManager.Instance.Get(WWWManager.GET.PIECES, data => { // TODO:全体の駒を扱うクラスを作って処理を渡す foreach (var piece in data) { InitPieces(piece.Value); } }); break; } }
private void btnAnalyzeCode_Click(object sender, EventArgs e) { try { String LocalFilePath = txtLocalSourceUrl.Text; String GitHubUrl = txtGitSourceUrl.Text; String ProjectName = txtProjectName.Text; if (String.IsNullOrEmpty(LocalFilePath) && String.IsNullOrEmpty(GitHubUrl)) { MessageBox.Show("Please specify either Local File Path or GIT Url"); } else { if (!String.IsNullOrEmpty(ProjectName)) { Boolean IsOneTime = chkOneTimeAnalyse.Checked; Boolean IsTimeToTime = chkTimeToTimeAnalyze.Checked; if (IsOneTime || IsTimeToTime) { if (!String.IsNullOrEmpty(LocalFilePath)) { if (Directory.Exists(LocalFilePath) && Directory.EnumerateFiles(LocalFilePath).Count() > 0) { //setup cqr and cqb and update db _cloneAnalyzer = new CloneAnalyzer(ProjectName); var TimeInterval = cmbInterval.SelectedValue; if (IsOneTime) { TimeInterval = ""; } Waiting waitingForm = new Waiting(); waitingForm.Show(); string analyzeId = ""; var status = _cloneAnalyzer.ProcessLocalFilePath(LocalFilePath, ProjectName, GitHubUrl, TimeInterval.ToString(), out analyzeId); waitingForm.Hide(); waitingForm.Dispose(); if (analyzeId != "") { Form3 frmJustResult = new Form3(analyzeId); frmJustResult.Show(); } } else { MessageBox.Show("Specified directory not exist or empty"); } } else if (!String.IsNullOrEmpty(GitHubUrl)) { //git hub implementation if (GitHubUrl.Contains(".git")) { //assume that the master branch always as /archive/master.zip Waiting waitingForm = new Waiting(); waitingForm.Show(); Application.DoEvents(); var GitHubUrlforMain = GitHubUrl.Replace(".git", "/archive/master.zip"); string url = @GitHubUrlforMain; WebClient client = new WebClient(); //client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); var workingDirectory = ConfigurationSettings.AppSettings["DefaultSourceLocation"]; CloneAnalyzer ca = new CloneAnalyzer(""); string analyzeId = ""; if (ca.CreateBaseLocationForSource()) { String uniqueProjectRef = Guid.NewGuid().ToString(); if (!Directory.Exists(workingDirectory + "\\GitSources\\" + uniqueProjectRef)) { Directory.CreateDirectory(workingDirectory + "\\GitSources\\" + uniqueProjectRef); } client.DownloadFile(new Uri(url), @workingDirectory + "\\GitSources\\" + uniqueProjectRef + "\\" + uniqueProjectRef + ".zip"); ZipFile.ExtractToDirectory(@workingDirectory + "\\GitSources\\" + uniqueProjectRef + "\\" + uniqueProjectRef + ".zip", @workingDirectory + "\\GitSources\\" + uniqueProjectRef + "\\"); ca = new CloneAnalyzer(""); var TimeInterval = cmbInterval.SelectedValue; if (IsOneTime) { TimeInterval = ""; } ca.ProcessLocalFilePath(@workingDirectory + "\\GitSources\\" + uniqueProjectRef, ProjectName, GitHubUrl, TimeInterval.ToString(), out analyzeId); } waitingForm.Hide(); waitingForm.Dispose(); if (analyzeId != "") { Form3 frmJustResult = new Form3(analyzeId); frmJustResult.Show(); } txtGitSourceUrl.Text = ""; txtLocalSourceUrl.Text = ""; txtProjectName.Text = ""; chkOneTimeAnalyse.Checked = false; chkTimeToTimeAnalyze.Checked = false; chkOneTimeAnalyse.Enabled = false; chkTimeToTimeAnalyze.Enabled = false; } else { MessageBox.Show("Seems like provided GIT Url is invalid."); } } else { MessageBox.Show("Please specify either Local File Path or GIT Url"); } } else { MessageBox.Show("Please specify a analysis method"); } } else { MessageBox.Show("Please specify a Project Name"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }