public CalendarForm() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); #region SetData string fileName = "default.xml"; if (FindFile(ref fileName)) { scheduleProvider = SimpleScheduleDataProvider.LoadXML(fileName); scheduleProvider.FileName = fileName; OffsetData(); } else { scheduleProvider = new SimpleScheduleDataProvider(); scheduleProvider.MasterList = new SimpleScheduleItemList(); scheduleProvider.FileName = "default.xml"; } scheduleControl1.ScheduleType = ScheduleViewType.Day; scheduleControl1.DataSource = scheduleProvider; #endregion #region Style Settings this.scheduleControl1.EnableAlerts = true; this.scheduleControl1.Appearance.ShowCaptionButtons = true; this.radWorkWeek.Visible = false; this.radFullWeek.Visible = false; #endregion //need to size a padding panel... foreach (Control c in scheduleControl1.CaptionPanel.Controls) { if (c.Name == "panelSpacer") { c.Width = 40; } } this.scheduleControl1.Appearance.VisualStyle = GridVisualStyles.Office2007Blue; }
/// <summary> /// Creates an instance of <see cref="SimpleScheduleDataProvider"/> and loads /// a previously serialized MasterList into the instance from a binary file. /// </summary> /// <param name="fileName">The serialized filename.</param> /// <returns>A SimpleScheduleDataProvider.</returns> /// <remarks> /// This method uses <see cref="AppDomain.CurrentDomain.AssemblyResolve"/> to /// avoid versioning issues with the binary serialization of the MasterList. /// </remarks> public static SimpleScheduleDataProvider LoadBinary(string fileName) { SimpleScheduleDataProvider t = new SimpleScheduleDataProvider(); Stream s = File.OpenRead(fileName); try { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(Syncfusion.ScheduleWindowsAssembly.AssemblyResolver); BinaryFormatter b = new BinaryFormatter(); b.AssemblyFormat = FormatterAssemblyStyle.Simple; object obj = b.Deserialize(s); t.MasterList = obj as SimpleScheduleItemList; } finally { s.Close(); AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(Syncfusion.ScheduleWindowsAssembly.AssemblyResolver); } return(t); }
/// <summary> /// Creates an instance of <see cref="SimpleScheduleDataProvider"/> and loads /// a previously serialized MasterList into the instance from an XML file. /// </summary> /// <param name="fileName">The serialized filename.</param> /// <returns>A SimpleScheduleDataProvider.</returns> public static SimpleScheduleDataProvider LoadXML(string fileName) { SimpleScheduleDataProvider t = new SimpleScheduleDataProvider(); Stream s = File.OpenRead(fileName); try { XmlSerializer serializer = new XmlSerializer(typeof(SimpleScheduleItem[]));//typeof(SimpleScheduleItem)); SimpleScheduleItem[] a = serializer.Deserialize(s) as SimpleScheduleItem[]; foreach (SimpleScheduleItem item in a) { t.MasterList.ItemList.Add(item); } a = null; } finally { s.Close(); } return(t); }