« first day (2558 days earlier)      last day (1591 days later) » 

G K
7:14 AM
Hi all,
In my WPF application we are doing scaling of the entire application. I wanted trying to measure the Height and Width of a Button in my window after scaling.

When I use snoop to check the values (Height and Width), they show the original values which I have given at my design time. When I use Greenshot to measure the dimensions of the button, it shows the value as per scaling factor which is got applied.

But the problem is at different DPI Scaling like in 150% and 175%, the values does not match with the scaling factor what is being calcuclated by algorithm. The values also calcuc
 
 
4 hours later…
10:44 AM
Morning
 
 
1 hour later…
12:01 PM
ciao Alex
 
Hi grandangelo
 
12:24 PM
I'm looking at something I did in March... no I don't think I was drunk, not in the morning... But really I don't understand why I did what I did :-)
 
Hi all :-)
@grandangelo welcome to development, I am like this after someone talks to me mid dev 😂
 
1:18 PM
feels better not being alone...
 
 
2 hours later…
3:44 PM
@GK i think my first question would be why do you need to know the height and width of a button? generally you design your app so it works "automatically" while being scaled
if you are measuring size to make the UI work somehow, there is probably a better approach
 
I believe you can use ActualWidth and ActualHeight. But yeah, bad idea in general. You shouldn't care how big your control is (unless doing very specific things like writing a custom panel)
 
 
1 hour later…
5:13 PM
i have done percentage based sizing on scaled stuff using converters
 
6:13 PM
Wow, meta is still burning.
As Bradley says, Rome is burning
A lot of posts there on the situation
Mods quitting. Makes me sad
 
6:57 PM
He's right, though - I would've said 2015, but SO has been on the decline for quite a while now
which is why I pretty much quit it entirely a couple of years back
 
A recent question I posted, the comment on it so depressed me, I immediately deleted the question.
I don't blame you for wanting out
I now use it mostly to look up stuff and chat. Maybe answer, but I know the "experts" will jump in and bury my answer in down votes. So why bother
 
7:53 PM
Any xkcd fans out there?
 
8:18 PM
Alex, I haven't seen the answer burying phenomenon before
Yeah, saw that book announcement a while ago
I cannot believe I just read this:

> One of the most common forms of rejections online occur when our invitations to
> connect with friends or colleagues on LinkedIn or Facebook are met with silence,
> or when someone we know well doesn’t follow us back on Twitter. Our feelings can
> be extremely hurt in such situations. Indeed, we often experience any lack of
> reciprocity on social media as a kind of shunning.
newsflash: My usage of social media has nothing to do with you.
I just find social media useless
Alex, any examples? I know I've never done it, but anything I should be on the look out for (regarding the burying thing)
 
 
2 hours later…
9:56 PM
Who's the best at maths here
 
What math you need done, Rudi?
 
depends on what kind of math
 
10:31 PM
Check this out
 
Off the top of my head, you are doing some super sketchy stuff by adding the things together, then multiplying/dividing them. I'm guessing there's a mistake in the analysis of how the fractions turn out
 
Yea it's v confusing - basically if Amount1 consumes the entire rate threshold, everything works fine
 
but its hard to tell exactly what formula/math you think is happening vs. what is in the code
like, adding the two percentages together, then dividing, then multiplying each individual by parts, then subtracting pieces of that out (not to mention the magic "CalculateRates" function)… I don't think we can debug that
oh, I see it at the bottom, nm on the magic method part
 
CalculateRates is just taking the threshold off the amount and multiplying up by the rate
yeye
I'm trying to see if I can simplify it down sec
 
I don't have time... but my recommendation would be to write it out with actual math symbols on paper
run the algorithm and see why it doesn't solve
the Math.Max is probably why your alogorithm breaks down based on the input data
could you just be exceeding the allowed inputs for whatever function this is derived from?
 
10:45 PM
The math.max() is there to prevent it doing 100-150 * 0.1 and going negative
Because if the total is 200 for example it would be 200 - 150 * 0.1
 
But it sends it to 0, so there is some sort of bounds where the numbers will get off (at least, I would think)
but basically, that's what I'm saying. Is the algorithm actually supposed to produce the expected results when that limit is breached?
 
It sends it to 0 because the first component result is 0, to calculate it on the second amount, you need to take in to account the first amount (as already being used from the threshold)
Overall, yes, not with the 2 components
The point is that amount 1 is using a portion of the threshold from the calculation in amount 2
So how is it possible to calculate what amount 2 is, exclusive of it being within it
 
I guess I'd have to know what the actual calculation is intending to achieve. Like I said, the fractions/distributive property is really messy
 
decimal threshold = 50m,
	rate = 0.2m,
	alreadyUsed = 10m,
	total = 110m,
	check = 10m;

var totalExclusive = (total - threshold) / (1 + rate);
var calculated = totalExclusive * rate;

Console.WriteLine(calculated != check ? "Bad" : "Good");
Here is the simplest I can boil it down to
That doesn't take in to account 'alreadyUsed' from the threshold
So for whatever reason, alreadyUsed has been consumed elsewhere, the calculated must still equal 10
 
I'll try and take another look in the morning. Numbers don't typically get "consumed" :)
 
10:54 PM
It's in part of a 2 step calculation, 1 where the rates are calculated atop that amount (in this example that first step total is 10), this part (2) where the rates are within that amount. Those 2 amounts need to be added together to get to the total
The threshold applies across both numbers - which is very simple when that threshold is consumed by part 1, because the entire amount of part 2 is subject to a flat percentage
 
So this is "Amounts up to 100 are subject to X percent, 120 Y percent" type problem?
and the answer being searched for is overall percent?
(for a given starting amount)
 
If amount doesn't breach the threshold, nothing is due
If amount breaches the threshold, amount less threshold * rate is due

That bit is obviously simple, but there are 2 parts to it. 1 part where the amount is exclusive of the rate, and so gets calculated on top of it. Again quite simple. Part 2 the amount is _inclusive_ of the rate, and so we need to figure out what the rate is within it

Again quite simple when we can say the second rate's entire amount is subject to the amount (because the first part has already passed the threshold)
Sorry 4h sleep does not help with articulation
That bit might actually be relatively simplistic too (as I can calculate the relative usage of the threshold against the amount in part 2 and determine what % of that is actually the inclusive rate), but as in my first example (the fiddle) when 2 differing rates and differing thresholds are involved, it gets more complex
 

« first day (2558 days earlier)      last day (1591 days later) »