I am working on the example application for a WPF & Silverlight component. As is common with these sorts of example applications, I would like to show C#/Xaml code to the end-user to assist them with creating their own applications with this component.
As a visual example of what I am trying to acheive, see here: http://www.microsoft.com/maps/isdk/silverlight/
This is the Bing Maps SDK example application. Notice how each example there is a tab with "Show Me" - the example, and "Source Code". A screenshot is also included below:
The examples application needs to both compile the source and display the source for both WPF and Silverlight. I don't want to include the source twice, as if the source for an example updates, I want to recompile and the "Source Code" tab should display the updated code.
Consider a typical example may consist of 1..N files in a folder, e.g.
AllExamples/SomeExample
SomeExampleView.xaml
SomeExampleView.xaml.cs
SomeExampleViewModel
SomeExampleConverter
How can I configure my project/solution to pick these source files up and not only compile them, but also get the text to display in the examples app "source code" tab, with the minimum fuss and avoiding copy/passting into a separate file?
Any suggestions welcome :)
Naive solution. Just add post-build event to your project that copies your sources to output directory and your "source code" tab can just read and show these files.
Related
I would really like to use Sublime Text more for light C# coding; however, I would prefer for Sublime Text to identify .NET Classes, Methods, and Property names; and, use colors from my custom color scheme to to highlight them.
I installed "C# Compile and Run" as well as "completion"; however, they didn't make any difference. I'm hoping someone can point me to an addon that could add this enhancement.
I don't program in C#, so I can't speak from personal experience, but a quick Google search turned up the csharp-tmbundle, a language definition for TextMate that should also work for Sublime Text. Go to your Packages folder on the command line (%APPDATA%\Sublime Text X\Packages where X is either 2 or 3) and run
git clone https://github.com/wintermi/csharp-tmbundle.git C#
and you should now have a C# option in the View -> Syntax menu, as well as the syntax menu accessible via the far right option in the status bar. For determining which scopes are currently active under your cursor, I highly recommend the ScopeAlways plugin available via Package Control.
Good luck!
You will have to extend the syntax definitions of the C# language. These are hidden inside .sublime-package files which are basicly zip files. You can use the plugin PackageResourceViewer of which one of the features is that it can extract the files and packages to the Packages directory.
Once you've installed the plugin, open the command palette and type prv to get the Package Resource Viewer options. Choose Open Resource and navigate to the C#. You then need to search for the .tmLanguage file. This will allow you to make changes to the parsing.
See:
http://docs.sublimetext.info/en/latest/reference/syntaxdefs.html
I have a very simple use case.
1) I have 4 config files which are needed for the application to start.
When I publish my application these files should be exported by default along with it. How can I do this ? Where should the files be stored so that they are available when the pplication is installed?
The users of this application should be able to edit and access these files.
I have seen the option of saving it using string source = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
I have tried adding these as resources, but these files need to be editable, hence cannot be in exe.(Reference is this question)
Please comment if you need additional information.
If you're building the installer in Visual Studio, you can add those files as Content and it should be automatically included in the installer when it's built.
You create installers in Visual Studio by adding a Setup Project to the solution.
Link to tutorial on MSDN: http://msdn.microsoft.com/en-us/library/vstudio/19x10e5c(v=vs.100).aspx
I recall it should automatically add all Content items automatically, but I'm a bit rusty. Here's more detail on how to add items to your installer, including desktop shortcuts and such:
http://msdn.microsoft.com/en-us/library/vstudio/z11b431t(v=vs.100).aspx
Good luck!
There are meny ways to do whay you want to do. the main question is why do you want to do it?
if you have a normal program for personal use you can simply link it to the needed file, meaning using the file without actual knowledge that it's there.
if it's for a task then you can zip them together, that way you'll know they are together, without adding them as resource.
for other kind of use, or if you have to add them as resources, just add them like shown here
for more reading on what do you need and how to do it i have here linked vs. Embeded resources
good luck
i have been trying to make something along the lines of this...
I have looked and looked and only found this article.
I am having trouble integrating this into my application. I just started WPF today, so i am learning. I have downloded the window.Shell dLL. What else do i need? Thanks!
If you are looking for a step-by-step guide on how to add this to your application I can give it a try; I just happened to need a bit of a brush-up for a small app, I liked this and gave it a try - it took me about 45 minutes to apply. Cool stuff actually!
First: Download the source application and extract it to your computer.
In it you will find three subfolders. One with the sample application, one named Microsoft.Windows.Shell, one named CustomChromeLibrary. Copy the latter two to the root folder of your project map, add them to your project map (add existing project) and, from your startup project, reference them.
Now open the Window you want to apply CustomChromeLibrary to. You need to change the root from
<Window>
to
<ccl:CustomChromeWindow>
, this is done by using this code as the document root:
<ccl:CustomChromeWindow
Title="YourWindowTitle" Height="268" Width="733" ResizeMode="CanResize"
x:Class="YourNamespace.YourWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
xmlns:ccl="clr-namespace:CustomChromeLibrary;assembly=CustomChromeLibrary"
xmlns:local="clr-namespace:YourNamespace"
>
Pay attention to the last three lines in the sample. These need to be updated to reference the correct libraries; the last one actually referencing to YOUR namespace.
Next you need to update the source code of your window as this is still a simple Window and you will receive an error from it.
Change this
public partial class YourWindow : Window
to this
public partial class YourWindow : CustomChromeLibrary.CustomChromeWindow
You are already half way there!
Next you just need to create the objects for your window (title bar etc.). This is wonderfully done in the sample project No. 5; I did really just copy it.
Take everything from
<shell:WindowChrome.WindowChrome>
<shell:WindowChrome
...
to here
<!--min/max/close buttons-->
<ccl:CaptionButtons/>
Now you can fill your Window like this
<Grid>
The content of your Window goes here
</Grid>
And close the xaml like this
</Grid>
</ccl:CustomChromeWindow>
Now, if you try to run this you will receive another error. There are still three files missing:
The first one you need is a Microsoft file: CaptionButtonRectToMarginConverter.cs; you will also find it in the sample. Copy it to your project and add it (add existing file).
You need to make one change to it:
namespace YourNamespace
{ ...
instead of the sample's namespace.
Finally you need the two xaml files that create the buttons: GlassButton.xaml and GlassIcon.xaml; they can be found in the "Resources" subfolder (and are referenced as resource dictionaries in the xaml). Copy the whole subfolder to your project and add the two files to your project (add existing file).
Now you should finally be able to run your project.
Let's not forget this: Lots of kudos to gbahns, the author of the original article over at codeplex.com!
There are quite a few implementations you can find for a custom chrome.
Another helper library I've seen to one you linked is
MahApps.Metro
Read section 3. It can be setup with Nuget making it more easier to integrate for someone new.
Also section 3.3 3.4 3.5 talk about customising and expanding the MetroWindow control which gives you a custom chrome and also allows adding controls to the chrome title bar
Over in this stack overflow question:
How can I add a button to the WPF caption bar while using custom window chrome?
I was asking about how to insert buttons into the title bar of my Custom Window Chrome window. The xaml example might be enough to help you get going.
Other than that, I'm not sure what you are looking for.
Edit: The button style I have in that other post is a fairly simplistic button, but you should be able to replace it with any styling that you want.
First, please note I am a Java developer, started C# just few weeks back. Here is my question, it is about Visual Studio IDE.
I am using visual studio ide 2008 to create C# projects. I opened a new windows application, added a picture box to the form and now ready to add an image to it. I clicked the small black arrow button in picture box and it opens a dialog where we can put images.
Now, the question comes. In my c# book, they add images using the first option "Local Resource". Anyway, since I have to add number of images, I selected the "Project Resource File" and added all the images to the folder at once. Now I am working smooth without any issue. But, I can see the "Form.resx" file is empty (in my book, they show that file contains all the image files).
I want to know whether what I have done is correct or not. Even though that file is empty, no errors in the program anyway. I don't know whether any issue will occur after the distribution, like missing resources (In Java it normally happens unless otherwise you put all the resources into a new 'Package' inside the project. That's one of reasons I selected the second option when adding the images). Please help!
Your resources will be in a file called Resources.Resx (I think) this can found in your Properties folder in your project file
http://msdn.microsoft.com/en-us/library/7k989cfy(v=vs.80).aspx This link has some information about using Resources
Its better to add the files to the project resource if your going to need them on multiple forms in the project. If they are only going to be required by the current form, you might as well put them in the forms resource file
So anyways, I got a program recently called "SkinBuilder Tool". More specifically "SkinBuilder for Sunisoft Skin Solutions v2".
It can open bitmaps and their own type of "skin" file (file extension is .ssk).
It then "builds" the theme/skin into something that is allegedly applicable to a C# forum, however, when I click build, it just tries to save it as another skin file (.ssk).
So, how do I:
1) Save it to something other than a .SSK that is applicable to my form?
2) Use the .SSK on my form to apply the skin/theme?
When you setup SuniSoft IrisSkin you find an extra control in the control box of visual studio with the name "SkinEngine".
When you use this controls in your application, it affects all forms in this application.
You should choose the .ssk file from the skinfile property of the control, If You used Trial version or Unregistered copy of software then please register first.