From 48dd3c0fd1d016bab69159101f9cc81a9aa743b1 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 7 Feb 2011 20:36:43 +0100 Subject: [PATCH] Code cleanup. --- ILSpy/AboutPage.cs | 1 - .../{ => Controls}/SortableGridViewColumn.cs | 2 +- ILSpy/CueBannerService.cs | 198 ------------------ ILSpy/ILSpy.csproj | 3 +- ILSpy/MainWindow.xaml.cs | 1 + ILSpy/OpenFromGacDialog.xaml | 14 +- ILSpy/OpenFromGacDialog.xaml.cs | 6 +- ILSpy/themes/generic.xaml | 10 +- 8 files changed, 17 insertions(+), 218 deletions(-) rename ILSpy/{ => Controls}/SortableGridViewColumn.cs (99%) delete mode 100644 ILSpy/CueBannerService.cs diff --git a/ILSpy/AboutPage.cs b/ILSpy/AboutPage.cs index f4377c252..2beb025eb 100644 --- a/ILSpy/AboutPage.cs +++ b/ILSpy/AboutPage.cs @@ -137,7 +137,6 @@ namespace ICSharpCode.ILSpy var bands = doc.Root.Elements("band"); var currentBand = bands.FirstOrDefault(b => (string)b.Attribute("id") == "stable") ?? bands.First(); Version version = new Version((string)currentBand.Element("latestVersion")); - version = new Version(1,0,0,0); string url = (string)currentBand.Element("downloadUrl"); if (!(url.StartsWith("http://", StringComparison.Ordinal) || url.StartsWith("https://", StringComparison.Ordinal))) url = null; // don't accept non-urls diff --git a/ILSpy/SortableGridViewColumn.cs b/ILSpy/Controls/SortableGridViewColumn.cs similarity index 99% rename from ILSpy/SortableGridViewColumn.cs rename to ILSpy/Controls/SortableGridViewColumn.cs index 92369c81d..49dd45d60 100644 --- a/ILSpy/SortableGridViewColumn.cs +++ b/ILSpy/Controls/SortableGridViewColumn.cs @@ -22,7 +22,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Data; -namespace ICSharpCode.ILSpy +namespace ICSharpCode.ILSpy.Controls { /// /// Allows to automatically sort a grid view. diff --git a/ILSpy/CueBannerService.cs b/ILSpy/CueBannerService.cs deleted file mode 100644 index e9d3919c5..000000000 --- a/ILSpy/CueBannerService.cs +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (c) 2008 Jason Kemp -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Documents; -using System.Windows.Media; - -namespace ICSharpCode.ILSpy -{ - /// - /// Watermark for text boxes; from http://www.ageektrapped.com/blog/the-missing-net-4-cue-banner-in-wpf-i-mean-watermark-in-wpf/. - /// - public static class CueBannerService - { - //there is absolutely no way to write this statement out - //to look pretty - public static readonly DependencyProperty CueBannerProperty = DependencyProperty.RegisterAttached( - "CueBanner", typeof (object), typeof (CueBannerService), - new FrameworkPropertyMetadata("", CueBannerPropertyChanged)); - - public static object GetCueBanner(Control control) - { - return control.GetValue(CueBannerProperty); - } - - public static void SetCueBanner(Control control, object value) - { - control.SetValue(CueBannerProperty, value); - } - - private static void CueBannerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - Control control = (Control)d; - control.Loaded += control_Loaded; - if (d is ComboBox || d is TextBox) - { - control.GotFocus += control_GotFocus; - control.LostFocus += control_Loaded; - } - if (d is ItemsControl && !(d is ComboBox)) - { - ItemsControl i = (ItemsControl) d; - //for Items property - i.ItemContainerGenerator.ItemsChanged += ItemsChanged; - itemsControls.Add(i.ItemContainerGenerator, i); - //for ItemsSource property - DependencyPropertyDescriptor prop = - DependencyPropertyDescriptor.FromProperty(ItemsControl.ItemsSourceProperty, i.GetType()); - prop.AddValueChanged(i, ItemsSourceChanged); - } - } - - private static readonly Dictionary itemsControls = new Dictionary(); - private static void ItemsSourceChanged(object sender, EventArgs e) - { - ItemsControl c = (ItemsControl)sender; - if (c.ItemsSource != null) - RemoveCueBanner(c); - else - ShowCueBanner(c); - } - - private static void ItemsChanged(object sender, ItemsChangedEventArgs e) - { - ItemsControl control; - if (itemsControls.TryGetValue(sender, out control)) - { - if (e.ItemCount > 0) - RemoveCueBanner(control); - else - ShowCueBanner(control); - } - } - - private static void control_GotFocus(object sender, RoutedEventArgs e) - { - Control c = (Control)sender; - if (ShouldShowCueBanner(c)) - { - RemoveCueBanner(c); - } - } - - private static void control_Loaded(object sender, RoutedEventArgs e) - { - Control control = (Control)sender; - if (ShouldShowCueBanner(control)) - { - ShowCueBanner(control); - } - } - - private static void RemoveCueBanner(UIElement control) - { - AdornerLayer layer = AdornerLayer.GetAdornerLayer(control); - - Adorner[] adorners = layer.GetAdorners(control); - if (adorners == null) return; - foreach (Adorner adorner in adorners) - { - if (adorner is CueBannerAdorner) - { - adorner.Visibility = Visibility.Hidden; - layer.Remove(adorner); - } - } - } - - private static void ShowCueBanner(Control control) - { - AdornerLayer layer = AdornerLayer.GetAdornerLayer(control); - layer.Add(new CueBannerAdorner(control, GetCueBanner(control))); - } - - private static bool ShouldShowCueBanner(Control c) - { - DependencyProperty dp = GetDependencyProperty(c); - if (dp == null) return true; - return c.GetValue(dp).Equals(""); - } - - private static DependencyProperty GetDependencyProperty (Control control) - { - if (control is ComboBox) - return ComboBox.TextProperty; - if (control is TextBoxBase) - return TextBox.TextProperty; - return null; - } - } - - internal class CueBannerAdorner : Adorner - { - private readonly ContentPresenter contentPresenter; - - public CueBannerAdorner(UIElement adornedElement, object cueBanner) : - base(adornedElement) - { - this.IsHitTestVisible = false; - - contentPresenter = new ContentPresenter(); - contentPresenter.Content = cueBanner; - contentPresenter.Opacity = 0.7; - contentPresenter.Margin = - new Thickness(Control.Margin.Left + Control.Padding.Left, - Control.Margin.Top + Control.Padding.Top, 0, 0); - } - - private Control Control - { - get { return (Control) this.AdornedElement; } - } - - protected override Visual GetVisualChild(int index) - { - return contentPresenter; - } - - protected override int VisualChildrenCount - { - get { return 1; } - } - - protected override Size MeasureOverride(Size constraint) - { - contentPresenter.Measure(Control.RenderSize); - return Control.RenderSize; - } - - protected override Size ArrangeOverride(Size finalSize) - { - contentPresenter.Arrange(new Rect(finalSize)); - return finalSize; - } - } -} diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 6824de2a2..61843f00b 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -80,8 +80,8 @@ + - @@ -116,7 +116,6 @@ MainWindow.xaml - diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index f6ebba249..4e3a0faf8 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -26,6 +26,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; + using ICSharpCode.Decompiler; using ICSharpCode.Decompiler.FlowAnalysis; using ICSharpCode.ILSpy.TreeNodes; diff --git a/ILSpy/OpenFromGacDialog.xaml b/ILSpy/OpenFromGacDialog.xaml index f9aba3c31..f7014f6b3 100644 --- a/ILSpy/OpenFromGacDialog.xaml +++ b/ILSpy/OpenFromGacDialog.xaml @@ -1,6 +1,6 @@  _Search: - + - - - - - + + + + + diff --git a/ILSpy/OpenFromGacDialog.xaml.cs b/ILSpy/OpenFromGacDialog.xaml.cs index ac11c2e8e..3cc9eee94 100644 --- a/ILSpy/OpenFromGacDialog.xaml.cs +++ b/ILSpy/OpenFromGacDialog.xaml.cs @@ -25,11 +25,9 @@ using System.Text; using System.Threading; 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.Threading; + +using ICSharpCode.ILSpy.Controls; using Mono.Cecil; namespace ICSharpCode.ILSpy diff --git a/ILSpy/themes/generic.xaml b/ILSpy/themes/generic.xaml index 929fdc463..7d6202224 100644 --- a/ILSpy/themes/generic.xaml +++ b/ILSpy/themes/generic.xaml @@ -1,22 +1,22 @@  - + - +