Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        // Changes background dynamically
        if (m_BackgroundColorBrightness > 1.0f)
        {
            Color goalColor = Color.Lerp(m_BackgroundColorGoTo, Color.white, m_BackgroundColorBrightness - 1.0f);

            m_currentCamera.backgroundColor = ExtendedFunctions.ColorSmoothDamp
                                              (
                m_currentCamera.backgroundColor,
                goalColor,
                ref m_backgroundVel,
                m_BackgroundColorAnimationDamp
                                              );
        }
        else
        {
            m_currentCamera.backgroundColor = ExtendedFunctions.ColorSmoothDamp
                                              (
                m_currentCamera.backgroundColor,
                m_BackgroundColorGoTo * m_BackgroundColorBrightness,
                ref m_backgroundVel,
                m_BackgroundColorAnimationDamp
                                              );
        }
    }
Exemple #2
0
        private void Adddialog_Adding(object sender, EventArgs e)
        {
            AddNewProjectTaskList adddialog = (AddNewProjectTaskList)sender;

            adddialog.MyList.CreatedBy  = this.MainWindow.StaffKey;
            adddialog.MyList.CreatedOn  = ExtendedFunctions.GetNetworkTime();
            adddialog.MyList.ProjectKey = this.MyProject.Key;
            adddialog.MyList.Key        = Encryption.GetUniqueKey(16);
            this.TaskListDbset.Add(adddialog.MyList);

            if (this.TaskListConn.GetValidationErrors().Count() > 0)
            {
                foreach (var item in TaskListConn.GetValidationErrors())
                {
                    Console.WriteLine(item.Entry.GetType().ToString());
                    foreach (var error in item.ValidationErrors)
                    {
                        Console.WriteLine("     " + error.PropertyName + ": " + error.ErrorMessage);
                    }
                }
            }
            else
            {
                try
                {
                    //Thêm vào cơ sở dữ liệu
                    TaskListConn.SaveChanges();
                }
                catch (Exception ex)
                {
                    //Nếu có lỗi thì ghi vào console và thông báo
                    Console.WriteLine(ex.Message);
                }
            }
        }
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public SaveEventMessages SetSaveData()
    {
        if (m_ActiveSave == null)
        {
            return(SaveEventMessages.SaveSlotEmpty);
        }

        if (OverrideSaveData() != SaveEventMessages.SaveOverrideSuccess)
        {
            return(SaveEventMessages.SaveOverrideSuccess);
        }

        string[] temp;

        if (m_Save1.GetSaveID() == m_ActiveSave.GetSaveID())
        {
            temp = SaveData.SaveDataToStringArray(m_Save1);

            ExtendedFunctions.PrintArray(temp);

            PlayerPrefsX.SetStringArray(K_SAVE1, temp);
        }
        else if (m_Save2.GetSaveID() == m_ActiveSave.GetSaveID())
        {
            temp = SaveData.SaveDataToStringArray(m_Save2);
            PlayerPrefsX.SetStringArray(K_SAVE2, temp);
        }

        PlayerPrefs.SetInt(K_HIGHSCORE, m_HighScore);

        return(SaveEventMessages.SaveSuccess);
    }
        /// <summary>
        /// Thêm các thông tin cuối cùng và gọi framework để chèn dự án vào csdl
        /// </summary>
        private void AddProjectToDb()
        {
            //Thông tin về phân nhóm dự án
            SetCategory();

            //Thông tin về khách hàng (chưa làm)
            SetCustomer();

            //Thông tin về nhân sự của dự án
            SetPeople();

            //Thông tin về ngày của dự án
            SetDates();

            //Thông tin về các thẻ đính kèm;
            SetTags();

            //Thông tin về người tạo, giờ tạo
            this.NewProject.AddedBy = this.MainWindow.StaffKey;
            this.NewProject.AddedOn = ExtendedFunctions.GetNetworkTime();

            //Thông tin về người sửa, giờ sửa
            this.NewProject.ModifiedBy = this.NewProject.AddedBy;
            this.NewProject.ModifiedOn = this.NewProject.AddedOn;

            //Danh sách công việc mặc định
            this.CreateDefaultTaskList();

            //Kiểm tra lỗi
            if (this.Conn.GetValidationErrors().Count() > 0)
            {
                foreach (var item in Conn.GetValidationErrors())
                {
                    Console.WriteLine(item.Entry.GetType().ToString());
                    foreach (var error in item.ValidationErrors)
                    {
                        Console.WriteLine("     " + error.PropertyName + ": " + error.ErrorMessage);
                    }
                }
            }
            else
            {
                try
                {
                    //Thêm vào cơ sở dữ liệu
                    Conn.SaveChanges();

                    //Nếu thành công thì gọi event
                    this.ProjectAdded?.Invoke(this, EventArgs.Empty);
                }
                catch (Exception ex)
                {
                    //Nếu có lỗi thì ghi vào console và thông báo
                    Console.WriteLine(ex.Message);

                    //Raise event
                    this.AddingProjectFailed?.Invoke(this, EventArgs.Empty);
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Create the All Project category (the root) and the No Category
        /// </summary>
        private void CreateBasicCategory()
        {
            using (Data.ConnectContainer Conn = new ConnectContainer())
            {
                if (Conn.Categories.Count() == 0)
                {
                    try
                    {
                        string AllProjectKey = Encryption.GetUniqueKey(16);
                        Conn.Categories.Add(new Category()
                        {
                            Name       = "All Projects",
                            Key        = AllProjectKey,
                            AddedBy    = this.MainWindow.StaffKey,
                            AddedOn    = ExtendedFunctions.GetNetworkTime(),
                            Color      = "DimGray",
                            IsDeleted  = false,
                            ModifiedBy = this.MainWindow.StaffKey,
                            ModifiedOn = ExtendedFunctions.GetNetworkTime(),
                            ParentKey  = "",
                            Level      = 0
                        });
                        Conn.Categories.Add(new Category()
                        {
                            Name       = "No Category",
                            Key        = Encryption.GetUniqueKey(16),
                            AddedBy    = this.MainWindow.StaffKey,
                            AddedOn    = ExtendedFunctions.GetNetworkTime(),
                            Color      = "DimGray",
                            IsDeleted  = false,
                            ModifiedBy = this.MainWindow.StaffKey,
                            ModifiedOn = ExtendedFunctions.GetNetworkTime(),
                            ParentKey  = AllProjectKey,
                            Level      = 1
                        });

                        if (Conn.GetValidationErrors().Count() > 0)
                        {
                            foreach (var item in Conn.GetValidationErrors())
                            {
                                foreach (var error in item.ValidationErrors)
                                {
                                    Console.WriteLine(error.ErrorMessage);
                                }
                            }
                        }
                        else
                        {
                            Conn.SaveChanges();
                        }
                    }
                    finally
                    {
                        Conn.Dispose();
                    }
                }
            }
        }
Exemple #6
0
        private void NextMonday_Click(object sender, EventArgs e)
        {
            var date = ExtendedFunctions.GetNetworkTime();

            while (date.DayOfWeek != DayOfWeek.Monday)
            {
                date = date.AddDays(1);
            }
            this.SelectedDate = date.Date;
        }
    // Use this for initialization
    void Start()
    {
        playerData = PlayerData.GetInstance();
        gameInfo   = GameInfo.GetInstance();

        GameObject currentMarker;

        switch (gameInfo.GetLatestWinner())
        {
        case GameOutcome.Tie:
            m_BackgroundColorGoTo = new Color
                                    (
                ExtendedFunctions.Convert8ToFloat(50),
                ExtendedFunctions.Convert8ToFloat(50),
                ExtendedFunctions.Convert8ToFloat(50)
                                    );

            m_congratsMessage.text = "TIE GAME!";

            break;

        case GameOutcome.PlayerWon:

            currentMarker = GetMarker(gameInfo.GetPlayerMarker());

            m_BackgroundColorGoTo = ExtendedFunctions.GetColorOfGameObject(currentMarker);

            SetupMarkerDisplay(currentMarker);

            m_congratsMessage.text = "YOU WON!";

            break;

        case GameOutcome.AIWon:

            currentMarker = GetMarker(gameInfo.GetAIMarker());

            m_BackgroundColorGoTo = ExtendedFunctions.GetColorOfGameObject(currentMarker);

            SetupMarkerDisplay(currentMarker);

            m_congratsMessage.text = "YOU LOSS!";

            break;
        }

        m_statsTitle.text = playerData.ActiveSave.m_saveName + "'s stats";

        m_winStats.text = "Total wins\n" + playerData.ActiveSave.m_TotalWins;

        m_lossStats.text = "Total losses\n" + playerData.ActiveSave.m_TotalLosses;
    }
        /// <summary>
        /// Thêm các thông tin về nhân sự dự án
        /// </summary>
        private void SetPeople()
        {
            //Create the staff dbset
            if (this.ProjectStaffDbset == null)
            {
                this.ProjectStaffDbset = this.Conn.Set <ProjectStaffs>();
            }
            else
            {
                this.ProjectStaffDbset.Local.Clear();
            }

            //Create the permission db set
            if (this.ProjectPermissionDbset == null)
            {
                this.ProjectPermissionDbset = this.Conn.Set <Data.UserProjectPermission>();
            }

            if (this.SelectedStaff == null)
            {
                this.SelectedStaff = new List <Data.Staff>();
                this.SelectedStaff.Add(MainWindow.LoggedInStaff);
            }

            //Create the assignment and permission
            foreach (Staff s in SelectedStaff)
            {
                var newAssign = this.ProjectStaffDbset.Create();

                if (IsProjectOwner(s.Key))
                {
                    this.NewProject.ProjectOwner = s.Key;
                }

                newAssign.StaffKey   = s.Key;
                newAssign.ProjectKey = this.NewProject.Key;
                newAssign.Key        = Encryption.GetUniqueKey(16);
                newAssign.AddedBy    = this.MainWindow.StaffKey;
                newAssign.AddedOn    = ExtendedFunctions.GetNetworkTime().ToString();

                //Create a permission record
                UserProjectPermission permission = this.ProjectPermissionDbset.Create();
                permission.ProjectStaffKey = newAssign.Key;
                permission.IsAdmin         = IsProjectOwner(newAssign.StaffKey);

                newAssign.PermissionKey = Encryption.GetPermisionKey(permission);

                this.ProjectPermissionDbset.Add(permission);
                this.ProjectStaffDbset.Add(newAssign);
            }
        }
Exemple #9
0
    Color GetMarkerColor(MarkerType selectedMarker)
    {
        switch (selectedMarker)
        {
        case MarkerType.O:
            //return m_oMarker.GetComponent<Shader>().GetColor("_Color");
            return(ExtendedFunctions.GetColorOfGameObject(m_oMarker));

        case MarkerType.X:
            //return m_xMarker.GetComponent<Material>().GetColor("_Color");
            return(ExtendedFunctions.GetColorOfGameObject(m_xMarker));

        default:
            return(Color.black);
        }
    }
Exemple #10
0
        private void UpdateCategoryToDb()
        {
            try
            {
                MainWindow M = (MainWindow)App.Current.MainWindow;
                using (Data.ConnectContainer conn = new Data.ConnectContainer())
                {
                    var cate   = conn.Categories.Where(c => c.Key == EditingCategory.Key).FirstOrDefault();
                    var Parent = ((ComboBoxItem)this.NestCombobox.SelectedItem).Tag as Category;

                    bool changed = false;

                    if (cate != null)
                    {
                        changed = changed || (cate.Name != NameTextbox.Text);
                        changed = changed || (cate.ParentKey != Parent.Key);
                        changed = changed || (cate.Color != this.colorPicker.CurrentSelectedColor.Color.ToString());
                    }

                    if (changed)
                    {
                        cate.Name       = NameTextbox.Text;
                        cate.Color      = this.colorPicker.CurrentSelectedColor.Color.ToString();
                        cate.ParentKey  = Parent.Key;
                        cate.ModifiedBy = M.StaffKey;
                        cate.ModifiedOn = ExtendedFunctions.GetNetworkTime();
                        cate.Level      = Parent.Level + 1;
                    }
                    int i = conn.SaveChanges();
                    if (i > 0)
                    {
                        this.Confirmed?.Invoke(this, EventArgs.Empty);
                    }
                    else
                    {
                        this.Failed?.Invoke(this, EventArgs.Empty);
                    }
                };
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
    public void OnPointerEnter(int marker)
    {
        switch (marker)
        {
        case 0:     // Circle

            m_BackgroundColorGoTo = ExtendedFunctions.GetColorOfGameObject(m_oMarker);
            SwapVisual(m_oMarker);

            break;

        case 1:     // Cross

            m_BackgroundColorGoTo = ExtendedFunctions.GetColorOfGameObject(m_xMarker);
            SwapVisual(m_xMarker);

            break;
        }
    }
        private void AddTagButton_Clicked(object sender, RoutedEventArgs e)
        {
            if (this.TagsDbset == null)
            {
                this.TagsDbset = Conn.Set <Tags>();
            }
            if (this.ListOfTags == null)
            {
                this.ListOfTags = new List <Tags>();
            }

            //Detect if this tag is currently added to the project
            bool TagExist = this.ListOfTags.Where(lt => lt.TagName.ToLower() == this.NewTagTextBox.Text.ToLower().Trim()).FirstOrDefault() != null;

            if (TagExist)
            {
                this.AddTagPopupButton.IsPopupOpen = false;
                this.MySnackbar.MessageQueue.Enqueue("This tag is already added to project".ToUpper());
                return;
            }

            //Create the new tag
            var newTag = this.TagsDbset.Create();

            newTag.TagName = this.NewTagTextBox.Text;
            newTag.TagKey  = Encryption.GetUniqueKey(16);
            newTag.Color   = this.TagColorPicker.CurrentSelectedColor.Color.ToString();
            newTag.AddedBy = ((MainWindow)App.Current.MainWindow).StaffKey;
            newTag.AddOn   = ExtendedFunctions.GetNetworkTime();

            MyTagChips tc = new MyTagChips(newTag);

            tc.Margin    = new Thickness(3);
            tc.Deleting += Tc_Deleting;

            //Add to collections
            this.TagWrapPanel.Children.Add(tc);
            this.ListOfTags.Add(newTag);
            this.TagsDbset.Add(newTag);

            //Close the popup
            this.AddTagPopupButton.IsPopupOpen = false;
        }
Exemple #13
0
        private void AddNewCategoryToDb()
        {
            try
            {
                MainWindow M = (MainWindow)App.Current.MainWindow;
                using (Data.ConnectContainer conn = new Data.ConnectContainer())
                {
                    var cate = new Data.Category()
                    {
                        Name       = NameTextbox.Text,
                        ModifiedBy = M.StaffKey,
                        ModifiedOn = ExtendedFunctions.GetNetworkTime(),
                        AddedBy    = M.StaffKey,
                        AddedOn    = ExtendedFunctions.GetNetworkTime(),
                        Color      = this.colorPicker.CurrentSelectedColor.Color.ToString(),
                        IsDeleted  = false,
                        Key        = Encryption.GetUniqueKey(16)
                    };
                    var Parent = ((ComboBoxItem)this.NestCombobox.SelectedItem).Tag as Category;

                    cate.ParentKey = Parent.Key;
                    cate.Level     = Parent.Level + 1;

                    conn.Categories.Add(cate);
                    int i = conn.SaveChanges();
                    if (i > 0)
                    {
                        this.Confirmed?.Invoke(this, EventArgs.Empty);
                    }
                    else
                    {
                        this.Failed?.Invoke(this, EventArgs.Empty);
                    }
                };
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// Thêm nhân viên mới
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddUserButtonClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                var DateTimeNow = ExtendedFunctions.GetNetworkTime();
                foreach (var item in Conn.ChangeTracker.Entries <Staff>())
                {
                    if (!this.IsEditing)
                    {
                        item.Entity.AddedOn  = DateTimeNow;
                        item.Entity.AddedBy  = this.MainWindow.StaffKey != null ? this.MainWindow.StaffKey : item.Entity.Key;
                        item.Entity.Password = Encryption.GetUniqueKey(8);
                    }
                    ;
                    item.Entity.ModifiedBy = this.MainWindow.StaffKey != null ? this.MainWindow.StaffKey : item.Entity.Key;
                    item.Entity.ModifiedOn = DateTimeNow;
                }

                bool _NoMoreError = true;

                _NoMoreError = this.Validate();

                if (_NoMoreError)
                {
                    int i = Conn.SaveChanges();
                    if (i > 0)
                    {
                        this.StaffAdded?.Invoke(this, EventArgs.Empty);
                    }
                    else
                    {
                        MySnackbar.MessageQueue.Enqueue("Error while adding staff. Please try again later.");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #15
0
 /// <summary> Writes the extended comm function. </summary>
 /// <param name="value"> The value. </param>
 public void Write(ExtendedFunctions value) {
     if (!EscapeCommFunction(Handle, (int) value))
         WinError.WinIOError();
 }
Exemple #16
0
        private void ToDayMyTextBlock_Click(object sender, EventArgs e)
        {
            var date = ExtendedFunctions.GetNetworkTime();

            this.SelectedDate = date.Date;
        }
Exemple #17
0
        private void NextWeek_Click(object sender, EventArgs e)
        {
            var date = ExtendedFunctions.GetNetworkTime();

            this.SelectedDate = date.AddDays(7).Date;
        }
Exemple #18
0
    /// <summary>
    /// Game loop
    /// </summary>
    /// <returns></returns>
    IEnumerator GameLoop()
    {
        // Delay start for wipe animation
        yield return(new WaitForSeconds(0.5f));

        int player = GI.GetPlayerFirst() ? 1 : 2;

        for (m_turns = 0; m_turns < 9 && Win(m_board) == 0; ++m_turns)
        {
            m_TurnText.text = "Turns: " + m_turns.ToString();

            if ((m_turns + player) % 2 == 0)
            {
                Debug.Log("Computer's turn!");
                currentTurnMove = TurnMode.AIMove;
                UpdateTurnVisual();
                m_BackgroundColorGoTo = GetMarkerColor(AIMarker);

                yield return(new WaitForSeconds(m_AITurnDuration));

                ComputerMove(m_board);
                Debug.Log("Computer has made their turn!");
                UpdateBoardVisuals();
            }
            else
            {
                Debug.Log("Player's turn!");
                currentTurnMove = TurnMode.PlayerMove;
                UpdateTurnVisual();
                m_BackgroundColorGoTo = GetMarkerColor(playerMarker);

                yield return(new WaitUntil(() => m_turnOver));

                Debug.Log("Player has made their turn!");
                UpdateBoardVisuals();
            }

            m_turnOver = false;
        }

        currentTurnMove = TurnMode.GameOver;

        yield return(new WaitForSeconds(1));

        switch (Win(m_board).ToInt())
        {
        case 0:
            Debug.Log("A draw. How droll.\n");
            m_BackgroundColorGoTo = Color.black;
            UpdateText("Tie game!",
                       new Color(
                           ExtendedFunctions.Convert8ToFloat(50.0f),
                           ExtendedFunctions.Convert8ToFloat(50.0f),
                           ExtendedFunctions.Convert8ToFloat(50.0f)
                           )
                       );

            GI.SetLatestWinner(GameOutcome.Tie);

            break;

        case 1:
            Debug.Log("You lose.\n");
            WinVisual(m_WinPositions);
            UpdateText("AI won!", GetMarkerColor(AIMarker));
            LoseState();
            break;

        case -1:
            Debug.Log("You win.\n");
            WinVisual(m_WinPositions);
            UpdateText("You win!", GetMarkerColor(playerMarker));
            WinState();
            break;
        }

        yield return(new WaitForSeconds(1.0f));

        m_WhiteWipe.SetTrigger("WipeIn");
    }
Exemple #19
0
 /// <summary> Writes the extended comm function. </summary>
 /// <param name="value"> The value. </param>
 public bool WriteBool(ExtendedFunctions value) {
     return EscapeCommFunction(Handle, (int) value);
 }
Exemple #20
0
 public static extern bool EscapeCommFunction(IntPtr hFile, ExtendedFunctions dwFunc);