I am in the process of writing a base class for gadgets that will be displayed on a form.I want the gadget to be fully self contained and reusable.At this point it does everything that I need it to do EXCEPT, i'm having trouble figuring out a creative way to serialize my objects using only one object.I have a feeling the answer lies somewhere within the context of using shared functions but I'm having trouble wrapping my mind around it.
I am trying to create a load and save function for my customizable Menu/Tool/StatusStrip controls (see signature). Those three controls use a single AppearanceControl class, which is mainly just a large list of properties (Colors) which control the colors of the Menu/Tool/StatusStrip.
I want to be able to save and load the values of these properties so the user can store them and load others with ease. Serialization seemed the obvious answer, although I never used it before.
Now, there is a slight problem that I cannot serialize Colors, so I simply gave each Color property the XmlIgnore attribute, and created an Integer property that gets and sets the Color property (using Color.ToArgb and Color.FromArgb). This way I can serialize the color properties succesfully.
Then, there is another problem. The properties are not all in the AppearanceControl class. Instead, the AppearanceControl class has a large number of subclasses, which in turn contain the color properties.
As a small example, I may have this:
vb.net Public Class AppearanceControl Private _toolStripColorProperties As ToolStripColorProperties Private _menuStripColorProperties As MenuStripColorProperties
I am having problems with serializing and de serializing my objects.The following is my code for serializing buttons and labels which I have in my form.
Dim nodes As New List(Of nodeclass) Dim objStreamWriter As New StreamWriter(filelocation) For Each btn As Button In myNodeBtns Dim u As New nodeclass
[code].....
I get an error: There is an error in XML document (20, 3).Now I have found out that this is because I have 2 root elements and 2 xml declerations. When I save the xml for the button and te xml for the label in 2 different files, I have no problem. However I have no idea how to go about saving the xml for both of them in the same file and deserializing it back.
I apologise if this thread has been posted in the wrong section I was not certain whether it was the serialization or the networking that was causing this problem, but I feel that it is likely that it is the serialization.I am currently building two applications a client and a server, where several objects have to be sent between the applications, a couple objects each way.The applications are called "ACME Server" and "ACME Client" (yay for originality).
While I can get the first object to be transferred from the client to the server, but I can't get the second object to be transferred successfully from the server to the client, the error is occurring in the client program, I have taken a printscreen of the error that I am receiving, which I have uploaded to [URL]..All objects that are being sent are serializable (well there is an Interface called Action which I am unable to make serializable I believe due to it being an Interface).
I am currently building two applications a client and a server, where several objects have to be sent between the applications, a couple objects each way.The applications are called "ACME Server" and "ACME Client" (yay for originality).While I can get the first object to be transferred from the client to the server, but I can't get the second object to be transferred successfully from the server to the client, the error is occurring in the client program,I have taken a printscreen of the error that I am receiving, I have uploaded to [URL]..
All objects that are being sent are serializable (well there is an Interface called Action which I am unable to make serializable I believe due to it being an Interface).
Is there a tool in the toolbox that i can use that replaces checkboxes. i have limited amount of space and checkboxes just keep taking up room. I need the user to select multiple objects like checking multiple checkboxes.
This is probably a stupid question, but when accessing an attribute from within a class is it generally better to access the private variable directly, or access it using the getter/setter? Of course the whole point of encapsulating attributes is to allow changes to the underlying code without affecting anything that uses it. Should that also apply to the class itself? Or is it a case where the class should have full knowledge, and so shouldn't have to use the getters/setters?
Does anyone know how to store settings/resources internally?I have this code (example).msgbox(my.settings.message)But this method generates a .resx file with the application.
I have a handle event that takes care of about 50 buttons. Is there a way to determine which button is being clicked when the event is handled? I have tried using the FromHandle, but I can't seem to get it to work.
i have a bunch of radio buttons which can have different text displayed depending on whats retrieved from the database.however i want to add code that hides any radio button that would have a 'zero' retrieved from the database.so far this is the code i was coming up with, without getting into the nitty gritty of the actual database queries
If RadioButton1.Text = Me.HWExamsDataSet.DSExamTextA.Rows.Item.tostring = 0 Then RadioButton1.Visible = False End Ifabase entries or queries.
it looks like it may work...but is there a way to automate it so that i can put in a reference to ANY radiobutton like radiobutton(*).text? or a bunch of buttons if need be.i know theres a way to specify additional items to a given command...just can't remember if its curly brakets etc.
I have a class, Vehicle. I created two child classes, Car and Plane. I want to monitor the speed, which is a Vehicle Property, and bind it to a control (label, or image, for example) in WPF. When i create a static Class which only purpose is watching the Speed Property, it works, as far as the INotifyPropertyChanged is declared with the Speed Property name.
But the problem is, I have to create dynamicly multiple Cars and Planes by looking in an XML file and deserializing my objects, and creating multiple Car or Plane UserControl (Let's not discuss this way of working, please). So I have to get the Speed property inside the Vehicle Class (which is normal), and I have to get a INotifyPropertyChanged on each Speed of each Vehicle Created. So, my Cars and Planes are loaded, and I have to get all speeds, but I can't create a static Speed property by Vehicle. By the way, by creating a non-static Speed property (as int, for example) in Vehicle Class with INotifyPropertyChanged raised in the setter, it does not work. The event seems to be raised, but my converter is not fired, and my controls does not update.
In my Vehicle Class
Private SpeedValue As Integer <XmlIgnore()> Public Property Speed() As Short Get
[Code]....
The PlaneView Class is almost the same for this part.
I confirm that the converter is fired just once, the first time, when the tabs are created, because I put a breakpoint on the Convert function definition. After that, the converter is never fired again. So the picture img_fonctionnement is displayed, but it is never updated. But the Speed property is updated, I swear. And the INotifyPropertyChanged (in Speed's setter) is raised, as far as i know with the help of the debugger.
And the "an item with the same key has already been added" (which appears in a messageBox, and not as an exception) seems to appear only when I am to long with the debugger. In normal execution mode, it never shows.
How can I call multiple objects? Example.. nameTextbox.Enabled addressTextbox.Enabled ContactTextbox.Enabled How can I call this objects with same properties...
So rather than typing them all with =True or False... I just have to type a variable = True or false... And where will I type the code.
So I want to click on different things in a listbox and somethings have a picture and some dont. I want the things without a picture to all show the same thing. I've tried this:
Code:
If ListBox1.SelectedItem = object1 Then PictureBox1.ImageLocation = object1picture Else
[CODE]...
This only works for object2 and I know why, but I dont know the correct way to make it work for multiple objects.
I'm using VB.net from the Visual Studio 2008. I have a large number of PictureBoxs in a form. They have been created sequentially, Pic1, Pic2, Pic3, ... Depending on how I access this form, I want to turn off a number of them. I'm working with the code below.I can put the name of the object into a variable, Pic, but am still unable to hide the object names in that variable, Pic.Hide().
Dim StartNumber As UShort = 1 Dim StopNumber As UShort = 33 Dim Number As Object = 1
I have one class with <Serialize> attribute called Tree. And Tree class has an arraylist of TreeNode classes. Is it possible to use Soap to convert the Tree class and arraylist of TreeNode classes to one xml file or binary file? If it is possible, do i need to use <Serialize> attribute on TreeNode classes too? If not, what should i do then?
I'm wanting to to make a color scheme selection feature for my program, which involves changing the foreground and background colors of many components at once. I have the components divided into groups in which all elements should have the same background and foreground.
vb With BtnLoad And BtnSave And TbxListname And CmbProgDifficulty And TbxRptStandard And TbxQNA And BtnAddProbQ .ForeColor = Color.White .BackColor = Color.IndianRed End With
The problem is that this get's an error message saying that you cannot use "And" (or & or +) in the statement.If I just use one object at a time,
vb With BtnLoad .ForeColor = Color.White .BackColor = Color.IndianRed End With
it works fine. I have so many objects though, I don't really want to copy and paste this with statement 50 times. is there a way to make a with statement take multiple objects?
In my game, which is just for practice, I have a 2 rectangles one set as the inner bounderies, one set as a sprite, but I want to create walls for my boundaries. So how could I set a string of bounds with this
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress If Sprite.Bounds.Top <> Wall.Bounds.Top Then
I have a collection of populated custom business objects in my app which I'm going to insert into a SQL 2005 DB using a stored procedure. The collection size isn't massive, maybe 20-30 objects.Is there an elegant way to insert all of these objects into the DB in one go without doing something like the following?:
Open DB conn For each item in collection ... Set parameter values of SP from item.properties for SQLCmd
I have about 20 different report tables in my Entity Data Model that all have a few common fields (like start_date and end_date). When my reporting application pulls data for a given report, the first thing I do is filter the table for today's date. This means I have code blocks similar to this throughout my code (VB)[code]...
Is there a way to create a single generic function that can apply some logic to different objects and return that specific object instead of a generic one? Alternatively, is there a way to cast the return value back to the specific entity object type?
My brain is fried at the moment, so here's the scenario.I have a form that adds a member to my VB.NET application.When I press submit I add their details: name and number as well as what products they want (internet and phone). Internet and Phone are their own class as is member.
I want to add that they HAVE whichever they have chosen and with the member store it.
[Code]...
As what happens is once the member is created (stored) I will go to input how much they have used, and then store that. But to do so I will need access to the internet and phone classes, which are associated with said member.
My program has multiple webbrowser objects, each one in a different tab. How would i go about setting up a button to refresh only the webbrowser on the active tab?
I am trying to save multiple type of objects to a single file, objects are a custom class that I am able to serializable and another object is a word document that is not being able to serialize via binary. Is there a way to save multiple objects to one file using vb, also would it be possible to save files like how a docx is saved, that is a .zip renamed as docx but get access to inner objects.
I'm trying to set up a system to resize multiple objects on a form (40+) when the form resizes. I've got it working but it's rather slow, when I resize the form it stutters a lot from looping through the objects to resize them. Is there a better way to do this that would not cause the stuttering effect?
How best to manage multiple dat files for serializable objects of the same class. If one of my data files goes past a particular size, I want to create a new file. I then loop through both files when I do processing. Is there any easier way to do this and what's the best size to do this at in terms of performance?
I am writing a numerical model to perform a set of calculations within a unit, pass the output to a new unit and perform the same calculations and so on. To do so, I have created a complicated set of functions. I have various arrays which store function outputs that are used for other functions within the program. I am trying to modify the language of the program so the functions can be repeated for each unit without literally repeating each code sequence with modified variable identities. For example:
I have a VB.NET application and use some third party (closed source) ActiveX controls. One of the controls represents a "camera" (connected over several interfaces) and I try to write an example how to work with several cameras in one application. To do this I allocate multiple "camera" objects dynamically as an array which works as expected like this:
Const NUM_CAMERAS = 2 Private MyCameras(NUM_CAMERAS ) As xxx.MCamera
But the camera objects needs to be allocated with WithEvents because they raise events when a new image was taken. I found out that WithEvents variables cannot be typed as arrays and this is a pretty common problem so I also found some workarounds: [URL]. This is already pretty good and I adopted this to my concept. So I have a MyCameras array and a MyCamera all "without Events", first allocate a new MyCamera object, add a event handler and then put it into the array.
Unfortunately I get an error when calling AddHandler Camera.ProcessModifiedImage, AddressOf MyHook
Normally "MyHook" is declared as Private Sub MyHook (ByVal sender As Object, ByVal ModifiedBuffer As xxx.ProcessModifiedImageEvent) Handles Camera.ProcessModifiedImage
Like in the "Button examples" I just removed the "Handles Camera.ProcessModifiedImage" but I get an error that "MyHook" has not the same signature as the Delegate Delegate Sub ICameraEvents_ProcessModifiedImageEventHandler(ImageIndex as Integer)