|
I make no apologies:
if(methodcall(param1, param2, param3)) {
outcome = AnotherMethod(MethodCall(param1, param2, param3), someintValue);
return;
}
if (methocall(param2, param3, param4)) {
outcome = AnotherMethod(MethodCall(param2, param3, param4), someintValue);
return;
}
if (Methodcall(param3, param4, param5)) {
outcome = AnotherMethod(MethodCall(param3, param4, param5), someintValue);
return;
}
throw new exception( "Logic error" );
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi,
as others already noted, every second call to MethodCall(param1, param2, param3), I mean the ones after the question marks, is likely to return true, as you just have tested for true (that is what the question mark does). I say likely, it might be ugly code that creates or uses nasty side effects. If so, what follows needs some adjusting.
it seems all your params have the same type, and all your someIntValues have different values, so I would suggest you:
1. stuff all the params in an array "paramsArray"
2. stuff all the someIntValues in an array "someIntValuesArray"
3. modify your MethodCall() to accept paramsArray and return an integer, being the first index in the paramsArray for which the original MethodCall() did return true; this basically means surrounding existing code with a for loop, adjusting the params (now array elements); also return a special value if no match found, say -1.
4. then simply do
int index=MethodCall(paramsArray);
if (index>=0) outcome=AnotherMethod(true, someIntValuesArray[index]);
|
|
|
|
|
Hi,
i have a report with the below structure
<group 1="">
<group 1="" header="">
<group2 footer="">
i'm trying to export this report to excel with repeated headers and footers with N number of rows to print the report..
After setting the page break calculations and repeat header and footers, the report does not break with the exact N number of rows..
i have few merged rows inside the report and conditions to hide rows..
Appreciate if some one could help me to achieve this... its really urgent
thanks in advance
|
|
|
|
|
|
I've just checked and nobody here appears to have this on their ToDo list at all, much less near teh top.
Are you sure it's urgent? Even the cat isn't too fussed about it at the moment.
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 go no experience at all in scanning barcodes, so excuse my ignorance.
What's involved in scanning a barcode and getting back the product's image?
I can provide more detail on the projects idea if needed.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Most barcode scanners are of the "keyboard wedge" variety. Scan a code and it "types" the code into your application.
The thing is, since the scanner types the code, you have to have a way of recognizing that the code is being typed by the scanner. So, most scanners will also let you configure a prefix and postfix you can add to the code. If you setup your code to look at every keystroke at the form level (Key Preview) you can look for the prefix and if you see it, set the focus to a textbox that takes the code, and the look for the postfix to know that the code is done.
As for the image, you have to look up that barcode in your own database if you've got images for each item. If not, there's public databases that have this stuff, but don't count on a free one. How you access them is dependent on the API for the vendor you use.
|
|
|
|
|
The scanner is the simple bit - all it returns is a string effectively, which contains the Article Number. Converting that to a product needs a database.
There is a free one here: Open Product Data[^] which you can access via code, but I've not done it. This chap has: OurGroceries[^] and he's a really nice guy. Ask him politely and he may share his code with you (particularly if you aren't in competition with him!)
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 Griff.
Just found this:
POD - Product Open Data -
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Hi Guys.
I'm trying to learn C# at the moment. I did some years ago using .net and WinForms but revisiting the language it seems WPF is the way to go? It might be me, but WPF seems a great deal more fiddly. Solutions that were really quite simple in Winforms, appear to take longer to code in WPF!
Not to rant. I'm sure there are many hidden benefits to WPF if I just stick with it! but I'm currently tearing my hair out after about 4 hours of failed googling. I just wanted you to know where my head is at before I go into the specific problem. I'm sure I'm not the first to find myself staring at the WPF framework in total confusion.
So. I managed to build a form (Window lol) with 5 buttons. Each button successfully opens an instance of a child window. One of these windows called 'LogWindow' contains (yes you guessed it) a textbox that I'm using as a log. Another window, that 'does something' needs to output a text based result (success or fail) to the LogWindow textbox.
I though this would be as easy as saying LogWindow.Textbox1.Text += updateText + /r/n" or something like that, but no, apparently not in WPF land.
Can anyone point me in the direction of a simple example where this is done? I think my knowledge needs more of a refresh than I thought lmao!
My Code Parts:
private NetworkingWindow NetworkingWindow = new NetworkingWindow();
private ClientWindow ClientWindow = new ClientWindow();
private LogWindow LogWindow = new LogWindow();
foreach (Error NetErr in results.Errors)
{
LogWindow.LogTextBox.text += updateText + /r/n"
// I suspect that this is wrong and I'm contacting the control in a non WPF manner
}
Any help would be greatly appreciated. Fully working examples with comments would be fantastic as I tend to go grab a coffee and read through them to try and learn what I can that way.
Thanks All!
|
|
|
|
|
Member 14058802 wrote: it seems WPF is the way to go?
Um ... not sure about that: WPF Dead or Not?[^]
There doesn't seem to be much support of / for WPF at MS - UWP and Xamarin Forms appear to be getting all their attention.
And my personal impression is: nice idea, badly implemented in VS. The designer is a true PITA after the simplicity that is WinForms! Doing anything pretty much means manual editing of the XML.
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 for the feedback Griff.
I'm 41 and so have plenty of experience of Microsoft technologies getting ummm... 'Microsofted'? I guess this is one of those times.
So, I'm already feeling like it might be a good idea to drop back to WinForms? or is there a better way that I've not even found yet?
I've only built about 6 windows in wpf and the c# can be tweaked back to fit Winforms, so it won't be a problem. I'd just like some help to get pointed in the right direction if that's ok!
Best Regards,
James
|
|
|
|
|
Wait and see what others say - I've been wrong before.
WPF just doesn't feel "finished" - the framework support is good, but the designer stuff feels like "version 0": thrown together to test the tech rather than written for release to devs.
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!
|
|
|
|
|
Ok so, problem solved!
I'm going to thank Griff (Thanks Griff!)
After the last update, I decided to go for a walk with the dog and contemplate a possible move back to Forms. I'm not great with C# but I'm enjoying it. I reasoned that maybe I need to stick with Forms which are more familiar, so that I can stick to learning C# better and then maybe move to WPF later on.
I think maybe the fresh air awakened some brain cells as it dawned on me that this isn't a WPF problem, it's a C# problem... or rather a me forgetting the fundamentals of access modifiers problem. As soon as I realised, the dog just got a shorter walk then normal (sorry dog lol).
Sorry to waste your time Griff, but thanks for the chat.
As soon as I changed the logwindow instance to static, and called the LogUpdater method from the child Window it worked!
private static LogWindow LogWindow = new LogWindow();
public static void LogUpdater(string stringUpdate)
{
LogWindow.LogTextBox.Text += stringUpdate + "\r\n";
}
James Wyatt - Putting the fun back into fundamentals!
|
|
|
|
|
|
|
I'd really enjoy reading an article from you describing your experience with these newer tools. Is the "desktop bridge" usable without high-overhead ?
thanks, Bill
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
I'm going to dispute OG assumption that WPF is dying or dead (I'm the dev who is still pissed at Silverlights demise so...) WPF has a steep learning curve especially from winforms. I found it well worth the effort as once you get moderately proficient production is fairly rapid.
Work through a few tutorials, get familiar with MVVM, I use the GalaSoft framework because it is really minimalist.
One additional benefit is that Xamarin forms seem to be based on the same xaml concepts.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Thanks Mycroft. I'll take a look. I'd not heard of Galasoft yet, but yes, MVVM references keep popping up during my travels.
|
|
|
|
|
Lots of options:
public string TheText { get; set; } = "Bound value";
private void UxOK_Click( object sender, RoutedEventArgs e ) {
Window log = new Window();
TextBlock tb = new TextBlock();
tb.FontSize = 24;
log.Content = tb;
tb.Text += "Good" + Environment.NewLine;
tb.Text += "Bye";
log.Show();
}
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi,
i have a report with the below structure
<group 1="">
<group 1="" header="">
<group2 footer="">
i'm trying to export this report to excel with repeated headers and footers with N number of rows to print the report..
After setting the page break calculations and repeat header and footers, the report does not break with the exact N number of rows..
i have few merged rows inside the report and conditions to hide rows..
Appreciate if some one could help me to achieve this... its really urgent
thanks in advance
|
|
|
|
|
This issue I have it for a while, almost 1 year or more. I tried diverse permutations but always got stuck at some point, when the whole idea will not work anymore. And I give up all the time on it.
I have a class with properties, fields and methods in it. I am thinking to add events to it, but im not that great at them yet. When i call this class into form1 I basically change some values inside class, and the "object" that represents it, will add value or change color or change position ,etc.
If i have a game let's say, when the character stays and I want him to look like it's breathing, this property should be inside the class? or outside, letting me choose when to breathe, how much, how long, how fast,etc. It's just an example. I had a lot of similar (and more complex) encounters with this subject and I simply freeze in the middle of it, not knowing how to manage it anymore.
Both ways are good! From outside or from inside class. But... sometime i need maneuverability, sometime is just in the way and i want it 'there' behind some close door(inside class I mean).
What your rules say about this thing? Should I change its values from inside the class? Or from outside?
Thank you.
------
thanks to OriginalGriff i relocated here the question.
q12
|
|
|
|
|
Don't sweat it, it's something you will learn to decide better as time goes.
As a rule, if your property has public setter it implied people will set it from outside!
Property usually have very simple set/get behaviour. But you could imagine the class having an Update() method that does some property updating.
As well as an external agent modifying them wen needed.
|
|
|
|
|
_Q12_ wrote: If i have a game let's say, when the character stays and I want him to look like it's breathing, this property should be inside the class? or outside, letting me choose when to breathe, how much, how long, how fast,etc. It's just an example. Inside, since it is part of.
_Q12_ wrote: Both ways are good! Nope.
Breathing would be done by a "AirSupplier", a base class that both Lungs and Gills inherit from. That way you can instantiate a fish with gills, and a rat with lungs. Add an IBreathable interface for quick filtering of breathing things.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Your character (class) could have a "Timer" that regulates breathing (and maybe another "ticker" for a heart).
Then you can "attach" (using "component composition") an air supply to your character.
Inside the air supply, you can have another timer so that eventually the air "runs out".
You can attach a "progress bar" (another component) to your character that goes to blue as air runs out.
Think "components"; and how to build more complicated components and scenarios from them.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|