Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Ewing <lewing@microsoft.com>2018-07-14 05:48:36 +0300
committerLarry Ewing <lewing@microsoft.com>2018-07-16 22:05:49 +0300
commitdccfe8d8808a21f5af393f5c165ff31bdbc502d1 (patch)
tree5d10748c229e8ef67ac5bd26ae01ee0fe16035f3 /Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs
parent4fae4441c00171a4ddecf9045d383e8732a83790 (diff)
Draw icons if the image is set
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs56
1 files changed, 54 insertions, 2 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs
index 2bc17f3..39deb43 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs
@@ -3,7 +3,59 @@ using CoreGraphics;
namespace Xamarin.PropertyEditing.Mac
{
- internal class UnderlinedTextField : NSTextField
+
+ internal interface ISelectable {
+ bool Selected { get; set; }
+ }
+
+ internal class UnderlinedImageView : NSImageView, ISelectable
+ {
+ public UnderlinedImageView (string name)
+ {
+ this.name = name;
+ }
+
+ private string name;
+
+ private bool selected;
+ public bool Selected
+ {
+ get => selected;
+ set {
+ //if (selected == value)
+ // return;
+ selected = value;
+
+ var version = PropertyEditorPanel.ThemeManager.Theme == Themes.PropertyEditorTheme.Dark ? $"{name}~dark" : name;
+ Image = NSImage.ImageNamed (selected ? $"{version}~sel" : version);
+
+ //Enabled = value;
+ NeedsDisplay = true;
+ }
+ }
+
+ public override void DrawRect (CGRect dirtyRect)
+ {
+ base.DrawRect (dirtyRect);
+ if (!Selected)
+ return;
+
+ NSBezierPath path = new NSBezierPath ();
+ path.AppendPathWithRect (new CGRect (Bounds.X + 1, Bounds.Top + 3, Bounds.Width - 2, 3));
+ (selected? NSColor.Text: NSColor.DisabledControlText).Set ();
+ path.Fill ();
+ }
+
+ public override CGSize IntrinsicContentSize
+ {
+ get {
+ var size = base.IntrinsicContentSize;
+ return new CGSize (size.Width + 2, size.Height + 12);
+ }
+ }
+ }
+
+ internal class UnderlinedTextField : NSTextField, ISelectable
{
public UnderlinedTextField ()
{
@@ -22,7 +74,7 @@ namespace Xamarin.PropertyEditing.Mac
// return;
selected = value;
TextColor = selected ? NSColor.Text : NSColor.DisabledControlText;
-
+
//Enabled = value;
NeedsDisplay = true;
}