My brother asked me to develop an application for him, but I don't exactly know how to plan it. It will be a WPF program with set of controls and I know how to make everything, except there should also be a datagrid and a bunch of labels and other controls updated continously with a XML feed from a server. Application will aproximately query and refresh the XML data every 2-5 seconds. I know there exist several methods to do that, but I would really choose the best one between quality and performance. I've never done something like that before, so I'm here to ask what is the best approach for continous download of XML files, parsing them and putting the data into WPF controls?
Related
So I'm rewriting a windows forms project.
The old project had few issues. These are some I'm trying to fix right now.
My problems:
Everything was on panels on one form. Switching screens in the code was done by hiding/unhiding these panels.
General slow performance across screens.
Poor data coupling.
My solutions:
Break up screens into user controls (hereon just refered to as 'screen(s)'). My main form has 3 components on it, a nav bar, title bar and 'view port'(an empty, docked, panel).
I will keep only one screen/user control (hereon just refered to as 'screen') in memory and docked in the view port. This is done by just initializing a screen and popping it into the view port panel on the main form. Changing screens will simply be destroying the current screen in the view port and initializing a new one in it's place. This isn't to reduce memory usage but rather active components, as what I understand, slows down the old winforms project, is the fact that winforms uses the cpu to render.
This is where the subjectively fun part comes in. If a controller/presenter(from mvc/mvp type patterns)/code changes business data, the screen that is displaying that data needs to be updated. Since there will be only one screen displayed at one time, I will now need to go check if the screen affected by the data is currently initialized and update the screen. I think checking which screen uses a piece of data and checking if that screen is active and then changing the appropriate visual component, for each piece of data will be moronic.
So when I initialize a screen I will just bind (with data binding) all of it's controls to my global state. This feels perfect since I will have some services impacting my state with their own controller, and the changes will be handled the same as a ui event changing the data. This is also great since my data layer will need to propegate to rather (for me) complex databases, so keeping the data layer clean will help.
My questions:
Am I managing my screens properly? Is it a good solution to slow performing winforms software?
Should I use data binding to achieve this? In this case it will be my sole source of view data, and I've read that data binding should be used in moderation. What am I missing.
I'm quite green and this job is my first C# bout. Although I have done java and flutter/dart before.
Also if there is a better place to ask these types of questions, I would appreciate a point in the right direction. There isn't any/other/senior/superior software engineers at work who I can ask these types of questions.
Working with relatively complex software, communicating over ethernet with hardware devices here.
I prefer having many many small windows that save their position when closed and restore their previous position when opened so that users can arrange them as needed.
Since I work with relatively slowly updating data, I periodically keep updating the data in the controls, unless they are focused (eg. potentially currently being edited).
Sure, with this, the data might be inconsistent sometimes, but no one will notice in the 50ms timeframe until the next update.
Since this is done for practically all my controls, the logic can also be centralized beautifully.
This, of course, goes against the binding paradigm but it's my development style which also works well for other programming languages.
Currently we're making a c# application (using WPF) and everything goes well. The only problem we have right now is that we want our application to be able to print documents directly from our application to the printer.
What we need to print is a list of customers, but not listed on a sheet, instead it should print 1 full page of information from every customer that yet haven't been printed. The document should also contain some formatting such as a "Result" section where you manually fill in information using a pen later on.
I've found several solutions but they all require us to either use iTextSharp and have Acrobat Reader installed. This way works but just complicated things for later on as some of our teachers doesn't even know what google chrome is, and less so even grasp the concept of having to install acrobat reader to be able to run this program.
Our other option is to create a simple report directly in c#, but all the tutorials use windows forms and a datagrid which doesn't feel very effective for what we're trying to achieve. Also we can't find reports in the "add new" menu for the solution explorer and we're not using windows forms.
Basically we want to press a button which automatically prints all the new customers that yet haven't been printed out. We're all good with the other backend stuff like marking the customer to not be printed again and so on, it's just the actual document formatting that've had us stuck for days now. I've searched for "c# create invoice" and so on, but every tutorial uses windows forms or Crystal Reports while we can't.
Any suggestions?
I'm currently working on a C#/WPF program where I'm displaying a lot of text data(replaying a text log). This runs on a timer that reads from text files and then sends the data to a User Control that will display them. The problem I'm having is that it takes more than one second to display the data that covers said second(due to the amount of data, ~11k lines pr second) in the TextBlock I'm using. If I skip the displaying part the timer/program runs just fine without any delays.
What is the best UI element to display this amount of data with in regards to update speed?
With large data, you are almost always better off if you paginate the results.
This is the approach google takes with their search results. You get millions but only a fraction are on the first page.
Microsoft gives you the tools to accomplish this - FlowDocument
You can very quickly get professional looking reader style output, like a Kindle screen.
Try AvalonEdit which is great at handling large data, unlike TextBox/Block which makes UI unresponsive when dealing with large data. http://www.codeproject.com/Articles/42490/Using-AvalonEdit-WPF-Text-Editor
Are you sure users would need the entire data? You can alternatively just show the tail of logs (e.g. last 100K lines) and provide a link to download the entire text or some kind of paging mechanism.
You could create a collection of your log messages / strings / lines, and use them as the itemssource of a virtualizing panel, such as the Listbox uses it by default. Only those messages that are actually in the field of view will be rendered.
I am working on a simple task app that uses windows forms.
WPF might be better toolwise, but I just don't want to use a technology that uses GPU acceleration just to render something transparently. I think its idiotic.
My problem is as follows: I have a main windows which contains a series of controls. At the press of a button, another form is shown (with ShowDialog) in which I can create a task. Pressing save, adds the task to the main form's listbox where all tasks are shown. Right now,all the communication is done via button click events (mostly). I would like to have something more elegant, like a communication interface between the dialogs.
EX: When I create the task, I want to automatically assign it to a project (which is probably going to be a an array containing all the tasks) and at the same time add it to the aforementioned list & have it acessible from memory. I am not sure how to achieve this, as using collections and arrays to manipulate, feels a bit impossible & overly complicated. I had seen some people suggest using delegates, data binding and interfaces. But I don't know exactly how they can be used and MSDN documentation is just impossibly difficult to read.
I think something similar to this: http://www.youtube.com/watch?v=sgMoNSNLLvg might be of use to me, but I'm not sure how to implement it. Also, thinking of saving the app settings/state into a file. I've seen XML, App.Config and whatnot. My app plans to be portable, which means that either saving its settings into the %user% app settings folder, or something similar. BTW: Not learning for an exam or something, just building an app to learn by myself. I'm actually a UI designer. ;)
I have a C# win form where I read a file and show lines in a datagridview. Everything works fine.. and I use delegate and Invoke for displaying the lines as they are being read. It also shows a progressbar and does some other stuff like calculating line length and parse the lines to extract certain fields from each line.
Just curious, if anybody has tried this kind of implementation. Currently my app reads a 250MB file (having ~ 12000 lines) in little over 3 minutes (Win 7 32bit/celeron 2.66Ghz/4GB). I was wondering if it is possible to reduce the time - more of like by changing the way I implemented it.
Well, you're quite right to have second thoughts about this. What's probably the toughest read possible, War and Peace by Tolstoy, has roughly half a million words. What you're dumping to the screen is a hundred times more. It doesn't really matter how long it takes to put this much info on the screen, it will take your user a wholeheckofalot longer to even scroll through it.
I personally hesitate to ever put anything more than, oh, 50 items in a list. 100 tops. Beyond that, it becomes sheer torture for a human being.
To get there, allow your user to filter content, gradually drilling down in the huge result set to a relevant item. Exactly what that ought to look like is not clear from your question. Think about it for a bit, I'm sure you'll come up with something.
Ok...I love these questions. Why are you showing a user 250mbs of data in a data grid? There is NO WAY that an end user can process understand 250mbs of data in a grid. If the end user is pressuring you for this feature you need to address it with them from a "this is a bad idea" standpoint. Performance problems can usually be solved in most cases by educating the user. :-D
First, you need not load the entire file, nor display it. You can load portions of it for display. i.e. in the grid, you cannot show the enire file anyway, the screen is only so big. Consider loading only what you display (plus a few extra lines for smooth scrolling) and load the rest on demand as the user is scrolling through the content. The user will be unaware that the file is only partially loaded.
Even nicer would be if you have some logical grouping, in a book you could display the chapters, in a financial type application, either by account or time period.
Maybe something like VirtualMode can helps you:
Virtual mode is designed for use with very large stores of data. When the VirtualMode property is true, you create a DataGridView with a set number of rows and columns and then handle the CellValueNeeded event to populate the cells. Virtual mode requires implementation of an underlying data cache to handle the population, editing, and deletion of DataGridView cells based on actions of the user. For more information about implementing virtual mode, see How to: Implement Virtual Mode in the Windows Forms DataGridView Control.
P.S. About performance: no one except profiling tool can't helps you to solve any performance-related problems.