public PlaylistGridViewColumn Create(PlaylistColumn column) { var gridViewColumn = new PlaylistGridViewColumn(column); switch (column.Type) { case PlaylistColumnType.Script: if (!string.IsNullOrEmpty(column.Script)) { gridViewColumn.DisplayMemberBinding = new PlaylistScriptBinding() { ScriptingContext = this.ScriptingContext.Value, Script = column.Script }; } break; case PlaylistColumnType.Plugin: if (!string.IsNullOrEmpty(column.Plugin)) { var provider = PlaylistColumnProviderManager.GetProvider(column.Plugin); if (provider != null) { gridViewColumn.CellTemplate = provider.CellTemplate; } } break; case PlaylistColumnType.Tag: if (!string.IsNullOrEmpty(column.Tag)) { gridViewColumn.DisplayMemberBinding = new PlaylistMetaDataBinding() { Name = column.Tag, Format = column.Format }; } break; } BindingHelper.Create( gridViewColumn, GridViewColumn.WidthProperty, typeof(GridViewColumn), column, "Width", ColumnWidthConverter.Instance, (sender, e) => this.OnWidthChanged(column) ); BindingHelper.Create( gridViewColumn, GridViewColumnExtensions.PositionProperty, typeof(GridViewColumn), column, "Sequence", (sender, e) => this.OnPositionChanged(column) ); return(gridViewColumn); }
public AutoExpandBehaviour(TreeView treeView) { this.TreeView = treeView; BindingHelper.AddHandler( this.TreeView, ItemsControl.ItemsSourceProperty, typeof(ListView), this.OnItemsSourceChanged ); }
public GroupStyleBehaviour(ListView listView) { this.ListView = listView; this.ScriptingContext = ScriptingRuntime.CreateContext(); BindingHelper.AddHandler( this.ListView, ItemsControl.ItemsSourceProperty, typeof(ListView), this.OnItemsSourceChanged ); }
public GridViewColumn Create(PlaylistColumn column) { this.EnsureScriptingContext(); var gridViewColumn = default(GridViewColumn); if (column.IsDynamic) { gridViewColumn = new RefreshableGridViewColumn(); } else { gridViewColumn = new GridViewColumn(); } gridViewColumn.Header = column.Name; switch (column.Type) { case PlaylistColumnType.Script: gridViewColumn.DisplayMemberBinding = new PlaylistScriptBinding() { PlaybackManager = this.PlaybackManager, ScriptingContext = this.ScriptingContext, Script = column.Script }; break; case PlaylistColumnType.Plugin: var provider = PlaylistColumnManager.GetProvider(column.Plugin); if (provider != null) { gridViewColumn.CellTemplate = provider.CellTemplate; } break; } BindingHelper.Create( gridViewColumn, GridViewColumn.WidthProperty, typeof(GridViewColumn), column, "Width", ColumnWidthConverter.Instance, (sender, e) => this.OnWidthChanged(column) ); BindingHelper.Create( gridViewColumn, GridViewColumnExtensions.PositionProperty, typeof(GridViewColumn), column, "Sequence", (sender, e) => this.OnPositionChanged(column) ); return(gridViewColumn); }
protected virtual void UpdateLayoutSource() { if (this.Parent == null) { return; } var grid = this.Parent.FindAncestor <Grid>(); if (grid == null) { return; } var index = default(int); switch (this.SizeMode) { case SquareUIComponentSizeMode.ToWidth: var column = default(ColumnDefinition); index = Grid.GetColumn(this); if (index < grid.ColumnDefinitions.Count) { column = grid.ColumnDefinitions[index]; BindingHelper.AddHandler(column, ColumnDefinition.WidthProperty, typeof(ColumnDefinition), (sender, e) => { this.UpdateLayoutSource(column); }); } this.UpdateLayoutSource(column); break; case SquareUIComponentSizeMode.ToHeight: var row = default(RowDefinition); index = Grid.GetRow(this); if (index < grid.RowDefinitions.Count) { row = grid.RowDefinitions[index]; BindingHelper.AddHandler(row, RowDefinition.HeightProperty, typeof(RowDefinition), (sender, e) => { this.UpdateLayoutSource(row); }); } this.UpdateLayoutSource(row); break; } }
protected override void Dispose(bool disposing) { if (this.ListView != null) { BindingHelper.RemoveHandler( this.ListView, ItemsControl.ItemsSourceProperty, typeof(ListView), this.OnItemsSourceChanged ); } if (this.ScriptingContext != null) { this.ScriptingContext.Dispose(); this.ScriptingContext = null; } base.Dispose(disposing); }
protected override void OnVisualParentChanged(DependencyObject oldParent) { if (this.Parent != null) { var row = default(RowDefinition); var grid = this.Parent.FindAncestor <Grid>(); if (grid != null) { var index = Grid.GetRow(this); if (index < grid.RowDefinitions.Count) { row = grid.RowDefinitions[index]; BindingHelper.AddHandler(row, RowDefinition.HeightProperty, typeof(RowDefinition), (sender, e) => { this.UpdateLayoutSource(row); }); } } this.UpdateLayoutSource(row); } base.OnVisualParentChanged(oldParent); }
public PlaylistGridViewColumn Create(PlaylistColumn column) { var gridViewColumn = new PlaylistGridViewColumn(column); switch (column.Type) { case PlaylistColumnType.Script: if (!string.IsNullOrEmpty(column.Script)) { gridViewColumn.DisplayMemberBinding = new PlaylistScriptBinding() { ScriptingContext = this.ScriptingContext.Value, Script = column.Script }; } break; case PlaylistColumnType.Plugin: if (!string.IsNullOrEmpty(column.Plugin)) { var provider = PlaylistColumnProviderManager.GetProvider(column.Plugin) as IUIPlaylistColumnProvider; if (provider == null) { Logger.Write(this, LogLevel.Warn, "Playlist column plugin \"{0}\" was not found, has it been uninstalled?", column.Plugin); } else { gridViewColumn.CellTemplate = provider.CellTemplate; } } break; case PlaylistColumnType.Tag: if (!string.IsNullOrEmpty(column.Tag)) { gridViewColumn.DisplayMemberBinding = new PlaylistMetaDataBinding() { Name = column.Tag, Format = column.Format }; } break; } BindingHelper.Create( gridViewColumn, GridViewColumn.WidthProperty, typeof(GridViewColumn), column, "Width", ColumnWidthConverter.Instance, (sender, e) => { if (IsAutoSizing(gridViewColumn)) { //Don't raise events while auto sizing is in progress. return; } this.OnWidthChanged(column); } ); BindingHelper.Create( gridViewColumn, GridViewColumnExtensions.PositionProperty, typeof(GridViewColumn), column, "Sequence", (sender, e) => this.OnPositionChanged(column) ); return(gridViewColumn); }
protected override void OnDisposing() { BindingHelper.RemoveHandler(this.ScrollViewer, VerticalValueProperty, typeof(ScrollViewer), this.OnVerticalValueChanged); base.OnDisposing(); }
public OffsetBehaviour(ScrollViewer scrollViewer) { this.ScrollViewer = scrollViewer; BindingHelper.AddHandler(this.ScrollViewer, VerticalValueProperty, typeof(ScrollViewer), this.OnVerticalValueChanged); }