Esempio n. 1
0
        public void TableToolAllowsEditingTextContent()
        {
            viewPort.Edit("FF"); // have to put the FF first, or trying to create a text run will fail
            viewPort.MoveSelectionStart.Execute(Direction.Left);
            viewPort.Edit("^text\"\" Some Text\"");

            viewPort.SelectionStart = new Point(0, 4);
            viewPort.Edit("^table[description<\"\">]4 <000000>"); // note that this auto-scrolls, since a table was created
            viewPort.FollowLink(0, 0);

            Assert.Equal(2, viewPort.Tools.TableTool.Children.Count);
            Assert.IsType <StreamArrayElementViewModel>(viewPort.Tools.TableTool.Children[1]);
        }
Esempio n. 2
0
        public void FollowLinkOpensTextTool()
        {
            CreateSimpleRun();
            viewPort.SelectionStart = new Point(2, 0);
            viewPort.FollowLink(2, 0);

            Assert.Equal(viewPort.Tools.IndexOf(viewPort.Tools.StringTool), viewPort.Tools.SelectedIndex);
        }
Esempio n. 3
0
        public void TextData_DoubleClick_OpenTextTool()
        {
            SetFullModel(0xFF);
            ViewPort.Edit("^bob\"\" \"Some Text\"");
            ViewPort.Tools.SelectedIndex = -1;
            var view = new StubView(ViewPort.Tools);

            ViewPort.FollowLink(0, 0);

            Assert.Contains(nameof(ViewPort.Tools.SelectedIndex), view.PropertyNotifications);
            Assert.IsType <PCSTool>(ViewPort.Tools[ViewPort.Tools.SelectedIndex]);
        }
Esempio n. 4
0
        public void CanUsePointerAsLink()
        {
            var buffer   = new byte[0x200];
            var model    = new PokemonModel(buffer);
            var viewPort = new ViewPort("file.txt", model)
            {
                Width = 0x10, Height = 0x10
            };

            viewPort.SelectionStart = new Point(4, 1);
            viewPort.Edit("<000120>");
            viewPort.FollowLink(4, 1);

            Assert.Equal("000120", viewPort.Headers[0]);
        }
Esempio n. 5
0
        public void ToolSelectionChangeUpdatesViewPortSelection()
        {
            var buffer   = Enumerable.Repeat((byte)0xFF, 0x200).ToArray();
            var model    = new PokemonModel(buffer);
            var viewPort = new ViewPort("file.txt", model)
            {
                Width = 0x10, Height = 0x10
            };

            viewPort.Edit("^bob\"\" \"Some Text\"");
            viewPort.SelectionStart = new Point(3, 0);
            viewPort.FollowLink(3, 0);

            viewPort.Tools.StringTool.ContentIndex = 4;

            Assert.Equal(new Point(4, 0), viewPort.SelectionStart);
        }
Esempio n. 6
0
        public void StringToolContentUpdatesWhenViewPortChange()
        {
            var buffer   = Enumerable.Repeat((byte)0xFF, 0x200).ToArray();
            var model    = new PokemonModel(buffer);
            var viewPort = new ViewPort("file.txt", model)
            {
                Width = 0x10, Height = 0x10
            };

            viewPort.Edit("^bob\"\" \"Some Text\"");

            viewPort.SelectionStart = new Point(3, 0); // select the 'e' in 'Some'
            viewPort.FollowLink(3, 0);                 // open the string tool
            viewPort.Edit("i");                        // change the 'e' to 'i'

            Assert.Equal("Somi Text", viewPort.Tools.StringTool.Content);
        }
        public void PlmStreamsAppearInTextTool()
        {
            SetupMoveTable(0x20);
            SetupPlmStream(0x70, 4);
            viewPort.Goto.Execute("000000");

            viewPort.SelectionStart = new Point(2, 7);
            viewPort.FollowLink(2, 7);

            Assert.Equal(viewPort.Tools.IndexOf(viewPort.Tools.StringTool), viewPort.Tools.SelectedIndex);
            var itemCount = viewPort.Tools.StringTool.Content.Split(Environment.NewLine).Length;

            Assert.Equal(4, itemCount);

            viewPort.Tools.StringTool.ContentIndex = 17; // third line
            Assert.True(viewPort.IsSelected(new Point(4, 7)));
            Assert.True(viewPort.IsSelected(new Point(5, 7)));
        }
Esempio n. 8
0
        public void StringToolCanOpenOnChosenData()
        {
            var buffer   = Enumerable.Repeat((byte)0xFF, 0x200).ToArray();
            var model    = new PokemonModel(buffer);
            var viewPort = new ViewPort("file.txt", model)
            {
                Width = 0x10, Height = 0x10
            };

            viewPort.Edit("^bob\"\" \"Some Text\" 00 <000100>");
            var toolProperties = new List <string>();

            viewPort.Tools.PropertyChanged += (sender, e) => toolProperties.Add(e.PropertyName);
            viewPort.FollowLink(0, 0);

            Assert.Contains("SelectedIndex", toolProperties);
            Assert.IsType <PCSTool>(viewPort.Tools[viewPort.Tools.SelectedIndex]);
        }
Esempio n. 9
0
        public void FindAllSourcesWorks()
        {
            var buffer   = new byte[0x200];
            var model    = new PokemonModel(buffer);
            var viewPort = new ViewPort("file.txt", model)
            {
                Width = 0x10, Height = 0x10
            };
            var editor = new EditorViewModel(new StubFileSystem());

            editor.Add(viewPort);

            viewPort.SelectionStart = new Point(4, 1);
            viewPort.Edit("<000120>");
            viewPort.FollowLink(4, 1);

            viewPort.FindAllSources(0, 0);

            Assert.Equal(1, editor.SelectedIndex);
        }