コード例 #1
0
        private TreeNode AddNode(TreeNode tnParent, ChangeInfo changeinfo)
        {
            TreeNode tn = new TreeNode();

            tn.Tag = changeinfo;
            UpdateNode(tn);

            if (tnParent != null)
            {
                tnParent.Nodes.Add(tn);
            }
            else
            {
                this.treeView.Nodes.Add(tn);
            }

            return(tn);
        }
コード例 #2
0
        private void UpdateNode(TreeNode tn)
        {
            ChangeInfo changeinfo = (ChangeInfo)tn.Tag;

            if (changeinfo.Change != null)
            {
                tn.Text = changeinfo.Change.Name;
            }
            else if (changeinfo.Original != null)
            {
                tn.Text = changeinfo.Original.Name;
            }

            // back color indicates change type
            if (changeinfo.Original == null)
            {
                // addition
                tn.BackColor = Color.Lime;
            }
            else if (changeinfo.Change == null)
            {
                // deletion
                tn.BackColor = Color.Red;
            }
            else if (changeinfo.Original.Documentation != changeinfo.Change.Documentation ||
                     (changeinfo.Original.Documentation != null && !changeinfo.Original.Documentation.Equals(changeinfo.Change.Documentation)))
            {
                // update
                tn.BackColor = Color.Yellow;
            }
            else
            {
                tn.BackColor = Color.Empty;
            }

            // checkbox indicates accept or reject
            //tn.Checked = changeinfo.Accept;
        }
コード例 #3
0
        private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            this.lvSource.Items.Clear();
            this.lvDestination.Items.Clear();

            ChangeInfo info = (ChangeInfo)this.treeView.SelectedNode.Tag;

            DiffList_TextString source      = new DiffList_TextString(info.Original != null ? info.Original.Documentation : String.Empty);
            DiffList_TextString destination = new DiffList_TextString(info.Change != null ? info.Change.Documentation : String.Empty);
            DiffEngine          de          = new DiffEngine();

            de.ProcessDiff(source, destination, DiffEngineLevel.SlowPerfect);
            ArrayList DiffLines = de.DiffReport();

            ListViewItem lviS;
            ListViewItem lviD;
            int          cnt = 1;
            int          i;

            foreach (DiffResultSpan drs in DiffLines)
            {
                switch (drs.Status)
                {
                case DiffResultSpanStatus.DeleteSource:
                    for (i = 0; i < drs.Length; i++)
                    {
                        lviS           = new ListViewItem(cnt.ToString("00000"));
                        lviD           = new ListViewItem(cnt.ToString("00000"));
                        lviS.BackColor = Color.Red;
                        lviS.SubItems.Add(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line);
                        lviD.BackColor = Color.LightGray;
                        lviD.SubItems.Add("");

                        lvSource.Items.Add(lviS);
                        lvDestination.Items.Add(lviD);
                        cnt++;
                    }

                    break;

                case DiffResultSpanStatus.NoChange:
                    for (i = 0; i < drs.Length; i++)
                    {
                        lviS           = new ListViewItem(cnt.ToString("00000"));
                        lviD           = new ListViewItem(cnt.ToString("00000"));
                        lviS.BackColor = Color.White;
                        lviS.SubItems.Add(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line);
                        lviD.BackColor = Color.White;
                        lviD.SubItems.Add(((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line);

                        lvSource.Items.Add(lviS);
                        lvDestination.Items.Add(lviD);
                        cnt++;
                    }

                    break;

                case DiffResultSpanStatus.AddDestination:
                    for (i = 0; i < drs.Length; i++)
                    {
                        lviS           = new ListViewItem(cnt.ToString("00000"));
                        lviD           = new ListViewItem(cnt.ToString("00000"));
                        lviS.BackColor = Color.LightGray;
                        lviS.SubItems.Add("");
                        lviD.BackColor = Color.LightGreen;
                        lviD.SubItems.Add(((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line);

                        lvSource.Items.Add(lviS);
                        lvDestination.Items.Add(lviD);
                        cnt++;
                    }

                    break;

                case DiffResultSpanStatus.Replace:
                    for (i = 0; i < drs.Length; i++)
                    {
                        lviS           = new ListViewItem(cnt.ToString("00000"));
                        lviD           = new ListViewItem(cnt.ToString("00000"));
                        lviS.BackColor = Color.Red;
                        lviS.SubItems.Add(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line);
                        lviD.BackColor = Color.LightGreen;
                        lviD.SubItems.Add(((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line);

                        lvSource.Items.Add(lviS);
                        lvDestination.Items.Add(lviD);
                        cnt++;
                    }

                    break;
                }
            }


            this.radioButtonOriginal.Checked = !this.treeView.SelectedNode.Checked;
            this.radioButtonChange.Checked   = this.treeView.SelectedNode.Checked;
        }
コード例 #4
0
        private void SaveNode(TreeNode tn)
        {
            ChangeInfo info = (ChangeInfo)tn.Tag;

            if (tn.Checked)
            {
                if (info.Original == null)
                {
                    // add new item
                    if (info.Change is DocLocalization)
                    {
                        DocLocalization localChange = (DocLocalization)info.Change;

                        ChangeInfo parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocObject  docObj     = (DocObject)parentinfo.Original;
                        docObj.RegisterLocalization(localChange.Locale, localChange.Name, localChange.Documentation);
                    }
                    else if (info.Change is DocAttribute)
                    {
                        DocAttribute localAttr = (DocAttribute)info.Change;

                        ChangeInfo parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocEntity  docEntity  = (DocEntity)parentinfo.Original;

                        DocAttribute docAttr = (DocAttribute)localAttr.Clone();
                        docEntity.Attributes.Add(docAttr);
                    }
                    else if (info.Change is DocWhereRule)
                    {
                        DocWhereRule localAttr = (DocWhereRule)info.Change;

                        ChangeInfo parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocEntity  docEntity  = (DocEntity)parentinfo.Original;

                        DocWhereRule docAttr = (DocWhereRule)localAttr.Clone();
                        docEntity.WhereRules.Add(docAttr);
                    }
                    else if (info.Change is DocFunction)
                    {
                        DocFunction localAttr = (DocFunction)info.Change;

                        ChangeInfo parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocSchema  docSchema  = (DocSchema)parentinfo.Original;

                        DocFunction docAttr = (DocFunction)localAttr.Clone();
                        docSchema.Functions.Add(docAttr);
                    }
                    else if (info.Change is DocConstant)
                    {
                        this.ToString();
                    }
                    else if (info.Change is DocProperty)
                    {
                        this.ToString();

                        DocProperty localProp = (DocProperty)info.Change;

                        ChangeInfo     parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocPropertySet docPset    = (DocPropertySet)parentinfo.Original;

                        DocProperty docProperty = (DocProperty)localProp.Clone();
                        docPset.Properties.Add(docProperty);
                    }
                    else if (info.Change is DocPropertyConstant)
                    {
                        this.ToString();

                        DocPropertyConstant localProp = (DocPropertyConstant)info.Change;

                        ChangeInfo             parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocPropertyEnumeration docPset    = (DocPropertyEnumeration)parentinfo.Original;

                        DocPropertyEnumeration docEnumChange = (DocPropertyEnumeration)parentinfo.Change;
                        int index = docEnumChange.Constants.IndexOf(localProp);

                        DocPropertyConstant docProperty = (DocPropertyConstant)localProp.Clone();
                        docPset.Constants.Insert(index, docProperty);
                    }
                    else
                    {
                        this.ToString();
                    }
                }
                else if (info.Change == null)
                {
                    // removal of definition
                    if (info.Original is DocAttribute)
                    {
                        DocAttribute docAttr    = (DocAttribute)info.Original;
                        ChangeInfo   parentinfo = (ChangeInfo)tn.Parent.Tag;
                        DocEntity    docEntity  = (DocEntity)parentinfo.Original;

                        docEntity.Attributes.Remove(docAttr);
                        docAttr.Delete();
                    }
                    else
                    {
                        this.ToString();
                    }
                }
                else
                {
                    // change of documentation
                    info.Original.Name          = info.Change.Name;
                    info.Original.Documentation = info.Change.Documentation;

                    if (info.Original is DocWhereRule)
                    {
                        DocWhereRule whereOriginal = (DocWhereRule)info.Original;
                        DocWhereRule whereChange   = (DocWhereRule)info.Change;
                        whereOriginal.Expression = whereChange.Expression;
                    }
                    else if (info.Original is DocFunction)
                    {
                        DocFunction whereOriginal = (DocFunction)info.Original;
                        DocFunction whereChange   = (DocFunction)info.Change;
                        whereOriginal.Expression = whereChange.Expression;
                    }
                }
            }

            foreach (TreeNode tnSub in tn.Nodes)
            {
                SaveNode(tnSub);
            }
        }
コード例 #5
0
ファイル: FormMerge.cs プロジェクト: corneliuspreidel/IfcDoc
        private TreeNode AddNode(TreeNode tnParent, ChangeInfo changeinfo)
        {
            TreeNode tn = new TreeNode();
            tn.Tag = changeinfo;
            UpdateNode(tn);

            if (tnParent != null)
            {
                tnParent.Nodes.Add(tn);
            }
            else
            {
                this.treeView.Nodes.Add(tn);
            }

            return tn;
        }