Example #1
0
        private void ApplyValueButton_Click(object sender, EventArgs e)
        {
            if (ObjectstreeView.SelectedNode.Tag != null)
            {
                if (ObjectstreeView.SelectedNode.Tag.GetType() == typeof(DeltaListEntry))
                {
                    DeltaListEntry delta = (DeltaListEntry)ObjectstreeView.SelectedNode.Tag;

                    if (delta.Changes.Where(c => c.ChangedProperty != null && c.ChangedProperty.Name == changedPropertieslistView.SelectedItems[0].Text).Count() > 0)
                    {
                        ObjectChangeDescription change = delta.Changes.Where(c => c.ChangedProperty != null && c.ChangedProperty.Name == changedPropertieslistView.SelectedItems[0].Text).First();

                        change.NewValue = NewValuetextBox.Text;

                        change.ChangedProperty.SetValue(delta.CurrentObject_NewVersion, NewValuetextBox.Text, null);
                    }
                }
            }
        }
Example #2
0
        private void ObjectstreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            ClearTabs();

            if (e.Node.Tag != null)
            {
                if (e.Node.Tag.GetType() == typeof(DeltaListEntry))
                {
                    DeltaListEntry delta = (DeltaListEntry)e.Node.Tag;

                    if (e.Node.Text.EndsWith("Changes)"))
                    {
                        if (tabControl1.TabPages.Count == 1 || (tabControl1.TabPages.Count > 1 && tabControl1.TabPages[1] != tabPage2))
                        {
                            tabControl1.TabPages.Insert(1, tabPage2);
                        }
                    }
                    else
                    {
                        if (tabControl1.TabPages.Count > 1 && tabControl1.TabPages[1] == tabPage2)
                        {
                            tabControl1.TabPages.RemoveAt(1);
                        }
                    }

                    ObjectPropertyGrid_newVersion.SelectedObject = delta.CurrentObject_NewVersion;
                    ObjectPropertyGrid_oldVersion.SelectedObject = delta.CurrentObject_OldVersion;
                    if (delta.CurrentObject_CurrentVersion != null)
                    {
                        ObjectPropertyGrid_currentVersion.SelectedObject = delta.CurrentObject_CurrentVersion;
                    }

                    foreach (ObjectChangeDescription change in delta.Changes)
                    {
                        string oldValue     = string.Empty;
                        string newValue     = string.Empty;
                        string currentValue = string.Empty;

                        if (change.ChangeType == ChangeTypes.Changed)
                        {
                            if (change.ChangedProperty != null)
                            {
                                if (typeof(DataAccess.IDomainObject).IsAssignableFrom(change.ChangedProperty.PropertyType))
                                {
                                    string typeName = change.ChangedProperty.PropertyType.Name.Split('.').LastOrDefault();

                                    if (change.OldValue != null)
                                    {
                                        oldValue = "[" + typeName + "] " + (change.OldValue is Guid ? ((Guid)change.OldValue).ToString() : ((IDomainObject)change.OldValue).Id.ToString());
                                    }

                                    if (change.NewValue != null)
                                    {
                                        newValue = "[" + typeName + "] " + (change.NewValue is Guid ? ((Guid)change.NewValue).ToString() : ((IDomainObject)change.NewValue).Id.ToString());
                                    }

                                    if (delta.CurrentObject_CurrentVersion != null)
                                    {
                                        if (delta.CurrentObject_CurrentVersion.GetType().GetProperties().Contains(change.ChangedProperty))
                                        {
                                            object tmpValue = change.ChangedProperty.GetValue(delta.CurrentObject_CurrentVersion, null);

                                            if (tmpValue != null)
                                            {
                                                currentValue = "[" + typeName + "]" + ((IDomainObject)tmpValue).Id.ToString();
                                            }
                                        }
                                    }



                                    ListViewItem newItem = changedPropertieslistView.Items.Add(change.ChangedProperty.Name);
                                    if (change.conflict)
                                    {
                                        newItem.ForeColor = System.Drawing.Color.Red;
                                    }
                                    newItem.Tag = new Dictionary <string, string>()
                                    {
                                        { "OLD", oldValue }, { "NEW", newValue }, { "CURRENT", currentValue }
                                    };
                                }
                                else
                                {
                                    if (change.OldValue != null)
                                    {
                                        oldValue = change.OldValue.ToString();
                                    }

                                    if (change.NewValue != null)
                                    {
                                        newValue = change.NewValue.ToString();
                                    }

                                    if (delta.CurrentObject_CurrentVersion != null)
                                    {
                                        if (delta.CurrentObject_CurrentVersion.GetType().GetProperties().Contains(change.ChangedProperty))
                                        {
                                            object tmpValue = change.ChangedProperty.GetValue(delta.CurrentObject_CurrentVersion, null);

                                            if (tmpValue != null)
                                            {
                                                currentValue = tmpValue.ToString();
                                            }
                                        }
                                    }

                                    ListViewItem newItem = changedPropertieslistView.Items.Add(change.ChangedProperty.Name);
                                    if (change.conflict)
                                    {
                                        newItem.ForeColor = System.Drawing.Color.Red;
                                    }
                                    newItem.Tag = new Dictionary <string, string>()
                                    {
                                        { "OLD", oldValue }, { "NEW", newValue }, { "CURRENT", currentValue }
                                    };
                                }
                            }
                            else
                            {
                                if (delta.CurrentObject_NewVersion != null)
                                {
                                    if (typeof(DataAccess.Domain.VisualModel.UXComponent).IsAssignableFrom(delta.CurrentObject_NewVersion.GetType()))
                                    {
                                        Type oldType     = delta.CurrentObject_OldVersion.GetType();
                                        Type newType     = delta.CurrentObject_NewVersion.GetType();
                                        Type currentType = null;

                                        if (delta.CurrentObject_CurrentVersion != null)
                                        {
                                            currentType = delta.CurrentObject_CurrentVersion.GetType();
                                        }


                                        ListViewItem newItem = changedPropertieslistView.Items.Add("Type");
                                        if (change.conflict)
                                        {
                                            newItem.ForeColor = System.Drawing.Color.Red;
                                        }
                                        newItem.Tag = new Dictionary <string, string>()
                                        {
                                            { "OLD", oldType.Name }, { "NEW", newType.Name }, { "CURRENT", (currentType != null ? currentType.Name : string.Empty) }
                                        };
                                    }
                                }
                            }
                        }
                        else if (change.ChangeType == ChangeTypes.Moved)
                        {
                            oldValue = change.OldValue.ToString();
                            newValue = change.NewValue.ToString();
                            ListViewItem newItem = changedPropertieslistView.Items.Add("Component Moved");
                            if (change.conflict)
                            {
                                newItem.ForeColor = System.Drawing.Color.Red;
                            }
                            newItem.Tag = new Dictionary <string, string>()
                            {
                                { "OLD", oldValue }, { "NEW", newValue }
                            };
                        }
                    }

                    //View

                    string newXamlSource     = string.Empty;
                    string oldXamlSource     = string.Empty;
                    string currentXamlSource = string.Empty;

                    if (delta.CurrentObject_NewVersion is DataAccess.Domain.View)
                    {
                        tabControl1.TabPages.Add(tabPage3);

                        newXamlSource = GenerateXaml((DataAccess.Domain.View)delta.CurrentObject_NewVersion);
                        oldXamlSource = GenerateXaml((DataAccess.Domain.View)delta.CurrentObject_OldVersion);

                        if (delta.CurrentObject_CurrentVersion != null)
                        {
                            currentXamlSource = GenerateXaml((DataAccess.Domain.View)delta.CurrentObject_CurrentVersion);
                        }
                    }

                    if (newXamlSource != string.Empty)
                    {
                        RenderXaml(newXamlSource, NewLayoutElementHost);
                    }

                    if (oldXamlSource != string.Empty)
                    {
                        RenderXaml(oldXamlSource, OldLayoutElementHost);
                    }

                    if (currentXamlSource != string.Empty)
                    {
                        RenderXaml(currentXamlSource, CurrentLayoutElementHost);
                    }



                    //Action
                    NewSQLrichTextBox.Text = "";
                    OldSQLrichTextBox.Text = "";

                    if (delta.CurrentObject_NewVersion is DataAccess.Domain.Action)
                    {
                        DataAccess.Domain.Action newAction = (DataAccess.Domain.Action)delta.CurrentObject_NewVersion;
                        DataAccess.Domain.Action oldAction = null;

                        if (delta.CurrentObject_OldVersion != null)
                        {
                            oldAction = (DataAccess.Domain.Action)delta.CurrentObject_OldVersion;
                        }

                        if (newAction.Query != null)
                        {
                            NewSQLrichTextBox.Text = newAction.Query.SqlStatement;

                            if (oldAction != null)
                            {
                                OldSQLrichTextBox.Text = oldAction.Query.SqlStatement;
                            }
                        }
                    }
                }
                else
                {
                    ObjectChangeDescription change = (ObjectChangeDescription)e.Node.Tag;

                    ObjectPropertyGrid_newVersion.SelectedObject = change.NewValue;
                    ObjectPropertyGrid_oldVersion.SelectedObject = change.OldValue;
                }
            }

            Cursor = Cursors.Default;
        }