Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

.NET Core 3 support #195

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions 1.0/FirstFloor.ModernUI/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[*]
indent_size = 4
end_of_line = crlf

[*.xml]
indent_style = space
54 changes: 27 additions & 27 deletions 1.0/FirstFloor.ModernUI/FirstFloor.ModernUI.App/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
using FirstFloor.ModernUI.Presentation;
using FirstFloor.ModernUI.Windows.Controls;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace FirstFloor.ModernUI.App
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
/// <summary>
/// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
/// </summary>
/// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
}
}
}
using FirstFloor.ModernUI.Presentation;
using FirstFloor.ModernUI.Windows.Controls;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace FirstFloor.ModernUI.App
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
/// <summary>
/// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
/// </summary>
/// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
}
}
}
162 changes: 81 additions & 81 deletions 1.0/FirstFloor.ModernUI/FirstFloor.ModernUI.App/BingImage.cs
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml.Linq;
using System.Xml.XPath;
namespace FirstFloor.ModernUI.App
{
/// <summary>
/// Provides an attached property determining the current Bing image and assigning it to an image or imagebrush.
/// </summary>
public static class BingImage
{
public static readonly DependencyProperty UseBingImageProperty = DependencyProperty.RegisterAttached("UseBingImage", typeof(bool), typeof(BingImage), new PropertyMetadata(OnUseBingImageChanged));
private static BitmapImage cachedBingImage;
private static async void OnUseBingImageChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
var newValue = (bool)e.NewValue;
var image = o as Image;
var imageBrush = o as ImageBrush;
if (!newValue || (image == null && imageBrush == null)) {
return;
}
if (cachedBingImage == null) {
var url = await GetCurrentBingImageUrl();
if (url != null) {
cachedBingImage = new BitmapImage(url);
}
}
if (cachedBingImage != null){
if (image != null) {
image.Source = cachedBingImage;
}
else if (imageBrush != null) {
imageBrush.ImageSource = cachedBingImage;
}
}
}
private static async Task<Uri> GetCurrentBingImageUrl()
{
var client = new HttpClient();
var result = await client.GetAsync("http://www.bing.com/hpimagearchive.aspx?format=xml&idx=0&n=2&mbl=1&mkt=en-ww");
if (result.IsSuccessStatusCode) {
using (var stream = await result.Content.ReadAsStreamAsync()) {
var doc = XDocument.Load(stream);
var url = (string)doc.XPathSelectElement("/images/image/url");
return new Uri(string.Format(CultureInfo.InvariantCulture, "http://bing.com{0}", url), UriKind.Absolute);
}
}
return null;
}
public static bool GetUseBingImage(DependencyObject o)
{
return (bool)o.GetValue(UseBingImageProperty);
}
public static void SetUseBingImage(DependencyObject o, bool value)
{
o.SetValue(UseBingImageProperty, value);
}
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml.Linq;
using System.Xml.XPath;

namespace FirstFloor.ModernUI.App
{
/// <summary>
/// Provides an attached property determining the current Bing image and assigning it to an image or imagebrush.
/// </summary>
public static class BingImage
{
public static readonly DependencyProperty UseBingImageProperty = DependencyProperty.RegisterAttached("UseBingImage", typeof(bool), typeof(BingImage), new PropertyMetadata(OnUseBingImageChanged));

private static BitmapImage cachedBingImage;

private static async void OnUseBingImageChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
var newValue = (bool)e.NewValue;
var image = o as Image;
var imageBrush = o as ImageBrush;

if (!newValue || (image == null && imageBrush == null)) {
return;
}

if (cachedBingImage == null) {
var url = await GetCurrentBingImageUrl();
if (url != null) {
cachedBingImage = new BitmapImage(url);
}
}

if (cachedBingImage != null){
if (image != null) {
image.Source = cachedBingImage;
}
else if (imageBrush != null) {
imageBrush.ImageSource = cachedBingImage;
}
}
}

private static async Task<Uri> GetCurrentBingImageUrl()
{
var client = new HttpClient();
var result = await client.GetAsync("http://www.bing.com/hpimagearchive.aspx?format=xml&idx=0&n=2&mbl=1&mkt=en-ww");
if (result.IsSuccessStatusCode) {
using (var stream = await result.Content.ReadAsStreamAsync()) {
var doc = XDocument.Load(stream);

var url = (string)doc.XPathSelectElement("/images/image/url");

return new Uri(string.Format(CultureInfo.InvariantCulture, "http://bing.com{0}", url), UriKind.Absolute);
}
}

return null;
}


public static bool GetUseBingImage(DependencyObject o)
{
return (bool)o.GetValue(UseBingImageProperty);
}

public static void SetUseBingImage(DependencyObject o, bool value)
{
o.SetValue(UseBingImageProperty, value);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
using FirstFloor.ModernUI.Windows.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FirstFloor.ModernUI.App.Content
{
/// <summary>
/// Interaction logic for ContentLoaderImages.xaml
/// </summary>
public partial class ContentLoaderImages : UserControl
{
public ContentLoaderImages()
{
InitializeComponent();
LoadImageLinks();
}
private async void LoadImageLinks()
{
var loader = (FlickrImageLoader)Tab.ContentLoader;
try {
// load image links and assign to tab list
this.Tab.Links = await loader.GetInterestingnessListAsync();
// select first link
this.Tab.SelectedSource = this.Tab.Links.Select(l => l.Source).FirstOrDefault();
}
catch (Exception e) {
ModernDialog.ShowMessage(e.Message, "Failure", MessageBoxButton.OK);
}
}
}
}
using FirstFloor.ModernUI.Windows.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FirstFloor.ModernUI.App.Content
{
/// <summary>
/// Interaction logic for ContentLoaderImages.xaml
/// </summary>
public partial class ContentLoaderImages : UserControl
{
public ContentLoaderImages()
{
InitializeComponent();

LoadImageLinks();
}

private async void LoadImageLinks()
{
var loader = (FlickrImageLoader)Tab.ContentLoader;

try {
// load image links and assign to tab list
this.Tab.Links = await loader.GetInterestingnessListAsync();

// select first link
this.Tab.SelectedSource = this.Tab.Links.Select(l => l.Source).FirstOrDefault();
}
catch (Exception e) {
ModernDialog.ShowMessage(e.Message, "Failure", MessageBoxButton.OK);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FirstFloor.ModernUI.App.Content
{
/// <summary>
/// Interaction logic for ContentLoaderIntro.xaml
/// </summary>
public partial class ContentLoaderIntro : UserControl
{
public ContentLoaderIntro()
{
InitializeComponent();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FirstFloor.ModernUI.App.Content
{
/// <summary>
/// Interaction logic for ContentLoaderIntro.xaml
/// </summary>
public partial class ContentLoaderIntro : UserControl
{
public ContentLoaderIntro()
{
InitializeComponent();
}
}
}
Loading