Пример #1
0
        protected override Dictionary <string, string> GetParameters(string applicationKey, string signature, string callBackURL, string dataName, string dataValue)
        {
            Dictionary <string, string> parameters = CreateParameters(applicationKey, signature, callBackURL, dataName, dataValue);

            parameters.Add("background", Convert.ToInt32(IncludeBackground).ToString());
            parameters.Add("pagesize", PageSize.ToString().ToUpper());
            parameters.Add("orientation", Orientation.ToString());
            parameters.Add("templateid", TemplateId);
            parameters.Add("customwatermarkid", CustomWaterMarkId);
            parameters.Add("includelinks", Convert.ToInt32(IncludeLinks).ToString());
            parameters.Add("includeoutline", Convert.ToInt32(IncludeOutline).ToString());
            parameters.Add("title", Title);
            parameters.Add("coverurl", CoverURL);
            parameters.Add("mleft", MarginLeft.ToString());
            parameters.Add("mright", MarginRight.ToString());
            parameters.Add("mtop", MarginTop.ToString());
            parameters.Add("mbottom", MarginBottom.ToString());
            parameters.Add("delay", Delay.ToString());
            parameters.Add("requestmobileversion", Convert.ToInt32(RequestAs).ToString());
            parameters.Add("quality", Quality.ToString());
            parameters.Add("target", TargetElement);
            parameters.Add("hide", HideElement);
            parameters.Add("waitfor", WaitForElement);
            parameters.Add("noads", Convert.ToInt32(NoAds).ToString());
            parameters.Add("post", post);
            parameters.Add("bwidth", BrowserWidth.ToString());
            parameters.Add("width", PageWidth.ToString());
            parameters.Add("height", PageHeight.ToString());
            parameters.Add("tvars", templateVariables);

            return(parameters);
        }
Пример #2
0
                public override int GetHashCode()
                {
                    int hash = 1;

                    if (MarginLeft != 0L)
                    {
                        hash ^= MarginLeft.GetHashCode();
                    }
                    if (MarginTop != 0L)
                    {
                        hash ^= MarginTop.GetHashCode();
                    }
                    if (ScaleRatio != 0D)
                    {
                        hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(ScaleRatio);
                    }
                    if (Handup != false)
                    {
                        hash ^= Handup.GetHashCode();
                    }
                    if (_unknownFields != null)
                    {
                        hash ^= _unknownFields.GetHashCode();
                    }
                    return(hash);
                }
Пример #3
0
        /// <summary>
        /// Returned object must be disposed
        /// MultiplexingConverter should be used for multithreading
        /// but and application doesn't exit after its using
        /// </summary>
        /// <returns></returns>
        private WkHtmlToPdfConverter GetConverter()
        {
            var conv = new WkHtmlToPdfConverter();

            conv.GlobalSettings.Dpi = Dpi;

            conv.GlobalSettings.Margin.Top    = MarginTop?.ToString();
            conv.GlobalSettings.Margin.Bottom = MarginBottom?.ToString();
            conv.GlobalSettings.Margin.Left   = MarginLeft?.ToString();
            conv.GlobalSettings.Margin.Left   = MarginLeft?.ToString();
            conv.GlobalSettings.Orientation   = Orientation;
            conv.GlobalSettings.Size.PageSize = PageSize;

            conv.ObjectSettings.Load.ZoomFactor = Zoom;
            conv.ObjectSettings.Header.Spacing  = HeaderSpacing;
            conv.ObjectSettings.Header.HtmlUrl  = HeaderHtmlUrl;
            conv.ObjectSettings.Page            = HtmlUrl;

            conv.ObjectSettings.Footer.Spacing = FooterSpacing;
            conv.ObjectSettings.Footer.HtmlUrl = FooterHtmlUrl;
            conv.ObjectSettings.Web.EnableIntelligentShrinking = false;

            //conv.Begin += (s, e) => _Log.DebugFormat("Conversion begin, phase count: {0}", e.Value);
            //conv.Error += (s, e) => _Log.Error(e.Value);
            //conv.Warning += (s, e) => _Log.Warn(e.Value);
            //conv.PhaseChanged += (s, e) => _Log.InfoFormat("PhaseChanged: {0} - {1}", e.Value, e.Value2);
            //conv.ProgressChanged += (s, e) => _Log.InfoFormat("ProgressChanged: {0} - {1}", e.Value, e.Value2);
            //conv.Finished += (s, e) => _Log.InfoFormat("Finished: {0}", e.Value ? "success" : "failed!");

            return(conv);
        }
Пример #4
0
 protected override void RenderAttributes(XElement element, FoRenderOptions options)
 {
     if (RegionName.HasValue())
     {
         element.Add(new XAttribute("region-name", RegionName));
     }
     if (BackgroundRepeat.HasValue())
     {
         element.Add(new XAttribute("background-repeat", BackgroundRepeat));
     }
     if (BackgroundImage.HasValue())
     {
         element.Add(new XAttribute("background-image", "url(" + BackgroundImage + ")"));
     }
     if (ColumnCount > 0)
     {
         element.Add(new XAttribute("column-count", ColumnCount));
     }
     if (ColumnGap.HasValue())
     {
         element.Add(new XAttribute("column-gap", ColumnGap));
     }
     if (Extent.HasValue())
     {
         element.Add(new XAttribute("extent", Extent));
     }
     if (Margin.HasValue())
     {
         element.Add(new XAttribute("margin", Margin));
     }
     if (MarginTop.HasValue())
     {
         element.Add(new XAttribute("margin-top", MarginTop));
     }
     if (MarginRight.HasValue())
     {
         element.Add(new XAttribute("margin-right", MarginRight));
     }
     if (MarginBottom.HasValue())
     {
         element.Add(new XAttribute("margin-bottom", MarginBottom));
     }
     if (MarginLeft.HasValue())
     {
         element.Add(new XAttribute("margin-left", MarginLeft));
     }
 }
Пример #5
0
        private async void StackPanel_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            //string JsonModel = "      {" +
            //              "\"PhoneOEM\": \"{0}\"," +
            //              "\"PhoneName\": \"{1}\"," +
            //              "\"Color\": \"{2}\"," +
            //              "\"ColorStr\": \"{3}\"," +
            //              "\"PhoneGlare\": \"{4}\"," +
            //              "\"PhoneScreen\": \"{5}\"," +
            //              "\"MarginLeft\": \"{6}\"," +
            //              "\"MarginTop\": \"{7}\"," +
            //              "\"MarginRight\": \"{8}\"," +
            //              "\"MarginBottom\": \"{9}\"," +
            //              "\"ScreenWidth\": \"{10}\"," +
            //              "\"ScreenHeight\": \"{11}\"" +
            //              "},";
            string[] args = new string[12];
            args[0]  = "\n      {\n        \"PhoneOEM\":\"" + PhoneOEM.Text + "\",\n";
            args[1]  = "        \"PhoneName\":\"" + PhoneName.Text + "\",\n";
            args[2]  = "        \"Color\": \"" + Color.SelectedItem as string + "\",\n";
            args[3]  = "        \"ColorStr\": \"" + ColorToStr(Color.SelectedItem as string) + "\",\n";
            args[4]  = "        \"PhoneGlare\": \"" + _filepath.Replace("C:\\Users\\blue-\\Documents\\Visual Studio 2015\\Projects\\ShotWithPhone\\ShotWithPhone\\PhoneImageSources\\", "/PhoneImageSources/").Replace("screen", "glare") + "\",\n";
            args[5]  = "        \"PhoneScreen\": \"" + _filepath.Replace("C:\\Users\\blue-\\Documents\\Visual Studio 2015\\Projects\\ShotWithPhone\\ShotWithPhone\\PhoneImageSources\\", "/PhoneImageSources/") + "\",\n";
            args[6]  = "        \"MarginLeft\": \"" + MarginLeft.ToString() + "\",\n";
            args[7]  = "        \"MarginTop\": \"" + MarginTop.ToString() + "\",\n";
            args[8]  = "        \"MarginRight\": \"" + MarginRight.ToString() + "\",\n";
            args[9]  = "        \"MarginBottom\": \"" + MarginBottom.ToString() + "\",\n";
            args[10] = "        \"ScreenWidth\": \"" + RecWidth.ToString() + "\",\n";
            args[11] = "        \"ScreenHeight\": \"" + RecHeight.ToString() + "\"\n      },";
            string Json = "";

            foreach (string item in args)
            {
                Json += item;
            }
            DataPackage data = new DataPackage();

            data.SetText(Json);
            Clipboard.SetContent(data);
            MessageDialog MD = new MessageDialog("CopyOK!");

            MD.Options = MessageDialogOptions.AcceptUserInputAfterDelay;
            await MD.ShowAsync();
        }
Пример #6
0
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            base.FillStyleAttributes(attributes, urlResolver);

            if (PaddingTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingTop, PaddingTop.ToString());
            }
            if (PaddingLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingLeft, PaddingLeft.ToString());
            }
            if (PaddingRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingRight, PaddingRight.ToString());
            }
            if (PaddingBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingBottom, PaddingBottom.ToString());
            }

            if (MarginTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginTop, MarginTop.ToString());
            }
            if (MarginLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginLeft, MarginLeft.ToString());
            }
            if (MarginRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginRight, MarginRight.ToString());
            }
            if (MarginBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginBottom, MarginBottom.ToString());
            }

            if (!String.IsNullOrEmpty(BackImageUrl))
            {
                attributes.Add(HtmlTextWriterStyle.BackgroundImage, String.Format("url({0})", urlResolver.ResolveClientUrl(BackImageUrl)));
            }
        }
Пример #7
0
        protected override void RenderAttributes(XElement element, FoRenderOptions options)
        {
            base.RenderAttributes(element, options);

            if (MasterName.IsNullOrWhiteSpace())
            {
                throw new PropertyNotSetException(nameof(MasterName));
            }
            element.Add(new XAttribute("master-name", MasterName));

            if (PageWidth.HasValue())
            {
                element.Add(new XAttribute("page-width", PageWidth));
            }
            if (PageHeight.HasValue())
            {
                element.Add(new XAttribute("page-height", PageHeight));
            }
            if (Margin.HasValue())
            {
                element.Add(new XAttribute("margin", Margin));
            }
            if (MarginTop.HasValue())
            {
                element.Add(new XAttribute("margin-top", MarginTop));
            }
            if (MarginRight.HasValue())
            {
                element.Add(new XAttribute("margin-right", MarginRight));
            }
            if (MarginBottom.HasValue())
            {
                element.Add(new XAttribute("margin-bottom", MarginBottom));
            }
            if (MarginLeft.HasValue())
            {
                element.Add(new XAttribute("margin-left", MarginLeft));
            }
        }
Пример #8
0
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            base.FillStyleAttributes(attributes, urlResolver);

            if (PaddingTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingTop, PaddingTop.ToString());
            }
            if (PaddingLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingLeft, PaddingLeft.ToString());
            }
            if (PaddingRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingRight, PaddingRight.ToString());
            }
            if (PaddingBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingBottom, PaddingBottom.ToString());
            }

            if (MarginTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginTop, MarginTop.ToString());
            }
            if (MarginLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginLeft, MarginLeft.ToString());
            }
            if (MarginRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginRight, MarginRight.ToString());
            }
            if (MarginBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginBottom, MarginBottom.ToString());
            }
        }
Пример #9
0
        public override string ToString()
        {
            string st =
                @"<DeviceInfo>
    <OutputFormat>{0}</OutputFormat>
    <PageWidth>{1}in</PageWidth>
    <PageHeight>{2}in</PageHeight>
    <MarginTop>{3}in</MarginTop>
    <MarginLeft>{4}in</MarginLeft>
    <MarginRight>{5}in</MarginRight>
    <MarginBottom>{6}in</MarginBottom>
</DeviceInfo>";

            return(string.Format(st,
                                 OutputFormat,
                                 PageWidth.ToString("F2"),
                                 PageHeight.ToString("F2"),
                                 MarginTop.ToString("F2"),
                                 MarginLeft.ToString("F2"),
                                 MarginRight.ToString("F2"),
                                 MarginBottom.ToString("F2")
                                 ));
        }
Пример #10
0
        protected override Dictionary <string, string> GetParameters(string applicationKey, string signature, string callBackURL, string dataName, string dataValue)
        {
            Dictionary <string, string> parameters = CreateParameters(applicationKey, signature, callBackURL, dataName, dataValue);

            parameters.Add("background", Convert.ToInt32(IncludeBackground).ToString());
            parameters.Add("pagesize", PageSize.ToString().ToUpper());
            parameters.Add("orientation", Orientation.ToString());
            parameters.Add("templateid", TemplateId);
            parameters.Add("customwatermarkid", CustomWaterMarkId);
            parameters.Add("includelinks", Convert.ToInt32(IncludeLinks).ToString());
            parameters.Add("includeoutline", Convert.ToInt32(IncludeOutline).ToString());
            parameters.Add("title", Title);
            parameters.Add("coverurl", CoverURL);
            parameters.Add("mleft", MarginLeft.ToString());
            parameters.Add("mright", MarginRight.ToString());
            parameters.Add("mtop", MarginTop.ToString());
            parameters.Add("mbottom", MarginBottom.ToString());
            parameters.Add("delay", Delay.ToString());
            parameters.Add("requestmobileversion", Convert.ToInt32(RequestAs).ToString());
            parameters.Add("quality", Quality.ToString());

            return(parameters);
        }
Пример #11
0
 protected override void RenderAttributes(XElement element, FoRenderOptions options)
 {
     base.RenderAttributes(element, options);
     if (Margin.HasValue())
     {
         element.Add(new XAttribute("margin", Margin));
     }
     if (MarginTop.HasValue())
     {
         element.Add(new XAttribute("margin-top", MarginTop));
     }
     if (MarginRight.HasValue())
     {
         element.Add(new XAttribute("margin-right", MarginRight));
     }
     if (MarginBottom.HasValue())
     {
         element.Add(new XAttribute("margin-bottom", MarginBottom));
     }
     if (MarginLeft.HasValue())
     {
         element.Add(new XAttribute("margin-left", MarginLeft));
     }
 }
Пример #12
0
        protected override void RenderAttributes(XElement element, FoRenderOptions options)
        {
            if (Src.IsNullOrWhiteSpace())
            {
                throw new PropertyNotSetException(nameof(Src));
            }
            element.Add(new XAttribute("src", Src));

            if (Width.HasValue())
            {
                element.Add(new XAttribute("width", Width));
            }
            if (Height.HasValue())
            {
                element.Add(new XAttribute("height", Height));
            }
            if (ContentWidth.HasValue())
            {
                element.Add(new XAttribute("content-width", ContentWidth));
            }
            if (ContentHeight.HasValue())
            {
                element.Add(new XAttribute("content-height", ContentHeight));
            }
            if (Scaling != FoScaling.Unspecified)
            {
                element.Add(new XAttribute("scaling", ToKebabCase(Scaling)));
            }
            if (ScalingMethod != FoScalingMethod.Unspecified)
            {
                element.Add(new XAttribute("scaling-method", ToKebabCase(ScalingMethod)));
            }

            if (Margin.HasValue())
            {
                element.Add(new XAttribute("margin", Margin));
            }
            if (MarginTop.HasValue())
            {
                element.Add(new XAttribute("margin-top", MarginTop));
            }
            if (MarginRight.HasValue())
            {
                element.Add(new XAttribute("margin-right", MarginRight));
            }
            if (MarginBottom.HasValue())
            {
                element.Add(new XAttribute("margin-bottom", MarginBottom));
            }
            if (MarginLeft.HasValue())
            {
                element.Add(new XAttribute("margin-left", MarginLeft));
            }

            if (Padding.HasValue())
            {
                element.Add(new XAttribute("padding", Padding));
            }
            if (PaddingTop.HasValue())
            {
                element.Add(new XAttribute("padding-top", PaddingTop));
            }
            if (PaddingRight.HasValue())
            {
                element.Add(new XAttribute("padding-right", PaddingRight));
            }
            if (PaddingBottom.HasValue())
            {
                element.Add(new XAttribute("padding-bottom", PaddingBottom));
            }
            if (PaddingLeft.HasValue())
            {
                element.Add(new XAttribute("padding-left", PaddingLeft));
            }

            base.RenderAttributes(element, options);
        }