コード例 #1
0
        /// <summary>
        /// Deletes the given checkbox item.
        /// </summary>
        /// <param name="checkbox"></param>
        private void DeleteItems(object checkboxes)
        {
            IList boxes = (IList)checkboxes;

            if (boxes == null)
            {
                return;
            }

            List <CheckBox> convertedBoxes = new List <CheckBox>(boxes.Cast <CheckBox>());

            // Loop around removing the checkboxes selected, but not if they're text is the default text.
            foreach (CheckBox box in convertedBoxes)
            {
                if (box.Content.ToString() == DefaultTODO)
                {
                    continue;
                }
                CheckListList.Remove(box);
            }

            DataDealer.WriteChecklistData(CheckListItems);

            // Make sure that there's always a default todo
            if (CheckListList.Count <= 0)
            {
                CheckListList.Add(MakeCheckBoxForItem(DefaultTODO));
            }

            string[] itemsDeleted = convertedBoxes.Select(checkbox => checkbox.Content.ToString()).ToList().ToArray();
            // Fire the event.
            ItemsDeleted?.Invoke(this, itemsDeleted);
        }
コード例 #2
0
ファイル: Cautioner.cs プロジェクト: vaginessa/Dashboard.net
        /// <summary>
        /// Refreshes the necessary elements that do not auto-refresh
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Refresh(object sender, NotifyCollectionChangedEventArgs e)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsWarning"));
            UpdateNTArray();

            DataDealer.WriteCautionerData(DataToSave);
        }
コード例 #3
0
        /// <summary>
        /// Prompts the user to confirm that they indeed want to erase the application's data and then proceeds to erase the data if so.
        /// </summary>
        /// <param name="obj"></param>
        private void EraseData(object obj)
        {
            MessageBoxResult dialogResult = MessageBox.Show("Are you sure you wish to PERMANENTLY ERASE " +
                                                            "ALL APPLICATION DATA and restart the application?"
                                                            , "Continue with Application Wipe?", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            // If user continues with yes, restart the application to make the changes work.
            if (dialogResult == MessageBoxResult.Yes)
            {
                DataDealer.EraseDataFile();
                DataDealer.RestartApplication();
            }
        }
コード例 #4
0
        /// <summary>
        /// Reloads the checklist from the file.
        /// </summary>
        private void Reload()
        {
            List <string> data = DataDealer.ReadCheckListData();

            if (data == null || data.Count == 0)
            {
                CheckListItems = new List <string>()
                {
                    { DefaultTODO }
                }
            }
            ;
            else
            {
                CheckListItems = data;
            }
        }
コード例 #5
0
        private bool GetEnabledState()
        {
            object isEnabled = DataDealer.ReadMiscData(ENABLED_KEY);

            bool enabled;

            if (isEnabled == null)
            {
                DataDealer.AppendMiscData(ENABLED_KEY, false);
                enabled = false;
            }
            else
            {
                enabled = (bool)isEnabled;
            }

            // If it's null, we need to write
            return(enabled);
        }
コード例 #6
0
ファイル: Cautioner.cs プロジェクト: vaginessa/Dashboard.net
        public Cautioner(Master controller) : base(controller)
        {
            WarningList = new ObservableCollection <string>();

            // Subscribe to the collection changed event in order to refresh
            WarningList.CollectionChanged += Refresh;

            CautionerClicked = new RelayCommand()
            {
                CanExecuteDeterminer = () => true,
                FunctionToExecute    = (object parameter) =>
                {
                    IsEnabled = !IsEnabled;
                    SetAnimation(true);
                }
            };

            // Set the initial state of the enabled boolean from the data file
            Hashtable cautionerData = DataDealer.ReadCautionerData();

            if (cautionerData == null)
            {
                _isEnabled = true;
                IgnoreList = new ObservableCollection <string>();

                DataDealer.WriteCautionerData(DataToSave);
            }
            else
            {
                _isEnabled = (bool)cautionerData[ENABLEDKEY];
                IgnoreList = (ObservableCollection <string>)cautionerData[IGNOREKEY];
            }
            IgnoreList.CollectionChanged += Refresh;

            // Listen for key changes on the add and remove queues
            master._Dashboard_NT.AddKeyListener(NTADDKEY, OnNTKWarningAdded);
            master._Dashboard_NT.AddKeyListener(NTREMOVEKEY, OnNTWarningRemoved);
            // Add a listener to the currrent warnings networktable property in case another program changes it.
            master._Dashboard_NT.AddKeyListener(NTCURRENTWARNINGS, (string key, Value value) => UpdateNTArray());

            // Listen for key changes in the cubeIn boolean
            master._Dashboard_NT.AddKeyListener(CUBESTATUSKEY, CubeStatusChanged);
        }
コード例 #7
0
        /// <summary>
        /// Adds a checkbox with the given text to the checklist
        /// </summary>
        /// <param name="text">The text on the checkbox</param>
        private void AddItem(object text)
        {
            string itemText = text.ToString();

            // Error validatation. If the default to-do is there still, remove it. If it's empty, return
            if (string.IsNullOrWhiteSpace(text.ToString()))
            {
                return;
            }
            else if (CheckListItems.Count == 1 && CheckListList.ElementAt(0).Content.ToString() == DefaultTODO)
            {
                CheckListList.RemoveAt(0);
            }

            // Make a checkbox for the item and add it.
            CheckListList.Add(MakeCheckBoxForItem(itemText));
            AddTextBox.Clear();

            // Save the newly created item.
            DataDealer.WriteChecklistData(CheckListItems);

            // Fire the event.
            ItemAdded?.Invoke(this, itemText);
        }
コード例 #8
0
 /// <summary>
 /// Saves the current state of the enabledness of the robot logging system
 /// </summary>
 private void SaveEnabledState()
 {
     // Append the data to the data dealer.
     DataDealer.AppendMiscData(ENABLED_KEY, IsEnabled);
 }
コード例 #9
0
        /// <summary>
        /// Handles all incoming packets into the server after fully recieving them
        /// </summary>
        /// <param name="packet">The packet that was recieved</param>
        /// <param name="clientSocket">The socket, used for sending back data to the client</param>
        public static void Handle(byte[] packet, Socket clientSocket)
        {
            // Get the packet length and type
            var packetLength = BitConverter.ToUInt32(packet, 0);
            var packetType   = BitConverter.ToUInt16(packet, 4);

            Console.WriteLine("Recieved packet of length: {0} and Type: {1}", packetLength, packetType);

            // Packet types:
            // 2000 - Update the steam token
            // 2001 - Update the host id
            // 2002 - Request to Update all the things
            // 2003 - Request to Update the summary
            // 2004
            // 3003 - Information to update the summary to the server
            switch (packetType)
            {
            case 2000:
                clientSocket.Send(new StdData(Program.SteamToken, 0, 2000).Data);
                break;

            case 2001:
                clientSocket.Send(new StdData("21", 0, 2001).Data);
                break;

            case 2002:
                clientSocket.Send(DataDealer.UpdateAll(new StdData(packet).MachineId));
                break;

            case 2003:
                clientSocket.Send(DataDealer.UpdateSum(true, new StdData(packet).MachineId).Data);
                break;

            case 2004:
                clientSocket.Send(DataDealer.UpdateGames(true, new StdData(packet).MachineId).Data);
                break;

            case 2006:
                clientSocket.Send(DataDealer.UpdateFriends(true, new StdData(packet).MachineId).Data);
                break;

            case 2007:
                try
                {
                    clientSocket.Send(new StdData("", 0, 1005).Data);
                    clientSocket.Send(DataDealer.UpdateGameNames(new StdData(packet).MachineId).Data);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                break;

            case 2050:
                clientSocket.Send(
                    new StdData(GetInformation.ShowGenStats(new StdData(packet).MachineId), 0, 3050).Data);
                break;

            case 2051:
                try
                {
                    clientSocket.Send(new StdData("", 0, 1005).Data);
                    clientSocket.Send(
                        new ListOfUsers(GetInformation.ShowPlayerStats(new StdData(packet)), 0, 3051).Data);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                break;

            case 3003:
                var list = new ListOfUsers(packet);
                try
                {
                    DataDealer.DealWithSum(list);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    clientSocket.Send(new StdData("", 0, 1000).Data);
                }
                break;

            case 3004:
                var gameUsers = new ListOfUsers(packet);
                try
                {
                    DataDealer.DealWithGames(gameUsers);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    clientSocket.Send(new StdData("", 0, 1000).Data);
                }
                break;

            case 3006:
                var friends = new ListOfUsers(packet);
                try
                {
                    clientSocket.Send(new StdData("", 0, 1005).Data);
                    DataDealer.DealWithFriends(friends);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    clientSocket.Send(new StdData("", 0, 1000).Data);
                }
                break;

            case 3007:
                var games = new ListOfGames(packet);
                try
                {
                    DataDealer.DealWithGameNames(games);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    clientSocket.Send(new StdData("", 0, 1000).Data);
                }
                break;
            }
        }