示例#1
0
        private void UpdateActionInfo(ActUIElement.eElementAction SelectedAction)
        {
            // TODO - Add case for KeyboardChange event for LocateValue
            // TODO - Add KeyboardChangeEventHandler for LocateValueEditPage

            ActionInfoLabel.Text = string.Empty;
            TextBlockHelper text = new TextBlockHelper(ActionInfoLabel);

            ActionInfoLabel.Visibility = Visibility.Visible;
            if (mAction.ElementType.ToString() != null && mAction.ElementType.ToString() != "" && mAction.ElementType != eElementType.Unknown)
            {
                text.AddBoldText("Select " + mAction.ElementType.ToString() + " ");
                if (mAction.ElementLocateBy.ToString() != null && mAction.ElementLocateBy.ToString() != "" && mAction.ElementLocateBy.ToString() != ActUIElement.eElementAction.Unknown.ToString())
                {
                    text.AddBoldText(mAction.ElementLocateBy.ToString().ToLower());
                }

                if (SelectedAction.ToString() != null && SelectedAction.ToString() != ActUIElement.eElementAction.Unknown.ToString())
                {
                    text.AddUnderLineText(" to perform " + SelectedAction.ToString() + " operation");
                }
            }
            else
            {
                if (mAction.ElementLocateBy.ToString() != null && mAction.ElementLocateBy.ToString() != "" && mAction.ElementLocateBy.ToString() != ActUIElement.eElementAction.Unknown.ToString())
                {
                    text.AddBoldText("  " + mAction.ElementLocateBy.ToString());
                }
                if (mAction.TargetLocateBy.ToString() != null && mAction.TargetLocateBy.ToString() != "" && mAction.TargetLocateBy.ToString() != ActUIElement.eElementAction.Unknown.ToString())
                {
                    text.AddBoldText("  " + mAction.TargetLocateBy.ToString());
                }
                if (mAction.TargetElementType.ToString() != null && mAction.TargetElementType.ToString() != "" && mAction.TargetElementType.ToString() != ActUIElement.eElementAction.Unknown.ToString())
                {
                    if (!string.IsNullOrEmpty(text.GetText()))
                    {
                        text.AddBoldText("  " + mAction.TargetElementType.ToString());
                    }
                    else
                    {
                        text.AddBoldText("  " + mAction.ElementType.ToString());
                    }
                }
                if (mAction.ElementType.ToString() != null && mAction.ElementType.ToString() != "" && mAction.ElementType.ToString() != ActUIElement.eElementAction.Unknown.ToString())
                {
                    if (!string.IsNullOrEmpty(text.GetText()))
                    {
                        text.AddBoldText("  " + mAction.ElementType.ToString());
                    }
                    else
                    {
                        text.AddBoldText("  " + mAction.ElementType.ToString());
                    }
                }
                if (SelectedAction.ToString() != null && SelectedAction.ToString() != "" && SelectedAction != ActUIElement.eElementAction.Unknown)
                {
                    text.AddUnderLineText("  " + SelectedAction.ToString() + " operation");
                }
            }
        }
        private void ShowSpecificHelp(string title, string category, string helpContentName, string helpContent, string helpExtraInfo = null)
        {
            xHelpPanelText.Text = string.Empty;
            TextBlockHelper TBH = new TextBlockHelper(xHelpPanelText);

            TBH.AddUnderLineText("Help:");
            TBH.AddLineBreak();

            TBH.AddBoldText(title);
            if (!String.IsNullOrEmpty(category))
            {
                TBH.AddLineBreak();
                TBH.AddText(category);
            }
            if (!String.IsNullOrEmpty(helpContentName))
            {
                TBH.AddLineBreak();
                TBH.AddText(helpContentName + ":");
            }
            if (!String.IsNullOrEmpty(helpContent))
            {
                TBH.AddLineBreak();
                TBH.AddText(helpContent);
            }
            if (!String.IsNullOrEmpty(helpExtraInfo))
            {
                TBH.AddLineBreak();
                TBH.AddText(helpExtraInfo);
            }
        }
        private void ShowVBSWarnHelp()
        {
            xHelpPanelText.Text = string.Empty;
            TextBlockHelper TBH = new TextBlockHelper(xHelpPanelText);

            TBH.AddUnderLineText("Help:");
            TBH.AddLineBreak();

            string msg = "Value Expression Contains VBS Operation."
                         + Environment.NewLine +
                         "VBS operations are slow and works only on Windows OS, please consider changing it to CS expression.";;

            TBH.AddFormattedText(msg, Brushes.OrangeRed);
        }
        private void ShowDefaultHelp()
        {
            xHelpPanelText.Text = string.Empty;
            TextBlockHelper TBH = new TextBlockHelper(xHelpPanelText);

            TBH.AddUnderLineText("Help:");
            TBH.AddLineBreak();

            string msg = "Enter expression like " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " from different levels, Environment Parameter or function which will be calculated in run time into dynamic value."
                         + Environment.NewLine + Environment.NewLine +
                         "Multiple expressions can be added together.";;

            TBH.AddText(msg);
        }
        private void SetDescriptionDetails()
        {
            try
            {
                if (txtDescription == null || cmbColSelectorValue.SelectedItem == null)
                {
                    return;
                }

                txtDescription.Text = string.Empty;
                TextBlockHelper TBH = new TextBlockHelper(txtDescription);

                TBH.AddText("Select the grid cell located by ");
                TBH.AddUnderLineText(cmbColSelectorValue.SelectedItem.ToString());
                TBH.AddText(" ");
                if (cmbColumnValue.SelectedIndex != -1)
                {
                    TBH.AddBoldText(cmbColumnValue.SelectedItem.ToString());
                }
                else
                {
                    TBH.AddBoldText(cmbColumnValue.Text);
                }
                TBH.AddText(" and ");
                if (RowNum.IsChecked == true)
                {
                    TBH.AddUnderLineText("row number ");
                    if (RowSelectorValue.SelectedIndex != -1)
                    {
                        TBH.AddBoldText(RowSelectorValue.SelectedItem.ToString());
                    }
                    else
                    {
                        TBH.AddBoldText(RowSelectorValue.Text);
                    }
                }
                else if (AnyRow.IsChecked == true)
                {
                    TBH.AddUnderLineText("random ");
                    TBH.AddText("row number");
                }
                else if (Where.IsChecked == true)
                {
                    TBH.AddText("the row located by a cell in ");
                    TBH.AddUnderLineText(WhereColumn.SelectedItem.ToString());
                    TBH.AddText(" ");
                    if (WhereColumnTitle.SelectedIndex != -1)
                    {
                        TBH.AddBoldText(WhereColumnTitle.SelectedItem.ToString());
                    }
                    else
                    {
                        TBH.AddBoldText(WhereColumnTitle.Text);
                    }
                    TBH.AddText(" having control property ");
                    TBH.AddUnderLineText(WhereProperty.SelectedItem.ToString());
                    TBH.AddText(" ");
                    TBH.AddUnderLineText(WhereOperator.SelectedItem.ToString());
                    TBH.AddText(" ");
                    TBH.AddBoldText(WhereColumnValue.ValueTextBox.Text);
                }
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed", ex);
            }
        }
        private void SetDependenciesHelper()
        {
            try
            {
                txtBlkDependenciesHelper.Text = string.Empty;
                TextBlockHelper TBH = new TextBlockHelper(txtBlkDependenciesHelper);

                //check if the mechanisem is enabeled
                switch (mDepededItemType)
                {
                case (eDependedItemsType.Actions):
                    if (((Activity)mParentObject).EnableActionsVariablesDependenciesControl == false)
                    {
                        TBH.AddFormattedText("The Actions-" + GingerDicser.GetTermResValue(eTermResKey.Variables) + " Dependencies control is disabled, in order to change the dependencies configurations you must enable it first.", Brushes.OrangeRed, true);
                        return;
                    }
                    break;

                case (eDependedItemsType.Activities):
                    if (((BusinessFlow)mParentObject).EnableActivitiesVariablesDependenciesControl == false)
                    {
                        TBH.AddFormattedText("The " + GingerDicser.GetTermResValue(eTermResKey.Activities) + "-" + GingerDicser.GetTermResValue(eTermResKey.Variables) + " Dependencies control is disabled, in order to change the dependencies configurations you must enable it first.", Brushes.OrangeRed, true);
                        return;
                    }
                    break;
                }


                //check for missing depended items/variables
                bool dependedItemsOrVarsAremissing = false;
                switch (mDepededItemType)
                {
                case (eDependedItemsType.Actions):
                    if (((Activity)mParentObject).Acts.Count == 0)
                    {
                        TBH.AddFormattedText("Add Actions to the " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " in order to configure dependencies.", Brushes.OrangeRed, true);
                        TBH.AddLineBreak();
                        dependedItemsOrVarsAremissing = true;
                    }
                    break;

                case (eDependedItemsType.Activities):
                    if (((BusinessFlow)mParentObject).Activities.Count == 0)
                    {
                        TBH.AddFormattedText("Add " + GingerDicser.GetTermResValue(eTermResKey.Activities) + " to the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " in order to configure dependencies.", Brushes.OrangeRed, true);
                        TBH.AddLineBreak();
                        dependedItemsOrVarsAremissing = true;
                    }
                    break;
                }

                if (mParentListVars == null || mParentListVars.Count == 0)
                {
                    switch (mDepededItemType)
                    {
                    case (eDependedItemsType.Actions):
                        TBH.AddFormattedText("Add " + GingerDicser.GetTermResValue(eTermResKey.Variables) + " from type 'Selection List' to the " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " in order to configure dependencies.", Brushes.OrangeRed, true);
                        break;

                    case (eDependedItemsType.Activities):
                        TBH.AddFormattedText("Add " + GingerDicser.GetTermResValue(eTermResKey.Variables) + " from type 'Selection List' to the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " in order to configure dependencies.", Brushes.OrangeRed, true);
                        break;
                    }
                    TBH.AddLineBreak();
                    dependedItemsOrVarsAremissing = true;
                }
                if (dependedItemsOrVarsAremissing)
                {
                    return;
                }

                //Set helper according to selected row
                DataRowView currentRow = (DataRowView)grdDependencies.grdMain.CurrentItem;
                if (currentRow != null)
                {
                    TBH.AddFormattedText("'" + currentRow.Row[0].ToString() + "'", null, true, true);
                    switch (mDepededItemType)
                    {
                    case (eDependedItemsType.Actions):
                        TBH.AddUnderLineText(" Action Dependencies Configurations Meaning:");
                        break;

                    case (eDependedItemsType.Activities):
                        TBH.AddUnderLineText(" " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " Dependencies Configurations Meaning:");
                        break;
                    }
                    TBH.AddLineBreak();
                    Dictionary <string, List <string> > actionConfigs = new Dictionary <string, List <string> >();
                    int colsIndex = 2;
                    foreach (VariableBase var in mParentListVars)
                    {
                        List <string> configuredVals = new List <string>();
                        foreach (OptionalValue optVal in ((VariableSelectionList)var).OptionalValuesList)
                        {
                            if ((bool)currentRow[colsIndex] == true)
                            {
                                configuredVals.Add(optVal.Value);
                            }
                            colsIndex++;
                        }
                        actionConfigs.Add(var.Name, configuredVals);
                    }
                    List <KeyValuePair <string, List <string> > > notConfiguredVars = actionConfigs.Where(d => d.Value.Count == 0).ToList();
                    if (notConfiguredVars.Count == 0)
                    {
                        switch (mDepededItemType)
                        {
                        case (eDependedItemsType.Actions):
                            TBH.AddText("The action will be executed only in case:");
                            break;

                        case (eDependedItemsType.Activities):
                            TBH.AddText("The " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " will be executed only in case:");
                            break;
                        }
                        TBH.AddLineBreak();
                        bool isFirst = true;
                        foreach (KeyValuePair <string, List <string> > configuredVar in actionConfigs)
                        {
                            if (!isFirst)
                            {
                                TBH.AddText("And");
                                TBH.AddLineBreak();
                            }
                            isFirst = false;
                            TBH.AddBoldText("'" + configuredVar.Key + "' ");
                            TBH.AddText(GingerDicser.GetTermResValue(eTermResKey.Variable) + " selected value is: ");
                            string vars = string.Empty;
                            foreach (string configVal in configuredVar.Value)
                            {
                                vars = vars + "'" + configVal + "' Or ";
                            }
                            vars = vars.Remove(vars.Length - 4, 4);
                            TBH.AddText(vars);
                            TBH.AddLineBreak();
                        }
                    }
                    else
                    {
                        switch (mDepededItemType)
                        {
                        case (eDependedItemsType.Actions):
                            TBH.AddFormattedText("The action won't be executed in any case because it missing dependency configurations for the " + GingerDicser.GetTermResValue(eTermResKey.Variable) + "/s: ", Brushes.OrangeRed, true);
                            break;

                        case (eDependedItemsType.Activities):
                            TBH.AddFormattedText("The " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " won't be executed in any case because it missing dependency configurations for the " + GingerDicser.GetTermResValue(eTermResKey.Variable) + "/s: ", Brushes.OrangeRed, true);
                            break;
                        }
                        TBH.AddLineBreak();
                        foreach (KeyValuePair <string, List <string> > notConfiguredVar in notConfiguredVars)
                        {
                            TBH.AddFormattedText("'" + notConfiguredVar.Key + "'", Brushes.OrangeRed);
                            TBH.AddLineBreak();
                        }
                    }
                }
                else
                {
                    TBH.AddText("Select cell/row for information.");
                }
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to set the " + mDepededItemType.ToString() + "-Variables dependencies helper text", ex);
            }
        }