Skip to content

MainMenu

Summary

Provides plugins access to main menu API.

Signature

1
public abstract interface MainMenu

Namespace

cAlgo.API

Examples

  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
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
 using System;
 using cAlgo.API;
 using System.Linq;
 namespace cAlgo.Plugins;
 [Plugin(AccessRights = AccessRights.None)]
 public class MainMenuTest : Plugin
 {
     private const string FirstItemSvgIconXml = "<svg width=\"800px\" height=\"800px\" viewBox=\"0 0 1024 1024\" class=\"icon\"  version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M819.9 747.6H204.1c-21.8 0-39.5-17.7-39.5-39.5V278.4c0-21.8 17.7-39.5 39.5-39.5h615.7c21.8 0 39.5 17.7 39.5 39.5v429.7c0.1 21.9-17.6 39.5-39.4 39.5z\" fill=\"#FFD632\" /><path d=\"M819.9 753.1H204.1c-24.8 0-45-20.2-45-45V278.4c0-24.8 20.2-45 45-45h615.7c24.8 0 45 20.2 45 45v429.7c0.1 24.9-20.1 45-44.9 45zM204.1 244.4c-18.7 0-34 15.3-34 34v429.7c0 18.7 15.3 34 34 34h615.7c18.7 0 34-15.3 34-34V278.4c0-18.7-15.3-34-34-34H204.1z\" fill=\"#333336\" /><path d=\"M296.5 766.6h58.3v39.9c0 10.1-8.2 18.4-18.4 18.4h-21.6c-10.1 0-18.4-8.2-18.4-18.4v-39.9z\" fill=\"#FFC86B\" /><path d=\"M336.4 830.4h-21.6c-13.2 0-23.9-10.7-23.9-23.9v-45.4h69.3v45.4c0.1 13.2-10.6 23.9-23.8 23.9zM302 772.1v34.4c0 7.1 5.8 12.9 12.9 12.9h21.6c7.1 0 12.9-5.8 12.9-12.9v-34.4H302z\" fill=\"#333336\" /><path d=\"M441 315.3v-62.1c0-29.4-23.9-53.3-53.3-53.3H263.6c-29.4 0-53.3 23.9-53.3 53.3v62.1c0 24.7 7.8 47.6 21 66.4 6.5 9.2 9.9 20.3 9.9 31.5v160.2c0 11.3-3.4 22.3-9.9 31.5-13.2 18.8-21 41.7-21 66.4v63.1c0 28.9 23.4 52.3 52.3 52.3h126.2c28.9 0 52.3-23.4 52.3-52.3v-63.1c0-24.7-7.7-47.5-20.9-66.2-6.5-9.3-10-20.4-10-31.8v-160c0-11.4 3.4-22.5 10-31.8 13-18.8 20.8-41.6 20.8-66.2z\" fill=\"#68A240\" /><path d=\"M388.7 792.1H262.6c-31.8 0-57.8-25.9-57.8-57.8v-63.1c0-25.1 7.6-49.1 22-69.5 5.8-8.2 8.9-18 8.9-28.4V413.2c0-10.3-3.1-20.1-8.9-28.4-14.4-20.4-22-44.5-22-69.5v-62.1c0-32.4 26.4-58.8 58.8-58.8h124.1c32.4 0 58.8 26.4 58.8 58.8v62.1c0 25-7.6 49-21.9 69.4-5.9 8.3-9 18.2-9 28.7v159.9c0 10.4 3.1 20.3 9 28.7 14.3 20.4 21.9 44.4 21.9 69.4v63.1c0 31.7-25.9 57.6-57.8 57.6zM263.6 205.4c-26.3 0-47.8 21.4-47.8 47.8v62.1c0 22.8 6.9 44.6 20 63.2 7.1 10.1 10.9 22.1 10.9 34.7v160.2c0 12.6-3.8 24.6-10.9 34.7-13.1 18.6-20 40.4-20 63.2v63.1c0 25.8 21 46.8 46.8 46.8h126.2c25.8 0 46.8-21 46.8-46.8v-63.1c0-22.7-6.9-44.5-19.9-63.1-7.2-10.2-11-22.3-11-35V413.3c0-12.7 3.8-24.8 11-35 13-18.5 19.9-40.3 19.9-63.1v-62.1c0-26.3-21.4-47.8-47.8-47.8H263.6z\" fill=\"#333336\" /><path d=\"M780.6 437.5H495.4c-8 0-14.5-6.5-14.5-14.5V317.6c0-8 6.5-14.5 14.5-14.5h285.2c8 0 14.5 6.5 14.5 14.5V423c0 8-6.5 14.5-14.5 14.5z\" fill=\"#D8A128\" /><path d=\"M780.6 443H495.4c-11 0-20-9-20-20V317.6c0-11 9-20 20-20h285.2c11 0 20 9 20 20V423c0 11-8.9 20-20 20zM495.4 308.6c-5 0-9 4-9 9V423c0 5 4 9 9 9h285.2c5 0 9-4 9-9V317.6c0-5-4-9-9-9H495.4zM476.9 889.6c-2.1 0-4-1.2-5-3.2-0.8-1.6-19.7-39-79-19.6-23.1 7.5-41.3 6.6-54.3-2.8-18.3-13.2-18.5-38-18.5-39.1 0-3 2.5-5.5 5.5-5.5s5.5 2.5 5.5 5.5c0 0.3 0.3 20.4 14 30.2 10 7.2 24.9 7.6 44.4 1.2 19.6-6.4 48.1-11 71.8 3.8 14.5 9 20.3 21 20.5 21.5 1.3 2.7 0.1 6-2.6 7.3-0.8 0.5-1.6 0.7-2.3 0.7z m-145.7-64.7z\" fill=\"#333336\" /><path d=\"M550 570.9h-57.3c-4.7 0-8.6-3.8-8.6-8.6V505c0-4.7 3.8-8.6 8.6-8.6H550c4.7 0 8.6 3.8 8.6 8.6v57.3c-0.1 4.7-3.9 8.6-8.6 8.6z\" fill=\"#D5D9CF\" /><path d=\"M550 576.4h-57.3c-7.8 0-14.1-6.3-14.1-14.1V505c0-7.8 6.3-14.1 14.1-14.1H550c7.8 0 14.1 6.3 14.1 14.1v57.3c-0.1 7.8-6.4 14.1-14.1 14.1z m-57.3-74.5c-1.7 0-3.1 1.4-3.1 3.1v57.3c0 1.7 1.4 3.1 3.1 3.1H550c1.7 0 3.1-1.4 3.1-3.1V505c0-1.7-1.4-3.1-3.1-3.1h-57.3z\" fill=\"#333336\" /><path d=\"M667.3 570.9H610c-4.7 0-8.6-3.8-8.6-8.6V505c0-4.7 3.8-8.6 8.6-8.6h57.3c4.7 0 8.6 3.8 8.6 8.6v57.3c0 4.7-3.8 8.6-8.6 8.6z\" fill=\"#D5D9CF\" /><path d=\"M667.3 576.4H610c-7.8 0-14.1-6.3-14.1-14.1V505c0-7.8 6.3-14.1 14.1-14.1h57.3c7.8 0 14.1 6.3 14.1 14.1v57.3c0 7.8-6.3 14.1-14.1 14.1zM610 501.9c-1.7 0-3.1 1.4-3.1 3.1v57.3c0 1.7 1.4 3.1 3.1 3.1h57.3c1.7 0 3.1-1.4 3.1-3.1V505c0-1.7-1.4-3.1-3.1-3.1H610z\" fill=\"#333336\" /><path d=\"M784.7 570.9h-57.3c-4.7 0-8.6-3.8-8.6-8.6V505c0-4.7 3.8-8.6 8.6-8.6h57.3c4.7 0 8.6 3.8 8.6 8.6v57.3c0 4.7-3.9 8.6-8.6 8.6z\" fill=\"#D5D9CF\" /><path d=\"M784.7 576.4h-57.3c-7.8 0-14.1-6.3-14.1-14.1V505c0-7.8 6.3-14.1 14.1-14.1h57.3c7.8 0 14.1 6.3 14.1 14.1v57.3c0 7.8-6.3 14.1-14.1 14.1z m-57.3-74.5c-1.7 0-3.1 1.4-3.1 3.1v57.3c0 1.7 1.4 3.1 3.1 3.1h57.3c1.7 0 3.1-1.4 3.1-3.1V505c0-1.7-1.4-3.1-3.1-3.1h-57.3z\" fill=\"#333336\" /><path d=\"M550 691.6h-57.3c-4.7 0-8.6-3.8-8.6-8.6v-57.3c0-4.7 3.8-8.6 8.6-8.6H550c4.7 0 8.6 3.8 8.6 8.6V683c-0.1 4.8-3.9 8.6-8.6 8.6z\" fill=\"#D5D9CF\" /><path d=\"M550 697.1h-57.3c-7.8 0-14.1-6.3-14.1-14.1v-57.3c0-7.8 6.3-14.1 14.1-14.1H550c7.8 0 14.1 6.3 14.1 14.1V683c-0.1 7.8-6.4 14.1-14.1 14.1z m-57.3-74.4c-1.7 0-3.1 1.4-3.1 3.1v57.3c0 1.7 1.4 3.1 3.1 3.1H550c1.7 0 3.1-1.4 3.1-3.1v-57.3c0-1.7-1.4-3.1-3.1-3.1h-57.3z\" fill=\"#333336\" /><path d=\"M667.3 691.6H610c-4.7 0-8.6-3.8-8.6-8.6v-57.3c0-4.7 3.8-8.6 8.6-8.6h57.3c4.7 0 8.6 3.8 8.6 8.6V683c0 4.8-3.8 8.6-8.6 8.6z\" fill=\"#D5D9CF\" /><path d=\"M667.3 697.1H610c-7.8 0-14.1-6.3-14.1-14.1v-57.3c0-7.8 6.3-14.1 14.1-14.1h57.3c7.8 0 14.1 6.3 14.1 14.1V683c0 7.8-6.3 14.1-14.1 14.1zM610 622.7c-1.7 0-3.1 1.4-3.1 3.1v57.3c0 1.7 1.4 3.1 3.1 3.1h57.3c1.7 0 3.1-1.4 3.1-3.1v-57.3c0-1.7-1.4-3.1-3.1-3.1H610z\" fill=\"#333336\" /><path d=\"M784.7 691.6h-57.3c-4.7 0-8.6-3.8-8.6-8.6v-57.3c0-4.7 3.8-8.6 8.6-8.6h57.3c4.7 0 8.6 3.8 8.6 8.6V683c0 4.8-3.9 8.6-8.6 8.6z\" fill=\"#68A240\" /><path d=\"M784.7 697.1h-57.3c-7.8 0-14.1-6.3-14.1-14.1v-57.3c0-7.8 6.3-14.1 14.1-14.1h57.3c7.8 0 14.1 6.3 14.1 14.1V683c0 7.8-6.3 14.1-14.1 14.1z m-57.3-74.4c-1.7 0-3.1 1.4-3.1 3.1v57.3c0 1.7 1.4 3.1 3.1 3.1h57.3c1.7 0 3.1-1.4 3.1-3.1v-57.3c0-1.7-1.4-3.1-3.1-3.1h-57.3z\" fill=\"#333336\" /></svg>";
     private const string SecondItemSvgIconXml = "<svg width=\"800px\" height=\"800px\" viewBox=\"0 0 1024 1024\" class=\"icon\"  version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M0.000976 0.999024h1023.000975v1023.000976H0.000976z\" fill=\"#FFFFFF\" /><path d=\"M844.176585 208.796098l-41.959024-11.988293 41.959024-10.989268 11.988293-42.958049 10.989268 42.958049 42.958049 10.989268-42.958049 11.988293-10.989268 41.959024-11.988293-41.959024zM104.898537 717.299512l-31.968781-6.993171 31.968781-7.992195 7.992195-31.96878 6.99317 31.96878 32.967805 7.992195-32.967805 6.993171-6.99317 32.967805-7.992195-32.967805zM883.138537 261.74439l-14.985366-2.997073 14.985366-3.996097 2.997073-13.986342 2.997073 13.986342 14.985366 3.996097-14.985366 2.997073-2.997073 14.985366-2.997073-14.985366zM109.893659 544.468293l-14.985366-2.997073 14.985366-2.997074 2.997073-14.985366 2.997073 14.985366 14.985366 2.997074-14.985366 2.997073-2.997073 14.985366-2.997073-14.985366z\" fill=\"#FDCD60\" /><path d=\"M114.88878 348.659512m-8.991219 0a8.99122 8.99122 0 1 0 17.982439 0 8.99122 8.99122 0 1 0-17.982439 0Z\" fill=\"#5546CB\" /><path d=\"M910.112195 711.305366a24.97561 24.97561 0 1 1 24.97561-24.97561 24.97561 24.97561 0 0 1-24.97561 24.97561z m0-35.964878a9.990244 9.990244 0 1 1 0 0.999024z\" fill=\"#5546CB\" /><path d=\"M626.389268 469.541463h69.931708v204.650147h-69.931708z\" fill=\"#FDCD60\" /><path d=\"M190.814634 734.282927h644.370732v34.965853H190.814634z\" fill=\"#AFBCF3\" /><path d=\"M855.165854 714.302439H170.834146v74.926829h684.331708z m-19.980488 54.946341H190.814634v-34.965853h644.370732z\" fill=\"#5546CB\" /><path d=\"M150.853659 837.182439h722.294634v34.965854H150.853659z\" fill=\"#AFBCF3\" /><path d=\"M127.876098 817.201951v74.926829h767.250731v-74.926829z m745.272195 54.946342H150.853659v-34.965854h722.294634z\" fill=\"#5546CB\" /><path d=\"M487.524878 483.527805h49.95122v182.821463h-49.95122z\" fill=\"#FDCD60\" /><path d=\"M467.54439 686.329756h89.912195V463.547317h-89.912195z m19.980488-202.801951h49.95122v182.821463h-49.95122z\" fill=\"#5546CB\" /><path d=\"M339.669268 483.527805h49.95122v182.821463h-49.95122z\" fill=\"#FDCD60\" /><path d=\"M319.68878 686.329756h89.912196V463.547317h-89.912196z m19.980488-202.801951h49.95122v182.821463h-49.95122z\" fill=\"#5546CB\" /><path d=\"M190.814634 373.635122h49.95122v40.96h-49.95122z\" fill=\"#FF8859\" /><path d=\"M260.746341 353.654634h-89.912195v80.920976h89.912195z m-19.980487 60.940488h-49.95122v-40.96h49.95122z\" fill=\"#5546CB\" /><path d=\"M784.235122 373.635122h49.951219v40.96h-49.951219z\" fill=\"#FF8859\" /><path d=\"M854.166829 353.654634h-89.912195v80.920976h89.912195z m-19.980488 60.940488h-49.951219v-40.96h49.951219z\" fill=\"#5546CB\" /><path d=\"M636.379512 373.635122h49.95122v40.96h-49.95122z\" fill=\"#FF8859\" /><path d=\"M706.31122 353.654634h-89.912196v80.920976h89.912196z m-19.980488 60.940488h-49.95122v-40.96h49.95122z\" fill=\"#5546CB\" /><path d=\"M487.524878 373.635122h49.95122v40.96h-49.95122z\" fill=\"#FF8859\" /><path d=\"M557.456585 353.654634h-89.912195v80.920976h89.912195z m-19.980487 60.940488h-49.95122v-40.96h49.95122z\" fill=\"#5546CB\" /><path d=\"M339.669268 373.635122h49.95122v40.96h-49.95122z\" fill=\"#FF8859\" /><path d=\"M409.600976 353.654634h-89.912196v80.920976h89.912196z m-19.980488 60.940488h-49.95122v-40.96h49.95122z\" fill=\"#5546CB\" /><path d=\"M515.497561 140.862439L241.764878 305.701463h542.470244L515.497561 140.862439z\" fill=\"#FDCD60\" /><path d=\"M515.497561 116.885854L170.834146 325.681951h683.332683z m0 23.976585l268.737561 164.839024H241.764878zM615.4 688.327805h89.912195V465.545366h-89.912195z m19.980488-202.801951h49.951219v182.821463h-49.951219z\" fill=\"#5546CB\" /><path d=\"M783.236098 485.525854h49.951219v182.821463h-49.951219z\" fill=\"#FDCD60\" /><path d=\"M763.25561 688.327805h89.912195V465.545366h-89.912195z m19.980488-202.801951h49.951219v182.821463h-49.951219z\" fill=\"#5546CB\" /><path d=\"M189.81561 666.349268h49.951219V481.529756h-48.952195l-0.999024 184.819512z\" fill=\"#FDCD60\" /><path d=\"M260.746341 461.549268h-89.912195v224.780488h88.913171z m-20.979512 204.8h-49.951219V481.529756h48.952195z\" fill=\"#5546CB\" /></svg>";
     private const string BottomItemSvgIconXml = "<svg width=\"800px\" height=\"800px\" viewBox=\"0 0 1024 1024\" class=\"icon\"  version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M819 234l-48-13 48-13 13-48 13 48 48 13-48 13-13 48-13-48zM867 287l-19-5 19-4 4-19 4 19 19 4-19 5-4 19-4-19z\" fill=\"#FDCD60\" /><path d=\"M130 472l-21-5 21-5 5-21 5 21 21 5-21 5-5 20-5-20z\" fill=\"#FDCD60\" /><path d=\"M208 246m-9 0a9 9 0 1 0 18 0 9 9 0 1 0-18 0Z\" fill=\"#5546CB\" /><path d=\"M824 804a25 25 0 1 1 25-25 25 25 0 0 1-25 25z m0-36a10 10 0 1 0 10 10 10 10 0 0 0-10-9z\" fill=\"#5546CB\" /><path d=\"M166 728h78v77.34h-78z\" fill=\"#FDCD60\" /><path d=\"M452 509v43h128v-43a19 19 0 0 1 14-18H438a19 19 0 0 1 14 18z\" fill=\"#F97744\" /><path d=\"M661 489h1a19 19 0 0 1 19 19v43h32v114a74 74 0 0 1-74 74H387a73 73 0 0 1-73-73V552h38v-43a19 19 0 0 1 19-19h1a116 116 0 0 1-83-50v337a31 31 0 0 0 31 31h386a31 31 0 0 0 31-31V440a116 116 0 0 1-76 49z\" fill=\"#F97744\" /><path d=\"M334 666a53 53 0 0 0 53 53h251a54 54 0 0 0 54-54v-93h-32a30 30 0 0 1-30 25 30 30 0 0 1-30-25H432a30 30 0 0 1-30 25 30 30 0 0 1-30-25h-38z\" fill=\"#FFFFFF\" /><path d=\"M580 553H452a19 19 0 0 1-19 19h166a19 19 0 0 1-19-19z\" fill=\"#5546CB\" /><path d=\"M662 572h30v93a54 54 0 0 1-54 54H387a53 53 0 0 1-53-53v-94h37a19 19 0 0 1-19-19h-38v113a73 73 0 0 0 73 73h251a74 74 0 0 0 74-74V552h-32a19 19 0 0 1-18 20z\" fill=\"#5546CB\" /><path d=\"M289 375a96 96 0 0 0 83 95v-70a30 30 0 0 1 30-30 30 30 0 0 1 30 30v71h168v-71a30 30 0 0 1 30-30 30 30 0 0 1 30 30v69a96 96 0 0 0 76-94V266a31 31 0 0 0-31-31H320a31 31 0 0 0-31 31v109z\" fill=\"#FDCD60\" /><path d=\"M402 597a30 30 0 0 0 30-25h-59a30 30 0 0 0 29 25zM372 510h60v41.48h-60zM630 597a30 30 0 0 0 30-25h-59a30 30 0 0 0 29 25zM600 510h60v41.48h-60z\" fill=\"#5546CB\" /><path d=\"M438 491h-67a19 19 0 0 0-19 19v43a19 19 0 0 0 19 19h63a19 19 0 0 0 19-19v-44a19 19 0 0 0-15-18z m-6 61h-60v-42h60zM662 490h-67a19 19 0 0 0-14 18v43a19 19 0 0 0 19 19h63a19 19 0 0 0 19-19v-42a19 19 0 0 0-20-19z m-1 61h-61v-41h60z\" fill=\"#FDCD60\" /><path d=\"M786 524h-29v148h29a24 24 0 0 0 24-24V548a24 24 0 0 0-24-24z\" fill=\"#AFBCF3\" /><path d=\"M786 504h-29V266a51 51 0 0 0-51-51h-78a116 116 0 0 0-230 0h-78a51 51 0 0 0-51 51v240l-8-2h-30a44 44 0 0 0-44 44v100a44 44 0 0 0 44 44h30l8-2v87a51 51 0 0 0 51 51h386a51 51 0 0 0 51-51v-85h29a44 44 0 0 0 44-44V548a44 44 0 0 0-44-44zM260 672h-29a24 24 0 0 1-24-24V548a24 24 0 0 1 24-24h29z m253-536a96 96 0 0 1 95 79H418a96 96 0 0 1 95-79zM289 266a31 31 0 0 1 31-31h386a31 31 0 0 1 31 31v109a96 96 0 0 1-76 94v-69a30 30 0 0 0-30-30 30 30 0 0 0-30 30v71H432v-71a30 30 0 0 0-30-30 30 30 0 0 0-30 30v70a96 96 0 0 1-83-95V266z m417 542H320a31 31 0 0 1-31-31V440a116 116 0 0 0 83 50h289a116 116 0 0 0 76-49v336a31 31 0 0 1-31 31z m104-160a24 24 0 0 1-24 24h-29V524h29a24 24 0 0 1 24 24z\" fill=\"#5546CB\" /><path d=\"M208 548v100a24 24 0 0 0 24 24h29V524h-30a24 24 0 0 0-23 24z\" fill=\"#AFBCF3\" /></svg>";
     private MainMenuOwnCustomItem _firstItem;
     private MainMenuOwnCustomItem _secondItem;
     private MainMenuBottomCustomItem _bottomItem;
     protected override void OnStart()
     {
         var panel = new StackPanel { Orientation = Orientation.Vertical };
         var changeSelectedItemToBuiltInItemButton = new Button { Text = "Change Selected Item to Built In Item" };
         changeSelectedItemToBuiltInItemButton.Click += args =>
         {
             MainMenu.TryChangeSelectedItem(MainMenu.BuiltInItems[Random.Shared.Next(0, MainMenu.BuiltInItems.Count)]);
         };
         panel.AddChild(changeSelectedItemToBuiltInItemButton);
         var changeSelectedItemToCustomnItemButton = new Button { Text = "Change Selected Item to Custom Item" };
         changeSelectedItemToCustomnItemButton.Click += args =>
         {
             MainMenu.TryChangeSelectedItem(_secondItem is null ? _firstItem : MainMenu.SelectedItem == _firstItem ? _secondItem : _firstItem);
         };
         panel.AddChild(changeSelectedItemToCustomnItemButton);
         var showSelectedItemButton = new Button { Text = "Show Selected Item" };
         showSelectedItemButton.Click += args =>
         {
             Print($"Selected Item: {(MainMenu.SelectedItem is MainMenuBuiltInItem menuBuiltInItem ? menuBuiltInItem.Type : MainMenu.SelectedItem is MainMenuCustomItem mainMenuCustomItem ? mainMenuCustomItem.Name : MainMenu.SelectedItem)}");
         };
         panel.AddChild(showSelectedItemButton);
         var showBuiltInItemsButton = new Button { Text = "Show Built-in Items" };
         showBuiltInItemsButton.Click += args =>
         {
             Print($"Built-in Items count: {MainMenu.BuiltInItems.Count}");
             Print($"Built-in Items: {string.Join(", ", MainMenu.BuiltInItems.Select(i => i.Type.ToString()))}");
         };
         panel.AddChild(showBuiltInItemsButton);
         var addItemButton = new Button { Text = "Add Item" };
         addItemButton.Click += args =>
         {
             if (_firstItem is null)
             {
                 _firstItem = MainMenu.AddItem("Test", new SvgIcon(FirstItemSvgIconXml));
                 var webView = new WebView();
                 webView.Loaded += args =>
                 {
                     webView.NavigateAsync("https://help.ctrader.com/");
                 };
                 _firstItem.Child = webView;
             }
             else
             {
                 _secondItem = MainMenu.AddItem("Test 2", new SvgIcon(SecondItemSvgIconXml));
                 var panel = new StackPanel { Orientation = Orientation.Vertical, BackgroundColor = Color.Red };
                 var panelButton = new Button { Text = "Trade", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, FontWeight = FontWeight.UltraBold };
                 panelButton.Click += _ =>
                 {
                     var symbol = Symbols.GetSymbol("EURUSD");
                     ExecuteMarketOrder(TradeType.Buy, symbol.Name, symbol.VolumeInUnitsMin);
                 };
                 panel.AddChild(panelButton);
                 _secondItem.Child = panel;
             }
         };
         panel.AddChild(addItemButton);
         var removeItemButton = new Button { Text = "Remove Item" };
         removeItemButton.Click += args =>
         {
             if (_firstItem is not null)
             {
                 Print($"Remove Result: {MainMenu.RemoveItem(_firstItem)}");
                 _firstItem = null;
                 return;
             }
             if (_secondItem is not null)
             {
                 Print($"Remove Result: {MainMenu.RemoveItem(_secondItem)}");
                 _secondItem = null;
             }
         };
         panel.AddChild(removeItemButton);
         var showIsExpandedButton = new Button { Text = "Show Is Expanded" };
         showIsExpandedButton.Click += args =>
         {
             Print($"IsExpanded: {MainMenu.IsExpanded}");
         };
         panel.AddChild(showIsExpandedButton);
         var changeIsExpandedButton = new Button { Text = "Change Is Expanded" };
         changeIsExpandedButton.Click += args =>
         {
             MainMenu.IsExpanded = !MainMenu.IsExpanded;
             Print($"IsExpanded: {MainMenu.IsExpanded}");
         };
         panel.AddChild(changeIsExpandedButton);
         var addBottomItemButton = new Button { Text = "Add Bottom Item" };
         addBottomItemButton.Click += args =>
         {
             _bottomItem = MainMenu.AddBottomItem("Test", new SvgIcon(BottomItemSvgIconXml));
             _bottomItem.Handler = () =>
             {
                 Print("Bottom item clicked!");
             };
         };
         panel.AddChild(addBottomItemButton);
         var removeBottomItemButton = new Button { Text = "Remove Bottom Item" };
         removeBottomItemButton.Click += args =>
         {
             Print($"Remove Result: {MainMenu.RemoveBottomItem(_bottomItem)}");
         };
         panel.AddChild(removeBottomItemButton);
         var aspBlock = Asp.SymbolTab.AddBlock("Main Menu Test");
         aspBlock.Child = panel;
         MainMenu.SelectedItemChanged += args =>
         {
             Print($"Selected Item Changed, old item: {GetItemDetail(args.OldItem)} | new item: {GetItemDetail(args.NewItem)}");
         };
     }
     private string GetItemDetail(MainMenuItem item) => item switch
     {
         null => string.Empty,
         MainMenuBuiltInItem builtInItem => builtInItem.Type.ToString(),
         MainMenuCustomItem customItem => customItem.Name,
         _ => throw new ArgumentOutOfRangeException(nameof(item)),
     };
 }

Methods

TryChangeSelectedItem (2)

TryChangeSelectedItem (1 of 2)

Summary

Tries to change selected item to passed built-in item.

Signature

1
public abstract bool TryChangeSelectedItem(MainMenuBuiltInItem builtInItem)

Parameters

Name Type Description
builtInItem MainMenuBuiltInItem Built-In Item

Return Value

bool

TryChangeSelectedItem (2 of 2)

Summary

Tries to change selected item to passed custom item.

Signature

1
public abstract bool TryChangeSelectedItem(MainMenuOwnCustomItem customItem)

Parameters

Name Type Description
customItem MainMenuOwnCustomItem Custom Item

Return Value

bool

GetBuiltInItem

Summary

Returns a built-in item by type.

Signature

1
public abstract MainMenuBuiltInItem GetBuiltInItem(MainMenuBuiltInItemType type)

Parameters

Name Type Description
type MainMenuBuiltInItemType Built-in item type

Return Value

MainMenuBuiltInItem

ContainsItem

Summary

Allows checking if a custom item exist with passed name or not.

Signature

1
public abstract bool ContainsItem(string name)

Parameters

Name Type Description
name string Item name

Return Value

bool

ContainsBottomItem

Summary

Allows checking if a bottom custom item exist with passed name or not.

Signature

1
public abstract bool ContainsBottomItem(string name)

Parameters

Name Type Description
name string Item name

Return Value

bool

AddItem

Summary

Adds a new custom item to main menu.

Signature

1
public abstract MainMenuOwnCustomItem AddItem(string name, SvgIcon icon)

Parameters

Name Type Description
name string Unique name for new custom item.
icon SvgIcon SVG icon

Return Value

MainMenuOwnCustomItem

RemoveItem

Summary

Removes a previously added custom item from main menu.

Signature

1
public abstract bool RemoveItem(MainMenuOwnCustomItem item)

Parameters

Name Type Description
item MainMenuOwnCustomItem Item to remove.

Return Value

bool

AddBottomItem

Summary

Adds a new bottom custom item to main menu.

Signature

1
public abstract MainMenuBottomCustomItem AddBottomItem(string name, SvgIcon icon)

Parameters

Name Type Description
name string Unique name for new custom item.
icon SvgIcon SVG icon

Return Value

MainMenuBottomCustomItem

RemoveBottomItem

Summary

Removes a previously added bottom item from main menu.

Signature

1
public abstract bool RemoveBottomItem(MainMenuBottomCustomItem item)

Parameters

Name Type Description
item MainMenuBottomCustomItem Item to remove.

Return Value

bool

Properties

IsExpanded

Summary

Gets or sets main menu expanded state.

Signature

1
public abstract bool IsExpanded {get; set;}

Return Value

bool

SelectedItem

Summary

Gets or sets main menu selected item.

Remarks

Returns MainMenuBuiltInItem if selected item is built-in or MainMenuCustomItem if custom.

Signature

1
public abstract MainMenuItem SelectedItem {get;}

Return Value

MainMenuItem

See Also

BuiltInItems

Summary

Gets a collection of built-in items.

Signature

1
public abstract IReadonlyList<MainMenuBuiltInItem> BuiltInItems {get;}

Return Value

IReadonlyList

Events

SelectedItemChanged

Summary

Occurs when main menu selected item changes.

Signature

1
public abstract event Action<MainMenuSelectedItemChangedEventArgs> SelectedItemChanged;