コード例 #1
0
        private String playsPosition(Player player, POSITIONS position)
        {
            switch (position)
            {
            case POSITIONS.CATCHER:
                return(player.Def.CatcherRating);

            case POSITIONS.FIRSTBASE:
                return(player.Def.FirstBaseRating);

            case POSITIONS.SECONDBASE:
                return(player.Def.SecondBaseRating);

            case POSITIONS.THIRDBASE:
                return(player.Def.ThirdBaseRating);

            case POSITIONS.SHORTSTOP:
                return(player.Def.ShortstopRating);

            case POSITIONS.LEFTFIELD:
                return(player.Def.LeftFieldRating);

            case POSITIONS.CENTERFIELD:
                return(player.Def.CenterFieldRating);

            case POSITIONS.RIGHTFIELD:
                return(player.Def.RightFieldRating);

            default:
                return("*");
            }
        }
コード例 #2
0
        private Boolean playsThisPosition(POSITIONS expected, Defense def)
        {
            switch (expected)
            {
            case POSITIONS.CATCHER:
                return(def.CatcherRating.Length > 0);

            case POSITIONS.FIRSTBASE:
                return(def.FirstBaseRating.Length > 0);

            case POSITIONS.SECONDBASE:
                return(def.SecondBaseRating.Length > 0);

            case POSITIONS.THIRDBASE:
                return(def.ThirdBaseRating.Length > 0);

            case POSITIONS.SHORTSTOP:
                return(def.ShortstopRating.Length > 0);

            case POSITIONS.LEFTFIELD:
                return(def.LeftFieldRating.Length > 0);

            case POSITIONS.CENTERFIELD:
                return(def.CenterFieldRating.Length > 0);

            case POSITIONS.RIGHTFIELD:
                return(def.RightFieldRating.Length > 0);
            }

            return(false);
        }
コード例 #3
0
        private String shortPositionName(POSITIONS position)
        {
            switch (position)
            {
            case POSITIONS.CATCHER:
                return(" C");

            case POSITIONS.FIRSTBASE:
                return(" 1B");

            case POSITIONS.SECONDBASE:
                return(" 2B");

            case POSITIONS.THIRDBASE:
                return(" 3B");

            case POSITIONS.SHORTSTOP:
                return(" SS");

            case POSITIONS.LEFTFIELD:
                return(" LF");

            case POSITIONS.CENTERFIELD:
                return(" CF");

            case POSITIONS.RIGHTFIELD:
                return(" RF");

            default:
                return(" DH");
            }
        }
コード例 #4
0
        private void sortPlayers(POSITIONS pos, List <Player> players)
        {
            IRankDefScorer scorer = RankDepthFactory.createDepthFactory(RankDepthFactory.DEPTH_ALGO.READ);

//            IRankDefScorer scorer = RankDepthFactory.createDepthFactory(RankDepthFactory.DEPTH_ALGO.SOMWORD);

            players.Sort(delegate(Player p1, Player p2)
            {
                double p1Score = 0;
                double p2Score = 0;

                switch (pos)
                {
                case POSITIONS.CATCHER:
                    //     p1Score = scorer.calculateFirstBaseDefScore(p1.Def.getDefRating(p1.Def.CatcherRating), p1.Def.getERating(p1.Def.CatcherRating));
                    //      p2Score = scorer.calculateFirstBaseDefScore(p2.Def.getDefRating(p2.Def.CatcherRating), p2.Def.getERating(p2.Def.CatcherRating));
                    break;

                case POSITIONS.FIRSTBASE:
                    p1Score = scorer.calculateFirstBaseDefScore(p1.Def.getDefRating(p1.Def.FirstBaseRating), p1.Def.getERating(p1.Def.FirstBaseRating));
                    p2Score = scorer.calculateFirstBaseDefScore(p2.Def.getDefRating(p2.Def.FirstBaseRating), p2.Def.getERating(p2.Def.FirstBaseRating));
                    break;

                case POSITIONS.SECONDBASE:
                    p1Score = scorer.calculateSecondBaseDefScore(p1.Def.getDefRating(p1.Def.SecondBaseRating), p1.Def.getERating(p1.Def.SecondBaseRating));
                    p2Score = scorer.calculateSecondBaseDefScore(p2.Def.getDefRating(p2.Def.SecondBaseRating), p2.Def.getERating(p2.Def.SecondBaseRating));
                    break;

                case POSITIONS.THIRDBASE:
                    p1Score = scorer.calculateThirdBaseDefScore(p1.Def.getDefRating(p1.Def.ThirdBaseRating), p1.Def.getERating(p1.Def.ThirdBaseRating));
                    p2Score = scorer.calculateThirdBaseDefScore(p2.Def.getDefRating(p2.Def.ThirdBaseRating), p2.Def.getERating(p2.Def.ThirdBaseRating));
                    break;

                case POSITIONS.SHORTSTOP:
                    p1Score = scorer.calculateShortStopDefScore(p1.Def.getDefRating(p1.Def.ShortstopRating), p1.Def.getERating(p1.Def.ShortstopRating));
                    p2Score = scorer.calculateShortStopDefScore(p2.Def.getDefRating(p2.Def.ShortstopRating), p2.Def.getERating(p2.Def.ShortstopRating));
                    break;

                case POSITIONS.LEFTFIELD:
                    p1Score = scorer.calculateLeftFieldDefScore(p1.Def.getDefRating(p1.Def.LeftFieldRating), p1.Def.getERating(p1.Def.LeftFieldRating));
                    p2Score = scorer.calculateLeftFieldDefScore(p2.Def.getDefRating(p2.Def.LeftFieldRating), p2.Def.getERating(p2.Def.LeftFieldRating));
                    break;

                case POSITIONS.CENTERFIELD:
                    p1Score = scorer.calculateCenterFieldDefScore(p1.Def.getDefRating(p1.Def.CenterFieldRating), p1.Def.getERating(p1.Def.CenterFieldRating));
                    p2Score = scorer.calculateCenterFieldDefScore(p2.Def.getDefRating(p2.Def.CenterFieldRating), p2.Def.getERating(p2.Def.CenterFieldRating));
                    break;

                case POSITIONS.RIGHTFIELD:
                    p1Score = scorer.calculateRightFieldDefScore(p1.Def.getDefRating(p1.Def.RightFieldRating), p1.Def.getERating(p1.Def.RightFieldRating));
                    p2Score = scorer.calculateRightFieldDefScore(p2.Def.getDefRating(p2.Def.RightFieldRating), p2.Def.getERating(p2.Def.RightFieldRating));
                    break;
                }
                return(p1Score.CompareTo(p2Score));
            });
        }
コード例 #5
0
 private void adjustPostionCount(Dictionary <POSITIONS, int> positions, POSITIONS pos)
 {
     if (positions.ContainsKey(pos))
     {
         positions[pos]++;
     }
     else
     {
         positions.Add(pos, 1);
     }
 }
コード例 #6
0
        public void setPlayers(List <Player> players)
        {
            int ABAdjustment = Int32.Parse(Properties.Settings.Default.ABAddition);

            clearInfoTable(InfoGrid);
            List <Player> sorted  = players.OrderBy(o => o.Name).ToList();
            int           postion = 1;

            foreach (Player player in sorted)
            {
                int totalAB = 0;
                Dictionary <POSITIONS, int> positions = new Dictionary <POSITIONS, int>();

                foreach (Object obj in LineupGrid.Children)
                {
                    if (obj is ComboBox)
                    {
                        ComboBox cb = (ComboBox)obj;
                        if (cb.SelectedItem != null && cb.SelectedItem is DefenseComboBoxItem)
                        {
                            LineupDataObj lineup         = (LineupDataObj)cb.GetValue(MainWindow.dp);
                            Player        selectedPlayer = ((DefenseComboBoxItem)cb.SelectedItem).Value;
                            if (selectedPlayer == player)
                            {
                                POSITIONS pos = ((PositionObj)cb.GetValue(MainWindow.dpPos)).Position;
                                adjustPostionCount(positions, pos);
                                totalAB += lineup.EstimatedAtBats;
                            }
                        }
                    }
                }
                int remaining = (player.Actual + ABAdjustment) - totalAB;

                RowDefinition row = new RowDefinition();
                row.Height = GridLength.Auto;
                InfoGrid.RowDefinitions.Add(row);
                InfoGrid.Children.Add(BuildPlayerInfoRow(player.Name, COLUMNS.NAME, postion, remaining >= 0 ? Colors.Black : Colors.Red));
                InfoGrid.Children.Add(BuildPlayerInfoRow(Convert.ToString(totalAB), COLUMNS.PROJECTED, postion, Colors.Black));
                if (ABAdjustment > 0)
                {
                    InfoGrid.Children.Add(BuildPlayerInfoRow(String.Format("{0}+{1}", player.Actual, ABAdjustment), COLUMNS.ACTUAL, postion, Colors.Black));
                }
                else
                {
                    InfoGrid.Children.Add(BuildPlayerInfoRow(player.Actual.ToString(), COLUMNS.ACTUAL, postion, Colors.Black));
                }
                InfoGrid.Children.Add(BuildPlayerInfoRow(Convert.ToString(remaining), COLUMNS.REMAINING, postion, remaining >= 0 ? Colors.Black : Colors.Red));
                InfoGrid.Children.Add(BuildPlayerInfoRow(player.Bal, COLUMNS.BAL, postion, Colors.Black));
                InfoGrid.Children.Add(BuildPlayerInfoRow(buildPositionDisplayString(positions), COLUMNS.POSITIONS, postion, Colors.Black));
                postion++;
            }
        }
コード例 #7
0
ファイル: Company.cs プロジェクト: cmu-sei/GHOSTS-ANIMATOR
        public static string GetPosition()
        {
            switch (AnimatorRandom.Rand.Next(3))
            {
            case 0: return(POSITION_PREFIXES.RandomElement() + " " + POSITIONS.RandomElement());

            case 1: return(POSITION_AREAS.RandomElement() + " " + POSITIONS.RandomElement());

            case 2: return(POSITION_PREFIXES.RandomElement() + " " + POSITION_AREAS.RandomElement() + " " + POSITIONS.RandomElement());

            default: throw new ApplicationException();
            }
        }
コード例 #8
0
        private Label BuildPositionTextBox(String position, POSITIONS row)
        {
            Label label = new Label();

            label.Content           = position;
            label.FontSize          = 14;
            label.FontWeight        = FontWeights.Bold;
            label.Foreground        = new SolidColorBrush(Colors.Green);
            label.VerticalAlignment = VerticalAlignment.Top;
            Grid.SetRow(label, (int)row);
            Grid.SetColumn(label, 0);
            return(label);
        }
コード例 #9
0
ファイル: Company.cs プロジェクト: dankli/SuperMassive
        public static string Position()
        {
            switch (RandomNumberGenerator.Int(3))
            {
            case 0: return(POSITION_PREFIXES.RandPick() + " " + POSITIONS.RandPick());

            case 1: return(POSITION_AREAS.RandPick() + " " + POSITIONS.RandPick());

            case 2: return(POSITION_PREFIXES.RandPick() + " " + POSITION_AREAS.RandPick() + " " + POSITIONS.RandPick());

            default: throw new InvalidOperationException();
            }
        }
コード例 #10
0
 private void addPlayersByPosition(ComboBox box, List <Player> players, POSITIONS position, int estimatedAB)
 {
     foreach (Player player in players)
     {
         String defRating = playsPosition(player, position);
         if (defRating.Length > 0)
         {
             DefenseComboBoxItem item = new DefenseComboBoxItem();
             item.Value = player;
             item.Text  = defRating;
             box.Items.Add(item);
         }
     }
 }
コード例 #11
0
ファイル: Company.cs プロジェクト: HeToC/HDK
        public static string GetPosition()
        {
            var Rand = FakerRandom.Rand;

            switch (Rand.Next(3))
            {
            case 0: return(POSITION_PREFIXES.Rand() + " " + POSITIONS.Rand());

            case 1: return(POSITION_AREAS.Rand() + " " + POSITIONS.Rand());

            case 2: return(POSITION_PREFIXES.Rand() + " " + POSITION_AREAS.Rand() + " " + POSITIONS.Rand());

            default: throw new Exception();
            }
        }
コード例 #12
0
        private List <Player> getSortedListOfPlayers(POSITIONS pos)
        {
            List <Player> posPlayers = new List <Player>();

            foreach (Player player in players)
            {
                Defense def = player.Def;
                if (playsThisPosition(pos, def))
                {
                    posPlayers.Add(player);
                }
            }

            sortPlayers(pos, posPlayers);

            return(posPlayers);
        }
コード例 #13
0
        private void addItemsToList(ListView list, List <Player> sortedPlayers, POSITIONS pos)
        {
            int rank = 1;

            foreach (Player player in sortedPlayers)
            {
                String defRating = "N/A";
                switch (pos)
                {
                case POSITIONS.CATCHER:
                    defRating = player.Def.CatcherRating;
                    break;

                case POSITIONS.FIRSTBASE:
                    defRating = player.Def.FirstBaseRating;
                    break;

                case POSITIONS.SECONDBASE:
                    defRating = player.Def.SecondBaseRating;
                    break;

                case POSITIONS.THIRDBASE:
                    defRating = player.Def.ThirdBaseRating;
                    break;

                case POSITIONS.SHORTSTOP:
                    defRating = player.Def.ShortstopRating;
                    break;

                case POSITIONS.LEFTFIELD:
                    defRating = player.Def.LeftFieldRating;
                    break;

                case POSITIONS.CENTERFIELD:
                    defRating = player.Def.CenterFieldRating;
                    break;

                case POSITIONS.RIGHTFIELD:
                    defRating = player.Def.RightFieldRating;
                    break;
                }


                list.Items.Add(new ListViewItem(rank++.ToString() + ") " + player.Name + " " + defRating + " " + player.Actual + "ab"));
            }
        }
コード例 #14
0
        private ComboBox BuildPlayerPostitionBox(int col, POSITIONS postion, LineupDataObj teamLineup, List <Player> players, int index)
        {
            ComboBox playerBox = new ComboBox();

            playerBox.Items.Add("NOT SET");
//            playerBox.Items.Add(index.ToString());

            playerBox.FontSize          = 12;
            playerBox.FontWeight        = FontWeights.Normal;
            playerBox.Foreground        = new SolidColorBrush(Colors.Green);
            playerBox.VerticalAlignment = VerticalAlignment.Top;
            playerBox.SelectedIndex     = 0;
            playerBox.SelectionChanged += lineup_player_SelectionChanged;
            playerBox.SetValue(dp, teamLineup);
            playerBox.SetValue(dpPos, new PositionObj(postion));

            addPlayersByPosition(playerBox, players, postion, teamLineup.EstimatedAtBats);

            Grid.SetRow(playerBox, (int)postion);
            Grid.SetColumn(playerBox, col);
            return(playerBox);
        }
コード例 #15
0
 private void clippingPanel_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
 {
     prePositon = e.Position;
     if (prePositon.X <= 5 && prePositon.Y <= 5)
     {
         positon = POSITIONS.LEFTTOP;
     }
     else if (prePositon.X >= ((sender as RelativePanel).ActualWidth - 5) && prePositon.Y <= 5)
     {
         positon = POSITIONS.RIGHTTOP;
     }
     else if (prePositon.X <= 5 && prePositon.Y >= ((sender as RelativePanel).ActualHeight - 5))
     {
         positon = POSITIONS.LEFTBUTTOM;
     }
     else if (prePositon.X >= ((sender as RelativePanel).ActualWidth - 5) && prePositon.Y >= ((sender as RelativePanel).ActualHeight - 5))
     {
         positon = POSITIONS.RIGHTBUTTOM;
     }
     else
     {
         positon = POSITIONS.UNKNOWN;
     }
 }
コード例 #16
0
 public PositionObj(POSITIONS p)
 {
     Position = p;
 }
コード例 #17
0
 public Card(POSITIONS pos, SUITS suit)
 {
     this.pos  = pos;
     this.suit = suit;
 }
コード例 #18
0
 /// <summary>
 /// Gets the first ICrystallonEntity it finds at the given position.
 /// </summary>
 /// <returns>
 /// The ICrystallonEntity.
 /// </returns>
 /// <param name='position'>
 /// Screen Position in pixels.
 /// </param>
 protected AbstractCrystallonEntity GetEntityAtPosition( Vector2 position, POSITIONS? pos=null )
 {
     System.Collections.ObjectModel.ReadOnlyCollection<ICrystallonEntity> allEntities = GameScene.getAllEntities();
     foreach (ICrystallonEntity e in allEntities) {
         if (e == null) continue;	// e IS NOT ACTUALLY A THING -- IGNORE (BUT IF THIS EVER HAPPENS, IT'S PROBS A BUG)
         if ( pos == null ) {
             if( e.getBounds().Overlaps(new Bounds2(position - 20.0f * Vector2.One, position + 20.0f * Vector2.One)) ){
                 return e as AbstractCrystallonEntity;
             }
         }
         if (AppMain.ORIENTATION_MATTERS
             && pos != null
             && e is SpriteTileCrystallonEntity
             && (e as SpriteTileCrystallonEntity).getOrientation() != (int)pos) { // ----- test for orientation-related pickup points
                     continue;
             }
         if ( e.getBounds().IsInside(position) ) {
             return e as AbstractCrystallonEntity;
         }
     }
     return null; // PLAYER TAPPED ON EMPTY SPACE, LIKE A N00B
 }
コード例 #19
0
        public void GenerateTestData(Action <EventArgs> callback)
        {
            if (NumberOfRecordsToGenerate > 0)
            {
                IsTestDataGenerationInProgress = true;

                BackgroundWorker worker = new BackgroundWorker();

                List <DataItem> list = new List <DataItem>();

                worker.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    // ********************************************************************
                    // Code Generated by Ideal Tools Organizer at http://idealautomate.com
                    // ********************************************************************
                    // Define Query String
                    //  "Select * from jobapplications  where dateadded >  cast('06/20/2020' as date)" +
                    string queryString =
                        "Select * from jobapplications where dateadded >  cast('07/01/2020' as date) -- and applicationstatus is null -- where jobboard = 'dice' and location <> 'remote' and applicationstatus is null" +
                        "";
                    // Define Connection String
                    string strConnectionString = null;
                    strConnectionString = @"Data Source=.\SQLEXPRESS02;Initial Catalog=IdealAutomateDB;Integrated Security=SSPI";
                    // Define .net fields to hold each column selected in query
                    String   str_jobapplications_JobUrl;
                    String   str_jobapplications_JobBoard;
                    String   str_jobapplications_JobTitle;
                    String   str_jobapplications_CompanyTitle;
                    DateTime dt_jobapplications_DateAdded;
                    DateTime dt_jobapplications_DateLastModified;
                    DateTime dt_jobapplications_DateApplied;
                    String   str_jobapplications_ApplicationStatus;
                    String   str_jobapplications_Keyword;
                    String   str_jobapplications_Location;
                    String   str_jobapplications_Comments;
                    // Define a datatable that we will define columns in to match the columns
                    // selected in the query. We will use sqldatareader to read the results
                    // from the sql query one row at a time. Then we will add each of those
                    // rows to the datatable - this is where you can modify the information
                    // returned from the sql query one row at a time. Finally, we will
                    // bind the table to the gridview.
                    DataTable dt = new DataTable();

                    using (SqlConnection connection = new SqlConnection(strConnectionString))
                    {
                        SqlCommand command = new SqlCommand(queryString, connection);

                        connection.Open();

                        SqlDataReader reader = command.ExecuteReader();
                        // Define a column in the table for each column that was selected in the sql query
                        // We do this before the sqldatareader loop because the columns only need to be
                        // defined once.

                        DataColumn column = null;
                        column = new DataColumn("jobapplications_JobUrl", Type.GetType("System.String"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_JobBoard", Type.GetType("System.String"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_JobTitle", Type.GetType("System.String"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_CompanyTitle", Type.GetType("System.String"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_DateAdded", Type.GetType("System.DateTime"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_DateLastModified", Type.GetType("System.DateTime"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_DateApplied", Type.GetType("System.DateTime"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_ApplicationStatus", Type.GetType("System.String"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_Keyword", Type.GetType("System.String"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_Location", Type.GetType("System.String"));
                        dt.Columns.Add(column);
                        column = new DataColumn("jobapplications_Comments", Type.GetType("System.String"));
                        dt.Columns.Add(column);
                        // Read the results from the sql query one row at a time
                        while (reader.Read())
                        {
                            // define a new datatable row to hold the row read from the sql query
                            DataRow dataRow = dt.NewRow();
                            // Move each field from the reader to a holding field in .net
                            // ********************************************************************
                            // The holding field in .net is where you can alter the contents of the
                            // field
                            // ********************************************************************
                            // Then, you move the contents of the holding .net field to the column in
                            // the datarow that you defined above
                            if (!(reader.IsDBNull(0)))
                            {
                                str_jobapplications_JobUrl        = reader.GetString(0);
                                dataRow["jobapplications_JobUrl"] = str_jobapplications_JobUrl;
                            }
                            if (!(reader.IsDBNull(1)))
                            {
                                str_jobapplications_JobBoard        = reader.GetString(1);
                                dataRow["jobapplications_JobBoard"] = str_jobapplications_JobBoard;
                            }
                            if (!(reader.IsDBNull(2)))
                            {
                                str_jobapplications_JobTitle        = reader.GetString(2);
                                dataRow["jobapplications_JobTitle"] = str_jobapplications_JobTitle;
                            }
                            if (!(reader.IsDBNull(3)))
                            {
                                str_jobapplications_CompanyTitle        = reader.GetString(3);
                                dataRow["jobapplications_CompanyTitle"] = str_jobapplications_CompanyTitle;
                            }
                            if (!(reader.IsDBNull(4)))
                            {
                                dt_jobapplications_DateAdded         = reader.GetDateTime(4);
                                dataRow["jobapplications_DateAdded"] = dt_jobapplications_DateAdded;
                            }
                            if (!(reader.IsDBNull(5)))
                            {
                                dt_jobapplications_DateLastModified         = reader.GetDateTime(5);
                                dataRow["jobapplications_DateLastModified"] = dt_jobapplications_DateLastModified;
                            }
                            if (!(reader.IsDBNull(6)))
                            {
                                dt_jobapplications_DateApplied         = reader.GetDateTime(6);
                                dataRow["jobapplications_DateApplied"] = dt_jobapplications_DateApplied;
                            }
                            if (!(reader.IsDBNull(7)))
                            {
                                str_jobapplications_ApplicationStatus        = reader.GetString(7);
                                dataRow["jobapplications_ApplicationStatus"] = str_jobapplications_ApplicationStatus;
                            }
                            if (!(reader.IsDBNull(8)))
                            {
                                str_jobapplications_Keyword        = reader.GetString(8);
                                dataRow["jobapplications_Keyword"] = str_jobapplications_Keyword;
                            }
                            if (!(reader.IsDBNull(9)))
                            {
                                str_jobapplications_Location        = reader.GetString(9);
                                dataRow["jobapplications_Location"] = str_jobapplications_Location;
                            }
                            if (!(reader.IsDBNull(10)))
                            {
                                str_jobapplications_Comments        = reader.GetString(10);
                                dataRow["jobapplications_Comments"] = str_jobapplications_Comments;
                            }
                            // Add the row to the datatable
                            dt.Rows.Add(dataRow);
                        }



                        // Call Close when done reading.
                        reader.Close();
                        //  SampleGrid.ItemsSource = dt.DefaultView;


                        int ctr = 0;
                        foreach (DataRow item in dt.Rows)
                        {
                            DataItem dataItem = new DataItem(ctr++);
                            dataItem.str_jobapplications_JobUrl       = item["jobapplications_JobUrl"].ToString();
                            dataItem.str_jobapplications_JobBoard     = item["jobapplications_JobBoard"].ToString();
                            dataItem.str_jobapplications_JobTitle     = item["jobapplications_JobTitle"].ToString();
                            dataItem.str_jobapplications_CompanyTitle = item["jobapplications_CompanyTitle"].ToString();
                            if (item["jobapplications_DateAdded"] != null && item["jobapplications_DateAdded"].ToString() != "")
                            {
                                dataItem.dt_jobapplications_DateAdded = DateTime.Parse(item["jobapplications_DateAdded"].ToString());
                            }
                            if (item["jobapplications_DateLastModified"] != null && item["jobapplications_DateLastModified"].ToString() != "")
                            {
                                dataItem.dt_jobapplications_DateLastModified = DateTime.Parse(item["jobapplications_DateLastModified"].ToString());
                            }
                            if (item["jobapplications_DateApplied"] != null && item["jobapplications_DateApplied"].ToString() != "")
                            {
                                dataItem.dt_jobapplications_DateApplied = DateTime.Parse(item["jobapplications_DateApplied"].ToString());
                            }
                            dataItem.str_jobapplications_ApplicationStatus = item["jobapplications_ApplicationStatus"].ToString();
                            dataItem.str_jobapplications_Keyword           = item["jobapplications_Keyword"].ToString();
                            dataItem.str_jobapplications_Location          = item["jobapplications_Location"].ToString();
                            dataItem.str_jobapplications_Comments          = item["jobapplications_Comments"].ToString();
                            list.Add(dataItem);
                        }
                    }
                };

                worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    EmployeeStatuses     = new ObservableCollection <EmployeeStatus>(STATUS.ToList());
                    EmployeePositionList = new ObservableCollection <EmployeePosition>(POSITIONS.ToList());

                    JobApplicationList = new ObservableCollection <DataItem>(list);



                    IsTestDataGenerationInProgress = false;

                    if (callback != null)
                    {
                        callback(EventArgs.Empty);
                    }
                };

                worker.RunWorkerAsync();
            }
        }
コード例 #20
0
    protected virtual void OnEnable()
    {
        // Get the current properties of the values
        s_radius      = serializedObject.FindProperty("compassRadius");
        s_rotRate     = serializedObject.FindProperty("rotRate");
        s_shiftRate   = serializedObject.FindProperty("shiftRate");
        s_strtPos     = serializedObject.FindProperty("strtPos");
        s_stormHeight = serializedObject.FindProperty("stormHeight");

        // Get reference for player object
        playerObj = GameObject.Find("Player");
        if (playerObj == null)
        {
            Debug.LogError("Player object not found in hierarchy");
        }

        // Calculate the index of s_strtPos in vectorPos
        switch (Mathf.RoundToInt(s_strtPos.vector2Value.x))
        {
        case 1:
            if (s_strtPos.vector2Value.y > 0)
            {
                strtIndex = POSITIONS.NE;
            }
            else if (s_strtPos.vector2Value.y < 0)
            {
                strtIndex = POSITIONS.SE;
            }
            else
            {
                strtIndex = POSITIONS.E;
            }
            break;

        case -1:
            if (s_strtPos.vector2Value.y > 0)
            {
                strtIndex = POSITIONS.NW;
            }
            else if (s_strtPos.vector2Value.y < 0)
            {
                strtIndex = POSITIONS.SW;
            }
            else
            {
                strtIndex = POSITIONS.W;
            }
            break;

        default:
            if (s_strtPos.vector2Value.y > 0)
            {
                strtIndex = POSITIONS.N;
            }
            else
            {
                strtIndex = POSITIONS.S;
            }
            break;
        }

        // Initialize the dictionary of cardinal position rotations
        cardinalRot.Add(new Vector2(0, 1), Quaternion.identity);     // position N
        cardinalRot.Add(new Vector2(1, 1), Quaternion.identity);     // position NE
        cardinalRot.Add(new Vector2(1, 0), Quaternion.identity);     // position E
        cardinalRot.Add(new Vector2(1, -1), Quaternion.identity);    // position SE
        cardinalRot.Add(new Vector2(0, -1), Quaternion.identity);    // position S
        cardinalRot.Add(new Vector2(-1, -1), Quaternion.identity);   // position SW
        cardinalRot.Add(new Vector2(-1, 0), Quaternion.identity);    // position W
        cardinalRot.Add(new Vector2(-1, 1), Quaternion.identity);    // position NW

        List <Vector2> cardRotIndex = new List <Vector2>(cardinalRot.Keys);
        Vector3        compCntr     = ((CompassCenter)target).transform.position;

        for (int i = 0; i < cardRotIndex.Count; i++)
        {
            cardinalRot[cardRotIndex[i]] = Quaternion.AngleAxis(45f * i, Vector3.up);
        }
    }
コード例 #21
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.BeginVertical("Box");
        EditorGUILayout.LabelField("Compass Settings");

        // Set radius of compass, with minimum bound
        EditorGUI.BeginChangeCheck();
        float newRadius = EditorGUILayout.DelayedFloatField("Compass Radius", s_radius.floatValue);

        newRadius = (newRadius < 0) ? 0.0f : newRadius;
        if (EditorGUI.EndChangeCheck())
        {
            s_radius.floatValue = newRadius;
        }

        // Set rotation rate of compass center, with minimum bound
        EditorGUI.BeginChangeCheck();
        float newRotRate = EditorGUILayout.DelayedFloatField("Rotation Time (sec)", s_rotRate.floatValue);

        newRotRate = (newRotRate < 0) ? 0 : newRotRate;
        if (EditorGUI.EndChangeCheck())
        {
            s_rotRate.floatValue = newRotRate;
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical("Box");
        EditorGUILayout.LabelField("Wizard Settings");

        // Set wizard position for storm mode
        EditorGUI.BeginChangeCheck();
        float wizardHeight = EditorGUILayout.DelayedFloatField("Storm Mode Height", s_stormHeight.floatValue);

        wizardHeight += playerObj.transform.position.y;
        if (EditorGUI.EndChangeCheck())
        {
            Vector3 newStormPos = ((CompassCenter)target).transform.position;
            newStormPos.y            = (wizardHeight < 0) ? playerObj.transform.position.y : wizardHeight;
            s_stormHeight.floatValue = newStormPos.y;
        }

        // Set shift rate for wizard, with minimum bound
        EditorGUI.BeginChangeCheck();
        float newShiftRate = EditorGUILayout.DelayedFloatField("Mode shift rate (sec)", s_shiftRate.floatValue);

        newShiftRate = (newShiftRate < 0) ? 0 : newShiftRate;
        if (EditorGUI.EndChangeCheck())
        {
            s_shiftRate.floatValue = newShiftRate;
        }

        // Set up drop down menu for intial position
        EditorGUI.BeginChangeCheck();
        strtIndex = (POSITIONS)EditorGUILayout.EnumPopup("Wizard Start Position", strtIndex);
        if (EditorGUI.EndChangeCheck())
        {
            s_strtPos.vector2Value = vectorPos[(int)strtIndex];
        }

        EditorGUILayout.EndVertical();
        serializedObject.ApplyModifiedProperties();
    }
コード例 #22
0
        public void GenerateTestData(Action <EventArgs> callback)
        {
            if (NumberOfRecordsToGenerate > 0)
            {
                IsTestDataGenerationInProgress = true;

                BackgroundWorker worker = new BackgroundWorker();

                List <Employee> list = new List <Employee>();

                worker.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    for (int i = 0; i < NumberOfRecordsToGenerate; i++)
                    {
                        initRandomGenerator();

                        Employee emp = new Employee();

                        fillWithTheRandomData(emp, i);

                        list.Add(emp);

                        TestDataGenerationPercent = ((double)i / NumberOfRecordsToGenerate) * 100;
                    }
                };

                worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    EmployeeStatuses     = new ObservableCollection <EmployeeStatus>(STATUS.ToList());
                    EmployeePositionList = new ObservableCollection <EmployeePosition>(POSITIONS.ToList());

                    EmployeeList = new ObservableCollection <Employee>(list);

                    Employee[] tmpArray = new Employee[EmployeeList.Count];
                    EmployeeList.ToList().CopyTo(tmpArray);
                    EmployeeListCopy = new ObservableCollection <Employee>(tmpArray.ToList());

                    IsTestDataGenerationInProgress = false;

                    if (callback != null)
                    {
                        callback(EventArgs.Empty);
                    }
                };

                worker.RunWorkerAsync();
            }
        }