Currently on my project of ppt addin, I want to know if it is possible tracking shape changes made by the user:
Text Box A Move to ( 210, 100)
Text Box B Change Font to Calibri
Text Box B Change Style to Underline
Delete Text Box C
Add Image A
Resize Image A to 320x240
...
What I know for PPT 2013 there's an AfterShapeSizeChange event so you can know after re-sizing, but I need more than that, which is all possible changes did by the user.
After trying to find out through browsing, here's some possibilities:
Create my own log tracking using SelectionChanged event, but this gonna be tricky if user press CTRL+Z or CTRL+Y
look through undo/redo stack (people says it's impossible...)
Do you need to actually track changes or do you need to be able to detect that a change has been made? Ie, that a given shape isn't exactly the same as it was in the original.
If the latter, how about this:
Write a routine that "touches" each shape in the presentation and adds tags to it, one tag for each property that you want to be able to detect changes to.
Then all you'd need to do is look at each shape's tags and see if the properties stored there match the current properties of the shape.
For example, to tag the shapes:
For each oSl in ActivePresentation.Slides
For each oSh in oSl.Shapes
oSh.Tags.Add "Left", cstr(oSh.Left)
oSh.Tags.Add "Top", cstr(oSh.Top)
Next
Next
I've the same problem.
Let me say, I think the best solution would be serialize the shape to XML (shape state) and save it in the shape it-self. In this way next time you access the shape you can check the current state with the serialized one.
It's possible to save XML in a shape, but you cannot serialize the COM shape in "one command", you have implement your own serialization looking to all shapes properties (!!!! to much I think).
What I did as work-around is: every time the user puts a shape (let's say ShapeA) in the slide a create a shape copy in a specific master page (ShapeA_state1), the new shape holds my ShapeA state. Then I save a reference to that ShapeA_state1 into the ShapeA. In this way when a second time the app access the ShapeA, the app can check if the state is changed looking to the referenced ShapeA_state1. When that happens, ShapeA.1 is updated to ShapeA_edited
Another way to solve this is to add a thread to your program that monitors Application.ActivePresentation.Saved - if it gets set to false you know a change has been made and can look at the selected object or slide - of course you need to add a layer to reset the Saved flag - and pass it back before saving.
I've had no success with accessing the undo information.
I have had good success with adding a mouse hook and intercepting button presses before PPT does - perfect for intercepting things like the PlaySlideShow button before Application_SlideShowBegin and the Next/Prev slides during playback before Application_SlideShowNext* events.
When working out where the button positions you wish to intercept are keep in mind things such as PresenterMode and DPI scale changes.
Related
I'm using the sketch editor to let the user draw and edit polygons on map
I want to let the user the option to move/rotate/resize etc.
when I create polyline/polygone I can do it with no problem as I send the geometry to the sketch editor
but when I want to create a point, I cannot resize and rotate it, only move the point along the map
(because sometimes my point are represented with a symbol, for example, truck)
is such option even exist?
P.S
I know I can go directly to the geometry / SimpleMarkSymbol and change it properties, but that's not an optimal solution for me
I have to use System.Windows.Forms.DataVisualization.Charting.Chart in my project
I created hair cross pair of System.Windows.Forms.DataVisualization.Charting.Cursor() on a chart;
I would like to show or hide these CursorX, CursorY on chart if needed.
The idea is to toggle cursor on chart by DoubleClick event.
I cannot find any property (i.e. CursorX.Visible) or method (i.e. CursorX.hide()) to do it.
To hide, I tried to copy cursor object to global private cursor object and dispose cursor object from chart.ChartArea; to show - [re]create cursor object again from global object.
But it caused more troubles because now I need to check everywhere if cursor object exists
Anybody knows a better way of hiding cursor?
P.S. I also used before National Instruments Measurements Studio chart - that is designed mach better, everything is thought out and much easier...
I found a way:
To make cursor "disappear", set ChartArea[0].CursorX.LineDashStyle to "NotSet"
To [re]appear, set this property to anything else from the choices: "Solid, Dot, Dash, etc."
Example:
chartArea2.CursorX.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
I am trying to create a WPF application using C# to run on Pixelsense that is basic version of the tangram puzzle. I am able to draw my 7 shapes and translate and rotate them all around the screen.
Could anyone give me advise regarding how I should go about saving the pattern (with shapes in specific positions and orientations) so that when a user creates the pattern next time, the application can match it to the saved one and tell the user if it's correct.
It's a pattern matching and recognition problem that I am trying to solve.
I have been stuck on this for a while now :(
Define the solution as a collection of objects with shapeType, position, and orientation properties. Have the solution include one shape at position 0, 0 and an orientation of 0. Now loop over all the shapes the user has actually placed to find the ones with a shapeType that matches the shape your solution has at 0,0,0. Calculate the position and orientation of every other shape relative to where the user put this one. Compare those values to the rest of your solution. You'll need to experiment with how much tolerance to allow because this stuff is not precise - to make the game fun, err on the side of having high tolerances. If needed, you can follow this up with some performance optimizations to only re-evaluate pieces that moved.
Hopefully you are using physical shape prices with tags on them instead of this purely a virtual game. I always wanted to build this when I was on the Surface team but it never happened. One challenge you will run into is defining how the tag's position/orientation relates to the actual shape. If you'll be putting tag stickers on multiple tangram sets, you almost certainly won't get the on precisely the same each time so you may need to add a "calibration" mode to your app (have the user place each piece in a specific spot and then push a button so you can record where the tag is relative to those spots). The TagVisualizer WPF control should help a lot for building your UI - definitely look into using it (this scenario was top of mind when we designed that API). The default behavior of that control (if you tell it the ID of a tag to look for but not how to visualize it) is a "crosshair" that can help you find tune your offset values.
Good luck! If you wouldn't mind recording a YouTube video when you are done and posting a comment here linking to it, I'd really appreciate that
You can use ObservableCollection or List of a custom class. That class can consist of various values such as position, orientation etc as properties.
When a new pattern is drawn or when the pattern change its position you can update that particular object stored in the collection. As you have all the details of the pattern(positions and orientation) you can iterate the for loop and check the position of the new pattern when added.
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 am designing a CAD application using a variation of MVC architecture. My model and view are independent of each other. They communicate through the controller. My problem is if I need to draw an object (say line or polyline) I need a number of input points. What would be the best way to get the points? All the events from the view are subscribed by the controller and controller has to keep the points, then generate the line or polyline and finally add this line to view. But I dont know how capturing the mouse points be done efficiently, because each object will have different number of inputs and different algorithms of input validations.
Any help would be highly appreciated.
I was working in a CAD application 3 years ago, and these are some tips I remembered we have done (BTW: the application is free, you can download it, register your copy, and make use of the features in the Truss Editor):
1- You may add buttons for shape drawing, example: a button for a line, a button for a polyline, a rectangle, ...etc.
2- Create a variable that holds the current state your application (may be an enum): ready, drawing point, drawing line, drawing polyline, drawing circle, ...etc.
3- Wherever the user clicks a drawing button, the system enters a relevant state from those mentioned above.
4- The system returns to the "ready mode" when finished drawing, which can be detected automatically by the expected number of points (1 for point, 2 for line, 3 for ellipse, ...etc) or when the user presses Esc or right-clicked the drawing area (if the expected number of points is unknown, example: polyline). You may also end polyline drawing if the user re-clicked the first point and he has drawn 3+ points.
5- The system may cancel current drawing operation if the user ends the operation before completing the number of expected points.
...
when designing a CAD software, you must not only think of flexibility and dynamic, but also of speed. You should use some kind of wrapper class that works as a very thin layer between you and the hardware driver, it should return stuff like the pixel array of the screen, the current bpp, etc... This is how I would do it (and did actually). Now in C#, seeing as it is a .NET language, I'm not sure you can go that below, but you can still have someking of handler between the controller and your pen object, can't you?