private void Open() { if (_dirty) { // Ask user if the current palette should be saved switch (KryptonMessageBox.Show(this, "Save changes to the current palette?", "Palette Changed", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)) { case DialogResult.Yes: // Use existing save method SavePalette(); break; case DialogResult.Cancel: // Cancel out entirely return; } } KryptonPalette _palette = new KryptonPalette(); Cursor = Cursors.WaitCursor; Application.DoEvents(); string fileName = _paletteTheme.Import(); Cursor = Cursors.Default; if (fileName.Length > 0) { if (_paletteTheme != null) { _paletteTheme.PalettePaint -= new EventHandler <PaletteLayoutEventArgs>(OnPalettePaint); } _paletteTheme = _palette; _tmsChrome.Palette = _paletteTheme; _ribbonChrome.OverridePalette = _paletteTheme; _paletteTheme.PalettePaint += new EventHandler <PaletteLayoutEventArgs>(OnPalettePaint); labelGridNormal.SelectedObject = _paletteTheme; _fileName = fileName; _loaded = true; _dirty = false; ApplyPalette(); UpdateTitleBar(); } _mostRecentlyUsedFileManager.AddRecentFile(fileName); }
private void OpenFile(string filePath) { if (File.Exists(filePath)) { //rtbTextPad.LoadFile(filePath); StreamReader reader = new StreamReader(filePath); rtbTextPad.Text = reader.ReadToEnd(); mostRecentlyUsedFileManager.AddRecentFile(filePath); } else { KryptonMessageBox.Show($"Error: file '{ filePath }' could not be found!"); } }
private void Open() { tslStatus.Text = "Attempting to inport colours from selected palette. Please wait..."; // If the current palette has been changed if (Dirty) { // Ask user if the current palette should be saved switch (KryptonMessageBox.Show(this, "Save changes to the current palette?", "Palette Changed", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)) { case DialogResult.Yes: // Use existing save method Save(); break; case DialogResult.Cancel: // Cancel out entirely return; } } // Create a fresh palette instance for loading into KryptonPalette palette = new KryptonPalette(); // Get the name of the file we imported from Cursor = Cursors.WaitCursor; Application.DoEvents(); string filename = palette.Import(); Cursor = Cursors.Default; // If the load succeeded if (filename.Length > 0) { // Need to unhook from any existing palette if (Palette != null) { Palette.PalettePaint -= new EventHandler <PaletteLayoutEventArgs>(OnPalettePaint); } // Use the new instance instead Palette = palette; // We need to know when a change occurs to the palette settings Palette.PalettePaint += new EventHandler <PaletteLayoutEventArgs>(OnPalettePaint); // Hook up the property grid to the palette labelGridNormal.SelectedObject = Palette; // Use the loaded filename FileName = filename; // Reset the state flags Loaded = true; Dirty = false; // Define the initial title bar string UpdateTitlebar(); } PaletteImportManager paletteImportManager = new PaletteImportManager(); paletteImportManager.ImportColourScheme(palette); kchkUpdateColours.Enabled = true; kcmbBasePaletteMode.Text = _globalStringSettingsManager.GetBasePaletteMode(); tslStatus.Text = _globalStringSettingsManager.GetFeedbackText(); kchkUpdateColours.Checked = true; invertColoursToolStripMenuItem.Enabled = true; kchkInvertColours.Enabled = true; _mostRecentlyUsedFileManager.AddRecentFile(filename); }