Beispiel #1
0
        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (this.DataContext != null && this.DataContext.GetType() == typeof(DatabaseIndexData))
            {
                DatabaseIndexData           index = (DatabaseIndexData)this.DataContext;
                Dictionary <uint, Property> propertyContainer;

                try
                {
                    MemoryStream byteStream = new MemoryStream(index.Data);

                    propertyFile = new PropertyFile();
                    propertyFile.Read(byteStream);
                    propertyContainer = propertyFile.Values;

                    PathFileEntry = new PathFile();
                    PathFileEntry.Load(propertyFile.Values);

                    ContainerGrid.DataContext = PathFileEntry;
                }
                catch (Exception ex)
                {
                    Exception subEx = ex.InnerException;
                    while (subEx != null)
                    {
                        //    exceptionMessage += subEx.Message + Environment.NewLine;
                        subEx = ex.InnerException;
                    }
                }
            }
        }
 private void Refresh()
 {
     //update properties
     if (this.DataContext.GetType() == typeof(DatabaseIndexData))
     {
         DatabaseIndexData index = (DatabaseIndexData)this.DataContext;
         //if the text has been changed, create a new modifiedIndex
         DatabaseIndex originalIndex = DatabaseManager.Instance.Find(i => i.TypeId == index.Index.TypeId &&
                                                                     i.GroupContainer == index.Index.GroupContainer &&
                                                                     i.InstanceId == index.Index.InstanceId);
         originalIndex.IsModified = true;
         ModifiedPropertyFile propertyFile = new ModifiedPropertyFile();
         propertyFile.PropertyFile               = new PropertyFile();
         propertyFile.PropertyFile.Values        = FlattenToPropertiesDictionary();
         propertyFile.PropertyFile.PropertyCount = (uint)propertyFile.PropertyFile.Values.Count;
         originalIndex.ModifiedData              = propertyFile;
     }
 }
        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (this.DataContext != null && this.DataContext.GetType() == typeof(DatabaseIndexData))
            {
                Decals.Clear();

                index = (DatabaseIndexData)this.DataContext;
                Dictionary <uint, Property> propertyContainer;

                try
                {
                    MemoryStream byteStream = new MemoryStream(index.Data);

                    propertyFile = new PropertyFile();
                    propertyFile.Read(byteStream);
                    propertyContainer = propertyFile.Values;

                    DecalDictionaryEntry = new DecalImageDictionary();
                    DecalDictionaryEntry.Load(propertyContainer);

                    gridDetails.DataContext = DecalDictionaryEntry;

                    DecalDictionaryEntry.DecalImages.ForEach(d => d.RefreshPreview());

                    Decals.AddRange(DecalDictionaryEntry.DecalImages);

                    var expression = txtMaterialId.GetBindingExpression(TextBox.TextProperty);
                    if (expression != null)
                    {
                        expression.UpdateTarget();
                    }

                    expression = txtTextureSizeX.GetBindingExpression(TextBox.TextProperty);
                    if (expression != null)
                    {
                        expression.UpdateTarget();
                    }

                    expression = txtTextureSizeY.GetBindingExpression(TextBox.TextProperty);
                    if (expression != null)
                    {
                        expression.UpdateTarget();
                    }

                    expression = txtAtlasSizeX.GetBindingExpression(TextBox.TextProperty);
                    if (expression != null)
                    {
                        expression.UpdateTarget();
                    }

                    expression = txtAtlasSizeY.GetBindingExpression(TextBox.TextProperty);
                    if (expression != null)
                    {
                        expression.UpdateTarget();
                    }
                }
                catch (Exception ex)
                {
                    Exception subEx = ex.InnerException;
                    while (subEx != null)
                    {
                        //    exceptionMessage += subEx.Message + Environment.NewLine;
                        subEx = ex.InnerException;
                    }
                }
            }
        }