private void SetForm()
{
ProjectFolderRole role = this._TopFolder.ProjectFolderRole;
this.cbRoles.IsEnabled = this._ProjectItem.IsFolder;
this.chkSyncTemplate.IsEnabled = this._ProjectItem.IsFile && (role == ProjectFolderRole.ComponentLayout || role == ProjectFolderRole.PageLayout);
if (role == ProjectFolderRole.ComponentLayout || role == ProjectFolderRole.PageLayout)
{
this.chkSyncTemplate.IsChecked = this._ProjectItem.IsSyncTemplate();
}
else
{
this.chkSyncTemplate.IsChecked = false;
}
this.btnDebug.IsEnabled = this._ProjectItem.IsFile && (role == ProjectFolderRole.ComponentLayout || role == ProjectFolderRole.PageLayout);
if (this.btnDebug.IsEnabled)
{
ProjectFileInfo projectFile = (ProjectFileInfo) this._ProjectItem;
this.btnDebug.Foreground = new SolidColorBrush(!string.IsNullOrEmpty(projectFile.TestItemTcmId) && !string.IsNullOrEmpty(projectFile.TestTemplateTcmId) ? Colors.Green : Colors.Red);
}
else
{
this.btnDebug.Foreground = new SolidColorBrush(Colors.Gray);
}
this.cbRoles.SelectedValue = role;
if (role == ProjectFolderRole.Other)
return;
if (role == ProjectFolderRole.Binary)
{
this.txtTemplateFormat.Text = String.Empty;
this.txtTemplateFormat.IsEnabled = false;
this.txtSchemaNames.Text = String.Empty;
this.txtSchemaNames.IsEnabled = false;
if (this._ProjectItem.IsFolder)
{
this.txtTitle.Text = null;
this.txtTitle.IsEnabled = false;
}
else
{
ProjectFileInfo file = (ProjectFileInfo)this._ProjectItem;
this.txtTitle.Text = String.IsNullOrEmpty(file.Title) ? Path.GetFileNameWithoutExtension(file.Path) : file.Title;
file.Title = String.IsNullOrEmpty(this.txtTitle.Text) ? null : this.txtTitle.Text;
this.txtTitle.IsEnabled = true;
}
this.txtTemplateTitle.Text = null;
this.txtTemplateTitle.IsEnabled = false;
}
else
{
if (this._ProjectItem.IsFolder)
{
if (this._ProjectItem.Path == this._TopFolder.Path)
{
this.txtTemplateFormat.Text = this._TopFolder.TemplateFormat.PrettyXml();
this.txtTemplateFormat.IsEnabled = true;
}
else
{
this.txtTemplateFormat.Text = String.Empty;
this.txtTemplateFormat.IsEnabled = false;
}
this.txtSchemaNames.Text = String.Empty;
this.txtSchemaNames.IsEnabled = false;
this.txtTitle.Text = null;
this.txtTitle.IsEnabled = false;
this.txtTemplateTitle.Text = null;
this.txtTemplateTitle.IsEnabled = false;
}
else
{
ProjectFileInfo file = (ProjectFileInfo)this._ProjectItem;
this.txtTemplateFormat.Text = this._TopFolder.TemplateFormat.PrettyXml();
this.txtTemplateFormat.IsEnabled = false;
this.txtSchemaNames.Text = file.SchemaNames == null ? String.Empty : string.Join("\n", file.SchemaNames);
this.txtSchemaNames.IsEnabled = true;
string title = Path.GetFileNameWithoutExtension(file.Path);
this.txtTitle.Text = String.IsNullOrEmpty(file.Title) ? (string.IsNullOrEmpty(title) ? null : title.Replace(" Layout", "") + " Layout") : file.Title;
file.Title = String.IsNullOrEmpty(this.txtTitle.Text) ? null : this.txtTitle.Text;
this.txtTitle.IsEnabled = true;
this.txtTemplateTitle.Text = String.IsNullOrEmpty(file.TemplateTitle) ? (string.IsNullOrEmpty(title) ? null : title.Replace(" Layout", "")) : file.TemplateTitle;
file.TemplateTitle = String.IsNullOrEmpty(this.txtTemplateTitle.Text) ? null : this.txtTemplateTitle.Text;
this.txtTemplateTitle.IsEnabled = this.chkSyncTemplate.IsChecked == true;
}
}
List<TridionFolderInfo> tridionFolders = this.TridionFolders.Where(x => x.TridionRole == this._TridionRole).ToList();
this.lstTridionFolders.SelectedIndex = tridionFolders.Any(x => x.TcmId == this._TopFolder.TcmId) ? tridionFolders.FindIndex(x => x.TcmId == this._TopFolder.TcmId) : 0;
}