I made a prototype of a module in PowerPoint 2010. The module drew some lines and shape on a PowerPoint Chart. I used PowerPoint.Point (the Data Point of a series). According to the MSDN article, Point Interface has the a Point.Left, Point.Top, Point.Height and Point.Width property. I used these properties to calculate the corner points of the each Point.
This worked fine in PowerPoint 2010.
But now due to some change in requirements I have to develop this in PowerPoint 2007 SP3. Microsoft updated the PowerPoint 2007 object model with the release of SP3 and introduced some new objects and interfaces, such as Chart, Series, Point etc. But the Point interface does not have Point.Left, Point.Top, Point.Height and Point.Width property.
I am really stuck at the moment. Is there a way I can get these properties by some other object or some other way? Can I use some other version of Office Interop Assembly dll?
You can get Top value from
powerpoint.DataLable.Top
After moving it to top with orientation property. You can do the same for the height by placing the orientation to bottom and then getting the top value. You can get the left value from
powerpoint.DataLable.Left
after moving its orientation to left. You can then calculate the right value from moving the orientation
It isn't trivial to make a demo sample from scratch to try. But have you tried to use
Point.Select()
and then get Left, Top, Width and Height of the selection (object returned by the call or ActiveWindow.Selection.ShapeRange http://msdn.microsoft.com/en-us/library/bb251483(v=office.12).aspx)?
Related
I have an application with a Microsoft.Maps.MapControl.WPF map, and a few layers added with mapView.Children.Add(layer).
Each of those layers has different types of overlays on it, which are images added with layer.Children.AddChild(image, locationRect).
I want to be able to move, resize and rotate those objects from code (not from xaml which knows nothing about them), but I don't seem to be able to do the first two (rotation being quite simple).
After trial and error and finding some non Microsoft documentation I see that MapLayer.GetPositionRectangle(UIElement) returns the correct location of the object, so it would seem logical that MapLayer.SetPositionRectangle() should set it, but it doesn't and I can't find any examples of anything on the web that programatically moves an object to a new Lat/long.
Is there a way of moving a geographical object on the map, or do I have to either remove it and add it in the right place, or just move it on the canvas in X/Y coords that I have worked out from the lat/long, both of which seem wrong somehow, but this is my first WPF application (normally use forms) and maybe this is the way it is done?
The Windows-universal-samples that exist on Microsoft github page can help you. There is an example of MapControl where you can get some ideas.
This sample demonstrates how to use the universal map control (MapControl) in a UWP app.
MapControl Basics: adjusting the ZoomLevel, Heading, DesiredPtich, and map stype
Adding points of interest on the map: PushPins, images, and shapes
Adding XAML overlays on the map
Showing 3D locations in MapControl
Showing Streetside experience within MapControl
Launching Maps using URI Schemes
Url: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/MapControl
After this example, if there is more question, post here to solve it.
I think, the best way is getting an model for this XAML, where you can update this properties.
What you can do is apply standard transitions to your image through code. you can use the MapLayer.SetPosition to link it to a location on the map. You may want to use an position origin/offset or a margin to align a specific point of the image with the location.
https://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.wpf.maplayer.setposition.aspx
https://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.wpf.maplayer.setpositionorigin.aspx
https://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.wpf.positionorigin.aspx
https://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.wpf.maplayer.setpositionoffset.aspx
I'm working on a LineGraph control which consists many DependencyProperties that affect how the control should display its data. For example, the control contains the following properties to affect its axes:
AxisStroke - Color of the axes.
AxisThickness - Stroke thickness of the axes.
It also contains properties for display numbers & tick marks
VerticalTicks - True/False to indicate whether or not ticks appear along the vertical axis
HorizontalTicks - True/False to indicate whether or not ticks appear along the horizontal axis
VerticalMin - Minimum value on the vertical axis (numeric)
VerticalStep - The distance in between each vertical tick
VerticalMax - Maximum value on the vertical axis (numeric)
HorizontalMin - Minimum value on the horizontal axis (numeric)
HorizontalStep - The distance in between each horizontal tick
HorizontalMax - Maximum value on the horizontal axis (numeric)
And many more properties exist to allow for different line styles on a single graph (LineColor, LineThickness, DataPointShape, and DataPointIcon to name a few).
My goal is to be able to call out my LineGraph in XAML to insert it into a Window. I would like to be able to specify each of these settings inside the XAML as well, and see the new rendered image of the control in the WPF designer.
Now, given there is a lot of geometric shapes to render on the LineGraph, I though using a Canvas would be a good choice to render the data. Unfortunately, when I'm working in XAML, I cannot perform computations for the locations of shapes based on the control's width & height.
And yes, the shapes' locations must be computed because the data points for the graph are dynamic and the tick-related information is dynamic. Not to mention, I would like to display the actual values along each axis of the LineGraph.
So, I thought I might be able to display this control as if I was doing the rendering in C# code. Other windowing frameworks sometimes provide a Render method that can be used for laying out all of the sub-components.
Doing this, however, doesn't seem possible since WPF relies heavily on XAML for the visual appearance of controls. Also, requiring that the WPF designer must display the LineGraph based on the properties and data specified, it doesn't seem like C# code would solve the problem.
I suppose my questions are these:
How can I render data dynamically inside of a WPF control?
Am I able to specify in C# how my control is rendered, allowing the WPF designer to reflect it?
Side Note:
I've done quite a bit of research, but I am only finding information on how to implement more simple types of controls. If you know of any references that contain information on this topic, please feel free to post them in addition to your answers. I will be more than happy to learn how to do this completely.
EDIT:
I've created a graph using Excel to elaborate what the LineGraph control might look like if it has correct data and properties.
I will answer this based on my experience on implementing custom built graphing libraries in WIN32, WinForm, WPF, WinCE, WP8+WinRT, ....and even on a FPGA :)
It's extremely difficult to implement one from scratch. It may seem easy at first but you will run into a lot of "What should I do if this happens?". For example, in your above graph it seems you got a DataPoint # (5,100) it graphs it pretty well. But lets say, I add another DataPoint # (5.000000005, 0). How would you handle that in your code? Would you say that each pixel on the graph represents an exact value on the X-Axis, or does each pixel represent a range of X-Values?
I would recommend that you use an already establish library to do what you want to do unless you need something very specific like lets say you need horizontal cursors on the graph (think Tektronix Oscilloscope) and you need to calculate some values in between the two cursors.. then maybe you need to implement your own custom one or build on top of an open source one.
So, if you are still adamant of creating your own custom control here are answers to your questions.
How can I render data dynamically inside of a WPF control?
You can use a WriteableBitmap and create your own primitive drawing library from that. After you're done rendering, set it as the ImageSource of your control.
Or you can use WriteableBitmapEx which has GDI like drawing functions already implemented for you.
WriteableBitmapEx CodePlex Page, I also think you can just get it from NuGet as well.
You can also use a <Canvas> and add UI elements to that as well.
Am I able to specify in C# how my control is rendered, allowing the WPF designer to reflect it?
This depends on how you create your controls, but yes you can create Properties in your custom control that will appear in the Designer. Allowing you to change it thus updating the display. I would read a lot of tutorials about writing your own custom user control library. They can explain it better than I can in a SO answer. If you implement the properties correctly it should like so.....
Full Size Image: http://i.stack.imgur.com/pmevo.png
After changing the Number of Rows from 15 to 10 and the starting Y offset to -1 (thus moving the graph up and making the rows a lot taller)
Full Size Image: http://i.stack.imgur.com/0RKnA.png
I'm trying to find a way to compute the scroll unit (num. of pixels the screen moves down when u click once on the down arrow in the scrollbar). The msdn documentation for SB_LINEUP says :
Decrements the scroll box position;
scrolls toward the top of the data by
one unit. In each case, a unit is
defined by the application as
appropriate for the data.
Is there anyway for us to find out what the value of 1 scroll unit is, for a given window??
Any help would be appreciated.
Thanks.
Check out SystemInformation.MouseWheelScrollLines Property:
The MouseWheelScrollLines property indicates how many lines to scroll, by default, in a multi-line control that has a scroll bar. The corresponding Platform SDK system-wide parameters are SPI_GETWHEELSCROLLLINES and SPI_SETWHEELSCROLLLINES. For more information about system-wide parameters, see "SystemParametersInfo" in the Platform SDK documentation at http://msdn.microsoft.com.
I've found out a way to find it out. For future reference for others:
hdc = GetDC (hwnd);
// Extract font dimensions from the text metrics.
GetTextMetrics (hdc, &tm);
int pixelCnt= tm.tmHeight + tm.tmExternalLeading;
Ref: http://msdn.microsoft.com/en-us/library/bb787531%28VS.85%29.aspx
i am using in my c# project visio activex to import visio floorplan drawings.
and i need to get the vertices of the shapes in that drawing, and i can't find any method or property for it.
if someone has any ideas please help.
You can use the BoundingBox method on the shape class to retrieve the dimensions of the box around a shape.
This MSDN page will give you more information about the method, it returns the top, bottom, left and right of the box, so it should be possible to work out the vertices from that.
Visio uses a PinX and a PinY to describe the location of a shape using the shapes Height and Width will allow you to calculate the vertices.
I just discovered the imagemap control in Visual Studio 2008.
I'm familiar with the imagemap concept from HTML, I'm just used to having editors that allow you to select areas visually, like drawing a hotspot on the image itself, and the software generates the HTML itself.
But I can't do that in Visual Studio, and I have about 20 different circular hotspots to create.. also I have no idea on how to easily detect coordinates (X & Y).
Any tips? Advice? Ideas?
Added in edit - Also, is there a way to add code to each hotspot in an imagemap?
No, AFAIK there is no designer support for hotspots - I use a piece of paper.
Concerning the code, you'll have to set HotSpotMode="PostBack" PostBackValue="HS1" for each hotspot and use a switch statement in ImageMap1_Click to react to the different Postback values.
You can capture mouse clicks on the imagemap using jQuery, then pass the x, y coordinates of mouseposition to textbox. At the end you can add captured areas to your imagemap.