Prob with a time picker and date picker in android - show-hide

I have a CheckBox in my app which sets the visibility of the TimePicker and the DatePicker!
The code looks something like this
public void onCheckBClicked(View v) {
boolean checked = ((CheckBox) v).isChecked();
if(checked==false)
{
mDateButton.setVisibility(View.INVISIBLE);
mTimeButton.setVisibility(View.INVISIBLE);
}
else
{
mDateButton.setVisibility(View.VISIBLE);
mTimeButton.setVisibility(View.VISIBLE);
}
}
This works perfectly fine! But the prob is, The time and date are by default set to the time and date on my phone! I want blank values on the TimePicker and DatePicker! How can I do that??

Related

Can a TorndaoFx tableview column have a datepicker as the input method?

I've got a tableview with a column that binds to a SimpleObjectProperty (LocalDate) variable:
tableview(Model) {
column("DATE",Model::date).makeEditable()
...
}
I would like to make it a date picker to allow easy access for the user, something like the following:
tableview(Model) {
column("DATE",Model::date).makeEditable().datepicker()
...
}
Although I'm not sure what the right syntax is, any help would be appreciated!
If your domain object has an id, you can create a cached cell with a datepicker in it like this:
column("DATE", Model::dateProperty) {
cellFormat {
graphic = cache(rowItem.id) {
datepicker(rowItem.dateProperty)
}
}
}
You can also do this without the use of a cache, but performance won't be great for big datasets.

How to add event in FSCalendar in Xamarin.iOS

I am using FSCalendar for application purpose. The FSCalendar demo is below.
https://github.com/MarcBruins/FSCalendar-Xamarin-iOS
I try to search on SO and Google from 2 days. But I coundn't find a way to how to add event in FSCalendar.
It would pleasure if someone use this and help me to how to add event in FSCalendar.
Any Help be Appreciated.
Edit :
look this Image
When I click on Date 15 the event of the Date 15 is show below the calender. Hey Daily Event place. I Hope now you understand.
Events in FSCalendar are supplied via a DataSource, much like other datasource-based controls (i.e.UITableView).
This example subclasses FSCalendarDataSource and added a hard-coded list of event dates (normally you would set/retrieve those via SQLite, Realm, etc...)
public class CalendarDataSource : FSCalendarDataSource
{
NSCalendarUnit calenderUnits = NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day;
NSCalendar calendar = new NSCalendar(NSCalendarType.Gregorian);
List<NSDate> events;
public CalendarDataSource()
{
events = new List<NSDate>();
events.Add(NSDate.Now);
events.Add(calendar.DateByAddingUnit(NSCalendarUnit.Day, 3, NSDate.Now, NSCalendarOptions.None));
events.Add(calendar.DateByAddingUnit(NSCalendarUnit.Day, 5, NSDate.Now, NSCalendarOptions.None));
events.Add(calendar.DateByAddingUnit(NSCalendarUnit.Day, 7, NSDate.Now, NSCalendarOptions.None));
events.Add(calendar.DateByAddingUnit(NSCalendarUnit.Day, 9, NSDate.Now, NSCalendarOptions.None));
}
bool SameDate(NSDate date1, NSDate date2)
{
return NSComparisonResult.Same == calendar.CompareDate(date1, date2, calenderUnits);
}
[Export("calendar:hasEventForDate:")]
public override bool HasEventForDate(FSCalendar calendar, NSDate date)
{
return events.Any((NSDate eventDate) => (SameDate(eventDate, date)));
}
public override nint NumberOfEventsForDate(FSCalendar calendar, NSDate date)
{
return events.Any((NSDate eventDate) => (SameDate(eventDate, date))) ? 1 : 0;
}
}
Then instance the datasource and assign it to your calendar instance:
calender = new FSCalendar
{
Frame = View.Frame,
DataSource = new CalendarDataSource()
};

make textbox value to datetime

Maybe this is to simple. If I have a textbox where I want to input a numeric value like "1300" and make it to display like datetime like this "13:00".
So what you should see is only 13:00 but it's also the days date.
anyone understand my question?
May be you need to use Day or Time Picker. This is most common way for Windows Phone to display date and time.
Check also Making a DateTimePicker
and Windows Phone 7 - DatePicker and TimePicker
But if you want to use only TextBox, you need to handled TextBox.LostFocus=OnLostFocus
private void OnLostFocus(object sender, RoutedEventArgs e)
{
//here change text of TextBox however you want.
}
UPD
If you want to place current time to TextBox as default value you can to use
tb.Text = DateTime.Now.ToShortTimeString();
when you arrive to current page or when TextBox.GotFocus=OnGotFocus
private void OnGotFocus(object sender, RoutedEventArgs e)
{
tb.Text = DateTime.Now.ToShortTimeString();
}
UPD2
When in TextBox you have value (for example 1300) you need to parse it and get newHours hours and newMinutes minutes. Then
var today = DateTime.Now;
var newDate = new DateTime(today.Year, today.Month, today.Day, newHours, newMinutes, 0);

Automated control of a Telerik RadDatePicker

I'm using WatIn to create an automated test for a Web App that uses Telerik controls: my first challenge is to drive a Telerik date control - a RadDatePicker.
Simply entering the text in the likeliest input field doesn't work: the value is reset to blank as the form is posted. So I imagine I need a more complex set of automated interactions -- for example, I found this thread on the Telerik site discussing how to automated a selection from a Telerik combo box.
Can anyone supply the magic combination of interactions I need?
(I'm sure that the answer would help anyone using any automated test tool, hence I've also flagged this question with a couple of other test frameworks too :-))
I'm using Selenium RC and had a similar problem few days ago. It took me ages to find the right way of doing it so I thought I will share the solution that worked for me:
(NOTE: I couldn't use $find)
The javascript to set the date on the RadDatePicker is:
var appBrowser = this.browserbot.getCurrentWindow();
var datepicker = appBrowser.yourDatePickerId; //note: no quotes
var selectDate=new Date();
selectDate.setFullYear(yourYear,yourMonth,yourDay);
datepicker.SetDate(selectDate);
datepicker.DateInput.SetDate(selectDate);
and then use selenium GetEval in your test to call javascript code to set the date:
selenium.GetEval("javascript here");
You should definitely wrap it around some parametrised helper class that will generate the javascript code for you each time you want to set the date in the test by passing id of the control and date.
I finally have a solution that works. The key is to use javascript to call the client-side API for the telerik control. The same technique is required for all complex Telerik controls, e.g. RadInput.
I used the technique recommended on the WatiN website for writing your own control http://watinandmore.blogspot.com/2009/12/wrapping-complex-logic-in-control.html to come up with this:
public class TelerikDatePicker : Control<TextField>
{
public DateTime? Value
{
get
{
var jScript = string.Format(#"$find(""{0}"").get_selectedDate();", Element.Id);
var selectedDateStr = Eval(jScript);
return TranslateJavascriptDateStringIntoDateTime(selectedDateStr);
}
set
{
var jScript = string.Format(#"$find(""{0}"").set_selectedDate(new Date(""{1:MMMM dd,yyyy}""));", Element.Id, value);
Eval(jScript);
}
}
public void SetValue(DateTime? value)
{
if (value.HasValue)
Value = value.Value;
else
Clear();
}
public void Clear()
{
var jScript = string.Format(#"$find(""{0}"").clear();", Element.Id);
Eval(jScript);
}
private string Eval(string script)
{
return Element.DomContainer.Eval(script);
}
public bool IsEnabled()
{
var jScript = string.Format(#"$find(""{0}"").get_enabled();", Element.Id);
return Eval(jScript) == "true";
}
private DateTime? TranslateJavascriptDateStringIntoDateTime(string jsDateStr /*E.g. Mon Mar 12 00:00:00 UTC+0100 2012*/)
{
if (String.IsNullOrEmpty(jsDateStr) || jsDateStr == "null") return null;
var abbreviatedMonth = jsDateStr.Substring(4, 3);
var dayOfTheMonth = jsDateStr.Substring(8, 2).TrimEnd(' ');
var year = jsDateStr.Substring(jsDateStr.Length-4, 4);
const string format = "d MMM yyyy";
var dateStr = dayOfTheMonth + " " + abbreviatedMonth + " " + year;
return DateTime.ParseExact(dateStr, format, CultureInfo.InvariantCulture);
}
}
I had the same issue with a RadDatePicker that would post back empty after typing in values.
I managed to automate typing in the date into the input field with these steps:
Select the dateInput text box associated with the control.
Do a dateInput.MouseClick() on it
Type the date into the field Manager.Desktop.KeyBoard.TypeText("1/1/1990")
Do a .MouseClick() on any other element on the page, e.g. some div
I found that #4 was needed to fire the events to make the control blur therefore "saving" its value.
Then you can submit and the value should go along with it.
Solved that problem for SeleniumIDE - you have to use "fireEvent" method with value "blur" for "ControlID" after you've set value using "sendKeys" or "type" methods. Strange that this problem does not occur when automating with WebDriver.

Value of Column Name DataGridView

I'm using Visual Studio 2010 and i'm developing a windows form. Right now I'm using a data grid view and i want to write some functions that would allow you to automaticlly edit the datagrid by just changing the text in the Datagrid view. Right now, I am able to get the actual value but I need the value of the column in order to use it as a parameter when i use ADO.net here's what my code looks like now
private void dgv_DataLookup_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
DialogResult dr;
dr = MessageBox.Show("Are you sure you want to edit this field?", "Edit Cell", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
DataGridViewCell editItemCell = dgv_DataLookup[dgv_DataLookup.CurrentCell.RowIndex, dgv_DataLookup.CurrentCell.ColumnIndex];
string editItem = editItemCell.Value.ToString();
}
}
this here gets me the value of the current cell that is currently selected. I tried doing something like this
DataGridViewColumns columnCells = dgv_DataLookup.CurrentCell.ColumnIndex.Value.ToString()... something that would represent this but actual code. thanks!
According to what I understand you want to edit the value within a field, you can choose the value in this way.
private void button2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure you want to edit this field?",Application.ProductName.ToString(),MessageBoxButtons.YesNo)== DialogResult.Yes)
{
string editItem = this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells["NameField"].Value.ToString();
}
}
Bye

Resources