I have no idea what the correct name for this UI style is. In MS Access the 'relationships' tool shows the db tables as little movable boxes that can be linked with lines. It's the same with Visio and a few audio apps - boxes that are movable, containing lines of text that can be joined together in a meaningful way.
How could I create a similar thing in .NET using Visual Studio 2008 and C#? I've never created my own controls before.
Here's an image of the sort of thing I mean: Click for example
You'll need two main custom controls: the main view and the table control.
The table control is responsible for drawing itself with all of its columns and ensuring that the item can scroll if need be. It is also responsible for providing an x/y co-ordinate for a specified row header. This is so that the relationship lines can match up to the correct row.
The main view is responsible for accepting a list of table objects (stored in a custom table object), creating the same number of table controls and arranging them in a specified order. It is also responsible for drawing the lines between the table controls.
All in all, this is not trivial. You'll want to override the OnPaint() method of both these controls to do all this custom drawing. Do some research on the GDI+ graphics routines to find out what methods you can use to draw this. You'll probably be using these objects/methods most often:
Pen
SolidBrush
LinearGradientBrush
DrawRectangle()
FillRectangle()
DrawString()
DrawImage()
DrawLine()
DrawPath()
You'll also need to trap all kinds of mouse events to enable moving the controls around. This can be done by overriding methods such as OnMouseDown or OnMouseMove.
Good luck.
The diagram you are trying to draw is an ERD or Database design. What you might also be looking for is a Class Diagram.
What you are trying to do is pretty complex.
Here are some links that might help. These are all open source type UML tools that do diagraming.
http://imar.spaanjaars.com/501/automatically-generating-class-diagrams-from-a-type-using-reflection
http://www.codebydesign.com/
http://sourceforge.net/projects/use-case-maker/
http://projects.gnome.org/dia/
http://www.monouml.org/doku.php?id=documentation
Related
This is more of a "Is it possible (with a reasonable amount of time and work)" than a "how exactly is it possible" question. I'm getting into WPF at the moment and am interested in graphical applications in an MVVM approach. In the meaning of an ms-paint like application. Now I see that and how I can draw e.g. a ractangle on a canvas, store those rectangles in a list etc.
But I am wondering if I can do that more advanced. For example extend the rectangle so I can give it more infos (I can't extend the rectangle itself since it's a sealed class), have existing shapes on the canvas able to drag them around, make the shapes complex (e.g. I double click one to open a new Window that represents the "inside" of that shape) etc.
Is such an application possible with a reasonable amount of work and time in WPF or would I rather use some different library/framework for this?
Yes, It is possible, Actually, you are listing CAD specifications, In fact, I work on this type of technology, so I'll suggest you some resources to have a clue..
Take a look at this project(WPF, 2D)
And this one(WPF, 3D)
And this one(WPF, 2D)
The previous projects are WPF-based, also, you might host a WinForm control in your WPF app, take a look at this one(WinForms, 2D)
If you change the specification a bit and say: "I don't want to edit the drawings on the canvas", then you could go with this option: convert your shapes to PathFigureCollection and EllipseGeometry objects, then construct Paths from these objects and add the Paths to the Canvas, this is a pure WPF approach. Indeed, you can add traditinal controls like TextBlocks as children to your Canvas, I have done such one like this..
Hope it helps.
I want to fill a selected region with a custom hatch that looks like a grid (like a chess table). I tried to use the ANSI37 pattern but its lines are too dense and I could not modify anything visually except the angle of the hatch. Also, I tried the custom hatch pattern creation of autocad but loading the file in autocad or creating a hatch from it in my code always results in error.This is my question: Is there anyway I can create a custom hatch pattern (grid like) that I can control the distance of lines of the grid? Is it possible for me to retrieve the custom hatch object later then query info of its lines? (how many lines, start points and end points, distance between them...)
? Thank you in advance.
About customize the predefined hatch pattern: It is possible to do that, however the properties of the hatch must be defined in a certain order to have actual effect, or else it will be ignored and use the default value instead.
for example: in my case, I defined the value of HatchStyle before PatternScale and PatternSpace while it should be the other way around. Thus, I receive the result from the default values.
About the custom grid lines drawing and querying: I got some ideas from these:
http://adndevblog.typepad.com/autocad/2013/07/create-hatch-objects-using-trace-boundaries-using-net.html
using the Editor.TraceBoudary() method, I can retrieve the loops I needed with the outer most loop will be the last entry in the return DBObjectCollection (a Polyline object to be precise). Then, create the region that needed to be hatched and access its RegionAreaProperty.Extends to get the bottom-left and top-right point of the rectangle that contains my newly created region. After that
, I can implement my logic to draw the lines of the grid.
Note that this method only works on 2d loops ( regions, closed polylines, lines, curves... on Oxy plane). I haven't find a way for the Editor.TraceBoundary() to work with 3d loops yet.
Still open for advices and suggestion for 3d loops and creating custom hatch from a given HatchPattern object.
I'm working on a Add-in for PowerPoint 2010 (C#) and I want to prevent the end-user to move or edit all the shapes that I have programmatically created.
I have already sought in the framework but I think it's not allowed programmaticaly. Has anyone already encountered this kind of limitations and could help me to find a solution?
I know that some people create their add-in thanks to C++ because there are a lot of limitations in office.
I have found two solutions :
The first is to catch all events from the "commandBars.OnUpdate" like this great sample code : http://code.msdn.microsoft.com/CSExcelNewEventForShapes-0e26b1f2#content
Then you can impose the position/the color or everything you want to your shape.
The second one is more "brutal" > unselect immediately the shape. When you catch all the events from the "CommandBars.OnUpdate" do this :
To see which shape is selected :
var selectedShape = this.Application.ActiveWindow.Selection.ShapeRange[1]
In all my shapes, I have set a tag with an ID. I have just to check that there are an ID in the tags of the selectedShape and if this is the case :
this.Application.ActiveWindow.Selection.Unselect();
Then I show a messageBox to warn the user to do not select this kind of shape.
I don't like this solution but it's the only one that I have found and it works.
I believe this is not possible. A way of achieving this to a certain extent (people can work around it if they figure out how to select the shapes below) is by making a transparent rectangle the size of the canvas and binding a custom event to that (like you described in your comment). The transparent rectangle is overlaying the shapes you created so people can no longer access the shapes that way. Of course if they are capable of figuring out how to select the shapes they can move them anyway...
Alternatively, to make people not do stuff like that (you only stop the inexperienced) you can also set them up as master slides.
Only 'real' solution for people not doing that? Images .. but then they can move the image too!
Roughly speaking, I want to create a child class from Excel Chart to add the following features into the child:
add a button to the visual appearance of the chart (the button should have a fixed position relatively to the chart - so if I move chart, the button moves as well). Actually, it doesn't have to be exactly button - it may be anything else which allows clicking on it (or do any other action) and do some activities after the click.
add some additional properties to the chart (these properties doesn't appear vizually but they influence the representation of the time-series). Maybe there is a standard way to customize the set of the properties of Excel Chart?
I don't know to what extent it is possible. Maybe "child class" is not that good idea to serve such simple needs. Maybe VSTO has something, but I can't find anything suitable in the Internet.
Any help will be very much appreciated!
PS
For the subquestion #2 I've decided to use the field TAG to put there an object with additional parameters.
In answer to your first question it is possible to embed a form-control button or a shape in a chart, and have it keep its position relative to the chart area, by cutting and pasting it onto the chart. Use the OnAction property to assign a procedure to the button.
Recorded code (in Excel) is like this:
Sub Macro1()
ActiveSheet.Buttons.Add(166.5, 48, 48, 32.25).Select
Selection.OnAction = ActiveWorkbook.Name & "!TestMacro"
Selection.Cut
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Paste
Selection.ShapeRange.IncrementLeft 10
Selection.ShapeRange.IncrementTop 30
End Sub
It may be possibly to do this programmatically without cutting and pasting, perhaps by adding to the ChartObject's ShapeRange, but I haven't explored this.
I do not know to what extent you can directly subclass an Excel Chart (if at all) and suspect that you might just create a wrapper class for it in C#.
I would like to programmatically(C#) update/replace all shapes of a given visio flowchart(*.vsd). The diagram layout remain the same(all connections, coordinates etc. are the same), but the master-shapes should be different(from different stencil).
Any examples, suggestions and ideas are highly appreciated.
Thanks for your suggestions! The source-diagram has many protected shapes that are grouped(+multiple subshapes), so I guess it will be better, if I take all the information for a given source-shape, and then drop a new master from the target-stencil and set these properties. Next, I would take the next Shape and do the same. I would create a new Visio document, since Iām not sure, whether the source Page-ShapeSheet is not customized someway. But I don't know how to do basic steps programmatically in C# e.g.
how to create new vsd file within C# (maybe
application.Documents.AddEx(āā))
must I then open this document with application.Document.OpenEx, or the document is already open/active
must I create a new Page within this document
-ā¦
In this post: "save and close visio documents visual basic macro
" similar steps explained, but in VBA and not in C#.
I'd suggest just using Visio 2013, which has that function out of the box.
However, that's probably not going to work for you. I've taken two different routes in the past, depending on what differences there were between the original and the replacement shape.
One way to do this is, to copy as many attributes as you can between the shapes, and duplicate the glues and everything. So to do this, you just copy the width, height, pins, etc.., and then step through all the glues in the original shape, and move the glues to the new shape.
The other way, which is a bit cleaner, in my opinion, is wholesale copying all the geometry sections from the original into the destination shape. This makes it so you don't have to worry about glues and formatting and things, and are just copying over the graphics that make up the shape.
If you have a grouped shape with multiple subshapes, it's probably going to be easier to drop a new master out, but if it's just a simple graphic-type shape, copying the geometry is probably better.
One thing to be aware of with the "copy the geometries" method is, you have to make sure any user cells or controls which are precedent to any geometry cells in the new shape also exist in the original shape. Visio's Cell class tells you the precedents for a cell, so this is easy enough to do.
Hope that helps.
I think you can extract some information from these two links and play with it:
Visio shape - get X,Y position
http://msdn.microsoft.com/en-us/library/cc160747.aspx