|
I suggest you take a look at some open-source applications. You could find a horde of examples on http://www.sourceforge.net[^]. There's no "standard" way of doing this and it greatly depends on your implementation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Have a look at mine (see link below) It's a helluva lot harder than you mite think (dont look at silly implementations that use a seperate control for line numbers, like #develop)
top secret xacc-ide 0.0.1
|
|
|
|
|
dear friends
i am a new to c#..
plz help me how to run the algorithm whose source code is given in c#. e.g. the source code for the cyclic redundancy check is given in this site..
plz tell me the step by step procedure to run it..
with regards
from gcm
|
|
|
|
|
You should probably ask in the forum for the individual article.
However, I can't imaging why you'd want to run a CRC algorithm on its own, so I can only assume you want to integrate it with something else. It might be better for you to convert the algorithm to the language of your choice.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
Hi Friends,
I am working on Visual C# .NET. I want to insert one value in Registry and then retrive that value from registry. In VB.NET there is a funtion "SAVESETTING" to store values in registry. Is there any funtion to store values in registry and retriving that values from registry.
If u have any solution for this then please give reply as early as possible
Thank You
Hemant Mane.
|
|
|
|
|
|
I found this brilliant piece of code by Francesco Natali when I was looking for an easy way out.
/* ***************************************
* ModifyRegistry.cs
* ---------------------------------------
* a very simple class
* to read, write, delete and count
* registry values with C#
* ---------------------------------------
* if you improve this code
* please email me your improvement!
* ---------------------------------------
* by Francesco Natali
* - fn.varie@libero.it -
* ***************************************/
using System;
// it's required for reading/writing into the registry:
using Microsoft.Win32;
// and for the MessageBox function:
using System.Windows.Forms;
namespace Utility.ModifyRegistry
{
///
/// An useful class to read/write/delete/count registry keys
///
public class ModifyRegistry
{
private bool showError = false;
///
/// A property to show or hide error messages
/// (default = false)
///
public bool ShowError
{
get { return showError; }
set { showError = value; }
}
private string subKey = "SOFTWARE\\" + Application.ProductName.ToUpper();
///
/// A property to set the SubKey value
/// (default = "SOFTWARE\\" + Application.ProductName.ToUpper())
///
public string SubKey
{
get { return subKey; }
set { subKey = value; }
}
private RegistryKey baseRegistryKey = Registry.LocalMachine;
///
/// A property to set the BaseRegistryKey value.
/// (default = Registry.LocalMachine)
///
public RegistryKey BaseRegistryKey
{
get { return baseRegistryKey; }
set { baseRegistryKey = value; }
}
/* **************************************************************************
* **************************************************************************/
///
/// To read a registry key.
/// input: KeyName (string)
/// output: value (string)
///
public string Read(string KeyName)
{
// Opening the registry key
RegistryKey rk = baseRegistryKey ;
// Open a subKey as read-only
RegistryKey sk1 = rk.OpenSubKey(subKey);
// If the RegistrySubKey doesn't exist -> (null)
if ( sk1 == null )
{
return null;
}
else
{
try
{
// If the RegistryKey exists I get its value
// or null is returned.
return (string)sk1.GetValue(KeyName.ToUpper());
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Reading registry " + KeyName.ToUpper());
return null;
}
}
}
/* **************************************************************************
* **************************************************************************/
///
/// To write into a registry key.
/// input: KeyName (string) , Value (object)
/// output: true or false
///
public bool Write(string KeyName, object Value)
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
// I have to use CreateSubKey
// (create or open it if already exits),
// 'cause OpenSubKey open a subKey as read-only
RegistryKey sk1 = rk.CreateSubKey(subKey);
// Save the value
sk1.SetValue(KeyName.ToUpper(), Value);
return true;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Writing registry " + KeyName.ToUpper());
return false;
}
}
/* **************************************************************************
* **************************************************************************/
///
/// To delete a registry key.
/// input: KeyName (string)
/// output: true or false
///
public bool DeleteKey(string KeyName)
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
RegistryKey sk1 = rk.CreateSubKey(subKey);
// If the RegistrySubKey doesn't exists -> (true)
if ( sk1 == null )
return true;
else
sk1.DeleteValue(KeyName);
return true;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Deleting SubKey " + subKey);
return false;
}
}
/* **************************************************************************
* **************************************************************************/
///
/// To delete a sub key and any child.
/// input: void
/// output: true or false
///
public bool DeleteSubKeyTree()
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
RegistryKey sk1 = rk.OpenSubKey(subKey);
// If the RegistryKey exists, I delete it
if ( sk1 != null )
rk.DeleteSubKeyTree(subKey);
return true;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Deleting SubKey " + subKey);
return false;
}
}
/* **************************************************************************
* **************************************************************************/
///
/// Retrive the count of subkeys at the current key.
/// input: void
/// output: number of subkeys
///
public int SubKeyCount()
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
RegistryKey sk1 = rk.OpenSubKey(subKey);
// If the RegistryKey exists...
if ( sk1 != null )
return sk1.SubKeyCount;
else
return 0;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Retriving subkeys of " + subKey);
return 0;
}
}
/* **************************************************************************
* **************************************************************************/
///
/// Retrive the count of values in the key.
/// input: void
/// output: number of keys
///
public int ValueCount()
{
try
{
// Setting
RegistryKey rk = baseRegistryKey ;
RegistryKey sk1 = rk.OpenSubKey(subKey);
// If the RegistryKey exists...
if ( sk1 != null )
return sk1.ValueCount;
else
return 0;
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Retriving keys of " + subKey);
return 0;
}
}
/* **************************************************************************
* **************************************************************************/
private void ShowErrorMessage(Exception e, string Title)
{
if (showError == true)
MessageBox.Show(e.Message,
Title
,MessageBoxButtons.OK
,MessageBoxIcon.Error);
}
}
}
JV
|
|
|
|
|
Hi all,
I am trying to create a custom project for Visual Studio.Net. Basically, what I need is for a specific kind of project to appear within the wizard and then I need for my specific kind of code page (like .cs pages, .cpp pages), corresponding to a particular extension, to appear and to be able to work with it.
Any ideas on this one?
Any help would be greatly appeciated.
|
|
|
|
|
This question is better suited to the VS.NET IDE forum.
In either case, I don't have a clue what your trying to accompish...
Are you trying to write your own project template? Like a Windows Forms Application or a Web Forms Application...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How I figured it out (and use it quite often) - go to the installation directory for the VC# or VB.NET in the Visual Studio .NET directory and look at the file structure. Creating a new project or item type is as simple as defining a .vsdir file that points to the wizard files in a sibling directory. These files are either simple templates or contain multiple files that you can use variable replacement. VS.NET defines several variables and you can define your own using a set of HTML files for any wizards and a/some javascript file(s).
If you want more information beyond what you can discover for yourself, you'll need to get Visual Studio .NET Enterprise Architect which includes templates and documentation for creating templates. There is some vague information in MSDN Library[^] about this, but it doesn't tell you much beyond what you can discover and most of the time refers you to use the Enterprise Architect project for creating templates.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In fact I have already created an addin that works well and gets opened everytime VS is opened. What I need to do is to open that addin as a TAB (like the .cs code pages, for example)....
any ideas?
|
|
|
|
|
That's what I was talking about. See the sub-directories in C:\Program Files\Microsoft Visual Studio .NET 2003\VC# (the default installation directory for VC#).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hmmm
I don't understand.
these are the folders I have at that location:
CSharpContextItems
CSharpProjectItems
CSharpProjects
DesignerTemplates
eCSharpProjectItems
VC#Wizards
VCPackages
Which one do I have to touch to add a tab with my component?
|
|
|
|
|
The directory names should make it obvious, but if you're not sure - look. Like I said, I had no problems figuring it out.
For instance, I wanted to create an interface item, so I copied the related files for the class file from CSharpProjectItems and VC#Wizards and modified them.
Just explore - it's how the world was founded.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
look, everytime you answer me you say: "explore by yourself."
Would I come here to post a question if I had found an answer by exploring?
I AM exploring, but I try this too because I work with tight deadlines. Is it that bad? or what is the whole point of this forum? As a matter of fact everything can be found by exploring so this forum would be useless if we all applied that policy, huh?
I'm just trying to say: don't assume I'm not exploring. I am. But I ask for help to quicken things.
Now, the reason I ask is because there a very concrete thing I don't know: how to make my addin component appear in a TAB in vs.net, a code-style tab, like a .cs tab. I don't even know if that's possible. Is the answer in the folders you told me? Which one? How?
|
|
|
|
|
Look at the directory names: there's projects, project items, etc. If you actually open the files, it's obvious.
It would take an entire article to tell you exactly what to do. I did tell you were to look, since it seemed like you didn't even know before. Forum members are different, and most of us regulars don't just hand over the answers - you'll never learn anything that way. In this case, though, it's a matter of content length: it would take an entire article but can be discovered in a matter of minutes.
Most of what you need to do you can copy, paste, and modify ever so slightly to get what you want, like copying an existing .vsdir file from CSharpProjectItems and creating your own (works best for an installer) pointing to your own directories and items inside that. Create sub-directories in the VC#Wizards directory. Look at examples like CSharpAddClassWiz.
It's really quite simple. You can add new file types and projects to VS.NET this way.
And I don't know what you mean by "TAB". Do you know now many tabs there are throughout VS.NET? Dozens if not hundreds. If you mean in the toolbox where you'd find Windows Forms, Web Forms, and other components (it's not a "TAB"), then see the ToolBoxItem class documentation in the .NET Framework SDK. The class documentation includes plenty of information and example code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks a lot. I fully understand your reasons and endorse them, too.
By TAB I mean a tab like a code page tab. When you open a .cs file where do you see it in VS? In a code tab! or a .cpp file, etc...
That's what I mean by tab, and that's what I don't see in the files in those folders....
|
|
|
|
|
You mean a window? How am I - or anyone - supposed to help you if you don't use proper terminology. What if I went to a doctor and told them my doodad hurt?
You can't open a component in a window, but that also depends on what you mean by "component" which you mentioned before. A component in .NET is a compiled class that gets instantiated on a Windows Form or UserControl or ASP.NET page or control (among other things).
Before you were talking about tabs, .cs files, and projects. It seemed like you were talking about new project item types (like when you right-click on a project or project folder and select Add New-<Add New Item....
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
sorry
that's what I meant
sorry!
I call that a tab....
Yes, that's what I thought: it can't be done.
Sorry for the inconveniences and thanks a lot.
I hope to have more interesting questions in the near future, and I am sure I will ....
|
|
|
|
|
It is possible!
I just did it with VSIP
Thanks for your help anyway.
thanks a lot.
|
|
|
|
|
Hi
I use C# to programmatically control windows media encoder to encode audio from microphone to streaming server using a push connection. However, there was a delay of around 8 seconds from voice in the microphone to the player. Anyone knows what might have been wrong here?
Thanks
Ferry
|
|
|
|
|
Nothing is wrong, that's the way it works for any served up stream. I've noticed about an 11 second delay coming from my QuickCam to the clients. The delay will vary depending on the speed on the client connection, the speed of the server machine, the speed of the machine doing the capture and encoding,... Also, some encoder must have a minimum amount of data to encode because their schemes may work over the span of a few seconds of data instead of what in front of it right now...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hai there,
i need your valuable information. i don't have any big esposure in think client application. but now i need to do that.
i need your opinion.
which method is good,reliable,efficient,less time consuming and cost effective to store picture files (for a cart application) in sql server or any database.
Sreejith S S Nair
|
|
|
|
|
Create a binary field (like an image field type in your database to store these images. Then use a SqlParameter for your SqlCommand like so:
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO MyTable (Image) VALUES (@Image)";
SqlParameter image = cmd.Parameters.Add("@Image", SqlDbType.Image);
using (MemoryStream ms = new MemoryStream())
{
bmp.Save(ms, ImageFormat.Jpeg);
ms.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, buffer.Length);
image.Value = buffer;
}
conn.Open();
cmd.ExecuteNonQuery();
conn.Close(); You should, of course, add some exception handling. How you get the image data isn't so much important as how you store it.
Another alternative is to use your database as a file system and only store a reference to the image files. This make it easier to display the images in a web page since you don't have to worry about either saving the images to a virtual directory when requested, or writing a handler (perhaps even an ASP.NET .aspx page) to extract the data on the fly (if you do, youmight consider caching against the query string params). This is what we do for the documen management portion of our application.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
From the article:Cutting Edge Windows Hooks in the _NET Framework -- MSDN Magazine, October 2002.htm,
i download its demo and test it.
in this function:
public void Install()
{
m_hhook = SetWindowsHookEx(
m_hookType,
m_filterFunc,
IntPtr.Zero,
0
//(int) AppDomain.GetCurrentThreadId()
};
}
When the 4th param is setting to AppDomain.GetCurrentThreadId,the hook does work.
While it is setting to 0(article says global),the hook doesnt work.
What is wrong ?
|
|
|
|