public object this[OptionField field]
 {
     get
     {
         return(this[field.ToField()]);
     }
 }
Exemple #2
0
            private void _read()
            {
                _version       = m_io.ReadBitsIntBe(5);
                _isFirstRecord = m_io.ReadBitsIntBe(1) != 0;
                _isLastRecord  = m_io.ReadBitsIntBe(1) != 0;
                _isChunkRecord = m_io.ReadBitsIntBe(1) != 0;
                _typeFormat    = ((DimeMessage.TypeFormats)m_io.ReadBitsIntBe(4));
                _reserved      = m_io.ReadBitsIntBe(4);
                m_io.AlignToByte();
                _lenOptions   = m_io.ReadU2be();
                _lenId        = m_io.ReadU2be();
                _lenType      = m_io.ReadU2be();
                _lenData      = m_io.ReadU4be();
                __raw_options = m_io.ReadBytes(LenOptions);
                var io___raw_options = new KaitaiStream(__raw_options);

                _options        = new OptionField(io___raw_options, this, m_root);
                _optionsPadding = new Padding(m_io, this, m_root);
                _id             = System.Text.Encoding.GetEncoding("ASCII").GetString(m_io.ReadBytes(LenId));
                _idPadding      = new Padding(m_io, this, m_root);
                _type           = System.Text.Encoding.GetEncoding("ASCII").GetString(m_io.ReadBytes(LenType));
                _typePadding    = new Padding(m_io, this, m_root);
                _data           = m_io.ReadBytes(LenData);
                _dataPadding    = new Padding(m_io, this, m_root);
            }
Exemple #3
0
    public void HighlightOption(OptionField optionField)
    {
        Highlight.Activate(optionField);
        if (optionField.constraint != null)
        {
            // Arrow
            if (optionField.constraint is StepParentConstraint)
            {
                GameObject arrowGO = Instantiate(arrowPrefab, transform);
                createdStuff.Add(arrowGO);
                Vector3 from     = ((StepParentConstraint)optionField.constraint).parent.field.transform.position;
                Vector3 to       = transform.position;
                Vector3 midPoint = (from + to) / 2;
                arrowGO.transform.position = midPoint;
                arrowGO.transform.LookAt(to, Vector3.up);
                arrowGO.transform.position += Vector3.Cross((to - from).normalized, Vector3.up) * 0.25f;
                arrowGO.transform.position += Vector3.up * 0.1f;

                arrowGO.transform.localScale /= 3f;
            }
            else
            {
                infoText.gameObject.SetActive(true);
                infoText.SetText(optionField.constraint.letter);
            }
        }
        optionGraphics.AddToDisplay(optionField);
    }
Exemple #4
0
    public override HashSet <OptionField> GetOptionsByRule()
    {
        HashSet <OptionField> options = new HashSet <OptionField>();

        // Step
        OptionField singleStep = GetOptionSingle(0, 1, Option.Step);

        if (singleStep != null)
        {
            options.Add(singleStep);
        }
        OptionField doubleStep = GetOptionSingle(0, 2, Option.Step);

        if (singleStep != null && doubleStep != null)
        {
            PawnDoubleStepConstraint pdsc            = new PawnDoubleStepConstraint(doubleStep, this);
            StepParentConstraint     spc             = new StepParentConstraint(singleStep);
            MultiConstraint          multiConstraint = new MultiConstraint(new List <Constraint> {
                pdsc, spc
            });
            doubleStep.AddConstraint(multiConstraint);
            options.Add(doubleStep);
        }

        // Capture
        options.UnionWith(GetOption(-1, 1, MultiOption.Capture));
        options.UnionWith(GetOption(1, 1, MultiOption.Capture));

        return(options);
    }
Exemple #5
0
 public void Activate(OptionField optionField)
 {
     if (!R.enabled)
     {
         R.enabled = true;
         R.material.SetColor("_EmissionColor", Color.gray / 3);
     }
 }
        /// <summary>
        /// Constructor for the class
        /// </summary>
        /// <param name="frm">The parent form</param>
        /// <param name="field">The fied to be edited</param>
        public OptionFieldDefinition(MainForm frm, OptionField field) : base(frm)
        {
            InitializeComponent();
            ScrapeControlLayout();
            this.mode  = FormMode.Edit;
            this.field = field;
            this.page  = field.Page;

            LoadFormData();
        }
Exemple #7
0
 public StepParentConstraint(OptionField parent)
 {
     this.parent = parent;
     description = "If unit can step on the field before";
 }
Exemple #8
0
        public IEnumerable <IAssociationOption> ResolveOptions(ApplicationMetadata application, OptionField optionField, AttributeHolder dataMap)
        {
            if (!FullSatisfied(optionField, dataMap))
            {
                return(null);
            }
            if (optionField.ShowExpression == "false")
            {
                return(null);
            }

            var attribute = optionField.ProviderAttribute;

            attribute = attribute.Replace("#", "");
            attribute = attribute.Replace("_", "");


            var methodName = GetMethodName(attribute);
            var dataSet    = FindDataSet(application.Name, methodName);
            var mi         = dataSet.GetType().GetMethod(methodName);

            if (mi == null)
            {
                throw new InvalidOperationException(String.Format(MethodNotFound, methodName, dataSet.GetType().Name));
            }
            if (mi.GetParameters().Count() != 1 || mi.GetParameters()[0].ParameterType != typeof(OptionFieldProviderParameters))
            {
                throw new InvalidOperationException(String.Format(WrongMethod, methodName, dataSet.GetType().Name));
            }
            var associationOptions = (IEnumerable <IAssociationOption>)mi.Invoke(dataSet, new object[] { new OptionFieldProviderParameters {
                                                                                                             OriginalEntity = dataMap, ApplicationMetadata = application, OptionField = optionField
                                                                                                         } });

            if (optionField.Sort)
            {
                associationOptions = associationOptions.OrderBy(f => f.Label);
            }
            return(associationOptions);
        }
        /// <summary>
        /// Field data is saved
        /// </summary>
        public void SetFieldData()
        {
            ControlFactory factory = ControlFactory.Instance;

            if (canvas != null && canvas.Panels != null)
            {
                foreach (Panel panel in canvas.Panels)
                {
                    foreach (Control control in panel.Controls)
                    {
                        try
                        {
                            // Skip prompts and field group boxes. They don't have any data.
                            if (control is Label)
                            {
                                continue;
                            }
                            if (control is FieldGroupBox)
                            {
                                continue;
                            }

                            Field field = factory.GetAssociatedField(control);
                            if (field == null)
                            {
                                continue;
                            }

                            field = this.view.Fields[field.Name];
                            // Images fields populate the file name when the file is selected. No need to read from control any more.
                            if (field is ImageField)
                            {
                                continue;
                            }

                            if (field is YesNoField)
                            {
                                YesNoField yesNoField = field as YesNoField;
                                ComboBox   comboBox   = control as ComboBox;
                                if (comboBox.SelectedIndex >= 0)
                                {
                                    if (comboBox.SelectedValue != null)
                                    {
                                        yesNoField.CurrentRecordValueObject = comboBox.SelectedValue;
                                    }
                                    else if (comboBox.SelectedIndex == 0)
                                    {
                                        yesNoField.CurrentRecordValueObject = 1; // 1 = yes index 0 = yes
                                    }
                                    else
                                    {
                                        yesNoField.CurrentRecordValueObject = 0; // 0 = no index 1 = no
                                    }
                                }
                                else
                                {
                                    yesNoField.CurrentRecordValueObject = null;
                                }
                            }
                            else if (field is GridField)
                            {
                                DataGridView dgv = (DataGridView)control;
                                if (dgv.DataSource is DataTable)
                                {
                                    ((GridField)field).DataSource = (DataTable)dgv.DataSource;
                                }
                            }
                            else if (field is OptionField)
                            {
                                OptionField optionField = field as OptionField;
                                GroupBox    groupBox    = control as GroupBox;

                                foreach (Control rb in groupBox.Controls)
                                {
                                    if (((RadioButton)rb).Checked)
                                    {
                                        int index = 0;
                                        foreach (string option in optionField.Options)
                                        {
                                            if (option == rb.Text)
                                            {
                                                optionField.CurrentRecordValueObject = index;
                                            }
                                            index++;
                                        }
                                    }
                                }
                            }
                            else if (control is TextBox || control is RichTextBox || control is ComboBox || control is CheckBox || control is MaskedTextBox || control is DateTimePicker)
                            {
                                if (field is IDataField)
                                {
                                    if (field is DateTimeField)
                                    {
                                        SetDateTimeData(field as DateTimeField, control);
                                    }
                                    else if (control is TextBox || control is RichTextBox)
                                    {
                                        SetTextData(field, control);
                                    }
                                    else if (control is MaskedTextBox)
                                    {
                                        if (field is NumberField || field is PhoneNumberField)
                                        {
                                            SetNumberData(field, control);
                                        }
                                        else
                                        {
                                            SetOtherMaskedData(field, control);
                                        }
                                    }
                                    else if (control is ComboBox)
                                    {
                                        SetComboBoxData(field, control);
                                    }
                                    else if (control is CheckBox)
                                    {
                                        SetCheckBoxData(field, control);
                                    }
                                    else if (control is GroupBox)
                                    {
                                    }
                                    else if (control is DateTimePicker)
                                    {
                                    }
                                }
                            }
                        }
                        catch
                        {
                            // do nothing for now
                        }
                    } // end foreach (Control control in panel.Controls)
                }     // end foreach (Panel panel in canvas.Panels)
            }
        }
Exemple #10
0
 public bool IsNull(OptionField field)
 {
     return((_nullFields & (int)field) > 0);
 }
Exemple #11
0
        private object GetValueByOptionField(KeyValuePair <Guid, Json.GetSchemaOptionData> modelEntry, OptionField field)
        {
            switch (field)
            {
            case OptionField.Id:
                return(UuidUtil.GetId(modelEntry.Key));

            case OptionField.Name:
                return(modelEntry.Value.Name);

            case OptionField.Label:
                return(modelEntry.Value.Label);

            case OptionField.ChildCount:
                return(modelEntry.Value.ChildCount);

            case OptionField.Enabled:
                return(modelEntry.Value.Enabled);

            case OptionField.Parent:
                return(new OptionDataCollection(new Dictionary <HrbcField, object> {
                    { OptionField.Id.ToField(), UuidUtil.GetId(modelEntry.Value.Parent) }
                }));

            default:
                throw new NotSupportedException();
            }
        }
Exemple #12
0
 public bool IsNull(OptionField field)
 {
     return (_nullFields & (int)field) > 0;
 }
Exemple #13
0
        //void lvMain_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        //{
        //    if(lvMain.SelectedItems.Count == 1)
        //    {

        //    }
        //}

        /// <summary>
        /// Handles the DoWorker event for the worker
        /// </summary>
        /// <param name="sender">Object that fired the event</param>
        /// <param name="e">.NET supplied event parameters</param>
        private void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            lock (syncLock)
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                this.Dispatcher.BeginInvoke(new SimpleCallback(SetToProcessingState));
                this.Dispatcher.BeginInvoke(new SimpleCallback(ClearResults));

                Configuration config   = dashboardHelper.Config;
                string        yesValue = config.Settings.RepresentationOfYes;
                string        noValue  = config.Settings.RepresentationOfNo;

                try
                {
                    DataTable dictionaryTable = dashboardHelper.FieldTable.Copy();

                    foreach (KeyValuePair <string, string> kvp in dashboardHelper.TableColumnNames)
                    {
                        DataRow row = dictionaryTable.Rows.Find(kvp.Key);
                        if (row == null)
                        {
                            dictionaryTable.Rows.Add(kvp.Key, kvp.Value);
                        }
                    }

                    if (dashboardHelper.IsUsingEpiProject)
                    {
                        dictionaryTable.Columns.Add("Page", typeof(int));
                        dictionaryTable.Columns.Add("Tab", typeof(int));
                        dictionaryTable.Columns.Add("Prompt", typeof(string));
                        dictionaryTable.Columns.Add("Items", typeof(string));

                        foreach (DataRow fieldRow in dictionaryTable.Rows)
                        {
                            if (fieldRow["epifieldtype"] is RenderableField)
                            {
                                RenderableField renderableField = fieldRow["epifieldtype"] as RenderableField;
                                fieldRow["Page"]   = renderableField.Page.Position + 1;
                                fieldRow["Tab"]    = renderableField.TabIndex;
                                fieldRow["Prompt"] = renderableField.PromptText;
                                if (renderableField is GroupField)
                                {
                                    GroupField groupField = renderableField as GroupField;
                                    fieldRow["Items"] = groupField.ChildFieldNames;
                                }
                                else if (renderableField is OptionField)
                                {
                                    OptionField optionField = renderableField as OptionField;
                                    fieldRow["Items"] = optionField.GetOptionsString();
                                }
                            }
                        }

                        dictionaryTable.Columns["columnname"].SetOrdinal(0);
                        dictionaryTable.Columns["Prompt"].SetOrdinal(1);
                        dictionaryTable.Columns["formname"].SetOrdinal(2);
                        dictionaryTable.Columns["Page"].SetOrdinal(3);
                        dictionaryTable.Columns["Tab"].SetOrdinal(4);
                        dictionaryTable.Columns["datatype"].SetOrdinal(5);
                        dictionaryTable.Columns["epifieldtype"].SetOrdinal(6);
                        dictionaryTable.Columns["tablename"].SetOrdinal(7);
                        dictionaryTable.Columns["Items"].SetOrdinal(8);
                    }

                    if (dictionaryTable == null || dictionaryTable.Rows.Count == 0)
                    {
                        //this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), "There are no valid fields to display.");
                        this.Dispatcher.BeginInvoke(new SimpleCallback(SetToFinishedState));
                        Debug.Print("Data dictionary thread cancelled");
                        return;
                    }
                    else if (worker.CancellationPending)
                    {
                        //this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), SharedStrings.DASHBOARD_GADGET_STATUS_OPERATION_CANCELLED);
                        this.Dispatcher.BeginInvoke(new SimpleCallback(SetToFinishedState));
                        Debug.Print("Data dictionary thread cancelled");
                        return;
                    }
                    else
                    {
                        e.Result = dictionaryTable;

                        //this.Dispatcher.BeginInvoke(addGrid, "", "", dictionaryTable.Columns.Count);
                        //string formatString = string.Empty;
                        //this.Dispatcher.BeginInvoke(renderHeader, "", "", dictionaryTable.Columns);

                        //int rowCount = 1;
                        //int columnCount = 1;

                        //foreach (System.Data.DataRow row in dictionaryTable.Rows)
                        //{
                        //    bool isGroup = false;

                        //    this.Dispatcher.Invoke(addRow, "", 30);
                        //    this.Dispatcher.BeginInvoke(setText, "", new TextBlockConfig(StringLiterals.SPACE + rowCount.ToString() + StringLiterals.SPACE, new Thickness(2, 0, 2, 0), VerticalAlignment.Center, HorizontalAlignment.Center, rowCount, 0, Visibility.Visible), FontWeights.Normal);

                        //    columnCount = 1;
                        //    foreach (DataColumn column in dictionaryTable.Columns)
                        //    {
                        //        string displayValue = row[column.ColumnName].ToString();
                        //        if (column.ColumnName.Equals("epifieldtype"))
                        //        {
                        //            displayValue = displayValue.Replace("Epi.Fields.", "");
                        //            if (isGroup)
                        //            {
                        //                displayValue = "GroupField";
                        //            }
                        //        }
                        //        else if (column.ColumnName.Equals("columnname"))
                        //        {
                        //            isGroup = dashboardHelper.GetGroupFieldsAsList().Contains(displayValue);
                        //        }
                        //        this.Dispatcher.BeginInvoke(setText, "", new TextBlockConfig(displayValue, new Thickness(8, 8, 8, 8), VerticalAlignment.Center, HorizontalAlignment.Left, rowCount, columnCount, Visibility.Visible), FontWeights.Normal);
                        //        columnCount++;
                        //    }

                        //    rowCount++;
                        //}

                        //this.Dispatcher.BeginInvoke(drawBorders, "");
                    }

                    //this.Dispatcher.BeginInvoke(new SimpleCallback(RenderFinish));
                    this.Dispatcher.BeginInvoke(new SimpleCallback(SetToFinishedState));
                }
                catch (Exception ex)
                {
                    //this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), ex.Message);
                    this.Dispatcher.BeginInvoke(new SimpleCallback(SetToFinishedState));
                }
                finally
                {
                    stopwatch.Stop();
                    Debug.Print("Data dictionary took " + stopwatch.Elapsed.ToString() + " seconds to complete with " + dashboardHelper.RecordCount.ToString() + " records and the following filters:");
                    Debug.Print(dashboardHelper.DataFilters.GenerateDataFilterString());
                }
            }
        }
Exemple #14
0
    public void AddToDisplay(OptionField optionField)
    {
        Sprite sprite = GetSpriteForOptionField(optionField);

        CreateGraphics(sprite, optionField.constraint);
    }
Exemple #15
0
 public PawnDoubleStepConstraint(OptionField option, Pawn pawn)
 {
     this.option = option;
     this.pawn   = pawn;
     description = "If Pawn hasn't moved yet";
 }
        private List <Control> GetControls(OptionField field, Size canvasSize)
        {
            DragableGroupBox groupBox = new DragableGroupBox();

            groupBox.Text      = field.PromptText;
            groupBox.Font      = field.PromptFont;
            groupBox.BackColor = SystemColors.Window;
            int groupWidthEstimate;

            System.Text.StringBuilder pattern   = new System.Text.StringBuilder();
            System.Text.StringBuilder locations = new System.Text.StringBuilder();

            if (field.ControlWidthPercentage == 0)
            {
                groupWidthEstimate = groupBox.Width - 40;
            }
            else
            {
                groupBox.Width     = (int)(field.ControlWidthPercentage * canvasSize.Width);
                groupWidthEstimate = groupBox.Width - 30;
            }

            Size     proposedSize    = new Size(groupWidthEstimate, int.MaxValue);
            Bitmap   tempImage       = new Bitmap(1, 1);
            Graphics graphics        = Graphics.FromImage(tempImage);
            SizeF    groupPromptSize = graphics.MeasureString(groupBox.Text, groupBox.Font, proposedSize.Width);

            if (field.Options.Count < 1)
            {
                RadioButton rdb = new RadioButton();
                rdb.Text    = "Option 1";
                rdb.Left    = 5;
                rdb.Top     = 20;
                rdb.Enabled = false;
                groupBox.Controls.Add(rdb);
            }
            else
            {
                int tallestControlHeight = 10;
                int widestOptionWidth    = 16;
                int leftAlign            = 12;

                foreach (string item in field.Options)
                {
                    RadioButton radioButton = new RadioButton();
                    radioButton.Text        = item;
                    radioButton.Font        = field.ControlFont;
                    radioButton.MaximumSize = new Size(proposedSize.Width + 4, int.MaxValue);

                    proposedSize = new Size(groupWidthEstimate, int.MaxValue);
                    SizeF optionMeasuredSize = graphics.MeasureString(radioButton.Text, radioButton.Font, radioButton.MaximumSize.Width - 20);

                    radioButton.Width  = (int)optionMeasuredSize.Width + 20;
                    radioButton.Height = (int)optionMeasuredSize.Height + 1;

                    radioButton.AutoSize = false;
                    radioButton.Enabled  = true;
                    radioButton.Visible  = false;

                    groupBox.Controls.Add(radioButton);

                    if (radioButton.Width > widestOptionWidth)
                    {
                        widestOptionWidth = (int)radioButton.Width;
                    }

                    if (radioButton.Height > tallestControlHeight)
                    {
                        tallestControlHeight = (int)radioButton.Height;
                    }
                }

                widestOptionWidth += 10;

                double div = (groupBox.Width - (1.2 * leftAlign)) / widestOptionWidth;
                div = div < 1 ? 1 : div;
                int columnCount = (int)Math.Floor(div);
                div = (double)field.Options.Count / (double)columnCount;
                int rowCount = (int)Math.Ceiling(div);

                bool isVertical  = true;
                bool startOnLeft = true;

                if (((OptionField)field).Pattern.Contains(Enums.OptionLayout.Horizontal.ToString()))
                {
                    isVertical = false;
                }

                if (((OptionField)field).Pattern.Contains(Enums.OptionLayout.Right.ToString()))
                {
                    startOnLeft = false;
                }

                pattern.Append(string.Format("{0},", isVertical == true ? Enums.OptionLayout.Vertical.ToString() : Enums.OptionLayout.Horizontal.ToString()));
                pattern.Append(string.Format("{0},", startOnLeft == true ? Enums.OptionLayout.Left.ToString() : Enums.OptionLayout.Right.ToString()));

                int topMargin = (int)groupPromptSize.Height + 10;

                int column = 0;
                int row    = 0;

                if (startOnLeft == false)
                {
                    column = columnCount - 1;
                }

                int topOfLastControlDown    = 0;
                int bottomOfLastControlDown = 0;

                foreach (Control control in groupBox.Controls)
                {
                    if (columnCount == 1)
                    {
                        if (row == 0)
                        {
                            control.Top = bottomOfLastControlDown + topMargin;
                        }
                        else
                        {
                            control.Top = bottomOfLastControlDown + 6;
                        }

                        topOfLastControlDown    = control.Top;
                        bottomOfLastControlDown = control.Top + control.Height;

                        control.Width = (int)control.MaximumSize.Width;
                    }
                    else
                    {
                        control.Top = row * (tallestControlHeight + 4) + topMargin;
                    }

                    if (row == (rowCount - 1) || isVertical == false)
                    {
                        topOfLastControlDown = control.Top;
                    }

                    if (field.ShowTextOnRight)
                    {
                        control.RightToLeft = RightToLeft.No;
                        control.Left        = column * (widestOptionWidth) + leftAlign;
                    }
                    else
                    {
                        control.RightToLeft = RightToLeft.Yes;
                        control.Left        = column * (widestOptionWidth) + leftAlign + widestOptionWidth - control.Width;
                    }

                    groupBox.AutoSizeMode = AutoSizeMode.GrowOnly;
                    groupBox.AutoSize     = false;
                    control.Visible       = true;

                    string topPercent  = ((float)control.Top / (float)canvasSize.Height).ToString("#.#####");
                    string leftPercent = ((float)control.Left / (float)canvasSize.Width).ToString("#.#####");
                    locations.Append(string.Format("{0}:{1},", topPercent, leftPercent));

                    if (isVertical)
                    {
                        row++;
                        if (row >= rowCount)
                        {
                            row    = 0;
                            column = startOnLeft ? ++column : --column;
                        }
                    }
                    else
                    {
                        if (startOnLeft)
                        {
                            column++;
                            if (column >= columnCount)
                            {
                                column = 0;
                                row   += 1;
                            }
                        }
                        else
                        {
                            column--;
                            if (column < 0)
                            {
                                column = columnCount - 1;
                                row   += 1;
                            }
                        }
                    }
                }

                groupBox.Height = topOfLastControlDown + (int)(tallestControlHeight * 1.9);
                field.ControlHeightPercentage = 1.0 * groupBox.Height / canvasSize.Height;
            }

            field.Pattern   = pattern.ToString().TrimEnd(new char[] { ',' });
            field.Locations = locations.ToString().TrimEnd(new char[] { ',' });
            field.SaveToDb();

            SetControlProperties(groupBox, field, canvasSize);

            List <Control> controls = new List <Control>();

            controls.Add(groupBox);
            return(controls);
        }
Exemple #17
0
 public AdjacentAllyConstraint(OptionField option, Unit unit)
 {
     this.option = option;
     this.unit   = unit;
     description = "If there is an adjacent ally";
 }
Exemple #18
0
 private Sprite GetSpriteForOptionField(OptionField optionField)
 {
     return(GetSpriteForOption(optionField.option, optionField.unit));
 }
Exemple #19
0
 public UnitHopConstraint(OptionField option, Unit unit)
 {
     this.option = option;
     this.unit   = unit;
     description = "If there is a unit in between";
 }
Exemple #20
0
 internal OptionFieldAccess(OptionType optionType, OptionField field)
 {
     this.optionType = optionType;
     this.field      = field;
 }
 public static HrbcField ToField(this OptionField optionField)
 {
     return(new HrbcField(ResourceId.None, optionNames[optionField], ResourceType.Option));
 }
Exemple #22
0
 public void SetFieldToNull(OptionField field)
 {
     _nullFields = _nullFields | (int)field;
 }
 public static bool IsField(this OptionField optionField, HrbcField field)
 {
     return(field.ResourceType == ResourceType.Option && field.Resource == ResourceId.None && optionNames.ContainsKey(optionField) && optionNames[optionField] == field.Name);
 }
Exemple #24
0
 public void SetFieldToNull(OptionField field)
 {
     _nullFields = _nullFields | (int)field;
 }
Exemple #25
0
        /// <summary>
        /// Handles the DoWorker event for the worker
        /// </summary>
        /// <param name="sender">Object that fired the event</param>
        /// <param name="e">.NET supplied event parameters</param>
        private void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            lock (syncLock)
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToProcessingState));
                this.Dispatcher.BeginInvoke(new SimpleCallback(ClearResults));

                AddLineListGridDelegate addGrid = new AddLineListGridDelegate(AddLineListGrid);

                Configuration config   = DashboardHelper.Config;
                string        yesValue = config.Settings.RepresentationOfYes;
                string        noValue  = config.Settings.RepresentationOfNo;

                try
                {
                    DataTable dictionaryTable = DashboardHelper.FieldTable.Copy();

                    foreach (KeyValuePair <string, string> kvp in DashboardHelper.TableColumnNames)
                    {
                        DataRow row = dictionaryTable.Rows.Find(kvp.Key);
                        if (row == null)
                        {
                            dictionaryTable.Rows.Add(kvp.Key, kvp.Value);
                        }
                    }

                    if (DashboardHelper.IsUsingEpiProject)
                    {
                        dictionaryTable.Columns.Add("Page", typeof(int));
                        dictionaryTable.Columns.Add("Tab", typeof(int));
                        dictionaryTable.Columns.Add("Prompt", typeof(string));
                        dictionaryTable.Columns.Add("Items", typeof(string));
                        dictionaryTable.Columns.Add("FieldType", typeof(string));

                        foreach (DataRow fieldRow in dictionaryTable.Rows)
                        {
                            if (fieldRow["epifieldtype"] is RenderableField)
                            {
                                RenderableField renderableField = fieldRow["epifieldtype"] as RenderableField;
                                fieldRow["Page"]      = renderableField.Page.Position + 1;
                                fieldRow["Tab"]       = renderableField.TabIndex;
                                fieldRow["Prompt"]    = renderableField.PromptText;
                                fieldRow["FieldType"] = fieldRow["epifieldtype"].ToString().Replace("Epi.Fields.", String.Empty);
                                if (renderableField is GroupField)
                                {
                                    GroupField groupField = renderableField as GroupField;
                                    fieldRow["Items"] = groupField.ChildFieldNames;
                                }
                                else if (renderableField is OptionField)
                                {
                                    OptionField optionField = renderableField as OptionField;
                                    fieldRow["Items"] = optionField.GetOptionsString();
                                }
                            }
                            fieldRow["datatype"] = fieldRow["datatype"].ToString().Replace("System.", String.Empty);
                        }

                        dictionaryTable.Columns["columnname"].SetOrdinal(0);
                        dictionaryTable.Columns["Prompt"].SetOrdinal(1);
                        dictionaryTable.Columns["formname"].SetOrdinal(2);
                        dictionaryTable.Columns["Page"].SetOrdinal(3);
                        dictionaryTable.Columns["Tab"].SetOrdinal(4);
                        dictionaryTable.Columns["datatype"].SetOrdinal(5);
                        dictionaryTable.Columns["FieldType"].SetOrdinal(6);
                        dictionaryTable.Columns["tablename"].SetOrdinal(7);
                        dictionaryTable.Columns["Items"].SetOrdinal(8);
                    }

                    if (dictionaryTable == null || dictionaryTable.Rows.Count == 0)
                    {
                        this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), "There are no valid fields to display.");
                    }
                    else if (worker.CancellationPending)
                    {
                        this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), SharedStrings.DASHBOARD_GADGET_STATUS_OPERATION_CANCELLED);
                        this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToFinishedState));
                        Debug.Print("Data dictionary thread cancelled");
                        return;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(addGrid, dictionaryTable.AsDataView());
                        string formatString = string.Empty;
                    }

                    this.Dispatcher.BeginInvoke(new SimpleCallback(RenderFinish));
                    this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToFinishedState));
                }
                catch (Exception ex)
                {
                    this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), ex.Message);
                    this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToFinishedState));
                }
                finally
                {
                    stopwatch.Stop();
                    Debug.Print("Data dictionary gadget took " + stopwatch.Elapsed.ToString() + " seconds to complete with " + DashboardHelper.RecordCount.ToString() + " records and the following filters:");
                    Debug.Print(DashboardHelper.DataFilters.GenerateDataFilterString());
                }
            }
        }