-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
307 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
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.Media; | ||
using System.Windows.Media.Imaging; | ||
|
||
namespace EmptyKeys.UserInterface.Designer | ||
{ | ||
/// <summary> | ||
/// Implements button with image | ||
/// </summary> | ||
public class ImageButton : Button | ||
{ | ||
private static readonly Type typeOfThis = typeof(ImageButton); | ||
private static DependencyObjectType dependencyType; | ||
|
||
/// <summary> | ||
/// The image normal property | ||
/// </summary> | ||
public static readonly DependencyProperty ImageNormalProperty = | ||
DependencyProperty.Register("ImageNormal", typeof(BitmapImage), typeOfThis, | ||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsMeasure)); | ||
|
||
/// <summary> | ||
/// Gets or sets the image normal. | ||
/// </summary> | ||
/// <value> | ||
/// The image normal. | ||
/// </value> | ||
public BitmapImage ImageNormal | ||
{ | ||
get { return (BitmapImage)GetValue(ImageNormalProperty); } | ||
set { SetValue(ImageNormalProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// The image pressed property | ||
/// </summary> | ||
public static readonly DependencyProperty ImagePressedProperty = | ||
DependencyProperty.Register("ImagePressed", typeof(BitmapImage), typeOfThis, | ||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsMeasure)); | ||
|
||
/// <summary> | ||
/// Gets or sets the image pressed. | ||
/// </summary> | ||
/// <value> | ||
/// The image pressed. | ||
/// </value> | ||
public BitmapImage ImagePressed | ||
{ | ||
get { return (BitmapImage)GetValue(ImagePressedProperty); } | ||
set { SetValue(ImagePressedProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// The image hover property | ||
/// </summary> | ||
public static readonly DependencyProperty ImageHoverProperty = | ||
DependencyProperty.Register("ImageHover", typeof(BitmapImage), typeOfThis, | ||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsMeasure)); | ||
|
||
/// <summary> | ||
/// Gets or sets the image hover. | ||
/// </summary> | ||
/// <value> | ||
/// The image hover. | ||
/// </value> | ||
public BitmapImage ImageHover | ||
{ | ||
get { return (BitmapImage)GetValue(ImageHoverProperty); } | ||
set { SetValue(ImageHoverProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// The image disabled property | ||
/// </summary> | ||
public static readonly DependencyProperty ImageDisabledProperty = | ||
DependencyProperty.Register("ImageDisabled", typeof(BitmapImage), typeOfThis, | ||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsMeasure)); | ||
|
||
/// <summary> | ||
/// Gets or sets the image disabled. | ||
/// </summary> | ||
/// <value> | ||
/// The image disabled. | ||
/// </value> | ||
public BitmapImage ImageDisabled | ||
{ | ||
get { return (BitmapImage)GetValue(ImageDisabledProperty); } | ||
set { SetValue(ImageDisabledProperty, value); } | ||
} | ||
|
||
/* | ||
/// <summary> | ||
/// The image focused property | ||
/// </summary> | ||
public static readonly DependencyProperty ImageFocusedProperty = | ||
DependencyProperty.Register("ImageFocused", typeof(BitmapImage), typeOfThis, | ||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsMeasure)); | ||
/// <summary> | ||
/// Gets or sets the image focused. | ||
/// </summary> | ||
/// <value> | ||
/// The image focused. | ||
/// </value> | ||
public BitmapImage ImageFocused | ||
{ | ||
get { return (BitmapImage)GetValue(ImageFocusedProperty); } | ||
set { SetValue(ImageFocusedProperty, value); } | ||
} | ||
*/ | ||
|
||
/// <summary> | ||
/// The image stretch property | ||
/// </summary> | ||
public static readonly DependencyProperty ImageStretchProperty = | ||
DependencyProperty.Register("ImageStretch", typeof(Stretch), typeOfThis, | ||
new FrameworkPropertyMetadata(Stretch.Uniform, FrameworkPropertyMetadataOptions.AffectsMeasure)); | ||
|
||
/// <summary> | ||
/// Gets or sets the image stretch. | ||
/// </summary> | ||
/// <value> | ||
/// The image stretch. | ||
/// </value> | ||
public Stretch ImageStretch | ||
{ | ||
get { return (Stretch)GetValue(ImageStretchProperty); } | ||
set { SetValue(ImageStretchProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the <see cref="ImageButton"/> class. | ||
/// </summary> | ||
static ImageButton() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ImageButton"/> class. | ||
/// </summary> | ||
public ImageButton() | ||
: base() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.CodeDom; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using EmptyKeys.UserInterface.Designer; | ||
|
||
namespace EmptyKeys.UserInterface.Generator.Types.Controls | ||
{ | ||
/// <summary> | ||
/// Implements Image Button generator | ||
/// </summary> | ||
/// <seealso cref="EmptyKeys.UserInterface.Generator.Types.ButtonGeneratorType" /> | ||
public class ImageButtonGeneratorType : ButtonGeneratorType | ||
{ | ||
/// <summary> | ||
/// Gets the type of the xaml. | ||
/// </summary> | ||
/// <value> | ||
/// The type of the xaml. | ||
/// </value> | ||
public override Type XamlType | ||
{ | ||
get | ||
{ | ||
return typeof(ImageButton); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Generates code | ||
/// </summary> | ||
/// <param name="source">The dependence object</param> | ||
/// <param name="classType">Type of the class.</param> | ||
/// <param name="initMethod">The initialize method.</param> | ||
/// <param name="generateField"></param> | ||
/// <returns></returns> | ||
public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) | ||
{ | ||
CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); | ||
CodeComHelper.GenerateEnumField<Stretch>(initMethod, fieldReference, source, ImageButton.ImageStretchProperty); | ||
|
||
ImageButton imageButton = source as ImageButton; | ||
BitmapImage bitmap = imageButton.ImageNormal as BitmapImage; | ||
if (bitmap != null) | ||
{ | ||
CodeComHelper.GenerateBitmapImageField(initMethod, fieldReference, source, bitmap.UriSource, imageButton.Name + "_normal_bm", ImageButton.ImageNormalProperty); | ||
} | ||
|
||
bitmap = imageButton.ImageDisabled as BitmapImage; | ||
if (bitmap != null) | ||
{ | ||
CodeComHelper.GenerateBitmapImageField(initMethod, fieldReference, source, bitmap.UriSource, imageButton.Name + "_disabled_bm", ImageButton.ImageDisabledProperty); | ||
} | ||
|
||
bitmap = imageButton.ImageHover as BitmapImage; | ||
if (bitmap != null) | ||
{ | ||
CodeComHelper.GenerateBitmapImageField(initMethod, fieldReference, source, bitmap.UriSource, imageButton.Name + "_hover_bm", ImageButton.ImageHoverProperty); | ||
} | ||
|
||
bitmap = imageButton.ImagePressed as BitmapImage; | ||
if (bitmap != null) | ||
{ | ||
CodeComHelper.GenerateBitmapImageField(initMethod, fieldReference, source, bitmap.UriSource, imageButton.Name + "_pressed_bm", ImageButton.ImagePressedProperty); | ||
} | ||
|
||
return fieldReference; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.