I'll add to Eddy's information, except as applies to WPF.
This is probably the simplest view, but I use INotifyPropertyChanged for program properties that are bound to screen controls. When the program is changing the value rather than the user it lets you update the value whenever you like, and the screen updates naturally. The benefit of doing things this way is that the relationship between the property and the control is defined by the binding, so that it works the same everywhere. You don't have to worry about changing update code wherever you change the value.
I'll admit I don't particularly like the binding mechanism. It's complex and expressing bindings directly in XAML can be an exercise in frustration. I set most of my bindings in the C# code-behind because the XAML syntax is so awkward.
In its way binding is very useful. It lets you handle conversions between the on-screen depiction and your internal representation consistently. For data entry you can add your own validation rules and integrity checks.
One caveat to my statements. I don't do data base applications so I'm not familiar with more elaborate bindings, say between a data base table and a grid control. I imagine there are quite a few articles here on CP and examples in the wild that can help if you need it.
This is sort of a "What would you do in this situation" post.
Our company has had a Windows program in use for many years since VB6.
The short description is that this program collects data points. It also makes use of DDE to make that information available to Excel. The user enters the server and topic in an Excel cell and gets the value from our program or can set a new register to monitor.
I have been asked to update the program to .NET and add some features. I am doing this is C#.
DDE is of course outdated and I have been trying other alternatives OLEDB / Interop and such.
The problem is that management wants all of the configuration to be on the Excel side so that its stored with the worksheet. (As it had been previously). For example my program shouldn't put a value in a specific cell. Rather it should behave like the DDE example did. and it shouldn't be using VBA to call the program via dlls or anything as the customer won't have access to that.
My background is not primarily .NET and I don't do much with OLE/COM/Interop ect.
I have been reading as much as I can and I have gotten to the point that if I know what cells to work with from the C# side I can get most of the functionality I want. However I have no idea how I would make this work such that the customer can specify everything about the shared data on the excel side.
Any thoughts? How would you approach a solution?
Edit: Edited to try to clarify that the management is really just trying to retain the functionality that the previous software versions had via DDE. As a developer I am trying to determine the best solution knowing DDE is obsolete. As of yet I haven't been able to find a newer technology that will meet the specific requirements of this tool. Its not a contentious situation or anything like that and I have no issues speaking up when I don't believe things make sense.
So really the question should be rephrased as.... "How would you approach a technical solution?"
The spreadsheets in this case would generally be setup by the customer using our equipment. Our prior app just acted as a server. At the moment the argument is that all of my solutions are too complicated for the customer or won't save with the excel file. Its for industrial customers not the typical office user.
I thought I might be able to get away with automation and maybe referencing by named ranges. I haven't been able to get it to work from the C# app trying to use named ranges though. Not without the app
already knowing what they are.
Believe me. They have heard my complaints. This is a rarely used feature but they insist it still needs to support it without changing it much. I may have to wind up using DDE (NDDE maybe?) though I would really rather not.
I have an application that receives messages from a network that describe object events and status (think of a CAN Bus data logging type of application).
My plan is to record 'change' events (actual change as opposed to re-transmit) to disk along with 'key frames' (status of all objects) to allow later playback of the data. Data format is not predetermined. I'll work with whatever is the best fit.
I am looking for code that would support playback controls such as 'play', 'pause', 'rewind', 'start playing at <time>', 'fast forward', etc.
My searching of the web gets me lots of things having to do with audio and video playback but nothing in the area of arbitrary data playback.
I can 'roll my own' but a head start would be helpful.
My application is a signal system I have designed for "Ride On Railroads" (7.5" gauge typically here in the USA).
The system consists of controller nodes distributed around the railroad. Each of these nodes detects track occupancy, calculates which train should be permitted to proceed and sets signals accordingly.
All of this data (track occupancy, signal head settings, etc.) is broadcast on a single CAN Bus in real time.
There can be one or more PCs attached to the network for monitoring and control (NOT control of train movements, that's totally done by the controller nodes).
One of the things the PCs support is display of train movements to passengers as well as one or more dispatchers.
I want to record this CAN Bus data as a stream of 'change' events as well as periodic "key frame" records to a disk file. The key frame record records the current status of every object (track, signal, etc.) on the railroad. Thus, starting at a 'key frame' and proceeding forward in time you have a time record of everything that happened on the railroad.
I want to be able to switch the display screen from the 'live data stream' (what is currently happening on the railroad) and display what happened at an earlier time ... i.e.: replay the railroad activity.
So, I need to be able to support things like "play back the data stream from 5pm yesterday", etc.
This is done all the time with audio and video streams but I have not been able to find any examples of code that will do it for an arbitrary stream of data.
I also need to decide the file format that would be efficient for recording the data stream and allows somewhat random read start points. Least efficient, but would work, would be for me to just do a 'binary search' in the file by picking a point in the file and scanning for a key frame, check the time, and jump forward or backward depending on the result of the comparison. No complicated indexes needed. Writing of the stream to disk is a MUCH more frequent activity than read so writing needs to be optimized over reading/playback.
It's kind of like a data acquisition system that gathers a stream of data and you want to be able to play it back from an arbitrary point.
Again, I can roll my own but figured it was worth checking to see if something existed that was close to my needs but all my searches only show up tools for audio or video.
As an aside: forward seems easy, skip back "x seconds" is harder/less efficient.
What format is the data in? Can it be stored into a database in a sequential manner? If so the do as Bill suggested and divorce the real time (which should be recording the data into a database) process and the play back process.
If the data can be stored in a database then play back is a trivial matter.
Never underestimate the power of human stupidity -
I'm old. I know stuff - JSOP
I would separate out the task of display of real-time "live" continuous state information from the task of doing a kind of animated slide-show starting from an initial state (key-frame). I think different strategies would be involved: streaming vs. moving back or forward in time in a data store.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
We have a C# windows forms application and I need to work with MS Word files to replace some text, table rows content, or add a new rows to an existed table, we need to know the best way.
I tried using Microsoft.Office.Interop.Word but this way may be old and must use the same office on the all pc's you install the application on it, if you use the MS Office 2007 then you must install it on any PC will use the application.
Please let me know the best way, tools to do that.
Personally, I'd look for a better file format - there is no guarantee that what you read today will stay the same format tomorrow if MS decide to "add features".
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
Interop is the only real method of updating Word. We had to make sure ALL users were on EXACTLY the same version of Word to use the application. It was updating legal documents that had to read exactly correctly and turned out to be one of the most painful operations I have ever had to do.
If you cannot control the version of Word on all clients then you have a serious problem.
Never underestimate the power of human stupidity -
I'm old. I know stuff - JSOP
What do you mean by CLIENT? Do you mean that if statement must be in C# part? I have written a query in SQL Management Tool. I can use the IF statement and achieve what I want. But SQL CE gives errors in multiple sections. How can I write queries which have multiple lines in SQLCE and C#?
I know little about C# and how, once your SQL Query gets constructed as mycommand.CommandText, you'd use it from your C# frontend, but I'lll wager you're going to need some more TSQL describing the redirection that "IF EXISTS" intimates in order to complete a statement ... I assume there's a target of your INSERT, something like a TABLE (called [MyData]).
WHERE NOT EXISTS [Wo] = 'ABC'
OR [Code] = 1200
INSERT INTO [MyData]
Last Visit: 31-Dec-99 19:00 Last Update: 27-Jan-23 22:08