예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Model.SaveEvent != null)
            {
                Model.Item.UseCategory       = ckbUseCategory.Checked;
                Model.Item.Category          = tbCategory.Text;
                Model.Item.OnlyNetworkValues = ckbOnlyNetwork.Checked;
                Model.Item.LookupDirection   = CRUDUIService.GetEnumValue <LookupDirection>(cbLookupDirection);
                CRUDUIService.SaveList(Model.Item.Criteria, lbCriteria);
                CRUDUIService.SaveList(Model.Item.ValueNames, lbValueNames);
                CRUDUIService.SaveList(Model.Item.Conditions, lbConditions);

                Model.SaveEvent(Model);
            }
            Close();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            StatusPanel.StatusUpdate(StatusModel.Update("Saving..."));

            var i = Model.Item;

            i.Documentation              = tbDocumentation.Rtf;
            i.DocumentMap                = ckbDocumentMap.Checked;
            i.Name                       = tbName.Text;
            i.Sort                       = tbSort.Text;
            i.GapNormal                  = ckbGapNormal.Checked;
            i.DisplayDurationFromParent  = ckbTimeFromParent.Checked;
            i.DisplayDurationFromSibling = ckbDurationFromSibling.Checked;
            i.Example                    = tbExample.Text;

            i.RegularExpression = tbRegularExpression.Text;

            i.Categories.Clear();
            foreach (var checkedItem in clbCategory.CheckedItems)
            {
                i.Categories.Add((Category)checkedItem);
            }
            i.SourceType = string.IsNullOrEmpty(cbSourceType.Text) ? null : cbSourceType.Text;

            i.SourceTypes.Clear();
            foreach (var checkedItem in clbSourceType.CheckedItems)
            {
                i.SourceTypes.Add(checkedItem.ToString());
            }

            if (i.SourceTypes.Count == 0)
            {
                i.SourceTypes.Add(Keywords.ALL);
            }

            if (cbFoldingEventId.SelectedItem != null)
            {
                i.FoldingEventId = ((EventLR)cbFoldingEventId.SelectedItem).EventId;
            }
            else
            {
                i.FoldingEventId = -1;
            }

            i.Network = cbNetworkCommunication.Text == "" ? NetworkDirection.Na : CRUDUIService.GetEnumValue <NetworkDirection>(cbNetworkCommunication);

            i.Level = (DocumentMapLevel)Enum.Parse(typeof(DocumentMapLevel), cbLevel.Text, true);
            i.IgnoreDocumentation       = cbIgnoreDocumentation.Checked;
            i.HighlightColor            = cbColor.Text == "" ? Color.Transparent.Name : cbColor.Text;
            i.DocumentMapHighlightColor = cbDocumentMapHighlightColor.Text == "" ? Color.Transparent.Name : cbDocumentMapHighlightColor.Text;

            CRUDUIService.SaveList(i.EventValues, lbValues);
            CRUDUIService.SaveList(i.EventLookupValues, lbLookupValues);

            i.IgnoreName = ckbIgnoreName.Checked;

            try
            {
                ViewModel.Save(Model);
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            StatusPanel.StatusUpdate(StatusModel.Completed);
        }