예제 #1
0
        /// <summary>
        /// Presents the function name dialogue. Returns true if the user enters
        /// a function name and category.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        public void ShowNewFunctionDialog(FunctionNamePromptEventArgs e)
        {
            string error = "";

            do
            {
                //var dialog = new FunctionNamePrompt(dynSettings.Controller.SearchViewModel.Categories, error);
                var dialog = new FunctionNamePrompt(dynSettings.Controller.SearchViewModel.Categories)
                {
                    nameBox     = { Text = e.Name },
                    categoryBox = { Text = e.Category }
                };

                if (dialog.ShowDialog() != true)
                {
                    e.Success = false;
                    return;
                }

                if (String.IsNullOrEmpty(dialog.Text))
                {
                    error = "You must supply a name.";
                    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else if (e.Name != dialog.Text && dynSettings.Controller.CustomNodeManager.Contains(dialog.Text))
                {
                    error = "A custom node with the given name already exists.";
                    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else if (e.Name != dialog.Text && dynSettings.Controller.BuiltInTypesByNickname.ContainsKey(dialog.Text))
                {
                    error = "A built-in node with the given name already exists.";
                    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else if (e.Category.Equals(""))
                {
                    error = "You must enter a new category or choose one from the existing categories.";
                    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else
                {
                    error = "";
                }

                e.Name        = dialog.Text;
                e.Category    = dialog.Category;
                e.Description = dialog.Description;
            } while (!error.Equals(""));

            e.Success = true;
        }
예제 #2
0
        /// <summary>
        /// Presents the function name dialogue. Returns true if the user enters
        /// a function name and category.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        public void ShowNewFunctionDialog(FunctionNamePromptEventArgs e)
        {
            string error = "";

            do
            {
                var categorized =
                    SearchCategory.CategorizeSearchEntries(
                        dynamoViewModel.Model.SearchModel.SearchEntries,
                        entry => entry.Categories);

                var allCategories =
                    categorized.SubCategories.SelectMany(sub => sub.GetAllCategoryNames());

                var dialog = new FunctionNamePrompt(allCategories)
                {
                    categoryBox      = { Text = e.Category },
                    DescriptionInput = { Text = e.Description },
                    nameView         = { Text = e.Name },
                    nameBox          = { Text = e.Name },
                    // center the prompt
                    Owner = this,
                    WindowStartupLocation = WindowStartupLocation.CenterOwner
                };

                if (e.CanEditName)
                {
                    dialog.nameBox.Visibility  = Visibility.Visible;
                    dialog.nameView.Visibility = Visibility.Collapsed;
                }
                else
                {
                    dialog.nameView.Visibility = Visibility.Visible;
                    dialog.nameBox.Visibility  = Visibility.Collapsed;
                }

                if (dialog.ShowDialog() != true)
                {
                    e.Success = false;
                    return;
                }

                if (String.IsNullOrEmpty(dialog.Text))
                {
                    error = "You must supply a name.";
                    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                //else if (e.Name != dialog.Text && dynamoViewModel.Model.BuiltInTypesByNickname.ContainsKey(dialog.Text))
                //{
                //    error = "A built-in node with the given name already exists.";
                //    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                //                                   MessageBoxImage.Error);
                //}
                else if (dialog.Category.Equals(""))
                {
                    error = "You must enter a new category or choose one from the existing categories.";
                    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else
                {
                    error = "";
                }

                e.Name        = dialog.Text;
                e.Category    = dialog.Category;
                e.Description = dialog.Description;
            } while (!error.Equals(""));

            e.Success = true;
        }
예제 #3
0
        /// <summary>
        /// Presents the function name dialogue. Returns true if the user enters
        /// a function name and category.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        public void ShowNewFunctionDialog(FunctionNamePromptEventArgs e)
        {
            string error = "";

            do
            {
                var dialog = new FunctionNamePrompt(dynamoViewModel.Model.SearchModel.Categories)
                {
                    categoryBox      = { Text = e.Category },
                    DescriptionInput = { Text = e.Description },
                    nameView         = { Text = e.Name },
                    nameBox          = { Text = e.Name }
                };

                if (e.CanEditName)
                {
                    dialog.nameBox.Visibility  = Visibility.Visible;
                    dialog.nameView.Visibility = Visibility.Collapsed;
                }
                else
                {
                    dialog.nameView.Visibility = Visibility.Visible;
                    dialog.nameBox.Visibility  = Visibility.Collapsed;
                }

                if (dialog.ShowDialog() != true)
                {
                    e.Success = false;
                    return;
                }

                if (String.IsNullOrEmpty(dialog.Text))
                {
                    error = "You must supply a name.";
                    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else if (e.Name != dialog.Text && dynamoViewModel.Model.BuiltInTypesByNickname.ContainsKey(dialog.Text))
                {
                    error = "A built-in node with the given name already exists.";
                    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else if (dialog.Category.Equals(""))
                {
                    error = "You must enter a new category or choose one from the existing categories.";
                    MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else
                {
                    error = "";
                }

                e.Name        = dialog.Text;
                e.Category    = dialog.Category;
                e.Description = dialog.Description;
            } while (!error.Equals(""));

            e.Success = true;
        }