private List <IRapidXamlAdornmentTag> ProcessGrid(string xaml)
        {
            var outputTags = new List <IRapidXamlAdornmentTag>();

            var sut = new GridProcessor();

            var snapshot = new FakeTextSnapshot();

            sut.Process(1, xaml, "	    ", snapshot, outputTags);

            return(outputTags);
        }
        private List <IRapidXamlAdornmentTag> ProcessGrid(string xaml)
        {
            var outputTags = new TagList();

            var sut = new GridProcessor(ProjectType.Any, new DefaultTestLogger());

            var snapshot = new FakeTextSnapshot();

            sut.Process("testfile.xaml", 1, xaml, "	    ", snapshot, outputTags);

            return(outputTags);
        }
        private List <IRapidXamlAdornmentTag> ProcessGrid(string xaml)
        {
            var outputTags = new TagList();

            var sut = new GridProcessor(new ProcessorEssentialsForSimpleTests());

            var snapshot = new FakeTextSnapshot(xaml.Length);

            sut.Process("testfile.xaml", 1, xaml, "	    ", snapshot, outputTags);

            return(outputTags);
        }
Ejemplo n.º 4
0
        public void Real_ProfileConfigControl_GridProcessor()
        {
            var xaml = System.IO.File.ReadAllText("./Misc/ProfileConfigControl.xaml");

            var outputTags = new TagList();

            var sut = new GridProcessor(new ProcessorEssentialsForSimpleTests(ProjectType.Wpf));

            var snapshot = new FakeTextSnapshot();

            sut.Process("testfile.xaml", 1, xaml, "    ", snapshot, outputTags);

            Assert.AreEqual(0, outputTags.OfType <MissingRowDefinitionTag>().Count());
        }
Ejemplo n.º 5
0
        public void NestedSelfClosingElementsDontBreakRowDefinitionDetection()
        {
            var xaml = @"
                        <Grid
                            x:Name=""PaneToggleButtonGrid""
                            Margin=""0,0,0,8""
                            HorizontalAlignment=""Left""
                            VerticalAlignment=""Top""
                            Canvas.ZIndex=""100"">

                            <Grid.RowDefinitions>
                                <RowDefinition Height=""Auto"" />
                                <RowDefinition Height=""Auto"" />
                            </Grid.RowDefinitions>

                            <Grid x:Name=""TogglePaneTopPadding""
                                  Height=""{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.TopPadding}""/>

                            <Grid x:Name=""ButtonHolderGrid"" Grid.Row=""1"">
                                <Button x:Name=""NavigationViewBackButton""
                                        Style=""{StaticResource NavigationBackButtonNormalStyle}""
                                        VerticalAlignment=""Top""
                                        Visibility=""{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.BackButtonVisibility}""
                                        IsEnabled=""{TemplateBinding IsBackEnabled}""/>

                                <Button
                                    x:Name=""TogglePaneButton""
                                    Style=""{TemplateBinding PaneToggleButtonStyle}""
                                    AutomationProperties.LandmarkType=""Navigation""
                                    Visibility=""{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.PaneToggleButtonVisibility}""
                                    VerticalAlignment=""Top""/>
                            </Grid>

                        </Grid>
";

            var outputTags = new TagList();

            var sut = new GridProcessor(new ProcessorEssentialsForSimpleTests());

            var snapshot = new FakeTextSnapshot();

            sut.Process("testfile.xaml", 1, xaml, "	    ", snapshot, outputTags);

            Assert.AreEqual(0, outputTags.OfType <MissingRowDefinitionTag>().Count());
        }
        public void CreateColumnDefinitionTags_IfJustHaveRows()
        {
            var xaml = @"<Grid>
    <Grid.RowDefinitions />

    <!-- Grid contents -->
</Grid>";

            var outputTags = new List <IRapidXamlAdornmentTag>();

            var sut = new GridProcessor();

            var snapshot = new FakeTextSnapshot();

            sut.Process(0, xaml, string.Empty, snapshot, outputTags);

            Assert.AreEqual(1, outputTags.Count);
            Assert.AreEqual(1, outputTags.OfType <AddColumnDefinitionsTag>().Count());
        }
Ejemplo n.º 7
0
        public void CreateColumnDefinitionTags_IfJustHaveRows()
        {
            var xaml = @"<Grid>
    <Grid.RowDefinitions />

    <!-- Grid contents -->
</Grid>";

            var outputTags = new TagList();

            var sut = new GridProcessor(new ProcessorEssentialsForSimpleTests());

            var snapshot = new FakeTextSnapshot();

            sut.Process("testfile.xaml", 0, xaml, string.Empty, snapshot, outputTags);

            Assert.AreEqual(1, outputTags.Count);
            Assert.AreEqual(1, outputTags.OfType <AddColumnDefinitionsTag>().Count());
        }
        public void CreateRowDefinitionTags_IfJustHaveColumns()
        {
            var xaml = @"<Grid>
    <Grid.ColumnDefinitions />

    <!-- Grid contents -->
</Grid>";

            var outputTags = new TagList();

            var sut = new GridProcessor(ProjectType.Any, new DefaultTestLogger());

            var snapshot = new FakeTextSnapshot();

            sut.Process("testfile.xaml", 0, xaml, string.Empty, snapshot, outputTags);

            Assert.AreEqual(1, outputTags.Count);
            Assert.AreEqual(1, outputTags.OfType <AddRowDefinitionsTag>().Count());
        }
        public void CreateRowDefinitionTags_WithCorrectLeftPad_SpacesTab()
        {
            var xaml = @"<Grid>
	<Grid.ColumnDefinitions />

	<!-- Grid contents -->
</Grid>";

            var outputTags = new List <IRapidXamlAdornmentTag>();

            var sut = new GridProcessor();

            var snapshot = new FakeTextSnapshot();

            sut.Process(1, xaml, "    	", snapshot, outputTags);

            Assert.AreEqual(1, outputTags.Count);
            Assert.AreEqual(1, outputTags.OfType <AddRowDefinitionsTag>().Count());
            Assert.AreEqual("    		", ((AddRowDefinitionsTag)outputTags[0]).LeftPad);
        }
Ejemplo n.º 10
0
        public void CreateRowDefinitionTags_WithCorrectLeftPad_SpacesTab()
        {
            var xaml = @"<Grid>
	<Grid.ColumnDefinitions />

	<!-- Grid contents -->
</Grid>";

            var outputTags = new TagList();

            var sut = new GridProcessor(new ProcessorEssentialsForSimpleTests());

            var snapshot = new FakeTextSnapshot();

            sut.Process("testfile.xaml", 1, xaml, "    	", snapshot, outputTags);

            Assert.AreEqual(1, outputTags.Count);
            Assert.AreEqual(1, outputTags.OfType <AddRowDefinitionsTag>().Count());
            Assert.AreEqual("    		", ((AddRowDefinitionsTag)outputTags[0]).LeftPad);
        }
Ejemplo n.º 11
0
        public void CreatesMultipleTags()
        {
            var xaml = @"<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
</Grid>";

            var outputTags = new List <IRapidXamlAdornmentTag>();

            var sut = new GridProcessor();

            var snapshot = new FakeTextSnapshot();

            sut.Process(0, xaml, string.Empty, snapshot, outputTags);

            Assert.AreEqual(3, outputTags.Count);
            Assert.AreEqual(2, outputTags.OfType <InsertRowDefinitionTag>().Count());
            Assert.AreEqual(1, outputTags.OfType <AddColumnDefinitionsTag>().Count());
        }
Ejemplo n.º 12
0
        public void CreatesMultipleTags()
        {
            var xaml = @"<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
</Grid>";

            var outputTags = new TagList();

            var sut = new GridProcessor(new ProcessorEssentialsForSimpleTests());

            var snapshot = new FakeTextSnapshot();

            sut.Process("testfile.xaml", 0, xaml, string.Empty, snapshot, outputTags);

            Assert.AreEqual(3, outputTags.Count);
            Assert.AreEqual(2, outputTags.OfType <InsertRowDefinitionTag>().Count());
            Assert.AreEqual(1, outputTags.OfType <AddColumnDefinitionsTag>().Count());
        }
Ejemplo n.º 13
0
        public IObservable <ColoredFrame> GetColoredGray2Frames()
        {
            double lastHue = 0;

            Color[] palette = null;
            int     index   = -1;

            if (_framesColoredGray2 == null)
            {
                var gridProcessor = new GridProcessor {
                    Spacing = 1d
                };
                Logger.Info("Capturing at {0} frames per second...", FramesPerSecond);
                _framesColoredGray2 = Observable.Interval(TimeSpan.FromMilliseconds(1000d / FramesPerSecond))
                                      .Select(x => CaptureWindow())
                                      .Where(bmp => bmp != null)
                                      .Select(bmp => gridProcessor.Process(bmp))
                                      .Select(bmp => TransformationUtil.Transform(bmp, 128, 32, ResizeMode.Stretch, false, false))
                                      .Select(bmp => {
                    double hue;
                    var frame = ImageUtil.ConvertToGray2(bmp, 3, out hue);
                    if (palette == null || Math.Abs(hue - lastHue) > 0.01)
                    {
                        byte r, g, b;
                        ColorUtil.HslToRgb(hue, 1, 0.5, out r, out g, out b);
                        var color = Color.FromRgb(r, g, b);
                        palette   = ColorUtil.GetPalette(new[] { Colors.Black, color }, 4);
                        lastHue   = hue;
                    }
                    return(new ColoredFrame(FrameUtil.Split(bmp.PixelWidth, bmp.PixelHeight, 2, frame), palette, index));
                })
                                      .Publish();

                StartPolling();
            }
            return(_framesColoredGray2);
        }