コード例 #1
0
    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 );
      }
    }
コード例 #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;
            }
        }
コード例 #3
0
    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 );
    }
コード例 #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;
        }
コード例 #5
0
ファイル: DataRow.cs プロジェクト: briancullinan/life.net
        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);
                    }
                }
            }
        }
コード例 #6
0
 protected internal virtual void PrepareDefaultStyleKey(Xceed.Wpf.DataGrid.Views.ViewBase view)
 {
     this.DefaultStyleKey = view.GetDefaultStyleKey(typeof(GroupByItem));
 }
コード例 #7
0
 internal virtual void PrepareDefaultStyleKey(Xceed.Wpf.DataGrid.Views.ViewBase view)
 {
     this.DefaultStyleKey = view.GetDefaultStyleKey(typeof(GroupLevelIndicatorPane));
 }
コード例 #8
0
    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));
 }
コード例 #10
0
 internal virtual void PrepareDefaultStyleKey(Xceed.Wpf.DataGrid.Views.ViewBase view)
 {
     this.DefaultStyleKey = view.GetDefaultStyleKey(typeof(RowSelectorPane));
 }
コード例 #11
0
    protected internal override void PrepareDefaultStyleKey( ViewBase view )
    {
      var newThemeKey = view.GetDefaultStyleKey( typeof( ColumnManagerCell ) );
      if( object.Equals( this.DefaultStyleKey, newThemeKey ) )
        return;

      this.DefaultStyleKey = newThemeKey;
    }
コード例 #12
0
    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 );
      }
    }
コード例 #13
0
    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 );
    }
コード例 #14
0
    // 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 );
        }
      }
    }
コード例 #15
0
    public static void ImportView( ViewBase view )
    {
      if( view == null )
        throw new ArgumentNullException( "view" );

      ResourceDictionary resourceDictionary = ViewImportExportManager.AskForResourceDictionary();

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