I have a simple SharpMap Map object (WinForms) which contains a TileAsyncLayer (OpenStreetMap using BruTile) within the BackgroundLayers collection.
I would like to have the map either wrap at the edges or repeat so that the user can fan continuously east/west without ever reaching the "end" of the map, but there doesn't seem to be a built in option to do this. What would be the simplest way to enable infinite scrolling?
My code:
BruTile.Web.HttpTileSource source = KnownTileSources.Create();
TileAsyncLayer background = new TileAsyncLayer(source, "OSM");
mapBox1.Map.BackgroundLayer.Add(background);
mapBox1.Map.ZoomToExtents();
mapBox1.Refresh();
mapBox1.ActiveTool = MapBox.Tools.Pan;
Software Versions:
SharpMap: 1.2.0-pre.182830673
BruTile: 2.1.2
Related
I'm making a top-down shooter game and I'm trying to add a muzzle flash by using URP light 2D.
I'm trying to set the target sorting layers for the URP Light2D. I've looked in the documentation and everywhere, but I can't seem to find the code for the target sorting layer. It seems that the target sorting layer can't be changed programmatically. This is a big problem especially when you created the Light2D component in code.
Here is my code:
GameObject MuzzleFlash = new GameObject("MuzzleFlash");
Light2D lightComp = MuzzleFlash.AddComponent<Light2D>();
lightComp.lightType = Light2D.LightType.Point;
// Add the target sorting layers here
MuzzleFlash.transform.position = fromPosition; // From position is a Vector3
I have looked through the Unity forums and found this:
[SerializeField] public int[] m_ApplyToSortingLayers = new int[1];
lightComp.m_ApplyToSortingLayers = new int[] {
SortingLayer.NameToID("someLayer1"),
SortingLayer.NameToID("someLayer2"),
SortingLayer.NameToID("Default"),
};
Source: Can Target Sorting Layer be set in code for Light2D?
But when I plugged that into my code, the console said that
"'Light2D' does not contain a definition for 'm_ApplyToSortingLayers' and no accessible extension method 'm_ApplyToSortingLayers' accepting a first argument of type 'Light2D' could be found".
I also got this message from the console:
"Some scripts have compilation errors which may prevent obsolete API usages to get updated. Obsolete API updating will continue automatically after these errors get fixed."
When will there be a proper API for setting target layers for Light2D? I am new to Unity, so if anyone could help me that would be great.
I would like to know how to create and setup a PresetTour using the ONVIF standard.
Using the the ONVIF ptz wsdl that has been added to my c# project's Connected Services, I can see that I can create a PresetTour for my PTZClient.
_ptzClient.CreatePresetTour(_profile.token);
After using this command, I can get the infos of this newly created preset tour using:
PresetTour[] tours = _ptzClient.GetPresetTours(_profile.token);
I would like to know how to create a new TourSpot or use an already existing Preset as a TourSpot to make my camera go to this spot when launching/starting the preset tour/patrol on my camera.
How do I set the position of a newly created tour spot?
How am I supposed to configure an entire PresetTour?
If there is no solution to my problem, I think I'll keep a list of preset on the side of my application and do everything manually.
You need to invoke ModifyPresetTour. It requires a tt:PresetTour struct, which has, among other fields, a TourSpot element of type tt:PTZPresetTourSpot. Beware that TourSpot is defined in the XML schema as minOccurs="0" maxOccurs="unbounded", thus you can specify any number of tour spots.
The PTZPresetTourSpot struct has a PresetDetail filed of type tt: PTZPresetTourPresetDetail.
Finally PTZPresetTourPresetDetail has a PresetToken field, where you can specify the preset.
I agree it is not very programmer-friendly.
I used in my Windows application(C#) GMAP API, I need to show the terrine feature of the map hence, I try to asssign the provider of the map as follow:
Map.MapProvider = GMapProviders.GoogleSatelliteMap;
unfortunately, the map didn't appear and show error as following:
How to get satellite view in C#??
check if you are in :
this is offline mode, it results to that if there are no caches.
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.CacheOnly;
if your map's zoom property is in 0, it will result to that. do this.
MainMap.Zoom=5; //country level zoom
EDIT: another thing, this is the code to view in satellite map.
MainMap.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;
Try Newer Greatmap Release in Map
You should download the lastest version of GMap.Net from here:
https://www.nuget.org/packages/GMap.NET.Presentation/
I need to insert an external DWG into an AutoCAD drawing via C# plugin.
I need to "ask" to the user the insertion point and rotation of the inserted block.
Until now I've always used a lisp function that calls the command "._-insert" which gives a thumbnail of the block under the mouse, allows the user to click into the drawing to set the insertion point and from that point allows the user to click one more time to set the rotation.
Now I want to avoid the use of Lisp or the use of low level API of AutoCAD because I need a solution that runs over various CAD environments.
What I found is something like this:
public static void InsertDwg(string dwgName)
{
CADAPI.ApplicationServices.Document doc = CADAPI.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
CADDB.Database db = doc.Database;
CADAPI.EditorInput.Editor ed = doc.Editor;
CADDB.ObjectId ObjId;
using (CADDB.Transaction trx = db.TransactionManager.StartTransaction())
{
CADDB.BlockTable bt = db.BlockTableId.GetObject(CADDB.OpenMode.ForRead) as CADDB.BlockTable;
CADDB.BlockTableRecord btrMs = bt[CADDB.BlockTableRecord.ModelSpace].GetObject(CADDB.OpenMode.ForWrite) as CADDB.BlockTableRecord;
using (CADDB.Database dbInsert = new CADDB.Database(false, true))
{
dbInsert.ReadDwgFile(dwgName, CADDB.FileOpenMode.OpenForReadAndAllShare, true, string.Empty);
ObjId = db.Insert(Path.GetFileNameWithoutExtension(dwgName), dbInsert, true);
}
CADAPI.EditorInput.PromptPointOptions ppo = new CADAPI.EditorInput.PromptPointOptions("\nInsertion Point");
CADAPI.EditorInput.PromptAngleOptions ppa = new CADAPI.EditorInput.PromptAngleOptions("\nInsert Rotation");
CADAPI.EditorInput.PromptPointResult ppr;
ppr = ed.GetPoint(ppo);
CADAPI.EditorInput.PromptDoubleResult ppd = ed.GetAngle(ppa);
if (ppr.Status == CADAPI.EditorInput.PromptStatus.OK)
{
CADGEOM.Point3d insertPt = ppr.Value;
CADDB.BlockReference bref = new CADDB.BlockReference(insertPt, ObjId);
btrMs.AppendEntity(bref);
trx.AddNewlyCreatedDBObject(bref, true);
trx.Commit();
}
}
}
But here I have two problems:
The main one is that there is no preview under the mouse.
The second is that the user needs to click 3 times instead of 2 to set both the insertion point and the rotation.
Is there any way that doesn't use some kind of SendCommand and does all of this stuff?
TIA
It seems Jigging is the way to go to allow the preview. I have three links for you.
Jigging multiple entities with the DrawJig
Using a jig to rotate an AutoCAD entity via .NET
Using transient graphics to simulate AutoCAD’s MOVE command using .NET
The first is an example of creating a simple jig with polylines - you could extend this to a block.
The second link is similar but applies rotation to the mix. This is applied to a rectangle but again could be modified to accomodate a block.
The third link describes a different method - AutoCADs transient graphics interface. You must be using AutoCAD 2009 or later to use this method.
The last two links are from the Through the Interface blog, where you may find some more examples and is a very good starting point if you have problems, especially for coding C#.
You will want to use the AcEdJig class. It provides the preview. You will have to write the code to collect the insert point and rotation and to transform the block accordingly.
Here is the first link from my google search for example usage code.
In a Microsoft Surface 1.0 SDK project based on WPF, I'd like to transform contacts captured in a small part of the screen to match the whole screen (like a virtual touchpad).
After capturing a contact and transforming it's position and orientation I would like to send it back to the event queue. I already figured out that there seems to be no way to create a "new Contact()" or to change anything in the "ReadOnlyContactCollection" (like it's name already says).
Here's what I was trying to do:
private void OnContactDown(object sender, ContactEventArgs e)
{
base.OnContactDown(e);
e.Contact.Capture(this);
// transform the contact's center and orientation
// and write them back into e.Contact via own private method
// e.Contact = transformContact(e.Contact);
// keep transformed contact in the event queue
// so it can be processed at it's new position
e.Handled = false;
}
My next idea was to make use of the simulator and automation to create SimulatedContacts, but sadly this doesn't work on the surface table itself, only in the simulator.
Is there any way to send out "virtual" contacts (that don't exist in the raw image) so that they will be recognized by the surface (without the use of the simulator)? How does the SurfaceInput.exe send out the recognized contacts?
Surface v1 doesn't officially support WPF 4.0, but others have figured out how to take Surface v1 input and route it into the standardized & extensible touch APIs that come with WPF 4.0. Take a look at http://nui.joshland.org/2010/07/how-to-write-surface-applications-with.html for creating a custom "touch device" that transforms Surface input into WPF 4.0 input events. Following that same approach, you can create another "touch device" on your own in order to pass in your fake touches.