Exemple #1
0
 public Command(ElemListItem listItem)
 {
     IAction  = listItem.Action;
     IName    = listItem.ElemName;
     IClass   = listItem.ElemClass;
     IAutoID  = listItem.ElemAutoID;
     IWinName = listItem.WinName;
     IData    = listItem.Data;
 }
Exemple #2
0
        public static Hashtable ElemListItemToHash(ElemListItem listItem)
        {
            Hashtable ElemHash = new Hashtable();

            PropertyInfo[] properties = listItem.GetType()
                                        .GetProperties();
            foreach (PropertyInfo prop in properties)
            {
                ElemHash.Add(prop.Name, prop.GetValue(listItem));
            }

            return(ElemHash);
        }
Exemple #3
0
        public static ElemListItem HashToElemListItem(Hashtable hash)
        {
            ElemListItem ElemLItem = new ElemListItem()
            {
                Action     = (string)hash["Action"],
                ElemAutoID = (string)hash["AutoID"],
                ElemClass  = (string)hash["Class"],
                ElemName   = (string)hash["Name"],
                WinName    = (string)hash["WinName"],
                Data       = (string)hash["Data"],
            };

            return(ElemLItem);
        }
Exemple #4
0
        private void lstElemList_DoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            DependencyObject obj      = (DependencyObject)e.OriginalSource;
            Hashtable        ElemHash = new Hashtable();

            while (obj != null && obj != lstElemList)
            {
                if (obj.GetType() == typeof(ListViewItem))
                {
                    ElemListItem   Selected   = (ElemListItem)lstElemList.SelectedItem;
                    PropertyInfo[] properties = Selected.GetType()
                                                .GetProperties();
                    foreach (PropertyInfo prop in properties)
                    {
                        ElemHash.Add(prop.Name, prop.GetValue(Selected));
                    }
                }
                obj = VisualTreeHelper.GetParent(obj);
            }

            MessageBox.Show(TypeConverter.HashToString(ElemHash));
        }
Exemple #5
0
        private void BtnSubControl_Click(object sender, RoutedEventArgs e, Hashtable _ElemHash, Button Btn, string[] SubMenuActions)
        {
            //MessageBox.Show(Btn.Content.ToString());
            //If the data needed for selected action is not null, show the window and ask for
            //needed details.
            if (!(SubMenuActions.Length == 0))
            {
                dataWindow.stkDataLabel.Children.Clear(); dataWindow.stkDataText.Children.Clear();
                LayControls(dataWindow.stkDataLabel, dataWindow.stkDataText, SubMenuActions, Btn, _ElemHash);

                dataWindow.Title = Btn.Content.ToString();
                dataWindow.Show();
            }
            //Else, do not show the DataWindow and proceed with adding the data.
            else
            {
                ElemListItem ToAdd = new ElemListItem(Btn.Content.ToString(), _ElemHash, null);
                Command.RunItem(ToAdd, 10);
                lstElemList.Items.Add(ToAdd);
            }
            patternWin.Hide();
        }
Exemple #6
0
        private void BtnAddData_Click(object sender, RoutedEventArgs e)
        {
            List <string>       Data         = new List <string>();
            UIElementCollection stkTextBoxes = dataWindow.stkDataText.Children;

            foreach (UIElement stkTextBox in stkTextBoxes)
            {
                Data.Add(((TextBox)stkTextBox).Text);
            }
            string Datum = string.Join(",", Data);

            ElemListItem ToAdd = new ElemListItem(buttToDataWin.Content.ToString(), _elHashToDataWin, Datum);

            //MessageBox.Show(buttToDataWin.Content.ToString());

            Command.RunItem(ToAdd, 10);
            lstElemList.Items.Add(ToAdd);
            dataWindow.Hide();

            //Handling and setting needed data back to normal
            e.Handled        = true;
            buttToDataWin    = null;
            _elHashToDataWin = null;
        }
Exemple #7
0
        public static void RunItem(ElemListItem listItem, int TimeOut)
        {
            string IAction  = listItem.Action;
            string IName    = listItem.ElemName;
            string IClass   = listItem.ElemClass;
            string IAutoID  = listItem.ElemAutoID;
            string IWinName = listItem.WinName;
            string IData    = listItem.Data;
            string Ixml     = listItem.ElemXMLTree;

            //UIControl UI = new UIControl(IWinName, IName, IClass, IAutoID, TimeOut);
            UIControl UI      = new UIControl(Ixml);
            var       Element = UI._WinElem;

            if (Element != null)
            {
                switch (IAction)
                {
                case "InvokeClick":
                    GetPattern.GetInvokePattern(Element).Invoke();
                    break;

                case "Expand":
                    GetPattern.GetExpandCollapsePattern(Element).Expand();
                    break;

                case "Collapse":
                    GetPattern.GetExpandCollapsePattern(Element).Collapse();
                    break;

                case "WinMaxState":
                    GetPattern.GetWindowPattern(Element).SetWindowVisualState(WindowVisualState.Maximized);
                    break;

                case "WinMinState":
                    GetPattern.GetWindowPattern(Element).SetWindowVisualState(WindowVisualState.Minimized);
                    break;

                case "WinNormalState":
                    GetPattern.GetWindowPattern(Element).SetWindowVisualState(WindowVisualState.Normal);
                    break;

                case "Scroll":
                    string[]     XnY = IData.Split(',');
                    ScrollAmount X   = (ScrollAmount)Enum.Parse(typeof(ScrollAmount), XnY[0]);
                    ScrollAmount Y   = (ScrollAmount)Enum.Parse(typeof(ScrollAmount), XnY[1]);
                    GetPattern.GetScrollPattern(Element).Scroll(X, Y);
                    break;

                case "ScrollHorizontal":
                    Y = (ScrollAmount)Enum.Parse(typeof(ScrollAmount), IData);
                    GetPattern.GetScrollPattern(Element).ScrollHorizontal(Y);
                    break;

                case "ScrollVertical":
                    X = (ScrollAmount)Enum.Parse(typeof(ScrollAmount), IData);
                    GetPattern.GetScrollPattern(Element).ScrollVertical(X);
                    break;

                case "SetScrollPercent":
                    double horPer = double.Parse(IData.Split(',')[0]);
                    double verPer = double.Parse(IData.Split(',')[1]);
                    GetPattern.GetScrollPattern(Element).SetScrollPercent(horPer, verPer);
                    break;

                case "ScrollToView":
                    GetPattern.GetScrollItemPattern(Element).ScrollIntoView();
                    break;

                case "SetElemText":
                    GetPattern.GetValuePattern(Element).SetValue(IData);
                    break;

                case "GetSelectedText":
                    throw new NotImplementedException();

                case "Toggle":
                    GetPattern.GetTogglePattern(Element).Toggle();
                    break;

                case "ElementClick":
                    UIControl.ElemClick(Element, IData);
                    break;

                case "MouseToElement":
                    UIControl.MouseToElem(Element);
                    break;

                //Wait disappear and appear to be implemented.

                case "UseKeyboard":
                    string Text    = IData.Split(',')[0];
                    string ToClick = IData.Split(',')[1].ToLower();
                    bool   Click;

                    if (ToClick == "yes" || ToClick == "true")
                    {
                        UIControl.SendKeys(Element, Text, true);
                    }
                    else if (ToClick == "no" || ToClick == "false")
                    {
                        UIControl.SendKeys(Element, Text, false);
                    }
                    else
                    {
                        Console.WriteLine($"Invalid value. Data given {IData}");
                    }
                    break;
                }
            }

            else
            {
                Console.WriteLine($"Element not found.\nName: {IName}\n" +
                                  $"Class: {IClass}\nAutoID: {IAutoID}\nWindow: {IWinName}");
            }
        }