public bool Contains(OrganizerEvent data) { StreamReader read = new StreamReader(new FileStream(@"..\..\database.txt", FileMode.Open, FileAccess.Read)); using (read) { StringBuilder currentLine = new StringBuilder(); int i = 0; bool check = false; while (read.ReadLine() != null) { currentLine.AppendLine(read.ReadLine()); currentLine.AppendLine(read.ReadLine()); currentLine.AppendLine(read.ReadLine()); currentLine.AppendLine(read.ReadLine()); currentLine.AppendLine(read.ReadLine()); if (currentLine.ToString() == data.ToString()) { check = true; break; } currentLine.Clear(); } return check; } }
public void FillData(OrganizerEvent dataSource) { if (dataSource == null) { throw new NullDataSourceException(); } this.DataSource = dataSource; FillData(dataSource.Title, dataSource.Location, dataSource.EventType, dataSource.Start, dataSource.End, dataSource.AllDay); }
public void Add(OrganizerEvent organizerEvent) { if (organizerEvent != null) { items.Add(organizerEvent); this.SaveEventsInDatabase(organizerEvent); this.OnEventAdded(new DataChangedEventArgs(organizerEvent, this)); } else { MessageBox.Show("OrganizerEvent parameters are empty."); // throw new ArgumentNullException(); } }
public EventControl(OrganizerEvent dataSource) { if (dataSource == null) { throw new NullDataSourceException(); } this.InitializeComponent(); //Bind to the properties of the data source OrganizerEvent object. this.BindTo(dataSource); //Store a reference to dataSOurce this.DataSource = dataSource; //Subscibe to dataSource's events this.SubscribeToDataSourceEvents(); //Initially set size, position and text of control. this.SingleDay = CheckSingleDayStatus(); this.SetTimeText(); }
public void AddEventControl(OrganizerEvent eventToBeDisplayed) { //Create control and add it to the VisualTree EventControl eventControl = new EventControl(eventToBeDisplayed); if (eventControl.SingleDay == true) { this.attachedWeekGrid.HoursGrid.Children.Add(eventControl); } else { this.attachedWeekGrid.DaysGrid.Children.Add(eventControl); } //Add the new control to the list of controls eventControls.Add(eventControl); //Subscribe for the control's events eventControl.SingleDayChanged += this.EventControl_SingleDayChanged; eventControl.DataSourcePropertyChanged += this.EventControlDataSourceProperty_Changed; eventControl.Click += this.OnEventControlClick; this.SetControlSizeAndPosition(eventControl); }
public void SaveEventsInDatabase(OrganizerEvent evn) { StreamWriter file = new StreamWriter(@"..\..\database.txt", true); using (file) { file.WriteLine(evn.ToString()); } }
public void Remove(OrganizerEvent organizerEvent) { if (organizerEvent != null) { items.Remove(organizerEvent); this.OnEventRemoved(new DataChangedEventArgs(organizerEvent, this)); } else { throw new ArgumentNullException(); } }
public void RemoveEventControl(OrganizerEvent eventBeingDisplayed) { EventControl controlToBeRemoved = this.EventControls.First(x => x.DataSource == eventBeingDisplayed); this.RemoveEventControl(controlToBeRemoved); }
public void UnSubscribeToDataSourceEvents() { dataSource.PropertyChanged -= this.OnDataSourcePropertyChanged; this.dataSource = null; }
public PopupDialogFinishedEventArgs(OrganizerEvent targetEvent, EventControl targetControl) { this.TargetEvent = targetEvent; this.TargetControl = targetControl; }
public void BindTo(OrganizerEvent dataSource) { if (dataSource != null) { //Bind event Title. Binding titleBinding = new Binding("Title"); titleBinding.Source = dataSource; this.SetBinding(EventControl.TitleProperty, titleBinding); //Bind event Location. Binding locationBinding = new Binding("Location"); locationBinding.Source = dataSource; this.SetBinding(EventControl.LocationProperty, locationBinding); //Get event Type. (eventType field is readony for the derived types of OrganizerEvent class) this.Type = dataSource.EventType; //Bind event start. Binding startBinding = new Binding("Start"); startBinding.Source = dataSource; this.SetBinding(EventControl.StartTimeProperty, startBinding); //Bind event end. Binding endBinding = new Binding("End"); endBinding.Source = dataSource; this.SetBinding(EventControl.EndTimeProperty, endBinding); } }
private void OnEventRemoved(OrganizerEvent removedEvent, EventControl callingControl) { if (this.EventCreated != null) this.EventCreated(this, new PopupDialogFinishedEventArgs(removedEvent, callingControl)); }
private void OnEventCreated(OrganizerEvent createdEvent) { if (this.EventCreated != null) this.EventCreated(this, new PopupDialogFinishedEventArgs(createdEvent, null)); }
public DataChangedEventArgs(OrganizerEvent data) : this(data, null) { }
public DataChangedEventArgs(OrganizerEvent data, IEventDataContainer dataSource) { this.Data = data; this.DataSource = dataSource; }
private bool EventIsFromWeekOnFocus(OrganizerEvent organizerEvent) { bool startsThisWeek = this.weekOnFocusStart <= organizerEvent.Start && organizerEvent.Start <= this.weekOnFocusEnd; bool endsThisWeek = this.weekOnFocusStart <= organizerEvent.End && organizerEvent.End <= this.weekOnFocusEnd; bool isActiveDuringThisWeek = organizerEvent.Start <= this.weekOnFocusStart && organizerEvent.End >= this.weekOnFocusEnd; return startsThisWeek || endsThisWeek || isActiveDuringThisWeek; }