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()
};
Related
How to get all data present in my Calendar using Xamarin. I am using below code and It is only returning already present holidays list. I want to get the manually added events and reminder list also.Below is the code am using
var calendarsUri = CalendarContract.Events.ContentUri;
var cursor = Forms.Context.ContentResolver.Query(calendarsUri, null, null, null, null);
if (cursor.MoveToFirst())
{
do
{
calendarEventList.Add(new Calendar()
{
Id = cursor.GetString(cursor.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.Id)),
CalendarDisplayName = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName)),
AccountName = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Calendars.InterfaceConsts.AccountType)),
Title = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Title)),
Description = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Description)),
Dtstart = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtstart)),
Dtend = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtend))
});
} while (cursor.MoveToNext());
}
So my 'calendarEventList' contains only the holidays event. Can anyone help me with getting all the events from my Calendar.
Thank in Advance.
I am attempting to integrate this library with my RxSwift project, https://github.com/glenyi/FloatRatingView
I am unable to get the updated rating.
Here is how I have created the FloatRatingView in the Controller,
let starRater : FloatRatingView = {
let floatRatingView = FloatRatingView()
floatRatingView.emptyImage = UIImage(named: "EmptyStar")
return floatRatingView
}()
The Model contains the following,
let my_rating = Variable<Float?>(nil)
What I want to be able to do is to update the value in the my_rating variable when a user changes the rating by tapping on a star. Here is what I've written for this,
_ = starRater.rx.rating
.asObservable()
.bindTo(viewModel.my_rating.rx_value)
But here is the error I'm receiving.
Value of type 'Reactive FloatRatingView' has no member 'rating'
Here is how I will retrieve the value from my_rating variable,
let stars = self.my_rating.value
Kindly help me out. Thanks.
You need to add a bindable sink for the property, it would be something like this:
extension Reactive where Base: FloatRatingView {
/// Bindable sink for `rating` property
public var progress: UIBindingObserver<Base, Float> {
return UIBindingObserver(UIElement: self.base) { floatRatingView, rating in
floatRatingView.rating = rating
}
}
}
I need to write a global javascript code that calculates age by birthday field and call the function from a diffrent javascript file to the specific entity.
from some reason i get error message "CalculateAge is undefined" after i loaded my entity javascript file to the form.
This is what i write in the global file:
CalculateAge: function (birthd)
{
if (birthd == null) {
return;}
var today = new Date().getFullYear();
year1 = birthd.getFullYear();
return (today-year1);
}
This is what i write in my entity file that i am loading to the form:
function onLoad() {
var birthDate = Xrm.Page.getAttribute("el_birth_date").getValue();
Xrm.Page.getAttribute("el_age").setValue(CalculateAge(birthDate));
}
I am new in Javascript.. Can ypu please help?
The JavaScript code you are using to calculate the age is not correct, it doesn't consider the month and the day.
A correct version is this one:
function CalculateAge(birthday, ondate) {
// if ondate is not specified consider today's date
if (ondate == null) { ondate = new Date(); }
// if the supplied date is before the birthday returns 0
if (ondate < birthday) { return 0; }
var age = ondate.getFullYear() - birthday.getFullYear();
if (birthday.getMonth() > ondate.getMonth() || (birthday.getMonth() == ondate.getMonth() && birthday.getDate() > ondate.getDate())) { age--; }
return age;
}
and can be used as:
var birthday = Xrm.Page.getAttribute("new_birthday").getValue();
var age = CalculateAge(birthday);
alert(age);
// age on 1st January 2000, JavaScript Date() object contains months starting from 0
var testdate = new Date(2000, 0, 1, 0, 0, 0);
var testage = CalculateAge(birthday,testdate);
alert(testage);
If you get CalculateAge is not defined, probably you didn't include the webresource containing your function inside the form. If you have two JS web resources (one containing the function, the other one containing the onLoad event) both need to be included inside the form.
If you are in a CRM version that has the issue of the asynchronous javascript loading, it's better to include the CalculateAge function in the same file as the onLoad event, but if you prefer keep them separate check this blog post: Asynchronous loading of JavaScript Web Resources after U12/POLARIS
The JavaScript function comes from my blog post: Calculate age in Microsoft Dynamics CRM 2011
guys!
I have a small issue with LINQ (Im total beginer in this topic). Maybe it is some desing mistake, but let you decide it.
I'm coding a Windows Store App, which is kind a calendar. It has a Day object. Because of the semantic zoom (and some groupping hack), I put this Day into a wrapper class, named as Month.
After loading all data, and after getting the current data, I want to extract from this structure the current Day object.
Here is the important code:
public class Day
{
public int nr { get; set; }
...
}
public class Month
{
public string Title {get;set;}
public List<Day> Days{get;set;}
}
Later I have this:
List<Month> Months;
It is correctly filled with lists of days. Now comes the tricky part:
Day Today = Months.Find( ??? )
I had some idea, but none of them was statisfying...
So, the question is:
How can I select an item from a multiple list hierarchy in LINQ?
(List<List<Day>>, and one condition must met in each list (Day.nr and Month.nr))
Create an Enum for every month:
public enum NamesOfMonths
{
January = 1,
February = 2,
// so on and so forth
}
Now, you can use it to find the correct Month, and eventually the correct Day.
var dayToday = DateTime.Now.Day;
var monthToday = DateTime.Now.Month;
Day Today = Months.Find(m => m.Title.Equals(((NamesOfMonths)monthToday).ToString()))
.Days.Where(d => d.Nr == dayToday).FirstOrDefault();
I think you're looking for SelectMany:
var days = months.SelectMany(m => m.Days); // Gets all the days in those months
var today = days.Where(d => /* some condition goes here */);
I use Telerik demo scheduler as my base, as it seen in http://www.telerik.com/community/forums/wpf/scheduler/uniqueid-property-how-to-access-it.aspx
So i have implemented data loading from SQL to this scheduler. Now I want to implement drag and drop. So, how can I get my appointment values in old place and values in new place on scheduler and what the best technique to do that? I would use these values, to implement update of appointment dates in SQL.
private void OnAppointmentEdited(object sender, AppointmentEditedEventArgs e)
{
Appointment eAppo = e.Appointment as Appointment;
SessionAppointment ses = e.Appointment as SessionAppointment;
if(eAppo != null && ses != null)
{
DateTime dateStart = eAppo.Start; //new datestart
DateTime dateEnd = eAppo.End;//new dateend
string id = ses.UniqueId;//id
}
}