|
Hi,
I am working on an application in which we have to retrieve the attachment files from given Gmail Id using Pop3 and save them in a folder. I worked this with yahoo mail, but now I have to do this with Gmail too. As Gmail have some security I am notable to directly connect to it directly. I came to know that using SSlconnection we can connect to Gmail. But I don't know how to do this.
If any one have any idea to solve this please reply me.
Thanks in Advance.
|
|
|
|
|
Well, in WPF I'd do this by... no wait, your question has nothing whatsoever to do with WPF. OK, change of tack, in WCF I'd do this by... no wait, it's not WCF either. Silly me, it must be WF - well, I'd start by... no wait not WF either. You haven't, um, got the wrong forum by any chance?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'm using data binding to populate the rows of a ListView. Then an event takes place where I have to change a value in a particular column in the row and I'm successfully doing that. But now to grab the user's attention I want to change the color of the text in the row. But all I have is a reference to the data object whose public properties I use to populate the row. But how do I get a reference to the UI object that presents this data visually in a row within the ListView so I can change the style of that row?
As you can see, I'm still puzzling over how to get back and forth between the data and the UI presenting it visually. I know there's a difference. I just don't know how to get back and forth. This sounds like a fundamental WPF question and is another example of fundamental knowledge that I have not yet mastered, but once I get this one answered, a lot of pieces of the puzzle are going to fall into place.
|
|
|
|
|
Never mind. I figured it out. I needed a Style Data Trigger.
|
|
|
|
|
Hi,
I have a grid container with controls in its cells. I need to move the controls from one cell to another in the grid or across grids by dragging and dropping.
Is there any sample for it. Can anyone tell how to achieve it in wpf.
Thanks
|
|
|
|
|
How can I open a file search dialog in WPF with XAML?
Thanks,
David
|
|
|
|
|
Why do you need to use XAML ? I don't see how you can, I mean, how would you work with the resultant file if not in code behind ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
|
The same way you would with winforms. I'd imagine some XAML to hook up an event for when you want the dialog to appear, but then you just create it and show it.
OpenFileDialog dlg = new OpenFileDialog(); // etc
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
|
You don't want the xaml to do the work. Hook up a button and write the code in the event. Here's a sample that I wrote that will open the file dialog box with a .zip filter. This code is for 3.5 sp1, it is slightly different in earlier versions.
Dim myDialog As New Microsoft.Win32.OpenFileDialog
Dim sourceFilePath As String = ""
myDialog.Filter = "Zipped Files(*.zip)|*.zip"
myDialog.CheckFileExists = True
myDialog.Multiselect = False
If myDialog.ShowDialog = True Then
sourceFilePath = myDialog.FileName
Else
|
|
|
|
|
Thanks, I will try it,
David
|
|
|
|
|
Hi!
I hope someone can help me with this:
I have an enum as itemssource for combobox and I want to bind selected item in this combobox with property of some object. How do I do that?
For instance, let's say this is enum:
public enum AlarmTypes
{
LOW,
HIGH
}
and there is class Alarm which has AlarmType property:
public class Alarm
{
...
private string alarmType;
public string AlarmType
{
get { return this.alarmType; }
set { this.alarmType = value; }
}
....
}
and of course ComboBox is defined in XAML:
<objectdataprovider
x:key="AlarmTypes"
="" methodname="GetValues" objecttype="{x:Type System:Enum}">
<objectdataprovider.methodparameters>
<x:type typename="enumns:AlarmTypes">
...
<combobox name="alarmTypeComboBox" itemssource="{Binding Source={StaticResource AlarmTypes}}">
I tried to solve this in many ways but none of them was completely successful. Thanks in advance!
|
|
|
|
|
|
Hi All,
I am working on Silverlight 2.0.
I have a grid (which is actually a menu) in my silverlight page. I want this grid to have a floating capability, that is, as and when the user scrolls, it should always stick to the bottom of the page or at the centre of the page page. Even when the page is minimized/maximized, this grid should be placed to the bottom of the page.
Is there an option in silverlight to dock a control to the any particular portion of the page ?
Is coding necessary to create such an effect?
Any pointers to online samples or code snippets will be really helpful.
Thanks in advance.
Sunil
|
|
|
|
|
The layout of the Silverlight control plugin on a page is
an HTML issue and outside the scope of this message board.
For layout within your Silverlight app, you need to use the
elements that give you the functionality you need.
A couple possible solutions:
The Silverlight Toolkit[^] has a DockPanel element you could use
to fix the grid at the bottom.
You could also use an outer grid with two rows - the first row
star-sized, and the second row fixed/auto sized. Put the grid you
want fixed to the bottom in the second row of the outer grid.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
I suppose there is a disconnect in the issue that i am facing and the your understanding of my issue.
I do know that silverlight is a plugin. What I wanted to achieve is like this:
1. A complete silverlight web page.
2. A menu (silverlight control) that floats top of this silverlight page. When the user scrolls the silverlight page, the menu should still be as docked botttom to the page.
I hope i am clear. Please let me know if I should elaborate the problem.
Thanks.
Sunil
|
|
|
|
|
I'm not sure what you mean by "floats" but I gave you two possible
solutions for docking something to the bottom of the page...
Use a DockPanel:
<UserControl x:Class="SilverlightTester.MyPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:stk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
>
<stk:DockPanel x:Name="layoutRoot" >
<!-- This is the menu that stays anchored at the bottom of the page -->
<StackPanel stk:DockPanel.Dock="Bottom" Orientation="Horizontal" Background="SteelBlue" >
<Button Content="Menu 1" />
<Button Content="Menu 2" />
<Button Content="Menu 3" />
</StackPanel>
<!-- This is the main body of the page (scrollable) -->
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
<Grid Width="1000" Height="1000" Background="LightSteelBlue" />
</ScrollViewer>
</stk:DockPanel>
</UserControl>
Use a Grid:
<UserControl x:Class="SilverlightTester.MyPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Grid x:Name="layoutRoot" >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- This is the main body of the page (scrollable) -->
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
<Grid Width="1000" Height="1000" Background="LightSteelBlue" />
</ScrollViewer>
<!-- This is the menu that stays anchored at the bottom of the page -->
<StackPanel Grid.Row="1" Orientation="Horizontal" Background="SteelBlue" >
<Button Content="Menu 1" />
<Button Content="Menu 2" />
<Button Content="Menu 3" />
</StackPanel>
</Grid>
</UserControl>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Thanks for your suggestion. I had to do a little tweaking to the canvas and i was able to achieve what I wished for. I could mail the .xap and html file of my prototype if you need. I will surely try out as per your suggestion and let you know...
Thanks for your time.
Sunil
|
|
|
|
|
private void button1_Click(object sender, RoutedEventArgs e)
{
Random rnd = new Random();
Pen p = new Pen();
byte red, green, blue;
for (int i = 0; i < 100; i++)
{
SolidColorBrush brush = new SolidColorBrush();
Line line = new Line();
red = (byte)rnd.Next(0, 255);
green = (byte)rnd.Next(0, 255);
blue = (byte)rnd.Next(0, 255);
Color col = new Color();
col.R = red;
col.G = green;
col.B = blue;
col.A = 255;
brush.Color = col;
line.X2 = rnd.Next(0, (int)canvas1.ActualWidth);
line.Y2 = rnd.Next(0, (int)canvas1.ActualHeight);
line.X1 = rnd.Next(0, (int)canvas1.ActualWidth);
line.Y1 = rnd.Next(0, (int)canvas1.ActualHeight);
line.Stroke = brush;
line.StrokeThickness = 1.0;
canvas1.Children.Add(line);
}
}
I would like to use a ProgressBar for this loop, but when I tried it my ProgressBar only updated itself once after the loop had been completed when it went from 0% to 100%. I reckon canvas1.Children.Add(line) functions like a stack, maybe I need to override some virtual method to make the ProgessBar show progress. Could anybody here give me a hint on how to do this?
Thankyou,
Ranger.
PS, What I tried was in the i-loop a command this.progressBar.Value = i; I tried my code in a sample program that only had an i-loop that did nothing and there my progressBar worked fine...
|
|
|
|
|
Ranger49 wrote: tried my code in a sample program that only had an i-loop that did nothing and there my progressBar worked fine...
Maybe it just appeared to work fine - a loop from 0 to 99 is pretty fast on modern machines.
When I ran your code, even the lines didn't show up until the end of the loop.
This is because you're hogging the UI thread for the duration of the loop.
It may be a better idea to do busy work on a separate thread. Here's an example
using a BackgroundWorker thread (I added a Sleep() to slow things down a bit since on
my machine this loop finishes faster than I can see):
BackgroundWorker bw = new BackgroundWorker();
public Window1()
{
InitializeComponent();
bw.WorkerReportsProgress = true;
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
if (!bw.IsBusy)
bw.RunWorkerAsync();
}
void bw_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i < 100; i++)
{
bw.ReportProgress(i);
Thread.Sleep(50);
}
}
void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
Random rnd = new Random();
Pen p = new Pen();
byte red, green, blue;
SolidColorBrush brush = new SolidColorBrush();
Line line = new Line();
red = (byte)rnd.Next(0, 255);
green = (byte)rnd.Next(0, 255);
blue = (byte)rnd.Next(0, 255);
Color col = new Color();
col.R = red;
col.G = green;
col.B = blue;
col.A = 255;
brush.Color = col;
line.X2 = rnd.Next(0, (int)canvas1.ActualWidth);
line.Y2 = rnd.Next(0, (int)canvas1.ActualHeight);
line.X1 = rnd.Next(0, (int)canvas1.ActualWidth);
line.Y1 = rnd.Next(0, (int)canvas1.ActualHeight);
line.Stroke = brush;
line.StrokeThickness = 1.0;
canvas1.Children.Add(line);
progressbar1.Value = e.ProgressPercentage;
}
*edit* Funny side note: Taking the Sleep() call out of my example makes it<br />
run too fast to get a newly seeded Random object so only a few lines appear<br />
(because there's so many duplicate lines :)). I suppose without the Sleep() call,<br />
the Random object should be created only once outside the loop. That change could <br />
look something like this:
void bw_DoWork(object sender, DoWorkEventArgs e)
{
Random rnd = new Random();
for (int i = 0; i < 100; i++)
{
bw.ReportProgress(i, rnd);
}
}
void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
Random rnd = e.UserState as Random;
...
Mark Salsbery
Microsoft MVP - Visual C++
modified on Monday, June 29, 2009 3:12 PM
|
|
|
|
|
Somehow, it seems to me, that the DoWork method should do the work and that the ProgressChanged method should update the progressBar. Unfortunately this doesn't work, I get an error message at runtime.
public void bw_DoWork(object sender, DoWorkEventArgs e)
{
Random rnd = new Random();
Pen p = new Pen();
byte red, green, blue;
Line line = new Line();
for (int i = 0; i < 100; i++)
{
SolidColorBrush brush = new SolidColorBrush();
red = (byte)rnd.Next(0, 255);
green = (byte)rnd.Next(0, 255);
blue = (byte)rnd.Next(0, 255);
Color col = new Color();
col.R = red;
col.G = green;
col.B = blue;
col.A = 255;
brush.Color = col;
line.X2 = rnd.Next(0, (int)canvas1.ActualWidth);
line.Y2 = rnd.Next(0, (int)canvas1.ActualHeight);
line.X1 = rnd.Next(0, (int)canvas1.ActualWidth);
line.Y1 = rnd.Next(0, (int)canvas1.ActualHeight);
line.Stroke = brush;
line.StrokeThickness = 1.0;
canvas1.Children.Add(line);
bw.ReportProgress(i);
}
}
public void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressbar1.Value = e.ProgressPercentage;
}
When I tried this, I got an exception in the line: Line line = new Line(); because the thread doesn't have enough resources it should be a STA Thread, which means that this method uses up so much capacity that it needs to be the only Thread running.
I am new to this. I never made a program that used more than one thread, I tried but didn't succeed.
If anybody has any pointers for me, I would appreciate it.
Ranger.
modified on Monday, June 29, 2009 3:44 PM
|
|
|
|
|
Ranger49 wrote: should the code to compute the fractal be put in the DoWork method, where the progressbar is in the ProgressChanged method?
Yes.
My example was over-simplified, and putting the code to create the
lines in the ProgressChaged event handler was out of necessity. I did that
because creating lines in the BackgroundWorker thread throws an exception
because the BackroundWorker thread is an MTA model thread and creating WPF elements
needs to be on a STA model thread. Additionally, even if you create the lines in
a STA thread, you can't add them to the canvas because you can only access UI elements
on the UI thread, and a line created on a background thread can't be added to a
canvas created on the UI thread. Catch-22?
Anyway, you'd want to do as much of the calculation as you can on the background thread
(i.e. in the DoWork handler) and you have to do the UI stuff on the UI thread (the
BackgroundWorker.ProgressChanged event occurs on the UI thread).
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I will read chapters about Threading in the books I use to learn about WPF and C# 2008.
This matter is really tricky, but that this is a challenge at the same time.
I reckon it isn't possible to turn the DoWork method into the UI Thread and the ProgressChanged in the backgroundworker Thread?
But I find this really interesting.
Thanks,
Ranger.
|
|
|
|
|
The issue here is that you are trying to update the line in a none-UI thread. You have two choices; put the UI work in the progress changed event, or invoke changes to force them onto the UI thread. If it was my choice, I'd do the UI stuff in the event.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|