Esempio n. 1
0
        public static void OpenPresentationToUser(PowerpointLoadInfo info)
        {
            if (!System.IO.File.Exists(info.filePath))
            {
                return;
            }
            PowerpointLoader loader;

            if (PRESENTATIONS.TryGetValue(info.filePath, out loader))
            {
                loader.saveAndClose();
            }

            MsoTriState ofalse = MsoTriState.msoFalse;
            MsoTriState otrue  = MsoTriState.msoTrue;

            PowerPoint.Application PowerPointApplication = new PowerPoint.Application();
            PowerPointApplication.Presentations.Open(@info.filePath, ofalse, ofalse, otrue);

            int currrent = PowerPointApplication.Presentations.Count;

            PowerPoint.Presentation Presentation = PowerPointApplication.Presentations[currrent];

            //if (Presentation != null) Presentation.Close();
            if (PowerPointApplication == null)
            {
                return;
            }
            if (PowerPointApplication.Presentations.Count == 0)
            {
                PowerPointApplication.Quit();
            }
        }
Esempio n. 2
0
        public override void Convert(string inputFilePath, FormatInfo format, string outputFilePath, string password)
        {
            base.Convert(inputFilePath, format, outputFilePath, password);

            MsoAutomationSecurity originalAutomationSecurity = this._application.AutomationSecurity;

            this._application.AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityForceDisable;

            string      sourceFileName = inputFilePath;
            MsoTriState openReadonly   = MsoTriState.msoTrue;
            MsoTriState untitled       = MsoTriState.msoFalse;
            MsoTriState withWindow     = MsoTriState.msoFalse;

            PowerPoint.Presentation presentation = this._application.Presentations.Open(sourceFileName, openReadonly, untitled, withWindow);

            string targetFileName = outputFilePath;

            PowerPoint.PpSaveAsFileType saveFormat = (PowerPoint.PpSaveAsFileType)format.SaveFormat;
            MsoTriState embedTrueTypeFonts         = MsoTriState.msoTriStateMixed;

            presentation.SaveAs(targetFileName, saveFormat, embedTrueTypeFonts);

            presentation.Close();

            this._application.AutomationSecurity = originalAutomationSecurity;
        }
Esempio n. 3
0
        public void OpenExists(string path, bool readOnly = false, bool visible = false)
        {
            MsoTriState readOnlyState = readOnly ? MsoTriState.msoTrue : MsoTriState.msoFalse;
            MsoTriState visibleState  = visible ? MsoTriState.msoTrue : MsoTriState.msoFalse;

            _presentation = _app.Presentations.Open(path, readOnlyState, MsoTriState.msoTrue, visibleState);
        }
Esempio n. 4
0
        ShowOrHideImagesInColumn
        (
            Workbook workbook,
            String worksheetName,
            String imageColumnName,
            Boolean show
        )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(!String.IsNullOrEmpty(worksheetName));
            Debug.Assert(!String.IsNullOrEmpty(imageColumnName));

            Worksheet oWorksheet;

            if (!ExcelUtil.TryGetWorksheet(workbook, worksheetName,
                                           out oWorksheet))
            {
                return;
            }

            MsoTriState eVisible = show ?
                                   MsoTriState.msoTrue : MsoTriState.msoFalse;

            foreach (Microsoft.Office.Interop.Excel.Shape oImage in
                     GetImagesInColumn(oWorksheet, imageColumnName).Values)
            {
                oImage.Visible = eVisible;
            }
        }
Esempio n. 5
0
 public void Distribute(MsoDistributeCmd distributeCmd, MsoTriState relativeTo)
 {
     object[] paramArray = new object[2];
     paramArray[0] = distributeCmd;
     paramArray[1] = relativeTo;
     InstanceType.InvokeMember("Distribute", BindingFlags.InvokeMethod, null, ComReference, paramArray, XlLateBindingApiSettings.XlThreadCulture);
 }
Esempio n. 6
0
 public PositionShapeProperties(System.Drawing.PointF position, float rotation, MsoTriState flipHorizontalState, MsoTriState flipVerticalState)
 {
     this._position            = position;
     this._rotation            = rotation;
     this._flipHorizontalState = flipHorizontalState;
     this._flipVerticalState   = flipVerticalState;
 }
Esempio n. 7
0
        /// <summary>把Word文件转换成为PDF格式文件</summary>   
        /// <param name="sourcePath">源文件路径</param>
        /// <param name="targetPath">目标文件路径</param>
        /// <returns>true=转换成功</returns>
        public static bool PowerPointToHtml(string sourcePath, string targetPath)
        {
            bool result = false;

            try
            {
                //Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType targetFileType = Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.;
                Microsoft.Office.Interop.PowerPoint.Application ppt = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Core.MsoTriState m1 = new MsoTriState();
                Microsoft.Office.Core.MsoTriState m2 = new MsoTriState();
                Microsoft.Office.Core.MsoTriState m3 = new MsoTriState();
                Microsoft.Office.Interop.PowerPoint.Presentation pp = ppt.Presentations.Open(sourcePath, m1, m2, m3);
                pp.SaveAs(targetPath, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML, Microsoft.Office.Core.MsoTriState.msoTriStateMixed);
                pp.Close();
                ppt.Quit();
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
                return(false);
            }
        }
Esempio n. 8
0
        ///<summary>
        /// 将PPT文件转换为HTML文件
        ///</summary>
        ///<param name="source_path">PPT文件路径(绝对)</param>
        ///<param name="target_path">生成的Html文件路径(绝对),路径的目录结构必须存在,否则保存失败</param>
        ///<returns>是否执行成功</returns>
        public static bool PowerPointToHtml(string source_path, string target_path)
        {
            PowerPoint.Application ppt = new PowerPoint.Application();
            MsoTriState            m1  = new MsoTriState();
            MsoTriState            m2  = new MsoTriState();
            MsoTriState            m3  = new MsoTriState();

            PowerPoint.Presentation pp = null;
            try
            {
                if (File.Exists(target_path))
                {
                    File.Delete(target_path);
                }
                pp = ppt.Presentations.Open(source_path, m1, m2, m3);
                pp.SaveAs(target_path, PowerPoint.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTriStateMixed);
                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                try
                {
                    pp.Close();
                }
                catch { }
                //Thread.Sleep(3000);
            }
        }
Esempio n. 9
0
 public MsoTriState getMsoTriState(int dbVal)
 {
     //int dbVal = Convert.ToInt32(dt.Rows[0]["FillVisible"]);
     try
     {
         if (dbVal == 1)
         {
             objValue = MsoTriState.msoCTrue;
         }
         else if (dbVal == 0)
         {
             objValue = MsoTriState.msoFalse;
         }
         else if (dbVal == -2)
         {
             objValue = MsoTriState.msoTriStateMixed;
         }
         else if (dbVal == -3)
         {
             objValue = MsoTriState.msoTriStateToggle;
         }
         else if (dbVal == -1)
         {
             objValue = MsoTriState.msoTrue;
         }
     }
     catch (Exception err)
     {
         string errtext = err.Message;
         PPTAttribute.ErrorLog(errtext, "getMsoTriState");
     }
     return(objValue);
 }
Esempio n. 10
0
 public void ScaleWidth(Single factor, MsoTriState relativeToOriginalSize)
 {
     object[] paramArray = new object[2];
     paramArray[0] = factor;
     paramArray[1] = relativeToOriginalSize;
     InstanceType.InvokeMember("ScaleWidth", BindingFlags.InvokeMethod, null, ComReference, paramArray, XlLateBindingApiSettings.XlThreadCulture);
 }
Esempio n. 11
0
 public void Align(MsoAlignCmd alignCmd, MsoTriState relativeTo)
 {
     object[] paramArray = new object[2];
     paramArray[0] = alignCmd;
     paramArray[1] = relativeTo;
     InstanceType.InvokeMember("Align", BindingFlags.InvokeMethod, null, ComReference, paramArray, XlLateBindingApiSettings.XlThreadCulture);
 }
Esempio n. 12
0
 public static MsoTriState changeState(MsoTriState state)
 {
     if (state == MsoTriState.msoTrue)
     {
         return MsoTriState.msoFalse;
     }
     return MsoTriState.msoTrue;
 }
Esempio n. 13
0
 public static MsoTriState changeState(MsoTriState state)
 {
     if (state == MsoTriState.msoTrue)
     {
         return(MsoTriState.msoFalse);
     }
     return(MsoTriState.msoTrue);
 }
        public override void SyncFormat(Shape formatShape, Shape newShape)
        {
            MsoTriState lockState = newShape.LockAspectRatio;

            newShape.LockAspectRatio = MsoTriState.msoFalse;
            newShape.Height          = formatShape.Height;
            newShape.LockAspectRatio = lockState;
        }
Esempio n. 15
0
 /// <summary>
 /// Initializes the Button Form
 /// </summary>
 private void InitButton()
 {
     //initialize everything
     buttonform = new ButtonForm(pptController, basicform);
     // set it to "initialized but hidden"
     isButtonHidden           = MsoTriState.msoTrue;
     buttonform.ShowInTaskbar = false;
 }
Esempio n. 16
0
        public static void SyncFormat(Shape formatShape, Shape newShape)
        {
            MsoTriState lockState = newShape.LockAspectRatio;

            newShape.LockAspectRatio = MsoTriState.msoFalse;
            newShape.Width           = formatShape.Width;
            newShape.LockAspectRatio = lockState;
        }
Esempio n. 17
0
 /// <summary>
 /// This method adds a Picture Object into the current slide
 /// </summary>
 /// <param name="picPath"></param>
 /// <param name="LinkToFile"></param>
 /// <param name="saveWithDocument"></param>
 /// <param name="left"></param>
 /// <param name="top"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public void AddPic(String picPath, MsoTriState LinkToFile,
                    MsoTriState saveWithDocument, float left, float top,
                    float width, float height)
 {
     objSlide.Shapes.AddPicture(picPath, LinkToFile, saveWithDocument,
                                left, top, width, height);
     oCount++;
 }
        public void AdjustAreaProportionally(PowerPoint.ShapeRange selectedShapes)
        {
            MsoTriState isAspectRatio = selectedShapes.LockAspectRatio;
            bool        isLockedRatio = isAspectRatio == MsoTriState.msoTrue;

            selectedShapes.LockAspectRatio = MsoTriState.msoFalse;
            AdjustActualAreaProportionally(selectedShapes, isLockedRatio);
            selectedShapes.LockAspectRatio = isAspectRatio;
        }
Esempio n. 19
0
        //private Boolean CompareGroupPerms()
        //{
        //    Boolean compare = false;
        //    string fileId = GetFileId("Excel Schedule.xlsx");
        //    List<string> groupId = GetGroupId("4");
        //    //CheckWriteOnlyGroup("4", "Excel Schedule.xlsx");
        //    for (int i = 0; i < groupId.Count; i++)
        //    {
        //        if (CheckWriteOnlyGroup(fileId, groupId[i]) == "True")
        //        {
        //            compare = true;
        //        }
        //        else
        //        {
        //            compare = false;
        //        }
        //    }
        //}

        private void CheckPpt()
        {
            string      fileName = @"C:\Users\Solomon\Documents\TEST\trided.pptx";
            MsoTriState readOnly = MsoTriState.msoFalse;
            object      missing  = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.PowerPoint.Application applicationPPT = new Microsoft.Office.Interop.PowerPoint.Application();
            applicationPPT.Presentations.Open(fileName, readOnly, MsoTriState.msoTrue, MsoTriState.msoTrue);
        }
Esempio n. 20
0
        public override void Convert(string inputFilePath, FormatInfo format, string outputFilePath, string password)
        {
            base.Convert(inputFilePath, format, outputFilePath, password);

            MsoAutomationSecurity originalAutomationSecurity = this._application.AutomationSecurity;

            this._application.AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityForceDisable;

            string tempFilePath = Converter.GetTempFileName(".pptx");

            if (this.Options.UseAddin && Path.GetExtension(inputFilePath) == ".odp")
            {
                // convert odp to pptx
                this.ConvertWithOdfConverter(inputFilePath, tempFilePath);
                inputFilePath = tempFilePath;
            }

            string      sourceFileName = inputFilePath;
            MsoTriState openReadonly   = MsoTriState.msoTrue;
            MsoTriState untitled       = MsoTriState.msoFalse;
            MsoTriState withWindow     = MsoTriState.msoFalse;

            PowerPoint.Presentation presentation = this._application.Presentations.Open(sourceFileName, openReadonly, untitled, withWindow);

            string targetFileName = outputFilePath;

            PowerPoint.PpSaveAsFileType saveFormat = (PowerPoint.PpSaveAsFileType)format.SaveFormat;
            MsoTriState embedTrueTypeFonts         = MsoTriState.msoTriStateMixed;

            string tempFilePath2 = Converter.GetTempFileName(".pptx");

            if (this.Options.UseAddin && format.SaveFormat == (int)PowerPoint.PpSaveAsFileType.ppSaveAsOpenDocumentPresentation)
            {
                // export to odt using addin
                saveFormat = PowerPoint.PpSaveAsFileType.ppSaveAsOpenXMLPresentation;
                string tempOpenXmlDocument = tempFilePath2;
                presentation.SaveAs(tempOpenXmlDocument, saveFormat, embedTrueTypeFonts);
                presentation.Close();

                this.ConvertWithOdfConverter(tempFilePath2, outputFilePath);
            }
            else
            {
                presentation.SaveAs(targetFileName, saveFormat, embedTrueTypeFonts);
                presentation.Close();
            }

            if (File.Exists(tempFilePath))
            {
                File.Delete(tempFilePath);
            }
            if (File.Exists(tempFilePath2))
            {
                File.Delete(tempFilePath2);
            }
            this._application.AutomationSecurity = originalAutomationSecurity;
        }
Esempio n. 21
0
        public static void ShowPresentationToUser(PowerpointLoadInfo info)
        {
            //if (!System.IO.File.Exists(info.filePath)) return;
            PowerpointLoader loader;

            if (PRESENTATIONS.TryGetValue(info.filePath, out loader))
            {
                loader.saveAndClose();
            }

            MsoTriState ofalse = MsoTriState.msoFalse;
            MsoTriState otrue  = MsoTriState.msoTrue;

            PowerPoint.Application PowerPointApplication = new PowerPoint.Application();
            PowerPointApplication.Presentations.Open(@loader.FilePath, otrue, otrue, ofalse);

            int currrent = PowerPointApplication.Presentations.Count;

            PowerPoint.Presentation Presentation = PowerPointApplication.Presentations[currrent];

            int avanceTime = 2;
            int countSlide = Presentation.Slides.Count;

            int[] SlideIdx = new int[countSlide];
            for (int i = 0; i < countSlide; i++)
            {
                SlideIdx[i] = i + 1;
            }
            PowerPoint.SlideRange range = Presentation.Slides.Range(SlideIdx);
            range.SlideShowTransition.AdvanceOnTime = MsoTriState.msoTrue;
            range.SlideShowTransition.AdvanceTime   = avanceTime;
            range.SlideShowTransition.EntryEffect   = PowerPoint.PpEntryEffect.ppEffectBoxOut;

            Presentation.SlideShowSettings.StartingSlide = 1;
            Presentation.SlideShowSettings.EndingSlide   = countSlide;
            //Presentation.Save();
            Presentation.SlideShowSettings.Run();

            //long wait = (countSlide * avanceTime) * 1000;

            //Wait for the slide show to end.
            //while (PowerPointApplication.SlideShowWindows.Count >= 1)
            //    System.Threading.Thread.Sleep(1000);

            //if (Presentation != null) Presentation.Close();
            if (PowerPointApplication == null)
            {
                return;
            }
            if (PowerPointApplication.Presentations.Count == 0)
            {
                PowerPointApplication.Quit();
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Initializes the Basic Form
        /// </summary>
        private void InitBasic()
        {
            //initialize everything
            basicform = new BasicForm(pptController);
            // set it to "initialized but hidden"
            isBasicHidden           = MsoTriState.msoTrue;
            basicform.ShowInTaskbar = false;

            //TEST FIXME TODO -- also initialize cornerform
            // fix : this should be in a separate method
            cornerform = new CornerForm(basicform);
        }
Esempio n. 23
0
        private static void SyncShapeSize(Shape refShape, Shape candidateShape)
        {
            // unlock aspect ratio to enable size tweak
            MsoTriState candidateLockRatio = candidateShape.LockAspectRatio;

            candidateShape.LockAspectRatio = MsoTriState.msoFalse;

            candidateShape.Width  = refShape.Width;
            candidateShape.Height = refShape.Height;

            candidateShape.LockAspectRatio = candidateLockRatio;
        }
Esempio n. 24
0
 /// <summary>
 /// Add text to the slide, change the font
 /// </summary>
 /// <param name="Text"></param>
 /// <param name="fontName"></param>
 /// <param name="fontSize"></param>
 /// <param name="left"></param>
 /// <param name="top"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public void AddText(String Text, String fontName, float fontSize, MsoTriState isBold, MsoTriState isItalic, MsoTriState isUnderlined, float left, float top,
                     float width, float height)
 {
     //Add text to the slide, change the font
     objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, left, top, width, height);
     objTextRng                = objSlide.Shapes[oCount++].TextFrame.TextRange;
     objTextRng.Text           = Text;
     objTextRng.Font.Name      = fontName;
     objTextRng.Font.Size      = fontSize;
     objTextRng.Font.Bold      = isBold;
     objTextRng.Font.Italic    = isItalic;
     objTextRng.Font.Underline = isUnderlined;
 }
Esempio n. 25
0
        public static bool StateTobool(MsoTriState state)
        {
            if (state == MsoTriState.msoFalse)
            {
                return(false);
            }
            else if (state == MsoTriState.msoTrue)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 26
0
        public static TextRange setItalic(TextRange textRange)
        {
            string text = textRange.Text;

            if (text.Contains("<i"))
            {
                MsoTriState state = MsoTriState.msoFalse;
                foreach (TextRange tr in textRange.Characters())
                {
                    tr.Font.Italic = state;
                    if (tr.Text == ">")
                    {
                        state = changeState(state);
                    }
                }

                foreach (TextRange trr in textRange.Runs())
                {
                    Console.WriteLine("RUN: " + trr.Text);
                    trr.Text = trr.Text.Replace("<i>", "").Replace("</i>", "");
                }
                return(textRange);
            }

            if (text.Contains("#"))
            {
                MsoTriState state = MsoTriState.msoFalse;
                foreach (TextRange tr in textRange.Characters())
                {
                    tr.Font.Italic = state;
                    if (tr.Text == "#")
                    {
                        state   = changeState(state);
                        tr.Text = "";
                    }
                }
                return(textRange);
            }

            /* int c = 0;
             * for (int e = 0; e < s.Length; e++)
             * {
             *   if (slideText[e] == '#')
             *   {
             *       c++;
             *   }
             * }*/
            return(null);
        }
Esempio n. 27
0
        public PowerpointLoader(String FilePath)
        {
            this.FilePath = FilePath;
            MsoTriState ofalse = MsoTriState.msoFalse;

            //MsoTriState otrue = MsoTriState.msoTrue;
            if (PowerPointApplication == null)
            {
                PowerPointApplication = new PowerPoint.Application();
            }
            PowerPointApplication.Presentations.Open(@FilePath, ofalse, ofalse, ofalse);
            int currrent = PowerPointApplication.Presentations.Count;

            PowerPointPresentation = PowerPointApplication.Presentations[currrent];
        }
        ShowOrHideSubgraphImages
        (
            Workbook workbook,
            Boolean show
        )
        {
            Debug.Assert(workbook != null);

            MsoTriState eVisible = show ?
                                   MsoTriState.msoTrue : MsoTriState.msoFalse;

            foreach (Microsoft.Office.Interop.Excel.Shape oSubgraphImage in
                     EnumerateSubgraphImages(workbook))
            {
                oSubgraphImage.Visible = eVisible;
            }
        }
        /// <summary>
        /// Resize the selected shapes to the same size (width and height) with
        /// the reference to first selected shape.
        /// </summary>
        /// <param name="selectedShapes"></param>
        public void ResizeToSameHeightAndWidth(PowerPoint.ShapeRange selectedShapes)
        {
            MsoTriState isAspectRatio = selectedShapes.LockAspectRatio;

            selectedShapes.LockAspectRatio = MsoTriState.msoFalse;
            switch (ResizeType)
            {
            case ResizeBy.Visual:
                ResizeVisualShapes(selectedShapes, Dimension.HeightAndWidth);
                break;

            case ResizeBy.Actual:
                ResizeActualShapes(selectedShapes, Dimension.HeightAndWidth);
                break;
            }
            selectedShapes.LockAspectRatio = isAspectRatio;
        }
Esempio n. 30
0
 private void stop_Click(object sender, RibbonControlEventArgs e)
 {
     if (activeAlready == MsoTriState.msoTrue || backgroundWorker1.IsBusy)
     {
         backgroundWorker1.CancelAsync();
         activeAlready = MsoTriState.msoCTrue;
         System.Windows.Forms.MessageBox.Show("Remote disconnected.",
                                              "Information",
                                              System.Windows.Forms.MessageBoxButtons.OK,
                                              System.Windows.Forms.MessageBoxIcon.Information);
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Not connected.",
                                              "Information",
                                              System.Windows.Forms.MessageBoxButtons.OK,
                                              System.Windows.Forms.MessageBoxIcon.Information);
     }
 }
Esempio n. 31
0
        public void drawText(eObject obj)
        {
            int Left   = obj.x1 * Constant.cardWidth / 100;
            int Top    = obj.y1 * Constant.cardHeight / 100;
            int Width  = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            RichTextBox txtText = new RichTextBox();

            try
            {
                txtText.LoadFile(Constant.ePath + obj.data, RichTextBoxStreamType.RichText);
                //txtText.LoadFile("C:\\Program Files\\eFlash\\Data\\Media\\" + obj.data, RichTextBoxStreamType.RichText);
            }
            catch (Exception e)
            {
                MessageBox.Show("file not found");
            }

            MsoTriState isItalic     = MsoTriState.msoFalse;
            MsoTriState isBold       = MsoTriState.msoFalse;
            MsoTriState isUnderlined = MsoTriState.msoFalse;

            if (txtText.Font.Italic)
            {
                isItalic = MsoTriState.msoTrue;
            }
            if (txtText.Font.Bold)
            {
                isBold = MsoTriState.msoTrue;
            }
            if (txtText.Font.Underline)
            {
                isUnderlined = MsoTriState.msoTrue;
            }
            //byte r = txtText.ForeColor.R;
            //byte g = txtText.ForeColor.G;
            //byte b = txtText.ForeColor.B;
            //int col = 256 * 256 * r + 256 * g + b;

            ppt.AddText(txtText.Text, txtText.Font.Style.ToString(), txtText.Font.Size * PPTFONTMULTIPLIER, isBold, isItalic, isUnderlined, Left, Top, Width, Height);
        }
Esempio n. 32
0
 public void ScaleWidth(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom fScale = MsoScaleFrom.msoScaleFromTopLeft)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Select the specified object.
 /// </summary>
 /// <param name="replace"></param>
 public void Select(MsoTriState replace)
 {
     _shape.Select(replace);
 }
 /// <summary>对齐指定形状区域中的形状。
 /// </summary>
 /// <param name="AlignCmd">指定某个指定形状范围中形状的对齐方式。</param>
 /// <param name="RelativeTo">不在 Microsoft Excel 中使用。必须为 False。</param>
 public void Align(MsoAlignCmd AlignCmd, MsoTriState RelativeTo)
 {
     _objaParameters = new object[2] { AlignCmd, RelativeTo };
     _objShapeRange.GetType().InvokeMember("Align", BindingFlags.InvokeMethod, null, _objShapeRange, _objaParameters);
 }
 /// <summary>水平或垂直地分布指定的形状区域中的各形状。
 /// </summary>
 /// <param name="DistributeCmd">指定该范围内的形状是水平分布还是垂直分布。</param>
 /// <param name="RelativeTo">不在 Microsoft Excel 中使用。必须为 False。</param>
 public void Distribute(MsoDistributeCmd DistributeCmd, MsoTriState RelativeTo)
 {
     _objaParameters = new object[2] { DistributeCmd, RelativeTo };
     _objShapeRange.GetType().InvokeMember("Distribute", BindingFlags.InvokeMethod, null, _objShapeRange, _objaParameters);
 }
        /// <summary>按指定的比例调整形状的宽度。对于图片和 OLE 对象,可以指定是相对于原有尺寸还是相对于当前尺寸来调整该形状。对于不是图片和 OLE 对象的形状,总是相对于其当前大小来调整宽度。
        /// </summary>
        /// <param name="Factor">指定形状调整后的宽度与当前或原始宽度的比例。例如,若要将一个矩形放大百分之五十,请将此参数设为 1.5。</param>
        /// <param name="RelativeToOriginalSize">如果为 False,则相对于形状的原有尺寸来调整宽度。仅当指定的形状是图片或 OLE 对象时,才能将此参数指定为 True。</param>
        /// <param name="Scale">MsoScaleFrom 的常量之一,它指定调整形状大小时,该形状哪一部分的位置将保持不变。</param>
        public void ScaleWidth(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom? Scale = null)
        {
            _objaParameters = new object[3] {
                Factor,
                RelativeToOriginalSize,
                Scale == null ? System.Type.Missing : Scale
            };

            _objShapeRange.GetType().InvokeMember("ScaleWidth", BindingFlags.InvokeMethod, null, _objShapeRange, _objaParameters);
        }
        /// <summary>现有文件创建图片。返回一个代表新图片的 Shape 对象。
        /// </summary>
        /// <param name="Filename">要在其中创建 OLE 对象的文件。</param>
        /// <param name="LinkToFile">要链接至的文件。</param>
        /// <param name="SaveWithDocument">将图片与文档一起保存。</param>
        /// <param name="Left">图片左上角相对于文档左上角的位置(以磅为单位)。</param>
        /// <param name="Top">图片左上角相对于文档顶部的位置(以磅为单位)。</param>
        /// <param name="Width">图片的宽度(以磅为单位)。</param>
        /// <param name="Height">图片的高度(以磅为单位)。</param>
        /// <returns></returns>
        public Shape AddPicture(string Filename, MsoTriState LinkToFile, MsoTriState SaveWithDocument, double Left, double Top, double Width, double Height)
        {
            _objaParameters = new object[7] { Filename, LinkToFile, SaveWithDocument, Left, Top, Width, Height };
            object objShape = _objShapes.GetType().InvokeMember("AddPicture", BindingFlags.InvokeMethod, null, _objShapes, _objaParameters);

            return new Shape(objShape);
        }
Esempio n. 38
0
 /// <summary>
 /// This method adds a Picture Object into the current slide
 /// </summary>
 /// <param name="picPath"></param>
 /// <param name="LinkToFile"></param>
 /// <param name="saveWithDocument"></param>
 /// <param name="left"></param>
 /// <param name="top"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public void AddPic(String picPath, MsoTriState LinkToFile,
     MsoTriState saveWithDocument, float left, float top,
     float width, float height)
 {
     objSlide.Shapes.AddPicture(picPath, LinkToFile, saveWithDocument,
         left, top, width, height);
     oCount++;
 }
Esempio n. 39
0
 public static bool ToBool(MsoTriState state)
 {
     return state == MsoTriState.msoTrue;
 }
 public void InsertPicture(string fileName, MsoTriState linkToFile, MsoTriState saveWithDoc,
                           Tuple<Single, Single> leftTopCorner)
 {
     _slide.Shapes.AddPicture(fileName, linkToFile, saveWithDoc, leftTopCorner.Item1, leftTopCorner.Item2).Select();
 }
Esempio n. 41
0
 public TextRange2 Replace(string FindWhat, string ReplaceWhat, int After = 0, MsoTriState MatchCase = MsoTriState.msoFalse, MsoTriState WholeWords = MsoTriState.msoFalse)
 {
     throw new NotImplementedException();
 }
Esempio n. 42
0
 public TextRange2 InsertSymbol(string FontName, int CharNumber, MsoTriState Unicode = MsoTriState.msoFalse)
 {
     throw new NotImplementedException();
 }
Esempio n. 43
0
 /// <summary>
 /// Add text to the slide, change the font
 /// </summary>
 /// <param name="Text"></param>
 /// <param name="fontName"></param>
 /// <param name="fontSize"></param>
 /// <param name="left"></param>
 /// <param name="top"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public void AddText(String Text, String fontName, float fontSize, MsoTriState isBold, MsoTriState isItalic, MsoTriState isUnderlined, float left, float top,
     float width, float height)
 {
     //Add text to the slide, change the font
     objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, left, top, width, height);
     objTextRng = objSlide.Shapes[oCount++].TextFrame.TextRange;
     objTextRng.Text = Text;
     objTextRng.Font.Name = fontName;
     objTextRng.Font.Size = fontSize;
     objTextRng.Font.Bold = isBold;
     objTextRng.Font.Italic = isItalic;
     objTextRng.Font.Underline = isUnderlined;
 }
Esempio n. 44
0
 public void Select(MsoTriState Replace = MsoTriState.msoTrue)
 {
     throw new NotImplementedException();
 }
        /// <summary>创建艺术字对象。返回一个代表新艺术字对象的 Shape 对象。
        /// 说明:
        /// 向文档添加艺术字对象时,该对象的高度和宽度将自动根据所指定的文字的大小和数量来设置。
        /// </summary>
        /// <param name="PresetTextEffect">预置文字效果。</param>
        /// <param name="Text">艺术字中的文字。</param>
        /// <param name="FontName">艺术字中所用字体的名称。</param>
        /// <param name="FontSize">艺术字中所用字体的大小(以磅为单位)。</param>
        /// <param name="FontBold">在艺术字中要加粗的字体。</param>
        /// <param name="FontItalic">在艺术字中要倾斜的字体。</param>
        /// <param name="Left">艺术字边框左上角相对于文档左上角的位置(以磅为单位)。</param>
        /// <param name="Top">艺术字边框左上角相对于文档顶部的位置(以磅为单位)。</param>
        /// <returns></returns>
        public Shape AddTextEffect(MsoPresetTextEffect PresetTextEffect, string Text, string FontName, double FontSize, MsoTriState FontBold, MsoTriState FontItalic, double Left, double Top)
        {
            _objaParameters = new object[8] { PresetTextEffect, Text, FontName, FontSize, FontBold, FontItalic, Left, Top };
            object objShape = _objShapes.GetType().InvokeMember("AddTextEffect", BindingFlags.InvokeMethod, null, _objShapes, _objaParameters);

            return new Shape(objShape);
        }
 private static bool check(MsoTriState cond)
 {
     return cond == MsoTriState.msoTrue;
 }
Esempio n. 47
0
 /// <summary>
 /// This method saves and closes the powerpoint (overload 1)
 /// </summary>
 /// <param name="FileName"></param>
 /// <param name="FileFormat"></param>
 /// <param name="EmbedTrueTypeFonts"></param>
 public void SaveAs(String FileName, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType FileFormat, MsoTriState EmbedTrueTypeFonts)
 {
     objPres.SaveAs(FileName, FileFormat, EmbedTrueTypeFonts);
     objPres.Close();
     objApp.Quit();
 }