Jump to content
Xtreme .Net Talk

Cags

Avatar/Signature
  • Posts

    699
  • Joined

  • Last visited

Everything posted by Cags

  1. Thanks for the suggestion, thats an interesting solution however not quite appropriate. I guess its my fault really as I neglected to mention a critical part that was causing me trouble. Your method will alwas find the solution using the least amount of numbers wheras what I need is to find a solution with a specified amount of values. Using the example I gave before what I meant to say was that 17 with 2 values must be 8 + 9. But I might also need to produce 17 in 3 values (which could be quite a few things, (9,1,7),(9,2,6).... etc...
  2. I've recently been coding various logic puzzles and I've ran into a tricky problem. I need to take a number between 1 & 45 and work out which (unique) numbers between 1 & 9 can be added up to achieve this number. For example 17 can only be made using 8 & 9. Unfortunately I can't think of an efficient way of doing it.
  3. Are you using the plugins to extend the functionality of classes that are embedded in the main application? Thats the only thing I can think of that you might be trying to do if the Interface method isn't appropriate. For example, given the vehicle scenario. The classes Car, Bike and Bus are all internal classes in the application and have a few methods each. The application also includes a plugin system that passes classes to the plugins (as cast by an interface). After deploying the application you decide that each class should have included a method / property for description. In order to add this method without altering the original application you distribute a plug-in dll. This plugin recieves the object decides what it is and displays a message containing the description depending on the type. This would not help you add a class (for example aeroplane) but would allow you to make some basic additions. Now if this is what your attempting I'm sure there would be a neater solution by making the classes Car, Bike and Bus plugins that implement an interface which is itself seperate from the main application. If that isn't what your attempting then i'm stumped.
  4. Using the select case statement that you are currently using, every time you add a class you will have to add another item to the case statement. It makes far more sense to create an extra Interface implemented by each class. You will still have the same amount of code but it will be part of the class rather than in the plugin. This way you can add further classes to your application without altering the plugin. I might not be doing a good job of explaining myself here, but hopefully either you'll understand what I'm getting at or somebody else can put it more eliquantly.
  5. As PlausiblyDamp says it would be a much neater system if this information was retrieved via an Interface. Assuming all the class's passed to the plugin are created by yourself you need to make them implement an Interface which includes a method something along the lines of 'GetInformation'. The current system you are using seems very strange, are the classes being passed into the Plugin not created by yourself, because the only reason I can see for using your current method is if you were going to pass it standard objects, but I can't think what use this would ever be.
  6. I could be wrong but the impression I got from reading the problem as stated by rbulph was that object X isn't the plugin, but is passed to a plugin. So I assumed that the plug-in performs some kind of operation on an object. I can't think what this would help achieve, but thats the impression I got.
  7. Perhaps we could help better if you exlained what the plug-in does.
  8. If your function was previously written as part of a form class it will have automatically included the Imports line.
  9. You can use the following code however there are hundreds of paper types and it would take some navigating for the user. foreach (string sPaperKind in Enum.GetNames(typeof(System.Drawing.Printing.PaperKind))) { comboBox1.Items.Add(sPaperKind); }
  10. You have to create a document type for your documents and an associated file extension, this can be done as part of a deployment project. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vbtskaddingdeletingdocumenttypesassociatedfileextensions.asp
  11. Thats excellent, thank you.
  12. Simple question here, is there a menu option for collapsing all the code segments, i.e the methods / regions. I ask because often I collapse them all manually switch between classes and when I go back they are all expanded again.
  13. I'm not entirely sure I'm completely understanding you but here goes... As far as I'm aware you can't make the form level on_enter event trigger before the base on_enter event of the control. If your trying todo what I think you are I would achieve it like this, add a custom method to the control and call it from the on_enter event of the form. Any code that you wished to be performed by the base on_enter event is then put into this public method. Thus 1. From first textbox, enter an existing record id and press enter. 2. Second textbox base class On_Enter event fires (but there is no custom code in it) 3. The form level on_enter event fires and the record is retrieved. 4. The public method is called from the form level on_enter achieving whatever your aim was.
  14. I could be wrong, but surely if the .Net framework is not installed on the PC, your application won't get as far as the form load method. Surely you cannot use a .Net language to test for the presence of .Net. Edit:- Take a look at the following... http://www.codersource.net/csharp_installer_projects.html
  15. In answer to 2, I believe its completely legal, infact i'm sure it should be possible to wrap it into the intall package of your application, but i've never created a proper distribution package so I don't know how.
  16. Whether the .Net framework is part of SP2 I couldn't tell you, but what I can tell you is that on my PC it appears seperately on the Add/Remove programs dialog under 'Microsoft .Net Framework 1.1'. So I would check the test machine to see if it has it listed. If not try downloading the installer and test your app again.
  17. Unfortunately I don't have vs2005, but I can tell you that those instructions were obviously meant for vs2003, because they worked fine on my system. I know this doesn't help you much, but I thought I'd let you know that the instuctions were at least valid for one version of vs.
  18. Found a better solution... int iMeasuredHeight = (int)e.Graphics.MeasureString( sString, fOptions, iSquareSize).Height; while(iSquareSize < iMeasuredHeight) { iFontSize --; fOptions = new Font(fOptions.FontFamily, iFontSize); iMeasuredHeight = (int)e.Graphics.MeasureString( sString, fOptions, iSquareSize).Height; } NB: iFontSize starts at the maximum size you wish the text to be. Due to the nature of the control my grid cells are always square.
  19. Thanks for the idea its a good suggestion however as far as I can tell it won't work in this situation. The string that will be held in the cell uses the overload DrawString(string, Font, Brush, RectangleF); Thus the string is automatically wrapped to fit into the rect. Due to the multiline nature measuring the string width won't work in this manner (I don't think :S) I've found a solution that ensures the string fits in the box unfortunately it merely ensures its small enough for the entire string to be displayed, not necessarily a good fit. SizeF stringSize = gTemp.MeasureString(sString , fOptions, iSquareSize ); double aspect = 0.0; if( iSquareSize / stringSize.Width < iSquareSize / stringSize.Height ) aspect = iSquareSize / stringSize.Width; else aspect = iSquareSize / stringSize.Height; float new_size = ( float )( fOptions.Size * aspect ); fOptions = new Font(fOptions.FontFamily, new_size);
  20. I'm creating what is essentially a custom control which consists of a grid with text values being included in the 'cells'. The entire control is being drawn using DrawLine, DrawString etc. What I am trying todo is have it so that if a 'cell' is resized, the control automatically selects (or at least tries to select) a font size that will still allow the entire string to stay within the sections. I know there is a MeasureString function, but I'm not sure how much help it would be in this instance, I might come up with an idea after some sleep, but if anyone has anyone can point me in the right direction, it'd be much appreciated?
  21. Well spotted, that was just a typo, I was testing it with the default form names and went through changing them for the post, I just missed one.
  22. I've been working on an application that involved drawing a grid. In order to draw this grid I was originally using DrawRectangle to draw each individual square. Upon revisiting the code to optimise it I realised there are much faster ways to draw the grid as drawing each square indivually means that most lines between squares are drawn twice. To get around this I used the DrawLine function. For example to draw a 9x9 grid, you only need to call DrawLine 20x as opposed to calling DrawRectangle 81x. Ok your all probably thinking 'well duh' but bear with me. The same grid could be drawn by calling DrawLine 16x and 1x DrawRectangle (basically drawing the outline as a square instead of each individual line). So what I was wondering is what are the overheads of each method? Does DrawRectangle encapsulate the same code as DrawLine? Which method actually takes longer to perform, DrawRectangle or DrawLine 4x. Obviously any difference is likely to be minimal and thus doesn't matter at all in the application I'm working on. I was just intruiged if anyone would know. Hope that makes sense.
  23. I'm not sure this will work as I haven't tested it but when you add a row instead of explicitly stating the index you could try using the IndexOf() property to find the right column. Private Sub AddRow() Dim row As ListViewItem Dim subText_Col(5) As ListViewItem.ListViewSubItem Dim chTest as ColumnHeader() row = New ListViewItem("Col 1") chTest.Text = "Column 1" subText_Col( listView1.Columns.IndexOf(chTest)) = New ListViewItem.ListViewSubItem(row, "Col 1") chTest.Text = "Column 2" subText_Col( listView1.Columns.IndexOf(chTest)) = New ListViewItem.ListViewSubItem(row, "Col 2") chTest.Text = "Column 3" subText_Col( listView1.Columns.IndexOf(chTest)) = New ListViewItem.ListViewSubItem(row, "Col 3") chTest.Text = "Column 4" subText_Col( listView1.Columns.IndexOf(chTest)) = New ListViewItem.ListViewSubItem(row, "Col 4") chTest.Text = "Column 5" subText_Col( listView1.Columns.IndexOf(chTest)) = New ListViewItem.ListViewSubItem(row, "Col 5") row.SubItems.AddRange(subText_Col) ListView1.Items.Add(row) End Sub
  24. On further research theres another method that might work in the coredll.dll called GetMouseMovePoints(). [DllImport("coredll.dll")] public static extern bool GetMouseMovePoints( Point[] pptBuf, uint nBufPoints, ref uint pnPointsRetrieved ); This is used something like the following (note its not fully tested, but it does seem to return the value). private Point CursorLocation() { Point[] defPnt = new Point[1]; uint iRetrieved = 0; uint iSize = (uint)defPnt.Length; GetMouseMovePoints(defPnt, iSize, ref iRetrieved); return defPnt[0]; }
  25. After doing some research all results points to the fact that GetCursorPosition() only works on devices that actually have a visible cursor. Since a PDA works through a touchscreen and thus has no onscreen cursor, the method does not work correctly.
×
×
  • Create New...