29 changed files with 1669 additions and 1734 deletions
@ -1,18 +1,18 @@
@@ -1,18 +1,18 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using ICSharpCode.Core;
|
||||
//
|
||||
//namespace ICSharpCode.WixBinding
|
||||
//{
|
||||
// public class OpenDialogCommand : AbstractMenuCommand
|
||||
// {
|
||||
// public override void Run()
|
||||
// {
|
||||
// if (SetupDialogListPad.Instance != null) {
|
||||
// SetupDialogListPad.Instance.OpenSelectedDialog();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
public class OpenDialogCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
if (SetupDialogListPad.Instance != null) { |
||||
SetupDialogListPad.Instance.OpenSelectedDialog(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,62 +1,62 @@
@@ -1,62 +1,62 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.IO;
|
||||
//using System.Xml;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.NRefactory;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//
|
||||
//namespace ICSharpCode.WixBinding
|
||||
//{
|
||||
// public class ViewDialogXmlCommand : AbstractMenuCommand
|
||||
// {
|
||||
// public override void Run()
|
||||
// {
|
||||
// // Get currently selected setup dialog.
|
||||
// SetupDialogListViewItem selectedDialogListItem = SetupDialogListPad.Instance.SelectedDialog;
|
||||
// if (selectedDialogListItem == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// SetupDialogErrorListViewItem errorDialogListItem = selectedDialogListItem as SetupDialogErrorListViewItem;
|
||||
// if (errorDialogListItem == null) {
|
||||
// ViewDialogXml(selectedDialogListItem.FileName, selectedDialogListItem.Id);
|
||||
// } else {
|
||||
// FileService.JumpToFilePosition(errorDialogListItem.FileName, errorDialogListItem.Line, errorDialogListItem.Column);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// static void ViewDialogXml(string fileName, string dialogId)
|
||||
// {
|
||||
// // Find dialog xml in text.
|
||||
// Location location = GetDialogElementLocation(fileName, dialogId);
|
||||
//
|
||||
// // Jump to text.
|
||||
// if (!location.IsEmpty) {
|
||||
// FileService.JumpToFilePosition(fileName, location.Y, location.X);
|
||||
// } else {
|
||||
// MessageService.ShowErrorFormatted(StringParser.Parse("${res:ICSharpCode.WixBinding.ViewDialogXml.DialogIdNotFoundMessage}"), new string[] {dialogId, Path.GetFileName(fileName)});
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the dialog element location given the filename and the dialog id.
|
||||
// /// </summary>
|
||||
// static Location GetDialogElementLocation(string fileName, string id)
|
||||
// {
|
||||
// try {
|
||||
// WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader();
|
||||
// using (TextReader reader = workbenchTextFileReader.Create(fileName)) {
|
||||
// WixDocumentReader wixReader = new WixDocumentReader(reader);
|
||||
// return wixReader.GetStartElementLocation("Dialog", id);
|
||||
// }
|
||||
// } catch (XmlException ex) {
|
||||
// WixBindingService.ShowErrorInErrorList(fileName, ex);
|
||||
// }
|
||||
// return Location.Empty;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
public class ViewDialogXmlCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
// Get currently selected setup dialog.
|
||||
SetupDialogListViewItem selectedDialogListItem = SetupDialogListPad.Instance.SelectedDialog; |
||||
if (selectedDialogListItem == null) { |
||||
return; |
||||
} |
||||
|
||||
SetupDialogErrorListViewItem errorDialogListItem = selectedDialogListItem as SetupDialogErrorListViewItem; |
||||
if (errorDialogListItem == null) { |
||||
ViewDialogXml(selectedDialogListItem.FileName, selectedDialogListItem.Id); |
||||
} else { |
||||
FileService.JumpToFilePosition(errorDialogListItem.FileName, errorDialogListItem.Line, errorDialogListItem.Column); |
||||
} |
||||
} |
||||
|
||||
static void ViewDialogXml(string fileName, string dialogId) |
||||
{ |
||||
// Find dialog xml in text.
|
||||
TextLocation location = GetDialogElementLocation(fileName, dialogId); |
||||
|
||||
// Jump to text.
|
||||
if (!location.IsEmpty) { |
||||
FileService.JumpToFilePosition(fileName, location.Line, location.Column); |
||||
} else { |
||||
MessageService.ShowErrorFormatted(StringParser.Parse("${res:ICSharpCode.WixBinding.ViewDialogXml.DialogIdNotFoundMessage}"), new string[] {dialogId, Path.GetFileName(fileName)}); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the dialog element location given the filename and the dialog id.
|
||||
/// </summary>
|
||||
static TextLocation GetDialogElementLocation(string fileName, string id) |
||||
{ |
||||
try { |
||||
WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader(); |
||||
using (TextReader reader = workbenchTextFileReader.Create(fileName)) { |
||||
WixDocumentReader wixReader = new WixDocumentReader(reader); |
||||
return wixReader.GetStartElementLocation("Dialog", id); |
||||
} |
||||
} catch (XmlException ex) { |
||||
WixBindingService.ShowErrorInErrorList(fileName, ex); |
||||
} |
||||
return TextLocation.Empty; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,53 +1,53 @@
@@ -1,53 +1,53 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Drawing.Design;
|
||||
//using System.IO;
|
||||
//using System.Reflection;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.FormsDesigner.Gui;
|
||||
//using ICSharpCode.SharpDevelop.Gui;
|
||||
//using ICSharpCode.SharpDevelop.Widgets.SideBar;
|
||||
//
|
||||
//namespace ICSharpCode.WixBinding
|
||||
//{
|
||||
// public sealed class SetupDialogControlsSideTab : SideTabDesigner
|
||||
// {
|
||||
// SetupDialogControlsSideTab(SideBarControl sideBar, Category category, IToolboxService toolboxService)
|
||||
// : base(sideBar, category, toolboxService)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Creates a new instance of the SetupDialogControlsSideTab class.
|
||||
// /// </summary>
|
||||
// public static SetupDialogControlsSideTab CreateSideTab()
|
||||
// {
|
||||
// ComponentLibraryLoader loader = new ComponentLibraryLoader();
|
||||
// loader.LoadToolComponentLibrary(ToolComponentLibraryFileName);
|
||||
//
|
||||
// // Fix WixBinding assembly hint path.
|
||||
// Category category = (Category)loader.Categories[0];
|
||||
// foreach (ToolComponent toolComponent in category.ToolComponents) {
|
||||
// toolComponent.HintPath = StringParser.Parse(toolComponent.HintPath);
|
||||
// }
|
||||
// return new SetupDialogControlsSideTab(WixDialogDesigner.SetupDialogControlsToolBox, category, ToolboxProvider.ToolboxService);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the file that contains the list of controls supported by the Wix dialog
|
||||
// /// designer.
|
||||
// /// </summary>
|
||||
// static string ToolComponentLibraryFileName {
|
||||
// get {
|
||||
// Assembly assembly = typeof(SetupDialogControlsSideTab).Assembly;
|
||||
// string assemblyFilename = assembly.CodeBase.Replace("file:///", String.Empty);
|
||||
// string directory = Path.GetDirectoryName(assemblyFilename);
|
||||
// return Path.Combine(directory, "SetupDialogControlLibrary.sdcl");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Drawing.Design; |
||||
using System.IO; |
||||
using System.Reflection; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.FormsDesigner.Gui; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Widgets.SideBar; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
public sealed class SetupDialogControlsSideTab : SideTabDesigner |
||||
{ |
||||
SetupDialogControlsSideTab(SideBarControl sideBar, Category category, IToolboxService toolboxService) |
||||
: base(sideBar, category, toolboxService) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the SetupDialogControlsSideTab class.
|
||||
/// </summary>
|
||||
public static SetupDialogControlsSideTab CreateSideTab() |
||||
{ |
||||
ComponentLibraryLoader loader = new ComponentLibraryLoader(); |
||||
loader.LoadToolComponentLibrary(ToolComponentLibraryFileName); |
||||
|
||||
// Fix WixBinding assembly hint path.
|
||||
Category category = (Category)loader.Categories[0]; |
||||
foreach (ToolComponent toolComponent in category.ToolComponents) { |
||||
toolComponent.HintPath = StringParser.Parse(toolComponent.HintPath); |
||||
} |
||||
return new SetupDialogControlsSideTab(WixDialogDesigner.SetupDialogControlsToolBox, category, ToolboxProvider.ToolboxService); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the file that contains the list of controls supported by the Wix dialog
|
||||
/// designer.
|
||||
/// </summary>
|
||||
static string ToolComponentLibraryFileName { |
||||
get { |
||||
Assembly assembly = typeof(SetupDialogControlsSideTab).Assembly; |
||||
string assemblyFilename = assembly.CodeBase.Replace("file:///", String.Empty); |
||||
string directory = Path.GetDirectoryName(assemblyFilename); |
||||
return Path.Combine(directory, "SetupDialogControlLibrary.sdcl"); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,193 +1,193 @@
@@ -1,193 +1,193 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.IO;
|
||||
//using System.Xml;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.Core.WinForms;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//using ICSharpCode.SharpDevelop.Workbench;
|
||||
//
|
||||
//namespace ICSharpCode.WixBinding
|
||||
//{
|
||||
// public class SetupDialogListPad : AbstractPadContent
|
||||
// {
|
||||
// SetupDialogListView setupDialogListView;
|
||||
// bool disposed;
|
||||
// static SetupDialogListPad instance;
|
||||
//
|
||||
// public SetupDialogListPad()
|
||||
// {
|
||||
// instance = this;
|
||||
//
|
||||
// setupDialogListView = new SetupDialogListView();
|
||||
// setupDialogListView.ContextMenuStrip = MenuService.CreateContextMenu(setupDialogListView, "/SharpDevelop/Pads/WixSetupDialogListPad/ContextMenu");
|
||||
// setupDialogListView.ItemActivate += SetupDialogListViewItemActivate;
|
||||
// setupDialogListView.Enter += SetupDialogListViewEnter;
|
||||
//
|
||||
// // Show dialogs in currently open wix project.
|
||||
// ShowDialogList();
|
||||
//
|
||||
// ProjectService.CurrentProjectChanged += CurrentProjectChanged;
|
||||
// }
|
||||
//
|
||||
// static public SetupDialogListPad Instance {
|
||||
// get {
|
||||
// return instance;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public override object Control {
|
||||
// get {
|
||||
// return setupDialogListView;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public override void Dispose()
|
||||
// {
|
||||
// if (!disposed) {
|
||||
// disposed = true;
|
||||
// setupDialogListView.Dispose();
|
||||
// setupDialogListView = null;
|
||||
// ProjectService.CurrentProjectChanged -= CurrentProjectChanged;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Opens the selected dialog and displays it in the designer.
|
||||
// /// </summary>
|
||||
// public void OpenSelectedDialog()
|
||||
// {
|
||||
// SetupDialogListViewItem selectedDialog = SelectedDialog;
|
||||
// if (selectedDialog != null) {
|
||||
// SetupDialogErrorListViewItem errorItem = selectedDialog as SetupDialogErrorListViewItem;
|
||||
// if (errorItem == null) {
|
||||
// OpenDialog(selectedDialog.FileName, selectedDialog.Id);
|
||||
// } else {
|
||||
// FileService.JumpToFilePosition(errorItem.FileName, errorItem.Line, errorItem.Column);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the selected dialog list view item.
|
||||
// /// </summary>
|
||||
// public SetupDialogListViewItem SelectedDialog {
|
||||
// get {
|
||||
// if (setupDialogListView.SelectedItems.Count > 0) {
|
||||
// return (SetupDialogListViewItem)(setupDialogListView.SelectedItems[0]);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Adds all the dialog ids from all the files in the project to the list view.
|
||||
// /// </summary>
|
||||
// /// <remarks>
|
||||
// /// If an error occurs an error item is added to the list. The error
|
||||
// /// list is only cleared the first time an error occurs
|
||||
// /// since there may be multiple errors, one in each Wix file.
|
||||
// /// Also we do not clear the error list unless we have an error
|
||||
// /// so any previously added errors from a build, for example, are not
|
||||
// /// cleared unless we have to.
|
||||
// /// </remarks>
|
||||
// void ShowDialogList()
|
||||
// {
|
||||
// // Make sure we do not leave any errors in the error list from a previous call.
|
||||
// if (setupDialogListView.HasErrors) {
|
||||
// WixBindingService.ClearErrorList();
|
||||
// }
|
||||
//
|
||||
// setupDialogListView.Items.Clear();
|
||||
//
|
||||
// WixProject openWixProject = ProjectService.CurrentProject as WixProject;
|
||||
// if (openWixProject != null) {
|
||||
// bool clearedErrorList = false;
|
||||
// foreach (FileProjectItem wixFile in openWixProject.WixFiles) {
|
||||
// if (File.Exists(wixFile.FileName)) {
|
||||
// try {
|
||||
// AddDialogListItems(wixFile.FileName);
|
||||
// } catch (XmlException ex) {
|
||||
// // Clear the error list the first time only.
|
||||
// if (!clearedErrorList) {
|
||||
// clearedErrorList = true;
|
||||
// WixBindingService.ClearErrorList();
|
||||
// }
|
||||
// setupDialogListView.AddError(wixFile.FileName, ex);
|
||||
// WixBindingService.AddErrorToErrorList(wixFile.FileName, ex);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (clearedErrorList) {
|
||||
// WixBindingService.ShowErrorList();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Adds dialog ids to the list.
|
||||
// /// </summary>
|
||||
// void AddDialogListItems(string fileName)
|
||||
// {
|
||||
// WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader();
|
||||
// using (TextReader reader = workbenchTextFileReader.Create(fileName)) {
|
||||
// WixDocumentReader wixReader = new WixDocumentReader(reader);
|
||||
// setupDialogListView.AddDialogs(fileName, wixReader.GetDialogIds());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void CurrentProjectChanged(object source, ProjectEventArgs e)
|
||||
// {
|
||||
// ShowDialogList();
|
||||
// }
|
||||
//
|
||||
// void SetupDialogListViewItemActivate(object source, EventArgs e)
|
||||
// {
|
||||
// OpenSelectedDialog();
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// When the setup dialog list gets focus update the list of dialogs since
|
||||
// /// the Wix document may have changed.
|
||||
// /// </summary>
|
||||
// void SetupDialogListViewEnter(object source, EventArgs e)
|
||||
// {
|
||||
// UpdateDialogList();
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Opens the specified dialog id into the designer.
|
||||
// /// </summary>
|
||||
// static void OpenDialog(string fileName, string dialogId)
|
||||
// {
|
||||
// // Open the Wix file.
|
||||
// IViewContent viewContent = FileService.OpenFile(fileName);
|
||||
//
|
||||
// // Show the designer.
|
||||
// WixDialogDesigner designer = WixDialogDesigner.GetDesigner(viewContent);
|
||||
// if (designer != null) {
|
||||
// designer.OpenDialog(dialogId);
|
||||
// } else {
|
||||
// LoggingService.Debug("Could not open Wix dialog designer for: " + fileName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Updates the list if the Wix documents can be read otherwise the list
|
||||
// /// items are unchanged for that document.
|
||||
// /// </summary>
|
||||
// void UpdateDialogList()
|
||||
// {
|
||||
// try {
|
||||
// setupDialogListView.BeginUpdate();
|
||||
// ShowDialogList();
|
||||
// } finally {
|
||||
// setupDialogListView.EndUpdate();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Core.WinForms; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
public class SetupDialogListPad : AbstractPadContent |
||||
{ |
||||
SetupDialogListView setupDialogListView; |
||||
bool disposed; |
||||
static SetupDialogListPad instance; |
||||
|
||||
public SetupDialogListPad() |
||||
{ |
||||
instance = this; |
||||
|
||||
setupDialogListView = new SetupDialogListView(); |
||||
setupDialogListView.ContextMenuStrip = MenuService.CreateContextMenu(setupDialogListView, "/SharpDevelop/Pads/WixSetupDialogListPad/ContextMenu"); |
||||
setupDialogListView.ItemActivate += SetupDialogListViewItemActivate; |
||||
setupDialogListView.Enter += SetupDialogListViewEnter; |
||||
|
||||
// Show dialogs in currently open wix project.
|
||||
ShowDialogList(); |
||||
|
||||
ProjectService.CurrentProjectChanged += CurrentProjectChanged; |
||||
} |
||||
|
||||
static public SetupDialogListPad Instance { |
||||
get { |
||||
return instance; |
||||
} |
||||
} |
||||
|
||||
public override object Control { |
||||
get { |
||||
return setupDialogListView; |
||||
} |
||||
} |
||||
|
||||
public override void Dispose() |
||||
{ |
||||
if (!disposed) { |
||||
disposed = true; |
||||
setupDialogListView.Dispose(); |
||||
setupDialogListView = null; |
||||
ProjectService.CurrentProjectChanged -= CurrentProjectChanged; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Opens the selected dialog and displays it in the designer.
|
||||
/// </summary>
|
||||
public void OpenSelectedDialog() |
||||
{ |
||||
SetupDialogListViewItem selectedDialog = SelectedDialog; |
||||
if (selectedDialog != null) { |
||||
SetupDialogErrorListViewItem errorItem = selectedDialog as SetupDialogErrorListViewItem; |
||||
if (errorItem == null) { |
||||
OpenDialog(selectedDialog.FileName, selectedDialog.Id); |
||||
} else { |
||||
FileService.JumpToFilePosition(errorItem.FileName, errorItem.Line, errorItem.Column); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the selected dialog list view item.
|
||||
/// </summary>
|
||||
public SetupDialogListViewItem SelectedDialog { |
||||
get { |
||||
if (setupDialogListView.SelectedItems.Count > 0) { |
||||
return (SetupDialogListViewItem)(setupDialogListView.SelectedItems[0]); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds all the dialog ids from all the files in the project to the list view.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If an error occurs an error item is added to the list. The error
|
||||
/// list is only cleared the first time an error occurs
|
||||
/// since there may be multiple errors, one in each Wix file.
|
||||
/// Also we do not clear the error list unless we have an error
|
||||
/// so any previously added errors from a build, for example, are not
|
||||
/// cleared unless we have to.
|
||||
/// </remarks>
|
||||
void ShowDialogList() |
||||
{ |
||||
// Make sure we do not leave any errors in the error list from a previous call.
|
||||
if (setupDialogListView.HasErrors) { |
||||
WixBindingService.ClearErrorList(); |
||||
} |
||||
|
||||
setupDialogListView.Items.Clear(); |
||||
|
||||
WixProject openWixProject = ProjectService.CurrentProject as WixProject; |
||||
if (openWixProject != null) { |
||||
bool clearedErrorList = false; |
||||
foreach (FileProjectItem wixFile in openWixProject.WixFiles) { |
||||
if (File.Exists(wixFile.FileName)) { |
||||
try { |
||||
AddDialogListItems(wixFile.FileName); |
||||
} catch (XmlException ex) { |
||||
// Clear the error list the first time only.
|
||||
if (!clearedErrorList) { |
||||
clearedErrorList = true; |
||||
WixBindingService.ClearErrorList(); |
||||
} |
||||
setupDialogListView.AddError(wixFile.FileName, ex); |
||||
WixBindingService.AddErrorToErrorList(wixFile.FileName, ex); |
||||
} |
||||
} |
||||
} |
||||
if (clearedErrorList) { |
||||
WixBindingService.ShowErrorList(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds dialog ids to the list.
|
||||
/// </summary>
|
||||
void AddDialogListItems(string fileName) |
||||
{ |
||||
WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader(); |
||||
using (TextReader reader = workbenchTextFileReader.Create(fileName)) { |
||||
WixDocumentReader wixReader = new WixDocumentReader(reader); |
||||
setupDialogListView.AddDialogs(fileName, wixReader.GetDialogIds()); |
||||
} |
||||
} |
||||
|
||||
void CurrentProjectChanged(object source, ProjectEventArgs e) |
||||
{ |
||||
ShowDialogList(); |
||||
} |
||||
|
||||
void SetupDialogListViewItemActivate(object source, EventArgs e) |
||||
{ |
||||
OpenSelectedDialog(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// When the setup dialog list gets focus update the list of dialogs since
|
||||
/// the Wix document may have changed.
|
||||
/// </summary>
|
||||
void SetupDialogListViewEnter(object source, EventArgs e) |
||||
{ |
||||
UpdateDialogList(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Opens the specified dialog id into the designer.
|
||||
/// </summary>
|
||||
static void OpenDialog(string fileName, string dialogId) |
||||
{ |
||||
// Open the Wix file.
|
||||
IViewContent viewContent = FileService.OpenFile(fileName); |
||||
|
||||
// Show the designer.
|
||||
WixDialogDesigner designer = WixDialogDesigner.GetDesigner(viewContent); |
||||
if (designer != null) { |
||||
designer.OpenDialog(dialogId); |
||||
} else { |
||||
LoggingService.Debug("Could not open Wix dialog designer for: " + fileName); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the list if the Wix documents can be read otherwise the list
|
||||
/// items are unchanged for that document.
|
||||
/// </summary>
|
||||
void UpdateDialogList() |
||||
{ |
||||
try { |
||||
setupDialogListView.BeginUpdate(); |
||||
ShowDialogList(); |
||||
} finally { |
||||
setupDialogListView.EndUpdate(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,296 +1,302 @@
@@ -1,296 +1,302 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Collections.ObjectModel;
|
||||
//using System.IO;
|
||||
//using System.Xml;
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.NRefactory;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//using ICSharpCode.SharpDevelop.Editor;
|
||||
//using ICSharpCode.SharpDevelop.Gui;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//using ICSharpCode.SharpDevelop.Refactoring;
|
||||
//
|
||||
//namespace ICSharpCode.WixBinding
|
||||
//{
|
||||
// public class WixDialogDesigner : FormsDesignerViewContent, IWixDialogDesigner
|
||||
// {
|
||||
// string dialogId = String.Empty;
|
||||
// WixProject wixProject;
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Ignore the dialog id in the text editor if the OpenDialog method is called
|
||||
// /// and the designer is not being opened by the user clicking the Design tab.
|
||||
// /// </summary>
|
||||
// bool ignoreDialogIdSelectedInTextEditor;
|
||||
//
|
||||
// public WixDialogDesigner(IViewContent view)
|
||||
// : this(view, new WixDialogDesignerLoaderProvider(), new WixDialogDesignerGenerator())
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public WixDialogDesigner(IViewContent view, WixDialogDesignerLoaderProvider designerLoaderProvider, WixDialogDesignerGenerator designerGenerator)
|
||||
// : base(view, designerLoaderProvider, designerGenerator)
|
||||
// {
|
||||
// designerLoaderProvider.Designer = this;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the WixDialogDesigner from the primary view.
|
||||
// /// </summary>
|
||||
// /// <returns>The wix dialog designer view that is attached as a
|
||||
// /// secondary view; <see langword="null"/> if the primary view
|
||||
// /// has no such designer attached.</returns>
|
||||
// public static WixDialogDesigner GetDesigner(IViewContent view)
|
||||
// {
|
||||
// foreach (IViewContent secondaryView in view.SecondaryViewContents) {
|
||||
// WixDialogDesigner designer = secondaryView as WixDialogDesigner;
|
||||
// if (designer != null) {
|
||||
// return designer;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Attempts to open the Wix dialog from the document currently
|
||||
// /// associated with this designer.
|
||||
// /// </summary>
|
||||
// /// <param name="id">The id of the dialog that will be opened.</param>
|
||||
// public void OpenDialog(string id)
|
||||
// {
|
||||
// JumpToDialogElement(id);
|
||||
// if (base.Host != null) {
|
||||
// // Reload so the correct dialog is displayed.
|
||||
// MergeAndUnloadDesigner();
|
||||
// DialogId = id;
|
||||
// ReloadDesignerFromMemory();
|
||||
// } else {
|
||||
// // Need to open the designer.
|
||||
// DialogId = id;
|
||||
// OpenDesigner();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected override void LoadInternal(OpenedFile file, Stream stream)
|
||||
// {
|
||||
// if (file == this.PrimaryFile) {
|
||||
// // The FormsDesignerViewContent normally operates independently of any
|
||||
// // text editor. The following statements connect the forms designer
|
||||
// // directly to the underlying XML text editor so that the caret positioning
|
||||
// // and text selection operations done by the WiX designer actually
|
||||
// // become visible in the text editor.
|
||||
// if (!this.SourceCodeStorage.ContainsFile(file)) {
|
||||
// ITextEditor editor = ((ITextEditorProvider)this.PrimaryViewContent).TextEditor;
|
||||
// this.SourceCodeStorage.AddFile(file, editor.Document, ParserService.DefaultFileEncoding, true);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// if (!ignoreDialogIdSelectedInTextEditor) {
|
||||
// string dialogId = GetDialogIdSelectedInTextEditor();
|
||||
// if (dialogId == null) {
|
||||
// dialogId = GetFirstDialogIdInTextEditor();
|
||||
// JumpToDialogElement(dialogId);
|
||||
// }
|
||||
// DialogId = dialogId;
|
||||
// }
|
||||
// wixProject = GetProject();
|
||||
// } catch (XmlException ex) {
|
||||
// // Let the Wix designer loader try to load the XML and generate
|
||||
// // an error message.
|
||||
// DialogId = "InvalidXML";
|
||||
// AddToErrorList(ex);
|
||||
// }
|
||||
// }
|
||||
// base.LoadInternal(file, stream);
|
||||
// }
|
||||
//
|
||||
// #region Switch...WithoutSaveLoad
|
||||
//
|
||||
// // These four methods prevent the text editor from doing a full save/load
|
||||
// // cycle when switching views. This allows the text editor to keep its
|
||||
// // selection and caret position.
|
||||
//
|
||||
// public override bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView)
|
||||
// {
|
||||
// return (newView == this) || (newView == this.PrimaryViewContent);
|
||||
// }
|
||||
//
|
||||
// public override void SwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView)
|
||||
// {
|
||||
// if (newView != this) {
|
||||
// this.MergeAndUnloadDesigner();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public override bool SupportsSwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView)
|
||||
// {
|
||||
// return (this.DesignerCodeFile != null) &&
|
||||
// ((oldView == this) || (oldView == this.PrimaryViewContent));
|
||||
// }
|
||||
//
|
||||
// public override void SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView)
|
||||
// {
|
||||
// if (oldView != this) {
|
||||
// this.ReloadDesignerFromMemory();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the Wix document filename.
|
||||
// /// </summary>
|
||||
// public string DocumentFileName {
|
||||
// get { return PrimaryFileName; }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the wix project containing the document open in the designer.
|
||||
// /// </summary>
|
||||
// public WixProject Project {
|
||||
// get { return wixProject; }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the Wix document xml.
|
||||
// /// </summary>
|
||||
// public string GetDocumentXml()
|
||||
// {
|
||||
// return DesignerCodeFileContent;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets or sets the dialog id currently being designed.
|
||||
// /// </summary>
|
||||
// public string DialogId {
|
||||
// get { return dialogId; }
|
||||
// set { dialogId = value; }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Finds the WixDialogDesigner in the current window's secondary views
|
||||
// /// and switches to it.
|
||||
// /// </summary>
|
||||
// void OpenDesigner()
|
||||
// {
|
||||
// try {
|
||||
// ignoreDialogIdSelectedInTextEditor = true;
|
||||
// WorkbenchWindow.ActiveViewContent = this;
|
||||
// } finally {
|
||||
// ignoreDialogIdSelectedInTextEditor = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// From the current cursor position in the text editor determine the
|
||||
// /// selected dialog id.
|
||||
// /// </summary>
|
||||
// string GetDialogIdSelectedInTextEditor()
|
||||
// {
|
||||
// ITextEditor textEditor = ActiveTextEditor;
|
||||
// if (textEditor != null) {
|
||||
// WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
|
||||
// return wixReader.GetDialogId(textEditor.Caret.Line);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the first dialog id in the file.
|
||||
// /// </summary>
|
||||
// string GetFirstDialogIdInTextEditor()
|
||||
// {
|
||||
// ITextEditor textEditor = ActiveTextEditor;
|
||||
// if (textEditor != null) {
|
||||
// WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
|
||||
// ReadOnlyCollection<string> ids = wixReader.GetDialogIds();
|
||||
// if (ids.Count > 0) {
|
||||
// return ids[0];
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets the active text area control.
|
||||
// /// </summary>
|
||||
// ITextEditor ActiveTextEditor {
|
||||
// get {
|
||||
// ITextEditorProvider provider = this.PrimaryViewContent as ITextEditorProvider;
|
||||
// if (provider != null) {
|
||||
// return provider.TextEditor;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void AddToErrorList(XmlException ex)
|
||||
// {
|
||||
// TaskService.ClearExceptCommentTasks();
|
||||
// TaskService.Add(new Task(this.PrimaryFileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1, TaskType.Error));
|
||||
// WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Cannot use ProjectService.CurrentProject since it is possible to switch
|
||||
// /// to the designer without selecting the project.
|
||||
// /// </summary>
|
||||
// WixProject GetProject()
|
||||
// {
|
||||
// Solution openSolution = ProjectService.OpenSolution;
|
||||
// if (openSolution != null) {
|
||||
// foreach (IProject project in openSolution.Projects) {
|
||||
// if (project.IsFileInProject(this.PrimaryFileName)) {
|
||||
// return project as WixProject;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Jumps to dialog element with corresponding dialog id. This is only used
|
||||
// /// when the user opens a dialog from the Setup dialogs window or the cursor
|
||||
// /// was not near a dialog when the designer was switched to. Jumping to the
|
||||
// /// dialog selected ensures that when the user switches back, if they did
|
||||
// /// not make any changes, then the dialog xml is displayed.
|
||||
// /// </summary>
|
||||
// void JumpToDialogElement(string dialogId)
|
||||
// {
|
||||
// try {
|
||||
// if (dialogId != null) {
|
||||
// ITextEditor textEditor = ActiveTextEditor;
|
||||
// if (textEditor != null) {
|
||||
// WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
|
||||
// Location location = wixReader.GetStartElementLocation("Dialog", dialogId);
|
||||
// textEditor.JumpTo(location.Y, 1);
|
||||
// }
|
||||
// }
|
||||
// } catch (XmlException) {
|
||||
// // Ignore
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// static SharpDevelopSideBar setupDialogControlsToolBox;
|
||||
//
|
||||
// public static SharpDevelopSideBar SetupDialogControlsToolBox {
|
||||
// get {
|
||||
// WorkbenchSingleton.AssertMainThread();
|
||||
// if (setupDialogControlsToolBox == null) {
|
||||
// setupDialogControlsToolBox = new SharpDevelopSideBar();
|
||||
// setupDialogControlsToolBox.Tabs.Add(SetupDialogControlsSideTab.CreateSideTab());
|
||||
// setupDialogControlsToolBox.ActiveTab = setupDialogControlsToolBox.Tabs[0];
|
||||
// }
|
||||
// return setupDialogControlsToolBox;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public override object ToolsContent {
|
||||
// get { return SetupDialogControlsToolBox; }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.ObjectModel; |
||||
using System.IO; |
||||
using System.Xml; |
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Refactoring; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
public class WixDialogDesigner : FormsDesignerViewContent, IWixDialogDesigner |
||||
{ |
||||
string dialogId = String.Empty; |
||||
WixProject wixProject; |
||||
|
||||
/// <summary>
|
||||
/// Ignore the dialog id in the text editor if the OpenDialog method is called
|
||||
/// and the designer is not being opened by the user clicking the Design tab.
|
||||
/// </summary>
|
||||
bool ignoreDialogIdSelectedInTextEditor; |
||||
|
||||
public WixDialogDesigner(IViewContent view) |
||||
: this(view, new WixDialogDesignerLoaderProvider()) |
||||
{ |
||||
} |
||||
|
||||
public WixDialogDesigner(IViewContent view, WixDialogDesignerLoaderProvider designerLoaderProvider) |
||||
: base(view, designerLoaderProvider) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the WixDialogDesigner from the primary view.
|
||||
/// </summary>
|
||||
/// <returns>The wix dialog designer view that is attached as a
|
||||
/// secondary view; <see langword="null"/> if the primary view
|
||||
/// has no such designer attached.</returns>
|
||||
public static WixDialogDesigner GetDesigner(IViewContent view) |
||||
{ |
||||
foreach (IViewContent secondaryView in view.SecondaryViewContents) { |
||||
WixDialogDesigner designer = secondaryView as WixDialogDesigner; |
||||
if (designer != null) { |
||||
return designer; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Attempts to open the Wix dialog from the document currently
|
||||
/// associated with this designer.
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the dialog that will be opened.</param>
|
||||
public void OpenDialog(string id) |
||||
{ |
||||
JumpToDialogElement(id); |
||||
if (base.Host != null) { |
||||
// Reload so the correct dialog is displayed.
|
||||
MergeAndUnloadDesigner(); |
||||
DialogId = id; |
||||
ReloadDesignerFromMemory(); |
||||
} else { |
||||
// Need to open the designer.
|
||||
DialogId = id; |
||||
OpenDesigner(); |
||||
} |
||||
} |
||||
|
||||
protected override void LoadInternal(OpenedFile file, Stream stream) |
||||
{ |
||||
if (file == this.PrimaryFile) { |
||||
// The FormsDesignerViewContent normally operates independently of any
|
||||
// text editor. The following statements connect the forms designer
|
||||
// directly to the underlying XML text editor so that the caret positioning
|
||||
// and text selection operations done by the WiX designer actually
|
||||
// become visible in the text editor.
|
||||
if (!this.SourceCodeStorage.ContainsFile(file)) { |
||||
ITextEditor editor = ((ITextEditorProvider)this.PrimaryViewContent).TextEditor; |
||||
this.SourceCodeStorage.AddFile(file, editor.Document, SD.FileService.DefaultFileEncoding, true); |
||||
} |
||||
|
||||
try { |
||||
if (!ignoreDialogIdSelectedInTextEditor) { |
||||
string dialogId = GetDialogIdSelectedInTextEditor(); |
||||
if (dialogId == null) { |
||||
dialogId = GetFirstDialogIdInTextEditor(); |
||||
JumpToDialogElement(dialogId); |
||||
} |
||||
DialogId = dialogId; |
||||
} |
||||
wixProject = GetProject(); |
||||
} catch (XmlException ex) { |
||||
// Let the Wix designer loader try to load the XML and generate
|
||||
// an error message.
|
||||
DialogId = "InvalidXML"; |
||||
AddToErrorList(ex); |
||||
} |
||||
} |
||||
base.LoadInternal(file, stream); |
||||
} |
||||
|
||||
#region Switch...WithoutSaveLoad
|
||||
|
||||
// These four methods prevent the text editor from doing a full save/load
|
||||
// cycle when switching views. This allows the text editor to keep its
|
||||
// selection and caret position.
|
||||
|
||||
public override bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) |
||||
{ |
||||
return (newView == this) || (newView == this.PrimaryViewContent); |
||||
} |
||||
|
||||
public override void SwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) |
||||
{ |
||||
if (newView != this) { |
||||
this.MergeAndUnloadDesigner(); |
||||
} |
||||
} |
||||
|
||||
public override bool SupportsSwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) |
||||
{ |
||||
return (this.DesignerCodeFile != null) && |
||||
((oldView == this) || (oldView == this.PrimaryViewContent)); |
||||
} |
||||
|
||||
public override void SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) |
||||
{ |
||||
if (oldView != this) { |
||||
this.ReloadDesignerFromMemory(); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Wix document filename.
|
||||
/// </summary>
|
||||
public string DocumentFileName { |
||||
get { return PrimaryFileName; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the wix project containing the document open in the designer.
|
||||
/// </summary>
|
||||
public WixProject Project { |
||||
get { return wixProject; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the Wix document xml.
|
||||
/// </summary>
|
||||
public string GetDocumentXml() |
||||
{ |
||||
return DesignerCodeFileContent; |
||||
} |
||||
|
||||
public ITextEditor PrimaryViewContentTextEditor { |
||||
get { |
||||
return PrimaryViewContent.GetRequiredService<ITextEditor>(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the dialog id currently being designed.
|
||||
/// </summary>
|
||||
public string DialogId { |
||||
get { return dialogId; } |
||||
set { dialogId = value; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Finds the WixDialogDesigner in the current window's secondary views
|
||||
/// and switches to it.
|
||||
/// </summary>
|
||||
void OpenDesigner() |
||||
{ |
||||
try { |
||||
ignoreDialogIdSelectedInTextEditor = true; |
||||
WorkbenchWindow.ActiveViewContent = this; |
||||
} finally { |
||||
ignoreDialogIdSelectedInTextEditor = false; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// From the current cursor position in the text editor determine the
|
||||
/// selected dialog id.
|
||||
/// </summary>
|
||||
string GetDialogIdSelectedInTextEditor() |
||||
{ |
||||
ITextEditor textEditor = ActiveTextEditor; |
||||
if (textEditor != null) { |
||||
WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text); |
||||
return wixReader.GetDialogId(textEditor.Caret.Line); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the first dialog id in the file.
|
||||
/// </summary>
|
||||
string GetFirstDialogIdInTextEditor() |
||||
{ |
||||
ITextEditor textEditor = ActiveTextEditor; |
||||
if (textEditor != null) { |
||||
WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text); |
||||
ReadOnlyCollection<string> ids = wixReader.GetDialogIds(); |
||||
if (ids.Count > 0) { |
||||
return ids[0]; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the active text area control.
|
||||
/// </summary>
|
||||
ITextEditor ActiveTextEditor { |
||||
get { |
||||
ITextEditorProvider provider = this.PrimaryViewContent as ITextEditorProvider; |
||||
if (provider != null) { |
||||
return provider.TextEditor; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
void AddToErrorList(XmlException ex) |
||||
{ |
||||
TaskService.ClearExceptCommentTasks(); |
||||
TaskService.Add(new SDTask(this.PrimaryFileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1, TaskType.Error)); |
||||
SD.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Cannot use ProjectService.CurrentProject since it is possible to switch
|
||||
/// to the designer without selecting the project.
|
||||
/// </summary>
|
||||
WixProject GetProject() |
||||
{ |
||||
ISolution openSolution = ProjectService.OpenSolution; |
||||
if (openSolution != null) { |
||||
foreach (IProject project in openSolution.Projects) { |
||||
if (project.IsFileInProject(this.PrimaryFileName)) { |
||||
return project as WixProject; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Jumps to dialog element with corresponding dialog id. This is only used
|
||||
/// when the user opens a dialog from the Setup dialogs window or the cursor
|
||||
/// was not near a dialog when the designer was switched to. Jumping to the
|
||||
/// dialog selected ensures that when the user switches back, if they did
|
||||
/// not make any changes, then the dialog xml is displayed.
|
||||
/// </summary>
|
||||
void JumpToDialogElement(string dialogId) |
||||
{ |
||||
try { |
||||
if (dialogId != null) { |
||||
ITextEditor textEditor = ActiveTextEditor; |
||||
if (textEditor != null) { |
||||
WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text); |
||||
TextLocation location = wixReader.GetStartElementLocation("Dialog", dialogId); |
||||
textEditor.JumpTo(location.Line, 1); |
||||
} |
||||
} |
||||
} catch (XmlException) { |
||||
// Ignore
|
||||
} |
||||
} |
||||
|
||||
static SharpDevelopSideBar setupDialogControlsToolBox; |
||||
|
||||
public static SharpDevelopSideBar SetupDialogControlsToolBox { |
||||
get { |
||||
SD.MainThread.VerifyAccess(); |
||||
if (setupDialogControlsToolBox == null) { |
||||
setupDialogControlsToolBox = new SharpDevelopSideBar(); |
||||
setupDialogControlsToolBox.Tabs.Add(SetupDialogControlsSideTab.CreateSideTab()); |
||||
setupDialogControlsToolBox.ActiveTab = setupDialogControlsToolBox.Tabs[0]; |
||||
} |
||||
return setupDialogControlsToolBox; |
||||
} |
||||
} |
||||
|
||||
|
||||
public override object ToolsContent { |
||||
get { return SetupDialogControlsToolBox; } |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,122 +1,78 @@
@@ -1,122 +1,78 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.CodeDom;
|
||||
//using System.CodeDom.Compiler;
|
||||
//using System.Collections;
|
||||
//using System.Collections.Generic;
|
||||
//using System.ComponentModel;
|
||||
//using System.Reflection;
|
||||
//using System.Xml;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.NRefactory.TypeSystem;
|
||||
//using ICSharpCode.SharpDevelop.Editor;
|
||||
//using Microsoft.CSharp;
|
||||
//
|
||||
//namespace ICSharpCode.WixBinding
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Simplified designer generator interface that the WixDesignerLoader calls
|
||||
// /// when flushing the changes.
|
||||
// /// </summary>
|
||||
// public interface IWixDialogDesignerGenerator
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// Passes the updated dialog element and its original id to the generator
|
||||
// /// so the wix document can be updated.
|
||||
// /// </summary>
|
||||
// /// <remarks>The dialog id is passed since it becomes the name of the
|
||||
// /// form and this can be changed from the designer.</remarks>
|
||||
// void MergeFormChanges(string dialogId, XmlElement dialogElement);
|
||||
// }
|
||||
//
|
||||
// public class WixDialogDesignerGenerator : IDesignerGenerator, IWixDialogDesignerGenerator
|
||||
// {
|
||||
// FormsDesignerViewContent view;
|
||||
// ITextEditor textEditor;
|
||||
//
|
||||
// public CodeDomProvider CodeDomProvider {
|
||||
// get { return new CSharpCodeProvider(); }
|
||||
// }
|
||||
//
|
||||
// public FormsDesignerViewContent ViewContent {
|
||||
// get { return view; }
|
||||
// }
|
||||
//
|
||||
// public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile)
|
||||
// {
|
||||
// designerCodeFile = view.PrimaryFile;
|
||||
// return new [] {designerCodeFile};
|
||||
// }
|
||||
//
|
||||
// public void Attach(FormsDesignerViewContent view)
|
||||
// {
|
||||
// this.view = view;
|
||||
// textEditor = ((ITextEditorProvider)view.PrimaryViewContent).TextEditor;
|
||||
// }
|
||||
//
|
||||
// public void Detach()
|
||||
// {
|
||||
// view = null;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Merges the changes made to the wix document by overwriting the dialog element.
|
||||
// /// </summary>
|
||||
// void IWixDialogDesignerGenerator.MergeFormChanges(string dialogId, XmlElement dialogElement)
|
||||
// {
|
||||
// DomRegion region = GetTextEditorRegionForDialogElement(dialogId);
|
||||
// if (region.IsEmpty) {
|
||||
// ThrowDialogElementCouldNotBeFoundError(dialogId);
|
||||
// }
|
||||
//
|
||||
// WixTextWriter writer = new WixTextWriter(textEditor.Options);
|
||||
// WixDialogElement wixDialogElement = (WixDialogElement)dialogElement;
|
||||
// string newDialogXml = wixDialogElement.GetXml(writer);
|
||||
//
|
||||
// WixDocumentEditor editor = new WixDocumentEditor(textEditor);
|
||||
// editor.Replace(region, newDialogXml);
|
||||
// }
|
||||
//
|
||||
// DomRegion GetTextEditorRegionForDialogElement(string dialogId)
|
||||
// {
|
||||
// IDocument document = view.DesignerCodeFileDocument;
|
||||
// WixDocumentReader wixReader = new WixDocumentReader(document.Text);
|
||||
// return wixReader.GetElementRegion("Dialog", dialogId);
|
||||
// }
|
||||
//
|
||||
// void ThrowDialogElementCouldNotBeFoundError(string dialogId)
|
||||
// {
|
||||
// string messageFormat = StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}");
|
||||
// string message = String.Format(messageFormat, dialogId);
|
||||
// throw new FormsDesignerLoadException(message);
|
||||
// }
|
||||
//
|
||||
// public void MergeFormChanges(CodeCompileUnit unit)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public void NotifyComponentRenamed(object component, string newName, string oldName)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
|
||||
// {
|
||||
// file = null;
|
||||
// position = 0;
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// public ICollection GetCompatibleMethods(EventDescriptor edesc)
|
||||
// {
|
||||
// return new ArrayList();
|
||||
// }
|
||||
//
|
||||
// public ICollection GetCompatibleMethods(EventInfo edesc)
|
||||
// {
|
||||
// return new ArrayList();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.Reflection; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.NRefactory.Editor; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using Microsoft.CSharp; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Simplified designer generator interface that the WixDesignerLoader calls
|
||||
/// when flushing the changes.
|
||||
/// </summary>
|
||||
public interface IWixDialogDesignerGenerator |
||||
{ |
||||
/// <summary>
|
||||
/// Passes the updated dialog element and its original id to the generator
|
||||
/// so the wix document can be updated.
|
||||
/// </summary>
|
||||
/// <remarks>The dialog id is passed since it becomes the name of the
|
||||
/// form and this can be changed from the designer.</remarks>
|
||||
void MergeFormChanges(string dialogId, XmlElement dialogElement); |
||||
} |
||||
|
||||
public class WixDialogDesignerGenerator : IWixDialogDesignerGenerator |
||||
{ |
||||
readonly IWixDialogDesigner view; |
||||
|
||||
public WixDialogDesignerGenerator(IWixDialogDesigner view) |
||||
{ |
||||
this.view = view; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Merges the changes made to the wix document by overwriting the dialog element.
|
||||
/// </summary>
|
||||
void IWixDialogDesignerGenerator.MergeFormChanges(string dialogId, XmlElement dialogElement) |
||||
{ |
||||
DomRegion region = GetTextEditorRegionForDialogElement(dialogId); |
||||
if (region.IsEmpty) { |
||||
ThrowDialogElementCouldNotBeFoundError(dialogId); |
||||
} |
||||
|
||||
var textEditor = view.PrimaryViewContentTextEditor; |
||||
WixTextWriter writer = new WixTextWriter(textEditor.Options); |
||||
WixDialogElement wixDialogElement = (WixDialogElement)dialogElement; |
||||
string newDialogXml = wixDialogElement.GetXml(writer); |
||||
|
||||
WixDocumentEditor editor = new WixDocumentEditor(textEditor); |
||||
editor.Replace(region, newDialogXml); |
||||
} |
||||
|
||||
DomRegion GetTextEditorRegionForDialogElement(string dialogId) |
||||
{ |
||||
WixDocumentReader wixReader = new WixDocumentReader(view.GetDocumentXml()); |
||||
return wixReader.GetElementRegion("Dialog", dialogId); |
||||
} |
||||
|
||||
void ThrowDialogElementCouldNotBeFoundError(string dialogId) |
||||
{ |
||||
string messageFormat = StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}"); |
||||
string message = String.Format(messageFormat, dialogId); |
||||
throw new FormsDesignerLoadException(message); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,155 +1,148 @@
@@ -1,155 +1,148 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.ComponentModel;
|
||||
//using System.ComponentModel.Design.Serialization;
|
||||
//using System.Security.Permissions;
|
||||
//using System.Windows.Forms;
|
||||
//using System.Xml;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.FormsDesigner.Services;
|
||||
//
|
||||
//namespace ICSharpCode.WixBinding
|
||||
//{
|
||||
// [PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")]
|
||||
// [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
|
||||
// public class WixDialogDesignerLoader : BasicDesignerLoader, IComponentCreator
|
||||
// {
|
||||
// WixDialog wixDialog;
|
||||
// IWixDialogDesignerGenerator generator;
|
||||
// IFileLoader fileLoader;
|
||||
// IWixDialogDesigner designer;
|
||||
//
|
||||
// public WixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator)
|
||||
// : this(designer, generator, new DefaultFileLoader())
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Creates a new WixDialogDesignerLoader that will load the specified
|
||||
// /// dialog id from the Wix xml.
|
||||
// /// </summary>
|
||||
// public WixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator, IFileLoader fileLoader)
|
||||
// {
|
||||
// this.designer = designer;
|
||||
// this.generator = generator;
|
||||
// this.fileLoader = fileLoader;
|
||||
//
|
||||
// if (designer == null) {
|
||||
// throw new ArgumentNullException("designer");
|
||||
// }
|
||||
// if (generator == null) {
|
||||
// throw new ArgumentNullException("generator");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public IWixDialogDesigner Designer {
|
||||
// get { return designer; }
|
||||
// }
|
||||
//
|
||||
// public IWixDialogDesignerGenerator Generator {
|
||||
// get { return generator; }
|
||||
// }
|
||||
//
|
||||
// public override void BeginLoad(IDesignerLoaderHost host)
|
||||
// {
|
||||
// VerifyDesignerHasDialogId();
|
||||
//
|
||||
// GetDialogElement();
|
||||
// VerifyDialogElementFound();
|
||||
//
|
||||
// AddServicesToHost(host);
|
||||
//
|
||||
// base.BeginLoad(host);
|
||||
// }
|
||||
//
|
||||
// void VerifyDesignerHasDialogId()
|
||||
// {
|
||||
// if (DesignerHasDialogId) {
|
||||
// ThrowNoDialogSelectedInDocumentException();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// bool DesignerHasDialogId {
|
||||
// get { return designer.DialogId == null; }
|
||||
// }
|
||||
//
|
||||
// void ThrowNoDialogSelectedInDocumentException()
|
||||
// {
|
||||
// string message = StringParser.Parse("${res:ICSharpCode.WixBinding.WixDialogDesigner.NoDialogSelectedInDocumentMessage}");
|
||||
// throw new FormsDesignerLoadException(message);
|
||||
// }
|
||||
//
|
||||
// void GetDialogElement()
|
||||
// {
|
||||
// WixDocument document = CreateWixDocument();
|
||||
// document.LoadXml(designer.GetDocumentXml());
|
||||
// wixDialog = document.CreateWixDialog(designer.DialogId, new WorkbenchTextFileReader());
|
||||
// }
|
||||
//
|
||||
// WixDocument CreateWixDocument()
|
||||
// {
|
||||
// WixDocument document = new WixDocument(designer.Project, fileLoader);
|
||||
// document.FileName = designer.DocumentFileName;
|
||||
// return document;
|
||||
// }
|
||||
//
|
||||
// void VerifyDialogElementFound()
|
||||
// {
|
||||
// if (wixDialog == null) {
|
||||
// ThrowDialogIdNotFoundException(designer.DialogId);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void ThrowDialogIdNotFoundException(string dialogId)
|
||||
// {
|
||||
// string messageFormat = StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}");
|
||||
// string message = String.Format(messageFormat, designer.DialogId);
|
||||
// throw new FormsDesignerLoadException(message);
|
||||
// }
|
||||
//
|
||||
// void AddServicesToHost(IDesignerLoaderHost host)
|
||||
// {
|
||||
// host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
|
||||
// host.AddService(typeof(INameCreationService), new XmlDesignerNameCreationService(host));
|
||||
// host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host));
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Creates a component of the specified type.
|
||||
// /// </summary>
|
||||
// public IComponent CreateComponent(Type componentClass, string name)
|
||||
// {
|
||||
// return base.LoaderHost.CreateComponent(componentClass, name);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Updates the dialog xml element and then passes this to the generator so the
|
||||
// /// Wix document is updated.
|
||||
// /// </summary>
|
||||
// protected override void PerformFlush(IDesignerSerializationManager serializationManager)
|
||||
// {
|
||||
// XmlElement updatedDialogElement = GenerateNewDialogElementFromDesignedForm();
|
||||
// MergeDialogChangesIntoFullWixDocument(updatedDialogElement);
|
||||
// }
|
||||
//
|
||||
// XmlElement GenerateNewDialogElementFromDesignedForm()
|
||||
// {
|
||||
// Form form = (Form)base.LoaderHost.RootComponent;
|
||||
// return wixDialog.UpdateDialogElement(form);
|
||||
// }
|
||||
//
|
||||
// void MergeDialogChangesIntoFullWixDocument(XmlElement updatedDialogElement)
|
||||
// {
|
||||
// generator.MergeFormChanges(designer.DialogId, updatedDialogElement);
|
||||
// }
|
||||
//
|
||||
// protected override void PerformLoad(IDesignerSerializationManager serializationManager)
|
||||
// {
|
||||
// wixDialog.CreateDialog(this);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Security.Permissions; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.FormsDesigner.Services; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
[PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")] |
||||
[PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")] |
||||
public class WixDialogDesignerLoader : BasicDesignerLoader, IComponentCreator |
||||
{ |
||||
WixDialog wixDialog; |
||||
IWixDialogDesignerGenerator generator; |
||||
IFileLoader fileLoader; |
||||
IWixDialogDesigner designer; |
||||
|
||||
/// <summary>
|
||||
/// Creates a new WixDialogDesignerLoader that will load the specified
|
||||
/// dialog id from the Wix xml.
|
||||
/// </summary>
|
||||
public WixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator = null, IFileLoader fileLoader = null) |
||||
{ |
||||
if (designer == null) { |
||||
throw new ArgumentNullException("designer"); |
||||
} |
||||
|
||||
this.designer = designer; |
||||
this.generator = generator ?? new WixDialogDesignerGenerator(designer); |
||||
this.fileLoader = fileLoader ?? new DefaultFileLoader(); |
||||
} |
||||
|
||||
public IWixDialogDesigner Designer { |
||||
get { return designer; } |
||||
} |
||||
|
||||
public IWixDialogDesignerGenerator Generator { |
||||
get { return generator; } |
||||
} |
||||
|
||||
public override void BeginLoad(IDesignerLoaderHost host) |
||||
{ |
||||
VerifyDesignerHasDialogId(); |
||||
|
||||
GetDialogElement(); |
||||
VerifyDialogElementFound(); |
||||
|
||||
AddServicesToHost(host); |
||||
|
||||
base.BeginLoad(host); |
||||
} |
||||
|
||||
void VerifyDesignerHasDialogId() |
||||
{ |
||||
if (DesignerHasDialogId) { |
||||
ThrowNoDialogSelectedInDocumentException(); |
||||
} |
||||
} |
||||
|
||||
bool DesignerHasDialogId { |
||||
get { return designer.DialogId == null; } |
||||
} |
||||
|
||||
void ThrowNoDialogSelectedInDocumentException() |
||||
{ |
||||
string message = StringParser.Parse("${res:ICSharpCode.WixBinding.WixDialogDesigner.NoDialogSelectedInDocumentMessage}"); |
||||
throw new FormsDesignerLoadException(message); |
||||
} |
||||
|
||||
void GetDialogElement() |
||||
{ |
||||
WixDocument document = CreateWixDocument(); |
||||
document.LoadXml(designer.GetDocumentXml()); |
||||
wixDialog = document.CreateWixDialog(designer.DialogId, new WorkbenchTextFileReader()); |
||||
} |
||||
|
||||
WixDocument CreateWixDocument() |
||||
{ |
||||
WixDocument document = new WixDocument(designer.Project, fileLoader); |
||||
document.FileName = designer.DocumentFileName; |
||||
return document; |
||||
} |
||||
|
||||
void VerifyDialogElementFound() |
||||
{ |
||||
if (wixDialog == null) { |
||||
ThrowDialogIdNotFoundException(designer.DialogId); |
||||
} |
||||
} |
||||
|
||||
void ThrowDialogIdNotFoundException(string dialogId) |
||||
{ |
||||
string messageFormat = StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}"); |
||||
string message = String.Format(messageFormat, designer.DialogId); |
||||
throw new FormsDesignerLoadException(message); |
||||
} |
||||
|
||||
void AddServicesToHost(IDesignerLoaderHost host) |
||||
{ |
||||
host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host)); |
||||
host.AddService(typeof(INameCreationService), new XmlDesignerNameCreationService(host)); |
||||
host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host)); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates a component of the specified type.
|
||||
/// </summary>
|
||||
public IComponent CreateComponent(Type componentClass, string name) |
||||
{ |
||||
return base.LoaderHost.CreateComponent(componentClass, name); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the dialog xml element and then passes this to the generator so the
|
||||
/// Wix document is updated.
|
||||
/// </summary>
|
||||
protected override void PerformFlush(IDesignerSerializationManager serializationManager) |
||||
{ |
||||
XmlElement updatedDialogElement = GenerateNewDialogElementFromDesignedForm(); |
||||
MergeDialogChangesIntoFullWixDocument(updatedDialogElement); |
||||
} |
||||
|
||||
XmlElement GenerateNewDialogElementFromDesignedForm() |
||||
{ |
||||
Form form = (Form)base.LoaderHost.RootComponent; |
||||
return wixDialog.UpdateDialogElement(form); |
||||
} |
||||
|
||||
void MergeDialogChangesIntoFullWixDocument(XmlElement updatedDialogElement) |
||||
{ |
||||
generator.MergeFormChanges(designer.DialogId, updatedDialogElement); |
||||
} |
||||
|
||||
protected override void PerformLoad(IDesignerSerializationManager serializationManager) |
||||
{ |
||||
wixDialog.CreateDialog(this); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,35 +1,25 @@
@@ -1,35 +1,25 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.ComponentModel.Design.Serialization;
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//
|
||||
//namespace ICSharpCode.WixBinding
|
||||
//{
|
||||
// public class WixDialogDesignerLoaderProvider : IDesignerLoaderProvider
|
||||
// {
|
||||
// IWixDialogDesigner designer;
|
||||
//
|
||||
// public WixDialogDesignerLoaderProvider()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public DesignerLoader CreateLoader(IDesignerGenerator generator)
|
||||
// {
|
||||
// return new WixDialogDesignerLoader(designer, generator as IWixDialogDesignerGenerator);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Gets or sets the designer that the loader provider should use.
|
||||
// /// </summary>
|
||||
// public IWixDialogDesigner Designer {
|
||||
// get {
|
||||
// return designer;
|
||||
// }
|
||||
// set {
|
||||
// designer = value;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Diagnostics; |
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
public class WixDialogDesignerLoaderProvider : IDesignerLoaderProvider |
||||
{ |
||||
public DesignerLoader CreateLoader(FormsDesignerViewContent viewContent) |
||||
{ |
||||
return new WixDialogDesignerLoader((IWixDialogDesigner)viewContent); |
||||
} |
||||
|
||||
public IReadOnlyList<OpenedFile> GetSourceFiles(FormsDesignerViewContent viewContent) |
||||
{ |
||||
return new[] { viewContent.PrimaryFile }; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,94 +1,94 @@
@@ -1,94 +1,94 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.WixBinding;
|
||||
//using NUnit.Framework;
|
||||
//using System;
|
||||
//using System.ComponentModel;
|
||||
//using System.Windows.Forms;
|
||||
//using WixBinding.Tests.Utils;
|
||||
//
|
||||
//namespace WixBinding.Tests.DialogLoading
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Unit tests for the XmlDesignerLoader.NameCreationService.ValidName method.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class NameCreationServiceValidNameTests
|
||||
// {
|
||||
// XmlDesignerNameCreationService nameCreationService;
|
||||
// MockDesignerLoaderHost loaderHost;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// loaderHost = new MockDesignerLoaderHost();
|
||||
// nameCreationService = new XmlDesignerNameCreationService(loaderHost);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NullName()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName(null));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void EmptyString()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName(String.Empty));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void FirstCharIsDigit()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName("8"));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void FirstCharIsUnderscore()
|
||||
// {
|
||||
// Assert.IsTrue(nameCreationService.IsValidName("_"));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void FirstCharIsNonDigit()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName("a*"));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// [Test]
|
||||
// public void SecondCharIsUnderscore()
|
||||
// {
|
||||
// Assert.IsTrue(nameCreationService.IsValidName("a_"));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SecondCharIsNonDigit()
|
||||
// {
|
||||
// Assert.IsFalse(nameCreationService.IsValidName("a$"));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// [ExpectedException(typeof(Exception), ExpectedMessage = "Invalid name 9")]
|
||||
// public void ValidateNameThrowsExceptionWhenFirstCharIsDigit()
|
||||
// {
|
||||
// nameCreationService.ValidateName("9");
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void FirstTextBoxName()
|
||||
// {
|
||||
// Assert.AreEqual("textBox1", nameCreationService.CreateName(typeof(TextBox)));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void SecondTextBoxName()
|
||||
// {
|
||||
// Component component = new Component();
|
||||
// loaderHost.Container.Add(component, "textBox1");
|
||||
// Assert.AreEqual("textBox2", nameCreationService.CreateName(typeof(TextBox)));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Windows.Forms; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.DialogLoading |
||||
{ |
||||
/// <summary>
|
||||
/// Unit tests for the XmlDesignerLoader.NameCreationService.ValidName method.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class NameCreationServiceValidNameTests |
||||
{ |
||||
XmlDesignerNameCreationService nameCreationService; |
||||
MockDesignerLoaderHost loaderHost; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
loaderHost = new MockDesignerLoaderHost(); |
||||
nameCreationService = new XmlDesignerNameCreationService(loaderHost); |
||||
} |
||||
|
||||
[Test] |
||||
public void NullName() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void EmptyString() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName(String.Empty)); |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstCharIsDigit() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName("8")); |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstCharIsUnderscore() |
||||
{ |
||||
Assert.IsTrue(nameCreationService.IsValidName("_")); |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstCharIsNonDigit() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName("a*")); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void SecondCharIsUnderscore() |
||||
{ |
||||
Assert.IsTrue(nameCreationService.IsValidName("a_")); |
||||
} |
||||
|
||||
[Test] |
||||
public void SecondCharIsNonDigit() |
||||
{ |
||||
Assert.IsFalse(nameCreationService.IsValidName("a$")); |
||||
} |
||||
|
||||
[Test] |
||||
[ExpectedException(typeof(Exception), ExpectedMessage = "Invalid name 9")] |
||||
public void ValidateNameThrowsExceptionWhenFirstCharIsDigit() |
||||
{ |
||||
nameCreationService.ValidateName("9"); |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstTextBoxName() |
||||
{ |
||||
Assert.AreEqual("textBox1", nameCreationService.CreateName(typeof(TextBox))); |
||||
} |
||||
|
||||
[Test] |
||||
public void SecondTextBoxName() |
||||
{ |
||||
Component component = new Component(); |
||||
loaderHost.Container.Add(component, "textBox1"); |
||||
Assert.AreEqual("textBox2", nameCreationService.CreateName(typeof(TextBox))); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,97 +1,103 @@
@@ -1,97 +1,103 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.FormsDesigner.Services;
|
||||
//using ICSharpCode.WixBinding;
|
||||
//using NUnit.Framework;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.ComponentModel;
|
||||
//using System.ComponentModel.Design.Serialization;
|
||||
//using System.Windows.Forms;
|
||||
//using WixBinding.Tests.Utils;
|
||||
//
|
||||
//namespace WixBinding.Tests.Gui
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests that a WixDialogDesignerLoader creates bitmaps specified in the Wix XML.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class BitmapCreatedByDesignerLoaderTestFixture : DialogLoadingTestFixtureBase, IWixDialogDesigner
|
||||
// {
|
||||
// Form formCreated;
|
||||
// MockDesignerLoaderHost loaderHost;
|
||||
//
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetUpFixture()
|
||||
// {
|
||||
// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, new WixDialogDesignerGenerator(), this);
|
||||
// loaderHost = new MockDesignerLoaderHost();
|
||||
// loader.BeginLoad(loaderHost);
|
||||
// IComponent rootComponent = loaderHost.RootComponent;
|
||||
// formCreated = (Form)rootComponent;
|
||||
// }
|
||||
//
|
||||
// [TestFixtureTearDown]
|
||||
// public void TearDownFixture()
|
||||
// {
|
||||
// if (formCreated != null) {
|
||||
// formCreated.Dispose();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void DialogBitmapFileNameRequested()
|
||||
// {
|
||||
// Assert.AreEqual(@"C:\Projects\Setup\Bitmaps\DialogBitmap.bmp", BitmapFileNamesRequested[0]);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void BannerBitmapFileNameRequested()
|
||||
// {
|
||||
// Assert.AreEqual(@"C:\Projects\Setup\Bitmaps\BannerBitmap.bmp", BitmapFileNamesRequested[1]);
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.DialogId {
|
||||
// get {
|
||||
// return "WelcomeDialog";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.GetDocumentXml()
|
||||
// {
|
||||
// return GetWixXml();
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.DocumentFileName {
|
||||
// get {
|
||||
// return @"C:\Projects\Setup\Setup.wxs";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// WixProject IWixDialogDesigner.Project {
|
||||
// get {
|
||||
// WixProject project = WixBindingTestsHelper.CreateEmptyWixProject();
|
||||
// project.SetProperty("DefineConstants", "DATADIR=Bitmaps");
|
||||
// return project;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// string GetWixXml()
|
||||
// {
|
||||
// return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +
|
||||
// "\t<Fragment>\r\n" +
|
||||
// "\t\t<UI>\r\n" +
|
||||
// "\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'>\r\n" +
|
||||
// "\t\t\t\t<Control Id='DialogBitmap' Type='Bitmap' X='10' Y='15' Width='50' Height='50' Text='DialogBitmap.bmp'/>\r\n" +
|
||||
// "\t\t\t\t<Control Id='BannerBitmap' Type='Bitmap' X='10' Y='15' Width='50' Height='50' Text='BannerBitmap.bmp'/>\r\n" +
|
||||
// "\t\t\t</Dialog>\r\n" +
|
||||
// "\t\t</UI>\r\n" +
|
||||
// "\t\t<Binary Id='DialogBitmap.bmp' SourceFile='Bitmaps\\DialogBitmap.bmp'/>\r\n" +
|
||||
// "\t\t<Binary Id='BannerBitmap.bmp' SourceFile='$(var.DATADIR)\\BannerBitmap.bmp'/>\r\n" +
|
||||
// "\t</Fragment>\r\n" +
|
||||
// "</Wix>";
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.FormsDesigner.Services; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Windows.Forms; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that a WixDialogDesignerLoader creates bitmaps specified in the Wix XML.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class BitmapCreatedByDesignerLoaderTestFixture : DialogLoadingTestFixtureBase, IWixDialogDesigner |
||||
{ |
||||
Form formCreated; |
||||
MockDesignerLoaderHost loaderHost; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, fileLoader: this); |
||||
loaderHost = new MockDesignerLoaderHost(); |
||||
loader.BeginLoad(loaderHost); |
||||
IComponent rootComponent = loaderHost.RootComponent; |
||||
formCreated = (Form)rootComponent; |
||||
} |
||||
|
||||
[TestFixtureTearDown] |
||||
public void TearDownFixture() |
||||
{ |
||||
if (formCreated != null) { |
||||
formCreated.Dispose(); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void DialogBitmapFileNameRequested() |
||||
{ |
||||
Assert.AreEqual(@"C:\Projects\Setup\Bitmaps\DialogBitmap.bmp", BitmapFileNamesRequested[0]); |
||||
} |
||||
|
||||
[Test] |
||||
public void BannerBitmapFileNameRequested() |
||||
{ |
||||
Assert.AreEqual(@"C:\Projects\Setup\Bitmaps\BannerBitmap.bmp", BitmapFileNamesRequested[1]); |
||||
} |
||||
|
||||
string IWixDialogDesigner.DialogId { |
||||
get { |
||||
return "WelcomeDialog"; |
||||
} |
||||
} |
||||
|
||||
string IWixDialogDesigner.GetDocumentXml() |
||||
{ |
||||
return GetWixXml(); |
||||
} |
||||
|
||||
string IWixDialogDesigner.DocumentFileName { |
||||
get { |
||||
return @"C:\Projects\Setup\Setup.wxs"; |
||||
} |
||||
} |
||||
|
||||
WixProject IWixDialogDesigner.Project { |
||||
get { |
||||
WixProject project = WixBindingTestsHelper.CreateEmptyWixProject(); |
||||
project.SetProperty("DefineConstants", "DATADIR=Bitmaps"); |
||||
return project; |
||||
} |
||||
} |
||||
|
||||
ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" + |
||||
"\t<Fragment>\r\n" + |
||||
"\t\t<UI>\r\n" + |
||||
"\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'>\r\n" + |
||||
"\t\t\t\t<Control Id='DialogBitmap' Type='Bitmap' X='10' Y='15' Width='50' Height='50' Text='DialogBitmap.bmp'/>\r\n" + |
||||
"\t\t\t\t<Control Id='BannerBitmap' Type='Bitmap' X='10' Y='15' Width='50' Height='50' Text='BannerBitmap.bmp'/>\r\n" + |
||||
"\t\t\t</Dialog>\r\n" + |
||||
"\t\t</UI>\r\n" + |
||||
"\t\t<Binary Id='DialogBitmap.bmp' SourceFile='Bitmaps\\DialogBitmap.bmp'/>\r\n" + |
||||
"\t\t<Binary Id='BannerBitmap.bmp' SourceFile='$(var.DATADIR)\\BannerBitmap.bmp'/>\r\n" + |
||||
"\t</Fragment>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,116 +1,106 @@
@@ -1,116 +1,106 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//using ICSharpCode.SharpDevelop.Gui;
|
||||
//using ICSharpCode.WixBinding;
|
||||
//using NUnit.Framework;
|
||||
//using WixBinding.Tests.Utils;
|
||||
//
|
||||
//namespace WixBinding.Tests.Gui
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests that the WixDialogDesignerDisplayBinding can attach to
|
||||
// /// Wix documents.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class CanAttachToFileNameTestFixture
|
||||
// {
|
||||
// WixDialogDesignerDisplayBinding binding;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// binding = new WixDialogDesignerDisplayBinding();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void WixFileName()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// view.SetFileName("Setup.wxs");
|
||||
// Assert.IsTrue(binding.CanAttachTo(view));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void WixIncludeFileName()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// view.SetFileName("Setup.wxi");
|
||||
// Assert.IsTrue(binding.CanAttachTo(view));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void WixFileNameUppercase()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// view.SetFileName("SETUP.WXS");
|
||||
// Assert.IsTrue(binding.CanAttachTo(view));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NonWixFileName()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// view.SetFileName("Setup.txt");
|
||||
// Assert.IsFalse(binding.CanAttachTo(view));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NonTextEditorProviderView()
|
||||
// {
|
||||
// MockViewContent view = new MockViewContent();
|
||||
// view.SetFileName("Setup.wxs");
|
||||
// Assert.IsFalse(binding.CanAttachTo(view));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void UntitledWixFileName()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// view.SetUntitledFileName("Setup.wxs");
|
||||
// Assert.IsTrue(binding.CanAttachTo(view));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void UntitledNonWixFileName()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// view.SetUntitledFileName("Setup.txt");
|
||||
// Assert.IsFalse(binding.CanAttachTo(view));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NullUntitledFileName()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// view.SetUntitledFileName(null);
|
||||
// Assert.IsFalse(binding.CanAttachTo(view));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NullFileName()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// view.SetFileName(null);
|
||||
// Assert.IsFalse(binding.CanAttachTo(view));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ReattachIsFalse()
|
||||
// {
|
||||
// Assert.IsFalse(binding.ReattachWhenParserServiceIsReady);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void CreatesWixDialogDesigner()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// IViewContent[] views = binding.CreateSecondaryViewContent(view);
|
||||
// Assert.AreEqual(1, views.Length);
|
||||
// Assert.IsTrue(views[0] is WixDialogDesigner);
|
||||
// views[0].Dispose();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the WixDialogDesignerDisplayBinding can attach to
|
||||
/// Wix documents.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class CanAttachToFileNameTestFixture |
||||
{ |
||||
WixDialogDesignerDisplayBinding binding; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
binding = new WixDialogDesignerDisplayBinding(); |
||||
} |
||||
|
||||
[Test] |
||||
public void WixFileName() |
||||
{ |
||||
MockTextEditorViewContent view = new MockTextEditorViewContent(); |
||||
view.SetFileName("Setup.wxs"); |
||||
Assert.IsTrue(binding.CanAttachTo(view)); |
||||
} |
||||
|
||||
[Test] |
||||
public void WixIncludeFileName() |
||||
{ |
||||
MockTextEditorViewContent view = new MockTextEditorViewContent(); |
||||
view.SetFileName("Setup.wxi"); |
||||
Assert.IsTrue(binding.CanAttachTo(view)); |
||||
} |
||||
|
||||
[Test] |
||||
public void WixFileNameUppercase() |
||||
{ |
||||
MockTextEditorViewContent view = new MockTextEditorViewContent(); |
||||
view.SetFileName("SETUP.WXS"); |
||||
Assert.IsTrue(binding.CanAttachTo(view)); |
||||
} |
||||
|
||||
[Test] |
||||
public void NonWixFileName() |
||||
{ |
||||
MockTextEditorViewContent view = new MockTextEditorViewContent(); |
||||
view.SetFileName("Setup.txt"); |
||||
Assert.IsFalse(binding.CanAttachTo(view)); |
||||
} |
||||
|
||||
[Test] |
||||
public void NonTextEditorProviderView() |
||||
{ |
||||
MockViewContent view = new MockViewContent(); |
||||
view.SetFileName("Setup.wxs"); |
||||
Assert.IsFalse(binding.CanAttachTo(view)); |
||||
} |
||||
|
||||
[Test] |
||||
public void UntitledWixFileName() |
||||
{ |
||||
MockTextEditorViewContent view = new MockTextEditorViewContent(); |
||||
view.SetUntitledFileName("Setup.wxs"); |
||||
Assert.IsTrue(binding.CanAttachTo(view)); |
||||
} |
||||
|
||||
[Test] |
||||
public void UntitledNonWixFileName() |
||||
{ |
||||
MockTextEditorViewContent view = new MockTextEditorViewContent(); |
||||
view.SetUntitledFileName("Setup.txt"); |
||||
Assert.IsFalse(binding.CanAttachTo(view)); |
||||
} |
||||
|
||||
[Test] |
||||
public void NullUntitledFileName() |
||||
{ |
||||
MockTextEditorViewContent view = new MockTextEditorViewContent(); |
||||
view.SetUntitledFileName(null); |
||||
Assert.IsFalse(binding.CanAttachTo(view)); |
||||
} |
||||
|
||||
[Test] |
||||
public void NullFileName() |
||||
{ |
||||
MockTextEditorViewContent view = new MockTextEditorViewContent(); |
||||
view.SetFileName(null); |
||||
Assert.IsFalse(binding.CanAttachTo(view)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ReattachIsFalse() |
||||
{ |
||||
Assert.IsFalse(binding.ReattachWhenParserServiceIsReady); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,112 +1,118 @@
@@ -1,112 +1,118 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.FormsDesigner.Services;
|
||||
//using ICSharpCode.WixBinding;
|
||||
//using NUnit.Framework;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.ComponentModel;
|
||||
//using System.ComponentModel.Design.Serialization;
|
||||
//using System.Windows.Forms;
|
||||
//using WixBinding.Tests.Utils;
|
||||
//
|
||||
//namespace WixBinding.Tests.Gui
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests that a WixDialogDesignerLoader uses the dialog id to find the dialog
|
||||
// /// XML element.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class DialogIdSpecifiedForDesignerLoaderTestFixture : IWixDialogDesigner
|
||||
// {
|
||||
// Form formCreated;
|
||||
// MockDesignerLoaderHost loaderHost;
|
||||
//
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetUpFixture()
|
||||
// {
|
||||
// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, new WixDialogDesignerGenerator());
|
||||
// loaderHost = new MockDesignerLoaderHost();
|
||||
// loader.BeginLoad(loaderHost);
|
||||
// IComponent rootComponent = loaderHost.RootComponent;
|
||||
// formCreated = (Form)rootComponent;
|
||||
// }
|
||||
//
|
||||
// [TestFixtureTearDown]
|
||||
// public void TearDownFixture()
|
||||
// {
|
||||
// if (formCreated != null) {
|
||||
// formCreated.Dispose();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void FormName()
|
||||
// {
|
||||
// Assert.AreEqual("WelcomeDialog", formCreated.Name);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void OneComponentCreated()
|
||||
// {
|
||||
// Assert.AreEqual(1, loaderHost.CreatedComponents.Count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NameCreationServiceCreated()
|
||||
// {
|
||||
// INameCreationService nameCreationService = (INameCreationService)loaderHost.GetService(typeof(INameCreationService));
|
||||
// Assert.IsTrue(nameCreationService is XmlDesignerNameCreationService);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void ComponentSerializationServiceCreated()
|
||||
// {
|
||||
// ComponentSerializationService serializationService = (ComponentSerializationService)loaderHost.GetService(typeof(ComponentSerializationService));
|
||||
// Assert.IsTrue(serializationService is ComponentSerializationService);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void DesignerSerializationServiceCreated()
|
||||
// {
|
||||
// IDesignerSerializationService designerSerializationServiceCreated = (IDesignerSerializationService)loaderHost.GetService(typeof(IDesignerSerializationService));
|
||||
// Assert.IsTrue(designerSerializationServiceCreated is DesignerSerializationService);
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.DialogId {
|
||||
// get {
|
||||
// return "WelcomeDialog";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.GetDocumentXml()
|
||||
// {
|
||||
// return GetWixXml();
|
||||
// }
|
||||
//
|
||||
// public string DocumentFileName {
|
||||
// get {
|
||||
// return String.Empty;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public WixProject Project {
|
||||
// get {
|
||||
// return WixBindingTestsHelper.CreateEmptyWixProject();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// string GetWixXml()
|
||||
// {
|
||||
// return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +
|
||||
// "\t<Fragment>\r\n" +
|
||||
// "\t\t<UI>\r\n" +
|
||||
// "\t\t\t<Dialog Id=\"WelcomeDialog\" Height=\"100\" Width=\"200\"/>\r\n" +
|
||||
// "\t\t</UI>\r\n" +
|
||||
// "\t</Fragment>\r\n" +
|
||||
// "</Wix>";
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.FormsDesigner.Services; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Windows.Forms; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that a WixDialogDesignerLoader uses the dialog id to find the dialog
|
||||
/// XML element.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class DialogIdSpecifiedForDesignerLoaderTestFixture : IWixDialogDesigner |
||||
{ |
||||
Form formCreated; |
||||
MockDesignerLoaderHost loaderHost; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this); |
||||
loaderHost = new MockDesignerLoaderHost(); |
||||
loader.BeginLoad(loaderHost); |
||||
IComponent rootComponent = loaderHost.RootComponent; |
||||
formCreated = (Form)rootComponent; |
||||
} |
||||
|
||||
[TestFixtureTearDown] |
||||
public void TearDownFixture() |
||||
{ |
||||
if (formCreated != null) { |
||||
formCreated.Dispose(); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void FormName() |
||||
{ |
||||
Assert.AreEqual("WelcomeDialog", formCreated.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void OneComponentCreated() |
||||
{ |
||||
Assert.AreEqual(1, loaderHost.CreatedComponents.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void NameCreationServiceCreated() |
||||
{ |
||||
INameCreationService nameCreationService = (INameCreationService)loaderHost.GetService(typeof(INameCreationService)); |
||||
Assert.IsTrue(nameCreationService is XmlDesignerNameCreationService); |
||||
} |
||||
|
||||
[Test] |
||||
public void ComponentSerializationServiceCreated() |
||||
{ |
||||
ComponentSerializationService serializationService = (ComponentSerializationService)loaderHost.GetService(typeof(ComponentSerializationService)); |
||||
Assert.IsTrue(serializationService is ComponentSerializationService); |
||||
} |
||||
|
||||
[Test] |
||||
public void DesignerSerializationServiceCreated() |
||||
{ |
||||
IDesignerSerializationService designerSerializationServiceCreated = (IDesignerSerializationService)loaderHost.GetService(typeof(IDesignerSerializationService)); |
||||
Assert.IsTrue(designerSerializationServiceCreated is DesignerSerializationService); |
||||
} |
||||
|
||||
string IWixDialogDesigner.DialogId { |
||||
get { |
||||
return "WelcomeDialog"; |
||||
} |
||||
} |
||||
|
||||
string IWixDialogDesigner.GetDocumentXml() |
||||
{ |
||||
return GetWixXml(); |
||||
} |
||||
|
||||
public string DocumentFileName { |
||||
get { |
||||
return String.Empty; |
||||
} |
||||
} |
||||
|
||||
public WixProject Project { |
||||
get { |
||||
return WixBindingTestsHelper.CreateEmptyWixProject(); |
||||
} |
||||
} |
||||
|
||||
ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" + |
||||
"\t<Fragment>\r\n" + |
||||
"\t\t<UI>\r\n" + |
||||
"\t\t\t<Dialog Id=\"WelcomeDialog\" Height=\"100\" Width=\"200\"/>\r\n" + |
||||
"\t\t</UI>\r\n" + |
||||
"\t</Fragment>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,105 +1,111 @@
@@ -1,105 +1,111 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.WixBinding;
|
||||
//using NUnit.Framework;
|
||||
//using System;
|
||||
//using System.CodeDom;
|
||||
//using System.CodeDom.Compiler;
|
||||
//using System.Collections;
|
||||
//using System.Collections.Generic;
|
||||
//using System.ComponentModel;
|
||||
//using System.Reflection;
|
||||
//using System.Windows.Forms;
|
||||
//using System.Xml;
|
||||
//using WixBinding.Tests.Utils;
|
||||
//
|
||||
//namespace WixBinding.Tests.Gui
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests that a WixDialogDesignerLoader calls the IDesignerGenerator.MergeFormChanges
|
||||
// /// method after being flushed.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class FlushLoaderTestFixture : IWixDialogDesignerGenerator, IWixDialogDesigner
|
||||
// {
|
||||
// class DerivedWixDialogDesignerLoader : WixDialogDesignerLoader
|
||||
// {
|
||||
// public DerivedWixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator)
|
||||
// : base(designer, generator)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public void CallPerformFlush()
|
||||
// {
|
||||
// base.PerformFlush(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// string newDialogTitle;
|
||||
// string dialogId;
|
||||
//
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetUpFixture()
|
||||
// {
|
||||
// newDialogTitle = String.Empty;
|
||||
// dialogId = String.Empty;
|
||||
//
|
||||
// DerivedWixDialogDesignerLoader loader = new DerivedWixDialogDesignerLoader(this, this);
|
||||
// MockDesignerLoaderHost loaderHost = new MockDesignerLoaderHost();
|
||||
// loader.BeginLoad(loaderHost);
|
||||
// using (Form form = (Form)loaderHost.RootComponent) {
|
||||
// form.Text = "NewTitle";
|
||||
// loader.CallPerformFlush();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MergeFormChangesCalled()
|
||||
// {
|
||||
// Assert.AreEqual("NewTitle", newDialogTitle);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void DialogId()
|
||||
// {
|
||||
// Assert.AreEqual("WelcomeDialog", dialogId);
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.DialogId {
|
||||
// get { return "WelcomeDialog"; }
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.GetDocumentXml()
|
||||
// {
|
||||
// return GetWixXml();
|
||||
// }
|
||||
//
|
||||
// public string DocumentFileName {
|
||||
// get { return String.Empty; }
|
||||
// }
|
||||
//
|
||||
// public WixProject Project {
|
||||
// get { return WixBindingTestsHelper.CreateEmptyWixProject(); }
|
||||
// }
|
||||
//
|
||||
// string GetWixXml()
|
||||
// {
|
||||
// return
|
||||
// "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +
|
||||
// "\t<Fragment>\r\n" +
|
||||
// "\t\t<UI>\r\n" +
|
||||
// "\t\t\t<Dialog Id=\"WelcomeDialog\" Height=\"100\" Width=\"200\"/>\r\n" +
|
||||
// "\t\t</UI>\r\n" +
|
||||
// "\t</Fragment>\r\n" +
|
||||
// "</Wix>";
|
||||
// }
|
||||
//
|
||||
// public void MergeFormChanges(string dialogId, XmlElement dialogElement)
|
||||
// {
|
||||
// this.dialogId = dialogId;
|
||||
// newDialogTitle = dialogElement.GetAttribute("Title");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.Reflection; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that a WixDialogDesignerLoader calls the IDesignerGenerator.MergeFormChanges
|
||||
/// method after being flushed.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class FlushLoaderTestFixture : IWixDialogDesignerGenerator, IWixDialogDesigner |
||||
{ |
||||
class DerivedWixDialogDesignerLoader : WixDialogDesignerLoader |
||||
{ |
||||
public DerivedWixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator) |
||||
: base(designer, generator) |
||||
{ |
||||
} |
||||
|
||||
public void CallPerformFlush() |
||||
{ |
||||
base.PerformFlush(null); |
||||
} |
||||
} |
||||
|
||||
string newDialogTitle; |
||||
string dialogId; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
newDialogTitle = String.Empty; |
||||
dialogId = String.Empty; |
||||
|
||||
DerivedWixDialogDesignerLoader loader = new DerivedWixDialogDesignerLoader(this, this); |
||||
MockDesignerLoaderHost loaderHost = new MockDesignerLoaderHost(); |
||||
loader.BeginLoad(loaderHost); |
||||
using (Form form = (Form)loaderHost.RootComponent) { |
||||
form.Text = "NewTitle"; |
||||
loader.CallPerformFlush(); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void MergeFormChangesCalled() |
||||
{ |
||||
Assert.AreEqual("NewTitle", newDialogTitle); |
||||
} |
||||
|
||||
[Test] |
||||
public void DialogId() |
||||
{ |
||||
Assert.AreEqual("WelcomeDialog", dialogId); |
||||
} |
||||
|
||||
string IWixDialogDesigner.DialogId { |
||||
get { return "WelcomeDialog"; } |
||||
} |
||||
|
||||
string IWixDialogDesigner.GetDocumentXml() |
||||
{ |
||||
return GetWixXml(); |
||||
} |
||||
|
||||
public string DocumentFileName { |
||||
get { return String.Empty; } |
||||
} |
||||
|
||||
public WixProject Project { |
||||
get { return WixBindingTestsHelper.CreateEmptyWixProject(); } |
||||
} |
||||
|
||||
ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return |
||||
"<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" + |
||||
"\t<Fragment>\r\n" + |
||||
"\t\t<UI>\r\n" + |
||||
"\t\t\t<Dialog Id=\"WelcomeDialog\" Height=\"100\" Width=\"200\"/>\r\n" + |
||||
"\t\t</UI>\r\n" + |
||||
"\t</Fragment>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
|
||||
public void MergeFormChanges(string dialogId, XmlElement dialogElement) |
||||
{ |
||||
this.dialogId = dialogId; |
||||
newDialogTitle = dialogElement.GetAttribute("Title"); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,35 +1,58 @@
@@ -1,35 +1,58 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.WixBinding;
|
||||
//using NUnit.Framework;
|
||||
//using System;
|
||||
//using WixBinding.Tests.Utils;
|
||||
//
|
||||
//namespace WixBinding.Tests.Gui
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests that the WixDialogDesigner.GetDesigner method returns the
|
||||
// /// Wix dialog designer attached to the primary view.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class GetWixDesignerFromViewTests
|
||||
// {
|
||||
// [Test]
|
||||
// public void WixDesignerAttached()
|
||||
// {
|
||||
// MockTextEditorViewContent view = new MockTextEditorViewContent();
|
||||
// using (WixDialogDesigner designerAdded = new WixDialogDesigner(view)) {
|
||||
// view.SecondaryViewContents.Add(designerAdded);
|
||||
// Assert.IsNotNull(WixDialogDesigner.GetDesigner(view));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NoWixDesignerAttached()
|
||||
// {
|
||||
// MockViewContent view = new MockViewContent();
|
||||
// Assert.IsNull(WixDialogDesigner.GetDesigner(view));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Widgets; |
||||
using ICSharpCode.SharpDevelop.WinForms; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using Rhino.Mocks; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the WixDialogDesigner.GetDesigner method returns the
|
||||
/// Wix dialog designer attached to the primary view.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GetWixDesignerFromViewTests |
||||
{ |
||||
[TestFixtureSetUp] |
||||
public void FixtureSetUp() |
||||
{ |
||||
SD.InitializeForUnitTests(); |
||||
SD.Services.AddService(typeof(IWinFormsService), MockRepository.GenerateStub<IWinFormsService>()); |
||||
SD.WinForms.Stub(s => s.CreateWindowsFormsHost()).IgnoreArguments().Return(new CustomWindowsFormsHost()); |
||||
SD.Services.AddService(typeof(IWorkbench), new MockWorkbench()); |
||||
SD.Services.AddService(typeof(IFileService), MockRepository.GenerateStub<IFileService>()); |
||||
SD.Services.AddService(typeof(IProjectService), MockRepository.GenerateStub<IProjectService>()); |
||||
} |
||||
|
||||
[TestFixtureTearDown] |
||||
public void FixtureTearDown() |
||||
{ |
||||
SD.TearDownForUnitTests(); |
||||
} |
||||
|
||||
[Test] |
||||
public void WixDesignerAttached() |
||||
{ |
||||
MockTextEditorViewContent view = new MockTextEditorViewContent(); |
||||
using (WixDialogDesigner designerAdded = new WixDialogDesigner(view)) { |
||||
view.SecondaryViewContents.Add(designerAdded); |
||||
Assert.IsNotNull(WixDialogDesigner.GetDesigner(view)); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void NoWixDesignerAttached() |
||||
{ |
||||
MockViewContent view = new MockViewContent(); |
||||
Assert.IsNull(WixDialogDesigner.GetDesigner(view)); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,63 +0,0 @@
@@ -1,63 +0,0 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.WixBinding;
|
||||
//using NUnit.Framework;
|
||||
//using System;
|
||||
//using System.ComponentModel.Design.Serialization;
|
||||
//using WixBinding.Tests.Utils;
|
||||
//
|
||||
//namespace WixBinding.Tests.Gui
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class LoaderProviderTests : IWixDialogDesigner
|
||||
// {
|
||||
// [Test]
|
||||
// public void NoDesignerSpecified()
|
||||
// {
|
||||
// WixDialogDesignerLoaderProvider provider = new WixDialogDesignerLoaderProvider();
|
||||
// WixDialogDesignerGenerator generator = new WixDialogDesignerGenerator();
|
||||
// try {
|
||||
// DesignerLoader loader = provider.CreateLoader(generator);
|
||||
// Assert.Fail("Expected an argument exception before this line.");
|
||||
// } catch (ArgumentException ex) {
|
||||
// Assert.AreEqual("designer", ex.ParamName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void DialogIdAndTextEditorSpecified()
|
||||
// {
|
||||
// WixDialogDesignerLoaderProvider provider = new WixDialogDesignerLoaderProvider();
|
||||
// provider.Designer = this;
|
||||
// WixDialogDesignerGenerator generator = new WixDialogDesignerGenerator();
|
||||
// WixDialogDesignerLoader loader = (WixDialogDesignerLoader)provider.CreateLoader(generator);
|
||||
// Assert.IsTrue(loader is WixDialogDesignerLoader);
|
||||
// Assert.AreSame(this, loader.Designer);
|
||||
// Assert.AreSame(generator, loader.Generator);
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.DialogId {
|
||||
// get { return "WelcomeDialog"; }
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.DocumentFileName {
|
||||
// get { return String.Empty; }
|
||||
// }
|
||||
//
|
||||
// WixProject IWixDialogDesigner.Project {
|
||||
// get { return WixBindingTestsHelper.CreateEmptyWixProject(); }
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.GetDocumentXml()
|
||||
// {
|
||||
// return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +
|
||||
// "\t<Fragment>\r\n" +
|
||||
// "\t\t<UI>\r\n" +
|
||||
// "\t\t\t<Dialog Id=\"WelcomeDialog\" Height=\"100\" Width=\"200\"/>\r\n" +
|
||||
// "\t\t</UI>\r\n" +
|
||||
// "\t</Fragment>\r\n" +
|
||||
// "</Wix>";
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,67 +1,75 @@
@@ -1,67 +1,75 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.WixBinding;
|
||||
//using NUnit.Framework;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.ComponentModel;
|
||||
//using System.Resources;
|
||||
//using System.Windows.Forms;
|
||||
//using WixBinding.Tests.Utils;
|
||||
//
|
||||
//namespace WixBinding.Tests.Gui
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests that a WixDialogDesignerLoader reports that the dialog id cannot be found
|
||||
// /// in the Wix document.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class MissingDialogIdDesignerLoaderTestFixture : IWixDialogDesigner
|
||||
// {
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetupFixture()
|
||||
// {
|
||||
// WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// [ExpectedException(typeof(FormsDesignerLoadException), ExpectedMessage = "Unable to find dialog with an id of 'MissingDialog'.")]
|
||||
// public void LoadMissingDialog()
|
||||
// {
|
||||
// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, new WixDialogDesignerGenerator());
|
||||
// MockDesignerLoaderHost loaderHost = new MockDesignerLoaderHost();
|
||||
// loader.BeginLoad(loaderHost);
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.DialogId {
|
||||
// get { return "MissingDialog"; }
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.GetDocumentXml()
|
||||
// {
|
||||
// return GetWixXml();
|
||||
// }
|
||||
//
|
||||
// public string DocumentFileName {
|
||||
// get { return String.Empty; }
|
||||
// }
|
||||
//
|
||||
// public WixProject Project {
|
||||
// get { return WixBindingTestsHelper.CreateEmptyWixProject(); }
|
||||
// }
|
||||
//
|
||||
// string GetWixXml()
|
||||
// {
|
||||
// return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +
|
||||
// "\t<Fragment>\r\n" +
|
||||
// "\t\t<UI>\r\n" +
|
||||
// "\t\t\t<Dialog Id=\"WelcomeDialog\" Height=\"100\" Width=\"200\"/>\r\n" +
|
||||
// "\t\t</UI>\r\n" +
|
||||
// "\t</Fragment>\r\n" +
|
||||
// "</Wix>";
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.Resources; |
||||
using System.Windows.Forms; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that a WixDialogDesignerLoader reports that the dialog id cannot be found
|
||||
/// in the Wix document.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class MissingDialogIdDesignerLoaderTestFixture : IWixDialogDesigner |
||||
{ |
||||
[TestFixtureSetUp] |
||||
public void SetupFixture() |
||||
{ |
||||
SD.InitializeForUnitTests(); |
||||
WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); |
||||
} |
||||
|
||||
[Test] |
||||
[ExpectedException(typeof(FormsDesignerLoadException), ExpectedMessage = "Unable to find dialog with an id of 'MissingDialog'.")] |
||||
public void LoadMissingDialog() |
||||
{ |
||||
WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this); |
||||
MockDesignerLoaderHost loaderHost = new MockDesignerLoaderHost(); |
||||
loader.BeginLoad(loaderHost); |
||||
} |
||||
|
||||
string IWixDialogDesigner.DialogId { |
||||
get { return "MissingDialog"; } |
||||
} |
||||
|
||||
string IWixDialogDesigner.GetDocumentXml() |
||||
{ |
||||
return GetWixXml(); |
||||
} |
||||
|
||||
public string DocumentFileName { |
||||
get { return String.Empty; } |
||||
} |
||||
|
||||
public WixProject Project { |
||||
get { return WixBindingTestsHelper.CreateEmptyWixProject(); } |
||||
} |
||||
|
||||
ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" + |
||||
"\t<Fragment>\r\n" + |
||||
"\t\t<UI>\r\n" + |
||||
"\t\t\t<Dialog Id=\"WelcomeDialog\" Height=\"100\" Width=\"200\"/>\r\n" + |
||||
"\t\t</UI>\r\n" + |
||||
"\t</Fragment>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,69 +1,66 @@
@@ -1,69 +1,66 @@
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.FormsDesigner;
|
||||
//using ICSharpCode.WixBinding;
|
||||
//using NUnit.Framework;
|
||||
//using System;
|
||||
//using System.Resources;
|
||||
//using WixBinding.Tests.Utils;
|
||||
//
|
||||
//namespace WixBinding.Tests.Gui
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Tests that a FormsDesignerLoadException is thrown when the WixDialogDesignerLoader
|
||||
// /// is used when no dialog id is set.
|
||||
// /// </summary>
|
||||
// [TestFixture]
|
||||
// public class NoDialogIdSpecifiedForDesignerLoaderTestFixture : IWixDialogDesigner
|
||||
// {
|
||||
// [TestFixtureSetUp]
|
||||
// public void SetupFixture()
|
||||
// {
|
||||
// WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// [ExpectedException(typeof(FormsDesignerLoadException), ExpectedMessage = "No setup dialog selected in Wix document. Please move the cursor inside a dialog element or use the Setup Dialogs window to open a dialog.")]
|
||||
// public void NoDialogIdSpecified()
|
||||
// {
|
||||
// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, new WixDialogDesignerGenerator());
|
||||
// loader.BeginLoad(new MockDesignerLoaderHost());
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void NoGeneratorSpecified()
|
||||
// {
|
||||
// try {
|
||||
// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, null);
|
||||
// Assert.Fail("Expected an argument exception before this line.");
|
||||
// } catch (ArgumentException ex) {
|
||||
// Assert.AreEqual("generator", ex.ParamName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.DialogId {
|
||||
// get {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// string IWixDialogDesigner.GetDocumentXml()
|
||||
// {
|
||||
// return String.Empty;
|
||||
// }
|
||||
//
|
||||
// public string DocumentFileName {
|
||||
// get {
|
||||
// return String.Empty;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public WixProject Project {
|
||||
// get {
|
||||
// return WixBindingTestsHelper.CreateEmptyWixProject();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.FormsDesigner; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Resources; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that a FormsDesignerLoadException is thrown when the WixDialogDesignerLoader
|
||||
/// is used when no dialog id is set.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class NoDialogIdSpecifiedForDesignerLoaderTestFixture : IWixDialogDesigner |
||||
{ |
||||
[TestFixtureSetUp] |
||||
public void SetupFixture() |
||||
{ |
||||
SD.InitializeForUnitTests(); |
||||
WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); |
||||
} |
||||
|
||||
[Test] |
||||
[ExpectedException(typeof(FormsDesignerLoadException), ExpectedMessage = "No setup dialog selected in Wix document. Please move the cursor inside a dialog element or use the Setup Dialogs window to open a dialog.")] |
||||
public void NoDialogIdSpecified() |
||||
{ |
||||
WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this); |
||||
loader.BeginLoad(new MockDesignerLoaderHost()); |
||||
} |
||||
|
||||
string IWixDialogDesigner.DialogId { |
||||
get { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
string IWixDialogDesigner.GetDocumentXml() |
||||
{ |
||||
return String.Empty; |
||||
} |
||||
|
||||
ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public string DocumentFileName { |
||||
get { |
||||
return String.Empty; |
||||
} |
||||
} |
||||
|
||||
public WixProject Project { |
||||
get { |
||||
return WixBindingTestsHelper.CreateEmptyWixProject(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue