I hav created a lib which reads an XAML file and generates a HUD for a game. So, now anyone can use WPF projects in visual studio to design and create a simple HUD. After that the XAML file is loaded to my lib and the HUD is created using directX. Thats the basic idea of it.
我创建了一个lib,它读取XAML文件并为游戏生成HUD。所以,现在任何人都可以在visual studio中使用WPF项目来设计和创建一个简单的HUD。之后,XAML文件被加载到我的lib,并使用directX创建HUD。这就是它的基本思想。
Now I want to let users create the XAML file using our own GUI editor project, without creating WPF projects and copy pasting XAML files from those WPF projects for implementing the HUD. So users must be able to,
现在我想让用户使用我们自己的GUI编辑器项目创建XAML文件,而无需创建WPF项目并从这些WPF项目中复制粘贴XAML文件以实现HUD。所以用户必须能够,
- Open Visual Studio and create new project of project type (project template) "Easy HUD Designer" project
- design the HUD using the visual GUI editor.
- Build the project so that it generates an XAML file. (or the XAML could be generated/modified while the GUI is edited, just like in WPF projects)
打开Visual Studio并创建项目类型(项目模板)“Easy HUD Designer”项目的新项目
使用可视化GUI编辑器设计HUD。
构建项目,以便生成XAML文件。 (或者在编辑GUI时可以生成/修改XAML,就像在WPF项目中一样)
How to do this?
这该怎么做?
I was thinking if I can do this using Visual Studio SDK, but could not find any info on creating a visual GUI editor using it. Currently I have VS2008 and VS2010.
我在想是否可以使用Visual Studio SDK执行此操作,但无法找到有关使用它创建可视GUI编辑器的任何信息。目前我有VS2008和VS2010。
If this is not possible or feasible, I think I should consider about creating our own HUD designing software. A completely new application. Any suggestions and info on this is also welcome.
如果这不可能或不可行,我想我应该考虑创建我们自己的HUD设计软件。一个全新的应用程序。任何建议和信息也欢迎。
A somewhat similar question I found : Using the visual studio wpf editor to create an gui not for windows gui
我找到了一个类似的问题:使用visual studio wpf编辑器为windows gui创建一个gui
-- EDIT --
- 编辑 -
I found some hints of doing this by experimenting,
我通过实验找到了一些提示,
- Create Empty C# project
- Add
Presentation Core
,Presentation Framework
andWindows Base
to References - Set project type to library ( so that building the project will not give build errors )
- Add XAML files. ( i copied an XAML file and removed the
x:Class="bla bla.."
attribute from the window tag. )
创建空C#项目
将Presentation Core,Presentation Framework和Windows Base添加到参考
将项目类型设置为库(以便构建项目不会产生构建错误)
添加XAML文件。 (我复制了一个XAML文件并从window标签中删除了x:Class =“bla bla ..”属性。)
This thing can be used as the project template prototype. But I would also like to control what is shown on the ToolBox at the time that user is editing this project. I also want to add the file type XAML to "Add New Item" window so that it will add a new xaml file to the project which has the following code
这个东西可以用作项目模板原型。但我还想控制用户编辑此项目时ToolBox上显示的内容。我还想将文件类型XAML添加到“添加新项”窗口,以便它将新的xaml文件添加到具有以下代码的项目中
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
</Window>
1 个解决方案
#1
0
Found a Solution :) Ensure to have .Net Framework 3.0 or above installed. ( don't need to have C# compilers installed. )
找到解决方案:)确保安装了.Net Framework 3.0或更高版本。 (不需要安装C#编译器。)
- Create your C++ project. ( I guess this could work with other project types too )
- Add a new item the way you normally do ( there are many ways, so just use the way you like ) and that item should be a text file with the extention .xaml ( e.g. "myFile.xaml" )
- Open it in the Visual Studio (See that design area is available but its giving an error)
- Ignore the messages/warnings/errors for a second and Add the following code to your xaml file,
创建您的C ++项目。 (我想这也适用于其他项目类型)
像往常一样添加一个新项目(有很多方法,所以只需使用你喜欢的方式),该项目应该是一个扩展名为.xaml的文本文件(例如“myFile.xaml”)
在Visual Studio中打开它(看到设计区域可用,但它给出了错误)
忽略消息/警告/错误一秒钟,并将以下代码添加到xaml文件中,
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
</Window>
- Close the file and open it again. Goto the design area of the xaml file and see that it is now having the GUI editor capabilities.
关闭文件并再次打开。转到xaml文件的设计区域,看它现在具有GUI编辑器功能。
p.s.
Just in case you are not familiar with WPF, remember to add a Grid tag inside this window tag. Otherwise you cannot add any rectangles or other things and edit them correctly.
附:如果您不熟悉WPF,请记住在此窗口标记内添加Grid标记。否则,您无法添加任何矩形或其他内容并正确编辑它们。
#1
0
Found a Solution :) Ensure to have .Net Framework 3.0 or above installed. ( don't need to have C# compilers installed. )
找到解决方案:)确保安装了.Net Framework 3.0或更高版本。 (不需要安装C#编译器。)
- Create your C++ project. ( I guess this could work with other project types too )
- Add a new item the way you normally do ( there are many ways, so just use the way you like ) and that item should be a text file with the extention .xaml ( e.g. "myFile.xaml" )
- Open it in the Visual Studio (See that design area is available but its giving an error)
- Ignore the messages/warnings/errors for a second and Add the following code to your xaml file,
创建您的C ++项目。 (我想这也适用于其他项目类型)
像往常一样添加一个新项目(有很多方法,所以只需使用你喜欢的方式),该项目应该是一个扩展名为.xaml的文本文件(例如“myFile.xaml”)
在Visual Studio中打开它(看到设计区域可用,但它给出了错误)
忽略消息/警告/错误一秒钟,并将以下代码添加到xaml文件中,
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
</Window>
- Close the file and open it again. Goto the design area of the xaml file and see that it is now having the GUI editor capabilities.
关闭文件并再次打开。转到xaml文件的设计区域,看它现在具有GUI编辑器功能。
p.s.
Just in case you are not familiar with WPF, remember to add a Grid tag inside this window tag. Otherwise you cannot add any rectangles or other things and edit them correctly.
附:如果您不熟悉WPF,请记住在此窗口标记内添加Grid标记。否则,您无法添加任何矩形或其他内容并正确编辑它们。