How save a part of a map with Mapsui? - c#

For a project, i'd like to save a part of a map and use it when i'm offline.
I'd like to know if it is possible to save a part of map using Mapsui ?
I already search but I didn't found something good..

If it is just the image of the map you could look at the test file 'MapRendererTests.cs'. It shows how you can save a map extent as an image.
var bitmap = new MapRenderer().RenderToBitmapStream(viewport, map.Layers, map.BackColor);
There is no support for saving the geometries themselves.

Related

How to get geometry information of a single wall?

I want to retrieve geometry information from a single wall in IFC file.
I have tried it using Xbim. I have learned that XbimModel.GetGeometryData Method (IfcProduct, XbimGeometryType) could be used to obtain information of a single ifc element.But this method seems to be obsoleted now. My question is how to get geometry information,say,the vertex coordination of a single ifc wall?
There are diffrent ways to get the Informations. In generall you ned to get the selected IFC Element. If you got that you are able to read all the informations you want.
If use for example XbimWebUI you can get all your infos from the viewer.

Saving Data On C# Wpf

How can I save my added buttons when closing the program ? Each time I hit an add button I'm creating a new title which type is button.And each title have it's own specific words.So I must save the words in buttons at the same time.
Find out what data needs to be stored. > Define a Model
Define how the Data will be stored > e.g. XML-Serialisation, JSON or whatever
Define where Data will be stored, e.g. Database, File
Define when the Configuration is read and saved
eg: read on startup, save on shutdown
Handle your Configuration Data to generate your buttons
Its all up to you. :)
An easy solution might be using XmlSerializer, which is documented here.

How to get all files from a folder in sorted order in C#.Net? [duplicate]

Is is possible to get files that is ordered same as in Windows Explorer
I know "natural sort", but it's not what I need, I need to get the file list ordered by the same attribute in Windows Explorer, for example:
If I ordered a directory by the attribute "create date", then I will get a file list as below:
name create date file size
1.txt 2012/1/1 125Kb
2.tab 2012/3/2 15Kb
3.bmp 2013/5/5 26Kb
If my windows explorer order file list with the attribute "file size", the the file list would be:
name create date file size
2.tab 2012/3/2 15Kb
3.bmp 2013/5/5 26Kb
1.txt 2012/1/1 125Kb
Could anyone help?
I think this is going to be a lot more complex than you expect. Folder settings are stored in the registry in two places:
HKCU\Software\Microsoft\Windows\Shell\BagMRU
HKCU\Software\Microsoft\Windows\Shell\Bags
The first path contains a structure which reflects the structure of the file system, and the second path contains details about those items, including a REG_BINARY value called "Sort" which records the sort order used for that folder.
See Willi Balenthin's website for details on the structure, including sample code (in Python)
Here's how to get a list of files sorted by their name:
var path = #"C:\windows"; // obviously change this to whatever you want
var files = System.IO.Directory.GetFiles (path).ToList ();
file.Sort();
And that's it!
Here's how you would do it per your given code sample:
var temperaturePressureSignalFilesList = Directory.GetFiles(TemperaturePressureSignalDirectory, "*.txt", SearchOption.TopDirectoryOnly).ToList();
temperaturePressureSignalFilesList.Sort();
using System.Linq;
DirectoryInfo info = new DirectoryInfo(""); FileInfo[] files =
info.GetFiles().OrderBy(p => p.CreationTime).ToArray(); foreach
(FileInfo file in files) {
// DO Something... }
here is the sample code for get files in directory by creation time.
You can get files by size same way.
I guess you are talking about viewing pane in Windows Explorer (it's essentially a Windows File Manager but also known under different name). Some clarification is needed. You can apply your custom sorting on various columns; moreover, you can have multiple viewing panes (windows) open sorted on different columns. Thus, the problem definition is a bit unclear.
Assuming that you know the sorting order in your viewing panes, then you can use System.IO.DirectoryInfo and derived FileSystemInfo[] objects; the latter has files.OrderBy method.
Hope this will help. My best, Alex
If you want natural sort order, you should either P/Invoke StrCmpLogicalW (http://msdn.microsoft.com/en-us/library/bb759947.aspx) or find a managed natural sort algorithm. There is no built-in natural sort in .NET Framework.
I think you cannot know which is the order in the pane (by size, name or whatever), you must read the list and then sort it the way you want or prompt the user to select a sorting attribute.
As Kenny posted Sorting Directory.GetFiles() here is an approach, anyway I still thinking there is no possibly way to know which is the sorting order that user selected in the viewing pane.
I think you would have to write a shell extension for windows explorer that captures sort events on columns and writes that metadata to disk in some structured way. You may have multiple explorer windows open so might be an idea to apply timestamp or id so you know which explorer window you are dealing with. Then in your app read that metadata to get the sort order and apply accordingly. Not easy but doable.

Create Unique Image (GUID to Image)

I'd like to do something like SO does with profile pictures of new users. It seems to create a unique image based on a value.
How can I repeatedly create the same unique image from a GUID?
I'm open to doing this on the server, but would prefer a client side solution to create it on the fly.
Something like these:
Edit: How can I repeatedly create the same unique "nice looking" image from a GUID?
What you are looking for is called an Identicon.
I think this post might either give you want you want or give you some sample code to look at in order to generate your own images.
http://www.puls200.de/?p=316
GUID is byte array - so it is already a raw data for an image if you treat the same data as bitmap.
If your question is "how to create nice image" it is different story.

Open "file" from memory stream?

I am wondering if its even possible. I am returning files from database (blob) and have them as bytes array. I would like to let the user to show the data content by clicking on associated object - something like opening in the WebBrowser which automatically selects the appropriate program..but I understand I would need to save the file to the disk.
Is there any other solution which would work only from streams/byte arrays?
You could try setting the WebBrowser.DocumentStream property:
browser.DocumentStream = new MemoryStream(blob);

Categories

Resources