private void Save_Clicked(object sender, RoutedEventArgs e)
        {
            HeliosTemplate selectedTemplate = TemplateTreeView.SelectedItem as HeliosTemplate;

            if (selectedTemplate != null)
            {
                string templateKey = TemplateCategory + "." + TemplateName;

                if (ConfigManager.TemplateManager.UserTemplates.ContainsKey(templateKey))
                {
                    if (MessageBox.Show(this, "A template already exists with that name.  Do you want to overwrite the existing template?", "Overwrite Template", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                    {
                        TemplateName     = selectedTemplate.Name;
                        TemplateCategory = selectedTemplate.Category;
                        return;
                    }
                    ConfigManager.TemplateManager.UserTemplates.RemoveKey(templateKey);
                }

                ConfigManager.TemplateManager.UserTemplates.Remove(selectedTemplate);
                selectedTemplate.Name     = TemplateName;
                selectedTemplate.Category = TemplateCategory;
                ConfigManager.TemplateManager.UserTemplates.Add(selectedTemplate);

                PopulateTemplates();
            }
        }
Exemplo n.º 2
0
        private void RemoveTemplateTool(HeliosTemplate template)
        {
            if (_toolboxGroups.ContainsKey(template.Category))
            {
                ToolboxGroup group = _toolboxGroups[template.Category];

                if (group != null)
                {
                    ToolboxItem removeItem = null;

                    foreach (ToolboxItem item in group)
                    {
                        TemplateToolboxItem templateItem = item as TemplateToolboxItem;
                        if (templateItem != null)
                        {
                            if (templateItem.Template.Equals(template))
                            {
                                removeItem = item;
                                break;
                            }
                        }
                    }

                    if (removeItem != null)
                    {
                        group.Remove(removeItem);
                    }
                }
            }
        }
        private void Delete_Clicked(object sender, RoutedEventArgs e)
        {
            HeliosTemplate selectedTemplate = TemplateTreeView.SelectedItem as HeliosTemplate;

            if (selectedTemplate != null)
            {
                if (MessageBox.Show(this, "This action cannot be undone.  Are you sure you want to delete this template?", "Delete Template", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    ConfigManager.TemplateManager.UserTemplates.Remove(selectedTemplate);
                    PopulateTemplates();
                }
            }
        }
        private void SelectedItem_Changed(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            HeliosTemplate selectedTemplate = TemplateTreeView.SelectedItem as HeliosTemplate;

            if (selectedTemplate == null)
            {
                TemplateCategory = "";
                TemplateName     = "";
                TemplatePreview  = null;
            }
            else
            {
                TemplateName               = selectedTemplate.Name;
                TemplateCategory           = selectedTemplate.Category;
                TemplatePreview            = selectedTemplate.CreateInstance();
                TemplatePreview.DesignMode = true;
            }
        }
Exemplo n.º 5
0
 public TemplateToolboxItem(HeliosTemplate template)
 {
     _template = template;
 }
        private static void SaveTemplate_Executed(object target, ExecutedRoutedEventArgs e)
        {
            HeliosVisualContainerEditor editor = target as HeliosVisualContainerEditor;
            if (editor != null)
            {
                if (editor.SelectedItems.Count > 0)
                {
                    HeliosVisual control = editor.SelectedItems[0];
                    SaveTemplateDialog dialog = new SaveTemplateDialog();
                    dialog.TemplateName = control.Name;
                    dialog.TemplateCategory = "User Templates";
                    dialog.Owner = Window.GetWindow(editor);

                    bool? results = dialog.ShowDialog();
                    if (results == true)
                    {
                        HeliosTemplate template = new HeliosTemplate(control);
                        template.Name = dialog.TemplateName;
                        template.Category = dialog.TemplateCategory;

                        string templateKey = ConfigManager.TemplateManager.UserTemplates.GetKeyForItem(template);
                        if (ConfigManager.TemplateManager.UserTemplates.ContainsKey(templateKey))
                        {
                            if (MessageBox.Show(Window.GetWindow(editor), "A template already exists with that name.  Do you want to overwrite the existing template?", "Overwrite Template", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                            {
                                ConfigManager.TemplateManager.UserTemplates.RemoveKey(templateKey);
                                ConfigManager.TemplateManager.UserTemplates.Add(template);
                            }
                        }
                        else
                        {
                            ConfigManager.TemplateManager.UserTemplates.Add(template);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void RemoveTemplateTool(HeliosTemplate template)
        {

            if (_toolboxGroups.ContainsKey(template.Category))
            {
                ToolboxGroup group = _toolboxGroups[template.Category];

                if (group != null)
                {
                    ToolboxItem removeItem = null;

                    foreach (ToolboxItem item in group)
                    {
                        TemplateToolboxItem templateItem = item as TemplateToolboxItem;
                        if (templateItem != null)
                        {
                            if (templateItem.Template.Equals(template))
                            {
                                removeItem = item;
                                break;
                            }
                        }
                    }

                    if (removeItem != null)
                    {
                        group.Remove(removeItem);
                    }
                }
            }
        }
Exemplo n.º 8
0
 public TemplateToolboxItem(HeliosTemplate template)
 {
     _template = template;
 }