protected virtual void OnOpenActivated(object sender, System.EventArgs e) { FileChooserDialog dialog = new FileChooserDialog("Open", this, FileChooserAction.Open, Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Ok); dialog.AddFilter(this.mSoapFilter); dialog.AddFilter(this.mBinaryFilter); if (dialog.Run() == (int)ResponseType.Ok) { string name = dialog.Filename; object o; bool binary = false; using (FileStream file = File.Open(name, FileMode.Open, FileAccess.Read)) { try { o = new BinaryFormatter().Deserialize(file); binary = true; } catch { file.Seek(0, SeekOrigin.Begin); try { o = new SoapFormatter().Deserialize(file); } catch (Exception ex) { Console.WriteLine(ex.ToString()); o = null; } } } LinearPreset preset = o as LinearPreset; if (preset == null) { MessageDialog md = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Unable to load that preset."); md.Run(); md.Destroy(); } else { // TODO: Handle different preset types. this.NewPreset(preset, new LinearPresetEditor(preset)); this.mLastSave = name; this.mLastSaveBinary = binary; } } dialog.Destroy(); }
public LinearPresetEditor(LinearPreset preset) { this.Build(); this.mPreset = preset; this.SyncStore(); this.EffectList.AppendColumn("Effect", new CellRendererText(), new TreeCellDataFunc(EffectFunc)); this.EffectList.Model = this.mEffectStore; this.EffectList.Selection.Changed += this.OnSelectionChanged; this.KeybindKeyEntry = new KeyEntry(); this.KeyEntryAlign.Add(this.KeybindKeyEntry); this.KeybindKeyEntry.Show(); }
protected virtual void OnLinearPresetActivated(object sender, System.EventArgs e) { LinearPreset preset = new LinearPreset(); this.NewPreset(preset, new LinearPresetEditor(preset)); }