
DPrometheus
Avatar/Signature-
Posts
50 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by DPrometheus
-
try to trace some messages in the Paint handling code ie. Trace.WriteLine("panel" & id & "painted!"); where you give each panel a temporary id. this way you can determine in your immediate window if your panel gets its paint event. if it does you can step through your code with a breakpoint under the condition that the id matches the third or second panel. This way your breakpoint only breaks on paint events of your 'incorrect' panels. Please share your results. ~DP
-
Hi Cindy, thanks for your response, since we're close to the deadline right now I will keep it in mind for a v2. ;) Though through curiosity I made a small test and it really works like a charm. :) Thank you ~DP
-
Hi there, First of all WinForms doesn't support real transparency. An image is created in the paint event from the colors beneath the object and uses that as it's background. So WinForms might have some paint-problems if you use several transparent object drawn on eachother. Secondly if your mousemove keeps calling there might be no time left for repainting before your next mousemove call. If you still encounter problems please post some code, and we'll see what we can do :) ~ DP
-
Personally I have few experience in C# but in VB.NET you do it like this: You first create a variable and an event. p.e. Public Event StringChanged(ByVal sender As Object, ByVal e As System.EventArgs) Or with a delegate, that's up to you. Then you create a property in within the property you call RaiseEvent StringChanged(Me, New System.EventArgs) in the set section of the property You can now add eventhandlers with addhandler me.StringChanged, addressof MyStringChangedEventHandler if your event handling function was called MyStringChangedEventHandler. Hope it's usefull to you, though it's VB.NET ~DP ps. for inherited classes you can also make your handling function overridable. This way you can override the handling function in the child classes.
-
Resource converted from Resource File to Local Resource
DPrometheus replied to Ontani's topic in Windows Forms
How are the build action property and Copy to output directory properties of the image set and of the resx? -
Resource converted from Resource File to Local Resource
DPrometheus replied to Ontani's topic in Windows Forms
What about a resource manager, which shares its resources to the outer world? Something like this: I used it for a outlook style control, which was created in a control library, but he needed resources from same library. I couldn't access it by my.Resources since it was another assembly. Just add resources to the resource pane on the property pages of y7our project and then export it with a public class with shared properties ''' <summary> ''' Export resource images from this dll ''' </summary> ''' <remarks></remarks> Public Class EccIconManager #Region " - Outlook - " ''' <summary> ''' Arrow Down ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Shared ReadOnly Property ArrowDown() As Icon Get Return My.Resources.Arrow_Down End Get End Property ''' <summary> ''' Arrow Up ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Shared ReadOnly Property ArrowUp() As Icon Get Return My.Resources.Arrow_Up End Get End Property ''' <summary> ''' Default Icon ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Shared ReadOnly Property [Default]() As Icon Get Return My.Resources.DefaultIcon End Get End Property #end region end class ~DP -
No, not quite 90A equals 2314. Since the compiler sees a character behind a number, it will probably solve it as a HEX value, 90A equals 2314 in decimal numbers, which is greater then 113, so your computer is correct. As with the other values you showed this seems the case: 1 < 5 .. 1 is less then 5 2a > 1b .. 42 is greater as 27 75a > 54 .. 1882 is greater as 54 92c > 92a .. 2348 is greater as 2346 ~ DP If you use a-f as a suffix the compiler will try to convert it to a heximal number (except .[nr]f, which will be a float (such as 12.0f) and 12f will be converted to its hex value (303 decimal)) Normal numbers are standard interpreted as decimal integer
-
Sorry for the late response, but I haven't been at work for a few days due to sickness. Eventually I changed the form to contain several buttons on the outside of the panel which now interacts to the word document. This seems to solve this issue and since we already needed multiple 'outside buttons' we can hold these as well.. It would have been prettier if they nicely integrated into eachother but hey, it works now :) And it ain't that bad after all ;) Thanks for your time and suggestions! ~DP
-
thanks for helping me out, however.. this is my conclusion of debugging this project: on the VBA side on the line of toolbar.LoadDoc (Word.ActiveDocument) Word.ActiveDocument equals the actual document I can't see the full object but he recognizes it (it has the right name property, and at least it ain't Nothing (since VBE doesn't have such neat debugging tools as VS08) But on the other side things get a bit harder. Since I have to sign it each time and put the dll in the GAC I can't actually use breakpoints here (or don't know how, just a normal breakpoint won't do at least). But after some logging I can determine that the document is NOT passed through and doc in the LoadDoc function resides empty aka Nothing Public Sub LoadDoc(ByRef doc As Word.Document) _document = doc End Sub I already tried changing byref (maybe vba only supports byval) but without succes. Someone idea's? ~DP
-
Hello there IcerdoseDer, hope you enjoy your time being here. ~DP
-
Hello there, The problem is the following: How can I pass a Word.Document object from vba code to vb.net? I have made a small program which wraps Word 2007 into a usercontrol (custom panel) but now I want to interact with the document I ran into some problems.. For some other customizations (extra buttons on the new Ribbon) I cannot call the function with correct parameters it seems. I cannot pass the Word.Document object from vba to vb.net for some reason I don't know. Can someone shine a light for me here? vb.net Public Class EcfToolForm Private _document As Word.Document Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub ' This one doesn't work since vba can't use parameterized constructors Public Sub New(ByRef doc As Word.Document) InitializeComponent() _document = doc End Sub ' Extra function to replace above constructor. This now must be called after the constructor has been called. Public Sub LoadDoc(ByRef doc As Word.Document) _document = doc End Sub ... VBA Sub SpecialistButton_Click(control As IRibbonControl) On Error Resume Next Set toolbar = New Specialist07.EcfToolForm toolbar.LoadDoc (Word.ActiveDocument) toolbar.Show Err.Clear End Sub The library seems linked correctly (The form is shown (a toolbar, as you might have guessed ;) ) when the button is pressed, but as soon as the toolbar buttons are clicked it says object reference not set on the Word.Document object). Can someone explain me what I'm doing wrong? Kind regards, ~DP
-
I'm not sure you can do this with web app since I normally use winforms, but try looking at the Excel Object library 12.0. (office 2007 equals version 12) You can add reference to this COM library, and edit excel files. Within this library are objects like an excel sheet, document, and application. Hope it brings you a little further.. ~DP
-
I've made a small modification and seperated this problem to a different project. If I use bindingSource the values are updated, however each entry in the combobox presents a different char / letter from the string. I.E. my testcase object gets initialized and sets its filename property to testimage.png I add 2 testcase objects to my list and the values in my combobox shows this: t e s t i m ... etc. _lists = New List(Of TestCase) Dim tests(3) As TestCase For i As Integer = 0 To 3 tests(i) = New TestCase() Next _lists.AddRange(tests) Dim bind As New BindingSource(_lists, "Filename") ComboBox1.DataSource = bind bind.EndEdit() Suggestions? ~DP Edit: Solved this one. What I did was set the binding back to post #1 SourceCBox.DataSource = _images SourceCBox.ValueMember = "Filename" SourceCBox.DisplayMember = "Name" ' Add this line SourceCBox.BindingContext = New BindingContext() add INotifyPropertyChanged to the sprite class and changed the list collection to a bindinglist collection _lists = New BindingList(Of _images) _lists.AllowEdit = True _lists.AllowRemove = True _lists.AllowNew = True That's it ;) ~ DP
-
Heyey I've placed a combobox on a form called SourceCBox in the load event on this form I placed the following code: _images = New List(Of Projects.Sprite) SourceCBox.DataSource = _images SourceCBox.ValueMember = "Filename" SourceCBox.DisplayMember = "Name" Dim img As New Projects.Sprite("TestImage") img.Filename = "image.png" _images.Add(_img) where filename and name correspond to the properties of the Sprite object however if I add sprites to the _image collection, the combobox never updates. If I put a breakpoint on the DropDown event I can see in my watch that the DataSource recognizes the newly added sprite and thus corresponds with the right collection. However no items are displayed in the dropdown 'panel' of the combobox. Anyone has a clue what I'm missing here? ~DP
-
if the above don't work you might want to check out http://www.vbthunder.com/articles/readcpp.php also, the error is an mda error. You can turn off the error by Debug->Exceptions->Managed Debugging Assistants->Invalid Variant Last I read something about structures being something totally different in c++ and vb.net, although I'm not that good with vb.net and hardly use structures in VB.NET I can't provide you with more information about that. Also I can't find that article right now :( Hope this points you in the right direction Good luck ~ DP
-
You can insert rows even after binding with [grid].rows.Insert To bind to a xml file and add an empty row above you can do just this: Try Dim dset As DataSet = New DataSet() dset.ReadXml("sales_by_category.xml") DataGridView1.BindData(dset, "category") DataGridView1.Rows.Insert(0, 1) Catch ex As Exception MsgBox(ex.Message) End Try this snippet inserts a blank row at index 0, the 1 stands for count. Since we want just 1 row, count equals 1. ~DP
-
Removing a Tab from a TabControl with mouse events
DPrometheus replied to Arokh's topic in Windows Forms
You can add event handlers to your tabpages / tabcontrol dynamically as well First I tried adding event handlers to the tabpages but this will only trigger when you actually click the page instead of the label. So here is another workaround: I made a form with a tabcontrol called tabcontrol1 As you click the tab the selectedTab changes as well. This way you know what tab is clicked, since it gets focus before it gets removed. Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. 'For Each p As TabPage In TabControl1.TabPages ' AddHandler p.MouseDoubleClick, AddressOf TabPage_Close 'Next AddHandler TabControl1.MouseDoubleClick, AddressOf TabPage_Close End Sub Private Sub TabPage_Close(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) TabControl1.TabPages.Remove(CType(sender, TabControl).SelectedTab) End Sub ~ DP -
Hi First of all I'm no good at asp.net or anything web-related. However, if you have working code which just shows a dialog box for user input you can ofcourse automate this process by simply use the open / save / close functionality in different places in your application. What I mean is this: When the page loads you open the document When the user clicks the append button (or whatever it is when the document needs to expand) you call the save functionality provided by the dialog box code. Hope this helps ~ DP
-
Heyey I'm trying to get a menu button as in http://www.mscui.net/PatientJourneyDemonstrator/PrimaryCare.htm but within windows forms as a user control instead of SilverLight 2 (patient record -> menu button on the top left) It is like a rounded button, and when clicked a set of buttons move around that button, with a gradient background to indicate the control is on top of the others. I want such background effect within a panel of mine but a gradient from black to transparent just won't work within the usercontrol After several hours of searching I came across a few threads as http://www.xtremedotnettalk.com/showthread.php?t=70106 http://social.msdn.microsoft.com/forums/en-US/winforms/thread/f7c12155-a4d6-4c50-a258-2ddbe5f4df81/ http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/24f64b45-dfcb-471a-b8eb-1e983d04e003/ but none of these has a working solution anyone has a suggestion on how to pull off the transparency? thnx ~DP
-
Scroll down to Public Class Item to see the class I was talking about ;) keypoint is.. Use the members ValueMember to show items and DisplayMember to hold data. The data behind a listbox uses a type called Object which can be used for almost any custom class you create.
-
Here is some snippet Create a form with 3 buttons, 2 listboxes and a textbox I've called my form tForm, the controls have it's default names Imports System.Collections.ObjectModel ''' <summary> ''' Form class ''' </summary> ''' <remarks></remarks> Public Class tForm ''' <summary> ''' Scan button ''' </summary> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ContextMenuChanged, Button2.Click If FolderBrowserDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then ' Add scan folder to textbox TextBox1.Text = FolderBrowserDialog.SelectedPath ' Get all files in folder Dim files As ReadOnlyCollection(Of String) files = My.Computer.FileSystem.GetFiles(TextBox1.Text, FileIO.SearchOption.SearchAllSubDirectories, "*.bmp") ' Add each file to the listbox For Each s As String In files Dim i As New Item(s) ListBox1.Items.Add(i) Next End If End Sub ''' <summary> ''' Add file to second listbox ''' </summary> Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ListBox2.Items.Add(ListBox1.SelectedItem) End Sub ''' <summary> ''' The save button ''' </summary> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Copies all items into a temporary newFolder folder For Each i As Item In ListBox2.Items My.Computer.FileSystem.CopyFile(i.name, "newFolder\" + i.shortname) Next End Sub ''' <summary> ''' Load form ''' </summary> Private Sub tForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Set listbox to display the property shortname ' but use the value of the name property ListBox1.ValueMember = "name" ListBox1.DisplayMember = "shortname" ListBox2.ValueMember = "name" ListBox2.DisplayMember = "shortname" End Sub End Class ''' <summary> ''' Seperate class for listbox values ''' </summary> ''' <remarks></remarks> Public Class Item ' Path to the file Private _longname As String ''' <summary> ''' Stripped of string ''' Just the filename ''' </summary> Public ReadOnly Property shortname() As String Get Dim _str As String Dim idx As Int32 = _longname.LastIndexOf("\") + 1 Dim len As Int32 = _longname.Length _str = _longname.Substring(idx, len - idx) Return _str End Get End Property ''' <summary> ''' The whole path ''' </summary> Public Property name() As String Get Return _longname End Get Set(ByVal value As String) _longname = value End Set End Property ''' <summary> ''' Constructor ''' </summary> ''' <param name="n">path to the file</param> ''' <remarks></remarks> Public Sub New(ByVal n As String) name = n End Sub End Class hope it's clear It scans a folder puts all files ending with .bmp in a listbox (modify .bmp to .wav to fit your needs) An add button is provided to put files into the other listbox and a save button saves all files added to the secondary listbox into $workingfolder\newFolder\
-
I would suggest creating a seperate class for the paths with a collection class. I'm sorry I haven't got the time right now, but I will take a look on this later today ;) Good luck
-
After a couple of hours I managed to modify that article to fit my needs. So I would say Problem solved. :D for comparison these were my test results.. If someone might want to create a floodfill, here are some speed tests for comparison: method speed Recursive * - GDI+ / Image.SetPixel 5 min. - 58 min. GDI+ / Graphics.FillRegion 6 - 48 seconds QueueLinear 0.04 - 0.6 seconds * Recursive didn't work in managed code. Almost all fills resulted into stackoverflow thnX
-
Yes I did.. After making some logfiles and a log scanner I found out that almost 90 % was a duplicate. So I included a check if it already exists on the stack with st.Contains(point) where st is the stack this does terminate the memory leak in its whole but it lets the user wait for almost 29 seconds to fill a (relatively) small image of 440x440 pxls! Therefore I started another approach.. Create a region and add a new rectangle for each pixel which needs to repaint. At the end I simply call graphics.FillRegion(new region) But the duplicates come back even with a check to st.contains I checked all the points where I add points to the stack in the newly created GetRegion function, and those are all variants of something like this: If Not st.Contains(rightPoint) Then st.Push(rightPoint) writer.WriteLine(rightPoint.ToString()) sRight = True End If The logger gives results like: From the 8760 added points there are 8178 duplicates. Any idea's how to implement a faster fill? Or what's happening in the GetRegion? How can I check for duplicate stack points if the stack.contains function checks each possible entry point to get onto the stack?
-
Hey there, Lately I'm working on some paint program in vb.net but the floodfill algorithm (such as the bucket tool in MS paint) gives me some problems. I do the tool as follows.. I create a new stack object, and from the point where the user clicks, it goes all the way to the top of the image, and checks colors accordingly. So it finds the boundary with another color or the boundary with the current selection. The it goes down in a while loop and checks if the right / left neighbours needs a repaint as well. If they do, we put them on the stack. The algorithm works nicely, but if I open up taskmanager the memory allocated by this component grows dramatically (sometimes over 1gb, starting from 30 mb) If I fire up CLR profiler it gives me more information and shows that the stack count with the points exceeds 4 million items. The stack.Pop() function should free memory for the top most item when removing it and the stack itself has 0 items when the function finishes I really have no clue what I'm doing wrong? has someone got any idea's? Also both the stack object and Drawing.Point don't implement IDisposable, so there is no need to call Dispose() explicitly, right? (Even if I would there ain't a member function.. ) thanks in advance, M. Siroen This is what I've got so far: ArgbColor = custom color class with alpha, red, green and blue properties MyImage = Drawing.Image object MyImage.InSelection returns true if the given point is within the current selection, false otherwise ''' <summary> ''' Flood Fill function with tolerance ''' </summary> ''' <param name="point">start point</param> ''' <param name="newVal">new color</param> ''' <param name="Tolerance">Tolerance</param> ''' <returns></returns> ''' <remarks></remarks> Private Function InternalFill(ByVal point As Point, ByVal newVal As Color, ByVal Tolerance As Color) As Object ' Check if the given point is within the selection If Not MyImage.InSelection(point) Then Return Nothing ' Original color value Dim oldval As Color Dim firstRun As Boolean = False ' Switch cursor type to indicate we are busy Cursor.Current = Cursors.WaitCursor ' Determine the color underneath the mouse oldval = MyImage.GetPixel(point) ' If the new color and the clicked pixel are the same return If (ArgbColor.Compare(oldval, newVal, Tolerance)) Then Return Nothing ' First determine if a bitmap is loaded If Not (Drawing.Bitmap.Equals(MyImage, Nothing)) Then ' Local variables Dim c As Color Dim st As Stack = New Stack() Dim y1 As Int32 ' Flags to keep track which spans are tested Dim sLeft As Boolean Dim sRight As Boolean ' Clear the stack st.Clear() ' Push cursor position onto stack st.Push(point) ' While there are items on the stack While (st.Count() > 0) ' Pop the last position point = CType(st.Pop(), Point) ' Retrieve the color for that position c = MyImage.GetPixel(point) ' Copy over y position to local variable y1 = point.Y ' Scan length of the line While (y1 >= 0) c = MyImage.GetPixel(New Point(point.X, y1)) If (ArgbColor.Compare(c, oldval, Tolerance) And MyImage.InSelection(New Point(point.X, y1))) Then y1 -= 1 Else Exit While End If End While ' Scan code goes 1 to far, so correct this y1 += 1 ' Get the pixel at the new position c = MyImage.GetPixel(New Point(point.X, y1)) ' Reset flags sLeft = False sRight = False ' Check if new position is within the image and the replacement color matches the color on this span While (y1 < MyImage.Height And ArgbColor.Compare(c, oldval, Tolerance)) ' Set the pixel If (MyImage.InSelection(New Point(point.X, y1))) Then MyImage.SetPixel(New Point(point.X, y1), newVal) ' Application.DoEvents() End If ' Test left neighbour and if color needs to be replaced for this span, add it to the stack If (MyImage.InSelection(New Point(point.X - 1, y1))) Then If Not sLeft And point.X > 0 And ArgbColor.Compare(MyImage.GetPixel(New Point(point.X - 1, y1)), oldval, Tolerance) Then st.Push(New Point(point.X - 1, y1)) sLeft = True Else If sLeft And point.X > 0 Then If ArgbColor.Compare(MyImage.GetPixel(New Point(point.X - 1, y1)), oldval, Tolerance) Then st.Push(New Point(point.X - 1, y1)) Else If Not (ArgbColor.Compare(MyImage.GetPixel(New Point(point.X - 1, y1)), oldval, Tolerance)) Then sLeft = False End If End If End If End If End If ' Test right neighbour If (MyImage.InSelection(New Point(point.X + 1, y1))) Then If Not sRight And point.X < MyImage.Width - 1 And ArgbColor.Compare(MyImage.GetPixel(New Point(point.X + 1, y1)), oldval, Tolerance) Then st.Push(New Point(point.X + 1, y1)) sRight = True Else If sRight And point.X < MyImage.Width - 1 Then If ArgbColor.Compare(MyImage.GetPixel(New Point(point.X + 1, y1)), oldval, Tolerance) Then st.Push(New Point(point.X + 1, y1)) Else If Not ArgbColor.Compare(MyImage.GetPixel(New Point(point.X + 1, y1)), oldval, Tolerance) Then sRight = False End If End If End If End If End If ' Go to next line If MyImage.InSelection(New Point(point.X, y1 + 1)) Then y1 += 1 End If ' Retrieve new color c = MyImage.GetPixel(New Point(point.X, y1)) If st.Count > 1500000 And firstRun = False Then Dim thr As New Threading.Thread(AddressOf threadMessage) thr.Start() firstRun = True End If End While End While st.Clear() ' Reset cursor type Cursor.Current = Cursors.Default End If Return True End Function EDIT: As I figured out today the stack grows just too much in size. In this part: If sLeft And point.X > 0 Then If ArgbColor.Compare(MyImage.GetPixel(New Point(point.X - 1, y1)), oldval, Tolerance) Then st.Push(New Point(point.X - 1, y1)) Else If Not (ArgbColor.Compare(MyImage.GetPixel(New Point(point.X - 1, y1)), oldval, Tolerance)) Then sLeft = False End If End If End If I had to check not only the opposite direction (which would be sufficient if no selections were made) but also check the current direction and push those values onto the stack. i.e. If the stack was 'moving' left I had to check the values left of the current column as well, otherwise I'm left behind with gaps in the image. If I remove this extra line however the memory leak seems to be gone (the program keeps around 31 MB). Still does someone has another workaround for those gaps? With the selections I can add or remove shapes to the current selection. Combinations of several primary shapes will make the fill tool more error-prone in words of leaving gaps. Suggestions?