Пример #1
0
        public bool Save(string path)
        {
            gvTasks.CloseEditor();
            gvLevelItems.CloseEditor();
            gvAttachmentTypes.CloseEditor();

            int selectionStart = txtLog.Text.Length - 1;

            if (!_pack.Save(path))
            {
                tabBottom.SelectedTabPage = tbpLog;
                txtLog.Select(selectionStart, txtLog.Text.Length - selectionStart);
                txtLog.ScrollToCaret();

                DialogUtility.ShowWarning("Pack was not saved, see errors on the \"{0}\" tab.", tbpLog.Text);

                return(false);
            }

            Text       = path;
            IsNeedSave = false;
            IsNew      = false;

            return(true);
        }
Пример #2
0
        private bool ValidateData()
        {
            gvItems.CloseEditor();
            gvItems.UpdateCurrentRow();

            if (txtCount.Value <= 1)
            {
                DialogUtility.ShowWarning("{0} must be greater than 1.", lblCount.Text);
                return(false);
            }

            if (txtInterval.Value <= 0)
            {
                DialogUtility.ShowWarning("{0} must be greater than 0.", lblInterval.Text);
                return(false);
            }

            if (_items.Count == 0)
            {
                DialogUtility.ShowWarning("No items added.");
                return(false);
            }

            int  prevFocused   = gvItems.FocusedRowHandle;
            bool hasItemErrors = false;

            for (int i = 0; i < gvItems.DataRowCount; i++)
            {
                gvItems.FocusedRowHandle = i;

                // NOTE: HasColumnErrors doesn't work
                foreach (GridColumn gc in gvItems.Columns)
                {
                    if (!gvItems.GetColumnError(gc).IsNullOrWhiteSpace())
                    {
                        hasItemErrors = true;
                        break;
                    }
                }

                if (hasItemErrors)
                {
                    break;
                }
            }

            gvItems.FocusedRowHandle = prevFocused;

            if (hasItemErrors)
            {
                DialogUtility.ShowWarning("One ore more items in the grid has errors. Correct or remove invalid item(s).");
                return(false);
            }

            return(true);
        }