Example #1
0
        protected virtual void OnDelete()
        {
            this.Operation = OperationType.Deleting;
            string             deletedone = "delete done";
            ITranslationResult trares     = this.Translator.Translate(null, deletedone, null);

            if (trares.IsSuccessful())
            {
                deletedone = trares.Translation;
            }
            List <ITemplatingItem> itemsToRemove = new List <ITemplatingItem>();

            try
            {
                ITemplatingItem[] arr = new ITemplatingItem[this._items.Count];
                this._items.CopyTo(arr, 0);
                ITemplatingItem[] array = arr;
                for (int i = 0; i < array.Length; i++)
                {
                    ITemplatingItem item = array[i];
                    if (item.IsCurrent)
                    {
                        this.OnMilestone("save-delete");
                        bool deleted = false;
                        if (!item.IsNew)
                        {
                            if (null != this.Delete)
                            {
                                Delete(this, new DeleteEventArgs((IDictionary)item.Data));
                            }
                            deleted = true;
                        }
                        this.OnValidationSucceed(null);
                        if (deleted && !this._monitor.HasErrors())
                        {
                            itemsToRemove.Add(item);
                            this._monitor.Register(this.Reporter, this._monitor.NewEventInstance(deletedone, EVENT_TYPE.Info));
                        }
                        this.NeedsDelete = false;
                        this.Operation   = OperationType.Viewing;
                    }
                }
                if (!this._monitor.HasErrors())
                {
                    this.OnMilestone("deleted");
                }
            }
            catch (Exception ex)
            {
                this._monitor.Register(this.Reporter, this._monitor.NewEventInstance("delete error", null, ex, EVENT_TYPE.Error));
            }
            foreach (ITemplatingItem item in itemsToRemove)
            {
                this._items.Remove(item);
            }

            _paginater.IsFrozen = false;
            _paginater.OnBackward();
            _paginater.OnForward();
        }
Example #2
0
        public virtual ITranslationResult Translate(ITranslatable target, string language)
        {
            ITranslationResult result = null;

            foreach (KeyValuePair <string, Control> pair in target.TranslationTargets)
            {
                if (pair.Value is ITextControl)
                {
                    ITextControl textControl = pair.Value as ITextControl;
                    result = this.Translate(pair.Key, textControl.Text, language);
                    if (result.IsSuccessful())
                    {
                        textControl.Text = result.Translation;
                    }
                }
            }
            return(result);
        }
Example #3
0
        protected virtual void OnSave()
        {
            string             savedone = "save done";
            ITranslationResult trares   = this.Translator.Translate(null, savedone, null);

            if (trares.IsSuccessful())
            {
                savedone = trares.Translation;
            }
            try
            {
                ITemplatingItem[] arr = new ITemplatingItem[this._items.Count];
                this._items.CopyTo(arr, 0);
                ITemplatingItem[] array = arr;
                for (int i = 0; i < array.Length; i++)
                {
                    ITemplatingItem item = array[i];
                    if (item.HasChanges)
                    {
                        this.OnValidate(item);
                        if (!item.IsValid)
                        {
                            break;
                        }
                        if (item.IsNew)
                        {
                            if (null != this.CurrentItem)
                            {
                                this.CurrentItem.IsCurrent = false;
                            }
                            item.IsCurrent = true;
                            this.OnMilestone("save-insert");
                        }
                        else
                        {
                            if (null != this.CurrentItem)
                            {
                                this.CurrentItem.IsCurrent = false;
                            }
                            item.IsCurrent = true;
                            this.OnMilestone("save-update");
                        }
                        if (item.IsNew)
                        {
                            if (null != this.Insert)
                            {
                                Insert(this, new InsertEventArgs((IDictionary)item.Data));
                            }
                        }
                        else
                        {
                            if (null != this.Update)
                            {
                                Update(this, new UpdateEventArgs((IDictionary)item.Data));
                            }
                        }
                        if (!this._monitor.HasErrors())
                        {
                            item.IsReadOnly = true;
                            item.IsNew      = false;
                            item.HasChanges = false;
                            this._monitor.Register(this.Reporter, this._monitor.NewEventInstance(savedone, EVENT_TYPE.Info));
                        }
                        this.NeedsSave = false;
                        this.Operation = OperationType.Viewing;
                    }
                }

                if (!this._monitor.HasErrors())
                {
                    this.OnMilestone("saved");
                }
            }
            catch (Exception ex)
            {
                this._monitor.Register(this.Reporter, this._monitor.NewEventInstance("save error", null, ex, EVENT_TYPE.Error));
            }
        }