Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pen and marker using PowerPoint 2010 interop

I'm new to PowerPoint interop and I'm trying to draw red pen and yellow text marker (not shapes!!!) lines while in presentation mode.

UPDATE:

I can draw a line like this:

settings = presentation.SlideShowSettings; 
window = settings.Run(); 
window.View.DrawLine(startX, startY, endX, endY); 

But the line will always be black and thin. How can I select the red pen or yellow text marker for it?

Aside from the DrawLine method, I can select the pen for the user (mouse cursor becomes a pen instead of arrow) by setting:

window.View.PointerType = PpSlideShowPointerType.ppSlideShowPointerPen;
window.View.PointerColor.RGB = 255;

But how can I set it to text marker? yellow would be 65535, how do I get the text marker style (bigger pen, transparency) instead of the tiny solid pen?

like image 893
Hinek Avatar asked Oct 21 '11 14:10

Hinek


People also ask

How do you use pen in PowerPoint 2010?

Turn on the pen and draw in Slide ShowClick that Pen button, and then choose Pen from the pop-up menu: Click and drag the mouse to draw on the slide. (Optional) To turn off the pen, right-click the slide, point to Pointer Options, and then click Arrow Options and choose the option you prefer.

Why can't I use my pen on PowerPoint?

Add-ins on the PowerPoint application, outdated driver for your pen, and file corruption are a few of the possible reasons why you are having challenges using the digital pen on PowerPoint.

How do you add a draw tab in PowerPoint 2010?

Adding the Draw tab to the RibbonRight-click the Ribbon and select Customize the Ribbon. Check the box next to Draw, then click OK. The Draw tab will now be available in the Ribbon.


1 Answers

  1. Create a WPF window that is transparent and topmost (EDIT: do not maximize window)

    <Window ... Background="#00000000" Topmost="True" ShowInTaskbar="False" WindowStyle="None" AllowsTransparency="True" ResizeMode="NoResize">
    
  2. (NEW) Use GetWindowRect to get the location and size of the slide show window

    [DllImport("user32.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
    [StructLayout(LayoutKind.Sequential)]
    private struct RECT
    {
        public int Left;
        public int Top;
        public int Right;
        public int Bottom;
    }
    
  3. Place the transparent window over the PowerPoint slideshow window

    settings = presentation.SlideShowSettings;
    slideshowWindow = settings.Run();
    
    RECT rect = new RECT();
    GetWindowRect(new IntPtr(slideshowWindow.HWND), ref rect);        
    overlayWindow.Left = rect.Left; // EDIT: do not use slideshowWindow.Left, etc.
    overlayWindow.Top = rect.Top;
    overlayWindow.Width = rect.Width;
    overlayWindow.Height = rect.Height;
    
  4. Put a Canvas into the WPF window and add Polyline objects to it as needed. Text marker lines could be like this:

    line = new Polyline
    {
        Opacity = 0.8,
        Stroke = new SolidColorBrush(Colors.Yellow),
        StrokeThickness = 20
    };
    this.canvas.Children.Add(line);
    

    Add points to line.Points as needed. Call this.canvas.Children.Clear() to clear all your drawings.

It's a workaround but I'd say your best shot.

like image 75
Steffen Schindler Avatar answered Sep 30 '22 05:09

Steffen Schindler