|
1 | | -<MudStack Row="false" Class="wh100"> |
| 1 | +@inject IDialogService DialogService |
| 2 | + |
| 3 | +<MudStack Row="false" Class="wh100"> |
2 | 4 | <MudText>@Class.Name</MudText> |
3 | 5 |
|
4 | 6 | <MudTreeView T="TreeItem" Items="Items" SelectedValueChanged="OnSelectedItemChanged" Dense="true" Class="w100"> |
|
44 | 46 | <div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%" @onmouseover="() => Hovered = Item" @onmouseout="() => Hovered = null"> |
45 | 47 | <MudText Style="justify-self: start;">@Item.Value.Property!.PropertyType.FriendlyName @Item.Text</MudText> |
46 | 48 | <div style="@($"justify-self: end; visibility: {(Hovered == Item ? "visible" : "hidden")}")"> |
| 49 | + <MudIconButton Icon="@Icons.Material.Filled.ShapeLine" Size="Size.Medium" Color="Color.Inherit" OnClick="() => ShowPropertyTypeEdit(Item.Value)" /> |
47 | 50 | <MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Medium" Color="Color.Inherit" OnClick="() => ShowRenameMenu(Item.Value)" /> |
48 | 51 | <MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Medium" Color="Color.Inherit" /> |
49 | 52 | </div> |
|
55 | 58 | </MudTreeView> |
56 | 59 | </MudStack> |
57 | 60 |
|
| 61 | + |
58 | 62 | @code { |
59 | 63 |
|
60 | 64 | private enum TreeItemType |
|
154 | 158 | Text = CurrentlyEditingItem.Name; |
155 | 159 | } |
156 | 160 |
|
| 161 | + private async Task ShowPropertyTypeEdit(TreeItem item) |
| 162 | + { |
| 163 | + var result = await DialogService.Show<TypeSelectorDialog>("", new() |
| 164 | + { |
| 165 | + [nameof(TypeSelectorDialog.TypeFactory)] = Class.TypeFactory |
| 166 | + }, new DialogOptions() |
| 167 | + { |
| 168 | + FullScreen = true, |
| 169 | + FullWidth = true |
| 170 | + }).Result; |
| 171 | + |
| 172 | + NodeDev.Core.Types.TypeBase typeBase; |
| 173 | + if (result.Data is Type type) |
| 174 | + typeBase = Class.TypeFactory.Get(type); |
| 175 | + else if (result.Data is NodeDev.Core.Types.TypeBase t) |
| 176 | + typeBase = t; |
| 177 | + else |
| 178 | + return; |
| 179 | + |
| 180 | + item.Property!.ChangeType(typeBase); |
| 181 | + } |
| 182 | + |
157 | 183 | private void OnEditTextKeyUp(KeyboardEventArgs args) |
158 | 184 | { |
159 | 185 | if (args.Key != "Enter" || string.IsNullOrWhiteSpace(Text) || CurrentlyEditingItem == null) |
|
191 | 217 | CurrentlyEditingItem.Method.Rename(Text); |
192 | 218 | CurrentlyEditingItem.Name = Text; |
193 | 219 | } |
194 | | - else if(CurrentlyEditingItem.Property != null) |
| 220 | + else if (CurrentlyEditingItem.Property != null) |
195 | 221 | { |
196 | 222 | CurrentlyEditingItem.Property.Rename(Text); |
197 | 223 | CurrentlyEditingItem.Name = Text; |
|
0 commit comments