//Notification >> Play Sound
 private void Notifcation_PlaySound_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e)
 {
     if (e.Handled)
     {
         CheckBoxPreference etp = (CheckBoxPreference)sender;
         var value = e.NewValue.ToString();
         etp.Checked = Boolean.Parse(value);
         if (etp.Checked)
         {
             S_SoundControl = true;
         }
         else
         {
             S_SoundControl = false;
         }
     }
 }
 //Notifcation >> Popup
 private void Notifcation_Popup_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e)
 {
     if (e.Handled)
     {
         SwitchPreference etp = (SwitchPreference)sender;
         var value            = e.NewValue.ToString();
         etp.Checked = Boolean.Parse(value);
         if (etp.Checked)
         {
             OneSignalNotification.RegisterNotificationDevice();
         }
         else
         {
             OneSignalNotification.Un_RegisterNotificationDevice();
         }
     }
 }
        //General >> PictureInPicture
        private void PictureInPicturePerfOnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs e)
        {
            try
            {
                if (e.Handled)
                {
                    SwitchPreferenceCompat etp = (SwitchPreferenceCompat)sender;
                    var value = e.NewValue.ToString();
                    etp.Checked              = Boolean.Parse(value);
                    SPictureInPicture        = etp.Checked;
                    UserDetails.PipIsChecked = etp.Checked;

                    if (!AppTools.CheckPictureInPictureAllowed(ActivityContext) && SPictureInPicture)
                    {
                        var intent = new Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Android.Net.Uri.Parse("package:" + ActivityContext.PackageName));
                        ActivityContext.StartActivityForResult(intent, 8520);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Exemple #4
0
        public static NodeGraphManager BuildGraph(GraphEditorViewModel graph)
        {
            List <VisualNodeViewModel> visualExecutionNodes = new List <VisualNodeViewModel>();

            foreach (var graphComponent in graph.VisualNodes)
            {
                VisualNodeViewModel visualNode = graphComponent as VisualNodeViewModel;
                if (visualNode != null && visualNode.ExecutionInputs.Count > 0)
                {
                    visualExecutionNodes.Add(visualNode);
                }
            }

            // Begin to build our graph
            NodeGraphManager graphManager = new NodeGraphManager();

            Dictionary <VisualNodeViewModel, GraphNode> functionNodes = new Dictionary <VisualNodeViewModel, GraphNode>();
            List <VisualConstantNodeViewModel>          constantNodes = new List <VisualConstantNodeViewModel>();

            foreach (dynamic visualNode in graph.VisualNodes)
            {
                if (visualNode is VisualNodeViewModel)
                {
                    functionNodes.Add(visualNode, new GraphNode(visualNode.NodeType, graphManager));
                }
                else if (visualNode is VisualConstantNodeViewModel)
                {
                    constantNodes.Add(visualNode as VisualConstantNodeViewModel);
                }
            }

            // Wire up constant nodes
            foreach (var constantNode in constantNodes)
            {
                List <ConnectionViewModel> connections = GetPinConnections(constantNode.OutputPin, graph);

                // Lookup each input pin that the constant node is connecting to and add it in our graph manager
                foreach (var connection in connections)
                {
                    foreach (var functionNode in functionNodes)
                    {
                        if (functionNode.Key.Inputs.Contains(connection.InputPin))
                        {
                            // Get pin index
                            int pindex = ((NodePinViewModel)connection.InputPin).Index;

                            IDataTypeContainer valueToSet;

                            // Get value to set
                            if (constantNode.OutputPin.DataType == typeof(DataTypes.Numeric))
                            {
                                valueToSet = new DataTypes.Numeric(Double.Parse(constantNode.Value));
                            }
                            else if (constantNode.OutputPin.DataType == typeof(DataTypes.Boolean))
                            {
                                valueToSet = new DataTypes.Boolean(Boolean.Parse(constantNode.Value));
                            }
                            else if (constantNode.OutputPin.DataType == typeof(DataTypes.String))
                            {
                                valueToSet = new DataTypes.String(constantNode.Value);
                            }
                            else
                            {
                                throw new Exception("Data type could not be determined.");
                            }

                            OutputPin pinConnection = new OutputPin(
                                ((NodePinViewModel)connection.InputPin).DataType, null)
                            {
                                OutputValue = valueToSet, OutputRealised = true
                            };


                            graphManager.AddConnection(pinConnection, functionNode.Value.NodeInputs[pindex]);
                        }
                    }
                }
            }

            // Wire up functional nodes
            foreach (var functionNode in functionNodes)
            {
                int outputPindex = 0;

                // Check each output pin on the node
                foreach (var output in functionNode.Key.Outputs)
                {
                    List <ConnectionViewModel> connections = GetPinConnections(output, graph);

                    foreach (var connection in connections)
                    {
                        // Wire up non-execution pins
                        foreach (var targetFunctionNode in functionNodes)
                        {
                            if (targetFunctionNode.Key.Inputs.Contains(connection.InputPin))
                            {
                                int pindex = ((NodePinViewModel)connection.InputPin).Index;

                                graphManager.AddConnection(
                                    functionNodes[functionNode.Key].NodeOutputs[outputPindex],
                                    targetFunctionNode.Value.NodeInputs[pindex]);
                            }
                        }
                    }
                }

                // Wire up execution pins
                foreach (var executionOutput in functionNode.Key.ExecutionOutputs)
                {
                    List <ConnectionViewModel> connections = GetPinConnections(executionOutput, graph);

                    if (connections.Count == 0)
                    {
                        graphManager.AddNode(functionNode.Value);
                    }

                    foreach (var connection in connections)
                    {
                        foreach (var targetFunctionNode in functionNodes)
                        {
                            if (targetFunctionNode.Key.ExecutionInputs.Contains(connection.InputPin))
                            {
                                int pindex = ((NodePinViewModel)connection.OutputPin).Index;
                                graphManager.AddConnection(functionNode.Value, pindex, targetFunctionNode.Value);
                            }
                        }
                    }
                }
            }

            graphManager.RealiseNodeOutputs();

            return(graphManager);
        }