public CommandLinePrompt(MachineStartPage msp)
 {
     InitializeComponent();
     textBox.Focus();
     machineStartPage = msp;
     uikind = msp.GetUIKind();
 }
 public SamaritanStartPage(bool train, UIKind uk)
 {
     InitializeComponent();
     uikind = uk;
     trainMachine = train;
     dispatchTimer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.ApplicationIdle, timerTick, Application.Current.Dispatcher);
 }
Ejemplo n.º 3
0
        /// <summary>   Constructor. </summary>
        ///
        /// <remarks>   Ken, 10/5/2020. </remarks>
        ///
        /// <param name="uiHierarchyPath">  Full pathname of the hierarchy file. </param>
        /// <param name="pathRootAlias">    The path root alias. </param>
        /// <param name="uiKind">             (Optional) The kind. </param>
        /// <param name="useRouter">        (Optional) True to use router. </param>

        public UIAttribute(string uiHierarchyPath, string pathRootAlias, UIKind uiKind = UIKind.None, bool useRouter = false)
        {
            this.UIHierarchyPath = uiHierarchyPath;
            this.UIKind          = uiKind;
            this.PathRootAlias   = pathRootAlias;
            this.UseRouter       = useRouter;
        }
Ejemplo n.º 4
0
 public SamaritanStartPage(bool train, UIKind uk)
 {
     InitializeComponent();
     uikind        = uk;
     trainMachine  = train;
     dispatchTimer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.ApplicationIdle, timerTick, Application.Current.Dispatcher);
 }
 public CommandLinePrompt(MachineStartPage msp)
 {
     InitializeComponent();
     textBox.Focus();
     machineStartPage = msp;
     uikind           = msp.GetUIKind();
 }
 public MachineStartPage(bool train, UIKind uk)
 {
     InitializeComponent();
     trainMachine = train;
     dispatchTimer = new DispatcherTimer();
     dispatchTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
     dispatchTimer.Tick += timerTick;
     uikind = uk;
 }
 public MachineStartPage(bool train, UIKind uk)
 {
     InitializeComponent();
     trainMachine           = train;
     dispatchTimer          = new DispatcherTimer();
     dispatchTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
     dispatchTimer.Tick    += timerTick;
     uikind = uk;
 }
Ejemplo n.º 8
0
        public ErrorReportingUI(string title, UIKind kind, Action action, bool closeAfterAction = true)
        {
            Contract.ThrowIfNull(title);

            Title = title;
            Kind = kind;
            Action = action;
            CloseAfterAction = closeAfterAction;
        }
Ejemplo n.º 9
0
        public ErrorReportingUI(string title, UIKind kind, Action action, bool closeAfterAction = true)
        {
            Contract.ThrowIfNull(title);

            Title            = title;
            Kind             = kind;
            Action           = action;
            CloseAfterAction = closeAfterAction;
        }
Ejemplo n.º 10
0
    // Token: 0x06000187 RID: 391 RVA: 0x0001843C File Offset: 0x0001663C
    public void PlayUISFX(ref AudioSourceController controller, UIKind Kind = UIKind.Normal)
    {
        if (!this.PlayUISFX(Kind))
        {
            return;
        }
        int num = (int)this.poolIndex;

        if (num == 0)
        {
            num = 19;
        }
        controller = this.SourceController;
        controller.Set(this.SFXSource[num - 1]);
    }
Ejemplo n.º 11
0
        protected override void OnStartup(StartupEventArgs args)
        {
            base.OnStartup(args);
            // Test whether or not to train the Machine by looking for the existence of various files.
            bool train = !Directory.Exists(FileUtilities.DirectoryName) || !File.Exists(FileUtilities.DirectoryName + "\\" + FileUtilities.AssetIndexData) ||
                         !File.Exists(FileUtilities.DirectoryName + "\\" + FileUtilities.CoreImageData);
            UIKind uikind = UIKind.UISamaritan;

            if (uikind == UIKind.UIMachine)
            {
                MachineStartPage m = new MachineStartPage(train, uikind);
                m.Show();
            }
            else if (uikind == UIKind.UISamaritan)
            {
                SamaritanStartPage ssp = new SamaritanStartPage(train, uikind);
                ssp.Show();
            }
        }
Ejemplo n.º 12
0
        /***
         *  Function: public InputSelection(bool train, bool disposal, String name, String title, String mwt, FaceIdentity fit)
         *  Parameter(s): bool train
         *      Whether or not to train the Machine (this is passed to the MainWindow.xaml.cs file).
         *                bool disposal
         *      Whether or not to enable resouce disposal.
         *                String name
         *      The name of the person that the Machine will train itself to recognize (if training is enabled; should be "" if trainMachine is false).
         *                String title
         *      The title of the input selection window.
         *                String mainWindowTitle
         *      The title of the main window (this is passed to the MainWindow.xaml.cs file).
         *                FaceIdentity fit
         *      The classification of the face to be examined during training (should be FaceIdentity.FaceNone if the Machine is not training; if the Machine is training).
         *                MachineStartPage msp
         *      A reference to the main window to control it.
         *  Return Value: N/A (Constructor)
         ***/
        public InputSelection(bool train, bool disposal, String name, String title, String mwt, FaceIdentity fit,
                              MachineStartPage msp, UIKind uk)
        {
            InitializeComponent();
            machineStartPage = msp;
            this.Title       = title;
            trainMachine     = train;
            faceIdentity     = fit;
            trainingName     = name;
            mainWindowTitle  = mwt;
            if (!disposal)
            {
                resDisposal = false;

                // Completely disable the option (this is only applicable for training).
                resourceDisposal.IsEnabled = false;
            }
            Closed += InputSelection_Closed;
            uikind  = uk;
        }
Ejemplo n.º 13
0
 public abstract dynamic GetResources(UIKind componentKind);
Ejemplo n.º 14
0
    // Token: 0x06000188 RID: 392 RVA: 0x00018480 File Offset: 0x00016680
    public bool PlayUISFX(UIKind Kind = UIKind.Normal)
    {
        if (this.MuteSFXVol || Kind == UIKind.None || this.AudioAssetBundleKey == 0)
        {
            return(false);
        }
        this.GetEmptyIndex();
        CString cstring = StringManager.Instance.StaticString1024();
        ushort  num     = (ushort)Kind;

        if (num == 0)
        {
            return(false);
        }
        int num2 = (int)(num / 100);

        cstring.StringToFormat(this.Path);
        cstring.IntToFormat((long)num2, 3, false);
        cstring.AppendFormat("{0}{1}");
        if (num == 40030 && this.bPlayOnlyOneClip >= 0)
        {
            return(false);
        }
        AssetBundle assetBundle = AssetManager.GetAssetBundle(cstring, out this.SFXBundleKey[(int)this.poolIndex]);

        if (assetBundle)
        {
            if (num == 40030)
            {
                this.bPlayOnlyOneClip = (short)this.poolIndex;
            }
            cstring.ClearString();
            cstring.IntToFormat((long)num, 1, false);
            cstring.AppendFormat("{0}");
            this.SFXClip.clip = (assetBundle.Load(cstring.ToString(), typeof(AudioClip)) as AudioClip);
            if (this.SFXClip.clip == null)
            {
                AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true);
                this.SFXBundleKey[(int)this.poolIndex] = 0;
                return(false);
            }
            this.SFXClip.DelaySecond = null;
            if (num2 == 300 && num != 30005)
            {
                this.SFXClip.Pitch = 0.8909f + 0.553f * UnityEngine.Random.value;
            }
            else
            {
                this.SFXClip.Pitch = 1f;
            }
            this.SFXClip.PanLevel = 0f;
            this.SFXClip.Loop     = false;
            this.SFXClip.Volume   = 1f;
            AudioSource[] sfxsource = this.SFXSource;
            byte          b;
            this.poolIndex = (b = this.poolIndex) + 1;
            this.PlayAudio(sfxsource[(int)b], this.SFXClip);
            this.ChangeDuckingState(AudioManager.DuckingState.Start);
            if (this.poolIndex >= 20)
            {
                this.poolIndex = 0;
            }
        }
        else
        {
            AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true);
            this.SFXBundleKey[(int)this.poolIndex] = 0;
        }
        return(true);
    }
Ejemplo n.º 15
0
        /// <summary>   Constructor. </summary>
        ///
        /// <remarks>   Ken, 10/5/2020. </remarks>
        ///
        /// <param name="uiKind">         The kind. </param>
        /// <param name="uiLoadKind">     The load kind. </param>
        /// <param name="useRouter">    (Optional) True to use router. </param>

        public UIAttribute(UIKind uiKind, UILoadKind uiLoadKind, bool useRouter = false)
        {
            this.UIKind     = uiKind;
            this.UILoadKind = uiLoadKind;
            this.UseRouter  = useRouter;
        }
Ejemplo n.º 16
0
        /***
            Function: public InputSelection(bool train, bool disposal, String name, String title, String mwt, FaceIdentity fit)
            Parameter(s): bool train
                Whether or not to train the Machine (this is passed to the MainWindow.xaml.cs file).
                          bool disposal
                Whether or not to enable resouce disposal.
                          String name
                The name of the person that the Machine will train itself to recognize (if training is enabled; should be "" if trainMachine is false).
                          String title
                The title of the input selection window.
                          String mainWindowTitle
                The title of the main window (this is passed to the MainWindow.xaml.cs file).
                          FaceIdentity fit
                The classification of the face to be examined during training (should be FaceIdentity.FaceNone if the Machine is not training; if the Machine is training).
                          MachineStartPage msp
                A reference to the main window to control it.
            Return Value: N/A (Constructor)
        ***/
        public InputSelection(bool train, bool disposal, String name, String title, String mwt, FaceIdentity fit,
            MachineStartPage msp, UIKind uk)
        {
            InitializeComponent();
            machineStartPage = msp;
            this.Title = title;
            trainMachine = train;
            faceIdentity = fit;
            trainingName = name;
            mainWindowTitle = mwt;
            if(!disposal)
            {
                resDisposal = false;

                // Completely disable the option (this is only applicable for training).
                resourceDisposal.IsEnabled = false;
            }
            Closed += InputSelection_Closed;
            uikind = uk;
        }
Ejemplo n.º 17
0
        public ResourceHelper CreateHelper(UIKind componentKind, IBase baseObject)
        {
            resources = appResources.GetResources(componentKind);

            return(new ResourceHelper(this, baseObject, resources));
        }
Ejemplo n.º 18
0
 public UINavigationNameAttribute(string name, UIKind kind, UILoadKind loadKind)
 {
     this.Name       = name;
     this.UIKind     = kind;
     this.UILoadKind = loadKind;
 }
        /***
         *  Function: public MainWindow(bool train, FaceIdentity fit, String nt, int cn, int fps, bool crd, int mdt, MachineInputSourceKind misk)
         *  Parameter(s): bool train
         *      Whether or not the machine is supposed to be training itself.
         *                FaceIdentity fit
         *      The classification of the person that the Machine is training itself to recognize (supposed to be equal to FaceIdentity.FaceNone during
         *      normal execution).
         *                String nt
         *      The name of the person that the Machine is training itself to recognize (supposed to be equal to "" during normal execution).
         *                int cn
         *      The camera number to used by the 'capture' variable.
         *                int fps
         *      The frame rate of the camera (not used when processing video files).
         *                bool crd
         *      Whether or not the Machine should dispose of resources (could potentially be unstable).
         *                int mdt
         *      The maxDistanceThreshold to use when classifying faces.
         *                 MachineInputSourceKind misk
         *      The input source from which the Machine will gather its input.
         *                 String t
         *      The title of this window.
         *                  MachineStartPage msp
         *      A reference to the main machine window to control.
         *  Return Value: N/A (Constructor)
         ***/
        public MainWindow(bool train, FaceIdentity fit, String nt, int cn, int fps, bool crd, int mdt,
                          MachineInputSourceKind misk, String t, MachineStartPage msp, UIKind uk)
        {
            machineStartPage       = msp;
            cameraResourceDisposal = crd;
            maxDistanceThreshold   = mdt;
            cameraNumber           = cn;
            cameraFrameRate        = fps;
            machineInputSourceKind = misk;
            if (misk == MachineInputSourceKind.SourceFile || misk == MachineInputSourceKind.SourceNone || train)
            {
                speechRecognitionOnline = true;
            }
            else
            {
                speechRecognitionOnline = true;
            }
            userSpeech = "";
            FileUtilities.DirectoryCreation();
            FileUtilities.TrainingDirectoryCreation();
            faceClassifier = new CascadeClassifier("assets\\haarcascade_frontalface_alt.xml");
            uikind         = uk;
            if (uikind == UIKind.UIMachine)
            {
                admin_focus     = new Bitmap("assets\\machine\\admin_focus.jpg");
                secondary_focus = new Bitmap("assets\\machine\\secondary_focus.jpg");
                threat_focus    = new Bitmap("assets\\machine\\threat_focus.jpg");
            }
            else
            {
                admin_focus     = new Bitmap("assets\\samaritan\\deviant_focus.jpg");
                secondary_focus = new Bitmap("assets\\samaritan\\irrelevant_focus.jpg");
                threat_focus    = new Bitmap("assets\\samaritan\\threat_focus.jpg");
            }
            machineIsTraining = train;
            //Check if the CORE_IMAGE_DATA.dat file exists and read the predefined width and height.
            if (File.Exists(FileUtilities.DirectoryName + "\\" + FileUtilities.CoreImageData))
            {
                String[] lines = File.ReadAllLines(FileUtilities.DirectoryName + "\\" + FileUtilities.CoreImageData);
                if (lines.Length != 0)
                {
                    String[] heightWidth = lines[0].Split('|');
                    facialRecognitionHeight = Int32.Parse(heightWidth[0]);
                    facialRecognitionWidth  = Int32.Parse(heightWidth[1]);
                }
            }
            FileUtilities.CoreImageDataCreation();
            // Check if the Machine is being trained or not.
            if (!train && fit == FaceIdentity.FaceNone && nt == "")
            {
                String[]                  lines2           = File.ReadAllLines(FileUtilities.DirectoryName + "\\" + FileUtilities.AssetIndexData);
                List <FaceIdentity>       faceIdentityList = new List <FaceIdentity>();
                List <String>             nList            = new List <String>();
                List <LBPHFaceRecognizer> lbphList         = new List <LBPHFaceRecognizer>();
                // Load the trained neural networks, list of names, and classifications.
                foreach (String line in lines2)
                {
                    String[] innerSplit = line.Split('^');
                    String   name       = innerSplit[0];
                    String   identifier = innerSplit[1];
                    String   file       = innerSplit[2];
                    if (identifier == adminIdentifier)
                    {
                        faceIdentityList.Add(FaceIdentity.FaceAdmin);
                    }
                    else if (identifier == auxAdminIdentifier)
                    {
                        faceIdentityList.Add(FaceIdentity.FaceAuxAdmin);
                    }
                    else if (identifier == assetIdentifier)
                    {
                        faceIdentityList.Add(FaceIdentity.FaceAsset);
                    }
                    else
                    {
                        PanicAndTerminateProgram();
                    }
                    nList.Add(name);
                    LBPHFaceRecognizer lbph = new LBPHFaceRecognizer();
                    lbph.Load(file);
                    lbphList.Add(lbph);
                }
                focusKindDatabase      = faceIdentityList.ToArray();
                nameDatabase           = nList.ToArray();
                lbphFaceRecognizerList = lbphList.ToArray();
                // Check to make sure the ANN, name, and classification database lengths are all equal.
                if (focusKindDatabase.Length == nameDatabase.Length && nameDatabase.Length == lbphFaceRecognizerList.Length)
                {
                    ;
                }
                else
                {
                    PanicAndTerminateProgram();
                }
            }
            faceIdentityTraining = fit;
            nameTraining         = nt;
            InitializeComponent();
            this.Title = t;

            Closed += (object sender, EventArgs args) =>
            {
                Environment.Exit(1);
            };
        }
Ejemplo n.º 20
0
        /***
            Function: public MainWindow(bool train, FaceIdentity fit, String nt, int cn, int fps, bool crd, int mdt, MachineInputSourceKind misk)
            Parameter(s): bool train
                Whether or not the machine is supposed to be training itself.
                          FaceIdentity fit
                The classification of the person that the Machine is training itself to recognize (supposed to be equal to FaceIdentity.FaceNone during
                normal execution).
                          String nt
                The name of the person that the Machine is training itself to recognize (supposed to be equal to "" during normal execution).
                          int cn
                The camera number to used by the 'capture' variable.
                          int fps
                The frame rate of the camera (not used when processing video files).
                          bool crd
                Whether or not the Machine should dispose of resources (could potentially be unstable).
                          int mdt
                The maxDistanceThreshold to use when classifying faces.
                           MachineInputSourceKind misk
                The input source from which the Machine will gather its input.
                           String t
                The title of this window.
                            MachineStartPage msp
                A reference to the main machine window to control.
            Return Value: N/A (Constructor)
        ***/
        public MainWindow(bool train, FaceIdentity fit, String nt, int cn, int fps, bool crd, int mdt,
            MachineInputSourceKind misk, String t, MachineStartPage msp, UIKind uk)
        {
            machineStartPage = msp;
            cameraResourceDisposal = crd;
            maxDistanceThreshold = mdt;
            cameraNumber = cn;
            cameraFrameRate = fps;
            machineInputSourceKind = misk;
            if (misk == MachineInputSourceKind.SourceWebcam) {
                speechRecognitionOnline = true;
                userSpeech = "";
            }
            FileUtilities.DirectoryCreation();
            FileUtilities.TrainingDirectoryCreation();
            faceClassifier = new CascadeClassifier("assets\\haarcascade_frontalface_alt.xml");
            uikind = uk;
            if (uikind == UIKind.UIMachine) {
                admin_focus = new Bitmap("assets\\machine\\admin_focus.jpg");
                secondary_focus = new Bitmap("assets\\machine\\secondary_focus.jpg");
                threat_focus = new Bitmap("assets\\machine\\threat_focus.jpg");
            }
            else
            {
                admin_focus = new Bitmap("assets\\samaritan\\deviant_focus.jpg");
                secondary_focus = new Bitmap("assets\\samaritan\\irrelevant_focus.jpg");
                threat_focus = new Bitmap("assets\\samaritan\\threat_focus.jpg");
            }
            machineIsTraining = train;
            //Check if the CORE_IMAGE_DATA.dat file exists and read the predefined width and height.
            if (File.Exists(FileUtilities.DirectoryName + "\\" + FileUtilities.CoreImageData))
            {
                String[] lines = File.ReadAllLines(FileUtilities.DirectoryName + "\\" + FileUtilities.CoreImageData);
                if (lines.Length != 0)
                {
                    String[] heightWidth = lines[0].Split('|');
                    facialRecognitionHeight = Int32.Parse(heightWidth[0]);
                    facialRecognitionWidth = Int32.Parse(heightWidth[1]);
                }
            }
            FileUtilities.CoreImageDataCreation();
            // Check if the Machine is being trained or not.
            if (!train && fit == FaceIdentity.FaceNone && nt == "")
            {
                String[] lines2 = File.ReadAllLines(FileUtilities.DirectoryName + "\\" + FileUtilities.AssetIndexData);
                List<FaceIdentity> faceIdentityList = new List<FaceIdentity>();
                List<String> nList = new List<String>();
                List<LBPHFaceRecognizer> lbphList = new List<LBPHFaceRecognizer>();
                // Load the trained neural networks, list of names, and classifications.
                foreach (String line in lines2)
                {
                    String[] innerSplit = line.Split('^');
                    String name = innerSplit[0];
                    String identifier = innerSplit[1];
                    String file = innerSplit[2];
                    if (identifier == adminIdentifier)
                        faceIdentityList.Add(FaceIdentity.FaceAdmin);
                    else if (identifier == auxAdminIdentifier)
                        faceIdentityList.Add(FaceIdentity.FaceAuxAdmin);
                    else if (identifier == assetIdentifier)
                        faceIdentityList.Add(FaceIdentity.FaceAsset);
                    else
                        PanicAndTerminateProgram();
                    nList.Add(name);
                    LBPHFaceRecognizer lbph = new LBPHFaceRecognizer();
                    lbph.Load(file);
                    lbphList.Add(lbph);
                }
                focusKindDatabase = faceIdentityList.ToArray();
                nameDatabase = nList.ToArray();
                lbphFaceRecognizerList = lbphList.ToArray();
                // Check to make sure the ANN, name, and classification database lengths are all equal.
                if (focusKindDatabase.Length == nameDatabase.Length && nameDatabase.Length == lbphFaceRecognizerList.Length) ;
                else
                    PanicAndTerminateProgram();
            }
            faceIdentityTraining = fit;
            nameTraining = nt;
            InitializeComponent();
            this.Title = t;

            Closed += (object sender, EventArgs args) =>
            {
                Environment.Exit(1);
            };
        }