コード例 #1
0
ファイル: QubitVM.cs プロジェクト: Wowand/quantum
        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();
        }
コード例 #2
0
ファイル: QubitVM.cs プロジェクト: Wowand/quantum
        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();
        }
コード例 #3
0
ファイル: QubitVM.cs プロジェクト: wupeng78/QuIDE-source-code
 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();
 }
コード例 #4
0
ファイル: QubitVM.cs プロジェクト: wupeng78/QuIDE-source-code
 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();
 }
コード例 #5
0
 public NewRegisterInput(NewRegisterInputVM context)
 {
     InitializeComponent();
     DataContext = context;
 }