Where are the default WPF Control Templates? [duplicate] - c#

This question already has answers here:
How to Extract Default Control Template In Visual Studio?
(6 answers)
Closed 5 years ago.
The default Control Templates exist, obviously, in binary form in the different DLLs that we add as "References" to each of our projects.
Do they exist in ASCII/source form somewhere? Are they available?
TIA

There are free tools available to explore the templates of the default wpf controls, e.g. Show Me The Template! (there are also tools for control styles, see StyleSnooper).
Alternatively you can explore templates with the following:
private string getTemplate(Control control)
{
StringBuilder stringBuilder = new StringBuilder();
XmlWriterSettings xmlSettings = new XmlWriterSettings();
xmlSettings.Indent = true;
using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, xmlSettings))
{
XamlWriter.Save(control.Template, xmlWriter);
}
return stringBuilder.ToString();
}

They are freely available on MSDN. The "directory" page can be found at:
http://msdn.microsoft.com/en-us/library/aa970773(v=vs.110).aspx
I realize this is a link-only answer, but the answer really is a link...
Currently, googling "WPF Control templates" shows the linked article as the second result. If the link changes, the same search may yield good results.

Related

How to open links in bot framework in a seperate tab

Is there a configuration in the bot framework that makes it open links in a seperate tab?
Looking at this link, seems there is no way to specify in markdown to open a link in a new window and that it is possible using html.
We do not want to specify that long HTML configuration in each link, and we cannot call a function that does that because some of the links appear as a prompt which expects const only (so calling a function is not possible).
Therefore, we are looking for some general configuration in the bot frameowrk that would make links appear in a new window.
Links should open in a new tab by default. There is a GitHub issue tracking this here: https://github.com/Microsoft/BotFramework-WebChat/issues/454
Here is the PullRequest that fixes the issue: configure MarkdownIt to open links in new tab
There is a class in bot framework named CardAction.
If you want to open some link, you should have something like this :
List<CardAction> listButtons = new List<CardAction>();
listButtons.Add(new CardAction
{
Value = "https://google.com",
Type = "openUrl",
Title = "open google",
});

Cannot add icon in shell extension with C#

I've found a very nice tutorial and i am trying to understand something that is not in this tutorial (because the tut itself works fine)
http://www.codeproject.com/Articles/9163/File-Rating-a-practical-example-of-shell-extension
When you look at applications like WinRar, TortoiseSVN, Antivirus-apps and many more, there is an icon next to the Shell Extension Item.
I would like to know how this is done. (Programmatically with C#)
Adding a separator works, adding a submenu works and click+action also works, but i'm struggling with the icon. This cannot be so hard. Can somebody help me?
And please don't say that Microsoft doesn't longer support this in .NET 4.0, because it is not guaranteed and therefore they don't supply samplecode. If all those other apps can do it, then it is possible.
Please supply me some sample code, some tutorials or maybe even a working piece of code.
Please have a look at the following article, it uses .NET 4.0 it to create Windows Shell Extensions using the SharpShell nuget package.
NET Shell Extensions - Shell Context Menus
Using this library, you can set the image directly while creating the contextmenustrip as shown below
protected override ContextMenuStrip CreateMenu()
{
// Create the menu strip.
var menu = new ContextMenuStrip();
// Create a 'count lines' item.
var itemCountLines = new ToolStripMenuItem
{
Text = "Count Lines...",
Image = Properties.Resources.CountLines
};
// When we click, we'll count the lines.
itemCountLines.Click += (sender, args) => CountLines();
// Add the item to the context menu.
menu.Items.Add(itemCountLines);
// Return the menu.
return menu;
}
You only have to add to the following registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Classes*\shellex\ContextMenuHandlers
and here is the code:
string TimeStamp = DateTime.Now.ToString("dd-MM-yyyy");
string key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\*\\shellex\\ContextMenuHandlers\\Winrar";
string valueName = "MyWinrar";
Microsoft.Win32.Registry.SetValue(key, valueName, HERE WHAT YOU WANT TO START, Microsoft.Win32.RegistryValueKind.String);
i hope it works for you!
All the apps you listed use COM and unmanaged code to create overlay icon handlers. There is even a special project TortoiseOverlays that provides a common library for drawing icons for TortoiceCSV, TortoiseSVN and TortoiseGIT. You can take a look at it's source code to find out how it is done. If you want to draw similar icons, you should probably just reuse it.
Using .Net for this type of extensions is not recommended, because when multiple extensions, built against different .Net versions would attempt to load in explorer process, they will crash the explorer.

Sharepoint - upgrade webpart properties

I'm playing with SharePoint 2010 now and have a problem.
There is a feature that is responsible for webparts - it's scope is web. It's needed to update some properties of already created webparts, for example - title.
So I've overridden FeatureUpgrading event and added custom upgrade action into feature manifest - there is no problem here.
In that feature receiver I plan to have a code that should get the file with needed page, check it out, iterate through all the web parts on it, change property and then check in page back.
The problem is that all my webparts appear as ErrorWebPart with empty title.
By the way, if I use the same code in FeatureDeactivating event - everything works good.
The only difference I've noticed - in featureupgrading HttpContext.Current was null. So I've populated it manually but it didn't help.
While googling, the only two advices were: populate HttpContext and ensure that libs with webparts are in GAC. Both conditions are done in my situation.
The sample code from FeatureUpgrading is as proper:
SPUtility.ValidateFormDigest();
web.AllowUnsafeUpdates = true;
var request = new HttpRequest("", web.Url, "");
HttpContext.Current = new HttpContext(request, new HttpResponse(new StringWriter()));
HttpContext.Current.Items["HttpHandlerSPWeb"] = web;
var fileUrl = web.Url + "/pages/sample.aspx";
var file = web.GetFile(fileUrl);
if (file.CheckOutType == SPFile.SPCheckOutType.None)
{
file.CheckOut();
}
using (var webPartsManager = file.GetLimitedWebPartManager(PersonalizationScope.Shared))
{
foreach (WebPart webPart in webPartsManager.WebParts)
{
Console.WriteLine(webPart.GetType().ToString());
}
}
file.CheckIn("System update");
Would appreciate any help. Maybe there is something I'm missing or there is another variant to accomplish described task?
Regards.
Since it is working on Deactivating(), I think the order in which the features are activated is the problem.
You may have to ensure the below:
1. First activate the Feature that adds the webparts
2. Then activate the new feature.
You can change this in package. Or better add a dependency to your new feature.

How Can I Add a New Column to All Document Library Lists in SharePoint 2010 Using Visual Studio 2010?

I can't figure out how to create a solution in Visual Studio 2010 that will allow me to alter existing lists in a SharePoint 2010 site. Specifically, I want to add a new column, which contains a small icon, to existing document library lists. I want to be able to take an action when someone clicks on one of the new icons. I also want this new column to become part of the default view for new document library lists. All of this needs to be easily deployed to a SharePoint 2010 site via a .wsp file.
Extensive searching on Google has shown how to create new lists and new column types, and how to programmatically add columns to one of the new lists, but not how to modify all existing lists.
I'm brand new to SharePoint, and any pointers towards a solution would be much appreciated. Thanks!
If you really want to change all Document Libraries in the site, you could try changing the Content Type:
using (SPSite site = new SPSite("http://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
SPContentType ct = web.ContentTypes[SPBuiltInContentTypeId.Document];
SPField fld = web.Fields.GetField(fldName);
SPFieldLink lnk = new SPFieldLink(fld);
ct.FieldLinks.Add(lnk);
ct.Update(true);
}
}
The above code is shortened and modified from the example of SPContentType.Update Method (Boolean). The MSDN article also has good general information on Updating Content Types.

How do I get latest clearcase label programmatically from C#?

I am trying to put version information to my C# GUI framework retrieved from the latest ClearCase label. This was originally done from Visual Soursafe as below.
vssDB = new VSSDatabaseClass();
vssDB.Open( databaseName, "vssadmin", "vssadmin" );
VSSItem item = vssDB.get_VSSItem( #"$\BuildDCP.bat", false );
foreach(VSSVersion vssVersion in item.get_Versions(0))
{
// Pull the first non-blank label and use that
if ( vssVersion.Label != "" )
{
labelID = vssVersion.Label.ToString();
break;
}
}
I am trying to do something similar using ClearCase since we changed our source code control from VSS to CC. Any help would be greatly appreciated.
Thanks!
I believe this could be better achieved through a script, which would be called from your C# program.
But you may be able to directly call some COM objects, through the CAL interface provided with ClearCase.
The documentation for the interface can be accessed through ClearCase help (Start>Programs>Rational ClearCase>ClearCase Help), where there's an entry for "ClearCase Automation Library (CAL)". An alternate path is to look in the ClearCase/bin directory for "cc_cal.chm".
In VB, with CAL API, that would give something like:
Dim CC As New ClearCase.Application
Dim labelID As String
Set aVersion = CC.Version("[Path-To]\BuildDCP.bat");
Set someLabels = Ver.Labels;
If (someLabels.Count > 0) Then
' the first label listed is the most recently applied
labelID = someLabels.Item(1).Type.Name
EndIf
I really wish that the COM interfaces had better documentation, or were more obvious. Or that the code to ClearCase Explorer or Project Explorer were open source.
I've done a few cool things, but I pretty much started by adding COM references to my C# project, and then started screwing around with the interfaces I found.
Good luck!

Categories

Resources