|
No it doesn't? That affects the visibility of a form, it doesn't show it in the first place. Use newformtime.Show(); or newformtime.ShowDialog(); to show the form.
|
|
|
|
|
I wouldn't do it in the way of just setting Visible = true but I had to try it, and when you for instance create a new form in the eventhandler of a button click and you add the code:
private void button1_Click(object sender, EventArgs e)
{
Form f2 = new Form();
f2.Visible = true;
}
The f2 form shows up. I didn't expect it would.. A bit confused about this..
|
|
|
|
|
Calla wrote: The f2 form shows up. I didn't expect it would.. A bit confused about this..
Me too - that goes counter to what I'd expect.
|
|
|
|
|
You didn't provide some essential information, such as the type of newformtime.
If it isn't a Form, then none of the code shown relates to a Form.
If it is a Form, it'd better not be the Form holding button1, as you would have a hard time clicking a button on an invisible Form.
|
|
|
|
|
Its a from, I'll just send you the whole code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using Gadgets.Properties;
namespace Gadgets
{
public partial class Form1 : Form
{
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
public Form1()
{
InitializeComponent();
pictureBox2.MouseDown += new MouseEventHandler(p2_MouseDown);
}
Time newformtime = new Time();
Note newNote = new Note();
Search newSearch = new Search();
SRLS newSRLS = new SRLS();
Alarm newAlarm = new Alarm();
QuickLaunch newQuickLaunch = new QuickLaunch();
Calender newCalender = new Calender();
private void Form1_Load(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
timeToolStripMenuItem.Checked = Settings.Default.timecheck;
alarmToolStripMenuItem.Checked = Settings.Default.alarmcheck;
calenderToolStripMenuItem.Checked = Settings.Default.calendercheck;
sRLSToolStripMenuItem.Checked = Settings.Default.srlscheck;
searchToolStripMenuItem.Checked = Settings.Default.searchcheck;
noteToolStripMenuItem.Checked = Settings.Default.notecheck;
quickLaunchToolStripMenuItem.Checked = Settings.Default.quickLaunchcheck;
if (timeToolStripMenuItem.Checked == true)
{
newformtime.Show();
}
if (alarmToolStripMenuItem.Checked == true)
{
newAlarm.Show();
}
if (calenderToolStripMenuItem.Checked == true)
{
newCalender.Show();
}
if (sRLSToolStripMenuItem.Checked == true)
{
newSRLS.Show();
}
if (searchToolStripMenuItem.Checked == true)
{
newSearch.Show();
}
if (noteToolStripMenuItem.Checked == true)
{
newNote.Show();
}
if (quickLaunchToolStripMenuItem.Checked == true)
{
newQuickLaunch.Show();
}
}
private void p2_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}
private void p1_MouseMove(object sender, MouseEventArgs e)
{
this.pictureBox1.Image = Properties.Resources.minimize2;
}
private void p1_MouseDown(object sender, MouseEventArgs e)
{
this.pictureBox1.Image = Properties.Resources.minimize3;
}
private void p1_MouseLeave(object sender, EventArgs e)
{
this.pictureBox1.Image = Properties.Resources.minimize1;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.Visible = false;
}
private void copyright_MouseMove(object sender, MouseEventArgs e)
{
this.copyright.Image = Properties.Resources.l2;
}
private void copyright_MouseLeave(object sender, EventArgs e)
{
this.copyright.Image = Properties.Resources.l1;
}
private void copyright_MouseDown(object sender, MouseEventArgs e)
{
this.copyright.Image = Properties.Resources.l3;
}
private void copyright_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("www.systemerror.co.nr");
}
Form2 newForm2 = new Form2();
private void button11_Click(object sender, EventArgs e)
{
newForm2.Visible = true;
}
private void button1_Click(object sender, EventArgs e)
{
if (newformtime.Visible == true)
{
timeToolStripMenuItem.Checked = false;
newformtime.Visible = false;
}
else if (newformtime.Visible == false)
{
timeToolStripMenuItem.Checked = true;
newformtime.Visible = true;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (newCalender.Visible == true)
{
calenderToolStripMenuItem.Checked = false;
newCalender.Visible = false;
}
else if (newCalender.Visible == false)
{
calenderToolStripMenuItem.Checked = true;
newCalender.Visible = true;
}
}
private void button3_Click(object sender, EventArgs e)
{
if (newAlarm.Visible == true)
{
alarmToolStripMenuItem.Checked = false;
newAlarm.Visible = false;
}
else if (newAlarm.Visible == false)
{
alarmToolStripMenuItem.Checked = true;
newAlarm.Visible = true;
}
}
private void button4_Click(object sender, EventArgs e)
{
if (newSRLS.Visible == true)
{
sRLSToolStripMenuItem.Checked = false;
newSRLS.Visible = false;
}
else if (newSRLS.Visible == false)
{
sRLSToolStripMenuItem.Checked = true;
newSRLS.Visible = true;
}
}
private void button6_Click(object sender, EventArgs e)
{
if (newSearch.Visible == true)
{
searchToolStripMenuItem.Checked = false;
newSearch.Visible = false;
}
else if (newSearch.Visible == false)
{
searchToolStripMenuItem.Checked = true;
newSearch.Visible = true;
}
}
private void button7_Click(object sender, EventArgs e)
{
if (newNote.Visible == true)
{
noteToolStripMenuItem.Checked = false;
newNote.Visible = false;
}
else if (newNote.Visible == false)
{
noteToolStripMenuItem.Checked = true;
newNote.Visible = true;
}
}
private void button9_Click(object sender, EventArgs e)
{
if (newQuickLaunch.Visible == true)
{
quickLaunchToolStripMenuItem.Checked = false;
newQuickLaunch.Visible = false;
}
else if (newQuickLaunch.Visible == false)
{
quickLaunchToolStripMenuItem.Checked = true;
newQuickLaunch.Visible = true;
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
this.Show();
}
private void timeToolStripMenuItem_Click(object sender, EventArgs e)
{
((ToolStripMenuItem)sender).Checked ^= false;
Settings.Default["timecheck"] = timeToolStripMenuItem.Checked;
Settings.Default.Save();
}
private void calenderToolStripMenuItem_Click(object sender, EventArgs e)
{
((ToolStripMenuItem)sender).Checked ^= false;
Settings.Default["calendercheck"] = calenderToolStripMenuItem.Checked;
Settings.Default.Save();
}
private void alarmToolStripMenuItem_Click(object sender, EventArgs e)
{
((ToolStripMenuItem)sender).Checked ^= false;
Settings.Default["alarmcheck"] = alarmToolStripMenuItem.Checked;
Settings.Default.Save();
}
private void sRLSToolStripMenuItem_Click(object sender, EventArgs e)
{
((ToolStripMenuItem)sender).Checked ^= false;
Settings.Default["srlscheck"] = sRLSToolStripMenuItem.Checked;
Settings.Default.Save();
}
private void searchToolStripMenuItem_Click(object sender, EventArgs e)
{
((ToolStripMenuItem)sender).Checked ^= false;
Settings.Default["searchcheck"] = searchToolStripMenuItem.Checked;
Settings.Default.Save();
}
private void noteToolStripMenuItem_Click(object sender, EventArgs e)
{
((ToolStripMenuItem)sender).Checked ^= false;
Settings.Default["notecheck"] = noteToolStripMenuItem.Checked;
Settings.Default.Save();
}
private void quickLaunchToolStripMenuItem_Click(object sender, EventArgs e)
{
((ToolStripMenuItem)sender).Checked ^= false;
Settings.Default["quickLaunchcheck"] = quickLaunchToolStripMenuItem.Checked;
Settings.Default.Save();
}
}
}
|
|
|
|
|
Sorry, I don't need more code; in order to answer your question, one would need more contextual information, and a real problem description. That implies a few sentences, and not dumping a lot of code.
BTW: the code shown would not even compile, there is a bunch of statements outside any method. You could edit it where it is, but first add more information.
|
|
|
|
|
The problem is the find the item at place X at fest time.
So i can do it like this
IEnumerator e = this.GetEnumerator();
while(index != -1 )
{
e.MoveNext( index-- );
}
Is there are more effective way ?
Thanks.
|
|
|
|
|
A ConcurrentQueue is meant to be thread-safe, whereas your code is not really safe: it will fail as soon as the queue content changes, as any change is going to invalidate the enumerator. I haven't studied the internals of that class, it must rely on a lock, which normally would not be accessible to you. So unless the class offers what you need somehow, you should not use it for whatever it is you want to do.
Perhaps you have been asking the wrong question, and you need another approach to your actual problem.
|
|
|
|
|
Thanks,
I need to take information from some object that exist on the ConcurrentQueue.
I understand what you saying - and of-course you are right - but
1. Can i 'lock' the access to the ConcurrentQueue in this case until i will finish to deal with this object ?
2. In the general case - how can i go to the item that sit in place X on the queue in the fastest way ?
|
|
|
|
|
A queue normally is intended to hold a number of items that get produced at one end, and consumed at the other end, sequentially, and in the same order. If that does not suit you, use something else.
|
|
|
|
|
I cant change the 'queue' because this is already implemented object ( not my hand write ... )
I need to dill with it as is.
Can you suggest something according to my question ?
|
|
|
|
|
Hello Everyone,
Which book do u prefer for beginners for starting with C# from scratch
OReilly Programming C Sharp 3.0 5th Edition
OR
OReilly Programming C Sharp 4.0 6th Edition ?
|
|
|
|
|
You definitely can jump start with OReilly Programming C Sharp 4.0 6th Edition
|
|
|
|
|
Thanks for the response.
Is it required to know the .net framework basics before starting with this book?
Books are enough or detail coaching class are required ?? or any online video tutor is good enough ?
Any good .net training center in Bangalore ?? Please let me know
|
|
|
|
|
NaveenHS wrote: Is it required to know the .net framework basics before starting with this book?
Yes. Understanding the basics of framework will help in learning the language. But you will eventually learn about the framework as you progress on C#.
NaveenHS wrote: Books are enough or detail coaching class are required ?? or any online video tutor is good enough ?
Depends on your style of learning. I'd suggest to start with a book and workout the examples provided.
Best wishes,
Navaneeth
|
|
|
|
|
|
|
If you are a beginner, then ANY introductory book would be fine, as long as it is a physical book, as opposed to an e-book. IMO you need the opportunity to mark things, to easily browse it, etc.
Most books do not strictly require prior knowledge, as their author/publisher want to sell to as many people as possible. OTOH most books make implicit assumptions; most likely a book on a specific language will not explain the purpose of a loop, nor the principles and best practices in object-orientation. So you might end up needing a few books if you're a newbie, say:
1. introduction to programming
2. introduction to a programming language
3. introduction to Windows programming
4. introduction to object-orientation
However I would still go for #2 first. And then take it from there.
I seldom give specific book recommendations as it is all very subjective, it depends on your prior knowledge, your need for examples and exercises, and much more. My advice is: visit a good bookstore. A lesser alternative is browse a number of books on Amazon's web site.
|
|
|
|
|
Hi again, sorry if I should not have started a new thread, but I have found the c++ code for what I wanted.
1) This is c++, I do not know how I would do it in c#
2) This function only decodes a string of digits into the byte arra, so I still dont know how to encode a byte array ito the string (reverse)
So... This function takes an installation ID (or what will be a serial number) and decodes it into its byte representation of the number.
int DecodeInstID(char *InstID, unsigned char *Result, int ResLen)
{
int i, k, m, Groups;
int Sum, Digit, Aux;
if (strlen(InstID) != 58)
fprintf(stderr, "Warning: Installation ID has non-standard length.\n");
if (strlen(InstID) % 7 < 2)
{
fprintf(stderr, "Installation ID has invalid length.\n");
return -1;
}
memset(Result, 0, ResLen);
Groups = (strlen(InstID) + 6) / 7;
for (i = 0; i < Groups * 7; i += 7)
{
Sum = 0;
for (k = 0; k < 5 && InstID[i + k + 1] != 0; k++)
{
Digit = InstID[i + k] - '0';
if (Digit < 0 || Digit > 9)
{
fprintf(stderr, "Invalid digit in group '");
for (k = 0; k < 6 && InstID[i + k] != 0; k++)
fprintf(stderr, "%c", InstID[i + k]);
fprintf(stderr, "'.\n");
return -1;
}
Aux = Digit;
m = 0;
do
{
Aux += Result[m] * 10;
Result[m++] = (unsigned char)(Aux & 255);
Aux >>= 8;
}
while (m < ResLen);
if ((k & 1) != 0)
Digit *= 2;
Sum += Digit;
}
Digit = InstID[i + k++] - '0';
if (Digit != Sum % 7)
{
fprintf(stderr, "Invalid check digit in group '");
for (k = 0; k < 6 && InstID[i + k] != 0; k++)
fprintf(stderr, "%c", InstID[i + k]);
fprintf(stderr, "'.\n");
return -1;
}
if (InstID[i + k] != '-' && InstID[i + k] != 0)
{
fprintf(stderr, "Expected '-' character after group '");
for (k = 0; k < 6 && InstID[i + k] != 0; k++)
fprintf(stderr, "%c", InstID[i + k]);
fprintf(stderr, "'.\n");
return -1;
}
}
return 0;
}
I know its in c++, but maybe someone can at least figure out what is going on and then maybe this time understand what I want.
So, if you pass ain installation ID string into this function, like the following
("23334 324234 324234 234234 etc")
You get the byte array of the multi precision value for it.
Now, I have my original 2 qustions....
1) How would I do this in c#
2) How would I code a reverse function to ENCODE a byte array (that the above creates) back into a string, like above.
Then I would be able to encode a byte array into a readable long string of digits to give to the user, and,
then DECODE the string (like above) into a byte array
Hopefully you may now understand what I am trying to do, and I cannot start to explain how much I want to do this as I found c# code before and cannot find it now.
Thank you loads in advance, I do appreciate any help.
Steve
|
|
|
|
|
I think you will find the same code will work, almost in C#. Your code is using char arrays, not byte arrays (In c I think there is no difference) however, in C# you have the option of:
string abc;
abc.ToCharArray();
or if you insist on bytes:
string abc;
System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding();
ae.GetBytes(abc);
<pre>
<div class="signature"><font size="-2">
Need <a href="http://www.erlglobal.com">custom software developed</a>? I do <a href="http://www.erlglobal.com">custom programming</a> based primarily on MS tools with an emphasis on <a href="http://www.erlglobal.com">C# development and consulting</a>. I also do <a href="http://www.erlglobal.com">Android Programming</a> as I find it a refreshing break from the MS.
"And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
</font></div>
|
|
|
|
|
Thank you.
So do you mean I leave the rest of the code as it is?
And also, Would you possibly be able to point me in the right direction with a function to ENCODE the byte or char array I get from the above, back inot the original string please?
Thank you
Steve
|
|
|
|
|
Message Closed
modified 23-Nov-14 5:57am.
|
|
|
|
|
Dear Qwertz
Thank you, but, the follwoing....
const string INST_ID = "23334 324234 324234 234234";
byte[] instIdInByteArray = Encoding.ASCII.GetBytes(INST_ID);
string instIdInString = Encoding.ASCII.GetString(instIdInByteArray);
That simply returns each byte for each char in the string, so I end up with a larger string.
I want the actual encoding of the digits in the string, into a byte array that is a decimal encoding in litle endian byte order of the digits.
Thank you
Steve
|
|
|
|
|
I know this is off topic, but am I missing something here?
This piece of code caught my eye:
if (strlen(InstID) != 58)
fprintf(stderr, "Warning: Installation ID has non-standard length.\n");
if (strlen(InstID) % 7 < 2)
{
fprintf(stderr, "Installation ID has invalid length.\n");
return -1;
}
My C++ is a bit rusty but why do that? Surely, the second if statement will always be true if the first one is false.
|
|
|
|
|
How so?
strlen(InstID) =
7m + {0, 1}: First is true (not 58), second is true (0 or 1).
58: First is false (not 58), second is false (2).
7m + {2, 3, 4, 5, 6}: First is true (anything but 58), second is false (2, 3, 4, 5, 6).
So basically, the length can only be of the form 58, but maybe 7m + {2, 3, 4, 5, 6} are acceptable.
Still have no idea how this makes sense though.
|
|
|
|
|