Reusing a Control in another Windows Forms Project - winforms

I've got lots of web experience but am a total novice when it comes to Windows Forms so this might be easy to answer:
I have Project1 which I've added a reusable control to which allows filtering and searching of data and presenting results.
I now want to use the same control in another Project.
When I open Project1 and select my form the reusable control appears on the toolbar so I can drag it onto any form in the project, but how do I get this to happen in my new Project?

You can add a reference to the (binary) control:
menu Project/Add Reference/tab Browse
Then it should turn up in the Toolbox (menu View/Toolbox).

Related

After adding a tab control and copying and pasting the text fields + buttons into a tab my windows form no longer works

I'm a C# noobie and have recently made a CRUD app with windows forms and decided to upgrade it a little by adding a tab function to add new functionalities to it but after copying and pasting the design of my windows form into the TabControl field, the design shows up but the CRUD system itself no long works.
I feel like I might need to call the TabControl in the form design code but have no idea how I'd do that. All of my CRUD code was made directly on the WinForm design class.
As #Idle_Mind mentioned in the comments, after pasting controls into the new tab all the events wired to them were wiped. After rewiring them the problem was solved!

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.

Creating portable silverlight user control

I'm trying to make a portable silverlight user control to be used in 2 separate projects: one is WP8 project, and the other is Windows Store.
In both of them I use xaml/C#, and based on silverlight. But the silverlight control I created works only in WP8 but not in Windows Store.
cannot convert from 'Controls.ProfileBox' to 'Windows.UI.Xaml.UIElement'
Is it possible to create a silverlight class library that has a control usable in both projects?
How do you compile your different project?
The easiest way to share your code between framework in c#/xaml is to compile the code in the required farmework:
You need to use the "Add as link" feature (Right click project -> Add Existing Item -> Change "Add" Button to "Add as link"). This way you have only one version of the source file, but you have N project for the N framework you want to compile.

extjs 4.x with Sencha Architect v2.x

We are trying to evaluate extjs 4.x with Sencha Architect v2.x (UI designer) for our in-house sales tracking system. We are able to design and develop each/single modules like user manager, item manager etc as an application for using designer.
However, in order to make entire application work - driven by menu or dashboard and opening each module/application in separate tab, we are not able to make out the appropriate approach. Are we expected to design entire application in single design file which I believe is not practical as we would have more than 50 modules and many UIs.
We want to have something like we have dashboard with tree menu on left and tabs opening on right. On menu click we create a tab (if it does not already added) and open application that was originally designed with designer. E.g. if user clicks on “Sales order” we open sales order tab and so on.
We wanted make sure that we do use designer with model, store. I would appreciate suggestion on reusability of components like models, stores etc.
Ref: http://blog.dnet-ebusiness-suite.com/2012/04/sales-order-to-invoice-and-delivery.html
Architect 2 does not have a single design file. In fact each class has it's own file. You would not need to have separate projects. In fact both the metadata and the source Architect produces is very source control friendly.

Building Visual studio like application, need inputs

I am working on a Visual studio like application i.e. have a toolbox, an editor and property grid similar to VS.
User can drag and drop the controls(custom and third party) to the editor window and perform operations like resize, move, align, group etc.; Properties of that control needs to be displayed in property grid and user can update them from there.
As per my current understanding I will have to extend the Canvas to create my own editor and and Interface for controls which it supports; Each supported control will have to implement this interface so that it can be placed in our editor.
Something similar to this - http://www.codeproject.com/KB/WPF/WPFDiagramDesigner_Part4.aspx
Looking forward for any kind of help, comment or links.
If WPF is a requirement, wait for the VS2010 release and use the Visual Studio Shell in either isolated mode or integrated mode. Otherwise you can use the Visual Studio 2008 Shell isolated or integrated.
You'll get the docking support, addin model, editors with highlight and much more almost for free that way.
Finally, I used the Diagram designer approch to build my application. Although, I had to create my custom property grid which was painful.
Recently I came across following post which suggests that .Net DesignSurface can be used for building this kind of application -
How to create an UI Designer utility?
I have been working on a generic framework Wide to create VS like applications.
Update: Here is the CodeProject article on how to use the framework.
Wide comes with two modules and various out of the box functions:
Core module (Required)
Used for customizable splash screen
Used for Menus (supports regular menus with icon, checkable menus)
Used for Toolbar (menu view model can be reused for toolbars)
Multiple toolbars can be added to the IDE (check demo)
Themes (VS2010, VS2012 Light theme and no theme)
ThemeManager to add/remove themes
Used for Statusbar (in development)
Open file service with participatory handlers (could be based on extension or even file contents)
Save and restore layout along with opening documents
Logger module (For the logging tool)

Resources