Exemplo n.º 1
0
        //Ignore and disconnect controller
        async void Btn_IgnoreController_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ControllerStatus activeController = vActiveController();
                if (activeController != null)
                {
                    int messageResult = await AVMessageBox.MessageBoxPopup(this, "Do you really want to ignore this controller?", "This will prevent the controller from been converted to XInput.", "Ignore the controller", "Cancel", "", "");

                    if (messageResult == 1)
                    {
                        //Update json profile
                        activeController.Details.Profile.Ignore = true;
                        JsonSaveObject(vDirectControllersProfile, "DirectControllersProfile");

                        //Release controller from hid guardian
                        HidGuardianReleaseController(activeController.Details);

                        //Disconnect the controller
                        await StopControllerAsync(activeController, "ignored");

                        Debug.Write("Ignored active controller.");
                    }
                }
                else
                {
                    NotificationDetails notificationDetails = new NotificationDetails();
                    notificationDetails.Icon = "Controller";
                    notificationDetails.Text = "No controller connected";
                    App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                }
            }
            catch { }
        }
    private void ShowNotificationList(NotificationDetails notificationDetails)
    {
        for (int i = 0; i < container.childCount; i++)
        {
            Destroy(container.GetChild(i).gameObject);
        }

        for (int i = 0; i < notificationDetails.notifications.Count; i++)
        {
            Notification notificationData = notificationDetails.notifications[i];

            GameObject gm = Instantiate(notificationPrefab, container) as GameObject;
            gm.transform.Find("Text").GetComponent <Text>().text = notificationData.title;
            Image icon = gm.transform.Find("Icon").GetComponent <Image>();

            if (notificationData.isRead)
            {
                icon.sprite = readImage;
            }
            else
            {
                icon.sprite = unreadImage;
            }

            gm.GetComponent <Button>().onClick.AddListener(() => ShowDetaildMessage(notificationData, icon));
        }

        layoutManager.UpdateLayout();
    }
Exemplo n.º 3
0
        //Set the keypad mapping profile
        void SetKeypadMappingProfile()
        {
            try
            {
                string        processNameLower           = vProcessForeground.Name.ToLower();
                string        processTitleLower          = vProcessForeground.Title.ToLower();
                KeypadMapping directKeypadMappingProfile = vDirectKeypadMapping.Where(x => x.Name.ToLower() == processNameLower || processTitleLower.Contains(x.Name.ToLower())).FirstOrDefault();
                if (directKeypadMappingProfile == null)
                {
                    directKeypadMappingProfile = vDirectKeypadMapping.Where(x => x.Name == "Default").FirstOrDefault();
                }

                //Show keypad mapping profile notification
                if (vKeypadMappingProfile != directKeypadMappingProfile)
                {
                    NotificationDetails notificationDetails = new NotificationDetails();
                    notificationDetails.Icon = "Keypad";
                    notificationDetails.Text = "Profile set to " + directKeypadMappingProfile.Name;
                    App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                }

                //Update the keypad mapping profile
                vKeypadMappingProfile = directKeypadMappingProfile;
            }
            catch { }
        }
Exemplo n.º 4
0
        //Send the notification status
        public async Task Notification_Send_Status(string targetIcon, string targetText)
        {
            try
            {
                //Check if socket server is running
                if (vArnoldVinkSockets == null)
                {
                    Debug.WriteLine("The socket server is not running.");
                    return;
                }

                //Create notification class
                NotificationDetails NotificationDetails = new NotificationDetails();
                NotificationDetails.Icon = targetIcon;
                NotificationDetails.Text = targetText;

                //Prepare socket data
                SocketSendContainer socketSend = new SocketSendContainer();
                socketSend.SourceIp   = vArnoldVinkSockets.vSocketServerIp;
                socketSend.SourcePort = vArnoldVinkSockets.vSocketServerPort;
                socketSend.Object     = NotificationDetails;

                //Request controller status
                byte[] SerializedData = SerializeObjectToBytes(socketSend);

                //Send socket data
                TcpClient tcpClient = await vArnoldVinkSockets.TcpClientCheckCreateConnect(vArnoldVinkSockets.vSocketServerIp, vArnoldVinkSockets.vSocketServerPort + 1, vArnoldVinkSockets.vSocketTimeout);

                await vArnoldVinkSockets.TcpClientSendBytesServer(tcpClient, SerializedData, vArnoldVinkSockets.vSocketTimeout, false);
            }
            catch { }
        }
Exemplo n.º 5
0
        public void sendNotificationMsg(string from, string to, string msg)
        {
            var touser = UserHandler.chatusers.Where(x => x.connID == to).FirstOrDefault();

            //   string connectionString = @"Data Source=DOTNETSERVER\SQLEXPRESS;Initial Catalog=SignalRDemo;  user id=sa;password=C1tytech;  ";
            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SqlDependencyConfig"].ConnectionString;
            string sqlQueue         = @"NamesQueue";
            //Listener query restrictions: http://msdn.microsoft.com/en-us/library/aewzkxxh.aspx
            string     listenerQuery = "SELECT [NotificationId],[UserId],[NotificationMessage],[CreatedDateTime],[IsSeen] FROM[dbo].[NotificationDetails] ";
            SqlWatcher w             = new SqlWatcher(connectionString, sqlQueue, listenerQuery);

            w.Start();

            NotificationService _ns = new NotificationService();

            NotificationDetails nd = new NotificationDetails()
            {
                UserId = _ns.GetuserIdBYSignalRId(touser.connID),
                NotificationMessage = msg,
                CreatedDateTime     = DateTime.Now
            };

            _ns.SaveNotification(nd);

            Clients.Client(touser.connID).sendMessage(from, msg);
            Clients.Caller.notifyMessageDelivered(touser.name);
        }
Exemplo n.º 6
0
        //Copy controller debug information
        async void Btn_CopyDebugInformation_Click(object sender, RoutedEventArgs args)
        {
            try
            {
                ControllerStatus activeController = vActiveController();
                if (activeController != null && activeController.InputReport != null)
                {
                    Clipboard.SetText(GenerateControllerDebugString(true));

                    Debug.WriteLine("Controller debug information copied to clipboard.");
                    NotificationDetails notificationDetails = new NotificationDetails();
                    notificationDetails.Icon = "Paste";
                    notificationDetails.Text = "Debug information copied";
                    await App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                }
                else
                {
                    Debug.WriteLine("Controller debug information is not available.");
                    NotificationDetails notificationDetails = new NotificationDetails();
                    notificationDetails.Icon = "Controller";
                    notificationDetails.Text = "No controller connected";
                    await App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                }
            }
            catch { }
        }
        private static async Task <NotificationDetails> GetPushDetailsAndPrintOutcome(RedundantNotificationHubClient nhClient, NotificationOutcome notificationOutcome)
        {
            if (string.IsNullOrEmpty(notificationOutcome.NotificationId))
            {
                Console.WriteLine($"Fcm has no outcome due to it is only available for Standard SKU pricing tier.");
                return(null);
            }

            var notificationId = notificationOutcome.NotificationId;
            var state          = NotificationOutcomeState.Enqueued;
            var count          = 0;
            NotificationDetails outcomeDetails = null;

            while ((state == NotificationOutcomeState.Enqueued || state == NotificationOutcomeState.Processing) && ++count < 10)
            {
                try
                {
                    Console.WriteLine($"Status: {state}");
                    outcomeDetails = await nhClient.GetNotificationOutcomeDetailsAsync(notificationId);

                    state = outcomeDetails.State;
                }
                catch (MessagingEntityNotFoundException)
                {
                    // It's possible for the notification to not yet be enqueued, so we may have to swallow an exception
                    // until it's ready to give us a new state.
                }
                Thread.Sleep(1000);
            }
            return(outcomeDetails);
        }
Exemplo n.º 8
0
        private static async Task <NotificationDetails> WaitForThePushStatusAsync(string pnsType, NotificationHubClient nhClient, NotificationOutcome notificationOutcome)
        {
            var notificationId = notificationOutcome.NotificationId;
            var state          = NotificationOutcomeState.Enqueued;
            var count          = 0;
            NotificationDetails outcomeDetails = null;

            while ((state == NotificationOutcomeState.Enqueued || state == NotificationOutcomeState.Processing) && ++count < 10)
            {
                try
                {
                    Console.WriteLine($"{pnsType} status: {state}");
                    outcomeDetails = await nhClient.GetNotificationOutcomeDetailsAsync(notificationId);

                    state = outcomeDetails.State;
                }
                catch (MessagingEntityNotFoundException)
                {
                    // It's possible for the notification to not yet be enqueued, so we may have to swallow an exception
                    // until it's ready to give us a new state.
                }
                Thread.Sleep(1000);
            }
            return(outcomeDetails);
        }
Exemplo n.º 9
0
        //Show the notification overlay
        public void Notification_Show_Status(NotificationDetails notificationDetails)
        {
            try
            {
                //Update notification position
                UpdateNotificationPosition();

                //Show the notification
                AVActions.ActionDispatcherInvoke(delegate
                {
                    try
                    {
                        grid_Message_Status_Image.Source = FileToBitmapImage(new string[] { "Assets/Default/Icons/" + notificationDetails.Icon + ".png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                        grid_Message_Status_Text.Text    = notificationDetails.Text;
                        grid_Message_Status.Visibility   = Visibility.Visible;
                    }
                    catch { }
                });

                //Start notification timer
                vDispatcherTimerOverlay.Interval = TimeSpan.FromMilliseconds(3000);
                vDispatcherTimerOverlay.Tick    += delegate
                {
                    try
                    {
                        //Hide the notification
                        grid_Message_Status.Visibility = Visibility.Collapsed;
                    }
                    catch { }
                };
                AVFunctions.TimerReset(vDispatcherTimerOverlay);
            }
            catch { }
        }
Exemplo n.º 10
0
        private static async Task ShowCtrlUI()
        {
            try
            {
                //Check if socket server is running
                if (vArnoldVinkSockets == null)
                {
                    Debug.WriteLine("The socket server is not running.");
                    return;
                }

                Debug.WriteLine("Showing CtrlUI.");

                //Show notification
                NotificationDetails notificationDetails = new NotificationDetails();
                notificationDetails.Icon = "AppLaunch";
                notificationDetails.Text = "Showing CtrlUI";
                await App.vWindowOverlay.Notification_Show_Status(notificationDetails);

                //Prepare socket data
                SocketSendContainer socketSend = new SocketSendContainer();
                socketSend.SourceIp   = vArnoldVinkSockets.vSocketServerIp;
                socketSend.SourcePort = vArnoldVinkSockets.vSocketServerPort;
                socketSend.Object     = "AppWindowHideShow";
                byte[] SerializedData = SerializeObjectToBytes(socketSend);

                //Send socket data
                TcpClient tcpClient = await vArnoldVinkSockets.TcpClientCheckCreateConnect(vArnoldVinkSockets.vSocketServerIp, vArnoldVinkSockets.vSocketServerPort - 1, vArnoldVinkSockets.vSocketTimeout);

                await vArnoldVinkSockets.TcpClientSendBytesServer(tcpClient, SerializedData, vArnoldVinkSockets.vSocketTimeout, false);
            }
            catch { }
        }
Exemplo n.º 11
0
        //Profile - Keypad remove profile
        void Btn_Settings_KeypadProcessProfile_Remove_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                KeypadMapping selectedProfile = (KeypadMapping)combobox_KeypadProcessProfile.SelectedItem;
                if (selectedProfile.Name != "Default")
                {
                    //Remove mapping from list
                    vDirectKeypadMapping.Remove(selectedProfile);

                    //Save changes to Json file
                    JsonSaveObject(vDirectKeypadMapping, "DirectKeypadMapping");

                    //Select the default profile
                    combobox_KeypadProcessProfile.SelectedIndex = 0;

                    NotificationDetails notificationDetails = new NotificationDetails();
                    notificationDetails.Icon = "RemoveCross";
                    notificationDetails.Text = "Application removed";
                    App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                    Debug.WriteLine("Removed the keypad profile.");
                }
                else
                {
                    NotificationDetails notificationDetails = new NotificationDetails();
                    notificationDetails.Icon = "Close";
                    notificationDetails.Text = "Cannot remove default";
                    App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                    Debug.WriteLine("Default profile cannot be removed.");
                }
            }
            catch { }
        }
Exemplo n.º 12
0
        //Activate controller
        async Task <bool> ControllerActivate(ControllerStatus Controller)
        {
            try
            {
                if (Controller.Connected() && !Controller.Activated)
                {
                    Debug.WriteLine("Activating controller: " + Controller.NumberId);

                    ControllerStatus activeController = vActiveController();
                    if (activeController != null)
                    {
                        //Deactivate previous controller
                        activeController.Activated = false;

                        //Show controller activated notification
                        string controllerNumberDisplay          = (Controller.NumberId + 1).ToString();
                        NotificationDetails notificationDetails = new NotificationDetails();
                        notificationDetails.Icon  = "Controller";
                        notificationDetails.Text  = "Activated (" + controllerNumberDisplay + ")";
                        notificationDetails.Color = Controller.Color;
                        await App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                    }

                    //Activate current controller
                    Controller.Activated = true;

                    //Update settings interface
                    ControllerUpdateSettingsInterface(Controller);
                    return(true);
                }
            }
            catch { }
            return(false);
        }
Exemplo n.º 13
0
        public static void Request()
        {
            NotificationDetails details = new NotificationDetails();

            details.Add("platform", Tools.Platform);

            SendNotification(APIUser.CurrentUser.displayName, APIUser.CurrentUser.id, "requestInvite", string.Empty, details);
        }
Exemplo n.º 14
0
 public DatabaseNotification(NotificationDetails notificationDetails)
 {
     NotificationId  = notificationDetails.NotificationId;
     AlertId         = notificationDetails.AlertId;
     TriggerDateTime = notificationDetails.TriggerDateTime;
     Acknowledged    = notificationDetails.Acknowledged;
     FailedEmail     = notificationDetails.FailedEmail;
 }
Exemplo n.º 15
0
 public static IBenoyEmailFilingSubscription GetByIdentifier(NotificationDetails identifier)
 {
     if (identifier == null)
     {
         throw new ArgumentNullException(nameof(identifier));
     }
     return(GetByIdentifier(identifier.SubscriptionName, identifier.MailBox));
 }
Exemplo n.º 16
0
        //Ignore and disconnect controller
        async void btn_IgnoreController_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ControllerStatus activeController = vActiveController();
                if (activeController != null)
                {
                    List <string> messageAnswers = new List <string>();
                    messageAnswers.Add("Ignore this controller model");
                    messageAnswers.Add("Cancel");

                    string messageResult = await new AVMessageBox().Popup(this, "Do you really want to ignore this controller?", "This will prevent this controller model from been converted to XInput.", messageAnswers);
                    if (messageResult == "Ignore this controller model")
                    {
                        string lowerVendorId  = activeController.Details.Profile.VendorID.ToLower();
                        string lowerProductId = activeController.Details.Profile.ProductID.ToLower();

                        //Update json profile
                        ControllerIgnored existingVendor = vDirectControllersIgnored.Where(x => x.VendorID.ToLower() == lowerVendorId).FirstOrDefault();
                        if (existingVendor != null)
                        {
                            List <string> existingProducts = existingVendor.ProductIDs.ToList();
                            existingProducts.Add(lowerProductId);
                            existingVendor.ProductIDs = existingProducts.ToArray();

                            Debug.WriteLine("Updated controller in ignore list: " + lowerVendorId + "/" + lowerProductId);
                        }
                        else
                        {
                            ControllerIgnored newController = new ControllerIgnored();
                            newController.CodeName   = activeController.Details.DisplayName;
                            newController.VendorID   = lowerVendorId;
                            newController.ProductIDs = new string[] { lowerProductId };
                            vDirectControllersIgnored.Add(newController);

                            Debug.WriteLine("Added new controller to ignore list: " + lowerVendorId + "/" + lowerProductId);
                        }

                        //Save json profile
                        JsonSaveObject(vDirectControllersIgnored, @"User\DirectControllersIgnored");

                        //Load ignored controllers to list
                        ListboxLoadIgnoredController();

                        //Disconnect the controller
                        StopControllerTask(activeController, "ignored", "Controller " + activeController.Details.DisplayName + " ignored and disconnected.");
                    }
                }
                else
                {
                    NotificationDetails notificationDetails = new NotificationDetails();
                    notificationDetails.Icon = "Controller";
                    notificationDetails.Text = "No controller connected";
                    await App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                }
            }
            catch { }
        }
Exemplo n.º 17
0
        //Update the keyboard mode
        async Task UpdateKeyboardMode()
        {
            try
            {
                await AVActions.ActionDispatcherInvokeAsync(async delegate
                {
                    //Check keyboard mode
                    KeyboardMode keyboardMode = (KeyboardMode)Convert.ToInt32(Setting_Load(vConfigurationDirectXInput, "KeyboardMode"));
                    if (keyboardMode == KeyboardMode.Media)
                    {
                        //Update help bar
                        stackpanel_DPad.Visibility     = Visibility.Visible;
                        textblock_ButtonLeft.Text      = "Media Prev";
                        textblock_ButtonRight.Text     = "Media Next";
                        textblock_ButtonUp.Text        = "Play/Pause";
                        textblock_ThumbRightOff.Text   = "Move";
                        textblock_LeftTriggerOff.Text  = string.Empty;
                        textblock_RightTriggerOff.Text = "Volume";
                        textblock_ThumbPress.Text      = "Mute";
                        textblock_BackOff.Text         = "Fullscreen";
                        image_Mode.Source = vImagePreloadIconKeyboardMedia;

                        //Play sound
                        PlayInterfaceSound(vConfigurationCtrlUI, "Click", false, false);

                        //Show notification
                        NotificationDetails notificationDetails = new NotificationDetails();
                        notificationDetails.Icon = "Keyboard";
                        notificationDetails.Text = "Switched to media mode";
                        await App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                    }
                    else if (keyboardMode == KeyboardMode.Scroll)
                    {
                        //Update help bar
                        stackpanel_DPad.Visibility     = Visibility.Collapsed;
                        textblock_ButtonLeft.Text      = "Backspace";
                        textblock_ButtonRight.Text     = "Enter";
                        textblock_ButtonUp.Text        = "Space";
                        textblock_ThumbRightOff.Text   = "Scroll";
                        textblock_LeftTriggerOff.Text  = "Caps";
                        textblock_RightTriggerOff.Text = "Tab";
                        textblock_ThumbPress.Text      = "Arrows";
                        textblock_BackOff.Text         = "Emoji/Text";
                        image_Mode.Source = vImagePreloadIconKeyboardScroll;

                        //Play sound
                        PlayInterfaceSound(vConfigurationCtrlUI, "Click", false, false);

                        //Show notification
                        NotificationDetails notificationDetails = new NotificationDetails();
                        notificationDetails.Icon = "Keyboard";
                        notificationDetails.Text = "Switched to scroll mode";
                        await App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                    }
                });
            }
            catch { }
        }
Exemplo n.º 18
0
        public NotificationDetails GetNotificationDetailsById(int notificationId)
        {
            NotificationDetails notification = new NotificationDetails(_databaseQueryService.GetNotificationById(notificationId));

            notification.Alert                 = new AlertDetails(_databaseQueryService.GetAlertById(notification.AlertId));
            notification.Alert.Camera          = new CameraDetails(_databaseQueryService.GetCameraById(notification.Alert.CameraId));
            notification.Alert.Camera.Location = new LocationDetails(_databaseQueryService.GetLocationById(notification.Alert.Camera.LocationId));
            return(notification);
        }
        public async Task AddNotificationAsync(Guid buildId, string channelId, WatchLevel watchLevel)
        {
            var notification = new NotificationDetails(buildId, channelId, watchLevel);

            logger.LogInformation($"Adding notification: '{notification}'");

            notificationDb.Add(notification);
            await notificationDb.SaveChangesAsync();
        }
Exemplo n.º 20
0
        public void SetDetails(NotificationDetails details)
        {
            ImportNotificationId = details.ImportNotificationId;
            NotificationType     = details.NotificationType;

            Codes =
                OperationCodeMetadata.GetCodesForOperation(details.NotificationType)
                .Select(c => new KeyValuePairViewModel <OperationCode, bool>(c, SelectedCodes.Contains(c)))
                .ToList();
        }
    public void QueueNotification(string message, float duration=-1f)
    {
        NotificationDetails notificationDeets = new NotificationDetails();
        notificationDeets.Message = message;
        notificationDeets.Duration = duration == -1f ? NOTIFICATION_DURATION : duration;

        stack.Add(notificationDeets);

        if (!notificationPanel.activeSelf && stack.Count == 1) ShowNextMessage();
    }
Exemplo n.º 22
0
 //Show the notification overlay
 public async Task Notification_Show_Status(string icon, string text)
 {
     try
     {
         NotificationDetails notificationDetails = new NotificationDetails();
         notificationDetails.Icon = icon;
         notificationDetails.Text = text;
         await Notification_Show_Status(notificationDetails);
     }
     catch { }
 }
Exemplo n.º 23
0
        public IActionResult NotificationInformation(int notificationId)
        {
            if (HttpContext.Session.GetString("currentUsername") == null)
            {
                return(RedirectToAction("SignIn", "Home"));
            }

            NotificationDetails notificationDetails = NotificationService.GetNotificationDetailsById(notificationId);

            return(View("NotificationInformation", notificationDetails));
        }
Exemplo n.º 24
0
 /// <summary>
 /// Adds the notification details.
 /// </summary>
 /// <param name="model">The model.</param>
 private void AddNotificationDetails(AttachmentNotificationSettingsModel model)
 {
     foreach (var item in model.notifyInfo)
     {
         NotificationDetails details = new NotificationDetails();
         details.AttachmentId      = model.AttachmentId;
         details.NotiicationSendOn = item.notifyText;
         details.type = model.ByEmail != false ? (int)NotificationDetailsEnum.Email : (int)NotificationDetailsEnum.Text;
         this.m_NotificationDetailsRepository.Add(details);
     }
 }
Exemplo n.º 25
0
 private static void PrintPushOutcome(string pnsType, NotificationDetails details, NotificationOutcomeCollection collection)
 {
     if (collection != null)
     {
         Console.WriteLine($"{pnsType} outcome: " + string.Join(",", collection.Select(kv => $"{kv.Key}:{kv.Value}")));
     }
     else
     {
         Console.WriteLine($"{pnsType} no outcomes.");
     }
     Console.WriteLine($"{pnsType} error details URL: {details.PnsErrorDetailsUri}");
 }
Exemplo n.º 26
0
 private static void PrintPushOutcome(NotificationDetails details, bool isPrimary)
 {
     if (details.FcmOutcomeCounts != null)
     {
         Console.WriteLine($"Notification outcome for {(isPrimary ? "Primary" : "Backup")}: " + string.Join(",", details.FcmOutcomeCounts.Select(kv => $"{kv.Key}:{kv.Value}")));
     }
     else
     {
         Console.WriteLine($"No outcomes for {(isPrimary ? "Primary" : "Backup")}");
     }
     Console.WriteLine($"{(isPrimary ? "Primary" : "Backup")} error details URL: {details.PnsErrorDetailsUri}");
 }
 public void SaveNotification(NotificationDetails nd)
 {
     try
     {
         db.NotificationDetails.Add(nd);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 28
0
 private void PrintPushOutcome(string pnsType, NotificationDetails details, NotificationOutcomeCollection collection)
 {
     if (collection != null)
     {
         _logger.LogInformation($"{pnsType} outcome: " + string.Join(",", collection.Select(kv => $"{kv.Key}:{kv.Value}")));
     }
     else
     {
         _logger.LogInformation($"{pnsType} no outcomes.");
     }
     _logger.LogInformation($"{pnsType} error details URL: {details.PnsErrorDetailsUri}");
 }
Exemplo n.º 29
0
        //Check controller for low battery level
        async Task ControllerLowBattery(ControllerStatus Controller, bool forceUpdate)
        {
            try
            {
                //Debug.WriteLine("Checking if controller " + Controller.NumberId + " has a low battery level " + Controller.BatteryPercentageCurrent + "/" + Controller.BatteryPercentagePrevious);
                string controllerNumberDisplay = (Controller.NumberId + 1).ToString();

                //Check if the controller is connected
                if (Controller == null || !Controller.Connected())
                {
                    return;
                }

                //Check the current battery level
                bool batteryLevelChanged = Controller.BatteryCurrent.BatteryPercentage != Controller.BatteryPrevious.BatteryPercentage || Controller.BatteryCurrent.BatteryStatus != Controller.BatteryPrevious.BatteryStatus;
                bool batteryLevelLow     = Controller.BatteryCurrent.BatteryPercentage <= Convert.ToInt32(Setting_Load(vConfigurationDirectXInput, "BatteryLowLevel")) && Controller.BatteryCurrent.BatteryStatus == BatteryStatus.Normal;

                //Check if battery level changed
                if (forceUpdate || batteryLevelChanged)
                {
                    Debug.WriteLine("Controller " + Controller.NumberId + " battery level changed.");

                    //Check if battery level is low
                    if (batteryLevelLow)
                    {
                        Debug.WriteLine("Controller " + Controller.NumberId + " has a low battery level.");

                        //Battery level notification
                        if (Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "BatteryLowShowNotification")))
                        {
                            NotificationDetails notificationDetails = new NotificationDetails();
                            notificationDetails.Icon  = "Battery/BatteryVerDis20";
                            notificationDetails.Text  = "Controller (" + controllerNumberDisplay + ") battery " + Controller.BatteryCurrent.BatteryPercentage + "%";
                            notificationDetails.Color = Controller.Color;
                            await App.vWindowOverlay.Notification_Show_Status(notificationDetails);
                        }

                        //Battery level sound
                        if (Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "BatteryLowPlaySound")))
                        {
                            PlayInterfaceSound(vConfigurationCtrlUI, "BatteryLow", true, false);
                        }
                    }
                }

                //Update the previous battery level
                CloneObjectShallow(Controller.BatteryCurrent, out Controller.BatteryPrevious);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed checking low battery level: " + ex.Message);
            }
        }
Exemplo n.º 30
0
        //Disconnect and stop all controllers
        async void Btn_DisconnectControllerAll_Click(object sender, RoutedEventArgs args)
        {
            try
            {
                StopAllControllers(false);

                NotificationDetails notificationDetails = new NotificationDetails();
                notificationDetails.Icon = "Controller";
                notificationDetails.Text = "Disconnected all controllers";
                await App.vWindowOverlay.Notification_Show_Status(notificationDetails);
            }
            catch { }
        }
Exemplo n.º 31
0
        public NotificationViewData Build(NotificationDetails notification)
        {
            if (notification.Type != NotificationType.Message)
            {
                throw new ChalkableException(ChlkResources.ERR_INVALID_NOTIFICATION_BUILDER_FOR_TYPE);
            }
            var res = new NotificationViewData(notification)
            {
                Person = ShortPersonViewData.Create(notification.PrivateMessage.Sender)
            };

            return(res);
        }
        public WasteOperationViewModel(NotificationDetails details, WasteOperation data)
        {
            ImportNotificationId = details.ImportNotificationId;
            NotificationType = details.NotificationType;

            var selectedCodes = data.OperationCodes ?? new OperationCode[0];

            Codes =
                OperationCodeMetadata.GetCodesForOperation(details.NotificationType)
                    .Select(c => new KeyValuePairViewModel<OperationCode, bool>(c, selectedCodes.Contains(c)))
                    .ToList();

            TechnologyEmployed = data.TechnologyEmployed;
        }
 public MarkAsInterimViewModel(NotificationDetails data)
 {
     NotificationId = data.ImportNotificationId;
     IsInterim = data.IsInterim;
     NotificationStatus = data.Status;
 }