Example #1
0
        private void SaveAsOnClick(object sender, RoutedEventArgs routedEventArgs)
        {
            var diag     = new SimpleDialog();
            var nameText = new TextBox();
            var desText  = new TextBox()
            {
                TextWrapping = TextWrapping.Wrap, AcceptsReturn = true, Height = 300
            };
            var saveButton = new Button()
            {
                Content = "Save", Width = 100
            };

            var stack =
                new StackPanel()
            {
                Margin = new Thickness(20, 20, 20, 20)
            }
            .Add(new Label {
                Content    = "Save Hardware",
                FontSize   = 25,
                FontWeight = FontWeights.Bold,
                Margin     = new Thickness(0, 0, 0, 20)
            })
            .Add(new Label()
            {
                Content = "Name"
            })
            .Add(nameText)
            .Add(new Label {
                Content = "Description"
            })
            .Add(desText)
            .Add(
                new StackPanel()
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Right,
                Margin = new Thickness(0, 20, 0, 0)
            }.Add(
                    saveButton.SetClick(async(o, h) => await SaveAsConfigAsync(nameText.Text, desText.Text)))
                .Add(
                    new Button {
                Content = "Cancel", Width = 100
            }.SetClick((o, args) => diag.CloseDialog())));

            diag.Content = stack;
            _diagManager.ShowDialog(diag);
        }
Example #2
0
        private async Task LoadAndCloseDialogAsync(List <HardwareDefinitionDto> hwDefs, ListBox list, SimpleDialog diag)
        {
            if (_loadButton.IsEnabled == false)
            {
                return;
            }

            _loadButton.IsEnabled       = false;
            _loadButton.Content         = "Loading"; //TODO ALRN - find a better user feedback
            _loadCancelButton.IsEnabled = false;

            diag.CloseDialog();

            await LoadHardwareDefAsync(hwDefs.First(h => h.Name.Equals(list.SelectedItem)));

            _loadCancelButton.IsEnabled = true;
            _loadButton.Content         = "Load";
            _loadButton.IsEnabled       = true;
        }