|
This is part of the solution:
public struct image {
private byte xy;
private byte color;
private byte gray;
public int X {
get { return xy>>4;}
sey { xy=(value<<4) | (xy&0xF);}
}
etc.
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Monday, July 20, 2009 8:15 PM
|
|
|
|
|
[Flags]
public enum PizzaToppings
{
ExtraCheese = 1,
Pepperoni = 2,
ItalianSausage = 4,
AmericanSausage = 8,
Peppers = 16,
Mushrooms = 32,
Anchovis = 64,
Pineapples = 128
}
public class Pizza
{
private PizzaToppings toppings;
public PizzaToppings Toppings
{
get{ return toppings; }
set{ toppings = value; }
}
}
Pizza p = new Pizza();
p.Toppings =
PizzaToppings.ExtraCheese |
PizzaToppings.ItalianSausage |
PizzaToppings.Pepperoni;
|
|
|
|
|
pixels are necessarily pizza toppings
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I thought there was (for interop), using attributes, I just never have so I don't recall.
Maybe I'll investigate a little later.
|
|
|
|
|
All Google could turn up was using field offsets to have several byte variables at the same address, then a lot of SHIFT and AND and OR. But then it doesn't make sense to me to have such unions, why not calculate the aggregate byte right away, as I did in my example.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Look into
System.Runtime.InteropServices.StructLayoutAttribute
and
System.Runtime.InteropServices.FieldOffsetAttribute
[StructLayout(LayoutKind.Explicit)]
public class SYSTEM_INFO
{
[FieldOffset(0)] public ulong OemId;
[FieldOffset(4)] public ulong PageSize;
[FieldOffset(16)] public ulong ActiveProcessorMask;
[FieldOffset(20)] public ulong NumberOfProcessors;
[FieldOffset(24)] public ulong ProcessorType;
}
Edit: Oh, wait, that's in bytes, not bits.
|
|
|
|
|
An idea came up to my mind
This is not a working code, it's just for demonstration
<br />
<br />
class image<br />
{<br />
byte x;
byte y;
byte color;
byte grayscale;
byte spare;
<br />
public byte[] getImageByteArray()<br />
{<br />
byte byteArray[3];<br />
byteArray[0] = x<<4 +y;<br />
byteArray[1] = color;<br />
byteArray[2] = grayscale<<7 + spare;<br />
}<br />
}<br />
<br />
I don't know if this will be fine since I am communicating with a real time application, and I have large structs,I mean will this bit manipulation slow the process of sending data over 40ms intervals.
Edit:
Another problem raises when I have fields larger than 8 bits
modified on Tuesday, July 21, 2009 5:02 AM
|
|
|
|
|
You should be able to send data quickly enough. I have an application that does something similar (turns many flags and less than full byte variables into a bit array in 'real time') and it keeps up.
For fields larger than 8 bits, just use the BitConverter class to get a variable of the next size up (eg: ushort for 10 bits, uint for 20 bits) and apply the same masking and combination techniques. Also, I would OR values together instead of adding them.
|
|
|
|
|
|
Hi,
is there a way to split the picturBox on demand, so that only everything underneath the diagonal is usable to paint on it?
|
|
|
|
|
Hell, no. A picturebox is a close to useless control, it's only value is to draw pictures for people too inexperienced to handle their own paint event. If you draw it yourself, you can use an ImageAttributes object in a DrawImage overload of the Graphics class, to specify a color range that would be transparent. This would occur in the Paint event.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi Christian,
thanks for your answer. Like i said in the other thread, i unfortunately can't use something else than a picturebox.
Maybe i can draw a graphic(in my case a triangle) in the pb-paint event and set it to be always in the foreground or something like that?!
It's only important that a part of the pb seems to be empty no matter if there was something painted or written.
|
|
|
|
|
Oh, I thought you wanted to disable the bikini on a model.
|
|
|
|
|
hehe good idea but not my intention.
I'm thankfull for any suggestion.
|
|
|
|
|
ok i think i found the solution and yes it is possible
picturebox.setclip should do the work for me. Now im gonna try it...
|
|
|
|
|
Hi,
I have created an Outlook 2007 plugin using VSTO and I am getting an error that I hope someone out there has seen and could help me fix.
The plugin (add-on) is a command bar that simply waits for a (email appointment, or task) property to change (MS CRM stuff - gets changed by Microsofts CRM Integration) and then shows a Windows form asking for a Category. Everything works great unless I follow a very specific set of steps.
What I mean by that is I can get the form to popup a hundred times for Emails, Tasks, and Appointments and never have a problem. Then if I do an appointment a certain way, it blows up and then it will do it for everything until I restart Outlook.
This is the error message I get...
Unable to cast COM object of type 'System.__ComObject' to interface type 'System.Runtime.InteropServices.UCOMIConnectionPointContainer'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B196B284-BAB4-101A-B69C-00AA00341D07}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I can find almost no information about UCOMIConnectionPointContainer other then it looks like it is depricated in the .NET Framework 3.5. The odd thing is where this error is occurring, I am not actually trying to cast to a UCOMIConnectionPointerContainer object, I am trying to cast to an Outlook.Appointment object.
Here is the piece of code that causes the error....
if (m_Item is Outlook.AppointmentItem)
{
m_ItemType = OutlookItemType.AppointmentItem;
((Outlook.AppointmentItem)m_Item).CustomPropertyChange += new Microsoft.Office.Interop.Outlook.ItemEvents_10_CustomPropertyChangeEventHandler(Item_PropertyChange);
((Outlook.AppointmentItem)m_Item).Write += new Microsoft.Office.Interop.Outlook.ItemEvents_10_WriteEventHandler(OutlookItem_Write);
}
else if .......
This goes on to check for a Mail Item and a Task Item. Those never fail initially. It is always an Appointment item and once it fails, then I get the error for almost everything.
I hope somebody has seen this an can offer some advice.
Thanks in advance,
Wendell
|
|
|
|
|
Hi,
I am trying to populate data into one grid name Grid1 using the row selected in Grid2. Grid1 and Grid2 have a common ID called ColorID . For a row with ColorID selected in Grid2 I want the data corresposding to that ColorID and also I have few combo boxes in the same grid2 selecting on which data to be populated in Grid1
Can someone help me with this or providing some link from which I might look and try to work on !!
Thanks a lot !!
|
|
|
|
|
I have a Windows form and I want to display a row across the bottom with a group of images.
The image location will be stored in a database.
I want them to be side by side in a single row. I know I can use a datagridview to display them vertically, but I am not sure if this can be done horizontally, nor am I sure if this is the right approach.
What is the right control to use for this? I want to be able to click on each picture and change the current record in the windows form to reflect the selected picture, I want to be able to scroll through the images (Horizontally only).
Is this a job for a repeater or datalist? Does anyone have a URL example of something of this sort?
Thank you in advance.
|
|
|
|
|
Hi,
I haven't done this yet, however my first attempt would entail a ListBox with its MultiColumn property set true.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I have simple form with 4 controls.
listbox, textbox, button and combobox (with 3 colors - red, blue, green).
When i press on the button i want the message that in the textbox will show in the listbox but with the color from the combobox.
Some can help me with that?
Thanks
|
|
|
|
|
here[^] is an example to show how to use the drawitem event of the listbox in order to change the color of the text
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Yes, i saw this article.
But how i combine this with the click event?
|
|
|
|
|
Hi,
this[^] is the simplest example I have on colored listbox items.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
All items the same color? Or different colors for different items?
If the latter and the ListBox won't do it, maybe try a TreeView instead.
|
|
|
|
|
The color off the text wil be the same as shown in the combobox.
for ex:
textbox - "Hello World".
combobox - Red.
When i press the button the listbox will show the line "Hello World" in red.
|
|
|
|