Jump to content
Xtreme .Net Talk

PlausiblyDamp

Administrators
  • Posts

    7016
  • Joined

  • Last visited

Everything posted by PlausiblyDamp

  1. Not sure what you are trying to do with the code you posted... Are you trying to pass a filename as an argument to the application?
  2. Could you not have a collection of forms and simply add each form you open to it? To close them all you would simply loop over the collection and call the .Close method of each form in turn.
  3. Playing around with it a bit here and nothing seems to make much of a difference. Probably the best so far is handling all drawing in the OnPaint method and explicitly ignoring the request to clear the background (handle WM_ERASEBKGND in your WndProc and bail without doing anything). I still can't remove the flicker though and it is getting annoying ;) Oddly enough specifying the ControlStyles.AllPaintingInWmPaint style seems to make it worse despite the fact all drawing is being done in the Paint event. Out of interest what OS are you running on? Vista 32 bit with a Nvidia card here...
  4. It seemed to have less of a flicker on my computer :( oh well. If you are handling the OnPaintBackground then you don't need to call the base as you are normally completely changing how the form is erased anyway. Have you tried drawing the border in the normal OnPaint handler rather than in OnPaintBackground to see if that makes any difference in appearance?
  5. Looking at the code there doesn't seem to be any reason why you should get the flicker... The only thing that immediately springs to mind is the possibility that the built in double buffering isn't helping; it might be worth looking at buffering it yourself. Couple of quick changes to try... //In the constructor set the styles to SetStyle(ControlStyles.ResizeRedraw, true); also modified the actual painting to be protected override void OnPaintBackground(PaintEventArgs e) { // base.OnPaintBackground(e); BufferedGraphics g; BufferedGraphicsContext context = BufferedGraphicsManager.Current; context.MaximumBuffer= new Size(Width, Height); g = context.Allocate(e.Graphics, new Rectangle(0, 0, Width, Height)); FormRegions.Left = new Rectangle(0, 6, 5, ClientSize.Height - 12); FormRegions.Right = new Rectangle(ClientSize.Width - 5, 6, 5, ClientSize.Height - 12); FormRegions.Top = new Rectangle(6, 0, ClientSize.Width - 12, 5); FormRegions.TopLeft = new Rectangle(0, 0, 6, 6); FormRegions.TopRight = new Rectangle(ClientSize.Width - 6, 0, 6, 6); FormRegions.Bottom = new Rectangle(6, ClientSize.Height - 5, ClientSize.Width - 12, 5); FormRegions.BottomLeft = new Rectangle(0, ClientSize.Height - 6, 6, 6); FormRegions.BottomRight = new Rectangle(ClientSize.Width - 6, ClientSize.Height - 6, 6, 6); FormRegions.Caption = new Rectangle(5, 5, ClientSize.Width - 10, SkinImage.Caption.Height); FormRegions.Background = new Rectangle(5, 5, ClientSize.Width - 10, ClientSize.Height - 10); g.Graphics.FillRectangle(Brushes.White, FormRegions.Background); g.Graphics.DrawImage(SkinImage.Caption, FormRegions.Caption, 0, 0, SkinImage.Caption.Width, SkinImage.Caption.Height, GraphicsUnit.Pixel, SkinAttributes); g.Graphics.DrawImage(SkinImage.CaptionLeft, 5, 5, SkinImage.CaptionLeft.Width, SkinImage.CaptionLeft.Height); g.Graphics.DrawImage(SkinImage.CaptionRight, FormRegions.Caption.Width + 4, 5, SkinImage.CaptionRight.Width, SkinImage.CaptionRight.Height); g.Graphics.DrawImage(SkinImage.Left, FormRegions.Left, 0, 0, SkinImage.Left.Width, SkinImage.Left.Height, GraphicsUnit.Pixel, SkinAttributes); g.Graphics.DrawImage(SkinImage.Right, FormRegions.Right, 0, 0, SkinImage.Right.Width, SkinImage.Right.Height, GraphicsUnit.Pixel, SkinAttributes); g.Graphics.DrawImage(SkinImage.Top, FormRegions.Top, 0, 0, SkinImage.Top.Width, SkinImage.Top.Height, GraphicsUnit.Pixel, SkinAttributes); g.Graphics.DrawImage(SkinImage.TopLeft, FormRegions.TopLeft); g.Graphics.DrawImage(SkinImage.TopRight, FormRegions.TopRight); g.Graphics.DrawImage(SkinImage.Bottom, FormRegions.Bottom, 0, 0, SkinImage.Bottom.Width, SkinImage.Bottom.Height, GraphicsUnit.Pixel, SkinAttributes); g.Graphics.DrawImage(SkinImage.BottomLeft, FormRegions.BottomLeft); g.Graphics.DrawImage(SkinImage.BottomRight, FormRegions.BottomRight); g.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; g.Graphics.DrawString(Text, new Font(Font.Name, 15, Font.Style), Brushes.Black, new PointF(47, 11)); g.Render(e.Graphics); } seems to make things better but certainly isn't perfect ;) might be a useful starting point though...
  6. The GetCommandLineArgs returns an array containing all the arguments passed on the command line, if the file to open is the first one then it will be at position 0 in the returned array. Easiest way to get the information into the text box is by using a StreamReader object to open the file.
  7. Is the other system a web service? If so you can add a web reference to it from the solution explorer in visual studio - that will take care of the hard work.
  8. Environment.GetCommandLineArgs() will return the command line arguments regardless of the language.
  9. Looking properly at the errors generated it looks like the applicationj is trying to use .Net 2 functionality (Generics etc.) but targeting the 1.1 framework. I would imagine you need to ensure you are only using 1.1 functionaily for this to work.
  10. The only real performance hit would be in creating the objects and populating all the properties in the first place. If you are only binding to two properties then only those two will be accessed during the actual binding. Obviously the overall size will impact memory usage but that is a general performance issue anyway.
  11. Without knowing exactly what format the request and response take it is a bit difficult to give any exact advice. Could you show the url format / response format?
  12. It looks like you are missing a couple of references - errors about System.Collections.Generic etc. What libraries does it reference by default?
  13. The sprite.Draw2D method has overloads that allow you to specify the size it will be rendered - you do not need to scale the texture yourself.
  14. I would tend to make my business object responsible for populating themselves from whatever underlying data source I am using. Personally I don't feel a data layer should have any real intimate knowledge of the higher level classes as this can create unpleasant dependencies. Given your situation I would try and encapsulate the xml parsing and data set creation into it's own layer (with a standard interface if possible) and have my business objects deal with this abstracted layer. The layer may do nothing more than return datasets that my business objects load themselves from though.
  15. I'm lazy ;) I would tend to use an O/R mapper and let it do the hard work.
  16. It is more likely to be a permissions thing than any particular restriction. I would check the permissions on the folder you are attempting to write to and see if the web application can actual write to it.
  17. It looks like the encoding could be the problem, however I honestly couldn't say why. Have you tried setting the encoding to UTF8 to see if that makes a difference?
  18. At the start try doing a AddHandler Appdomain.Current.DomainUnload, addressof
  19. IIRC console applications don't have the standard window events (probably because they don't run as part of the window manager). You could possibly try handling the AppDomain.CurrentDomain.DomainUnload event.
  20. It is a known problem, http://vivekthangaswamy.blogspot.com/2006/11/loaderlock-was-detected-error-when.html might be of some use in preventing it though.
  21. http://mironabramson.com/blog/post/2008/05/Sorting-a-collection-using-sort-expression-string.aspx has a nice way of doing this using lambda expression trees rather than reflection - not a clue if it is better or worse but it has nice buzz words in the article and has worked for me in the past ;)
  22. You will need to add an Imports System.Io to the top of the source file to get it to compile. the Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData bit will return the path for the current users application data - this can vary by OS or be configured differently to the normal OS' default so you are better avoiding hard coded paths. Path.Combine simply builds a valid path from two strings - I tend to use it because it handles leading / trailing or omitted path separators (/ or \) plus the fact the code expresses it's intention more clearly than just concatenating strings.
  23. Rather than an array could you not bind to a list of strings and simply remove the item from the underlying list? Something like Dim torrentList As List(Of String) Private Sub cmdRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If lstDisplay.SelectedIndex <> -1 Then torrentList.Remove((lstDisplay.SelectedValue)) lstDisplay.DataSource = Nothing lstDisplay.DataSource = torrentList End If End Sub Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Search for torrent files Dim torrents() As String = System.IO.Directory.GetFiles("C:\Documents and Settings\Sam\Application Data\uTorrent", "*.torrent") torrentList = torrents.ToList() 'Display found files lstDisplay.DataSource = torrentList End Sub Rather than the iffy bit of code setting the datasource to nothing and back you could also use a DataSource control... As an aside you are better using code like Dim torrents() As String = Directory.GetFiles(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "uTorrent"), "*.torrent") instead of hard coding paths.
  24. You could have been clearer about which Kinf of Timer you were using... If you are using the timer component from the toolbox then there is a strong probability that you are suffering from a cross thread / UI issue. You might want to .Invoke a method from the form itself to start the timer or investigate using one of the other timer objects (e.g. System.Threading.Timer).
  25. Without profiling the code it is a bit speculative but I would be interested in knowing what the PrintDocument1.DefaultPageSettings is doing behind the scenes. It might be querying some OS / printer information - that could be taking the time. It is possibly worth checking when / why this is being called and seeing if that could be addressed.
×
×
  • Create New...