void UpdateOkStatus()
        {
            try
            {
                FileTemplate template = iconView.CurrentlySelected != null ? iconView.CurrentlySelected.Template : null;

                if (template != null)
                {
                    string  language = iconView.CurrentlySelected.Language;
                    string  filename = GetFileNameFromEntry();
                    Project project  = null;
                    string  path     = null;

                    if (!boxProject.Visible || projectAddCheckbox.Active)
                    {
                        project = parentProject;
                        path    = basePath;
                    }

                    if (projectAddCheckbox.Active)
                    {
                        okButton.Sensitive = template.IsValidName(filename, language);
                    }
                    else
                    {
                        if (!template.IsValidName(filename, language))
                        {
                            okButton.Sensitive = false;
                        }
                        else
                        {
                            bool sensitive = true;
                            foreach (var file in template.Files)
                            {
                                if (!template.CanCreateUnsavedFiles(file, project, project, path, language, filename))
                                {
                                    sensitive = false;
                                    break;
                                }
                            }
                            okButton.Sensitive = sensitive;
                        }
                    }
                }
                else
                {
                    okButton.Sensitive = false;
                }
            }
            catch (Exception ex)
            {
                LoggingService.LogError(ex.ToString());
            }
        }
示例#2
0
        void UpdateOkStatus()
        {
            try {
                TemplateItem sel = (TemplateItem)iconView.CurrentlySelected;
                if (sel == null)
                {
                    okButton.Sensitive      = false;
                    infoLabel.Text          = string.Empty;
                    labelTemplateTitle.Text = string.Empty;
                    return;
                }

                FileTemplate item = sel.Template;

                if (item != null)
                {
                    labelTemplateTitle.Markup = "<b>" + GettextCatalog.GetString(item.Name) + "</b>";
                    infoLabel.Text            = GettextCatalog.GetString(item.Description);

                    //desensitise the text entry if the name is fixed
                    //careful to store user-entered text so we can replace it if they change their selection
                    if (item.IsFixedFilename)
                    {
                        if (userEditedEntryText == null)
                        {
                            userEditedEntryText = nameEntry.Text;
                        }
                        nameEntry.Text      = item.DefaultFilename;
                        nameEntry.Sensitive = false;
                    }
                    else
                    {
                        if (userEditedEntryText != null)
                        {
                            nameEntry.Text      = userEditedEntryText;
                            userEditedEntryText = null;
                        }
                        nameEntry.Sensitive = true;
                    }

                    //fill in a default name if text entry is empty or contains a default name
                    if ((string.IsNullOrEmpty(nameEntry.Text) || (previousDefaultEntryText == nameEntry.Text)) && !string.IsNullOrEmpty(item.DefaultFilename))
                    {
                        nameEntry.Text           = item.DefaultFilename;
                        previousDefaultEntryText = item.DefaultFilename;
                    }

                    okButton.Sensitive = item.IsValidName(nameEntry.Text, sel.Language);
                }
                else
                {
                    nameEntry.Sensitive     = true;
                    okButton.Sensitive      = false;
                    infoLabel.Text          = string.Empty;
                    labelTemplateTitle.Text = string.Empty;
                }
            } catch (Exception ex) {
                LoggingService.LogError(ex.ToString());
            }
        }
        void UpdateOkStatus()
        {
            try {
                TemplateItem sel = (TemplateItem)iconView.CurrentlySelected;
                if (sel == null)
                {
                    okButton.Sensitive      = false;
                    infoLabel.Text          = string.Empty;
                    labelTemplateTitle.Text = string.Empty;
                    return;
                }

                FileTemplate item = sel.Template;

                if (item != null)
                {
                    labelTemplateTitle.Markup = "<b>" + GettextCatalog.GetString(item.Name) + "</b>";
                    infoLabel.Text            = GettextCatalog.GetString(item.Description);

                    //desensitise the text entry if the name is fixed
                    //careful to store user-entered text so we can replace it if they change their selection
                    if (item.IsFixedFilename)
                    {
                        if (userEditedEntryText == null)
                        {
                            userEditedEntryText = nameEntry.Text;
                        }
                        nameEntry.Text      = item.DefaultFilename;
                        nameEntry.Sensitive = false;
                    }
                    else
                    {
                        if (userEditedEntryText != null)
                        {
                            nameEntry.Text      = userEditedEntryText;
                            userEditedEntryText = null;
                        }
                        nameEntry.Sensitive = true;
                    }

                    //fill in a default name if text entry is empty or contains a default name
                    if ((string.IsNullOrEmpty(nameEntry.Text) || (previousDefaultEntryText == nameEntry.Text)) && !string.IsNullOrEmpty(item.DefaultFilename))
                    {
                        nameEntry.Text           = item.DefaultFilename;
                        previousDefaultEntryText = item.DefaultFilename;
                    }
                    Project project = null;
                    string  path    = null;
                    if (!boxProject.Visible || projectAddCheckbox.Active)
                    {
                        project = parentProject;
                        path    = basePath;
                    }

                    if (projectAddCheckbox.Active)
                    {
                        okButton.Sensitive = item.IsValidName(nameEntry.Text, sel.Language);
                    }
                    else
                    {
                        if (!item.IsValidName(nameEntry.Text, sel.Language))
                        {
                            okButton.Sensitive = false;
                        }
                        else
                        {
                            bool sensitive = true;
                            foreach (var file in item.Files)
                            {
                                if (!item.CanCreateUnsavedFiles(file, project, project, path, sel.Language, nameEntry.Text))
                                {
                                    sensitive = false;
                                    break;
                                }
                            }
                            okButton.Sensitive = sensitive;
                        }
                    }
                }
                else
                {
                    nameEntry.Sensitive     = true;
                    okButton.Sensitive      = false;
                    infoLabel.Text          = string.Empty;
                    labelTemplateTitle.Text = string.Empty;
                }
            } catch (Exception ex) {
                LoggingService.LogError(ex.ToString());
            }
        }