public override void GetCurrentTimelineEntry(CLKComplication complication, Action <CLKComplicationTimelineEntry> handler) { // Call the handler with the current timeline entry System.Diagnostics.Debug.WriteLine("GetCurrentTimelineEntry"); CLKComplicationTimelineEntry entry = null; try { var minutesPastHour = DateTime.Now.Minute.ToString(); if (complication.Family == CLKComplicationFamily.ModularSmall) { var textTemplate1 = new CLKComplicationTemplateModularSmallSimpleText(); textTemplate1.TextProvider = CLKSimpleTextProvider.FromText("OWCE"); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate1); } else if (complication.Family == CLKComplicationFamily.GraphicCircular) { var graphicTemplate = new CLKComplicationTemplateGraphicCircularImage(); graphicTemplate.ImageProvider = new CLKFullColorImageProvider(UIImage.FromBundle("OWCELogo")); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, graphicTemplate); } } catch (Exception x) { System.Diagnostics.Debug.WriteLine("Exception " + x); } handler(entry); }
public override void GetCurrentTimelineEntry(CLKComplication complication, Action <CLKComplicationTimelineEntry> handler) { Console.WriteLine("GetCurrentTimelineEntry"); CLKComplicationTimelineEntry entry = null; try { var txt = DateTime.Now.Minute.ToString(); if (complication.Family == CLKComplicationFamily.ModularSmall) { var textTemplate1 = new CLKComplicationTemplateModularSmallSimpleText(); textTemplate1.TextProvider = CLKSimpleTextProvider.FromText(txt); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate1); } else if (complication.Family == CLKComplicationFamily.ModularLarge) { var textTemplate = new CLKComplicationTemplateModularLargeStandardBody(); textTemplate.HeaderTextProvider = CLKSimpleTextProvider.FromText("Header" + txt, "XH", "```"); textTemplate.Body1TextProvider = CLKSimpleTextProvider.FromText("B1 " + txt, "X1", "~~~"); textTemplate.Body2TextProvider = CLKSimpleTextProvider.FromText("Body 2x", "X2", "---"); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate); } else if (complication.Family == CLKComplicationFamily.UtilitarianSmall) { var textTemplate = new CLKComplicationTemplateUtilitarianSmallFlat(); textTemplate.TextProvider = CLKSimpleTextProvider.FromText("2Xam"); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate); } else if (complication.Family == CLKComplicationFamily.UtilitarianLarge) { var textTemplate = new CLKComplicationTemplateUtilitarianLargeFlat(); textTemplate.TextProvider = CLKSimpleTextProvider.FromText("3Xam"); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate); } else if (complication.Family == CLKComplicationFamily.CircularSmall) { var imgTemplate = new CLKComplicationTemplateCircularSmallRingImage(); imgTemplate.ImageProvider = CLKImageProvider.Create(UIImage.FromBundle("Circular")); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, imgTemplate); } else { Console.WriteLine("GetCurrentTimelineEntry: Complication not supported (" + complication.Family + ")"); } } catch (Exception x) { Console.WriteLine("Exception " + x); } handler(entry); }
private CLKComplicationTimelineEntry CreateComplicationEntry(CLKComplicationFamily complicationFamily, string complicationText) { var template = CreateComplicationTemplate(complicationFamily, complicationText); if (template != null) { return(CLKComplicationTimelineEntry.Create(NSDate.Now, template)); } else { return(null); } }
public override void GetCurrentTimelineEntry(CLKComplication complication, Action <CLKComplicationTimelineEntry> handler) { // var entry = new CLKComplicationTimelineEntry () { // Date = new NSDate (), // ComplicationTemplate = new CLKComplicationTemplateCircularSmallRingText () // }; // handler (entry); // CLKComplicationTimelineEntry entry = null; if (complication.Family == CLKComplicationFamily.ModularSmall) { var textTemplate = new CLKComplicationTemplateModularSmallSimpleText(); textTemplate.TextProvider = CLKSimpleTextProvider.FromText("Xamarin1"); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate); } else if (complication.Family == CLKComplicationFamily.UtilitarianSmall) { var textTemplate = new CLKComplicationTemplateUtilitarianSmallFlat(); textTemplate.TextProvider = CLKSimpleTextProvider.FromText("Xamarin2"); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate); } else if (complication.Family == CLKComplicationFamily.UtilitarianLarge) { var textTemplate = new CLKComplicationTemplateUtilitarianLargeFlat(); textTemplate.TextProvider = CLKSimpleTextProvider.FromText("Xamarin3"); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate); } else if (complication.Family == CLKComplicationFamily.CircularSmall) { var imgTemplate = new CLKComplicationTemplateCircularSmallRingImage(); imgTemplate.ImageProvider = CLKImageProvider.Create(UIImage.FromBundle("Circular")); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, imgTemplate); } else { Console.WriteLine("GetCurrentTimelineEntry: Complication not supported"); } handler(entry); }
public override void GetCurrentTimelineEntry(CLKComplication complication, Action <CLKComplicationTimelineEntry> handler) { // Only support .modularLarge currently. if (complication.Family == CLKComplicationFamily.ModularLarge) { var random = new Random(); // Display a random number string on the body. var tallBody = new CLKComplicationTemplateModularLargeTallBody { HeaderTextProvider = CLKSimpleTextProvider.FromText("SimpleWC"), BodyTextProvider = CLKSimpleTextProvider.FromText($"{random.Next(400)}") }; // Pass the entry to ClockKit. var entry = CLKComplicationTimelineEntry.Create(new NSDate(), tallBody); handler(entry); } else { handler(null); } }
public override void GetCurrentTimelineEntry(CLKComplication complication, Action <CLKComplicationTimelineEntry> handler) { // Call the handler with the current timeline entry Console.WriteLine("GetCurrentTimelineEntry"); CLKComplicationTimelineEntry entry = null; try { var minutesPastHour = DateTime.Now.Minute.ToString(); if (complication.Family == CLKComplicationFamily.ModularSmall) { var textTemplate1 = new CLKComplicationTemplateModularSmallSimpleText(); textTemplate1.TextProvider = CLKSimpleTextProvider.FromText(minutesPastHour); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate1); } else if (complication.Family == CLKComplicationFamily.ModularLarge) { var textTemplate = new CLKComplicationTemplateModularLargeStandardBody(); textTemplate.HeaderTextProvider = CLKSimpleTextProvider.FromText("Set " + minutesPastHour + " mins past", "XH", "```"); textTemplate.Body1TextProvider = CLKSimpleTextProvider.FromText("Body text", "X1", "~~~"); textTemplate.Body2TextProvider = CLKSimpleTextProvider.FromText("Body 2", "X2", "---"); // if the user typed something in the app, show that in complication var c = NSUserDefaults.StandardUserDefaults["complication"]; if (c != null) { textTemplate.Body1TextProvider = CLKSimpleTextProvider.FromText("You typed:", "You:", "~~~"); textTemplate.Body2TextProvider = CLKSimpleTextProvider.FromText(c.ToString(), c.ToString(), "---"); } entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate); } else if (complication.Family == CLKComplicationFamily.UtilitarianSmall) { var textTemplate = new CLKComplicationTemplateUtilitarianSmallFlat(); textTemplate.TextProvider = CLKSimpleTextProvider.FromText(minutesPastHour + "m"); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate); } else if (complication.Family == CLKComplicationFamily.UtilitarianLarge) { var textTemplate = new CLKComplicationTemplateUtilitarianLargeFlat(); textTemplate.TextProvider = CLKSimpleTextProvider.FromText(minutesPastHour + " past hour"); entry = CLKComplicationTimelineEntry.Create(NSDate.Now, textTemplate); } else if (complication.Family == CLKComplicationFamily.CircularSmall) { var ringTemplate = new CLKComplicationTemplateCircularSmallRingText(); ringTemplate.TextProvider = CLKSimpleTextProvider.FromText(minutesPastHour); ringTemplate.FillFraction = DateTime.Now.Minute / 60f; entry = CLKComplicationTimelineEntry.Create(NSDate.Now, ringTemplate); } else { Console.WriteLine("GetCurrentTimelineEntry: Complication not supported (" + complication.Family + ")"); } } catch (Exception x) { Console.WriteLine("Exception " + x); } handler(entry); }