コード例 #1
0
        private void OnNoAudioContentFoundByFlowDocumentParserEvent(TreeNode treeNode)
        {
            DebugFix.Assert(treeNode.NeedsAudio());
            DebugFix.Assert(!treeNode.HasOrInheritsAudio());

            if (Tobi.Common.Settings.Default.ValidMissingAudioElements_Enable && isTreeNodeValidNoAudio(treeNode))
            {
                return;
            }

            foreach (var valItem in ValidationItems)
            {
                // ensure no duplicates
                if (valItem is MissingAudioValidationError && ((MissingAudioValidationError)valItem).Target == treeNode)
                {
                    return;
                }
            }

            var error = new MissingAudioValidationError(m_Session)
            {
                Target    = treeNode,
                Validator = this
            };

            addValidationItem(error);
        }
コード例 #2
0
        private void updateTreeNodeAudioStatus(bool forceRemove, TreeNode node)
        {
            foreach (var childTreeNode in node.Children.ContentsAs_Enumerable)
            {
                updateTreeNodeAudioStatus(forceRemove, childTreeNode);
            }

            if (!forceRemove && node.NeedsAudio() && !node.HasOrInheritsAudio())
            {
                bool alreadyInList = false;
                foreach (var vItem in ValidationItems)
                {
                    var valItem = vItem as MissingAudioValidationError;

                    DebugFix.Assert(valItem != null);
                    if (valItem == null)
                    {
                        continue;
                    }

                    if (valItem.Target == node)
                    {
                        alreadyInList = true;
                        break;
                    }
                }
                if (!alreadyInList)
                {
                    var validationItem = new MissingAudioValidationError(m_Session)
                    {
                        Target    = node,
                        Validator = this
                    };

                    bool inserted = false;
                    int  i        = -1;
                    foreach (var vItem in ValidationItems)
                    {
                        i++;
                        var valItem = vItem as MissingAudioValidationError;

                        DebugFix.Assert(valItem != null);
                        if (valItem == null)
                        {
                            continue;
                        }

                        if (node.IsBefore(valItem.Target))
                        {
                            insertValidationItem(i, validationItem);
                            inserted = true;
                            break;
                        }
                    }
                    if (!inserted)
                    {
                        addValidationItem(validationItem);
                    }
                }
            }
            else
            {
                var toRemove = new List <ValidationItem>();

                foreach (var vItem in ValidationItems)
                {
                    var valItem = vItem as MissingAudioValidationError;

                    DebugFix.Assert(valItem != null);
                    if (valItem == null)
                    {
                        continue;
                    }

                    if (valItem.Target == node)
                    {
                        toRemove.Add(vItem);
                    }
                }

                removeValidationItems(toRemove);
            }
        }