|
Actually, is there a place on www.codeproject.com that lists these downloads? Or is it mostly just searching around the site to find them?
|
|
|
|
|
You can browse by category. Go to the homepage to begin.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You can also download (or order) VB resource kit from MS website. There are some visual basic tools and docs and couple FREE .NET components like ComponentOne Studio Enterprise (a lot of controls, improved datagrid, toolbar/menu/outlook bar component etc.), DundasCharts, Sax.NET and Infragistics WebNavigator.
I am using ComponentOne controls in my projects - they are worth their price (0$ )
but - be warned - it has some bugs.
|
|
|
|
|
I've just started to learn C# and am trying to use it to create a web service, and I have a question that I hope can be answered.
I have a set of instructions to be run before each instance of the service is started. What I'm trying to do is put some information from a file into memory and then the service will find the information it needs and return that to the user.
I currently have it working where it reads the files from disk every time a request is received, but that seems horribly inefficient, and was wondering if there was a way to have this done once?
Thanks for your help
|
|
|
|
|
It sounds like caching the data with a dependancy on the file may be the solution you're looking for. Take a peek at the System.Web.Caching namespace on MSDN[^].
Hope that helps.
--Jesse
|
|
|
|
|
Thanks for the help. However, I'm really new and have another question. Where would I put the CacheDependency?
|
|
|
|
|
Because you must check the cache each time you get the item from it, you'd want to encapsulate this in a method that the constructor (called when the Web Service class is instantiated) and your methods can call to get the object from the cache:
[WebService]
public class MyWebService : WebService
{
public MyWebService()
{
GetContent();
}
[WebMethod]
public void DoSomething()
{
string content = GetContent();
if (content != null)
}
private string GetContent()
{
string content = (string)Context.Cache[CacheName];
if (content == null)
{
string path = Server.MapPath("/path/to/virtual/file.txt");
using (StreamReader reader = new StreamReader(path))
{
content = reader.ReadToEnd();
reader.Close();
}
Context.Cache.Add(
CacheName,
content,
new CacheDependency(path),
Cache.NoAbsoluteExpiration,
Cache.NoSlidingExpiration,
CacheItemPriority.Default,
null);
}
return content;
}
private const string CacheName = "CONTENT";
} This places the content of a file in the cache. The CacheDependency makes sure that if the file is changed, the cache item is invalidated. This means that null would be returned when trying to get the item from the cache. In this case, you read-in the content of that file and re-add it to the cache.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Your question is not clear as you use "each instance" and yet you seem to want to have a global value. If what you are trying to accomplish is to save yourself from having to re-read a semi-static file, here is what I would try...
// THE RESULTANT DATA
object myData = null;
// THE NAME OF THE FILE
string myFileName = @Server.MapPath(@"\dir\filename");
// GET THE INFO
System.IO.FileInfo fileInfo = new System.IO.FileInfo(myFileName);
// DOES IT EXIST
if (fileInfo.Exists)
{
// THE NAME OF THE DATA KEY
string myDataKey = "DATA";
// THE NAME OF THE TIMESTAMP KEY
string myTimestampKey = "DATETIME";
// GET THE PREVIOUS TIME STAMP (IF ANY, ELSE A NULL)
DateTime myTimestamp = Application[myTimestampKey] as DateTime;
// GET THE TIMESTAMP
DateTime currentTimestamp = fileInfo.LastWriteTime;
// GET THE PREVIOUS DATA (IF ANY, ELSE A NULL)
myData = Application[myKey];
// ANY PREVIOUS DATA?
if (myData != null)
{
// DO WE HAVE A TIMESTAMP?
if (myTimestamp == null)
{
// SHOULD NOT HAPPEN, BUT JUST IN CASE (DATA AND NO TIMESTAMP)
myData = null;
}
else
{
// SAME?
if (!myTimestamp.Equals(currentTimestamp))
{
// FILE CHANGED, RE-READ
myData = null;
}
}
}
// ALREADY THERE?
if (myData == null)
{
// GET THE DATA
myData = ...;
// AND SAVE FOR NEXT TIME
Application[myDataKey] = myData;
// AND SAVE THE TIMESTAMP
Application[myTimestampKey] = currentTimestamp;
}
}
Have fun.....
|
|
|
|
|
Sorry for the confusion. What I want is a global value. I think I understand your example (thank you), however, I'm not sure where to put it in my code. The only place I can see to add it would be in the constructor, but I'm not sure if this would cause this code to be run each time the service received a request (I think it would).
If I understand everything correctly, then if I put your example in the constructor, then the first time the service handled a request (or when the file was changed) it would get the data, other wise is would skip the step to load the data. Is that right?
Thanks for your help!
|
|
|
|
|
When I try this:
DateTime tpmTimestamp = Application[tpmTimestampKey] as DateTime;
the compiler tells me "The as operator must be used with a reference type ('System.DateTime' is a value type).
I'm sorry if this seems really trivial, but I'm just learning C#
<edit>
I've found a way to fix this:
if(Application[tpmTimestampKey] == null)
tpmTimestamp = CurrentTime;
else
tpmTimestamp = (DateTime)Application[tpmTimestampKey];
Thanks for your help!
|
|
|
|
|
Hello,
Do you know how I can change (Windows form) ListView item height, if it is possible?
Thank you.
Arnaud.
|
|
|
|
|
There is no member of the ListView class that specifies an item height, nor is there any Windows message or notification message (for custom drawing) that supports such an operation (for which you'd normally override WndProc in a child class and handle Windows messages the "old fashioned" way).
If you need this type of control, I suggest you take a look at the very robust third-party controls from companies like Developer Express[^] and Infragistics[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
What I want to do is have a context menu come up whenever the user right-clicks a tab label.
Right now I added a context menu to my TabControl, and the context menu pops up regardless where the user right clicks, be it the tabpage or the tab label.
Is it possible for me to have the menu pop up only when the user right clicks the tab label (where the tab's name is displayed)?
Also, how can I deduce which tabpage was right clicked?
What I want is similar to the tabs in VS .Net. You right click a tab, it becomes the selected tab, and a little menu is displayed. And this only occurs when you click the tab name. This is the type of functionality I am looking for.
Thanx for the help
-Flack
|
|
|
|
|
You could iterate through your TabControl.TabPages collection property and use the TabControl.GetTabRect to get the bounds of each tab (till you find a match). Use Rectangle.Contains (calling it on the Rectangle returned from GetTabRect to see if the mouse coordinates in the MouseDown event handler are over the specified tab. This will give you the tab that was clicked. You can then use ContextMenu.Show to show a ContextMenu at those coordinates. Show also tracks the ContextMenu so it continues to display until clicked.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
We are working with a web-cam, which sends us frames (photos).
We want to turn these frames into a live video, to be watched from an ASP.NET web application.
What is the best way to do so using c-sharp?
|
|
|
|
|
Why, when so many solutions already exist? You don't need to assembly the frames in C# to be used in an ASP.NET web application. For example, some software will create MPEGs from frames and provide you with a URL that you can use with an embedded player (like Windows Media Player, QuickTime, RealPlayer , etc.).
If you insist on rewriting what's already been done a thousand times, you can assembly these frames in an AVI - an uncompressed (traditionally) video format. There is an article about this here on CodeProject: http://www.codeproject.com/csharp/steganodotnet4.asp[^].
If you want to encode this as something else, I recommend you look at Managed DirectX 9.0b (http://msdn.microsoft.com/directx[^]), which lets you easily enough pass the AVI through compressors. There are other ways, too, but again this type of software has already been written countless times.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Use this powerful control:
http://www.banasoft.net/AVPhone.htm
|
|
|
|
|
can a singleton remoteObj serve multiple(many) clients?
or should I use singlecall? (which gives me life span problem).
|
|
|
|
|
Yes. It is the single instance of an object. Because of this reason, make sure you lock any shared resources in your implementation using the lock statement (compiles to use a Monitor ) or a similar locking mechanism (mutexes, etc.), which you can find in the System.Threading namespace.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i want to set the textbox = ""
|
|
|
|
|
This belongs in the ASP.NET forum, but anyway...
Enumerate a Page 's Controls collection property:
foreach (Control c in Controls)
if (c is TextBox)
((TextBox)c).Text = ""; This is pretty much the same as what you'd do in Windows Forms.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i tell my friends you are my mentor i owe you so much i am writting a web app as well as windows app and loving it. my c# is growing every day thanks to you.
|
|
|
|
|
I've designed a form with a left and right section divided by a splitter component. in the left i've inserted a treeview component and on the right a panel with edits showing the data of the selected node in the tree.
I've seen that if i select a node and then focus on an edit control, in the tree the selection disappears.
Is there a property of a workaround to having always visible the selected item? In MFC when you use splitters, the splitted areas are standalone windows with their own focus handling.
|
|
|
|
|
See the documentation for the TreeView.HideSelection property in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is it possible for a ListView to contain SubLists (Kinda like a TreeList, but with more than one item)
For example:
+ TopItem1
+ TopItem2
- TopItem3
|_ ChildItem1 ChildItem2 ChildItem3
|_ ChildItem1 ChildItem2 ChildItem3
+ TopItem4
And you would be able to expand like shown above.
I hope to read your input soon.
Thanks in advance,
Jon
|
|
|
|