コード例 #1
0
        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;
            }
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 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();
     }
 }
コード例 #4
0
        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();
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void SaveEventsInDatabase(OrganizerEvent evn)
 {
     StreamWriter file = new StreamWriter(@"..\..\database.txt", true);
     using (file)
     {
         file.WriteLine(evn.ToString());
     }
 }
コード例 #7
0
 public void Remove(OrganizerEvent organizerEvent)
 {
     if (organizerEvent != null)
     {
         items.Remove(organizerEvent);
         this.OnEventRemoved(new DataChangedEventArgs(organizerEvent, this));
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
コード例 #8
0
 public void RemoveEventControl(OrganizerEvent eventBeingDisplayed)
 {
     EventControl controlToBeRemoved = this.EventControls.First(x => x.DataSource == eventBeingDisplayed);
     this.RemoveEventControl(controlToBeRemoved);
 }
コード例 #9
0
 public void UnSubscribeToDataSourceEvents()
 {
     dataSource.PropertyChanged -= this.OnDataSourcePropertyChanged;
     this.dataSource = null;
 }
コード例 #10
0
 public PopupDialogFinishedEventArgs(OrganizerEvent targetEvent, EventControl targetControl)
 {
     this.TargetEvent = targetEvent;
     this.TargetControl = targetControl;
 }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
 private void OnEventRemoved(OrganizerEvent removedEvent, EventControl callingControl)
 {
     if (this.EventCreated != null)
         this.EventCreated(this, new PopupDialogFinishedEventArgs(removedEvent, callingControl));
 }
コード例 #13
0
 private void OnEventCreated(OrganizerEvent createdEvent)
 {
     if (this.EventCreated != null)
         this.EventCreated(this, new PopupDialogFinishedEventArgs(createdEvent, null));
 }
コード例 #14
0
 public DataChangedEventArgs(OrganizerEvent data)
     : this(data, null)
 {
 }
コード例 #15
0
 public DataChangedEventArgs(OrganizerEvent data, IEventDataContainer dataSource)
 {
     this.Data = data;
     this.DataSource = dataSource;
 }
コード例 #16
0
        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;
        }