|
programmervb.netc++ wrote: For instance the user sees my log on form and has a drop down to select "Testing", "Development", "Production" etc and when they select one of the profiles the rest of the information is populated.
It would be easy to do this in a table but I am trying to do so using a configuration file so that the entire solution will be self contained without the need for tables.
I'd go for a business-class that contains said profile, and serialize that. Save the serialized string under it's profiles name in the configurationfile, and restore it when required.
What type of configuration-file is it actually? Are you referring to the "Settings" tab on the project-page, or is this coming from an ini-file?
I are Troll
|
|
|
|
|
The "config" file I was going to use was under the settings tab.
You are talking a little above my head I will research serialization and config files and try to get a better idea of what you mean.
Thank you
Humble Programmer
|
|
|
|
|
MSDN[^] has a nice example (bottom of the page) that shows how to "save" the contents of an object to a file and how to reload it.
I wouldn't bother researching ini-files though, they're more a thing from the past.
I are Troll
|
|
|
|
|
This might be of some help:
Overriding App.Config Settings for Multiple Objects[^]
No guarantees, but...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I have tried and tried and tried and im so frustrated with trying ot get it to work. It started with the elapsed time reaching zero and the decrementing into the negatives. I fixed that and it stays at 00:00:00, but now when I reset the time from the date time picker it then starts from its original position at 00:00:00 and the decrements once again into the negatives. Also when I specify globally the seconds say at 15, its starts at a random number, usually it starts at 10 and counts down or it will start at 3 and count down, but if I were to declare it within the tick method it starts it where I want it to, but then the time doesn't decrement. Im so stranded I dont even know where to go from here or even how to fix it.
Public Class Form1
Dim Drag, boolShortBreak, boolLongBreak As Boolean
Dim X As Integer
Dim Y As Integer
'Set Alarm Time for 15 Minutes (Is seconds to reduce countdown when testing
Public Shared alarmTime15 As Date = Date.Now.AddSeconds(15)
'Set Alarm Time for 30 Minutes
Public Shared alarmTime30 As Date = Date.Now.AddMinutes(30)
'Update Label to show system time
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSystemTime.Tick
Label4.Text = TimeOfDay
'Check Date Time Picker if value matches system time
CheckDTP()
End Sub
'No form border style present
'If mouse down get Mouse position
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Drag = True
X = Windows.Forms.Cursor.Position.X - Me.Left
Y = Windows.Forms.Cursor.Position.Y - Me.Top
End Sub
'No form border style present
'Get position of form when mouse is dragged(mouse down)
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If Drag = True Then
Me.Left = Windows.Forms.Cursor.Position.X - X
Me.Top = Windows.Forms.Cursor.Position.Y - Y
End If
End Sub
'Release form from being dragged on mouse up
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Drag = False
End Sub
'15 minute timer subtracted from system time
Private Sub tmrStart15_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrStart.Tick
Select Case True
'date time picker bool for short break (implies 15min break)
Case boolShortBreak
Dim remainingTime15 As TimeSpan = alarmTime15.Subtract(Date.Now)
Label5.Text = String.Format("{0}:{1:d2}:{2:d2}", remainingTime15.Hours, remainingTime15.Minutes, remainingTime15.Seconds)
'If 15min reaches zero, stop timer and set bool to false
If remainingTime15.Duration.Seconds = 0 Then
Stop_Clock()
boolShortBreak = False
End If
'date time picker bool for long break (implies 30min break)
Case boolLongBreak
Dim remainingTime30 As TimeSpan = alarmTime30.Subtract(Date.Now)
Label5.Text = String.Format("{0}:{1:d2}:{2:d2}", remainingTime30.Hours, remainingTime30.Minutes, remainingTime30.Seconds)
'If 30min reaches zero, stop timer and set bool to false
If remainingTime30.Duration.Seconds = 0 Then
Stop_Clock()
boolLongBreak = False
End If
End Select
End Sub
'Check if date time picker values match system time
'If so enable timer based on either 15min break or 30min break
'using select case within the tmrStart
'bools choose whether it is a 15min break or 30min break
Public Sub CheckDTP()
If dtp1.Text = Label4.Text Then
boolShortBreak = True
tmrStart.Enabled = True
End If
If dtp2.Text = Label4.Text Then
boolLongBreak = True
tmrStart.Enabled = True
End If
If dtp3.Text = Label4.Text Then
boolShortBreak = True
tmrStart.Enabled = True
End If
End Sub
'Used to stop the tmrStart Timer
Private Sub Stop_Clock()
tmrStart.Stop()
tmrStart.Enabled = False
End Sub
End Class
I set Date.Now.AddSeconds so I didnt have to wait 15min for the results to show up. Its supposed to be Date.Now.AddMinutes(15).
modified on Tuesday, January 11, 2011 11:22 PM
|
|
|
|
|
1.
your code is a bit messy, and it is not easy to guess what all of it is supposed to do; making control names more descriptive would help. There is code handling mouse events, it is not relevant here; and I'm not sure all timer related code has been shown.
2.
rather than have several instances of tmrStart.Enabled = True , you should call a subroutine that sets the value of alarmTime15 and/or alarmTime30, then starts the timer; setting them once when the class loads does not make sense.
That should get you started.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I sincerely apologize for the sloppyness, yet it still may be sloppy but I edited the code and added comments. Basically the alarm times that I set arent exactly turning out as its expected. And the when the timer is decreased it just seems like label5 itself is set to "00:00:00" when its duration is up, so even if I restart the timer without exiting the application its decrements further into the negative and I cant seem to find a way around that.
I pasted a link to the pastebin website for my Form Designer code. I didnt want to flood the forum with unnecessary code. I do hope this helps:
Form Designer Code(PasteBin)
|
|
|
|
|
I haven't read all of it again yet, however I noticed two things:
3.
you ignored my earlier #2 completely, so it is bound to fail, and more so the longer you wait.
4.
you use an equals test in If remainingTime15.Duration.Seconds = 0 Then , it would be much more defensive/safer testing for less than or equal to zero.
Now if you fix those points, I expect it would start to behave like you want it to.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I didnt ignore your numero dos, I just happened to be in my car with an almost dead battery, so I only had enough time to comment it before it died , but yes I will give it a shot, hopefully it will behave properly, per your say. If I have any issues I will be back tomorrow with details. Later hubcap!
|
|
|
|
|
Now I'm getting really worried: either you can comment code in a hands-free way, or you have a private chauffeur, or you're just reckless.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
All of the above
|
|
|
|
|
I got as far as
Label4 , i.e. line 13, and didn't find this code worth looking at further. Guess why.
|
|
|
|
|
Hi everyone
whats "runtime" exactly?
I have read about it on MSDN but can you explain for me?
" You can think of the runtime as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety and other forms of code accuracy that promote security and robustness".
Thanks.
|
|
|
|
|
.NET (source)programs are compiled into assemblies. These assemblies are in the form of MSIL, MS Intermediate Language.
The runtime, Common Language Runtime (CLR) is the set of programs that compiles your .NET assemblies into binary code for the processor and operating system it runs on, and executes them.
All .NET languages (VB, C#, F#, Managed C++) are compiled into the same MSIL.
That's why you can mix assemblies written in any of the available .NET languages.
Whereas in the olden days (before .NET) you had to worry about things like memory management, now it's handled by the CLR.
Cheers
I don't like my signature at all
|
|
|
|
|
Thanks for your reply so runtime is equals with common language runtime and is it correct MSIL=CIL and they are same? and Common Language Runtime is a software or a virtual machine?
|
|
|
|
|
Yes MSIL==CIL. I think nowadays the official term is CIL, us old people have hard to break habits
Just as the JVM is a virtual machine solely to run JAVA-bytecode, the CLR is for .NET CIL-assemblies.
further reading : Common Intermediate Language[^]
Cheers
If you can read this, you don't have Papyrus installed
|
|
|
|
|
For such question please prefer using FAQs that will be faster.
|
|
|
|
|
Are you talking to moi?
It's saturday, spare time on my hands. It was a veryveryvery basic question, I know.
If you've got a good link, hijack the thread, hiho!
If you can read this, you don't have Papyrus installed
|
|
|
|
|
Think of the CLR as the engine that converts the C# code that you write into machine level code that the computer understands.
It does many other things like memeory management, thread management etc. while doing this conversion.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
<script type="text/javascript">
function SubmitParent(sourceID) {
if (sourceID.value != '') {
opener.document.getElementById('hf').value = sourceID.value;
opener.document.getElementById('Button1').click();
}
window.close();
}
function Cancel() {
window.close();
return;
}
|
|
|
|
|
Nice to know. How about:
- Not posting test messages on a public forum
- Asking a question about a problem, you know, like the site is intended for
- Resolve your issues (and I guess they are manifold) before posting again.
|
|
|
|
|
...and what were you "testing" with this??
I'd say you successfully failed your test.
|
|
|
|
|
Fail!
I must get a clever new signature for 2011.
|
|
|
|
|
|
Actually, it's Technical Issues, and that's what you appear to have had while posting this. Would you care to explain what your problem is, so that we can attempt to help?
|
|
|
|