Using SharpKML library from VB (VS2010), I can create kml files with a custom icon for each placemark. The placemarks are created in a loop and I want to set the icon's heading property for each placemark.
'Define the style for the icon
Dim kmlStyle As New SharpKml.Dom.Style
kmlStyle.Id = "ShipIcon"
kmlStyle.Icon = New SharpKml.Dom.IconStyle
kmlStyle.Icon.Icon = New SharpKml.Dom.IconStyle.IconLink(New System.Uri("http://www.mysite.com/mapfiles/ship4.png"))
kmlStyle.Icon.Scale = 1
Poscommand.CommandText = "SELECT * FROM Ships"
PosReader = Poscommand.ExecuteReader()
While PosReader.Read()
'Add placemark for position
kmlPosPoint = New SharpKml.Dom.Point
kmlPosPoint.Coordinate = New SharpKml.Base.Vector(PosReader("Lat"), PosReader("Lon"))
kmlPosPlaceMark = New SharpKml.Dom.Placemark
kmlPosPlaceMark.Geometry = kmlPosPoint
kmlPosPlaceMark.Name = "My Name"
kmlPosPlaceMark.StyleUrl = New System.Uri("#ShipIcon", UriKind.Relative)
'SET icon.heading HERE??? How to access icon heading property for this placemark only???
End While
Can anybody help me set the icon heading for an individual placemark using SharpKML?
The Heading is actually a property of IconStyle and not Icon (Icon is a child property of IconStyle and only specifies the URL to the icon image.
In your code above it would be (from memory):
kmlStyle.Icon.Heading = 90;
Because you are using a common style for all items I believe you can override just parts of a Style like this inside your loop (please post the result if you test):
kmlPosPlaceMark.StyleUrl = New System.Uri("#ShipIcon", UriKind.Relative);
Style s = new Style();
s.Icon = new IconStyle();
s.Icon.Heading = 90;
kmlPosPlaceMark.StyleSelector = s;
If that doesn't work you might have to create and set a style per Placemark, but i am pretty sure that is not the case. Again, please post back and let us know how you make out.
Related
I create TinyMCE based custom editor in Vue component.
After #input caret position sets to 0 (to left position)
so I get caret position
window.tinyMCE.activeEditor.selection.getRng().startOffset
but I can't set it
window.tinyMCE.activeEditor.selection.setRng(4)
window.tinyMCE.activeEditor.setContent('<p>test test</p>')
not working also
var ed = window.tinyMCE.activeEditor.selection
ed.setCursorLocation(ed.getContent(), 3)
Please help
TinyMCE selection.setRng() doesn't take a number, it takes a Range object.
Some good documentation on how this Range object works, can be found on javascript.info
Here's an example on how to set your cursor to the beginning of the TinyMCE editor:
//make it easier for yourself, we only get so many keystrokes in our lives
const editor = window.tinyMCE.activeEditor;
const selection = editor.selection;
//get the HTML element container
const container = editor.contentAreaContainer;
//get the first element of that container
const firstElementChild = container.firstElementChild;
//create a Range object
const range = new Range();
//set the start and end (start = end, as we want the selection to be collapsed; more info in the documentation above)
range.setStart(firstElementChild, 0);
range.setEnd(firstElementChild, 0);
//Set the editor's selection to our created range
selection.setRng(range, true); //true means it's selected forward; false for backwards selection
In my editor I used this:
let rng = tinymce.DOM.createRng(); // the range object
var newNode = editor.dom.select('#_mce_temp_rob')[0];
rng.setStart(newNode.firstChild, 0); // 0 is the offset, it will be at the beginning of the line.
rng.setEnd(newNode.firstChild, 0);
editor.selection.setRng(rng);
Now I guess implementation will vary in your case as I did this while back and can't remember much of it but hope this helps you in some way.
More here: https://exceptionshub.com/whats-the-best-way-to-set-cursorcaret-position.html
How can I reduce the top margin of a MigraDoc document?
I added an image to the top right of my document however the space between the top of the document and the image is too big.
Here is how I'm setting the image:
Section section = document.AddSection();
Image image = section.AddImage(#"C:\img\mentSmallLogo.png");
image.Height = "1.5cm";
image.Width = "4cm";
image.LockAspectRatio = true;
image.RelativeVertical = RelativeVertical.Line;
image.RelativeHorizontal = RelativeHorizontal.Margin;
image.Top = ShapePosition.Top;
image.Left = ShapePosition.Right;
image.WrapFormat.Style = WrapStyle.Through;
And the document style:
Style style = document.Styles["Normal"];
style.Font.Name = "Verdana";
style = document.Styles[StyleNames.Header];
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);
style = document.Styles[StyleNames.Footer];
style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);
// Create a new style called Table based on style Normal
style = document.Styles.AddStyle("Table", "Normal");
style.Font.Name = "Verdana";
style.Font.Name = "Times New Roman";
style.Font.Size = 8;
// Create a new style called Reference based on style Normal
style = document.Styles.AddStyle("Reference", "Normal");
style.ParagraphFormat.SpaceBefore = "5mm";
style.ParagraphFormat.SpaceAfter = "5mm";
style.ParagraphFormat.TabStops.AddTabStop("16cm", TabAlignment.Right);
style.ParagraphFormat.Font.Size = 8;
How can I reduce the space between the image and the top of the page?
Set image.WrapFormat.DistanceTop to set the top position of the image.
If you set the image position this way, there is no need to modify the PageSetup.
There are different values for RelativeVertical that can be used. And you can also use negative values.
See also:
http://forum.pdfsharp.net/viewtopic.php?p=5267#p5267
With respect to the other answer: it is good practice not to modify DefaultPageSetup. Instead make a Clone() of DefaultPageSetup and modify that.
The PageSetup of your documentis specific to your document. The DefaultPageSetup is shared by all documents; modifying it can lead to strange effects when you persist documents in MDDDL format or when your application has different documents with different page setups.
Code that creates a clone can look like this:
var doc = new Document();
var section = doc.AddSection();
section.PageSetup = doc.DefaultPageSetup.Clone();
Then you can make all necessary changes to section.PageSetup. If you need different settings for other sections, you can use either doc.DefaultPageSetup.Clone() or section.PageSetup.Clone() to get started.
something like this
document.DefaultPageSetup.LeftMargin = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(.8);
document.DefaultPageSetup.TopMargin = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(.5);
document.DefaultPageSetup.PageWidth = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(11);
My solution to this involved having the image in my header section of the document, and controlling the position within the header by enclosing it in a borderless table.
Actual header and footer sections of the document are not effected by the margins applied to the document, they have their own Unit properties.
There is a HeaderDistance property in the PageSetup object of the document.
Same thing exists for Footers (FooterDistance).
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3076
document.DefaultPageSetup.HeaderDistance = "0.20in";
document.DefaultPageSetup.FooterDistance = "0.20in";
Although other answers say to not modify DefaultPageSetup directly, it is a read-only variable in the document object, so you cannot set it equal to a clone. This is the best way.
I am programmatically drawing a flowchart using Java UNO Runtime Reference in which I want to display grid Lines permanently.Using following code I was able to display the Grid Lines but they are toggled ON and OFF alternately when the code executes.
XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xDrawDoc);
XController xController = xModel.getCurrentController();
XDispatchProvider xDisp = UnoRuntime.queryInterface(XDispatchProvider.class, xController);
XMultiComponentFactory xMCF = xContext.getServiceManager();
Object dispatchHelper = xMCF.createInstanceWithContext("com.sun.star.frame.DispatchHelper", xContext);
XDispatchHelper xDispatchHelper = UnoRuntime.queryInterface(XDispatchHelper.class, dispatchHelper);
PropertyValue[] navigatorDesc = new PropertyValue[1];
navigatorDesc[0] = new PropertyValue();
navigatorDesc[0].Name = "GridVisible";
navigatorDesc[0].Value = true;
xDispatchHelper.executeDispatch(xDisp, ".uno:GridVisible" , "", 0, navigatorDesc);
I want to permanently show Grid Lines.How can I achieve this using Java.Pls suggest. If there is any way of checking whether the Grid Lines are ON(any method which could return a boolean value), this could also be a useful approach.
How to change color of hyperlink after clicking on hyperlink (visited state).
I create hyperlink dynamically with next code:
I use Paragraph into RichTextBox in XAML
I fill this TShortName object in code behind with:
TShortName.Inlines.Add(GetNameUrlAsLink(((MyClass)DataContext).MyProperty));
And finally I populate data (hyperlink) with:
private Hyperlink GetNameUrlAsLink(string hp)
{
var hl = new Hyperlink
{
NavigateUri = new Uri(hp),
TargetName = "_blank",
Foreground = new SolidColorBrush(currentAccentColorHex),
FontSize = 20,
};
hl.Inlines.Add(hp);
return hl;
}
As a result, I get hyperlink with accent color (currentAccentColorHex). But I need to change that color when I click on link because it becomes white which is not appropriate for me at all.
Best regards
try this
Dim scb As New SolidColorBrush()
scb.Color = Colors.Green
myHyperlinkButton.Background = scb
I'm trying to update a windows 8 application from the Developer Preview to the Consumer Preview. It seems there's been a few changes. This code used to work:
var myDataSource = new WinJS.UI.ArrayDataSource(array)
var basicListView = WinJS.UI.getControl(document.getElementById("basicListView"));
basicListView.dataSource = myDataSource;
Now, there is no WinJS.UI.getControl method and no ArrayDataSource. This is my code:
var dataList = new WinJS.Binding.List(array);
var list = document.getElementById("basicListView");
list.itemDataSource = dataList.dataSource;
but it does nothing (except add a property to a DOM element that is ignored). Any ideas what I'm missing?
Got it. To get the control you now use the winControl property of the element:
var list = document.getElementById("basicListView").winControl;
Setting the itemDataSource works a treat.