Exemple #1
0
 /// <summary>
 /// Finishes the table and the contained objects (Effects, TableElements)
 /// </summary>
 public void Finish()
 {
     AssignedStaticEffects.Finish();
     TableElements.FinishAssignedEffects();
     Effects.Finish();
     Pinball = null;
 }
Exemple #2
0
        /// <summary>
        /// Gets all values from table and stores them in a list.
        /// </summary>
        /// <returns>List with all table values.</returns>
        public List <string> AllValues()
        {
            var result = new List <string>();

            var list = new TableElements().TableCells;

            foreach (Element cell in list)
            {
                if (cell.GetAttributeValueText("AccessibleName").Contains(";1") || cell.GetAttributeValueText("AccessibleName").Contains(";2") || cell.GetAttributeValueText("AccessibleName").Contains(";3"))
                {
                    result.Add(cell.GetAttributeValueText("AccessibleValue"));
                }
            }

            if (result.Count == 0)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Failed to store values in list.");
            }
            else
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Finished storing table values in list");
            }

            return(result);
        }
        private void UpdateTableElements()
        {
            DataTable DT = new DataTable();

            DT.Columns.Add("Type", typeof(string));
            DT.Columns.Add("Number", typeof(int));
            DT.Columns.Add("Name", typeof(string));
            DT.Columns.Add("Value", typeof(int));
            DT.Columns.Add("Assigned FX", typeof(int));

            if (Pinball != null)
            {
                foreach (TableElement E in Pinball.Table.TableElements)
                {
                    DT.Rows.Add(((TableElementTypeEnum)E.TableElementType).ToString(), E.Number, E.Name, E.Value, E.AssignedEffects.Count);
                }
            }
            ;

            DT.DefaultView.Sort = "Type ASC, Number ASC";
            TableElements.ClearSelection();
            TableElements.Columns.Clear();
            TableElements.AutoGenerateColumns = true;
            TableElements.DataSource          = DT;
            TableElements.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);

            //TableElements.Refresh();
        }
Exemple #4
0
        /// <summary>
        /// Initializes the table and the contained objects(Effects, TableElements).
        /// </summary>
        /// <param name="Pinball">The Pinball object containing the Table.</param>
        public void Init(Pinball Pinball)
        {
            this.Pinball = Pinball;
            Effects.Init(this);

            TableElements.InitAssignedEffects(this);
            AssignedStaticEffects.Init(this);
        }
Exemple #5
0
 /// <summary>
 /// Scrolls to top of event list so that first event is visible (via keyboard up).
 /// </summary>
 /// <param name="treeItemsEventList">
 /// The tree Items Event List.
 /// </param>
 private void ScrollToTop(IList <TreeItem> treeItemsEventList)
 {
     try
     {
         Element tree = new TableElements().EventListTree;
         Mouse.Click(tree, Location.Center);
         while (treeItemsEventList[0].Visible == false)
         {
             Keyboard.Press(Keys.Up);
         }
     }
     catch (Exception exception)
     {
         Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
     }
 }
Exemple #6
0
        /// <summary>
        /// Counts the events.
        /// </summary>
        /// <returns>Number of the events.</returns>
        private int CountEvents()
        {
            int result = 0;
            IList <TreeItem> treeItemsEventList = new TableElements().GetHistoRomEventList();

            if (treeItemsEventList == null || treeItemsEventList.Count == 0)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "EventList does not exist");
            }
            else
            {
                this.ScrollToLastEvent(treeItemsEventList);
                Cell eventNumber = treeItemsEventList[treeItemsEventList.Count - 1].FindChild <Cell>();
                result = Convert.ToInt32(eventNumber.Text);
            }

            return(result);
        }
Exemple #7
0
        /// <summary>
        /// Returns the value for a specified row and column
        /// </summary>
        /// <param name="row">
        /// The row.
        /// </param>
        /// <param name="column">
        /// The column.
        /// </param>
        /// <returns>
        /// The value for the row and column.
        /// </returns>
        public string SingleValue(int row, int column)
        {
            string result = string.Empty;

            var list = new TableElements().TableCells;

            foreach (Element cell in list)
            {
                if (cell.GetAttributeValueText("AccessibleName") == (row - 1) + ";" + column)
                {
                    result = cell.GetAttributeValueText("AccessibleValue");
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Value for row " + row + " column " + column + " = " + result);
                    break;
                }
            }

            if (result == string.Empty)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Failed to get value for row " + row + " column " + column);
            }

            return(result);
        }
Exemple #8
0
        /// <summary>
        /// Initializes the table and the contained objects(Effects, TableElements).
        /// </summary>
        /// <param name="Pinball">The Pinball object containing the Table.</param>
        public void Init(Pinball Pinball)
        {
            this.Pinball = Pinball;

            FileInfo ShapeDefinitionFile = Pinball.GlobalConfig.GetShapeDefinitionFile();

            if (ShapeDefinitionFile != null && ShapeDefinitionFile.Exists)
            {
                Log.Write("Loading shape definition file: {0}".Build(ShapeDefinitionFile.FullName));
                try
                {
                    ShapeDefinitions = ShapeDefinitions.GetShapeDefinitionsFromShapeDefinitionsXmlFile(ShapeDefinitionFile);
                }
                catch (Exception E)
                {
                    Log.Exception("Loading shape definition file {0} failed.".Build(ShapeDefinitionFile.FullName), E);
                }
                ShapeDefinitions.BitmapFilePattern = new General.FilePattern(ShapeDefinitionFile.FullName.Substring(0, ShapeDefinitionFile.FullName.Length - ShapeDefinitionFile.Extension.Length) + ".png");
            }
            else
            {
                if (ShapeDefinitionFile == null)
                {
                    Log.Warning("Could not determin name of shape definition file");
                }
                else
                {
                    Log.Warning("Shape definition file {0} does not exist");
                }
                ShapeDefinitions = new ShapeDefinitions();
            }

            Effects.Init(this);

            TableElements.InitAssignedEffects(this);
            AssignedStaticEffects.Init(this);
        }
        /// <summary>
        /// Sets all table values provided from a list.
        /// </summary>
        /// <param name="inputValues">
        /// The input values.
        /// </param>
        /// <returns>
        /// <c>true</c> if values have been set, <c>false</c> otherwise.
        /// </returns>
        public bool SetValues(List <string> inputValues)
        {
            if (inputValues.Count % 2 != 0)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Your list has an odd number of values. Please use an even number of values.");
                return(false);
            }

            Cell firstCell = new TableElements().TableCell(0, 1);

            firstCell.DoubleClick(500);

            for (int counter = 0; counter < inputValues.Count / 2; counter++)
            {
                Keyboard.Press(inputValues[counter * 2]);
                Keyboard.Press(Keys.Enter);

                Thread.Sleep(500);
            }

            Keyboard.Press(Keys.Right);

            for (int i = 0; i < inputValues.Count / 2; i++)
            {
                Keyboard.Press(Keys.Up);
            }

            for (int counter = 0; counter < inputValues.Count / 2; counter++)
            {
                Keyboard.Press(inputValues[(counter * 2) + 1]);
                Keyboard.Press(Keys.Enter);
                Thread.Sleep(500);
            }

            return(true);
        }
Exemple #10
0
        /// <summary>
        ///     Reads the entire event list and creates a list with the events
        /// </summary>
        /// <returns>
        ///     <br>IList: if event list was created successfully</br>
        ///     <br>Null: if an error occurred</br>
        /// </returns>
        public IList <IEvent> ReadEvents()
        {
            try
            {
                IList <IEvent>   listEvent          = new List <IEvent>();
                IList <TreeItem> treeItemsEventList = new TableElements().GetHistoRomEventList();
                if (treeItemsEventList != null && treeItemsEventList.Count != 0)
                {
                    // make sure first event is visible
                    this.ScrollToTop(treeItemsEventList);

                    int index;
                    for (index = 0; index < treeItemsEventList.Count; index++)
                    {
                        TreeItem        treeItemEvent = treeItemsEventList[index];
                        IList <Unknown> listCells     = treeItemEvent.Children;
                        if (listCells == null || listCells.Count == 0)
                        {
                            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "No children cells available");
                        }
                        else
                        {
                            /*Checks if first cell of actual tree item has no text
                             * This is the case if the description of an event needs more than one row
                             */
                            if (listCells[Id].As <Cell>().Text.Equals(string.Empty))
                            {
                                // check if list is empty if it is, cell of first row (event) is empty -> failure
                                if (listEvent.Count == 0)
                                {
                                    Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "List empty ?,First cell of first row is empty");
                                }
                                else
                                {
                                    // cell "row" is empty, list is not empty ->add description to previous event:
                                    int lastEventIndex = listEvent.Count - 1;
                                    this.CreateEventDescription(listCells, listEvent[lastEventIndex]);
                                }
                            }
                            else
                            {
                                // normal event, add to list :
                                listEvent.Add(this.CreateEvent(listCells));
                            }

                            // if last element in list is visible,  no scroll needed
                            if (treeItemsEventList[treeItemsEventList.Count - 1].Visible == false)
                            {
                                this.ScrollDown();
                            }
                        }
                    }

                    return(listEvent);
                }

                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "List is empty!");
                return(null);
            }
            catch (Exception exception)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(null);
            }
        }
Exemple #11
0
 /// <summary>
 /// Updates the TableElements list with data received from Pinmame.
 /// </summary>
 /// <param name="Data">Data received from Pinmame and handled by the PinMameInputManger</param>
 public void UpdateTableElement(TableElementData Data)
 {
     TableElements.UpdateState(Data);
 }
Exemple #12
0
 /// <summary>
 /// Updates the TableElements list with data received from Pinmame.
 /// </summary>
 /// <param name="Data">Data received from Pinmame and handled by the PinMameInputManger</param>
 public void UpdateTableElement(TableElementData Data)
 {
     TableElements.UpdateState(Data.TableElementType, Data.Number, Data.Value);
 }