How to create custom WPF ribbon tab for COM AddIn - wpf

I have a shared COM AddIn (not VSTO) for excel 2003, now I want to add a ribbon tab to support excel 2007.
I did some research online.
know that I need reference 2007 PIA, implement
IDTExtensibility2, IRibbonExtensibility in my connection
and IRibbonExtensibility has only one method string GetCustomUI()
string IRibbonExtensibility.GetCustomUI(string RibbonID)
{
return Properties.Resources.Ribbons;
}
I add ribbons.xml in resources, ribbons.xml is as follows:
Not sure if this is the good/right way to do.
I want to customize like add icon to button, largeimage, smallimgae, connect command to button, etc.
I feel in xml, it is hard to do this.
There must be better way to achieve this, please let me know how
thanks

Nope, that's about it when doing a shared addin without vsto.
You MIGHT be able to create a VSTO addin, setup the ribbon using that project, then extract just the ribbon control files and move them to youre shared add in.
In that case, for your GETCUSTOMUI method, you'd have to call the ribbon control to render it's XML manually and pass that on through. I experimented briefly with that several months back but other things came up and I had to leave it.

Related

Best Starting Point for WPF Revit Add in

I am wanting to rewrite one of my Revit Add ins so that it utilizes WPF with MVVM because I like the look and functionality of WPF better than Windows Forms.
I have used the Revit Template Wizzard from Jeremy Tammik for the Form based add in, but adding a WPF user control seems not to work (a run time error that the xaml resource cannot be found).
I found a WPF MVVM revit add in example (AddMaterials, here is the github link, which will add materials from an Excel spreadsheet) but it does not follow what I am expecting to see at the top level.
Revit Add ins have an app.cs file which tells Revit how to register and access the DLL (ribbon panel buttons etc).
A windows WPF app will have app.xaml as the top level entry point.
The Add Materials project has neither which tells me that it must be
a class library, however the views are not using UserControls
rather they are Windows which I prefer. However Visual Studio does not
let you add a Window for a Class Library type project.
The third issue is easily solved by simply copying windows from a WPF application project into a class library project. But I don't really understand how the class library will instantiate in Revit without following the app.cs code from the template. Is anyone else creating add-ins this way, and if so can you let me in on any tricks or discussions that will help? Has anyone created a WPF Revit addin template for Visual Studio?
When I add a WPF window and try to instantiate it I get an error that it cannot find the xaml resource (System.IO.IOException: Cannot locate resource 'xxxx.xaml'). I have tried to fix this according to advice found when googling for this error, but to no avail. I am thinking it comes from being in a form based project, and that I may have to just start with a new project without the form stuff.
I have now verified that indeed you can start with the Revit AddIn Wizzard and use WPF . . . I started from scratch and copied in a window created in another project and got it to run (after adding the various references, namespaces, etc). So my problem seems to just be with the original project which already had a bunch of form stuff added.
Yes, I'm using WPF to create Revit Addins. It works well. You can easily create your own WPF template from the SDK samples:
Start with one of the Autodesk-provided SDK samples. I used the "DockableDialogs" sample. I know this one works, your mileage may vary with the others. If you're looking for windows rather than docked panes in the UI, another sample (perhaps the AddMaterials sample) is probably simpler.
I used Visual Studio to turn the sample into a template. File - Export Template -> select "DockableDialogs" or other WPF sample project.
Create a new project based on the template you just created. This was the easiest method I could find to get the WPF internal bits wired up correctly.
I'm not specifically familiar with the AddMaterials project, but to clarify your bullet points.
Revit Addins - It's not the file name (app.cs) but rather they must extend IExternalApplication or IExternalCommand. If you are creating a xaml interface (rather than just running a command from a ribbon button) you'll use 'IExternalApplication' as your entry point. Look for something like this in the sample:
public class ThisApplication : IExternalApplication ...
I don't used a top level app.xaml, but instead have page.xaml pages which are called by the Revit app. In my case these are Pages rather than Windows, which extend the IDockablePaneProvider class. These must be registered with the application which can then can be show, hide, etc your Panes. I imagine this is simpler with Windows, but haven't done it myself. For the dockable panes, your xaml.cs should start out something like:
public partial class MainPage : Page, Autodesk.Revit.UI.IDockablePaneProvider ...
Yes, the project is a class library in the sense that it is a collection of classes, at least one of which extends IExternalApplication or IExternalCommand. Remember that you're not creating a standalone application, but adding functionality to an existing Windows application (Revit). Revit will instantiate the ThisApplication class and then call its .OnStartup() method when the Revit application starts. This shouldn't stop you from adding .xaml or .cs files to the project, though. I can do it using VS Community 2015 using Ctrl-Shift-A.
Hopefully this gets you started - I've been able to implement a WPF UI in Revit without any prior WPF experience, and I'm not even a real programmer, so it's definitely possible. Good Luck!
addendum
If you want to add WPF elements to an existing revit addin, you can follow the instructions here: How can I connect xaml and xaml.cs files
Ultimately I found it easier to migrate my addin code into a template made from a working sample, you may want to try this approach as well.

Can i implement extreme design elements in my app with Visual Studio, or do i need Blend?

I'm new to Visual Studio and Blend and i'm trying to see their difference. I thought that Blend was ideal for adding more design and interactivity into your app so i chose to use this in order to create an app about a virtual museum (which i wanted to include design and 3d elements).
So far i have created 2 Grids. The 1st Grid contains a sign in or sign up option(along with its design for which i used Blend tools). The 2nd Grid is the registation form which i wanted the user to be redirected to after the user has clicked the sign up button. I'm trying to make the transition from grid 1 to grid 2 like if i had two windows forms, but i can't seem to find how i can do that. Any ideas on how to do it?
I tried to open it into Visual studio and it doesn't seem to respond that well.I suppose i must do something wrong.
So taken the previous difficulties, i'm wondering whether Blend is not necessary to use to create this kind of app and i could simply use standard Visual Studio's windows form without having problem adding design elements.
Thanks in advance
Visual Studio has all that you need to be able to do your interfaces as you want them to be. As Glen Thomas said, you should learn how to code in xaml to create your interface. Visual studio gives you a render of what it looks like in real-time while coding it so it might be helpful to do it this way.

create application like simple PowerPoint in c# wpf?

I want to create create application like simple PowerPoint in c# WPF, I meant exactly that I want to create page like slides and can arrange in time line with various speed and transition and can seeing in preview panel.I tries on Microsoft PowerPoint interoperability but as I found It just create PowerPoint file not provide framework to interact!!.
Please show me sample code or sample way to-do or how do it?
One method I have used is to have a WPF WebBrowser control and then navigate to a pptx file. This will open PowerPoint inside the WebBrowser control. You will not be able to interact with the PowerPoint application from your WPF host, but that is about as good as it gets.
Try this control from syncfusion: http://www.syncfusion.com/products/file-formats/presentation. They now offer a free community version with all if their controls.

Creating a Drag n Drop Designer so users can create a Form?

I'd like to create a way for my users to create Forms so they won't have to ask me to do it. Unfortunately, I am in dark, unknown territory. I envisioned it as the following:User can drag pre-made tables or (pre-made) custom rows.Once the user has created the layout, he will save the layout and deploy to the server.Other users will then be able to access the new Form which will have textboxes, radiobuttons, and checkboxes.Lastly, users will be able to save and load that Form Data anytime they access the Form.
Anyone can point me in the right direction or give me a quick summary of what I'll need to accomplish this task? It will be much appreciated.
At this point, I'd like to do it in WinForms, WPF, or Silverlight. I know the tech is different but the overall approach should be same (I'm hoping).
Rather than building an application for form-filling, consider using Microsoft Infopath.
If Infopath is too expensive to deploy, you may use the form functionality in Microsoft Word instead. Here's a tip to save data from Microsoft Word forms to the database.

How to create a control like Solution Explorer in Visual Studio?

I want to create control that seems and works like the Solution Explorer of Visual Studio.
I mean not the functionality of solution explorer, the control should be seems like that control. That means, server explorer, toolbox, error List,... All these controls will pop-out when we put mouse and pop-in when we leave. We can lock and unlock those controls also.
So can anyone help me, to get the solution for this problem.
Thanks!!!!!!!!!!!
I am assuming you are using C#/VB.NET for development. The dockpanel suite will provide a docking framework for an application. Basically in terms of dockpanel, it is the forms which can be docked on the application using drag and drop like visual studio.
So create a treeview control in the form and dock it to the parent. You can populate the treeview control based on file directories or any specific needs of your project. Please note in dockpanel you create a form by not inheriting from Form class but from DockContent class. Documentation will give you more insight of how to create applications. It has a good example along with the source code in which it simulates the all the visual studio panes. It also provides and option to save the position of various docks which can act as a user preference. For eg, you may like to position solution explorer on left side whereas i may want it on right side. this get stored in a conf file which gets read next time when you start the application.
Incase you using MFC, then visual studio 2008 SP1 provides you with docking framwork and within that use the treeview control.
XAML also provides a docking framework. But i am not sure, you need to verify.
Win32 API does not have any native docking framework.

Resources