public Comparison.IDiffViewer GetDifferenceViewer(object Comparand)
        {
            var DiffViewer = new Comparison.ExternalTextDiffViewer(m_Content.ToString(), ((HTMLDocument)Comparand).m_Content.ToString());

            return(DiffViewer);
        }
Exemple #2
0
        private void GatherUICommands(ComparisonItem cmpItem, List <UICommand> RClickCommands, bool IsLeftSourced)
        {
            if (cmpItem == null || cmpItem.NodeType == ResultNodeType.ObjectsCollection)
            {
                return;
            }

            if (cmpItem.NodeType == ResultNodeType.FakeNode)
            {
                GatherUICommands(cmpItem.Parent, RClickCommands, IsLeftSourced);
                return;
            }

            // gathering treeitem commands
            object srcObject = (IsLeftSourced) ? cmpItem.Left.Object : cmpItem.Right.Object;

            if (cmpItem.NodeType == ResultNodeType.PropertyDef)
            {
                if (srcObject != null)
                {
                    var PropDef = (PropDef)srcObject;
                    AddProviderCommands(PropDef as ICommandProvider, RClickCommands);

                    if (cmpItem.Status == ComparisonStatus.Modified || cmpItem.Status == ComparisonStatus.Match)
                    {
                        if (PropDef.Value is V8ModuleProcessor)
                        {
                            var cmd = new UICommand("Показать различия в модулях", cmpItem, new Action(
                                                        () =>
                            {
                                V8ModuleProcessor LeftVal  = ((PropDef)cmpItem.Left.Object).Value as V8ModuleProcessor;
                                V8ModuleProcessor RightVal = ((PropDef)cmpItem.Right.Object).Value as V8ModuleProcessor;
                                var viewer = LeftVal.GetDifferenceViewer(RightVal);
                                if (viewer != null)
                                {
                                    viewer.ShowDifference(LeftName, RightName);
                                }
                            }));

                            RClickCommands.Add(cmd);
                        }
                        else if (PropDef.Value is TemplateDocument)
                        {
                            var cmd = new UICommand("Показать различия в макетах", cmpItem, new Action(
                                                        () =>
                            {
                                TemplateDocument LeftVal  = ((PropDef)cmpItem.Left.Object).Value as TemplateDocument;
                                TemplateDocument RightVal = ((PropDef)cmpItem.Right.Object).Value as TemplateDocument;
                                var viewer = LeftVal.GetDifferenceViewer(RightVal);
                                if (viewer != null)
                                {
                                    viewer.ShowDifference(LeftName, RightName);
                                }
                            }));

                            RClickCommands.Add(cmd);
                        }
                        else if (PropDef.Value is MDUserDialogBase)
                        {
                            var cmd = new UICommand("Показать различия в диалогах", cmpItem, new Action(
                                                        () =>
                            {
                                MDUserDialogBase LeftVal  = ((PropDef)cmpItem.Left.Object).Value as MDUserDialogBase;
                                MDUserDialogBase RightVal = ((PropDef)cmpItem.Right.Object).Value as MDUserDialogBase;
                                var viewer = new Comparison.ExternalTextDiffViewer(LeftVal.ToString(), RightVal.ToString());
                                if (viewer != null)
                                {
                                    viewer.ShowDifference(LeftName, RightName);
                                }
                            }));

                            RClickCommands.Add(cmd);
                        }
                    }
                    GatherUICommands(cmpItem.Parent, RClickCommands, IsLeftSourced);
                }
            }
            else if (cmpItem.NodeType == ResultNodeType.Object)
            {
                var Provider = srcObject as ICommandProvider;
                AddProviderCommands(Provider, RClickCommands);
            }

            if (srcObject != null && srcObject is IMDPropertyProvider)
            {
                var cmd = new UICommand("Отчет по свойствам", srcObject, () =>
                {
                    PropertiesReport repGenerator;
                    string windowTitle;

                    if (cmpItem.Left.Object != null && cmpItem.Right.Object != null)
                    {
                        repGenerator = new PropertiesReportCompare(cmpItem.Left.Object as IMDPropertyProvider, cmpItem.Right.Object as IMDPropertyProvider);
                        windowTitle  = String.Format("Отчет по свойствам: {0}/{1}", cmpItem.Left.Object.ToString(), cmpItem.Right.Object.ToString());
                    }
                    else
                    {
                        repGenerator = new PropertiesReportSingle((IMDPropertyProvider)srcObject);
                        windowTitle  = srcObject.ToString();
                    }

                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        FlowDocViewer fdViewer = new FlowDocViewer();
                        fdViewer.Title         = windowTitle;
                        fdViewer.Document      = repGenerator.GenerateReport();
                        fdViewer.Show();
                    }));
                });

                RClickCommands.Add(cmd);
            }
        }