TimePicker Minimum value Silverlight - silverlight

I wan't to use a TimePicker but setting to it a minimum posible value, that the user can't choose other after that value.
Like the DisplayDateStart in DatePicker.

You can use Minimum and Maximum properties of TimePicker Control in silverlight to limit the times displayed in drop down menu.
startTime.Maximum = endTime;
endTime.Minimum = startTime;
here startTime and endTime are two timepickers

In datefield using throw the BlackoutDates
MonthlyDatePicker.DisplayDate = new DateTime(2009, 5, 1);
MonthlyDatePicker.DisplayDateStart = new DateTime(2009, 1, 1);
MonthlyDatePicker.DisplayDateEnd = new DateTime(2009, 1, 31);
or
MonthlyDatePicker.BlackoutDates.Add(new DatePickerDateRange(
new DateTime(2009, 1, 1),
new DateTime(2009, 1, 4)
));
i think i hope its helps to you

Related

textArea growByContent doesnt work in layer layout

I used layer layout to keep the title ie textArea on top of button image. But i cannot grow textArea size. Also the padding and margin on the textArea is not working as well.
Image btnIcon = URLImage.createToStorage(placeholder, "homeIcon" + imageUrl, allUrl.globalHomeImageUrl + imageUrl, URLImage.RESIZE_SCALE);
int width = placeholder.getWidth();
int height = placeholder.getHeight();
homeButton.setPreferredSize(new Dimension(width, height));
homeButton.getAllStyles().setBgImage(btnIcon);
TextArea buttonTitle = new TextArea(title);
buttonTitle.setRows(1);
buttonTitle.setUIID("smallLabel");
buttonTitle.getAllStyles().setPadding(0, 0, 0, 0);
buttonTitle.getAllStyles().setMargin(0, 4, 0, 4);
buttonTitle.setPreferredW(screenWidth / 3 - 30);
buttonTitle.setEditable(false);
buttonTitle.setGrowByContent(true);
buttonTitle.setIsScrollVisible(false);
buttonTitle.setGrowLimit(2);
Container container1 = new Container();
container1.setUIID("buttonTitleContainer");
container1.getAllStyles().setMargin(0, 5, 0, 0);
container1.getAllStyles().setBgTransparency(0);
container1.add(LayeredLayout.encloseIn(homeButton, FlowLayout.encloseRightBottom(buttonTitle)));
middleContainer.addComponent(BorderLayout.CENTER, container1);
How can i grow the textArea row as required and set the padding margin of the textarea.
Update:
i commented setPreferredW() and added calcPreferredSize() to set the dimension but how can i set the height dynamically??
TextArea buttonTitle = new TextArea(title){
#Override
protected Dimension calcPreferredSize() {
Dimension d = new Dimension(screenWidth/3-10, 40);
return d; //To change body of generated methods, choose Tools | Templates.
}
};
buttonTitle.setUIID("smallLabel");
buttonTitle.getAllStyles().setAlignment(Label.LEFT);
buttonTitle.setRows(1);
buttonTitle.getAllStyles().setPadding(0, 0, 0, 0);
buttonTitle.getAllStyles().setMargin(0, 0, 0, 4);
// buttonTitle.setPreferredW(screenWidth / 3 - 30);
buttonTitle.setEditable(false);
buttonTitle.setGrowByContent(true);
buttonTitle.setIsScrollVisible(false);
buttonTitle.setGrowLimit(2);
buttonTitle.setScrollVisible(false);
the design is somewhat like below:
Current screenshot:
As you can see, there is only one word displayed and the textArea always has only 1 row and doesnt grow
The problem isn't in the LayeredLayout it's due to the fact that you called the deprecated setPreferredW.
Notice that setPreferredW also limits the height.

Setting date range in DynamicTimeSeriesCollection horizontal axis

I am now working on a DynamicTimeSeriesCollection chart which display energy value in Y-axis, and X-axis should be date.
private final Second time = new Second();
private final DynamicTimeSeriesCollection dataset = new DynamicTimeSeriesCollection(1, 180, time);
The JFreeChart display a tick every 1/2 second automatically as the following example!
00:13:00
00:13:30
00:14:00
00:14:30
How can I change them by my customized value as:
00:13:00---> 01-Jan-2011
00:13:30---> 02-Jan-2011
00:14:00---> 03-Jan-2011
00:14:30---> 04-Jan-2011
(1 default second = 2 days in my case).
I can't find any solution, could any one help?
OK. Finally i resolved my question by using TimeSeries. We can create a dataset as we need:
TimeSeries s1 = new TimeSeries("L&G European Index Trust");
s1.add(new Day(1, 1, 2001), 181.8);
s1.add(new Day(3, 1, 2001), 181.8);
s1.add(new Day(5, 1, 2001), 167.3);
s1.add(new Day(7, 1, 2001), 153.8);
In TimeSeries we can control dataset, i means value and date better than DynamicTimeSeriesCollection.

How to add calendar item using MonoDroid?

I'm trying to add an event to a calendar on an android device, and I'm using MonoDroid. I found the following example in Java: http://www.androidcookbook.com/Recipe.seam?recipeId=3852
I tried to translate the first code snippet to C#, but I have trouble setting the "beginTime" and "endTime" fields, especially translating from Calendar.getTimeInMillis() to System.DateTime. This is my code:
DateTime epoch = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
TimeSpan startSpan = fromDate - epoch;
TimeSpan endSpan = toDate - epoch;
Intent intent = new Intent(Intent.ActionEdit);
intent.SetType("vnd.android.cursor.item/event");
intent.PutExtra("beginTime", startSpan.TotalMilliseconds);
intent.PutExtra("endTime", endSpan.TotalMilliseconds);
The result is that the from and to fields are filled with today's date and a time slot with length of one hour.
How do I correctly set begin/end time of the event?
I have used a helper method in the past that has worked out pretty well. Here is a quick sample that should set the date and time properly.
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
AddEvent(this, "Sample Event", DateTime.UtcNow, DateTime.UtcNow.AddHours(5));
}
public void AddEvent(Context ctx, String title, DateTime start, DateTime end)
{
var intent = new Intent(Intent.ActionEdit);
intent.SetType("vnd.android.cursor.item/event");
intent.PutExtra("title", title);
intent.PutExtra("beginTime", TimeInMillis(start));
intent.PutExtra("endTime", TimeInMillis(end));
intent.PutExtra("allDay", false);
ctx.StartActivity(intent);
}
private readonly static DateTime jan1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private static Int64 TimeInMillis(DateTime dateTime)
{
return (Int64)(dateTime - jan1970).TotalMilliseconds;
}

WPF thickness keyframe not working

I used to animate my border with a from to animation but now I wanted to add a thicknesskeyframe to make it look better. I'm using .net 4.0 and vb.
Dim t As New ThicknessAnimationUsingKeyFrames()
t.RepeatBehavior = RepeatBehavior.Forever
Dim instance As ThicknessKeyFrame
instance.Value = New Thickness(0, 0, 0, 0)
instance.KeyTime = TimeSpan.FromSeconds(0.0)
t.KeyFrames.Add(instance)
Dim instance2 As ThicknessKeyFrame
instance2.Value = New Thickness(1, 1, 1, 1)
instance2.KeyTime = TimeSpan.FromSeconds(0.5)
t.KeyFrames.Add(instance)
I can't instantiate the thickness keyframe I think it's an interface but I don't know how to use it in this context.
fistly, you need to instantiate your instances
Dim instance As New DiscreteThicknessKeyFrame()
the bottom line is incorrect:
t.KeyFrames.Add(instance)
it should be
t.KeyFrames.Add(instance2)

How to Play a section of the WPFmediaElement

I need to play a section of the Mediaelement for example from the second 0:45 to 0:55 sec
I tried using the mediaelement position property here is the code
Dim mytimeline As New MediaTimeline
Dim mc As MediaClock
FReveal1.Visibility = Windows.Visibility.Visible
FReveal1.Source = New Uri("videos\Front-Game-Answer-Reveals.wmv", UriKind.Relative)
FReveal1.Position = New TimeSpan(0, 0, 4)
mytimeline.Source = FReveal1.Source
mytimeline.Duration = (TimeSpan.FromMilliseconds(5000))
mc = myTimeLine.CreateClock()
FReveal1.Clock = mc
FReveal1.Play()
But I get the following error : "Cannot perform this operation while a clock is assigned to the media player."
Is there another way to do this ?
Thanks
Would something like this work?
var StartTime = new TimeSpan(0, 0, 45);
var EndTime = new TimeSpan(0, 0, 55);
theMediaElement.Position = StartTime;
theMediaElement.Play();
while (theMediaElement.Position != EndTime)
{
// chill and let it play
}
theMediaElement.Stop();
EDIT: I should probably add that this is a bit cowboy.

Resources