Beispiel #1
0
        void WebsiteHostNameEditorControl_ReflectDataToForm(object sender, DataEditorReflectEventArgs e)
        {
            lastKnownMode = e.Mode;

            if (e.GetData <Website>().HostArray != null)
            {
                int selectedIndex = getSelectedIndex();

                hostList.Clear();
                hostList.AddRange(e.GetData <Website>().HostArray);

                hostBindingList.Clear();
                hostList.ForEach(h => hostBindingList.Add(h));
                hostBindingList.ResetBindings();

                selectGridViewRow(selectedIndex);
            }
        }
Beispiel #2
0
 void WebsiteHostNameEditorControl_ReflectFormToData(object sender, DataEditorReflectEventArgs e)
 {
     lastKnownMode = e.Mode;
     dataGridView.EndEdit();
     e.GetData <Website>().HostArray = hostList.ToArray();
 }
        private void handleAfterDataAction(DataEditorActionResult result)
        {
            DataActionAfterEventArgs eventArgs = new DataActionAfterEventArgs(
                result.StatusGuid, result.Cancelled, result.Data);

            switch (result.Action)
            {
            case DataEditorAction.Load:
                OnAfterLoadAsync(eventArgs);
                break;

            case DataEditorAction.Save:
            case DataEditorAction.SaveClose:
            {
                OnAfterSaveAsync(eventArgs);

                switch (editorMode)
                {
                case DataEditorMode.Create:
                    OnAfterCreateAsync(eventArgs);
                    break;

                case DataEditorMode.Update:
                    OnAfterUpdateAsync(eventArgs);
                    break;
                }

                // Ensure form can close.
                changesSaved = true;

                // When cancelled, do not change mode or close.
                if (!result.Cancelled)
                {
                    switch (result.Action)
                    {
                    case DataEditorAction.SaveClose:
                        Close();
                        break;

                    case DataEditorAction.Save:
                        editorMode = DataEditorMode.Update;
                        break;
                    }
                }
            }
            break;
            }

            if (IsHandleCreated)
            {
                if (AutoChangeStatus)
                {
                    // Only revert when window is still alive.
                    AsyncStatusRevert(result.StatusGuid);
                }

                // Not sure if this is so elegant.
                if (DisplayUserMessageAfter &&
                    result.Cancelled &&
                    !string.IsNullOrEmpty(result.UserMessage))
                {
                    MessageBox.Show(
                        result.UserMessage,
                        "Cancelled",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                }
            }

            suspendChangeMadeNotify = false;
        }
 public void SetUpdateMode(IUniqueData editorData)
 {
     this.editorMode = DataEditorMode.Update;
     SetEditorData(editorData);
 }
Beispiel #5
0
 public DataEditorReflectEventArgs(object data, DataEditorMode mode)
 {
     this.data = data;
     this.Mode = mode;
 }
Beispiel #6
0
 public void RunReflectFormToData(DataEditorMode mode)
 {
     OnReflectFormToData(new DataEditorReflectEventArgs(editorData, mode));
 }
Beispiel #7
0
 public void RunReflectDataToForm(DataEditorMode mode)
 {
     OnReflectDataToForm(new DataEditorReflectEventArgs(editorData, mode));
 }