Adding a DatePicker with the following code, I can scroll the year but not the Day or Month. Any ideas?
datePicker = new UIDatePicker(pickerRect);
datePicker.Mode = UIDatePickerMode.Date;
datePicker.SetDate(appDelegate.store.builderPlan.p_startDateTime, true);
datePicker.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
datePicker.ValueChanged += delegate(object sender, EventArgs e) {
SetDate();
};
this.AddSubview(datePicker);
Thanks,
Rick
The picker was hanging outside the view, so no events passed to the view...
Related
I'm using a primefaces schedule component in my aplication and i've detected a strange behaviour. When I select an event and push the "save button" the hour is reset to 12am. After much time investigating, turned to the Primefaces Showcase page for more info.
In the Showcase, schedule behaviour is the same. In the Schedule Editable Example http://www.primefaces.org/showcase/ui/data/schedule.xhtml, for example, select the event with the title "Champions League Match", which date is 28/04/2015 and the hour is from 8:00 to 11:00 and push save button. It automatically changes the hour to 12am. Is it the normal behaviour?????
Thanks.
EDITED: I'll add the code that i have in my aplication, that is the same or very similar to the showcase.
Creation of the event:
eventModel.addEvent(new DefaultScheduleEvent("Champions League Match", previousDay8Pm(), previousDay11Pm()));
Methods to set time frame:
private Date previousDay8Pm() {
Calendar t = (Calendar) today().clone();
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.DATE, t.get(Calendar.DATE) - 1);
t.set(Calendar.HOUR, 8);
return t.getTime();
}
private Date previousDay11Pm() {
Calendar t = (Calendar) today().clone();
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.DATE, t.get(Calendar.DATE) - 1);
t.set(Calendar.HOUR, 11);
return t.getTime();
}
Add method which is invoked when push "Save" button (only i'm trying to change event background to red, with setStyleClass):
public void addEvent(ActionEvent actionEvent) {
event.setStyleClass("emp1");
eventModel.updateEvent(event);
event = new DefaultScheduleEvent();
}
Because its just an example.
Add input text with time selector and add event on specific, While creating an event specify time frame like:
eventModel.addEvent(new DefaultScheduleEvent("Birthday Party", today1Pm(),todat6Pm());
where
private Date today1Pm() {
Calendar t = (Calendar) today().clone();
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.HOUR, 1);
return t.getTime();
}
private Date today6Pm() {
Calendar t = (Calendar) today().clone();
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.HOUR, 6);
return t.getTime();
}
As for showcase yes you need some update to achieve it :)
Behavior of showcase, if you do not define any time frame and not set AllDay check event is added like eventModel.addEvent(event); which set default time to 12am and Yes it is normal!
Update
Use this method for add new event, startTime/endTime is your field which is set by form. I also paste the default constructor signature with snippet.
public void addEvent(ActionEvent actionEvent) {
if(event.getId() == null)
//DefaultScheduleEvent(String title, Date start, Date end, String styleClass) ;
eventModel.addEvent(new DefaultScheduleEvent(actionEvent.Title(), calculateTime(startTime), calculateTime(endTime),"emp1"));
else
eventModel.updateEvent(event);
}
Ok, I'm a noob so go easy on me.
I have created an app in WPF using c#.
Of the many functions I have made one is a textbox that shows a countdown from 1:0:0 to 0.
This has a start/reset, play/pause, +30sec, -30 sec buttons attached.
They all work perfectly. However, I need the output showing from that particular textbox to show in a secondary window I have created in either another or duplicated textbox.
Is this even possible?
Thanks
public void CountDownTimer()
{
_timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
{
// _time = TimeSpan.FromMinutes(60);
ShowTimer.Text = _time.ToString("c");
if (_time == TimeSpan.Zero) _timer.Stop();
_time = _time.Add(TimeSpan.FromSeconds(-1));
}, Application.Current.Dispatcher);
}
//STARTS TIMER FROM 1HOUR ALSO RESETS
private void StartButton_Click(object sender, RoutedEventArgs e)
{
_time = TimeSpan.FromMinutes(60);
_timer.Start();
}
//PAUSES AND COMMENCES TIMER NOTE: THIS DOES NOT RESET THE TIMER
private void PauseButton_Click(object sender, RoutedEventArgs e)
{
if (_timer.IsEnabled)
{
_timer.Stop();
}
else _timer.Start();
}
I know you're aware that there's bad practice here, so I won't chew you out for that. :D
The easiest way to achieve what you want is to have the secondary window as a member of the first window, then change your DispatchTimer's callback to
_timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
{
// _time = TimeSpan.FromMinutes(60);
ShowTimer.Text = _time.ToString("c");
if (_time == TimeSpan.Zero) _timer.Stop();
_time = _time.Add(TimeSpan.FromSeconds(-1));
secondaryWindow.TextBoxTimer = _time;
}, Application.Current.Dispatcher);
It depends on where and how you instantiate your secondary window, and if the first window has reference to it. You might also consider raising an event when the timer changes, and subscribing the secondary window to that event with a handler that updates the textbox. Better yet, don't use controls like TextBox as a variable, but bind them to a property in another class. That's a step towards MVVM.
I have tried this solution and it works beautifully FolderBrowserDialogEx
but now I have to add another button which will be placed next to editbox and upon clicking will show a particular folder always. I have tried this so far.
In the constructor:
btnDefault = new Button();
btnDefault.Text = "Default";
btnDefault.Enabled = true;
btnDefault.Click +=new EventHandler(btnDefault_Click);
on click
private void btnDefault_Click(object sender, EventArgs e)
{
_selectedPath = #"C:\ProgramData";
}
How do I add new Button? Full code is available HERE
Thank you for any help.
I am creating an application using lwuit. And i want to add calendar in comboBox. please give me an idea as soon as possible..
Do u mean that you want to add the selected date of calendar component at the end of combobox values or to show the selected date in textbox?
If so, then below code shows the selected date of calendar component in textbox:
Button cal = new Button("Calendar"); // button for calendar
cal.addActionListener(new ActionListener() { // define action for button
// action listener to show the calendar container
public void actionPerformed(ActionEvent ae) {
final Form calFrame = new Form();
final Calendar cal = new Calendar();
calFrame.setScrollable(true);
calFrame.setSmoothScrolling(true);
calFrame.setIsScrollVisible(true);
cal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
txtDate.setText(cal.getDate()); // textfield in which date should be set
mainForm.showBack(); // main form to show back after calender disappears
}
});
calFrame.addComponent(cal);
calFrame.show();
}
});
mainForm.addComponent(calButton); // add calendar button to main form
this code will add one calendar button to your main form and will display the selected date in textfield (here named txtDate).
If you want to add date in combo values, you can add the selected date in the vector or list of the combo component's vector.
If this is not what you want, kindly briefly explain what you want actually to do.
I have a user control
public partial class ButtonControl : UserControl
which has two controls of label and picturebox
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.text = new System.Windows.Forms.Label();
I have used this control in a windows form
this.appointmentButton = new DentalSoft.UI.Controls.ButtonControl();
created an event
this.appointmentButton.Click += new System.EventHandler(this.appointmentButton_Click);
but the problem is, if i click on the image or the label inside of the control, the click event doesn't fire.
I want to fire this click event no matter where the user clicks inside of the control. Is it possible?
Yes it is a simple matter. When you click on the child controls they receive the click event and the user control does not. So you can subscribe to the child control click events and when they occur simply raise the usercontrol click event and it will appear to click no matter where the mouse is positioned.
Just double click on the picturebox and the label to create the click event handlers then add a line of code to call the parent usercontrol OnClick method.
private void text_Click(object sender, EventArgs e)
{
this.OnClick(new EventArgs());
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.OnClick(new EventArgs());
}
I solved this problem the following way. I wanted to changes the background images of the parent PictureBox when the child Label was clicked. I played around some and found I could call the event handler in the following way.
private void Label_Click(object sender, EventArgs e)
{
Label label = (Label)sender;
Box_Click(label.Parent, e);
}
private void Box_Click(object sender, EventArgs e)
{
//
PictureBox box = sender as PictureBox;
//
if (isMine[int.Parse(box.Name)])
{
box.Image = Image.FromFile(#"..\..\images\BoxRedX.jpg");
MessageBox.Show("Game Over");
}
else
{
box.Image = Image.FromFile(#"..\..\images\BoxGray.jpg");
}
}
As you can see I grab the Child and using it to reference its parent and send it to the parents click event. This is the code I used to work in my project. The important method is the first on listed. The second is there for clarity to see how it passed and worked.