public MainView() { this.Hide(); InitializeComponent(); Initialize(); try { OTCContext.Initialize(); StudioContext.Initialize(this); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } // Enable application visual styles DevExpress.Skins.SkinManager.EnableFormSkins(); DevExpress.LookAndFeel.UserLookAndFeel.Default.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin; DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = StudioContext.SkinName; this.LoadToolbox(nbcPlugins); // Set the form title this.Text = Application.ProductName + " " + Application.ProductVersion; StudioContext.LogInformation("{0} v{1} started", Application.ProductName, Application.ProductVersion); }
private void cmdAccept_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("You must provide a valid name for the new project.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtName.Focus(); return; } try { SaveFileDialog form = new SaveFileDialog(); form.Filter = "OTC projects|*.otc|All files|*.*"; if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { OTCContext.CreateProject(form.FileName, txtName.Text.Trim(), txtDescription.Text.Trim(), txtVersion.Text.Trim()); } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show("ERROR creating new project:" + Environment.NewLine + Environment.NewLine + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Close the current opened project. /// </summary> internal void ProjectClose() { try { if (this.IsProjectLoaded) { StudioContext.LastOpenedProjectFile = OTCContext.Project.Filename; OTCContext.Settings.SaveSettings(); OTCContext.Initialize(); } this.RefreshViewStatus(); } catch (Exception ex) { Logger.LogError(this, ex); MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CmdAccept_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("You must provide a valid name for the project.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtName.Focus(); return; } try { this.MapViewToInstance(); if (!this.Project.IsNew) { Project.Save(this.Project); this.DialogResult = DialogResult.OK; this.Close(); } else { SaveFileDialog form = new SaveFileDialog(); form.Filter = "OTC projects|*.otc|All files|*.*"; if (form.ShowDialog(this) == DialogResult.OK) { OTCContext.CreateProject(form.FileName, this.Project); this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Opens the last used project (if exists). /// </summary> internal async Task ProjectOpenLast() { if (!StudioContext.OpenLastProject) { return; } else if (!File.Exists(StudioContext.LastOpenedProjectFile)) { return; } beiProgress.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; await OTCContext.OpenProject(StudioContext.LastOpenedProjectFile); this.RefreshViewStatus(); // Show information in console StudioContext.LogInformation("Project {0} loaded (from {1})", OTCContext.Project.Name, StudioContext.LastOpenedProjectFile); beiProgress.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; return; }
/// <summary> /// Selects and open a project file. /// </summary> internal async void ProjectOpen() { try { OpenFileDialog form = new OpenFileDialog(); form.CheckFileExists = true; form.Filter = "OTC projects (*.otc)|*.otc|All files|*.*"; if (form.ShowDialog(this) == DialogResult.OK) { await OTCContext.OpenProject(form.FileName); StudioContext.LastOpenedProjectFile = form.FileName; OTCContext.Settings.SaveSettings(); } this.RefreshViewStatus(); } catch (Exception ex) { Logger.LogError(this, ex); MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }