Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
gently caress, do I struggle with Form controls.

I have a form which has a PictureBox in it. When the form loads initially, that picture box is a gray dot. When I hit a button, it needs to turn to a green dot. I can not for the life of me get this son of a bitch to change it's picture. Just to test it, I'm trying to get it to flip a color on startup, and it won't even do that and I'm way too stupid at Windows Formsprogramming to understand what's happening. 'main' is the form name. My code looks like this:

code:
public partial class main : Form
{
...
        public void changeNtpStatus(int status)
        {
                switch (status)
                {
                    case 0:
                        ntpBox.Image = sysinfo.Properties.Resources.gray;
                        ntpBox.Refresh();
                        break;
                    case 1:
                        ntpBox.Image = sysinfo.Properties.Resources.green;
                        ntpBox.Refresh();
                        break;
                    case 2:
                        ntpBox.Image = sysinfo.Properties.Resources.yellow;
                        ntpBox.Refresh();
                        break;
                    case 3:
                        ntpBox.Image = sysinfo.Properties.Resources.red;
                        ntpBox.Refresh();
                        break;
            	}
        }
}

code:
internal class Reporting
  {
    private main form = new main();
...

    public void createWindow()
    { 
        Application.Run(form);
        form.changeNtpStatus(1);
    }
}
code:
  internal static class Program
  {
    [STAThread]
    private static void Main()
    {
      
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);

      Reporting report = new Reporting();
      report.createWindow();     
    }
  }
}
Now, if I flip the lines in Reporting.createWindow() to be

code:
    public void createWindow()
    { 
        form.changeNtpStatus(1);
        Application.Run(form);
    }
Than it will load as a green dot, as it should. But anything that happens after Run() is called is no bueno. I just want to change the picture in a picture box on a button click! This has got to be really simple. What the gently caress do I do!?!?

Adbot
ADBOT LOVES YOU

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Forgall posted:

I don't see your button click event handler in code you posted, do you have one?

Oh yeah. I removed pretty much all the functionality in the name of isolating where the problem is here. Complete code for main is:

code:
namespace sysinfo
{
    public partial class main : Form
    {
        public main()
        {
            InitializeComponent();
        }

        private void createReport_MouseClick(object sender, MouseEventArgs e)
        {
            Reporting report = new Reporting();

            report.run();
        }
        public void changeNtpStatus(int status)
        {
                switch (status)
                {
                    case 0:
                        ntpBox.Image = sysinfo.Properties.Resources.gray;
                        ntpBox.Refresh();
                        break;
                    case 1:
                        ntpBox.Image = sysinfo.Properties.Resources.green;
                        ntpBox.Refresh();
                        break;
                    case 2:
                        ntpBox.Image = sysinfo.Properties.Resources.yellow;
                        ntpBox.Refresh();
                        break;
                    case 3:
                        ntpBox.Image = sysinfo.Properties.Resources.red;
                        ntpBox.Refresh();
                        break;
            }
        }
    }
}
The context under which it'd be used looks something like this

code:
public string createHash(sysinfo.main form)
        {
            try
            {
                string[] strArray = Enumerable.ToArray<string>(Enumerable.Select<char, string>((IEnumerable<char>) string.Format("{0:ddMMyyhhmmssffff}", 
			(object) SimpleNTP.GetNetworkTime()), (Func<char, string>) (c => c.ToString())));
                string[] input = new string[8];

                form.changeNtpStatus(2);
                //System.Threading.Thread.Sleep(1000);
                //updateStatus(2);

                for (int index = 0; index < 8; ++index)
                {
                    string str = strArray[index] + strArray[15 - index];
                    input[index] = str;
                }

                this.finalhash = this.createHash(input);
            }
            catch (Exception ex)
            {
                Console.WriteLine(((object) ex).ToString());
                form.changeNtpStatus(3);
                //updateStatus(3);
            }

        form.changeNtpStatus(1);
        //updateStatus(1);
        return this.finalhash;
        }
The image just won't update. If I can get it to update in the context which I presented it in the post above, I can probably get it to update in it's actual context, so that's all I really need.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Che Delilas posted:

Yeah, you're passing in the form to your createHash function, which reeeealy shouldn't be necessary. Can you show us where you're calling createHash?

Sure -- Just a quick note: I've made a mess of this code trying to fix this. I've restored it to where I left off before I said 'gently caress it'.

First, the form class. This is the only form on the application, so that makes things a little easier:

code:
    public partial class main : Form
    {
        public main()
        {
            InitializeComponent();
        }

        private void createReport_MouseClick(object sender, MouseEventArgs e)
        {
            Reporting report = new Reporting();

            report.run();
        }
        public void changeNtpStatus(int status)
        {
                switch (status)
                {
                    case 0:
                        ntpBox.Image = sysinfo.Properties.Resources.gray;
                        ntpBox.Refresh();
                        break;
                    case 1:
                        ntpBox.Image = sysinfo.Properties.Resources.green;
                        ntpBox.Refresh();
                        break;
                    case 2:
                        ntpBox.Image = sysinfo.Properties.Resources.yellow;
                        ntpBox.Refresh();
                        break;
                    case 3:
                        ntpBox.Image = sysinfo.Properties.Resources.red;
                        ntpBox.Refresh();
                        break;
            }
        }
    }
}
The one button there talks to the Reporting class. The relevant bits look like so:

code:
  internal class Reporting
  {
    private main form = new main();
    private Hash hash = new Hash();
    private OperatingSystem os = new OperatingSystem();
    private CPU cpu = new CPU();
    private GFX gfx = new GFX();
    private HardDrive hardDrive = new HardDrive();
    private InstalledPrograms programs = new InstalledPrograms();
    private Motherboard mb = new Motherboard();
    private Minidump minidump = new Minidump();
    private PageFile pageFile = new PageFile();
    private ProcessList processes = new ProcessList();
    private RAM memory = new RAM();
    private ServiceList services = new ServiceList();
    private StartupItems startupItems = new StartupItems();
    private HardDrive hd = new HardDrive();
    private string report = "";
    public string reportID = "";
    private string reporturl = "";
    private string version = "SysInfo - Version 0.3.1 - 6/23/2014";
    
    private string GenerateReport()
    {
      reportID += hash.createHash(form);

      //report += createHeader();
      //report += os.getOS();
      //report += memory.getMemory();
      //report += cpu.getCPU();
      //report += gfx.getGFXUnit();
      //report += pageFile.getPageFile();
      //report += hd.buildData();
      //report += minidump.getCrashes(reportID);
      //report += processes.getProcessList();
      //report += services.getServiceList();
      //report += startupItems.getStartupItems();

      return report;
    }
The commented out stuff is all functional, but I'm trying to just the one picturebox to work instead of all 15 or whatever it ends up being, so I only call the one method. The method we are working with is in the Hash class:

code:
  internal class Hash
  {
    private string[] hashTable = new string[100]
    {
...
    };
    private string finalhash;

        public string createHash()
        {
            main form = new main();
            try
            {
                string[] strArray = Enumerable.ToArray<string>(Enumerable.Select<char, string>((IEnumerable<char>) string.Format("{0:ddMMyyhhmmssffff}",
			(object) SimpleNTP.GetNetworkTime()), (Func<char, string>) (c => c.ToString())));
                string[] input = new string[8];

                form.changeNtpStatus(2);

                for (int index = 0; index < 8; ++index)
                {
                    string str = strArray[index] + strArray[15 - index];
                    input[index] = str;
                }

                this.finalhash = this.createHash(input);
            }
            catch (Exception ex)
            {
                Console.WriteLine(((object) ex).ToString());
                form.changeNtpStatus(3);
            }

        form.changeNtpStatus(1);
        return this.finalhash;
        }

        private string createHash(string[] input)
        {
            string str1 = "";

            foreach (string str2 in input)
            {
                int index = Convert.ToInt32(str2);
                str1 = str1 + this.hashTable[index];
            }
                return str1;
        }
    }
}
I realize I cannot actually create a new form object here and expect it to change the existing form's state, but I think this at least clearly illustrates what I want to accomplish.

Canine Blues Arooo fucked around with this message at 15:55 on Dec 23, 2014

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Che Delilas posted:

Added stuff in bold. This is correct, you can't do that. But you are also doing it in your Reporting class:
code:
internal class Reporting
{
    private main form = new main();
    //Snip
    reportID += hash.createHash(form);
}
Like you said, you can't create that second form and expect it to change anything on the calling form.

----

Beyond that, as forgall mentioned you really, really shouldn't be changing the state of your UI outside of your form. WinForms is bad about letting you separate display logic from other logic, but at the very least, your form class should be manipulating the color of the picture box based on the results of the other classes, not letting those classes do it.

Something like like:

This is what I ended up doing and it works just fine. It seems so obvious but it never even crossed my mind until you mentioned it. Thanks!

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

biznatchio posted:

Well, you could do something like this, which reduces the amount of boilerplate you need to write, but still requires you to write a field, event, and one-line getter and setter for each property.

Or, you could use the .Net standard INotifyPropertyChanged interface and simplify things a little further into something like this; though you'll pay a little bit of runtime cost with this because it's adding a dictionary lookup and boxing/unboxing to your gets and sets.

You could combine the two approaches to remove that extra overhead, though, at the cost of having to define the backing field for each property like this.

Taking the INotify approach a bit further, you can use Prism and simplify it a bit since some of the boilerplate is just handled. The 'simple' version here still has you signing up for private/public locals, but the class is simple to read and maintain and it's a pretty reasonable amount of boilerplate, all things considered.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Bruegels Fuckbooks posted:

The whole experience with learning WPF and XAML is essentially trolling because most of the time if you try to use something like a UI tookit or a library to do something, you only need to understand the subset of the library necessary for what you want to do, and don't have to read article on article about the overarching philosophy of ***. With WPF, I initially approached it like "this is not cryptography, this is just putting a window with controls on it on a computer screen, why do I need to read all these articles or care about poo poo like view models?" Having that mindset will absolutely kill you with WPF because the framework will give you all the tools you need to hang yourself with monumentally lovely code, and actually taking the time to learn and understand the patterns makes the coding actually trivial.

This is a gospel truth and it really, really sucks because some of those important patterns seem either estoric or needlessly verbose, especially on a first read. I actually really like WPF, but I've written some pretty trashy poo poo on my journey to writing slightly less trashy poo poo now, and almost all of it was borne from an attitude of, 'This seems needlessly complex/annoying to implement/boilerplate for the sake of boilerplate and I probably don't actually *need* it...

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

insta posted:

var is good

Oh, I see we are going to have to fight today...

(I jest ofc, but I usually insist on avoiding var)

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

New Yorp New Yorp posted:

Sure, do it consistently the way I like to do it.

you goddamn right.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
My major beef with it is code readability / observing data flow, in addition to having a full understanding of how things work.

For example, I just implemented language detection in a project with NTextCat. The code example provided looks like this:

code:
var factory = new RankedLanguageIdentifierFactory();
var identifier = factory.Load("Core14.profile.xml"); // can be an absolute or relative path. Beware of 260 chars limitation of the path length in Windows. Linux allows 4096 chars.
var languages = identifier.Identify("your text to get its language identified");
var mostCertainLanguage = languages.FirstOrDefault();
if (mostCertainLanguage != null)  
    Console.WriteLine("The language of the text is '{0}' (ISO639-3 code)", mostCertainLanguage.Item1.Iso639_3);  
else 
    Console.WriteLine("The language couldn’t be identified with an acceptable degree of certainty");
That is nice, but it's also borderline interpreted nonsense for understanding what's actually happening here and how this library is constructed.

We can easily identify factory as type RankedLanguageIdentifierFactory, but what the hell is identifier? Or languages...? We are calling FirstOrDefault on languages, so that's a clue, but it also doesn't narrow it down much. The point here is that if I were maintaining this code, understanding what I'm actually working with requires a bunch of extra time because I'm effectively eschewing one of the major advantages of a strongly typed language by not letting the reader know what these things actually are.

Compare to:

code:
RankedLanguageIdentifierFactory factory = new RankedLanguageIdentifierFactory();
RankedLanguageIdentifier identifier = factory.Load("Core14.profile.xml");
IEnumerable<Tuple<LanguageInfo, double>> languages = identifier.Identify("your text to get its language identified");
Tuple<LanguageInfo, double> mostCertainLanguage = languages.FirstOrDefault();

if (mostCertainLanguage != null)  
    Console.WriteLine("The language of the text is '{0}' (ISO639-3 code)", mostCertainLanguage.Item1.Iso639_3);  
else 
    Console.WriteLine("The language couldn’t be identified with an acceptable degree of certainty");
Immediately there is a lot more information here available to the maintainer. Besides understanding explicit how things are constructed (factory loads an indentifier of type RankedLanguageIdentifier, which is applied to a string that returns IEnumerable<Tuple<>>...), a lot of functionality is immediately communicated. languages is IEnumerable<T>, which means this is actually returning a collection with a specific kind of functionality. Tuple has specific functionality I can use as well. I get all this information without having to start mousing over functional calls on a first read, and it's also easy to reference if I need to look up type information about a specific variable. This is all lost (or at least obfuscated) using var in the name of saving keystrokes, which in my head is a pretty weak reason to not create code that's easier to maintain.

This is also a fairly simple, self-contained example. The problem of readability and maintainability expands a lot as one expands the scope of a project.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

raminasi posted:

While I am personally a var-everywhere guy, I have to admit that it can easily become a pain in the rear end when you don't have an IDE right there, like during code reviews.

Code Reviews are definitely a common use case where it gets obnoxious, but for complex structures, constantly having to mouse over stuff is a mental drain. Do you really want to have to mouse over stuff to see it's type, or would you rather it always be right there?

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
I don't disagree, but how you are going to descriptively name a Tuple<LanguageInfo, double> that implies it's type, or name something of an arbitrary type e.g. RankedLanguageIdentifier . I'd argue it's a 'both' kind of a thing, not one or the other.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Rocko Bonaparte posted:

I need to double check my thinking for extending my WPF GUI for the other use cases. I'd just merrily plod along if it were anything else, but WPF has that little habit of tacitly demanding things be done a certain way and just not render if you do it wrong, or it just somehow becoming a strange mess.

All the screens I am making have:
1. A top bar with a title.
2. A series of buttons that may or may not scroll and whose bodies may have data templates to draw them differently.
3. A bottom bar to show how to return to the main menu, and possibly something else like enabling deleting saves or something.

I'm assuming the way to go to do this is to abstract one view model, develop the XAML to work primarily on that, and then create a window or control for each of the different screens. The abstraction would include the title, how to get at the buttons and the templates to draw them, and what to put in the bottom bar. However, this is WPF and it has a mind of its own, so maybe I'm supposed to spread a live goat out in Visual Studio and stab it with my cursor until the blood fills up something.

With all my WPF projects, I have a custom Window that I maintain with specific functionality I desire, and then on top of that, I usually customize it more per-project. I don't think that's the best way to do what you want to do here, but it's an option. I think Cuntpunch's suggestion is superior.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
Does WinUI have the absurd restrictions that UWP does? I was luke warm on UWP until I learned that you didn't have first-class access to pretty anything useful in the OS. File System access, Registry access, meaningful hardware access - it's all locked off. I don't write software to look pretty. I need it do stuff. UWP doesn't not do stuff and I give negative fucks about 'Touch Support'.

A high level glance looks like WinUI is making the same mistakes. I'm not moving off of WPF/Win32 until MS can actually deliver a feature set that makes a computer work like a computer.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Hammerite posted:

It makes me very happy that I can write "x is not null" in C# now.

Seriously though. Null checks in C# did not need to be as goofy as they were at times.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
I feel like the major selling point of Blazor is, 'It's not Javascript!'.

Honestly, that's a pretty compelling sales pitch.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Drastic Actions posted:

The point here though is unless you already know of things you want to use in .NET Framework that hasn't been ported to .NET Core / NET 5+, you should just target NET 5+ and not think about it.

My Take: If you are building desktop apps that you know are only going to be targeting Windows, probably use Framework.

Edit: I looked into some of the concerns I thought I had about functionality that would be gained or lost in .NET 5 vs Framework, and they seem to be either incorrect or unfounded. I retract the above and label it a 'bad take'.

Canine Blues Arooo fucked around with this message at 19:51 on Jun 4, 2021

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
I don't think I've ever used OneWayToSource, but what an obnoxious edge case. Thanks for sharing! I feel like that's the kind of thing you'd Google forever and only find answers to if you got obscenely lucky.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

epswing posted:

What's the Right Way to trigger some code frequently (every X seconds) in an ASP.NET site? While there are plans to move it to an Azure App Service, and maybe WebJobs is what I'm looking for, it's running as a Site on IIS for now.

If this is on IIS, there is no reason to get a library or a service involved to get a computer to count to 5. You could use DispatchTimer if you don't need better than 1/10th a second of precision and are hosting it on a Windows box.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
Unless you are doing work on front end, there isn't a compelling reason to not be on Core. Conversely, all my projects with UI are still on Framework.

Porting existing projects is of course very project specific.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

fps_nug posted:

just spent my first serious 5 hours since high school learning programming, decided to start with c# for no other reason than accessibility. I learned on python and now that I have an incredibly rudimentary knowledge do you guys have any ideas of where to go from here?

I simp hard for C# and would insist that it's both a strong starting language and a language that does basically All The Things™ well. Some of it's buttery smoothness is lost if you leave the Windows platform, but Core is honestly in a pretty good spot - it's less of a problem then it used to be (unless you want to build interface).

If you want to build Desktop apps on Windows, WPF is pretty outstanding and is my favorite UI framework by a mile.
If you want to just do general CLI tooling, just learning more about the C# language will give you great returns.
If you want to do web stuff, you can go the ASP.NET route, but I'm unsure if that's the 'optimal play', but if you enjoy it, do that!

For desktop apps, I think WPF can be intimidating as you start to learn it, but it's really not that bad once you start getting into it, and unlocking the ability to build apps is very powerful, both for personal tools and tools for others. I'd highly encourage it if you are interested.

Regardless of the specifics of what you want to do, the answer is to find something you think you want to build and build it. Build *anything*. Solve the problems one at a time and be willing to suck at it for awhile.

Canine Blues Arooo fucked around with this message at 19:53 on Feb 1, 2022

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

aperfectcirclefan posted:

Is there a market for WPF developers anymore?

There definitely is. I get pretty frequent emails from all sorts of folks asking for WPF developers. It's definitely not as common as, say, React or [fotm frontend JS framework], but jobs certainly exist.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Small White Dragon posted:

If anyone else is doing .NET on OS X -- is the JetBrains IDE really that much better than Visual Studio, and if so, why?

Rider is decidedly better than VS Code, but VS proper has way, way more features. It probably comes down to what features you want/use. If you use those features, then Rider is gonna fall short. If you do Interface development, then Rider is going to fall way short.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

zokie posted:

I have to make a GUI application and distribute it internally. It looks like I can choose from WinUI 2, WinUI 3, WPF, and WinForms. I’ve used both WinForms and WPF before (5+ years ago). But what I care about the most except for easy installation and updates (ClickOnce looks like it’s still around) I would really like to make the application window me an exotic shape.

Anyone knows if that can be done?

So you can do this, but I kinda recommend against it, depending on what you mean by 'exotic'.

Fundamentally, your window is going to be a box no matter how you spin it, but you can make portions of it transparent and click through and all that if you want and craft a shape however you please. The real problems start in window manipulation. Depending on your shape, resizing might not be very intuitive, or even possible. You have to make sure you are building it correctly to make it resize without problems like distortion or weird margin problems. You probably will need to build your own resizing handles (although maybe chrome lets you set offsets and positions?). You end up with a lot of goofy considerations. You'll have to override the default Title Bar(which is not hard, but another thing to do).

Regardless, write it in WPF. WinUI loving sucks compared to WPF dont @ me. If you are writing your logic in C++ though, it's probably fine.

Canine Blues Arooo fucked around with this message at 00:44 on Apr 29, 2022

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
My favorite MS selling point of WinUI3 is that 'you can create modern looking apps'. That's a style preset my dude.

Please just maintain WPF as your native win32 framework until you actually have a good reason not to. Stop with this 'new framework' nonsense.


These are facts.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
I have what feels like a simple problem:

In WPF: I have a DataGrid that is bound to an ObservableCollection<MyObject>, which can have up to hundreds of thousands of items in it. I frequently add to said ObservableCollection and the newest item is placed on the bottom of the DataGrid... But I want to place it on the top.

DataGrid receives an Index from the OC to determine where it should be placed. Placing it on the bottom is really easy - appending to an OC is an O(1) operation and that makes me real happy. However, appending to the beginning isn't really an option. What I'm trying to do here is avoid something that's O(n) every time I add an item.

The first option is pretty obvious: Don't use DataGrid. Build your own thing that reads from the back. The problem here is that that is still O(n) since you have to 'rebuild' from the back. To spare you some details, every thing I've thought of is *at least* linear time, and most of them are O(2n). My current implementation is to write to a 'holding OC', reverse it and use the reversed OC as my default search source, which means that the actual cost is O(3n) now. The nice thing is that this is very easy to write, but the perf has much to be desired.

Perhaps unsurprisingly, this is actually quite performant on my computer. At 10,000 items, the time to do that entire block of operations is <3ms, so that's definitely acceptable and I'm willing to just let it ride for now. At this point, I'm more academically curious about this problem then I am for practical reasons.

Is there a way to show the most recent item appended to an OC as the first item in a DataGrid (or any collection view) in less than O(n) time?

Canine Blues Arooo fucked around with this message at 18:53 on Jun 1, 2022

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

epswing posted:

Not sure how to solve your specific problem offhand, but have you considered paging the collection? No human can 'browse' a list of 100,000+ records. Actually, you mentioned "search source", does that mean a user would search/filter the big list, and then edit the results?

Can you use sorting to solve your problem? I.e. who cares how your OC is ordered, just let the DataGrid sort it (maybe via CollectionViewSource)?

This software is a 'remote logging' solution. Any apps can just bring a logging library and call Write with parameters and it'll blast a message to an arbitrary address, or just localhost. The use case is that you can have persistent logs regardless of app state, and your can consume logs from any number of apps simultaneously.

To that end, I'm not too interested in paging since that UX starts to suck under load. Yeah, a human doesn't really care about thousands of lines, but they generally care about the last dozen or so.

Talking this out presents a pretty obvious idea. Store the last few hundred in the 'active' OC, but just discard anything not recent and stash it in an 'everything' OC. If you want to search everything, expose that as an option. It'd keep things snappy.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

raminasi posted:

Have you considered creating a custom backing structure that implements INotifyCollectionChanged?

I actually do, but it's based on OC. Since it needs to be thread safe, it's called ConcurrentObservableCollection.

Maybe going back to the drawing board on that might be the way.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

zokie posted:

Shouldn’t the list control be virtualized? Then if you are adding an item outside of the “viewing window” should that really cause new rendering?

And if you are displaying logs, why use a data grid? Those are for editing stuff, at least in my world

The DataGrid is temporary. It's a really easy to hand an object to something and say, 'draw data plz', but everything eventually will become a ListView.

It probably should be Virtualized.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

epswing posted:

Is MAUI still a nightmare or if one wanted to build a dead simple LOB (i.e. load list of records from API, open record, edit simple fields, save record) it’s kinda alright?

I'm not a MAUI expert. I'm a huge WPF simp. With that said...

If you know WPF and are targeting the the Windows desktop, there is absolutely no reason to not use WPF. If you must be xplatform, then you could do a lot worse.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

raminasi posted:

I’m sad I’m leaving my .NET job before I get to play with this stuff :(

I left .NET for a year and immediately missed it. I'm back in it now and am not anxious to leave. I'm so sorry I betrayed you - never again!

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
My take would be that unless you are building something cross platform, there is no reason to not use WPF.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Hughmoris posted:

Broad question here from a novice:

For those working in .NET, what field/domain are you working in? It seems like more and more of the popular blogs/articles/tutorials are focused on front-end webdev which I have zero interest or talent in. I think it could be interesting to build a desktop app but the general sentiment is "just build it with React".

So, for those of you not out there building websites, what do you build with .NET?

Tooling for game dev stuff, which is almost entirely WPF. And what isn't WPF should be :colbert:

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

ChocolatePancake posted:

I agree completely about tuples. Very useful for a quick throwaway type, but if you'll be needing them any more than in the next couple of lines, make a proper type for it.

Echoing this verbatim. I've used Tuple for this kind of typing less and less over time and basically only use it now for something extremely ephemeral. Just make a proper type 99% of the time.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Surprise T Rex posted:

What's the state of the art for creating PDFs in C# code now? Ideally one I can run from a serverless Azure Function or AWS Lambda. At work we do some of this using rendering Razor templates to HTML and feeding it to Puppeteer(?) to basically fake a print-to-PDF, but that requires us to run it as a docker container so we can bundle a headless Chrome with it and that seems like more effort than is necessary.

QuestPDF seems good but new and I'm not sure if I'm just being blinded by it looking semi-modern.

If your document doesn't need complex elements, I'd just do it in PDFSharp/MigraDoc. I've used it in the past and it's been easy enough to use if a bit verbose. If you aren't actually interested in constructing a PDF, but just printing one, I guess you can use a service but then prepare for all the poo poo that comes with it.

You don't need this mess of services and containers and all this poo poo just to run a browser so you can 'fake' print a PDF. Like, at some level of document complexity, that becomes an attractive solution, but holy poo poo this pipeline can begin and end at 'project code'.

Canine Blues Arooo fucked around with this message at 03:56 on Jan 11, 2024

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
I tried Rider for a bit, but it is missing a lot from VS. I still revisit it from time to time but their most recent redesign has put a nail in that. It looks like some stupid web idiot got to design productivity software. There is a hamburger menu in my IDE... No thanks...

Adbot
ADBOT LOVES YOU

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Jen heir rick posted:

I hate writing web apps and wish I could write native apps, but it seems like the world is moving to hybrid/web type apps. The economics are just too good. You can have a single team write an app that works on android iOS, macOS, Linux, and windows. You just can't beat that with native apps. You need a team or developer for each platform. The suits just aren't gonna pay for that. Even if the result is a shittier experience. People will get over it. poo poo sucks yo.

This is a big reason I'm into proprietary tooling. gently caress that web bullshit. Build in WPF.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply