private void exportTildaShape_Click(object sender, RibbonControlEventArgs e) { setUpFolders(); System.IO.File.WriteAllText(Settings.outputPath + Path.DirectorySeparatorChar + "settings.js", Settings.PresoSettingsToJS()); String js = ""; PowerPoint.PpSelectionType type = Globals.ThisAddIn.Application.ActiveWindow.Selection.Type; if (type == PowerPoint.PpSelectionType.ppSelectionNone || type == PowerPoint.PpSelectionType.ppSelectionText) { MessageBox.Show("You can only export slides right now via selection"); } else if (type == PowerPoint.PpSelectionType.ppSelectionSlides) { foreach (PowerPoint.Slide currentSlide in Globals.ThisAddIn.Application.ActiveWindow.Selection.SlideRange) { TildaSlide slide = new TildaSlide(currentSlide); js += "preso.slides.push(" + slide.exportSlide() + ");"; } export(js); } else if (type == PowerPoint.PpSelectionType.ppSelectionShapes) { /*PowerPoint.Slide currentSlide = Settings.ActiveSlide(); * TildaSlide slide = new TildaSlide(currentSlide); * slide.shapesRange = Globals.ThisAddIn.Application.ActiveWindow.Selection; * js += "preso.slides.push(" + slide.exportSlide() + ");";*/ MessageBox.Show("You can only export slides right now via selection"); } cleanUpFolders(); }
public static bool getSelection(PowerPoint.PpSelectionType selectionType, out PowerPoint.Selection selection) { PowerPoint.Selection _selection = Globals.ThisAddIn.Application.ActiveWindow.Selection; if (_selection.Type == selectionType) { selection = _selection; return(true); } else { System.Windows.Forms.MessageBox.Show( String.Format("You have selected {0}.\nPlease select {1} instead!", getSelectionName(_selection.Type), getSelectionName(selectionType))); selection = _selection; return(false); } }
public static string getSelectionName(PowerPoint.PpSelectionType selectionType) { switch (selectionType) { case Microsoft.Office.Interop.PowerPoint.PpSelectionType.ppSelectionNone: return("nothing"); case Microsoft.Office.Interop.PowerPoint.PpSelectionType.ppSelectionShapes: return("shapes"); case Microsoft.Office.Interop.PowerPoint.PpSelectionType.ppSelectionSlides: return("slides"); case Microsoft.Office.Interop.PowerPoint.PpSelectionType.ppSelectionText: return("text"); default: return("undefined"); } }
private void OnWindowSelectionChanged(Selection Sel) { if (Sel != null) { try { PowerPoint.PpSelectionType type = Sel.Type; if (type == PowerPoint.PpSelectionType.ppSelectionShapes) { selectedShapePositions = new List <int>(0); PowerPoint.ShapeRange range = Sel.ShapeRange; if (range == null) { return; } foreach (PowerPoint.Shape shape in range) { selectedShapePositions.Add(shape.Id); } } else if (type == PowerPoint.PpSelectionType.ppSelectionNone) { if (selectedShapePositions != null && selectedShapePositions.Count > 0) { PowerPoint._Slide slide = GetActiveSlide(); if (slide == null) { return; } foreach (int position in selectedShapePositions) { PowerPoint.Shape shape = getShape(slide.SlideIndex, position); if (shape != null) { continue; } if (ShapeDeleted != null) { ShapeDeleted(slide.SlideNumber, slide.Name, position, "", SlideItemType.NULL, ""); } } selectedShapePositions = new List <int>(0); } } } catch { //PowerPoint._Slide slide = GetActiveSlide(); //if (slide == null) return; //foreach (int position in selectedShapePositions) //{ // if (ShapeDeleted != null) ShapeDeleted(slide.SlideNumber, slide.Name, position, "", SlideItemType.NULL, ""); //} selectedShapePositions = new List <int>(0); } } else { selectedShapePositions = new List <int>(0); } }