|
byte[] bytBuffer = new byte[4096];
long lngBytesProcessed = 0;
long lngFileLength = fsInput.Length;
int intBytesIncurrentBlock;
CryptoStream csCryptoStream;
System.Security.Cryptography.RijndaelManaged cspRijndael = new System.Security.Cryptography.RijndaelManaged();
pbStatus.Value = 0;
pbStatus.Maximum = 100;
switch (Direction)
{
case CryptoAction.ActionEncrypt:
csCryptoStream = new CryptoStream(fsOutput, cspRijndael.CreateEncryptor(bytKey, bytIV), CryptoStreamMode.Write);
break;
case CryptoAction.ActionDecrypt:
csCryptoStream=new CryptoStream(fsOutput, cspRijndael.CreateDecryptor(bytKey, bytIV), CryptoStreamMode.Write);
break;
}
while (lngBytesProcessed<lngFileLength){
intBytesIncurrentBlock = fsInput.Read(bytBuffer, 0, 4096);
csCryptoStream.Write(bytBuffer, 0, intBytesIncurrentBlock);
lngBytesProcessed = lngBytesProcessed + long.Parse(intBytesIncurrentBlock);
pbStatus.Value = int.Parse((lngBytesProcessed/lngFileLength)*100);
}
Am getting this error with the long.Parse and int.Parse,
The best overloaded method match for 'int.Parse(string)' has some invalid arguments
The best overloaded method match for 'long.Parse(string)' has some invalid arguments
Can't convert long or int to string
plss help
|
|
|
|
|
Well, there are a few things you need to understand.
1. This forum is for WPF/Silverlight. What you posted should be dealt with in the C# forum.
2. You haven't supplied any strings to parse. The values in the Parse methods are numeric already, and Parse expects a string.
3. When parsing a string to a number, you are better off using TryParse instead - just in case the string contains crap.
4. Your post seems to indicate that you are trying to convert a long/int to a string. This can be done simply by calling ToString() on the value, or convert it with the (string) converter. Here's an example:
private string GetValue(int value)
{
return (string)value;
}
|
|
|
|
|
I am working on this dialog[^]
The part data in the center is a ListBox. I want to add radio buttons to each list row so that it will then look like this[^](I mocked this up). Each row can be always expanded an non-collapsable.
So, I have this xaml:
<Window.Resources>
<HierarchicalDataTemplate DataType="{x:Type model:PartDescriptionUpdateModel}"
ItemsSource="{Binding Path=Descriptions}">
<StackPanel Orientation="Horizontal">
<Image Source="/Abtech.Spares.UI;component/Media/Graphics/lancard_enabled_128x128.png"
Height="16"
Width="16"
Margin="0,0,3,0"/>
<TextBlock Text="{Binding Path=PartNo}"/>
<Label Content=" - "/>
<TextBlock Text="{Binding Path=Description}"/>
</StackPanel>
</HierarchicalDataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--List of part info-->
<ListBox x:Name="lstParts"
Grid.Row="2"
Margin="5"
ItemsSource="{Binding PartsData}"/>
</Grid>
I am not sure how to add to the data template to get the radio buttons in there. Anyone know how to do this?
Mank thanks
Everything makes sense in someone's mind
|
|
|
|
|
In your StackPanel, you would add an ItemsControl ItemsSource={Binding SubItems} or whatever and set the item template of the ItemsControl up to be a RadioButton + Text. The tricky part here is going to be setting up the RadioButton GroupName (so the radio buttons actually behave like a group). If you have 3 radio buttons in an item, they've all got to have the same group name, but that group name has to be different for each listbox item. I'm gonna assume PartNo is unique for each part, so I'd set the group name in your ItemsControl template radio button to be PartNo.
|
|
|
|
|
Now that I think about it - there's no gaurentee that the part # will be unique in the list.
I'm wondering if I can do this more simply with a treeview.
Everything makes sense in someone's mind
|
|
|
|
|
Doesn't have to be the PartNo. That was just a suggestion that looked the simplest. You can use a GUID, or the index of the item in the ItemsSource. Anything that is unique at the ListBoxItem level. You'd run into the same issue using radio buttons in a tree. If you don't set the group name, they act like checkboxes. ItemsControl is very simple to use.
|
|
|
|
|
Ok, I understand your solution.
My data models are very simple:
public class PartDescriptionUpdateModel
{
public string PartNo { get; set; }
public string Description { get; set; }
public List<PartDescriptionModel> Descriptions { get; set; }
}
and
public class PartDescriptionModel
{
public Inventory InventoryLocation { get; set; }
public string PartDescription { get; set; }
public string ImageName { get; set; }
}
I now have this:
<Window.Resources>
<HierarchicalDataTemplate DataType="{x:Type model:PartDescriptionUpdateModel}"
ItemsSource="{Binding Path=Descriptions}">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=PartNo}"/>
<Label Content=" - "/>
<TextBlock Text="{Binding Path=Description}"/>
</StackPanel>
<ItemsControl ItemsSource="{Binding Descriptions}"
Margin="10, 0, 0, 20">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding PartDescription}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</HierarchicalDataTemplate>
</Window.Resources>
It produces this[^].
There are 2 problems:
1) There's only 1 radio button being displayed. There are 3 per part.
2) The same value is being displayed for all.
I'm sort of new to templating, but I'm guessing there's a binding problem? Anything look abvious to you?
Everything makes sense in someone's mind
|
|
|
|
|
Not sure why you are using a HierarchicalDataTemplate for the ListBox vs. a DataTemplate, but I don't think thats causing your issue. Or did you switch over to a tree?
One "nice-ety" in WPF is that it allows string formatting, so instead of doing the string - string part in a StackPanel, you can just have a single TextBlock and use the StringFormat property to format the string (using a MultiBinding for the PartNo and Description), but thats just clean up, not really your issue.
Ok, so if I'm to understand, your ItemsSource on the ListBox is pointing to PartDescriptionUpdateModel? PartDescriptionUpdateModel.Descriptions is a List of PartDescriptionModels. However, it seems like you are binding to properties of PartDescriptionUpdateModel and not the individual PartDescriptionModels?
Where is that LevelingPad stuff stored?
|
|
|
|
|
No, I'm still using the listbox.
Yes, the listbox is bound to PartDescriptionUpdateModel and its ItemsSource is Descriptions
which is a list of PartDescriptionModels
The ItemsControl is defined like this:
<ItemsControl ItemsSource="{Binding Descriptions}"
Margin="10, 0, 0, 20">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding PartDescription}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
You can see the ItemsSource="{Binding Descriptions}". I'm not sure if this is the problem. I now have both the listbox and ItemsControl.ItemsSource bound to the same source.
t you mean by "LevelingPad stuff". Can you elaborate please?
Everything makes sense in someone's mind
|
|
|
|
|
Yeah, thats what I was getting at... according to your screen shot, the ListBox ItemsSource should be binding to the list of items that looks something like:
[0] A7136-67001 _ System BRX...
[1] AB587-60005 _ ...
.
.
.
The ItemsSource for the ItemsControl should be binding to a collection that looks something like:
[0] Leveling pad - screws into bottom of cabinet
[1] Backplane
.
.
Are the radio buttons choices going to be the same for each ListBoxItem? If so, you can just use a single ItemsSource for all the radio buttons and have that List on your VM. Otherwise, each item would need to have its own list of RadioButton choices.
|
|
|
|
|
There will always be 3 radio buttons. Their content is coming from data.
Everything makes sense in someone's mind
|
|
|
|
|
Ok, I see...
So, in this XAML
<Window.Resources>
<HierarchicalDataTemplate DataType="{x:Type model:PartDescriptionUpdateModel}"
ItemsSource="{Binding Path=Descriptions}">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=PartNo}"/>
<Label Content=" - "/>
<TextBlock Text="{Binding Path=Description}"/>
</StackPanel>
<ItemsControl ItemsSource="{Binding Descriptions}"
Margin="10, 0, 0, 20">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding PartDescription}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</HierarchicalDataTemplate>
</Window.Resources>
I think it's as you described... The LisBox is bound to a list of PartDescriptionUpdateModels. They have the PartNumber and Description.
The ItemsControl is bound to Descriptions, wich is the subitems list on the PartDescriptionUpdateModel. Still, the ItemsControl feels wrong.
Everything makes sense in someone's mind
|
|
|
|
|
Ok, so the ListBox is bound to some object that has a "List<partdescriptionupdatemodels> Descriptions" property. Everything inside of the data template is bound to a SINGLE PartDescriptionUpdateModels in that list. So then it makes sense why both are binding to "Descriptions" because those are two different "Descriptions". It looks like your XAML is correct except the 2nd Descriptions object only contains the one item (the ...screws to bottom of case... item)? Can you debug that and see if you really have the 3 items in that list?
|
|
|
|
|
THANK YOU!
I did indeed have some issues in the code behind. Strange thing is, I worked on this last night and the collections were correct. After your last post I thought, "I better check just to be sure", and of course not only was the data wrong, but I had a couple of subtle bugs that were affecting it.
So, now I have this[^].
Next step is to wire up the IsSelected.
Again, many thanks!
Everything makes sense in someone's mind
|
|
|
|
|
Cool. I think if you try clicking around on the radio buttons, you'll find they operate like checkboxes. Adding in the GroupName as I mentioned before will fix that.
|
|
|
|
|
Ya I think that I will add a GroupName property to the PartDescriptionModel. Then I will set all 3 to a unique value when I'm loading the collection. Then bind the GroupName to that property. That ought to do it.
Everything makes sense in someone's mind
|
|
|
|
|
Hey all,
I am working on some code for Silverlight / windows phone:
I have 2 Xaml pages , Main and Second page:
Main page , I have a button. With default text. " button"
I have an OnHold event, that navigates to Second.xaml page.
On Second.xaml page is a ListBox. With lets say 3 ListBoxItems. item1, item2 and item3.
Here's where I am lost.
I want to have my selected item() 1 2 or 3, do 2 things:
1. Update the text in the button on the MainPage.xaml. The text says "item1" or whateveritem I selected.
2. The selected item in the listbox also selects an object in a folder. Call this folder resources. and the objects lets say are text or png files or whatever...just something I created outside of the IDE.
I wil worry about any OnClick functions or what to do with the objects in the folder later. Its the selection / update upon multiple pages that gets me right now.
|
|
|
|
|
You mean auto select a file / folder in an external Windows Explorer window?
You can just do something like:
System.Diagnostics.Process.Start("explorer.exe", avi.Path);
and it will auto-select the folder / file in avi.Path for you.
Does Main have a reference to Second? or does Second have a reference to Main? Really, in proper MVVM, they shouldn't know about each other, so you should use something like a messenger service to communicate between views.
|
|
|
|
|
Well actually I think simpler than that?
this is strictly going to be a windows phone application using a couple xaml pages. No windows.exe or anything like that.
so no mesenger service either as navigating from one xaml to another in a windows phone app is normal and accepted.
|
|
|
|
|
Do you have a reference to the other page? You could just subscribe to a simple event.
|
|
|
|
|
A reference? Well the only reference I have in a snece is the button OnHold event navigationg to the second page.
|
|
|
|
|
Hmm.. well, I'll have to hand you off to the Silverlight guys then. If you don't have a reference to the page and don't want to use messenger (which is really simple IMO), then I'd think you'd need a global static class that exposes an event or holds the references there. There might be something to handle that in Silverlight that I'm not aware of. In WPF, I'd certainly use messenger to communicate between views.
|
|
|
|
|
Hi, I'm drawing on a topmost semitransparent Window. I'd draw rectangle with transparent background.
I tried:
rec.Fill = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));
canvas.Children.Add(rec);
but doesn't work. How can I do?
|
|
|
|
|
I know how to create a flat style button with just the image showing unless the user hovers over it or when it's pressed. I don't know how to do the same thing for a toggle button. I need it be flat (image only) in a normal state but when the user hovers over it or when it is pressed or when IsChecked=True the state behaves like the default toggle button. I tried modifying the Normal state only but when I do, the MouseOver state no longer behaves the same way.
Any ideas?
Let me know,
Aaron
|
|
|
|
|
Hi,
I have a Silverlight application where in the browser which loads a WCFClient dll requests the data from a server a WCFService dll.The IE has many graphic elements on the browser window which are populated with the data retrieved from the WCFService. The issue here is the server is throwing the below exception when the the number of graphic elements configured exceeds.Also the data is not populated in these graphic elements.
[HttpWebRequest_WebException_RemoteServer]
Arguments: NotFound
Debugging resource strings are unavailable...
Going through the below blog
http://forums.silverlight.net/t/133801.aspx/3/10[^]
observed that the issue could be with the following tag configured in my WCFService projects Web.config file
<dataContractSerializer maxItemsInObjectGraph="2000000000"/>
Could any one of you please tell me how to go about fixing this issue?
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|