C#/Powerpoint add-in file select and "store" - c#

For one part of the add-in I am creating I would like to add a video file. I am not necessarily trying to show the video in powerpoint, but I need to place this file somewhere for later reference.
So a) can I store the file within the powerpoint file, or b) if I have a relatively positioned file (same folder) could I then access the file easily?
I will be getting the file name from file open dialog.

If you want to embed the you could use the following code to add a new shape containing the video and hide it.
Dim shape As shape
Set shape = Slide.Shapes.AddMediaObject(videofile, 0, 0, -1, -1)
shape.Visible = msoFalse
However, it can be tricky to retrieve the video file later. See How to export movie from Powerpoint 2010 and VBA Export embedded video from Powerpoint presentation.
Or you could read the video data and store it in a slide or shape tag which might be an overkill depending on what you are trying to achieve.
Surely, you could copy the video file to the same directory as the PPT file but it will be lost if you move the PPT file or send it by mail etc.

Related

Access Tools in Save Menu with C#

I use C# to turn ppt files into jpg images but I also want the program to resave the same ppt with compressed pictures and cropped pictures, I want to use settings in Tools menu when saving a file. How can I access them with Microsoft.Office.Interop.PowerPoint?
Sorry, I should clarify. I want to re-save the same ppt but with those settings of compression and cropping. Basically, I want to resave the ppt file and then break it into images. I need a ppt with compressed images in order to save space on the pc.
Right now I use this to save JPGs.
file.SaveCopyAs(outputPath + "CONVERTED.jpg", PowerPoint.PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoTrue);
I may have an answer for you:
In the PPTX file's PPT folder, you'll find a presProps.xml file.
In it, you'll find something like this:
<p:extLst>
<p:ext uri="{E76CE94A-603C-4142-B9EB-6D1370010A27}">
<p14:discardImageEditData xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="0"/>
</p:ext>
<p:ext uri="{D31A062A-798A-4329-ABDD-BBA856620510}">
<p14:defaultImageDpi xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="96"/>
</p:ext>
<p:ext uri="{FD5EFAAD-0ECE-453E-9831-46B23BE46B34}">
<p15:chartTrackingRefBased xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main" val="1"/>
</p:ext>
</p:extLst>
From this, it appears that you could save a copy of the PPTX, change defaultImageDPI and possibly discardImageEditData in the XML, re-open and resave the PPTX from PPT.
It doesn't seem to allow values below 96dpi; set it lower and it reverts to 96 when you open the file in PPT.

C# Wpf embed images at runtime

In my C# WPF application the user have the possibility to import pictures.
Currently the source of the image is referenced to the picture path.
When the picture will be deleted or moved, then my reference is not valid anymore.
How is it managed in applications like Word or Photoshop? Is it possible to embed
the picture at runtime in my custom file? Or should these files copied to a
"image database"?
In Microsoft Word (docx) format. When you paste images in the document, it saves them as file(s). Try this:
Rename the .docx to .zip extension
Extract the zip archive
Now, navigate to the following and you can see all the embeded images here:
You can do something similar for your app. Without knowing the full context and design details its difficult to answer where should the images go.
Generally speaking, images should/could be co-located with the rest of the data that image compliments.

Load .txt data from file explorer to Chart in C#

I have list of array that hold the value of X & Y and it save in .txt file. I also have the button "Load data from computer".
Now i want to create function where when the user click the load button, it will open the file explorer directory, user then able to choose the file. When user click the file, the system will automatically load and plot the data in the .txt files to the chart where the graph are created.
I'm having trouble with this function,can someone help me with this function?
use openfiledialog to open the file explorer
use text reader to read the text file
use any commercial chart control to render the data to chart

Embed image in file

I'm trying to figure out a way to embed an image into a file in c#.
What I'm doing is to create a file with text inside of it (it uses XML) , and I want a quite big image embedded into it which I then can read from the file along with the XML.
But how do I do that?
I can't put an image file along with the file since the file may be used on different computers and I don't want 100's of image files laying around with the files.
Any ideas would be appreciated!

Working with embedded resources

I have an application that works with Visio drawing control and it needs to use a file with shapes for Visio drawing. I want to embed that file (stencil.vss) into my application so that I don't have to provide my stencil file when distributing application. I don't know how to access that file in code. My function needs file path to load that .vss file, so really what I don't know is, when that file is compiled along with application, how can I get it's path, because I need to provide a string as function parameter.
To the best of my recollection, you do need to provide a file system path to the Visio API in order to open a *.vss stencil file.
How are you embedding it in your application? Perhaps you could read it from its embedded location, and write it out to a user app data location, and then reference it after it's written out to disk on a per-user basis.

Categories

Resources