Exemple #1
0
        public EpiInfo.Plugin.IVariable Resolve(string pName, string pNamespace = null)
        {
            EpiInfo.Plugin.IVariable result = null;

            if (!string.IsNullOrEmpty(pNamespace) && (!string.IsNullOrEmpty(_name) && !_name.Equals(pNamespace, StringComparison.OrdinalIgnoreCase)))
            {
                if (_parent != null)
                {
                    result = _parent.Resolve(pName, pNamespace);
                }
            }
            else if (_symbolList.ContainsKey(pName))
            {
                result = _symbolList[pName];
            }
            else
            {
                if (_parent != null)
                {
                    result = _parent.Resolve(pName, pNamespace);
                }
            }

            return(result);
        }
Exemple #2
0
        public void CloseViewHandler(object returnHome, EventArgs e)
        {
            this.canvas.UnsubscribeControlEventHandlers();
            this.SetFieldData();

            if (SaveRecord() == false)
            {
                return;
            }

            RunTimeView RTV = this.EnterCheckCodeEngine.CurrentView;

            this.IsClosingRelatedView = RTV.View.IsRelatedView;
            EpiInfo.Plugin.IScope scope = RTV.EpiInterpreter.Context.Scope.GetEnclosingScope();
            this.EnterCheckCodeEngine.CheckCodeHandler(this, new RunCheckCodeEventArgs(EventActionEnum.CloseView, ""));

            if (returnHome is Boolean && (bool)returnHome)
            {
                while (this.EnterCheckCodeEngine.CurrentView.View.IsRelatedView)
                {
                    this.EnterCheckCodeEngine.CheckCodeHandler(this, new RunCheckCodeEventArgs(EventActionEnum.CloseView, ""));
                }
            }

            if (this.EnterCheckCodeEngine.CurrentView != null)
            {
                view = this.EnterCheckCodeEngine.CurrentView.View;

                this.Reset();
                this.canvas.CurrentView = this.view;
                this.mainForm.OpenView(this.view);

                this.viewExplorer.LoadView(this.EnterCheckCodeEngine.CurrentView, this.EnterCheckCodeEngine.CurrentView.CurrentPage);

                // *** populate view data with any changes from child - begin
                if (scope != null && this.view.Name.Equals(scope.Name, StringComparison.OrdinalIgnoreCase))
                {
                    foreach (Epi.Fields.Field field in this.view.Fields)
                    {
                        if (field is EpiInfo.Plugin.IVariable)
                        {
                            EpiInfo.Plugin.IVariable iVariable = scope.Resolve(field.Name, this.view.Name);

                            if (iVariable != null && (field is Epi.Fields.ImageField == false))
                            {
                                if (field is Epi.Fields.CheckBoxField || field is Epi.Fields.YesNoField)
                                {
                                    if (((Epi.Fields.IDataField)field).CurrentRecordValueString == "true" || ((Epi.Fields.IDataField)field).CurrentRecordValueString == "1")
                                    {
                                        //v.Expression = "true";
                                        ((Epi.Fields.IDataField)field).CurrentRecordValueString = "1";
                                    }
                                    else if (((Epi.Fields.IDataField)field).CurrentRecordValueString == "false" || ((Epi.Fields.IDataField)field).CurrentRecordValueString == "0")
                                    {
                                        //v.Expression = "false";
                                        ((Epi.Fields.IDataField)field).CurrentRecordValueString = "0";
                                    }
                                    else
                                    {
                                        ((Epi.Fields.IDataField)field).CurrentRecordValueString = null;
                                    }
                                }
                                else
                                {
                                    string value = iVariable.Expression;

                                    if (value != ((EpiInfo.Plugin.IVariable)field).Expression)
                                    {
                                        ((Epi.Fields.IDataField)field).CurrentRecordValueString = value;
                                    }
                                }
                            }
                        }
                    }
                }
                // *** populate view data with any changes from child - end

                this.Render();
                this.IsClosingRelatedView = false;
            }
            else
            {
                this.view              = null;
                this.currentPage       = null;
                this.mainForm.View     = this.view;
                this.viewExplorer.View = this.EnterCheckCodeEngine.CurrentView;
                this.Reset();
                this.Render();
                this.canvas.CurrentView = this.view;
            }
        }