Exemplo n.º 1
0
        public static void FlattenToPathObject(this IObject3D item, UndoBuffer undoBuffer)
        {
            if (item is IPathObject pathObject)
            {
                using (item.RebuildLock())
                {
                    var newPathObject = new PathObject3D();
                    newPathObject.VertexSource = new VertexStorage(pathObject.VertexSource);

                    // and replace us with the children
                    var replaceCommand = new ReplaceCommand(new[] { item }, new[] { newPathObject });

                    if (undoBuffer != null)
                    {
                        undoBuffer.AddAndDo(replaceCommand);
                    }
                    else
                    {
                        replaceCommand.Do();
                    }

                    newPathObject.MakeNameNonColliding();
                }
            }
        }
Exemplo n.º 2
0
 public StatVM(StatsUserControl stat)
 {
     this.stat    = stat;
     model        = new StatModel();
     generateComm = new ReplaceCommand();
     this.generateComm.ReplaceUserControl += gener;
 }
 public ClientViewModel(ClientBISmapUserControl clientBISmapUserControl, ContentControl page)
 {
     this.myview      = clientBISmapUserControl;
     this.page        = page;
     mapBISWinCommand = new ReplaceCommand();
     addListCommand   = new ReplaceCommand();
 }
Exemplo n.º 4
0
        public ICommand Replace(int startIndex, int len, string newText)
        {
            var command = new ReplaceCommand(this, startIndex, len, newText);

            command.Do();
            return(command);
        }
Exemplo n.º 5
0
    /// <summary>
    /// TEMP!!! Needs to include Character as an argument.
    /// </summary>
    public void SelectReplacement()
    {
        // TEMP: Just select whichever character hasn't fainted.
        var replacement = Party.Characters.FirstOrDefault(x => x.ActiveState != ActiveState.Fainted);

        ReplacementCharacterSelected.InvokeSafe(ReplaceCommand.Create(this, replacement));
    }
Exemplo n.º 6
0
        public void When_deleting_item_in_cache_with_time_will_block_replace_operations()
        {
            Cache["foo2"] = new CachedItem();

            var stream  = new MemoryStream();
            var command = new DeleteCommand();

            command.SetContext(stream);
            command.Init("foo2", "500");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("DELETED\r\n", ReadAll(stream));

            wait.Reset();

            var buffer = new byte[] { 1, 2, 3, 4 };

            stream = GetStreamWithData(buffer);
            var replaceCommand = new ReplaceCommand();

            replaceCommand.SetContext(stream);
            replaceCommand.Init("foo2", "1", "6000", "4");

            replaceCommand.FinishedExecuting += () => wait.Set();
            replaceCommand.Execute();
            wait.WaitOne();

            Assert.AreEqual("NOT_STORED\r\n", ReadAll(6, stream));
        }
Exemplo n.º 7
0
        public static void Replace(User user, string pTypeNames)
        {
            try
            {
                string[] splitted = pTypeNames.Trim().Split(',');
                string   toFind   = splitted[0].ToLower().Replace(" ", "");

                string toReplace = string.Empty;

                if (splitted.Length >= 2)
                {
                    toReplace = splitted[1].Trim().ToLower().Replace(" ", "");
                }

                ReplaceCommand command = new ReplaceCommand(user, toFind, toReplace);
                if (command.Invoke())
                {
                    user.Player.MsgLoc($"{command.BlocksChanged} blocks changed.");
                }
            }
            catch (WorldEditCommandException e)
            {
                user.Player.ErrorLocStr(e.Message);
            }
            catch (Exception e)
            {
                Log.WriteError(Localizer.Do($"{e}"));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// It's fast and not a thread-safety version of ReplaceRows method.
        /// TODO: remove it after sqlite thread-safety refactoring.
        /// </summary>
        /// <param name="rows"></param>
        /// <returns></returns>
        public Int64 ReplaceRowsTrans(IEnumerable <ITableRow> rows)
        {
            Int64 result = 0L;

            using (OpenCloseConnectionWrapper wrapper = this.Connection.OpenWrapper())
            {
                using (SQLiteTransaction transaction = wrapper.Connection.BeginTransaction())
                {
                    ReplaceCommand replaceCommand = new ReplaceCommand(
                        wrapper.Connection,
                        this.TableDefinition,
                        transaction
                        );

                    foreach (ITableRow row in rows)
                    {
                        replaceCommand.AddRowForReplacing(row);
                    }

                    result = replaceCommand.Execute(100);

                    transaction.Commit();
                }
            }

            return(result);
        }
 public async Task ReadResponse()
 {
     var command = new ReplaceCommand();
     await StorageCommandValidator.AssertReadResponse(command, StorageCommandResult.Stored, true);
     await StorageCommandValidator.AssertReadResponse(command, StorageCommandResult.NotStored, false);
     await StorageCommandValidator.AssertReadResponseFailure<ReplaceCommand, bool>(command, StorageCommandResult.NotFound);
     await StorageCommandValidator.AssertReadResponseFailure<ReplaceCommand, bool>(command, StorageCommandResult.Exists);
 }
Exemplo n.º 10
0
        public void WhenOldValueValueNotPresent_ThenSetSame()
        {
            var sut = new ReplaceCommand("Jill", "Peter").SetValue(Value);

            sut.Execute();

            Assert.That(sut.Result, Is.EqualTo(Value));
        }
Exemplo n.º 11
0
        public void WhenNewValueIsNullOrEmpty_ThenReplaceWithEmpty(string newValue)
        {
            var sut = new ReplaceCommand("John", newValue).SetValue(Value);

            sut.Execute();

            Assert.That(sut.Result, Is.EqualTo(" Smith  Smith"));
        }
Exemplo n.º 12
0
        public void WhenOldValueIsNullOrEmpty_ThenSetSame(string oldValue)
        {
            var sut = new ReplaceCommand(oldValue, "Peter").SetValue(Value);

            sut.Execute();

            Assert.That(sut.Result, Is.EqualTo(Value));
        }
Exemplo n.º 13
0
 //    BLimp mybl;
 public MapsViewModel(MapsUserControlxaml mapsUserControlxaml)
 {
     model       = new MapModel();
     this.myview = mapsUserControlxaml;
     initializeMap();
     returnMapCommand = new ReplaceCommand();
     returnMapCommand.ReplaceUserControl += returnWin;
 }
Exemplo n.º 14
0
 public ListViewModel(Window1 view)
 {
     myview           = view;
     addListCommand   = new ReplaceCommand();
     mapBISWinCommand = new ReplaceCommand();
     mapBISWinCommand.ReplaceUserControl += mapwindow;
     addListCommand.ReplaceUserControl   += addList;
 }
Exemplo n.º 15
0
        public void WhenOldValuePresent_ThenReplaceWithNewValue()
        {
            var sut = new ReplaceCommand("John", "Peter").SetValue(Value);

            sut.Execute();

            Assert.That(sut.Result, Is.EqualTo("Peter Smith Peter Smith"));
        }
Exemplo n.º 16
0
        private ICommand Replace(XTable table, ICommand command)
        {
            ReplaceCommand cmd = (ReplaceCommand)command;

            table.Replace(cmd.Key, cmd.Record);

            return(null);
        }
 public SelectViewModel(selectUserControl selectUserControl, System.Windows.Controls.ContentControl page)
 {
     model       = new ClientModel();
     this.page   = page;
     myview      = selectUserControl;
     ericCommand = new ReplaceCommand();
     ericCommand.ReplaceUserControl += mapfunction;
 }
Exemplo n.º 18
0
 public LoginViewModel(Views.LoginV loginUC)
 {
     loginuc            = loginUC;
     MyReplaceUCCommand = new ReplaceCommand();
     myloginmodel       = new LoginModel();
     MyReplaceUCCommand.ReplaceUserControl += OKbutt;
     myforgotcom = new ForgotCom();
     myforgotcom.ReplaceUserControl += Forgotbutt;
 }
Exemplo n.º 19
0
 public void Transform()
 {
     InitNextTransform();
     var replaceIndex = _random.Next(_commands.Count);
     var replacedICommand = GetReplacedVersionOf(replaceIndex);
     var replaceCommand = new ReplaceCommand(_commands, replacedICommand, replaceIndex);
     _replaced = replaceCommand;
     replaceCommand.Execute();
 }
Exemplo n.º 20
0
        public async Task ReplaceCommandHandler_MissingTask_ReturnsNull()
        {
            var command = new ReplaceCommand {
                ItemNumber = 12, Text = "Replace"
            };
            var result = await _handler.Handle(command, new CancellationToken());

            result.Should().BeNull();
        }
Exemplo n.º 21
0
 public AddclientVM(AddClientUserControlxaml addClientUserControlxaml)
 {
     model              = new ClientModel();
     this.myview        = addClientUserControlxaml;
     this.addClientComm = new ReplaceCommand();
     this.CancelComm    = new ReplaceCommand();
     addClientComm.ReplaceUserControl += addClientButton;
     CancelComm.ReplaceUserControl    += cancel;
 }
 private void RefreshCanExecute()
 {
     FindNextCommand.RaiseCanExecuteChanged();
     FindPreviousCommand.RaiseCanExecuteChanged();
     FindInDocumentCommand.RaiseCanExecuteChanged();
     HighlightAllCommand.RaiseCanExecuteChanged();
     ReplaceCommand.RaiseCanExecuteChanged();
     ReplaceAllCommand.RaiseCanExecuteChanged();
 }
Exemplo n.º 23
0
 // public System.Windows.Controls.ContentControl page;
 public UpdateDMViewModel(UpdateDelV view)
 {
     model         = new DelModel();
     this.myview   = view;
     updateDelComm = new ReplaceCommand();
     cancelComm    = new ReplaceCommand();
     this.updateDelComm.ReplaceUserControl += update;
     cancelComm.ReplaceUserControl         += cancel;
     //this.page = page1;
 }
Exemplo n.º 24
0
        public async Task ReplaceCommandHandler_ReplacesPartsThatAreSpecified(string replace, string expected)
        {
            var command = new ReplaceCommand {
                ItemNumber = 2, Text = replace
            };
            var result = await _handler.Handle(command, new CancellationToken());

            result.Should().NotBeNull();
            result.ToString().Should().Be(expected);
        }
Exemplo n.º 25
0
        public async Task ReplaceCommandHandler_ReplacedIsWrittenToFile()
        {
            var command = new ReplaceCommand {
                ItemNumber = 4, Text = "Replace"
            };

            _ = await _handler.Handle(command, new CancellationToken());

            _taskFile.TaskLines[2].Should().Be("Replace");
        }
Exemplo n.º 26
0
        public async Task ReplaceCommandHandler_ReplacesText(int line, string expected)
        {
            var command = new ReplaceCommand {
                ItemNumber = line, Text = "Replace"
            };
            var result = await _handler.Handle(command, new CancellationToken());

            result.Should().NotBeNull();
            result.ToString().Should().Be(expected);
        }
Exemplo n.º 27
0
        public async Task ReplaceCommandHandler_RemovesBlankLinesFromTodoFile()
        {
            var command = new ReplaceCommand {
                ItemNumber = 2, Text = "Replace"
            };

            _ = await _handler.Handle(command, new CancellationToken());

            _taskFile.TaskLines.Should().HaveCount(4);
        }
Exemplo n.º 28
0
 // public System.Windows.Controls.ContentControl page;
 public addDMviewModel(AddDelV view)
 {
     model       = new DelModel();
     this.myview = view;
     addDelComm  = new ReplaceCommand();
     this.addDelComm.ReplaceUserControl += add;
     cancelComm = new ReplaceCommand();
     cancelComm.ReplaceUserControl += cancel;
     //this.page = page1;
 }
Exemplo n.º 29
0
 public DisViewModel(DistUserControl distUserControl, System.Windows.Controls.ContentControl page1)
 {
     model = new DistributionModel();
     this.distUserControl = distUserControl;
     addDisComm           = new ReplaceCommand();
     successDisComm       = new ReplaceCommand();
     this.addDisComm.ReplaceUserControl     += addButton;
     this.successDisComm.ReplaceUserControl += successButton;
     this.page = page1;
 }
Exemplo n.º 30
0
        public void Transform()
        {
            InitNextTransform();
            var replaceIndex     = _random.Next(_commands.Count);
            var replacedICommand = GetReplacedVersionOf(replaceIndex);
            var replaceCommand   = new ReplaceCommand(_commands, replacedICommand, replaceIndex);

            _replaced = replaceCommand;
            replaceCommand.Execute();
        }
 public ClientViewModel(ClientUserControl clientUserControl, ContentControl page)
 {
     model = new ClientModel();
     this.clientUserControl = clientUserControl;
     this.page     = page;
     addWinCommand = new ReplaceCommand();
     mapWinCommand = new ReplaceCommand();
     addWinCommand.ReplaceUserControl += addwindow;
     mapWinCommand.ReplaceUserControl += mapwindow;
 }
        public RepeatableFlexPageViewModel(INavigationService navigationService, IPageDialogService pageDlg)
        {
            FlexDirection.Value   = Xamarin.Forms.FlexDirection.Row;
            FlexAlignItems.Value  = Xamarin.Forms.FlexAlignItems.Start;
            FlexJustify.Value     = Xamarin.Forms.FlexJustify.Start;
            FlexWrap.Value        = Xamarin.Forms.FlexWrap.NoWrap;
            ScrollDirection.Value = ScrollOrientation.Horizontal;

            SetColors(DirectionColor, 0);
            SetColors(AColor, 3);
            SetColors(JColor, 3);
            SetColors(WrapColor, 0);

            DirectionCommand.Subscribe(x => {
                var idx             = int.Parse(x);
                FlexDirection.Value = (Xamarin.Forms.FlexDirection)idx;
                SetScrollDirection();
                SetColors(DirectionColor, idx);
            });
            AlignItemsCommand.Subscribe(x => {
                var idx = int.Parse(x);
                FlexAlignItems.Value = (Xamarin.Forms.FlexAlignItems)idx;
                SetColors(AColor, idx);
            });
            JustifyContentCommand.Subscribe(x => {
                var idx           = int.Parse(x);
                FlexJustify.Value = (Xamarin.Forms.FlexJustify)idx;
                SetColors(JColor, idx);
            });
            WrapCommand.Subscribe(x => {
                var idx        = int.Parse(x);
                FlexWrap.Value = (Xamarin.Forms.FlexWrap)idx;
                SetScrollDirection();
                SetColors(WrapColor, idx);
            });


            BoxList = new ObservableCollection <Hoge>(Shuffle());

            AddCommand.Subscribe(_ => {
                BoxList.Add(GetNextItem());
            });

            DeleteCommand.Subscribe(_ => {
                BoxList.Remove(BoxList.Last());
            });

            ReplaceCommand.Subscribe(__ => {
                BoxList[0] = GetNextItem();
            });

            ClearCommand.Subscribe(__ => {
                BoxList.Clear();
            });
        }
Exemplo n.º 33
0
 private void InitNextTransform()
 {
     _replaced = null;
 }
Exemplo n.º 34
0
 public ICommand Replace(int startIndex, int len, string newText)
 {
     var command = new ReplaceCommand(this, startIndex, len, newText);
     command.Do();
     return command;
 }
Exemplo n.º 35
0
 public void Undo()
 {
     _replaced?.Undo();
     _replaced = null;
 }