Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from official #1

Merged
merged 12 commits into from
Nov 9, 2015
15 changes: 15 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog for Fluent.Ribbon

## 3.6.0

- ### Bug fixes
- [#163](../../issues/163) - ColorGallery produces Binding errors because of Binding of Color on SolidColorBrush in Fill/Background
- [#166](../../issues/166) - Type is mismatch for IsCheckedProperty of ToggleButton
- [#170](../../issues/170) - Black RibbonWindow title bar
- [#173](../../issues/173) - Binding Observable Collection to InRibbonGallery causes Layout Error
- [#178](../../issues/178) - Ribbonwindow crashes

- ### Enhancements
- [#172](../../issues/172) - ToggleButtonHelper.OnIsCheckedChanged() accepts type of "bool?". contributed by ([nishy2000](https://github.com/nishy2000))
- [#175](../../issues/175) - Add "CloseOnEsc" property to Backstage to disable closing the backstage when ESC is pressed. contributed by Christoph Fink ([chrfin](https://github.com/chrfin))

Commits: [c7151027f5...97001b17e9](../../compare/c7151027f5...97001b17e9)

## 3.5.1

- ### Bug fixes
Expand Down
61 changes: 40 additions & 21 deletions Fluent/Controls/GalleryGroupContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ public class GalleryGroupContainer : HeaderedItemsControl
{
#region Fields

private Panel previousItemsPanel;
private int previousItemsCount;

// Whether MaxWidth of the ItemsPanel needs to be updated
bool maxMinWidthNeedsToBeUpdated;
private bool maxMinWidthNeedsToBeUpdated;

#endregion

Expand Down Expand Up @@ -154,7 +157,6 @@ public int MaxItemsInRow
DependencyProperty.Register("MaxItemsInRow", typeof(int),
typeof(GalleryGroupContainer), new UIPropertyMetadata(int.MaxValue, OnMaxMinItemsInRowChanged));


#endregion

#endregion
Expand All @@ -175,7 +177,7 @@ static object OnCoerceStyle(DependencyObject d, object basevalue)
{
if (basevalue == null)
{
basevalue = (d as FrameworkElement).TryFindResource(typeof(GalleryGroupContainer));
basevalue = ((FrameworkElement)d).TryFindResource(typeof(GalleryGroupContainer));
}

return basevalue;
Expand Down Expand Up @@ -228,42 +230,59 @@ private void UpdateMinAndMaxWidth()
/// <returns></returns>
public Size GetItemSize()
{
if (!double.IsNaN(this.ItemWidth) && !double.IsNaN(this.ItemHeight)) return new Size(this.ItemWidth, this.ItemHeight);
if (this.Items.Count == 0) return Size.Empty;
if (!double.IsNaN(this.ItemWidth)
&& !double.IsNaN(this.ItemHeight))
{
return new Size(this.ItemWidth, this.ItemHeight);
}

if (this.Items.Count == 0)
{
return Size.Empty;
}

var anItem = this.ItemContainerGenerator.ContainerFromItem(this.Items[0]) as UIElement;
if (anItem == null)
{
return Size.Empty;
}

UIElement anItem = this.ItemContainerGenerator.ContainerFromItem(this.Items[0]) as UIElement;
if (anItem == null) return Size.Empty;
anItem.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
Size result = anItem.DesiredSize;
var result = anItem.DesiredSize;
anItem.InvalidateMeasure();
return result;
}

// Determinates item's width (return Double.NaN in case of it is not possible)
double GetItemWidth()
private double GetItemWidth()
{
return this.GetItemSize().Width;
}

// Finds panel with IsItemsHost, or null if such panel is not found
static Panel FindItemsPanel(DependencyObject obj)
private static Panel FindItemsPanel(DependencyObject obj)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
Panel panel = obj as Panel;
if (panel != null && panel.IsItemsHost) return panel;
var panel = obj as Panel;
if (panel != null &&
panel.IsItemsHost)
{
return panel;
}

panel = FindItemsPanel(VisualTreeHelper.GetChild(obj, i));
if (panel != null) return panel;
if (panel != null)
{
return panel;
}
}

return null;
}

#endregion

Panel previousItemsPanel = null;
int previousItemsCount = 0;

/// <summary>
/// Called to remeasure a control.
/// </summary>
Expand All @@ -272,9 +291,9 @@ static Panel FindItemsPanel(DependencyObject obj)
protected override Size MeasureOverride(Size constraint)
{
var panel = FindItemsPanel(this);
if (panel != this.previousItemsPanel ||
this.previousItemsCount != this.Items.Count ||
this.maxMinWidthNeedsToBeUpdated)
if (panel != this.previousItemsPanel
|| this.previousItemsCount != this.Items.Count
|| this.maxMinWidthNeedsToBeUpdated)
{
// Track ItemsPanel changing
this.previousItemsPanel = panel;
Expand All @@ -284,4 +303,4 @@ protected override Size MeasureOverride(Size constraint)
return base.MeasureOverride(constraint);
}
}
}
}
6 changes: 1 addition & 5 deletions Fluent/Controls/GalleryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ namespace Fluent
/// </summary>
public class GalleryItem : ListBoxItem, IKeyTipedControl
{
#region Fields


#endregion

#region Properties

#region KeyTip
Expand Down Expand Up @@ -296,6 +291,7 @@ public event RoutedEventHandler Click
this.RemoveHandler(ClickEvent, value);
}
}

/// <summary>
/// Identifies the RibbonControl.Click routed event.
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions Fluent/Controls/GalleryPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Threading;
Expand Down Expand Up @@ -607,5 +608,16 @@ protected override IEnumerator LogicalChildren
}
}
}

/// <summary>
/// Called when the <see cref="P:System.Windows.Controls.ItemsControl.Items"/> collection that is associated with the <see cref="T:System.Windows.Controls.ItemsControl"/> for this <see cref="T:System.Windows.Controls.Panel"/> changes.
/// </summary>
/// <param name="sender">The <see cref="T:System.Object"/> that raised the event.</param><param name="args">Provides data for the <see cref="E:System.Windows.Controls.ItemContainerGenerator.ItemsChanged"/> event.</param>
protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
{
base.OnItemsChanged(sender, args);

this.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(this.Refresh));
}
}
}
16 changes: 0 additions & 16 deletions Fluent/Controls/Ribbon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1984,19 +1984,13 @@ private string IsolatedStorageFileName

public void SaveStateToMemoryStream()
{
Trace.WriteLine(string.Format("Saving state to memory stream..."));

this.memoryStream.Position = 0;
this.SaveState(this.memoryStream);

Trace.WriteLine(string.Format("State saved to memory stream."));
}

// Saves to Isolated Storage (in user store for domain)
public void SaveStateToIsolatedStorage()
{
Trace.WriteLine(string.Format("Saving state to isolated storage..."));

// Check whether automatic save is valid now
if (this.ribbon.AutomaticStateManagement == false)
{
Expand All @@ -2018,8 +2012,6 @@ public void SaveStateToIsolatedStorage()
{
this.SaveState(stream);
}

Trace.WriteLine(string.Format("State saved to isolated storage."));
}
catch (Exception ex)
{
Expand Down Expand Up @@ -2084,12 +2076,8 @@ private void SaveState(Stream stream)

public void LoadStateFromMemoryStream()
{
Trace.WriteLine(string.Format("Loading state from memory stream..."));

this.memoryStream.Position = 0;
this.LoadState(this.memoryStream);

Trace.WriteLine(string.Format("State loaded from memory stream."));
}

/// <summary>
Expand All @@ -2100,8 +2088,6 @@ public void LoadStateFromMemoryStream()
/// </remarks>
public void LoadStateFromIsolatedStorage()
{
Trace.WriteLine(string.Format("Loading state from isolated storage..."));

// Don't save or load state in design mode
if (DesignerProperties.GetIsInDesignMode(this.ribbon))
{
Expand Down Expand Up @@ -2132,8 +2118,6 @@ public void LoadStateFromIsolatedStorage()
this.memoryStream.Position = 0;
stream.CopyTo(this.memoryStream);
}

Trace.WriteLine(string.Format("State loaded from isolated storage."));
}
}
catch (Exception ex)
Expand Down
2 changes: 0 additions & 2 deletions Fluent/Controls/RibbonWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@ public override void OnApplyTemplate()

this.UpdateCanUseDwm();

this.UpdateWindowChrome();

if (this.iconImage != null)
{
this.iconImage.MouseDown -= this.HandleIconMouseDown;
Expand Down
5 changes: 3 additions & 2 deletions FluentTest/TestContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1212,9 +1212,10 @@
Header="Pink" />
</Fluent:DropDownButton>

<Fluent:Button Header="TEST"
<Fluent:Button Header="Refresh (Galleries)"
Icon="Images\Green.png"
LargeIcon="Images\GreenLarge.png"/>
LargeIcon="Images\GreenLarge.png"
Command="{Binding GalleryViewModel.RefreshCommand}" />

<!--Though, you may set children of the Gallery explicitly -->
<Fluent:DropDownButton Header="Pink"
Expand Down
41 changes: 25 additions & 16 deletions FluentTest/ViewModels/GalleryViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
namespace FluentTest.ViewModels
{
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Input;
using FluentTest.Commanding;

public class GalleryViewModel : ViewModel
{
private ObservableCollection<GalleryItemViewModel> items;

public GalleryViewModel()
{
this.Items = new ObservableCollection<GalleryItemViewModel>
{
new GalleryItemViewModel("Group 1", "1"),
new GalleryItemViewModel("Group 1", "2"),
new GalleryItemViewModel("Group 1", "3"),
new GalleryItemViewModel("Group 1", "4"),
new GalleryItemViewModel("Group 1", "5"),
new GalleryItemViewModel("Group 1", "6"),
this.Items = new ObservableCollection<GalleryItemViewModel>();
this.RefreshCommand = new RelayCommand(this.Refresh);

new GalleryItemViewModel("Group 2", "10"),
new GalleryItemViewModel("Group 2", "20"),
new GalleryItemViewModel("Group 2", "30"),
new GalleryItemViewModel("Group 2", "40"),
new GalleryItemViewModel("Group 2", "50"),
new GalleryItemViewModel("Group 2", "60"),
};
this.Refresh();
}

public ObservableCollection<GalleryItemViewModel> Items
Expand All @@ -37,5 +26,25 @@ private set
this.OnPropertyChanged("Items");
}
}

public ICommand RefreshCommand { get; private set; }

public void Refresh()
{
this.Items.Clear();

this.Items.Add(new GalleryItemViewModel("Group 1", "1"));
this.Items.Add(new GalleryItemViewModel("Group 1", "2"));
this.Items.Add(new GalleryItemViewModel("Group 1", "3"));
this.Items.Add(new GalleryItemViewModel("Group 1", "4"));
this.Items.Add(new GalleryItemViewModel("Group 1", "5"));
this.Items.Add(new GalleryItemViewModel("Group 1", "6"));
this.Items.Add(new GalleryItemViewModel("Group 2", "10"));
this.Items.Add(new GalleryItemViewModel("Group 2", "20"));
this.Items.Add(new GalleryItemViewModel("Group 2", "30"));
this.Items.Add(new GalleryItemViewModel("Group 2", "40"));
this.Items.Add(new GalleryItemViewModel("Group 2", "50"));
this.Items.Add(new GalleryItemViewModel("Group 2", "60"));
}
}
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Fluent.Ribbon or "Fluent Ribbon Control Suite"
=============

[![Join the chat at https://gitter.im/fluentribbon/Fluent.Ribbon](https://img.shields.io/badge/GITTER-join%20chat-green.svg?style=flat-square)](https://gitter.im/fluentribbon/Fluent.Ribbon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Twitter](https://img.shields.io/badge/twitter-%40batzendev-blue.svg?style=flat-square)](https://twitter.com/batzendev)

[![Build status](https://img.shields.io/appveyor/ci/batzen/fluent-ribbon.svg?style=flat-square)](https://ci.appveyor.com/project/batzen/fluent-ribbon)
[![Release](https://img.shields.io/github/release/fluentribbon/fluent.ribbon.svg?style=flat-square)](https://github.com/fluentribbon/Fluent.Ribbon/releases/latest)
[![Issues](https://img.shields.io/github/issues/fluentribbon/fluent.ribbon.svg?style=flat-square)](https://github.com/fluentribbon/Fluent.Ribbon/issues)
Expand Down
4 changes: 2 additions & 2 deletions Shared/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("3.5.1.0")]
[assembly: AssemblyFileVersion("3.5.1.0")]
[assembly: AssemblyVersion("3.6.0.0")]
[assembly: AssemblyFileVersion("3.6.0.0")]
[assembly: AssemblyInformationalVersion("SRC")]

[assembly: ComVisible(false)]
Expand Down
11 changes: 9 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# http://www.appveyor.com/docs/appveyor-yml

version: 3.5.1.{build}
version: 3.6.0.{build}
configuration: Release

# Install scripts. (runs after repo cloning)
Expand All @@ -25,4 +25,11 @@ assembly_info:
artifacts:
- path: build/bin
name: Fluent.Ribbon.$(appveyor_build_version)
type: zip
type: zip

notifications:
- provider: Webhook
url: https://webhooks.gitter.im/e/855da764a995f5aa1a24
on_build_success: true
on_build_failure: true
on_build_status_changed: false