Exemplo n.º 1
0
 private void OnOperationChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!throwevent)
     {
         return;
     }
     if (this.PeriodItem == null)
     {
         this.PeriodItem = new PeriodItem(Index - 1);
     }
     this.PeriodItem.operationNumber      = numberValueTextBox.Text.Trim().ToUpper();
     this.PeriodItem.operationGranularity = granulartityComBox.SelectedItem.ToString();
     this.PeriodItem.operation            = operationComboBox.SelectedItem.ToString();
     if (!string.IsNullOrEmpty(this.numberValueTextBox.Text))
     {
         bool isValid = TagFormulaUtil.isSyntaxeFormulaCorrectly(this.numberValueTextBox.Text);
         if (!isValid)
         {
             int result;
             isValid = int.TryParse(this.numberValueTextBox.Text, out result);
             isValid = isValid ? result > 0 : false;
         }
         this.PeriodItem.operationNumber = isValid ? this.numberValueTextBox.Text : "";
     }
     if (Updated != null && update)
     {
         Updated(this);
     }
 }
Exemplo n.º 2
0
        public void Display(PeriodItem item)
        {
            update     = false;
            throwevent = false;
            bool enableForLoop = item.loop != null;

            if (enableForLoop)
            {
                this.SignComboBox.Width       = 100;
                this.SignComboBox.ItemsSource = new String[] {
                    DateOperator.DURING_PERIOD.sign, DateOperator.BEFORE_START_PERIOD.sign, DateOperator.BEFORE_END_PERIOD.sign,
                    DateOperator.AFTER_START_PERIOD.sign, DateOperator.AFTER_END_PERIOD.sign
                };
                this.SignComboBox.SelectedItem = DateOperator.DURING_PERIOD.sign;

                this.Label.Foreground          = Brushes.Red;
                this.FormulaTextBox.IsEnabled  = !enableForLoop;
                this.ValueDatePicker.IsEnabled = !enableForLoop;
                this.SignComboBox.IsEnabled    = true;
            }

            this.PeriodItem = item;
            if (item == null)
            {
                return;
            }
            this.Index         = item.position + 1;
            this.Label.Content = item.name != null ? item.name : "";
            if (item.value != null)
            {
                this.ValueDatePicker.SelectedDate = item.valueDateTime;
            }
            this.FormulaTextBox.Text = item.formula != null ? item.formula : "";
            if (!String.IsNullOrEmpty(item.operatorSign))
            {
                this.SignComboBox.SelectedItem = item.operatorSign;
            }
            if (!String.IsNullOrEmpty(item.operationGranularity))
            {
                this.granulartityComBox.SelectedItem = item.operationGranularity;
            }
            if (!String.IsNullOrEmpty(item.operation))
            {
                this.operationComboBox.SelectedItem = item.operation;
            }
            if (!String.IsNullOrEmpty(item.operationNumber))
            {
                int number;
                if (!TagFormulaUtil.isFormula(item.operationNumber))
                {
                    bool ok = int.TryParse(item.operationNumber, out number);
                    item.operationNumber = (ok && number > 0) ? "" + number : "";
                }
                this.numberValueTextBox.Text = item.operationNumber;
            }

            update     = true;
            throwevent = true;
        }
Exemplo n.º 3
0
        public void Display(PeriodItem item)
        {
            update          = false;
            this.PeriodItem = item;
            if (item == null)
            {
                return;
            }
            this.Index            = item.position + 1;
            this.NameTextBox.Text = item.name != null ? item.name : "";
            if (item.value != null)
            {
                this.ValueDatePicker.SelectedDate = item.valueDateTime;
            }
            this.FormulaTextBox.Text = item.formula != null ? item.formula : "";
            if (!String.IsNullOrEmpty(item.operatorSign))
            {
                this.SignComboBox.SelectedItem = item.operatorSign;
            }
            if (!String.IsNullOrEmpty(item.operationGranularity))
            {
                this.granulartityComBox.SelectedItem = item.operationGranularity;
            }
            if (!String.IsNullOrEmpty(item.operation))
            {
                this.operationComboBox.SelectedItem = item.operation;
            }
            if (!String.IsNullOrEmpty(item.operationNumber))
            {
                int number;
                if (!TagFormulaUtil.isFormula(item.operationNumber))
                {
                    bool ok = int.TryParse(item.operationNumber, out number);
                    item.operationNumber = (ok && number > 0) ? "" + number : "";
                }
                this.numberValueTextBox.Text = item.operationNumber;
            }
            bool enableForLoop = item.loop != null;

            if (enableForLoop)
            {
                this.NameTextBox.Text             = item.loop.name;
                this.NameTextBox.Foreground       = Brushes.Red;
                this.numberValueTextBox.IsEnabled = !enableForLoop;
                this.FormulaTextBox.IsEnabled     = !enableForLoop;
                this.granulartityComBox.IsEnabled = !enableForLoop;
                this.operationComboBox.IsEnabled  = !enableForLoop;
                this.ValueDatePicker.IsEnabled    = !enableForLoop;
                this.SignComboBox.IsEnabled       = !enableForLoop;
            }
            update = true;
        }
Exemplo n.º 4
0
        private void OnValueSelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!throwevent)
            {
                return;
            }
            bool added = false;

            if (this.ValueDatePicker.SelectedDate.HasValue)
            {
                if (this.PeriodItem == null)
                {
                    this.PeriodItem = new PeriodItem(Index - 1);
                    added           = true;
                }
                this.PeriodItem.value = this.ValueDatePicker.SelectedDate.Value.ToShortDateString();
                this.PeriodItem.operationGranularity = this.granulartityComBox.SelectedItem.ToString();
                if (string.IsNullOrEmpty(this.PeriodItem.operationDate))
                {
                    String sign = this.SignComboBox.SelectedItem.ToString();
                    if (DateOperator.getBySign(sign) != null)
                    {
                        this.PeriodItem.operationDate = DateOperator.getBySign(sign).name;
                    }
                }
                if (!string.IsNullOrEmpty(this.numberValueTextBox.Text))
                {
                    bool isValid = TagFormulaUtil.isSyntaxeFormulaCorrectly(this.numberValueTextBox.Text);
                    if (!isValid)
                    {
                        int result;
                        isValid = int.TryParse(this.numberValueTextBox.Text, out result);
                    }
                    this.PeriodItem.operationNumber = isValid ? this.numberValueTextBox.Text : "";
                }
                this.PeriodItem.operation = this.operationComboBox.SelectedItem.ToString();
            }
            else
            {
                this.PeriodItem.value = null;
            }
            if (Added != null && added && update)
            {
                Added(this);
            }
            else if (Updated != null && update)
            {
                Updated(this);
            }
        }
Exemplo n.º 5
0
        private void OnValidateFormula(object sender, KeyEventArgs e)
        {
            if (!throwevent)
            {
                return;
            }
            if (this.PeriodItem == null)
            {
                this.PeriodItem = new PeriodItem(Index - 1);
            }
            if (ValueDatePicker.SelectedDate.HasValue)
            {
                this.PeriodItem.valueDateTime = ValueDatePicker.SelectedDate.Value;
            }

            this.PeriodItem.operationGranularity = this.granulartityComBox.SelectedItem.ToString();
            if (string.IsNullOrEmpty(this.PeriodItem.operationDate))
            {
                String sign = this.SignComboBox.SelectedItem.ToString();
                if (DateOperator.getBySign(sign) != null)
                {
                    this.PeriodItem.operationDate = DateOperator.getBySign(sign).name;
                }
            }
            if (!string.IsNullOrEmpty(this.numberValueTextBox.Text))
            {
                bool isValid = TagFormulaUtil.isSyntaxeFormulaCorrectly(this.numberValueTextBox.Text);
                if (!isValid)
                {
                    int result;
                    isValid = int.TryParse(this.numberValueTextBox.Text, out result);
                }
                this.PeriodItem.operationNumber = isValid ? this.numberValueTextBox.Text : "";
            }
            this.PeriodItem.operation = this.operationComboBox.SelectedItem.ToString();

            this.PeriodItem.formula = FormulaTextBox.Text.Trim().ToUpper();
            if (e.Key == Key.Enter && ValidateFormula != null && update)
            {
                ValidateFormula(this);
            }
        }
Exemplo n.º 6
0
        protected void completeCell(CellProperty cellProperty)
        {
            if (cellProperty.cellScope != null)
            {
                cellProperty.cellScope.targetItemListChangeHandler.Items = cellProperty.cellScope.targetItemListChangeHandler.getItems();
                foreach (TargetItem item in cellProperty.cellScope.targetItemListChangeHandler.Items)
                {
                    if (TagFormulaUtil.isFormula(item.formula) && item.value == null)
                    {
                        System.Windows.Point coord = TagFormulaUtil.getCoordonne(TagFormulaUtil.getFormulaWithoutEqualSign(item.formula));
                        item.value      = new Target();
                        item.value.name = GetValue((int)coord.X, (int)coord.Y, cellProperty.nameSheet);
                    }
                    cellProperty.cellScope.buildName();
                }
            }

            if (cellProperty.cellMeasure != null && TagFormulaUtil.isFormula(cellProperty.cellMeasure.formula) && cellProperty.cellMeasure.measure == null)
            {
                if (TagFormulaUtil.isFormula(cellProperty.cellMeasure.formula) && cellProperty.cellMeasure.measure == null)
                {
                    System.Windows.Point coord = TagFormulaUtil.getCoordonne(TagFormulaUtil.getFormulaWithoutEqualSign(cellProperty.cellMeasure.formula));
                    String measureName         = GetValue((int)coord.X, (int)coord.Y, cellProperty.nameSheet);
                    cellProperty.cellMeasure.name = measureName;
                }
            }

            if (cellProperty.period != null)
            {
                cellProperty.period.itemListChangeHandler.Items = cellProperty.period.itemListChangeHandler.getItems();
                foreach (PeriodItem item in cellProperty.period.itemListChangeHandler.Items)
                {
                    if (TagFormulaUtil.isFormula(item.formula) && item.value == null)
                    {
                        System.Windows.Point coord = TagFormulaUtil.getCoordonne(TagFormulaUtil.getFormulaWithoutEqualSign(item.formula));
                        item.value = GetValue((int)coord.X, (int)coord.Y, cellProperty.nameSheet);
                    }
                    cellProperty.period.BuildName();
                }
            }
        }