public void ShowAbout() { ICustomContentDialog dialog = _window.DialogManager .CreateCustomContentDialog(new AboutWindow(), DialogMode.Ok); dialog.Show(); }
public ICustomContentDialog CreateCustomContentDialog(object content, DialogMode dialogMode) { ICustomContentDialog dialog = null; InvokeInUIThread(() => { dialog = new CustomContentDialog(_dialogHost, dialogMode, content, _dispatcher); }); return(dialog); }
public ICustomContentDialog CreateCustomContentDialog(object content, string caption, DialogMode dialogMode) { ICustomContentDialog dialog = null; InvokeInUIThread(() => { dialog = new CustomContentDialog(_overviewViewModel, dialogMode, content, _dispatcher) { Caption = caption }; }); return(dialog); }
public ICustomContentDialog CreateCustomContentDialog(object content, string caption, DialogMode dialogMode) { ICustomContentDialog dialog = null; this.InvokeInUIThread(() => { dialog = new CustomContentDialog(this.dialogHost, dialogMode, content, this.dispatcher) { Caption = caption, }; }); return(dialog); }
public void EditRegister(object parameter) { MainWindow window = App.Current.MainWindow as MainWindow; NewRegisterInputVM vm = new NewRegisterInputVM(); NewRegisterInput input = new NewRegisterInput(vm); ICustomContentDialog dialog = window.DialogManager.CreateCustomContentDialog(input, DialogMode.OkCancel); dialog.Ok = () => { // to update bindings: input.normalize.Focus(); if (!Validation.GetHasError(input.widthBox) && !Validation.GetHasError(input.statesGrid)) { int width = (int)vm.Width; Dictionary <ulong, Complex> initStates = vm.GetInitStates(); if (width > 0 && initStates.Count > 0) { int toAdd = width - _model.Registers[_registerIndex].Qubits.Count; if (toAdd > 0) { for (int i = 0; i < toAdd; i++) { _model.InsertQubitAbove(_registerIndex, _model.Registers[_registerIndex].Qubits.Count - 1); } } else if (toAdd < 0) { for (int i = 0; i < -toAdd; i++) { _model.DeleteQubit(_registerIndex, _model.Registers[_registerIndex].Qubits.Count - 1); } } _model.Registers[_registerIndex].InitStates = initStates; } } }; dialog.Show(); }
public void InsertRegisterBelow(object parameter) { MainWindow window = App.Current.MainWindow as MainWindow; NewRegisterInputVM vm = new NewRegisterInputVM(); NewRegisterInput input = new NewRegisterInput(vm); ICustomContentDialog dialog = window.DialogManager.CreateCustomContentDialog(input, DialogMode.OkCancel); dialog.Ok = () => { // to update bindings: input.normalize.Focus(); if (!Validation.GetHasError(input.widthBox) && !Validation.GetHasError(input.statesGrid)) { int width = (int)vm.Width; Dictionary <ulong, Complex> initStates = vm.GetInitStates(); if (width > 0 && initStates.Count > 0) { _model.InsertRegisterBelow(_registerIndex, width, initStates); } } }; dialog.Show(); }
public void MakeComposite(object parameter) { try { List <Gate> toGroup = _model.GetSelectedGates(); CompositeInput ci = new CompositeInput(); ICustomContentDialog dialog1 = _window.DialogManager .CreateCustomContentDialog(ci, DialogMode.OkCancel); dialog1.Ok = () => { try { string name = ci.nameBox.Text; string pattern = @"^\s*[a-zA-Z_][a-zA-Z0-9_]*\s*$"; Regex regex = new Regex(pattern); Match match = regex.Match(name); if (!match.Success) { throw new Exception("Entered name is invalid."); } CircuitEvaluator eval = CircuitEvaluator.GetInstance(); Dictionary <string, List <MethodInfo> > dict = eval.GetExtensionGates(); if (dict.ContainsKey(name)) { MessageBox.Show( "Another composite gate with the same name already exist. Please choose other name.", "New composite gate", MessageBoxButton.OK, MessageBoxImage.Error); } else { List <Gate> alreadyDefined = _model.FindComposite(name); if (alreadyDefined != null) { MessageBox.Show( "Another composite gate with the same name already exist. Please choose other name.", "New composite gate", MessageBoxButton.OK, MessageBoxImage.Error); } else { _model.MakeComposite(name, toGroup); if (!_toolsVM.Contains(name)) { List <string> newTools = _toolsVM; newTools.Add(name); CompositeTools = newTools; } } } } catch (Exception ex) { MessageBox.Show("Unable to create composite gate from selection:\n" + ex.Message, "Unable to create composite gate", MessageBoxButton.OK, MessageBoxImage.Error); } }; dialog1.Show(); } catch (Exception ex) { MessageBox.Show("Unable to create composite gate from selection:\n" + ex.Message, "Unable to create composite gate", MessageBoxButton.OK, MessageBoxImage.Error); } }