Exemple #1
0
        private void testCode()
        {
            // Create a PowerPoint application object.
            PowerPoint.Application appPPT = Globals.ThisAddIn.Application;

            // Create a new PowerPoint presentation.
            PowerPoint.Presentation pptPresentation = appPPT.ActivePresentation;


            PowerPoint.CustomLayout pptLayout = default(PowerPoint.CustomLayout);
            if ((pptPresentation.SlideMaster.CustomLayouts._Index(7) == null))
            {
                pptLayout = pptPresentation.SlideMaster.CustomLayouts._Index(1);
            }
            else
            {
                pptLayout = pptPresentation.SlideMaster.CustomLayouts._Index(7);
            }

            // Create newSlide by using pptLayout.
            PowerPoint.Slide newSlide =
                pptPresentation.Slides.AddSlide((pptPresentation.Slides.Count + 1), pptLayout);

            Color myBackgroundColor = Color.Aqua;
            int   oleColor          = ColorTranslator.ToOle(myBackgroundColor);

            newSlide.FollowMasterBackground        = Core.MsoTriState.msoFalse;
            newSlide.Background.Fill.ForeColor.RGB = oleColor;
            //newSlide.Background.Fill.Visible = Core.MsoTriState.msoFalse;


            PowerPoint.Shape textBox = newSlide.Shapes.AddTextbox(Core.MsoTextOrientation.msoTextOrientationHorizontal, 100, 100, 500, 100);

            textBox.TextFrame.TextRange.Text = "teasdfst";
        }
Exemple #2
0
        /// <summary>
        /// Converts HLS colour to RGB
        /// </summary>
        /// <param name="hue">Hue ranged between 0-240</param>
        /// <param name="light">Light ranged between 0-240 (120 is normal)</param>
        /// <param name="saturation">Saturation ranged between 0-240</param>
        /// <returns>System.Media.Color from HLS parameters</returns>
        private static Color HLSToRGB(int hue, int light, int saturation)
        {
            int win32Color = ColorHLSToRGB(hue, light, saturation);                 // Get win32 colour from HLS

            System.Drawing.Color sysColor = ColorTranslator.FromWin32(win32Color);  // Convert to system color

            return(Color.FromArgb(sysColor.A, sysColor.R, sysColor.G, sysColor.B)); // Convert to color
        }
Exemple #3
0
        private void AddHorizontalLine(Document d, _HorizontalLine horizontalLine)
        {
            var line = d.Paragraphs.Last.Range.InlineShapes.AddHorizontalLineStandard(ref missing);

            line.Height = horizontalLine.Height;
            line.Fill.Solid();
            line.HorizontalLineFormat.NoShade      = true;
            line.Fill.ForeColor.RGB                = ColorTranslator.ToOle(horizontalLine.Color);
            line.HorizontalLineFormat.PercentWidth = horizontalLine.PorcentWidth;
            line.HorizontalLineFormat.Alignment    = horizontalLine.Alignment;
        }
Exemple #4
0
        /// <summary>
        /// Apply appearance to selection set
        /// </summary>
        /// <param name="selectionSet"></param>
        /// <param name="Color"></param>
        /// <param name="transparency"></param>
        private void ApplyAppearance(SelectionSet selectionSet, object Color, object transparency)
        {
            if (selectionSet != null &&
                (Color != null || transparency.ToString() != "-1"))

            {
                var debug = selectionSet.Search.FindAll(false);
                IEnumerable <ModelItem> modelItems = debug as IEnumerable <ModelItem>;


                if (Color != null)
                {
                    //Pick color from json
                    var color = TransformColor(ColorTranslator.FromHtml(Color.ToString()));
                    Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor(modelItems, color);
                }

                if (transparency.ToString() != "-1")
                {
                    Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentTransparency(modelItems, int.Parse(transparency.ToString()));
                }
            }
        }