|
The easiest way to do it would be to launch the installer for the codecs from your app and let the installer do it's job for you.
Since you don't own the codecs, you probably would not get away with shipping the codec with your application.
|
|
|
|
|
Does anybody know how to create an efficient Undo/Redo Class? What are the general things I need to implement?
may your code be error free
|
|
|
|
|
Undo/Redo functionality is really based on what your application does.
If it's a text editor, you'd want to store which text was inserted/deleted/moved where. If it's a graphics program, you might want to store that drawing tool X was used at location Y. If it's a game, you'd want to store that the player moved from A to B, and what each enemy did in response.
In general terms, an Undo/Redo class is going to act like a list or array of state objects. The state object would need to:
1) Store data representing the action performed
2) Know how to "apply" that data to the application (Enter text, make a move, draw something)
3) Know how to reverse that process (Remove the text, back up a move, erase something)
I can't help you with the implementation of that state object, but the general functionality of the Undo/Redo would be:
(Storing an integer representing the location in the undo list)
Undo:
1) "Reverse" the state object at the current index
2) Add one to the index
3) If the index is greater than the size of your state array, disable undo
Redo (Enabled when index > 0):
1) Subtract one from the index
2) "Apply" the state object at the current index
User performs an action:
1) Remove any state objects less than the current index (So the current undo item is in position zero)
2) Insert a state object at the zero position that describes what the user just did
3) Set the index to zero (First item)
Sounds easy, of course figuring out that state object could be really difficult, depending on your app.
|
|
|
|
|
Thanks for your response! I need Undo/Redo functionality for multiple objects. My application allows the user to
- move
- resize
- change font type
- change background image
etc..
The research I've done so far only supports undo/redo operations for one class. In other words, you would have to have a reference to the object then use the undo interface attached to it. Any ideas on how to implement undo's for multiple objects?
|
|
|
|
|
Create a class heirarchy for undo/redo actions, so that you can keep a collection of the base object, and the derived objects represent the different types of action to undo.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How about looking at the source code for Paint.NET? It has Undo/Redo functionality that seems to match the scenario you describe.
Paint.NET[^]
Kevin
|
|
|
|
|
Hello, is there any way to get a NumericUpDown control to update and validate itself as you type?
My problem is: The NUD control updates it's Value property when you use the up-down arrows, but it doesn't update itself as you type until it has lost focus.
What I am trying to do is have a "FINISHED" button stay Enabled=False until the value entered into the NUD control is greater than a certain amount, then, I want it to Enabled=True.
I don't want the user to have to click off the NUD control or have to "Tab" off if it just to throw a LostFocus event just for the "finished" button to light up.
Can this be done? Are there any already written user controls or chunks of code out there that already do this?
Thanks.
|
|
|
|
|
It is ALOT of events but look at using the KeyPress/KeyUp/KeyDown (whichever works best) events for that control.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Well, I gave it a few days of hard effort, but there's just too much going on to trap. Essentially, I had to try to, based on key-presses within the control, figure out it's value at all times. I got it about 80% of the way there with using overrides and such but things like "using the mouse to highlight the box and hitting delete" as opposed to "highlighting a digit or two and hitting delete" made me aware this is way over my head.
Once again, I toss this out to the forums:
Need a numeric text entry control. Control has to at all times, know it's value, including while entering. Basically, if it's on the screen; it has to know it's value. Does such a beast exist for the .NET framework?
Thank you.
|
|
|
|
|
Is this for a Windows Form? If so .NET 2.0 brought back the masked text box which can only allow numerics if you set that property but you can also just validate the text after the fact.
A better way to do this on your own would be to use the textbox's KeyPress event or something along those lines and look at the following.
If e.KeyChar = Chr(CharCode for 0-9) Then
e.Handled = True
Else
e.Handled = False
End If I think that is all you really need to do.
-- modified at 12:10 Tuesday 29th May, 2007
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
how to work with datagrid using
1)delete command( permanently to remove all selected rows or selected single rows)
in sql database through datagrid during run time in vb.net windows application
and
2)update and save the changed values permanently in sql database through datagrid during run time in vb.net windows application?
|
|
|
|
|
If you bind this to a dataset object and provide the delete/update/insert commands then it is all taken care of for you. All you have to do is at some point call the tableAdapterName.Update(dataSetName.dataTableName) .
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TblUserTableAdapter.Fill(Me.DatabaseDataSet.TblUser)
End Sub
Private Sub TblUserBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblUserBindingNavigatorSaveItem.Click
Me.Validate()
Me.TblUserBindingSource.EndEdit()
Me.TblUserTableAdapter.Update(Me.DatabaseDataSet.TblUser)
End Sub
It doesn't save information into my database. Help!
|
|
|
|
|
how to work with datagrid using
1)delete command( permanently to remove all selected rows or selected single rows)
in sql database through datagrid during run time in vb.net windows application
and
2)update and save the changed values permanently in sql database through datagrid during run time in vb.net windows application?
|
|
|
|
|
Hello all, I creating a Temp DataSet and Adapter, populating it and then doing an Insert to move data from this table back into the orginial table I copied it from but with a new DATE. I have it all working fine so far but when I get to trying to list the value of one of my columns (the most inportant one) I can't seem to grab the value. Below is what I have as of now. The line that I am having a problem with is OrderName = ADS.Orders.Select.ToString but I wanted to show you exactly what I am doing. Does anyone have any suggestions? Thank you for any help that you can provide...
Dim NewVisitDate As String
Dim PriorVisitDate As String
Dim SQL As String = String.Empty
'set Variables
NewVisitDate = txtVisitDate.Text
PriorVisitDate = Me.cbobxPriorDates.Text.ToString
MR = frmQuestionnaire.txtMRNo.Text
'create SQL to filter out data
SQL = "SELECT OrderMR, OrderDate,Order FROM (Orders) WHERE (OrderMR='" & MR & "') and (OrderDate= #" & PriorVisitDate & "#)"
'create new DataSet and new DataAdapter
Dim dr As OleDbDataReader
Dim ADS As New AnesDataSet
Dim CopyOrders As New OleDbDataAdapter(SQL, Connection)
CopyOrders.Fill(ADS, "Orders")
'CopyOrders.Fill(ADS.Orders)
Try
Connection.Open()
Dim Command As New OleDbCommand(SQL, Connection)
dr = Command.ExecuteReader()
Catch ex As Exception
End Try
'run a ForEach statement to modify all of the records in the ADS.Orders table
Dim Row As DataRow
Dim OrderName As String
Dim SQLInsert As String = String.Empty
For Each Row In ADS.Orders.Rows
OrderName = ADS.Orders.Select.ToString
'setup an SQL to change the Date and Insert new records
SQLInsert = "INSERT INTO Orders (OrderMR, OrderDate, [Order]) VALUES (@MR, @NewVisitDate,@OrderName)"
Dim Command_Insert As New OleDbCommand(SQLInsert, Connection)
Command_Insert.Parameters.AddWithValue("@orderMR", MR)
Command_Insert.Parameters.AddWithValue("@OrderDate", NewVisitDate)
Command_Insert.Parameters.AddWithValue("@Order", OrderName)
Command_Insert.ExecuteNonQuery()
'Console.Write(Command_Insert)
|
|
|
|
|
Are you attempting to update the date or just add back in all the rows with a new date in addition to the originals?
Also, what is the command that is executed at the line OrderName = ADS.Orders.Select.ToString ?
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Hey Cleako, thanks for your response.
I am writing back the records with a new date in addition to the originals.
That line that you noticed is where my problem is. I can't figure out what to set my OrderName variable to. I can't find anything from the intellisense list that will give me the feild value of Orders on the row that I am on.
|
|
|
|
|
If you dont have a strongly typed DataSet where the columns are provided then you will need to access the column this way.
For Each Row In ADS.Orders.Rows
OrderName = row("Order").ToString I hope that helps!
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
That is EXACTLY what I needed. Thanks CleaKO!!
|
|
|
|
|
We are building a html(some controls) and assigning to a div's innerhtml.
They are built using some validations. The size of the string in any case would be around 200 KB(The controls are more). We are calling one or two functions in a loop which is returning a stringbuilder. The calling function will append the return value to a main stringbuilder. Main stringbuilder will be around 200 KB and the stringbuilder within functions will be around 100bytes. Will that be a better way to initialize the stringbuilder with some expected values.
Thanks,
K.P.Kannan
|
|
|
|
|
If you know the size of the StringBuilder I would initialize it with that size or a little more for efficiency but in general StringBuilders are just more efficient as they are. You dont necessarily have to use "expected values" though.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
hai all,
i am using .net 2003.i want to update and save the changed values permanently in sqldatabase through datagrid during runtime in vb.net windows form.
using the following code can't update and can't save the changed values permanently.but i run this program, didn't show any error.plz any body help.
Try
Dim myChangedDataset As DataSet = Me.DataSet41.GetChanges
If Not (myChangedDataset Is Nothing) Then
Dim modifiedRows As Integer = Me.SqlDataAdapter1.Update(myChangedDataset)
MessageBox.Show("Database has been updated successfully: " + modifiedRows + " Modified row(s) ", "Success")
Me.DataSet41.AcceptChanges()
fnRefresh()
Else
MessageBox.Show("Nothing to save", "No changes")
End If
Catch ex As Exception
MessageBox.Show("An error occurred updating the database: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.DataSet41.RejectChanges()
End Try
|
|
|
|
|
I would suggest using a breakpoint and taking a closer look at your SqlDataAdapter1 just before the update. Make sure the connection is set properly and make sure your commands are set properly. Otherwise this code doesn't have any obvious problems that I can see.
Hope this helps.
|
|
|
|
|
Hi sathyan,
just a few questions to better understand your problem:
1) Do you use a SqlCommandBuilder to create your commands in SqlDataAdapter or create them manually ?
2) In the first case, is your query based upon one table or uses joins ?
I had the same problem and found that SqlCommandBuilder works only for 1-table queries.
Bye,
Advansis
Peace!
|
|
|
|
|
Hello,
I have imported Windows Script Host in my project, because of the CopyFolder() function. But, is my program legal when i have imported Windows Script Host (IWshRuntimeLibrary) and can i still distribute it?
(Maybe someone of Microsoft could answer this question?)
Thanks in regard,
--Zaegra--
|
|
|
|