public WndModify(Trigger trig, StarcraftEPDTriggers.src.data.TriggerCollection colection, Action <Trigger> saveCallback) { InitializeComponent(); setup(); _originalTrigger = trig; _colection = colection; _saveCallback = saveCallback; myTrigga = new Trigger(); TriggerDefinitionPartProperties def = new TriggerDefinitionPartProperties(); myTrigga.reparseFromString(_originalTrigger.ToSaveString(false), null, def); updateValuesFromTrigger(); ShowDialog(); setup(); }
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.CurrentState == AppState.MapOpened) { if (tabs.SelectedIndex == 0) // To triggers, compile text { string trigs = txtContent.Text; src.data.TriggerCollection tc = new src.data.TriggerCollection(); bool loaded = false; int errPos = 0; int errPosEnd = 0; try { loaded = tc.loadFromSTR(true, false, trigs, ref errPos, ref errPosEnd); } catch (NotImplementedException) { } if (!loaded) { e.Handled = true; tabs.SelectedIndex = 1; txtContent.Text = trigs; MessageBox.Show("Failed to compile triggers", "Trigger text editor", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); txtContent.CaretIndex = errPos; txtContent.Select(errPos, errPosEnd - errPos); txtContent.ScrollToHome(); MyFocuser m = () => { txtContent.Focus(); }; txtContent.Dispatcher.BeginInvoke(m); return; } else { Triggers.set(tc); updateLists(); refershListAndKeepSelection(); } btnSave.IsEnabled = true; } else if (tabs.SelectedIndex == 1) // To text { string trigs = getSaveString(true); txtContent.Text = trigs; btnSave.IsEnabled = false; } } }