private RootNode BuildProgramNode(SyntaxNodeOrToken node)
        {
            var exp = new RootNode();

            exp.AddNode(node);
            return(exp);
        }
Esempio n. 2
0
 private void OnOnNotifyControl(FilterChangedEventArgs info)
 {
     if (info.Action == FilterChangedAction.RebuildWholeTree && info.CurrentNode == null && !_isUpdating)
     {
         _isUpdating = true;
         BeginUpdate();
         RootNode = null;
         var processor        = new XpandCriteriaToTreeProcessor(CreateNodesFactory(), new List <CriteriaOperator>());
         var criteriaOperator = ((IXpandFilterControl)Control).Criteria();
         var node             = (Node)processor.ProcessX(criteriaOperator);
         if (AllowCreateDefaultClause && node == null)
         {
             node = CreateCriteriaByDefaultProperty();
         }
         RootNode = node as GroupNode;
         if (RootNode == null)
         {
             RootNode = CreateGroupNode(null);
             if (node != null)
             {
                 RootNode.AddNode(node);
             }
         }
         FocusInfo = new FilterControlFocusInfo(RootNode, 0);
         EndUpdate(FilterChangedAction.RebuildWholeTree);
         _isUpdating = false;
     }
 }
        async void OnSceneCompleted(ReCapPhotosceneResponse response)
        {
            var sceneWithInfo = await RetrieveSceneInfo(
                response.Photoscene.PhotosceneId);

            string id = response.Photoscene.PhotosceneId;

            if (_progressMap.ContainsKey(id))
            {
                _progressMap[id].Close();

                _progressMap.Remove(id);
            }

            if (sceneWithInfo != null)
            {
                OnLogMessage("Scene completed: " +
                             sceneWithInfo.SceneName);

                var node = GetNodeById(id);

                if (node != null)
                {
                    node.Photoscene = sceneWithInfo;
                }
                else
                {
                    RootNode.AddNode(
                        new ReCapTreeItem(
                            sceneWithInfo,
                            Properties.Resources.file));
                }
            }
        }
Esempio n. 4
0
 protected override void LoadChildren()
 {
     foreach (string dir in Directories())
     {
         RootNode.AddNode(this, new DirectoryItem(dir, this));
     }
 }
Esempio n. 5
0
        public void GetText_ShouldReturnJoinedTextsOfAllChildren()
        {
            var root   = new RootNode();
            var bold   = new BoldNode();
            var italic = new ItalicNode();
            var plain  = new PlainTextNode("Text");

            bold.AddNode(new PlainTextNode("Bold"));
            italic.AddNode(new PlainTextNode("Italic"));
            root.AddNode(plain);
            root.AddNode(bold);
            root.AddNode(italic);

            var actual = root.GetText();

            actual.Should().BeEquivalentTo($"{plain.GetText()}{bold.GetText()}{italic.GetText()}");
        }
Esempio n. 6
0
        public void BuildTree_TagsBetweenDigits_ShouldReturnTreeWithOnlyPlainText(string markdown)
        {
            var expected = new RootNode();

            expected.AddNode(new PlainTextNode(markdown));

            var actual = treeBuilder.ParseMarkdown(markdown);

            CheckTree(expected, actual);
        }
Esempio n. 7
0
        public void BuildTree_OnlyPlainText_ShouldReturnTreeFromThisText()
        {
            var markdown = "this is plain text";
            var expected = new RootNode();

            expected.AddNode(new PlainTextNode(markdown));

            var actual = treeBuilder.ParseMarkdown(markdown);

            CheckTree(expected, actual);
        }
Esempio n. 8
0
        public void BuildTree_EscapedBoldTagNotBecomeItalic_ShouldReturnTreeWithPlainText(
            string markdown, string expectedString)
        {
            var expected = new RootNode();

            expected.AddNode(new PlainTextNode(expectedString));

            var actual = treeBuilder.ParseMarkdown(markdown);

            CheckTree(expected, actual);
        }
Esempio n. 9
0
        private static IEnumerable <TestCaseData> GenerateCoherentValidTags()
        {
            foreach (var tag in Tags)
            {
                foreach (var other in Tags.Where(other => tag != other))
                {
                    var markdown = $"{tag.String}first{tag.String} {other.String}second{other.String}";
                    var expected = new RootNode();
                    var first    = tag.CreateNode();
                    var second   = other.CreateNode();
                    expected.AddNode(first);
                    expected.AddNode(new PlainTextNode(" "));
                    expected.AddNode(second);
                    first.AddNode(new PlainTextNode("first"));
                    second.AddNode(new PlainTextNode("second"));

                    yield return(new TestCaseData(markdown, expected)
                                 .SetName($"{other.GetType().Name} tags after {tag.GetType().Name} tags"));
                }
            }
        }
Esempio n. 10
0
        private void Add(string dirStr)
        {
            DirectoryInfo dir = new DirectoryInfo(dirStr);

            IEnumerable <string> names =
                from item
                in Children
                select(item as DirectoryItem).DirInfo.Name;

            int index = names.AlphaNumericInsertPosition(dir.Name);

            RootNode.AddNode(this, new DirectoryItem(dir.FullName, this), index);
        }
Esempio n. 11
0
        public void BuildTree_MarkdownWithRightTags_ShouldReturnTreeWithThisTagsNode(string markdown, Node tagNode,
                                                                                     string expectedText)
        {
            var expected = new RootNode();

            expected.AddNode(tagNode);
            tagNode.AddNode(new PlainTextNode(expectedText));


            var actual = treeBuilder.ParseMarkdown(markdown);

            CheckTree(expected, actual);
        }
Esempio n. 12
0
        public void BuildTree_EscapedBoldTagBecomeItalic_ShouldReturnTreeWithItalic(string markdown,
                                                                                    string expectedText)
        {
            var expected = new RootNode();
            var italic   = new ItalicNode();

            expected.AddNode(italic);
            italic.AddNode(new PlainTextNode(expectedText));

            var actual = treeBuilder.ParseMarkdown(markdown);

            CheckTree(expected, actual);
        }
Esempio n. 13
0
        private void Add(string driveStr)
        {
            DriveInfo drive = new DriveInfo(driveStr);

            IEnumerable <string> names =
                from item
                in Children
                select(item as VolumeItem).Path;

            int index = names.AlphaNumericInsertPosition(drive.Name);

            RootNode.AddNode(this, new VolumeItem(drive.ToString(), this), index);
        }
Esempio n. 14
0
        private static IEnumerable <TestCaseData> GenerateTabAndNewLineInsideValidTags()
        {
            foreach (var tag in Tags)
            {
                var expected = new RootNode();
                var tagNode  = tag.CreateNode();
                expected.AddNode(tagNode);
                tagNode.AddNode(new PlainTextNode("this is \nplain \t text"));

                yield return(new TestCaseData(
                                 $"{tag.String}this is \nplain \t text{tag.String}",
                                 expected)
                             .SetName($"new line and tab inside {tag.GetType().Name} tags"));
            }
        }
Esempio n. 15
0
        private static IEnumerable <TestCaseData> GenerateNestedTags()
        {
            foreach (var tag in Tags)
            {
                foreach (var other in Tags.Where(other => tag != other))
                {
                    var expectedResult = new RootNode();
                    var external       = tag.CreateNode();
                    expectedResult.AddNode(external);
                    external.AddNode(new PlainTextNode("this is "));
                    var otherNode = other.CreateNode();
                    external.AddNode(otherNode);
                    otherNode.AddNode(new PlainTextNode("plain"));
                    external.AddNode(new PlainTextNode(" text"));

                    yield return(new TestCaseData(
                                     $"{tag.String}this is {other.String}plain{other.String} text{tag.String}",
                                     expectedResult)
                                 .SetName($"{other.GetType().Name} tag nested in {tag.GetType().Name} tag"));
                }
            }
        }
        async void AddScene_Click(object sender, RoutedEventArgs e)
        {
            SceneSettingsDlg settingsDlg = new SceneSettingsDlg();

            settingsDlg.Owner = this.Parent as Window;

            settingsDlg.ShowDialog();

            if (!settingsDlg.DialogResult.HasValue || !settingsDlg.DialogResult.Value)
            {
                return;
            }

            ReCapPhotosceneOptionsBuilder options =
                new ReCapPhotosceneOptionsBuilder(
                    settingsDlg.MeshQuality,
                    settingsDlg.MeshFormat);

            var id = await CreateNewPhotoscene(
                settingsDlg.SceneName,
                options);

            if (id != string.Empty)
            {
                var sceneWithInfo = await RetrieveSceneInfo(id);

                if (sceneWithInfo != null)
                {
                    RootNode.AddNode(
                        new ReCapTreeItem(
                            sceneWithInfo,
                            Properties.Resources.file));
                }

                ShowProgressDlg(settingsDlg.SceneName, id);
            }
        }
        async Task <string> CreateNewPhotoscene(
            string sceneName,
            ReCapPhotosceneOptionsBuilder options)
        {
            string[] files = UIHelper.FileSelect(
                "Select Pictures",
                "(*.jpg)|*.jpg",
                true);

            if (files == null)
            {
                return(string.Empty);
            }

            // Step 1 - Create a new Photoscene

            var createResult = await _reCapClient.CreatePhotosceneAsync(
                sceneName,
                options);

            if (!createResult.IsOk())
            {
                OnLogReCapError(createResult.Error);

                return(string.Empty);
            }

            OnLogMessage("New scene created: " + sceneName +
                         " [Id: " + createResult.Photoscene.PhotosceneId + "]");

            var sceneWithInfo = await RetrieveSceneInfo(
                createResult.Photoscene.PhotosceneId);

            if (sceneWithInfo != null)
            {
                RootNode.AddNode(
                    new ReCapTreeItem(
                        sceneWithInfo,
                        Properties.Resources.file));
            }

            // Step 2 - Upload pictures

            OnLogMessage("Uploading " + files.Length +
                         " images for scene: " + sceneName);

            string photosceneId = createResult.Photoscene.PhotosceneId;

            var uploadResultArray = await _reCapClient.UploadFilesAsync(
                photosceneId,
                files);

            foreach (var uploadResult in uploadResultArray)
            {
                if (!uploadResult.IsOk())
                {
                    OnLogReCapError(uploadResult.Error);

                    //return;
                }
            }

            OnLogMessage("Files uploaded for scene: " + sceneName);

            // Step 3 - start processing the Photoscene

            var processResult = await _reCapClient.ProcessPhotosceneAsync(
                photosceneId);

            if (!processResult.IsOk())
            {
                OnLogReCapError(processResult.Error);

                return(photosceneId);
            }

            OnLogMessage("Start processing for scene: " + sceneName);

            return(photosceneId);
        }
Esempio n. 18
0
 protected TreeNode(TreeNode parent)
 {
     ParentNode = parent;
     RootNode.AddNode(this, DummyChild);
 }