Пример #1
0
        public void ShowProperties(object obj)
        {
            object selObj = obj;

            if (MainForm.PropertiesUserControl.SelectedObject == selObj)
            {
                return;
            }
            string caption = Locale.Get("_properties");

            if (obj is GObject)
            {
                GObject gobj = (GObject)obj;
                selObj  = new ObjectProps(gobj);
                caption = Locale.Get("_gobject");
                mainForm.TypesUserControl.SelectType(gobj.Type);
            }
            else if (obj is GType)
            {
                selObj  = new TypeProps((GType)obj);
                caption = Locale.Get("_gtype");
            }
            else if (obj is GLib)
            {
                selObj  = new LibProps((GLib)obj);
                caption = Locale.Get("_glib");
            }
            else if (obj is BgImage)
            {
                selObj  = new BgImageProps((BgImage)obj);
                caption = Locale.Get("_bgimage");
            }

/*			else if (obj is Config)
 *                      {
 *                              selObj = new OptionsProps((Config)obj);
 *                              caption = Locale.Get("_optionsprops");
 *                      }*/
            else if (obj is Stat)
            {
                selObj  = new StatProps((Stat)obj);
                caption = Locale.Get("_stat");
            }
            else if (obj is LibStatProps || obj is StatProps)
            {
                caption = Locale.Get("_stat");
            }
            StringUtils.RemoveHotKey(ref caption);
            MainForm.PropertiesUserControl.Text           = caption;
            MainForm.PropertiesUserControl.SelectedObject = selObj;
        }
Пример #2
0
        public static bool Save(int ID, int SeasonId, string SeasonTypeId, string Position, string PlayerName,
                                string GamesPlayed, string Record, string AvgMatchRating, string Goals, string Assists, string CleanSheets,
                                string ShotsOnGoal,
                                string ShotsOnTarget, string ShotPercentage, string Tackles, string TackleAttempts, string TacklePercentage,
                                string PassPercentage, string KeyPasses, string Interceptions, string Blocks,
                                string YellowCards, string RedCards, string ManOfTheMatch, string PlayerURL, string System,
                                string TeamIconURL, string Command)
        {
            var dbName    = "";
            var tableName = "";

            if (Command == "schedule")
            {
                dbName = "LGFA_Current.db";
                if (System == "xbox" || System == "psn")
                {
                    var currentSeasonId = int.Parse(Fetch.GetSeason(System));
                    if (currentSeasonId == SeasonId)
                    {
                        if (SeasonTypeId == "regular")
                        {
                            tableName = "CRS_Player";
                        }
                        else if (SeasonTypeId == "pre-season")
                        {
                            tableName = "CPS_Player";
                        }
                    }
                }
            }
            else if (Command == "uh")
            {
                if (System == "xbox" || System == "psn")
                {
                    var historicalSeason = SeasonId;
                    if (SeasonTypeId == "regular")
                    {
                        tableName = "HRS_Player" + SeasonId;
                        dbName    = "Historical_Reg_Player.db";
                    }
                    else if (SeasonTypeId == "pre-season")
                    {
                        tableName = "HPS_Player" + SeasonId;
                        dbName    = "Historical_Pre_Player.db";
                    }
                }
            }


            using (var database = new LiteDatabase(dbName))
            {
                var playerCollection = database.GetCollection <StatProps>(tableName);
                playerCollection.EnsureIndex(x => x.SeasonId);

                var playerStats = new StatProps
                {
                    SeasonId          = SeasonId,
                    Id                = ID,
                    TeamIcon          = TeamIconURL,
                    Position          = Position,
                    PlayerName        = PlayerName,
                    GamesPlayed       = GamesPlayed,
                    Record            = Record,
                    AvgMatchRating    = AvgMatchRating,
                    Goals             = Goals,
                    Assists           = Assists,
                    CleanSheets       = CleanSheets,
                    ShotsOnGoal       = ShotsOnGoal,
                    ShotsOnTarget     = ShotsOnTarget,
                    ShotPercentage    = ShotPercentage,
                    Tackles           = Tackles,
                    TackleAttempts    = TackleAttempts,
                    TacklePercentage  = TacklePercentage,
                    PassingPercentage = PassPercentage,
                    KeyPasses         = KeyPasses,
                    Interceptions     = Interceptions,
                    Blocks            = Blocks,
                    YellowCards       = YellowCards,
                    RedCards          = RedCards,
                    ManOfTheMatch     = ManOfTheMatch,
                    PlayerUrl         = PlayerURL,
                    PlayerSystem      = System,
                    SeasonTypeId      = SeasonTypeId,
                };
                try
                {
                    var playerFound = playerCollection.FindById(ID);
                    if (playerFound != null)
                    {
                        playerCollection.Update(playerStats);
                        return(true);
                    }
                    else
                    {
                        playerCollection.Insert(playerStats);
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Error saving Historical Stats to database");
                }
            }

            return(false);
        }
        public void SetStatVarProperties(string pCellContentType, int pIndex, DataOrientation pDataOrientation)
        {
            switch (pCellContentType)
            {
                // Load stat variables
                case CellContentType.StatVars:
                    this.StatVarProperties = Table.GetIndex(this.SelectedRange.Cells.Value, pIndex, pDataOrientation);
                    break;
                // Load stat dates
                case CellContentType.StatVars2:
                    this.StatVarProperties2 = Table.GetIndex(this.SelectedRange.Cells.Value, pIndex, pDataOrientation);
                    break;
                // Load stat dates
                case CellContentType.StatDatum:
                    this.StatDatumProperties = Table.GetIndex(this.SelectedRange.Cells.Value, pIndex, pDataOrientation);
                    break;
                // Load stat area IDs and names concatenated - note that this takes presedent over other stat area attributes
                case CellContentType.StatAreaIDsAndNames:
                    // Create three statvar props,
                    // One for ids and names concatenated
                    StatProps mIDsAndNames = Table.GetIndex(this.SelectedRange.Cells.Value, pIndex, pDataOrientation);
                    // One for ids alone
                    this.StatAreaIDsProperties = Table.GetIndex(this.SelectedRange.Cells.Value, pIndex, pDataOrientation);
                    // And one areas alone
                    this.StatAreaNameProperties = Table.GetIndex(this.SelectedRange.Cells.Value, pIndex, pDataOrientation);

                    // Loop through the values
                    foreach (int t in mIDsAndNames.Keys)
                    {
                        // Read the concatenated string
                        List<string> mStatAreaIDAndName = mIDsAndNames[t].ToString().Split(' ').ToList<string>();
                        if (mStatAreaIDAndName.Count() >= 1)
                        {
                            string mStatAreaID = mStatAreaIDAndName[0];
                            this.StatAreaIDsProperties[t] = mStatAreaID;

                            if (mStatAreaIDAndName.Count() >= 2)
                            {
                                mStatAreaIDAndName.RemoveAt(0);
                                string mStatAreaName = string.Join(" ", mStatAreaIDAndName);
                                this.StatAreaNameProperties[t] = mStatAreaName;
                            }
                        }
                    }
                    break;
                // Load stat area IDs
                case CellContentType.StatAreaIDs:
                    this.StatAreaIDsProperties = Table.GetIndex(this.SelectedRange.Cells.Value, pIndex, pDataOrientation);
                    break;
                // Load stat area names
                case CellContentType.StatAreaNames:
                    this.StatAreaNameProperties = Table.GetIndex(this.SelectedRange.Cells.Value, pIndex, pDataOrientation);
                    break;
                // Load stat area groups
                case CellContentType.StatAreaGroups:
                    this.StatAreaGroupProperties = Table.GetIndex(this.SelectedRange.Cells.Value, pIndex, pDataOrientation);
                    break;
            }
            return;
        }
        public void OnCellContenTypeComboBoxChangeCommit(ComboBox pChangedComboBox, DataOrientation pDataOrientation, int pIndex)
        {

            // Get the new value of the changed CB
            var mNewCellContentType = Util.GetComboBoxSelectedValueString(pChangedComboBox);

            // Create a list to store all currently selected CB values
            var mAssignedCellContentTypes = new List<string>();

            // For each of the comboboxes with data layout info
            foreach (ComboBox mComboBox in this.CellContentTypeComboBoxes)
            {
                // Get the current contents of col/row
                var mCellContentType = Util.GetComboBoxSelectedValueString(mComboBox);

                // For all but the current control
                if (mComboBox != pChangedComboBox &&
                    (mCellContentType != CellContentType.Values && mCellContentType != CellContentType.Ignore))
                {
                    if (mCellContentType == mNewCellContentType ||
                        mAssignedCellContentTypes.Contains(mCellContentType))
                    {
                        mComboBox.SelectedValue = CellContentType.Values;
                    }
                    mAssignedCellContentTypes.Add(mCellContentType);
                }
            }

            // Add the new type to the list of used types
            if (!mAssignedCellContentTypes.Contains(mNewCellContentType) &&
                (mNewCellContentType != CellContentType.Values && mNewCellContentType != CellContentType.Ignore))
            {
                mAssignedCellContentTypes.Add(mNewCellContentType);
            }

            // Based on the new value of the changed CB, do something
            SetStatVarProperties(mNewCellContentType, pIndex, pDataOrientation);

            // Set conditional visibility of manual statdatum settings
            if (mAssignedCellContentTypes.Contains(CellContentType.StatDatum) && mAssignedCellContentTypes.Contains(CellContentType.StatVars))
            {
                this.grpStatDatumSettings.Enabled = false;
                this.grpAutoDateSettings.Enabled = true;
                this.dgvStatVarProperties.Columns["ar"].Visible = false;
                this.dgvStatVarProperties.Columns["kvartal"].Visible = false;
                this.dgvStatVarProperties.Columns["mnd"].Visible = false;
                this.dgvStatVarProperties.Columns["Day"].Visible = false;
            }
            else if (!mAssignedCellContentTypes.Contains(CellContentType.StatDatum) && mAssignedCellContentTypes.Contains(CellContentType.StatVars))
            {
                this.grpStatDatumSettings.Enabled = true;
                this.grpAutoDateSettings.Enabled = false;
                this.dgvStatVarProperties.Columns["ar"].Visible = true;
                this.dgvStatVarProperties.Columns["kvartal"].Visible = true;
                this.dgvStatVarProperties.Columns["mnd"].Visible = true;
                this.dgvStatVarProperties.Columns["Day"].Visible = true;
            }
            else
            {
                this.grpStatDatumSettings.Enabled = false;
                this.grpAutoDateSettings.Enabled = false;
            }

            // Set conditional visibility of manual stat area settings
            if (!mAssignedCellContentTypes.Contains(CellContentType.StatAreaIDs) && !mAssignedCellContentTypes.Contains(CellContentType.StatAreaIDsAndNames))
            {
                this.grpStatAreaSettings.Enabled = true;
            }
            else if (mAssignedCellContentTypes.Contains(CellContentType.StatAreaIDs) || mAssignedCellContentTypes.Contains(CellContentType.StatAreaIDsAndNames))
            {
                this.grpStatAreaSettings.Enabled = false;
            }
            else
            {
                this.grpStatAreaSettings.Enabled = false;
            }

            // Reset parsed values if no longer present in layout combos
            // Reset statvars
            if (!mAssignedCellContentTypes.Contains(CellContentType.StatVars))
            {
                this.StatVarProperties = null;
                this.dgvStatVarProperties.DataSource = null;
                this.dgvStatVarProperties.Refresh();
            }

            // Reset statareaids
            if (!mAssignedCellContentTypes.Contains(CellContentType.StatAreaIDs) &&
                !mAssignedCellContentTypes.Contains(CellContentType.StatAreaIDsAndNames))
            {
                this.StatAreaIDsProperties = null;
            }

            // Reset statdatum
            if (!mAssignedCellContentTypes.Contains(CellContentType.StatDatum))
            {
                this.StatDatumProperties = null;
            }

            // Rebind statvarprops to grid
            if (this.StatVarProperties != null)
            {
                // Load statvars to manual settings for statvars if not already done
                // or if change in content of perpendicular rows/columns
                if (dgvStatVarProperties.DataSource == null ||
                    mNewCellContentType == CellContentType.StatVars ||
                    mNewCellContentType == CellContentType.StatVars2 ||
                    pDataOrientation != this.StatVarProperties.DataOrientation)
                {
                    this.LoadStatVarPropertiesGrid();
                    //tabControl.SelectedTab = tpStatisticsVariables;
                }

                // Parse with current settings
                // TODO: Verify if this causes multiple reloads
                this.ParseSelectionWithCurrentSettings();

            }

            // Determine whether layout comboboxes are supposed to be enabled or not
            this.SetCellContentTypeComboBoxEnabledState();
            return;

        }
 public static StatProps GetRowNum(Object[,] mSelection, int pRowNum = 1, DataOrientation pDataOrientation = DataOrientation.InRows)
 {
     if (pRowNum <= mSelection.GetLength(0))
     {
         var mStatProps = new StatProps(pDataOrientation);
         for (int mColNum = 1, mNumCols = mSelection.GetLength(1); mColNum <= mNumCols; mColNum++)
         {
             mStatProps.Add(mColNum, Table.GetNullOrString(mSelection[pRowNum, mColNum]));
         }
         return mStatProps;
     }
     else
     {
         return null;
     }
 }
        public static StatProps GetColNum(Object[,] mSelection, int pColNum = 1, DataOrientation pDataOrientation = DataOrientation.InColumns)
        {
            if (pColNum <= mSelection.GetLength(1))
            {
                var mStatProps = new StatProps(pDataOrientation);
                for (int mRowNum = 1, mNumRows = mSelection.GetLength(0); mRowNum <= mNumRows; mRowNum++)
                {
                    mStatProps.AddValue(mRowNum, Table.GetNullOrString(mSelection[mRowNum, pColNum]));
                }
                return mStatProps;
            }
            else
            {
                return null;
            }

        }