I'm using asp.net for generating pdf file. In pdf i must show plot. I decided using oxyplot with exporting it in png and inserting in pdf. The documentation says using PlotModel, filling it with series and axes and simply export by using PngExporting object. But when I'm trying generate it, nothing is presented except the axes.
The code I'm using:
var _plotModel = new OxyPlot.PlotModel()
{
PlotAreaBorderColor = OxyPlot.OxyColors.Transparent,
LegendBorder = OxyPlot.OxyColors.Transparent,
TitleToolTip = "Temperature",
Culture = new System.Globalization.CultureInfo("ru-Ru"),
Series =
{
new OxyPlot.Series.LineSeries()
{
ItemsSource = new List<SimplePointModel>
{
new SimplePointModel { Date = DateTime.Now, Temperature = 36.6f },
new SimplePointModel { Date = DateTime.Now.AddDays(1), Temperature = 42.6f },
new SimplePointModel { Date = DateTime.Now.AddDays(2), Temperature = 48.6f },
},
MarkerFill = OxyPlot.OxyColor.Parse("#A9CF9C"),
MarkerType = OxyPlot.MarkerType.Circle,
MarkerSize = item.ListSegments[0].Count() == 1 ? 2 : 1,
DataFieldX = "Date",
DataFieldY = "Temperature",
XAxisKey = "Date",
YAxisKey = "Temperature",
Color = OxyPlot.OxyColor.Parse("#A9CF9C"),
}
},
Axes =
{
new OxyPlot.Axes.DateTimeAxis()
{
Position = OxyPlot.Axes.AxisPosition.Bottom,
Key = "Date",
ToolTip = "Temperature",
AbsoluteMinimum = OxyPlot.Axes.Axis.ToDouble(DateTime.Now.Date),
AbsoluteMaximum = OxyPlot.Axes.Axis.ToDouble(DateTime.Now.AddDays(10000))
},
new OxyPlot.Axes.LinearAxis()
{
Position = OxyPlot.Axes.AxisPosition.Left,
Key = "Temperature",
ToolTip = "Temperature",
IsZoomEnabled = false,
IsPanEnabled = false,
}
}
};
using (var stream = System.IO.File.Create(Path.Combine(folder, "temp.png")))
{
PngExporter.Export(_plotModel, stream, 800, 400, OxyPlot.OxyColors.Transparent);
}
What can I do?
I found solution: we must load data to Points list parameter in Series object instead of ItemSource parameter. ItemSource parameter used in mobile version of library.
Related
I wrote the following code to disable the series animation :
Animation = new Animation{Enabled = false},
But after runing my application , the problem still persists.
My code to display the treemap is as follows:
#{ var chartOptions =
new Highcharts
{
Title = new Title
{
Text = ""
},
Credits = new Credits
{
Enabled = false
},
Series = new List<Series>
{
new TreemapSeries
{
Animation = new Animation{Enabled = false},
LayoutAlgorithm = TreemapSeriesLayoutAlgorithm.Squarified,
AlternateStartingDirection = true,
Levels = new List<TreemapSeriesLevels>
{
new TreemapSeriesLevels
{
Level = 1,
LayoutAlgorithm = TreemapSeriesLevelsLayoutAlgorithm.Squarified,
DataLabels = new TreemapSeriesDataLabels()
{
Enabled = true,
Align = TreemapSeriesDataLabelsAlign.Left,
VerticalAlign = TreemapSeriesDataLabelsVerticalAlign.Top
}
}
},
Data = #ViewBag.resultGreen
,
}
}
};
chartOptions.ID = "chart";
chartOptions.PlotOptions.Series.Animation.Enabled = false;
var renderer = new HighchartsRenderer(chartOptions);
}
#Html.Raw(renderer.RenderHtml())
How can i solve this problems?
I tried to solve this problem by the link below:
How to disable animations on Highcharts Dotnet C# MVC?
The provided answer in the mentioned thread looks to be related to DotNet.Highcharts. If you use the official Highcharts .NET wrapper use the AnimationBool option:
new TreemapSeries
{
AnimationBool = false,
...
}
API Reference:
https://dotnet.highcharts.com/Help/Highcharts/html/class_highsoft_1_1_web_1_1_mvc_1_1_charts_1_1_treemap_series.html#a3b53a65560c6917e7ee52e1779335b2e
I am trying to make a TextBox locked by using OpenXML SDK. I've tried this method but the TextBox NoTextEdit is not working.
public DocumentFormat.OpenXml.Presentation.Shape GenerateShape(string StrText)
{
DocumentFormat.OpenXml.Presentation.Shape shape1 = new DocumentFormat.OpenXml.Presentation.Shape();
DocumentFormat.OpenXml.Presentation.NonVisualShapeProperties nonVisualShapeProperties1 = new DocumentFormat.OpenXml.Presentation.NonVisualShapeProperties();
DocumentFormat.OpenXml.Presentation.NonVisualDrawingProperties nonVisualDrawingProperties1 = new DocumentFormat.OpenXml.Presentation.NonVisualDrawingProperties() { Id = (UInt32Value)3U, Name = "ID",Hidden=true ,Description="Do not Remove" ,MCAttributes=null };
DocumentFormat.OpenXml.Presentation.NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new DocumentFormat.OpenXml.Presentation.NonVisualShapeDrawingProperties();
Drawing.ShapeLocks shapeLocks1 = new Drawing.ShapeLocks() { NoTextEdit = true, NoGrouping = true,NoMove=true,NoSelection=true,NoEditPoints=true ,NoAdjustHandles=true ,NoRotation=true,NoChangeArrowheads=true,NoChangeAspect=true,NoChangeShapeType=true,NoResize=true};
nonVisualShapeDrawingProperties1.Append(shapeLocks1);
ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties1 = new ApplicationNonVisualDrawingProperties();
PlaceholderShape placeholderShape1 = new PlaceholderShape() { Type = PlaceholderValues.SubTitle, Index = (UInt32Value)1U };
applicationNonVisualDrawingProperties1.Append(placeholderShape1);
nonVisualShapeProperties1.Append(nonVisualDrawingProperties1);
nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1);
nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties1);
DocumentFormat.OpenXml.Presentation.ShapeProperties shapeProperties1 = new DocumentFormat.OpenXml.Presentation.ShapeProperties();
DocumentFormat.OpenXml.Presentation.TextBody textBody1 = new DocumentFormat.OpenXml.Presentation.TextBody();
Drawing.BodyProperties bodyProperties1 = new Drawing.BodyProperties();
Drawing.ListStyle listStyle1 = new Drawing.ListStyle();
Drawing.TextShape shp = new Drawing.TextShape();
Drawing.Paragraph paragraph1 = new Drawing.Paragraph();
Drawing.EndParagraphRunProperties endParagraphRunProperties1 = new Drawing.EndParagraphRunProperties() { Language = "en-US" ,Dirty=false };
paragraph1.Append(GenerateRun(StrText));
paragraph1.Append(endParagraphRunProperties1);
textBody1.Append(bodyProperties1);
textBody1.Append(listStyle1);
textBody1.Append(paragraph1);
shape1.Append(nonVisualShapeProperties1);
shape1.Append(shapeProperties1);
shape1.Append(textBody1);
return shape1;
}
public Drawing.Run GenerateRun(string StrText)
{
Drawing.Run run1 = new Drawing.Run();
Drawing.RunProperties runProperties1 = new Drawing.RunProperties() { Language = "en-US", Dirty = false };
runProperties1.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0"));
Drawing.Text text1 = new Drawing.Text();
text1.Text = StrText;
Drawing.SolidFill solidFill2 = new Drawing.SolidFill();
Drawing.SchemeColor schemeColor = new Drawing.SchemeColor();
string y = System.Drawing.Color.Transparent.ToArgb().ToString("X");
Drawing.RgbColorModelHex rgbColorModelHex2 = new Drawing.RgbColorModelHex() { Val = "FFFFFF" };//Set Font-Color to Blue (Hex "0070C0").
solidFill2.Append(rgbColorModelHex2);
runProperties1.Append(solidFill2);
Color color = new Color() { Val = "365F91", ThemeColor = ThemeColorValues.Accent1, ThemeShade = "BF" };
run1.Append(runProperties1);
run1.Append(text1);
return run1;
}
Everything works fine except editing. Still the user can edit the TextBox values by double clicking it. How can I avoid this ?
Is there any permanent solution to prevent editing ? Please help me to find a better solution.
Thanks in advance
By researching and communications with the MVP team I've pointed out that there is no way to Protect the TextBox from editing.
As Cindy Meister mentioned in the comments,
Are you able to do it in the PowerPoint application user interface? If not, then Open XML cannot do it... If yes, you can.
If you do not want to text to be changed , Just change it as image then lock that by using NoSelection=true/1 and NoMove=true/1 properties. If you enable these properties the user can't either delete nor change it's position.
For your ref: https://answers.microsoft.com/en-us/msoffice/forum/msoffice_powerpoint-mso_windows8-mso_2016/shape-lock-is-not-working/c1705b55-d2aa-4adb-b538-574ed2fc8eca?tm=1579265435636&page=1&rtAction=1579495439869
I have a simple C# windows forms app. What I am trying to accomplish is modify the Default Root Object of one of my Cloud front Distributions. I can't seem to find any related articles that describes how this is accomplished. Please help
After alot of trial and error Here's the C# code to update an AWS cloud front distribution. You will need AWS's new modularized assemblies. AWSSKD.Core v3 & AWSSDK.Cloudfront.
First you need to get the current Distribution for 2 reasons. Mostly for validation you'll need to grab the Etag and Caller Reference. Etag to var and Caller Reference to string.
var client2 = new AmazonCloudFrontClient();
var tag = client2.GetDistributionConfig(new GetDistributionConfigRequest
{
Id = "YOURDISTID"
}).ETag;
string cf = client2.GetDistributionConfig(new GetDistributionConfigRequest
{
Id = "YOURDISTID"
}).DistributionConfig.CallerReference;
client2.Dispose();
Next you will need to make a update to the distribution. What I have below is the minimally required to update a distribution (Pretty much Everything you see in the AWS console when editing a distribution.
Take notice of where tag variable and cf string are used. If the Etag's do not match you will get 400 bad request back.
var client = new AmazonCloudFrontClient();
client.UpdateDistribution(new UpdateDistributionRequest
{
Id = "YOURDISTID",
DistributionConfig = new DistributionConfig
{
WebACLId = "",
HttpVersion = "http2",
IsIPV6Enabled = true,
DefaultRootObject = "maintenance.html",
CacheBehaviors = new CacheBehaviors {
Quantity = 0,
},
Restrictions = new Restrictions {
GeoRestriction = new GeoRestriction
{
Quantity = 0,
RestrictionType = "none"
}
},
CustomErrorResponses = new CustomErrorResponses {
Quantity = 0
},
ViewerCertificate = new ViewerCertificate {
SSLSupportMethod = "sni-only",
ACMCertificateArn = "YOUR_IMPORTED_CERT_ARN",
MinimumProtocolVersion = "TLSv1.1_2016"
},
Enabled = true,
Comment = "Maintenance",
Origins = new Origins
{
Items = new List<Origin>() {
new Origin(){Id = "S3-example.example.com", DomainName = "example.example.com.s3.amazonaws.com", S3OriginConfig = new S3OriginConfig(){ OriginAccessIdentity = "" }, OriginPath = "", CustomHeaders = new CustomHeaders{ Quantity = 0 } }
},
Quantity = 1
},
Logging = new Amazon.CloudFront.Model.LoggingConfig
{
Bucket = "example.example.com.s3.amazonaws.com",
IncludeCookies = false,
Enabled = false,
Prefix = ""
},
PriceClass = "PriceClass_All",
Aliases = new Aliases
{
Quantity = 1,
Items = list
},
CallerReference = cf,
DefaultCacheBehavior = new DefaultCacheBehavior
{
ForwardedValues = new ForwardedValues
{
QueryString = false,
QueryStringCacheKeys = new QueryStringCacheKeys {
Quantity = 0
},
Headers = new Headers {
Quantity = 0
},
Cookies = new CookiePreference
{
Forward = "none"
}
},
AllowedMethods = new AllowedMethods {
Quantity = 2,
Items = httpmeth,
CachedMethods = new CachedMethods
{
Quantity = 2,
Items = httpmeth
}
},
DefaultTTL = 86400,
Compress = false,
MaxTTL = 31536000,
TargetOriginId = "S3-example.example.com",
LambdaFunctionAssociations = new LambdaFunctionAssociations {
Quantity = 0
},
ViewerProtocolPolicy = "allow-all",
MinTTL = 0,
SmoothStreaming = false,
TrustedSigners = new TrustedSigners
{
Enabled = false,
Quantity = 0,
},
}
},
IfMatch = tag
});
client.Dispose();
If you have issues with ACMCertificationARN not being found in the reference Assembly chances are you are using the old v2 AWSSDK. Remove\Uninstall it. Get the latest Nuget Package for AWSSKD.Core & AWSSDK.CloudFront
Nuget Package Manager Console Install:
Install-Package AWSSDK.Core -Version 3.3.21.17
Install-Package AWSSDK.CloudFront -Version 3.3.6.3
Is it possible?
I can change the values by updating the ValueRange object as in the code above but couldnt find a way to change the format.
ValueRange l_oValueRange = new ValueRange();
List<object> l_olCellsNewValue = new List<object>() { DateTime.UtcNow.ToString("dd'/'MM'/'yyyy HH:mm:ss") };
l_oValueRange.Values = new List<IList<object>> { l_olCellsNewValue };
SpreadsheetsResource.ValuesResource.UpdateRequest l_oUpdate = service.Spreadsheets.Values.Update(
l_oValueRange,
spreadsheetId,
"A60");
l_oUpdate.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.RAW;
UpdateValuesResponse l_oResponse = l_oUpdate.Execute();
string spreadsheetId = "1DD3zfGe6.......UtENHhnBwz0CA";
//get sheet id by sheet name
Spreadsheet spr = service.Spreadsheets.Get(spreadsheetId).Execute();
Sheet sh = spr.Sheets.Where(s => s.Properties.Title == sheetName).FirstOrDefault();
int sheetId = (int)sh.Properties.SheetId;
//define cell color
var userEnteredFormat = new CellFormat()
{
BackgroundColor = new Color()
{
Blue = 0,
Red = 1,
Green = (float)0.5,
Alpha = (float)0.1
},
TextFormat = new TextFormat()
{
Bold = true,
FontFamily = "your font family",
FontSize = 12
}
};
BatchUpdateSpreadsheetRequest bussr = new BatchUpdateSpreadsheetRequest();
//create the update request for cells from the first row
var updateCellsRequest = new Request()
{
RepeatCell = new RepeatCellRequest()
{
Range = new GridRange()
{
SheetId = sheetId,
StartColumnIndex = 0,
StartRowIndex = 0,
EndColumnIndex = 28,
EndRowIndex = 1
},
Cell = new CellData()
{
UserEnteredFormat = userEnteredFormat
},
Fields = "UserEnteredFormat(BackgroundColor,TextFormat)"
}
};
bussr.Requests = new List<Request>();
bussr.Requests.Add(updateCellsRequest);
bur = service.Spreadsheets.BatchUpdate(bussr, spreadsheetId);
bur.Execute();
You need to have an other update (Requests) using BatchUpdate (I'm using Golang):
func (s *Settings) UpdateSheet(req *sheets.Request)(*sheets.BatchUpdateSpreadsheetResponse, error) {
update := sheets.BatchUpdateSpreadsheetRequest{
Requests: []*sheets.Request{req},
}
return s.service.Spreadsheets.BatchUpdate(s.spreadsheetId, &update).Context(s.ctx).Do()
}
The request must contain FontFamily, there aren't lots of docs but it must contain a string under this format "arial,sans,sans-serif" :
req := &sheets.Request{
RepeatCell: &sheets.RepeatCellRequest{
Range: &sheets.GridRange{
SheetId: sheetId,
StartRowIndex: startRow,
EndRowIndex: endRow,
EndColumnIndex: endCol,
},
Cell: &sheets.CellData{
UserEnteredFormat: &sheets.CellFormat{
TextFormat: &sheets.TextFormat{
FontFamily: "arial,sans,sans-serif", // The font family
},
},
},
},
}
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#textformat
TextFormat: {
"foregroundColor": {
object(Color)
},
"fontFamily": string,
"fontSize": number,
"bold": boolean,
"italic": boolean,
"strikethrough": boolean,
"underline": boolean,
}
Keywords: Google Sheets API v4 Golang
I'm using the DocuSign.eSign library from https://github.com/docusign/docuSign-csharp-client
I've created an EnvelopeDefinition:
var envDef = new EnvelopeDefinition()
{
CustomFields = new CustomFields()
{
TextCustomFields = new List<TextCustomField>()
{
new TextCustomField()
{
FieldId = "d9d584f6-0a3a-40df-b94f-407c1a90c87d",
Name = "A.LoanNumber",
Required = "true",
Show = "true",
Value = "1234567890",
},
},
},
EmailBlurb = "Don't panic! This is only a template test.",
EmailSubject = "Template Test...",
Status = "sent",
TemplateId = "458407ac-f0a0-44e6-a60b-5126e2d0a8cf",
TemplateRoles = new List<TemplateRole>()
{
new TemplateRole()
{
AccessCode = "1234",
Email = "jjeppson#example.com",
Name = "Josh Jeppson",
RoleName = "Borrower.1",
},
},
};
But no matter what combination of values I have used for properties of the TextCustomField, the default value for A.LoanNumber, "Loan Number", is output in the resulting document.
The envelope sends correctly but none of the fields (only one shown above) have been inserted/replaced in the document.
Using the specified library, how do I override the default values for the custom fields?