示例#1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            ShapeExportOptions shapeExportOptions = ShapeExportOptions.OneShapeExportOnce;
            int exportDpi = Convert.ToInt32(dropDownExportDpi.SelectedItem.ToString());

            switch (dropDownExportOption.SelectedItem)
            {
            case "Same Export Once":
                shapeExportOptions = ShapeExportOptions.OneShapeExportOnce;
                break;

            case "Export Irrespective":
                shapeExportOptions = ShapeExportOptions.ShapeExportIrrespective;
                break;

            default:
                break;
            }
            if (Settings.SaveSettings(exportDpi, shapeExportOptions))
            {
                MessageBox.Show("Settings Updated Successfully");
            }
            else
            {
                MessageBox.Show("Error!!! Settings Update Unsuccessful!");
            }

            Settings.ReadAndUpdateFromXML();
            this.Close();
        }
示例#2
0
        /// <summary>
        /// Write the current settings to XML in public douments folder
        /// </summary>
        internal static bool SaveSettings(int exportImageDpi, ShapeExportOptions shapeExportOptions)
        {
            try
            {
                string saveDirectory = @"C:\Users\Public\Documents\EzilmStudioSettings";
                Directory.CreateDirectory(saveDirectory);

                XmlDocument xmlDoc   = new XmlDocument();
                XmlNode     rootNode = xmlDoc.CreateElement("Settings");
                xmlDoc.AppendChild(rootNode);

                XmlNode exportDpi = xmlDoc.CreateElement("exportDpi");
                exportDpi.InnerText = exportImageDpi.ToString();
                rootNode.AppendChild(exportDpi);

                XmlNode shapeExportOption = xmlDoc.CreateElement("shapeExportOptions");
                shapeExportOption.InnerText = shapeExportOptions.ToString();
                rootNode.AppendChild(shapeExportOption);

                xmlDoc.Save(saveDirectory + @"\settings.xml");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#3
0
        internal static bool ReadAndUpdateFromXML()
        {
            string xmlPath = @"C:\Users\Public\Documents\EzilmStudioSettings" + @"\settings.xml";

            if (File.Exists(xmlPath))
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(xmlPath);
                exportImageDpi     = Convert.ToInt32(xmlDocument.GetElementsByTagName("exportDpi")[0].InnerText);
                shapeExportOptions = (ShapeExportOptions)Enum.Parse(typeof(ShapeExportOptions), xmlDocument.GetElementsByTagName("shapeExportOptions")[0].InnerText, true);
            }
            else
            {
                SaveSettings(72, ShapeExportOptions.OneShapeExportOnce);
            }
            return(true);
        }
示例#4
0
        private void LoadPreviousSettingsToUI()
        {
            int dpiSettings = Settings.exportImageDpi;
            ShapeExportOptions shapeExportOption = Settings.shapeExportOptions;

            dropDownExportDpi.SelectedItem = dpiSettings.ToString();

            switch (shapeExportOption)
            {
            case ShapeExportOptions.OneShapeExportOnce:
                dropDownExportOption.SelectedItem = "Same Export Once";
                break;

            case ShapeExportOptions.ShapeExportIrrespective:
                dropDownExportOption.SelectedItem = "Export Irrespective";
                break;

            default:
                break;
            }
        }
示例#5
0
        private void ShapeExportOption(Shape shape, ShapeExportOptions exportOptions)
        {
            //Export the image of the shape
            int slideWidth  = (int)Utility.SlideWidthGet((shape.Parent).Parent);
            int slideHeight = (int)Utility.SlideHeightGet((shape.Parent).Parent);

            string shapeExportDirectory = PowerPointStudioRibbon.currentPPTPath + "\\images";

            if (!Directory.Exists(shapeExportDirectory))
            {
                Directory.CreateDirectory(shapeExportDirectory);
            }

            //Need to set rotation property 0 before export then set back to original
            float originalRotation = shape.Rotation;

            try
            {
                shape.Rotation = 0;
            }catch
            {
            }

            string exportedUrl = "";
            //shape name may contain character that are not qualify as file name so need to remove those
            //Qulify shape Name
            string qulifiedShapeName = Utility.qulifiedNameGenerator(shape.Name);

            if (exportOptions == ShapeExportOptions.OneShapeExportOnce)
            {
                exportedUrl = shapeExportDirectory + "\\" + qulifiedShapeName + ".png";
            }
            else
            {
                exportedUrl = shapeExportDirectory + "\\" + qulifiedShapeName + Utility.RandomNumber(0, 999999, count++) + ".png";
            }


            if (!File.Exists(exportedUrl))
            {
                shape.Export(exportedUrl, PpShapeFormat.ppShapeFormatPNG, slideWidth * 4, slideHeight * 4, PpExportMode.ppClipRelativeToSlide);
            }

            //Back rotation to original
            shape.Rotation = originalRotation;

            actualUrl   = exportedUrl;
            exportedUrl = exportedUrl.Replace("\\", "/");

            imgurlLarge  = exportedUrl.Replace(PowerPointStudioRibbon.currentPPTPath.Replace("\\", "/"), "https://ezilmdev.org");
            imgurlMedium = exportedUrl.Replace(PowerPointStudioRibbon.currentPPTPath.Replace("\\", "/"), "https://ezilmdev.org");
            imgurlSmall  = exportedUrl.Replace(PowerPointStudioRibbon.currentPPTPath.Replace("\\", "/"), "https://ezilmdev.org");

            css = new ezCss(shape);

            //Custom dpi based on settings
            int    dpiRequired = Settings.exportImageDpi;
            Bitmap shapeBitmap = new Bitmap(exportedUrl);

            Utility.CustomDpi(shapeBitmap, shapeBitmap.Width, shapeBitmap.Height, dpiRequired, exportedUrl);
        }