public static void ExportViewToXaml( ViewBase view, string fileName )
    {
      if( view == null )
        throw new ArgumentNullException( "view" );

      object value;
      DependencyProperty dp;
      ResourceDictionary resourceDictionary = new ResourceDictionary();
      Type viewType = view.GetType();
      Style viewStyle = new Style( viewType );

      foreach( FieldInfo fieldInfo in viewType.GetFields( BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static ) )
      {
        dp = fieldInfo.GetValue( view ) as DependencyProperty;

        if( dp != null )
        {
          value = view.ReadLocalValue( dp );

          if( value != DependencyProperty.UnsetValue )
            viewStyle.Setters.Add( new Setter( dp, value ) );
        }
      }

      resourceDictionary.Add( viewType, viewStyle );

      XmlWriterSettings settings = new XmlWriterSettings();
      settings.Indent = true;
      settings.OmitXmlDeclaration = true;

      using( XmlWriter xmlWriter = XmlWriter.Create( fileName, settings ) )
      {
        XamlWriter.Save( resourceDictionary, xmlWriter );
      }
    }
Example #2
0
        protected internal override void PrepareDefaultStyleKey(Views.ViewBase view)
        {
            object currentThemeKey = view.GetDefaultStyleKey(typeof(DataRow));

            if (currentThemeKey.Equals(this.DefaultStyleKey) == false)
            {
                this.DefaultStyleKey = currentThemeKey;
            }
        }
    public static void ExportView( ViewBase view )
    {
      if( view == null )
        throw new ArgumentNullException( "view" );

      string fileName = ViewImportExportManager.AskForExportFileName();

      if( fileName.Length > 0 )
        ViewImportExportManager.ExportViewToXaml( view, fileName );
    }
Example #4
0
        protected internal override void PrepareDefaultStyleKey(Xceed.Wpf.DataGrid.Views.ViewBase view)
        {
            var currentThemeKey = view.GetDefaultStyleKey(typeof(ColumnManagerRow));

            if (currentThemeKey.Equals(this.DefaultStyleKey))
            {
                return;
            }

            this.DefaultStyleKey = currentThemeKey;
        }
Example #5
0
        protected virtual void SetTitleBarContentBinding(DataGridContext dataGridContext)
        {
            if (dataGridContext != null)
            {
                Xceed.Wpf.DataGrid.Views.ViewBase view = dataGridContext.DataGridControl.GetView();

                if ((view is TableView) ||
                    (view is TableflowView))
                {
                    return;
                }

                Column headerColumn = dataGridContext.Columns.MainColumn as Column;

                if (headerColumn != null)
                {
                    // Disable warning for DisplayMemberBinding when internaly used
#pragma warning disable 618

                    BindingBase displayMemberBinding = headerColumn.DisplayMemberBinding;

#pragma warning restore 618

                    if (displayMemberBinding == null)
                    {
                        if (dataGridContext.ItemsSourceFieldDescriptors == null)
                        {
                            throw new InvalidOperationException("An attempt was made to create a DisplayMemberBinding before the DataGridContext has been initialized.");
                        }

                        string name = headerColumn.FieldName;
                        ItemsSourceHelper.FieldDescriptor fieldDescriptor;
                        dataGridContext.ItemsSourceFieldDescriptors.TryGetValue(name, out fieldDescriptor);

                        displayMemberBinding = ItemsSourceHelper.CreateDefaultBinding(
                            this.DataContext is DataRow, name, fieldDescriptor,
                            false, true, typeof(object));
                    }

                    if (displayMemberBinding == null)
                    {
                        Debug.Assert(false, "displayMemberBinding is null.");
                        this.ClearValue(DataRow.TitleBarContentProperty);
                    }
                    else
                    {
                        this.SetBinding(DataRow.TitleBarContentProperty, displayMemberBinding);
                    }
                }
            }
        }
Example #6
0
 protected internal virtual void PrepareDefaultStyleKey(Xceed.Wpf.DataGrid.Views.ViewBase view)
 {
     this.DefaultStyleKey = view.GetDefaultStyleKey(typeof(GroupByItem));
 }
 internal virtual void PrepareDefaultStyleKey(Xceed.Wpf.DataGrid.Views.ViewBase view)
 {
     this.DefaultStyleKey = view.GetDefaultStyleKey(typeof(GroupLevelIndicatorPane));
 }
    protected internal override void PrepareDefaultStyleKey( ViewBase view )
    {
      object currentThemeKey = view.GetDefaultStyleKey( typeof( ColumnManagerRow ) );

      if( currentThemeKey.Equals( this.DefaultStyleKey ) == false )
      {
        this.DefaultStyleKey = currentThemeKey;
      }
    }
 protected internal virtual void PrepareDefaultStyleKey(Xceed.Wpf.DataGrid.Views.ViewBase view)
 {
     this.DefaultStyleKey = view.GetDefaultStyleKey(typeof(HierarchicalGroupByControlNode));
 }
 internal virtual void PrepareDefaultStyleKey(Xceed.Wpf.DataGrid.Views.ViewBase view)
 {
     this.DefaultStyleKey = view.GetDefaultStyleKey(typeof(RowSelectorPane));
 }
    protected internal override void PrepareDefaultStyleKey( ViewBase view )
    {
      var newThemeKey = view.GetDefaultStyleKey( typeof( ColumnManagerCell ) );
      if( object.Equals( this.DefaultStyleKey, newThemeKey ) )
        return;

      this.DefaultStyleKey = newThemeKey;
    }
    private static void ClearViewPropertyValues( ViewBase view )
    {
      if( view == null )
        throw new ArgumentNullException( "view" );

      DependencyProperty dp;

      foreach( FieldInfo fieldInfo in view.GetType().GetFields( BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static ) )
      {
        dp = fieldInfo.GetValue( view ) as DependencyProperty;

        if( dp != null )
          view.ClearValue( dp );
      }
    }
    public static void ImportViewFromResourceDictionary( ViewBase view, ResourceDictionary resourceDictionary )
    {
      if( view == null )
        throw new ArgumentNullException( "view" );

      if( resourceDictionary == null )
        throw new ArgumentNullException( "resourceDictionary" );

      Type viewType = view.GetType();

      // Try extracting a implicit style for the specified view from the ResourceDictionary.
      Style viewStyle = resourceDictionary[ viewType ] as Style;

      if( viewStyle == null )
      {
        // There is no implicit style for the specified view in the ResourceDictionary. 
        // Use the first Style having the view type as TargetType.
        Style tempStyle;

        foreach( object value in resourceDictionary.Values )
        {
          tempStyle = value as Style;

          if( ( tempStyle != null ) && ( tempStyle.TargetType == viewType ) )
          {
            viewStyle = tempStyle;
            break;
          }
        }
      }

      ViewImportExportManager.ImportViewFromStyle( view, viewStyle );
    }
    // In a typical application, this way of applying a style would be undesirable. The 
    // style would rather simply be added to a ResourceDictionary as implicit.
    // Here, we want to set all CardflowView3D properties so that the ConfigurationPanel
    // reflects them.
    public static void ImportViewFromStyle( ViewBase view, Style viewStyle )
    {
      if( view == null )
        throw new ArgumentNullException( "view" );

      // Remove the local values on the CardflowView3D so that the newly selected preset
      // is applied in its entirety. The properties set in a style have a priority less 
      // than a local value (set by the various sliders and checkboxes).
      ViewImportExportManager.ClearViewPropertyValues( view );

      if( viewStyle != null )
      {
        foreach( Setter setter in viewStyle.Setters )
        {
          view.SetValue( setter.Property, setter.Value );
        }
      }
    }
    public static void ImportView( ViewBase view )
    {
      if( view == null )
        throw new ArgumentNullException( "view" );

      ResourceDictionary resourceDictionary = ViewImportExportManager.AskForResourceDictionary();

      if( resourceDictionary != null )
        ViewImportExportManager.ImportViewFromResourceDictionary( view, resourceDictionary );
    }