|
ICollection is an interface that extends IEnumerable [^].
Generic collection classes provides increased type-safety and in some cases can provide better performance, especially when storing value types over simple collections. Good link here on when to use generic collections.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
I'm taking a brief break from my Recloser project to try a custom control. For many years I've wanted to build a scheduling app that actually works, something like Project, except that it would be usable. The stumbling block was always in developing a nice Gannt chart control with the little triangles at the edges, a rectangle to show the task duration, and a contrasting rectangle to show progress, all of which had to be draggable (yeah, I know that's not a word, but it works here). For a decade I tried with MFC to do it, but remain stumped; the GDI+ functions in the .Net Framework seem ideal for the task and I've been reading about them. I need a break from the other task, so I started this one tonight.
I've got as far as creating a container, sizing it, and populating it with the graphical elements for the display. Tomorrow I plan to start trying to Draw the elements and maybe delve into mouse interaction a bit. But I'm stuck on a proper approach. I see a lot of controls that can be resized at runtime, and the visual elements change size or positions as the mouse moves. I have a fair idea how to make the elements change one time - after a drag - by recalculating all the parameters on a Mouse_up event. But I don't have any idea how to implement a method that continuously updates the screen as the item is dragged by the mouse.
Can someone point me to a tutorial or example of implementing this behavior?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
This[^] should give you a good start.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hello, how do drawing windows form manually?
how make form Class?
Visual C#
thanks
|
|
|
|
|
Are you and Hakaxxxx in the same class? Or did you create a second user name thinking it would speed up getting an answer to the exact same question?
I'm not clear about what you mean by drawing a form manually. I usually use a pencil - a HB lead is best - to do this, long before I type any code.
As for making a form class, it would take far less time to type "Windows Form Class" in the Google search box than it took to write this question, and you'd find much clearer answers that way.
My guess is that you have an assignment to create a Windows Form class, and you don't have Visual Studio. That means you have to create source files in a text editor and compile them with the free C# compiler in the SDK. That's definitely the hard way, and I can't help you with it; I'm a beginner myself.
But Visual C# Express is free to download, and I recommend you do so. If you need to show the source code to your teacher, I suggest cheating. Build the project with the proper tools, then copy/paste the code into a text document.
Good luck!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
All you need is to override the OnPaint method of your form and shape it as you wish inside that.
If you are looking to have your own class that will create a non-rectangular form, create a class that inherits from Form class and override the OnPaint method in that. Then use this class to create froms instead of the default one.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hello how do drawing windows form manually?
how make form Class?
thanks
|
|
|
|
|
Hi all,
The question is as follows:
In my C# application , as i click on the image the corrosponding pixel values should be shown in two textboxes(one for row value and another for column) with the point clicked should be shown over the image. I want this to be a repititive process(i mean, any number of points could be stored). These textbox values should ultimately be stored in two diff arrays and fed into a .dll file(written in c++).
How can i achieve this?
Any help is greatly appreciated.
|
|
|
|
|
What do you mean by row and column value?
If you have the image in a PictureBox, handle its MouseClick event and it will give you the clicked locatio. You can set that as the textbox text and at the same time add it to a generic list of Point objects.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Row and Column are nothing but the pixel values only!
logically, i undestand that what event i have to go for but i dont have much experience on graphics programming part so thats my main problem.
|
|
|
|
|
When you will handle the MouseClick event, the MouseEventArgs object will have the location. The coordinates will be based on the top left of the picturebox. This means that it the location comes out to be (10,10), it means it is at a location of 10,10 with respect to the top left corner of the picture box.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Using the click event, get the mouse coordinates. Then display them in your textbox.
Add the x coordinate value in one collection, the y coordinate value in another collection.
meetmak wrote: and fed into a .dll file
Not sure what you mean by that.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
Actually, once the point values are stored as two arrays they are transferred into a .dll(Dynamic Link Library) file which requires that collection of array as the input.
and after taking this input it generates some output.
i hope , you get me now.
|
|
|
|
|
logically, i undestand that what event i have to go for but i dont have much experience on graphics programming part so thats my main problem.
|
|
|
|
|
Don't use an an array, use List<Point> , where Point can be found in the System.Drawing namespace. Depending upon your implementation you might also consisder BindingList<Point> and ObservableCollection<Point> instead of the list, as these both support bindin gto the UI.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Thank you for the reply!
actaully i cant go for "list" as my .dll file takes the collection as array only!
logically, i undestand that what event i have to go for but i dont have much experience on graphics programming part so thats my main problem.
|
|
|
|
|
Error : "The type or namespace HRESULT could not be found(are you missing a using directive or an assembly reference)"
Code Snippet
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
[
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid(IIDGuid.EnumIdList),
]
internal interface IEnumIDList
{
[PreserveSig()]
HRESULT Next(uint celt, out IntPtr rgelt, out int pceltFetched);
[PreserveSig()]
HRESULT Skip(uint celt);
void Reset();
void Clone([Out, MarshalAs(UnmanagedType.Interface)] out IEnumIDList ppenum);
}
Please help...
|
|
|
|
|
For C#'s COM Interop HRESULT will be returned as uint when using the PreserveSig(true) attribute. Change the method signatures in your interface of the two methods that return HRESULT to return uint instead and you should be good to go. You can also go a step further and create a uint enum that defines the possible result values:
public enum Next_HRESULTs : uint
{
S_OK 0x...,
...
}
public enum Skip_HRESULTs : uint
{
S_OK 0x...,
...
}
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
|
|
|
|
|
Hi Friends,
I want to do some registry settings changes through my .net app. Registry settings change will happen only in the "Settings" part of the app like "Starts at Windows" i.e. put an entry in the "Run" key. But to do this things in Win7 or Vista I am experiencing problems like Unauthorized access due to UAC. I am not being able to change the settings. I don't want to run the app in admin mode each time it runs, I just only want to elevate the permission at the time of changing the registry settings. Can anyone please help me out in this situation on how to accomplish this task like by modifying manifest file or putting permission attribute, anything at all.
Thanks in advance.
|
|
|
|
|
Are you writing to HKLM? Try writing to HKCU and you will not have security issues.
|
|
|
|
|
I tried with
<br />
RegistryKey runKey = Registry.CurrentUser.OpenSubKey(@"\Software\Microsoft\Windows\CurrentVersion\Run", true);<br /> but runKey is getting always null in Win7 and XP also. What to do? Please help me out.
|
|
|
|
|
I am trying to call the following method from a library to an exe file using a delegate, can anyone help with the following code, am I missing something, if so what and where do I add it. Below where it says “//********Error************”
I called the delegate and I get the error message “Object reference not set to an instance of an object.” with Troubleshooting tips “Use the “new” keyword to create an object instance”.
Thanks in advance,
Michael
namespace z
{
static class Program
{
[STAThread]
public static void Main()
{
A a = new A();
DelegateMethodA delegateMethodA = new DelegateMethodA(a.MethodA);
}
}
//Execution class
class A
{
void MethodA(Int32 x)
{
y = x + 1;
}
}
//Library in separate project
public delegate void DelegateMethodA(Int32 x);
class B
{
public static DelegateMethodA delegateMethodA = null;
void MethodB()
{
delegateMethodA (Int32 x); //********Error************
}
}
}
|
|
|
|
|
Hi,
inside class B you have a delegateMethodA which is null, and never changes, hence MethodB() will never succeed. the delegateMethodA inside class Program is unrelated.
You really should use an event to "link" both classes.
I suggest:
- you read up on delegates and events;
- you study an introductory book to C#;
- you look at how Visual Studio and Visual Designer generate code when connecting a Button to its click handler.
PS: please use PRE tags (e.g. through the "code block" widget when showing code), as it results in better readability.
|
|
|
|
|
Hello,
i'll try to be concret on my problem.
I want to convert a string: "alex" to bits (by bits I mean 0 and 1) and then write them into a binary file.
There are many ways to do this, but i've selected this:
private void MyWriteMethod()
{
byte[] bytes = UTF8Encoding.Default.GetBytes("alex");
Stream str = File.Create("test.bin");
BinaryWriter bw = new BinaryWriter(str);
BitArray bits = new BitArray(bytes);
for (int i = 0; i < bits.Length; i++)
{
bw.Write(bits.Get(i));
}
}
My problem is:
All goes well, but when I look for my file it occurs 32 bytes on my HDD.
Now to do a comparison, I create a new file and write by hand the text "alex". When I look for this new created file, I see that it occurs 4 bytes!!!!
My questions are:
1. Why is that ?? Can anyone explain to me this phenomenon ??
2. Can I occure the same amount of bytes using the bits ?
3. Afther that may I recive a code sample on how this can be done? I mean: how can I write bits to a binary file?
Thanks you for you're patience!
Alex Manolescu.
modified on Tuesday, December 29, 2009 3:58 AM
|
|
|
|
|
oldsellerros wrote: 1. Why is that ?? Can anyone explain to me this phenomenon ??
It's lazy and writing a whole byte. It could save up bools in batches of 8 and flush them when there are 8 or when something else is written, but they just didn't make it like that.
oldsellerros wrote: 2. Can I occure the same amount of bytes using the bits ?
Could you try to translate that again, maybe using a different translator?
oldsellerros wrote: 3. Afther that may I recive a code sample on how this can be done? I mean: how can I write bits to a binary file?
It has been done countless times before, just search codeproject/google for "bitstream C#" or something like that. Or you could make one yourself, just collect bits until you have 8 of them and then write them all at once in a byte. The exact details will depend on whether you want bytes/ints/etc to be byte-aligned or not
|
|
|
|