Exemplo n.º 1
0
        public void OnValueChanged(GXDLMSViewArguments arg)
        {
            if (arg.Index != 2)
            {
                throw new IndexOutOfRangeException("index");
            }
            EntriesView.Items.Clear();
            GXDLMSSchedule target = (GXDLMSSchedule)Target;

            foreach (GXScheduleEntry item in target.Entries)
            {
                AddEntry(item);
            }
        }
Exemplo n.º 2
0
 void OnShowDialog(GXActionArgs arg)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new ShowScheduleDialogEventHandler(OnShowDialog), arg).AsyncWaitHandle.WaitOne();
     }
     else
     {
         GXDLMSSchedule target = (GXDLMSSchedule)Target;
         if (arg.Index == 1)
         {
             //Enable/Disable...
             if (EntriesView.SelectedItems.Count == 1)
             {
                 GXScheduleEntry  it  = (GXScheduleEntry)EntriesView.SelectedItems[0].Tag;
                 GXDLMScheduleDlg dlg = new GXDLMScheduleDlg(it, target.Parent, 1);
                 if (dlg.ShowDialog(this.Parent) == DialogResult.OK)
                 {
                     if (it.Enable)
                     {
                         arg.Value = target.Enable(arg.Client, it);
                     }
                     else
                     {
                         arg.Value = target.Disable(arg.Client, it);
                     }
                     EntriesView.SelectedItems[0].SubItems[1].Text = it.Enable.ToString();
                 }
                 else
                 {
                     arg.Handled = true;
                 }
             }
             else
             {
                 arg.Handled = true;
             }
         }
         else if (arg.Index == 2)
         {
             //Add
             GXScheduleEntry  it  = new GXScheduleEntry();
             GXDLMScheduleDlg dlg = new GXDLMScheduleDlg(it, target.Parent, 2);
             if (dlg.ShowDialog(this.Parent) == DialogResult.OK)
             {
                 arg.Value = target.Insert(arg.Client, it);
                 AddEntry(it);
             }
             else
             {
                 arg.Handled = true;
             }
         }
         else if (arg.Index == 3)
         {
             //Delete
             if (EntriesView.SelectedItems.Count == 1)
             {
                 GXScheduleEntry  it  = (GXScheduleEntry)EntriesView.SelectedItems[0].Tag;
                 GXDLMScheduleDlg dlg = new GXDLMScheduleDlg(it, target.Parent, 3);
                 if (dlg.ShowDialog(this.Parent) == DialogResult.OK)
                 {
                     arg.Value = target.Delete(arg.Client, it);
                     EntriesView.SelectedItems[0].Remove();
                 }
                 else
                 {
                     arg.Handled = true;
                 }
             }
             else
             {
                 arg.Handled = true;
             }
         }
     }
 }