|
There are likely many examples for that task available on the web, but I do not know the technical terms.
I have a list of point (in this case, System.Drawing.Point), and I am looking for a closed line around them. All points of the list must be inside, some other points may be inside additionally, but their number should be as low as possible. And, actually, I do not need the line proper: knowing its length is enough.
Finding a rectangle enclosing all the points of the list is very easy - but there are too many other points enclosed. Another issue is that there might be "holes", not all points have a direct neighbor (in "8 neighborhood").
Could you give me some pointers where to look for? Thanks a lot.
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
Hi,
you want a “convex hull” algorithm; there are some excellent articles on the subject right here at CP, mostly by Eric Ouellet.
|
|
|
|
|
You type faster than me
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Convex hull - Wikipedia[^] is probably a good starting point. Good hunting!
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
This is the case
I download several Fields to a datatable including an image, that copy to "AccesoryImage"
<br />
Image AccessoryImage = Image.FromStream(newMemoryStream((byte[])SKUInformationDataTable.Rows[AccessoriesRow]["IM_Image"]));
<small> This works great, the problem is that the catalog from de DB had some items whitout a image, and I need to call a default image (from project resources catalog).
How can I make the comparation if the AccessoryImage is NULL or empty I was thinking something like this but dosent work
Image AccessoryImage = Image.FromStream(new MemoryStream((byte[])SKUInformationDataTable.Rows[AccessoriesRow]["IM_Image"]));
var ImagenDefault = new Bitmap(MESWMP.Properties.Resources.ImagenDefaultMan);
if (AccessoryImage == NULL){ AccessoryImage = BitmapToByte(MESWMP.Properties.Resources.ImagenDefaultMan);}
AccessoryRadPanel.BackgroundImage = AccessoryImage;
|
|
|
|
|
Something like this should work:
DataRow row = SKUInformationDataTable.Rows[AccessoriesRow];
Image AccessoryImage = row.IsNull("IM_Image")
? (Image)new Bitmap(MESWMP.Properties.Resources.ImagenDefaultMan)
: Image.FromStream((byte[])row["IM_Image"]);
DataRow.IsNull Method (System.Data) | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
tks a lot, works like a charm!!
|
|
|
|
|
I have your home typical network. We have Spectrum for our ISP. From time to time the router's IP changes. THis is expected of course as I don't want to pay for a static IP address.
What would be involved in writing a small app that detects when the IP address changes? I could of course write some kind of looping process that keeps comparing it somehow, but I was wondering if there is some way of using an event handler.
Any thoughts on this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You probably can't detect the change unless you poll for the IP address. Your "home network" is probably on the wrong side of the cable modem to get any kind of hint of what's going on.
The traffic to change the modem IP isn't routed to the inside of the network and you can't really get the IP address without going to an external site and having it tell you the IP address the request was sent from, which will NOT be your machine IP, but your cable modems IP.
|
|
|
|
|
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You can only tell by asking the outside world what the IP is - the internet IP is not transferred into the LAN with "normal" messages.
Have a look here: Using IP based Geolocation - and why it's pretty much useless.[^] It includes an app I knocked up to find out my IP so I could tell when it changed. You'd need to modify it to run in a thread in your app, but that's not too complicated.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I am new to API and MVC. I have a MVC application which calls a third party Api. The Api returns the data in Json format.
I want to get the Json data and map it to a class object.
modified 28-Aug-18 10:02am.
|
|
|
|
|
|
Hi there,
I'm trying to make a program which sends a command and getting certain values from the result from an invisble command line program which has the current values.
Here's a HelloWorld-esque example:
How can I get this working? (e.g putting only that number 5 next to the amount)
~wesley9946
|
|
|
|
|
Wesley there is a problem with your question - this is your first post and you want us to click on a link that is not recognised. And you are looking for "invisible" code, immediately raises the level of paranoia in most of us.
Post your code rather than a link.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
With "invisible", I mean that there's a hidden cmd running in the background, somehow I couldn't get the image in the post so that's why I made a link to it.
So.... the problem here is that i don't know the piece of code that makes the winform read and filter the info from that hidden cmd so maybe you can help me with that.
|
|
|
|
|
You have to realise that we can't see your screen, can't access your HDD, and can't read your mind - we only get exactly what you type to work with. While there are ways to run a command from a C# program without a window attached and to retrieve the output from it, we don't know what - exactly - you are doing at the moment, or how you do it.
So show us the code that kicks off the command - copy'n'paste of the relevant fragments are good - and explain what you mean by "hidden cmd" - because there are a a number of things that could be as well - a windowless CMD prompt, a windows service (which has no UI, and can never have one), ... We don't know and we can't see!
And we can't tell you what code you need to use unless we understand what your problem is in the first place, so help us to help you!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
I've got a really weird problem here !
I've written a C# console app to get data from predefined IP addresses, after the calculations, I want the data to be inserted to a MySQL database so I can read it and do more calculations if needed using a PHP web application,
on my lap top everything is working perfectly,
when I run the C# app on the server, the data is being handled perfectly until the last step which is inserting it, but when it inserts the data, it's like an integer, no decimals.
I used VS Studio tools and tracked my variables, they are correct even in the sql statements but on the database they're losing their decimals.
I'm using windows 10 on my laptop and the server has windows Server 2016
here's the C# code :
<pre lang="c#">
public static string send_to_db(int uid, float prs, float btlvl, float f1, float f2, double t1, double t2, int dState, int supState, string datetime, string stmt)
{
MySqlConnection connection = null;
string feedback = "";
double min_prs_val = 0, max_prs_val = 0;
btlvl = (btlvl * 100) / 12;
try
{
connection = new MySqlConnection(stmt);
connection.Open();
MySqlCommand insertData = new MySqlCommand($"INSERT INTO pm_data_records (pm_detail_id, pm_pressure, pm_battery_charge, pm_flow1, pm_flow2, pm_tot1, pm_tot2, pm_door, pm_sup, pm_sent_time) VALUES('{uid}','{prs}','{btlvl}','{f1}','{f2}','{t1}','{t2}','{dState}','{supState}','{datetime}')", connection);
insertData.ExecuteNonQuery();
MySqlCommand updateData = new MySqlCommand($"UPDATE pm_data_last SET pm_detail_id = '{uid}', pm_pressure = '{prs}', pm_battery_charge = '{btlvl}', pm_flow1 = '{f1}', pm_flow2 = '{f2}', pm_tot1 = '{t1}', pm_tot2 = '{t2}', pm_door = '{dState}', pm_sup = '{supState}', pm_sent_time = '{datetime}' WHERE pm_detail_id = '{uid}'", connection);
updateData.ExecuteNonQuery();
...
I installed visual studio on the server and copied the code from my laptop and compiled it there too (after installing the MySQL for vs files) and still no decimals,
I'm outta ideas, help me plz ! tnx
|
|
|
|
|
How do you find out that the values are being changed? What is the structure of the table where you add these values?
I notice you are using inline formatting on your INSERT statements. You should print out the final statement to see exactly what is being passed to the database.
modified 26-Aug-18 9:42am.
|
|
|
|
|
To add to what Richard has said, don't do it like that!
Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead.
When you concatenate strings, you cause problems because SQL receives commands like:
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood' The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable; Which SQL sees as three separate commands:
SELECT * FROM MyTable WHERE StreetAddress = 'x'; A perfectly valid SELECT
DROP TABLE MyTable; A perfectly valid "delete the table" command
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.
So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You left out a critical piece of information - the data type of the database columns where the floats are stored!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
RTFM=> 5.7.1 Preparing Statements in Connector/NET
As I am not a MySql developer- so I checked first on your INSERT statement as all of your values are wrapped in quotes, and to see how to use parameters. Wouldn't you know it, them resources at MySQL had a document with both in the same article
Director of Transmogrification Services
Shinobi of Query Language
Master of Yoda Conditional
|
|
|
|
|
RTFM is not welcome on this site.
If it bothers you too much to answer the question, then simply ignore it and move on.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|