Ignore:
Timestamp:
01/15/09 15:47:39 (12 years ago)
Author:
whackl
Message:

added first version of scheduler, attention no validation!!! (#468)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Console/HiveClientConsole.cs

    r1087 r1138  
    3434using System.ServiceModel;
    3535using System.Net;
     36using Calendar;
    3637
    3738namespace HeuristicLab.Hive.Client.Console {
     
    5455    private System.Windows.Forms.Timer refreshTimer;
    5556    private ListViewColumnSorterDate lvwColumnSorter;
     57
     58    private List<Appointment> onlineTimes = new List<Appointment>();
    5659
    5760    #endregion
     
    6972      RefreshGui();
    7073      GetEventLog();
     74      InitCalender();
    7175    }
    7276
     
    161165      } else {
    162166        for (int i = 0; i < jobs.Length; i++) {
    163           allProgress += jobs[i].Progress;         
     167          allProgress += jobs[i].Progress;
    164168        }
    165169
     
    167171
    168172        myPane.AddPieSlice(done, Color.Green, 0, "");
    169         myPane.AddPieSlice(1-done, Color.Red, 0, "");
     173        myPane.AddPieSlice(1 - done, Color.Red, 0, "");
    170174      }
    171175      //Hides the slice labels
     
    175179
    176180      pbGraph.Image = zgc.GetImage();
     181    }
     182
     183    private void InitCalender() {
     184
     185      dvOnline.StartDate = DateTime.Now;
     186      dvOnline.OnNewAppointment += new EventHandler<NewAppointmentEventArgs>(DvOnline_OnNewAppointment);
     187      dvOnline.OnResolveAppointments += new EventHandler<ResolveAppointmentsEventArgs>(DvOnline_OnResolveAppointments);
     188    }
     189
     190    void DvOnline_OnResolveAppointments(object sender, ResolveAppointmentsEventArgs e) {
     191      List<Appointment> Apps = new List<Appointment>();
     192
     193      foreach (Appointment m_App in onlineTimes)
     194        if ((m_App.StartDate >= e.StartDate) &&
     195            (m_App.StartDate <= e.EndDate))
     196          Apps.Add(m_App);
     197
     198      e.Appointments = Apps;
     199    }
     200
     201    void DvOnline_OnNewAppointment(object sender, NewAppointmentEventArgs e) {
     202      Appointment Appointment = new Appointment();
     203
     204      Appointment.StartDate = e.StartDate;
     205      Appointment.EndDate = e.EndDate;
     206
     207      onlineTimes.Add(Appointment);
    177208    }
    178209
     
    191222        tbPort.Text = curConnection.Port.ToString();
    192223      } else {
    193                refreshTimer.Stop();
     224        refreshTimer.Stop();
    194225        DialogResult res = MessageBox.Show("Connection Error, check if Hive Client is running! - " + e.Error.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    195226        if (res == DialogResult.OK)
     
    328359    #endregion
    329360
     361    private void mcOnline_DateChanged(object sender, DateRangeEventArgs e) {
     362      dvOnline.StartDate = mcOnline.SelectionStart;
     363    }
     364
     365    private void btCreate_Click(object sender, EventArgs e) {
     366
     367      if (string.IsNullOrEmpty(txtFrom.Text)) {
     368        Appointment App = new Appointment();
     369        App.StartDate = dvOnline.SelectionStart;
     370        App.EndDate = dvOnline.SelectionEnd;
     371        App.BorderColor = Color.Red;
     372        App.Locked = true;
     373        App.Subject = "Online";
     374        onlineTimes.Add(App);
     375      } else if (string.IsNullOrEmpty(txtTimeTo.Text)) {
     376        Appointment App = new Appointment();
     377        App.StartDate = DateTime.Parse(txtFrom.Text);
     378        App.EndDate = DateTime.Parse(txtTo.Text);
     379        App.BorderColor = Color.Red;
     380        App.Locked = true;
     381        App.Subject = "Online";
     382        onlineTimes.Add(App);
     383      } else {
     384        DateTime from = DateTime.Parse(txtFrom.Text);
     385        DateTime to = DateTime.Parse(txtTo.Text);
     386
     387        while (from.Date != to.Date) {
     388          Appointment App = new Appointment();
     389          App.StartDate = new DateTime(from.Year, from.Month, from.Day, int.Parse(txttimeFrom.Text), 0,0);
     390          App.EndDate = new DateTime(from.Year, from.Month, from.Day, int.Parse(txtTimeTo.Text), 0, 0);
     391          App.BorderColor = Color.Red;
     392          App.Locked = true;
     393          App.Subject = "Online";
     394          onlineTimes.Add(App);
     395          from = from.AddDays(1);
     396        }
     397      }
     398     
     399      dvOnline.Invalidate();
     400    }
     401
     402    private void btbDelete_Click(object sender, EventArgs e) {
     403      if (dvOnline.SelectedAppointment != null)
     404        onlineTimes.Remove(dvOnline.SelectedAppointment);
     405      dvOnline.Invalidate();
     406    }
     407
    330408  }
    331409}
Note: See TracChangeset for help on using the changeset viewer.