-
Notifications
You must be signed in to change notification settings - Fork 0
/
ComboBoxDropDownHelper.cs
81 lines (77 loc) · 3.06 KB
/
ComboBoxDropDownHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright (c) Rishikeshan Sulochana/Lavakumar 2024
* As a special exception, this file is (at your option)
* also under the MIT license, regardless of the other
* files' license.
*
* Why is this code here?
* This is an extension helper for making a ComboBox Drop
* Down.
*
* Tested and is working on WinForms/WPF. Should work on
* GTK# too. Please load the appropriate Eto.Platform
* assemblies referenced in this file before compiling,
* even though your program might not care about them.
* *
* */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Eto.Forms;
using System.Windows.Forms;
using System.Windows;
namespace Eto.Forms
{
public static partial class ComboBoxExtensions
{
public static void LaunchDropDown(this ComboBox C) {
//Eto.Forms.MessageBox.Show($"{Eto.Platform.Detect}, {Eto.Platform.Get(Eto.Platforms.WinForms)}");
var P = Eto.Platform.Instance.ToString();
if (P == Eto.Platform.Get(Eto.Platforms.WinForms).ToString()) {
System.Windows.Forms.ComboBox N = (System.Windows.Forms.ComboBox)Eto.Forms.WinFormsHelpers.ToNative(C);
N.DroppedDown = true;
}
else if (P == Eto.Platform.Get(Eto.Platforms.Wpf).ToString())
{
System.Windows.Controls.ComboBox N = (System.Windows.Controls.ComboBox)Eto.Forms.WpfHelpers.ToNative(C);
N.IsDropDownOpen = true;
}
else if (P == Eto.Platform.Get(Eto.Platforms.Gtk).ToString())
{
Gtk.ComboBox N = (Gtk.ComboBox)Eto.Forms.Gtk3Helpers.ToNative(C);
N.Popdown();
}
else if (P == Eto.Platform.Get(Eto.Platforms.Mac64).ToString())
{
//Implement mac
}
}
public static void UnlaunchDropDown(this ComboBox C)
{
//Eto.Forms.MessageBox.Show($"{Eto.Platform.Detect}, {Eto.Platform.Get(Eto.Platforms.WinForms)}");
var P = Eto.Platform.Instance.ToString();
if (P == Eto.Platform.Get(Eto.Platforms.WinForms).ToString())
{
System.Windows.Forms.ComboBox N = (System.Windows.Forms.ComboBox)Eto.Forms.WinFormsHelpers.ToNative(C);
N.DroppedDown = false;
}
else if (P == Eto.Platform.Get(Eto.Platforms.Wpf).ToString())
{
System.Windows.Controls.ComboBox N = (System.Windows.Controls.ComboBox)Eto.Forms.WpfHelpers.ToNative(C);
N.IsDropDownOpen = false;
}
else if (P == Eto.Platform.Get(Eto.Platforms.Gtk).ToString())
{
Gtk.ComboBox N = (Gtk.ComboBox)Eto.Forms.Gtk3Helpers.ToNative(C);
N.Popdown();
}
else if (P == Eto.Platform.Get(Eto.Platforms.Mac64).ToString())
{
//Implement mac
}
}
}
}