private void MyClose(bool force = false) { progressBar1.Style = ProgressBarStyle.Blocks; if (!warningTextOut || force) { if (dialogOpen) { CloseModalWindows(); } this.Hide(); windowOpen = false; Form1.myself.Enabled = true; foreach (Form2 form2 in Form2.myInstantiations) { form2.Enabled = true; } currentCallback?.Invoke(); currentCallback = null; textBox3.Clear(); warningTextOut = false; } calcFinished = true; }
public void CalculateRoster(string id, Form1.CalcRosterReadyCallbackDelegate callback) { string projectPath = projectBaseFolder + Path.DirectorySeparatorChar + id; string name = GetProjectName(id); if (name != null) { if (!julia.NativeMethods.juliaRunning && Form1.myself.julia_ok) { List <FileInfo> rosterFound = CheckForCalculatedRosters(id); foreach (FileInfo file in rosterFound) { try { file.Delete(); } catch (Exception e) { log_output = "warning: can't delete " + file.Name + "file in " + projectPath + ":"; Form1.logWindow.Write_to_log(ref log_output); log_output = e.ToString(); Form1.logWindow.Write_to_log(ref log_output); return; } } log_output = "calculating project <" + name + ">"; Form1.logWindow.Write_to_log(ref log_output); julia.NativeMethods.juliaRunning = true; julia.NativeMethods.Julia(Form1.juliaDir, Form1.juliaScriptDir, projectPath); Progress.currentProgress.Show(); Progress.currentProgress.ActivateMe(Progress.Type.CALC, callback); Form1.myself.Enabled = false; foreach (Form2 form2 in Form2.myInstantiations) { form2.Enabled = false; } } else { log_output = "A new Julia thread can not be opened."; Form1.logWindow.Write_to_log(ref log_output); } } return; }
public void ActivateMe(Type type = Type.CALC, Form1.CalcRosterReadyCallbackDelegate callback = null) { calcFinished = false; warningTextOut = false; currentType = type; if (callback != null) { currentCallback = callback; } if (currentType == Type.CALC) { this.Text = LocRM.GetString("String136"); } if (currentType == Type.DOWNLOAD) { this.Text = LocRM.GetString("String179"); } splitContainer1.Enabled = false; splitContainer2.Enabled = false; splitContainer3.Enabled = false; if (currentType == Type.CALC) { textBox1.Text = LocRM.GetString("String134"); } if (currentType == Type.DOWNLOAD) { textBox1.Text = LocRM.GetString("String187"); } textBox1.DeselectAll(); textBox1.HideSelection = false; textBox1.Enabled = false; if (currentType == Type.CALC) { textBox2.Text = LocRM.GetString("String135") + " " + "0"; } if (currentType == Type.DOWNLOAD) { textBox2.Text = LocRM.GetString("String188") + " " + "0"; } textBox2.DeselectAll(); textBox2.HideSelection = false; textBox2.Enabled = false; textBox3.Clear(); textBox3.DeselectAll(); textBox3.HideSelection = false; textBox3.ReadOnly = true; //textBox3.Enabled = false; textBox3.ForeColor = Color.Red; textBox3.BackColor = textBox3BgColor; textBox3.ScrollBars = ScrollBars.Vertical; if (currentType == Type.CALC) { textBox3.AppendText(LocRM.GetString("String159") + Environment.NewLine); } HideCaret(textBox3.Handle); progressBar1.Style = ProgressBarStyle.Marquee; progressBar2.Value = 0; if (!skipActivateEvent) { if (width > 0 && height > 0 && pos.X > 0 && pos.Y > 0) { this.Width = width; this.Height = height; this.Location = pos; windowOpen = true; } if ( this != null && // this.Visible && this.WindowState == FormWindowState.Minimized && true ) { this.WindowState = FormWindowState.Normal; Form1.logWindow.WindowState = FormWindowState.Normal; Form1.myself.WindowState = FormWindowState.Normal; //foreach (Form2 form2 in Form2.myInstantiations) //{ // form2.WindowState = FormWindowState.Normal; //} } NativeMethods.DoOnProcess(this.Text); } skipActivateEvent = false; int x = Form1.myself.Location.X + Form1.myself.Width / 2 - this.Width / 2; int y = Form1.myself.Location.Y + Form1.myself.Height / 2 - this.Height / 2; this.Location = new Point(x, y); }