예제 #1
0
 protected virtual void OnProgramStateChangeRequested(ProgramStates state)
 {
     if (ProgramStateChangeRequested != null)
     {
         ProgramStateChangeRequested(state);
     }
 }
예제 #2
0
        protected virtual void OnProgramStateChanged(ProgramStates state)
        {
            var temp = ProgramStateChanged;

            if (temp != null)
            {
                temp(state);
            }
        }
예제 #3
0
        public MainForm()
        {
            InitializeComponent();

            ProgressEvent.Event += Work;
            ProgramState         = ProgramStates.Started;
            _progressTimer       = new Timer(ProgrressTimerTick, null, Timertimeout, Timeout.Infinite);

            _encoding = Encoding.GetEncoding("cp866");
        }
예제 #4
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            _allFiles = new List <AllFilesClass>();
            LoadAllFiles(textBoxDirectory.Text);
            ProgramState = ProgramStates.WaitAction;

            labelLoadedCodeFilesCount.Text    = _allFiles.Count(f => f.Type == AllFilesClass.ExtType.CppFile).ToString();
            labelLoadedHeadersFilesCount.Text = _allFiles.Count(f => f.Type == AllFilesClass.ExtType.HppFile).ToString();
            labelLoadedMakesFilesCount.Text   = _allFiles.Count(f => f.Type == AllFilesClass.ExtType.MakeFile).ToString();
            labelLoadedForFilesCount.Text     = _allFiles.Count(f => f.Type == AllFilesClass.ExtType.ForFile).ToString();
            labelLoadedUnknownFilesCount.Text =
                _allFiles.Count(f => f.Type == AllFilesClass.ExtType.UnknownFile).ToString();
            labelLoadedTotalFilesCount.Text = _allFiles.Count.ToString();
        }
예제 #5
0
        private void FindNotUsedCpp()
        {
            ProgressEvent.Exec("Begin", 0, ProgressEventType.Start);
            ProgramState = ProgramStates.Worked;

            ListToPanel(GetDelete(_allFiles.Count(f => f.Type == AllFilesClass.ExtType.MakeFile),
                                  Convert.ToInt32(comboBoxThreadsCount.Text),
                                  new List <AllFilesClass>(_allFiles.Where(f => f.Type == AllFilesClass.ExtType.CppFile)),
                                  @"\b(?<word>\w+)\.cp?p?\b", new List <AllFilesClass.ExtType> {
                AllFilesClass.ExtType.MakeFile
            }, s => s));

            ProgramState = ProgramStates.WaitAction;
            ProgressEvent.Exec("Complete Find Not Used Cpp", 100, ProgressEventType.End);
        }
예제 #6
0
        private void button8_Click(object sender, EventArgs e)
        {
            var folderBrowserDialog = new FolderBrowserDialog();

            if (textBoxDirectory.TextLength != 0)
            {
                folderBrowserDialog.SelectedPath = textBoxDirectory.Text;
            }
            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                textBoxDirectory.Text = folderBrowserDialog.SelectedPath;
                if (textBoxDirectory.Text[textBoxDirectory.TextLength - 1] != '\\')
                {
                    textBoxDirectory.Text += @"\";
                }
                ProgramState = ProgramStates.Started;
            }
        }
예제 #7
0
        void initMeasure(ProgramStates state)
        {
            OnLog(pState.ToString());
            if (CurrentMeasureMode != null && CurrentMeasureMode.isOperating)
            {
                //error. something in operation
                throw new Exception("Measure mode already in operation.");
            }
            CurrentMeasureMode.VoltageStepChangeRequested += measureMode_VoltageStepChangeRequested;
            CurrentMeasureMode.Disable += CurrentMeasureMode_Disable;
            // TODO: move inside MeasureMode
            SubscribeToCountsUpdated(deviceCountsUpdated);

            setProgramState(state);

            MeasureCancelRequested = false;
            SendSettings();
        }
예제 #8
0
        public GameProgram()
        {
            _optionsManager = new GameOption(new GraphicsDeviceManager(this), 1920, 1080);

            Content.RootDirectory = "Content";

            _guiManager = new GuiManager();

            _guiManager.AddButton("EXIT", new Button(100, 800, 200, 100, Content.Load <Texture2D>("ExitNoPress")));
            _guiManager.AddButton("START", new Button(100, 400, 200, 100, Content.Load <Texture2D>("StartNoPress")));
            _guiManager.AddButton("OPTIONS", new Button(100, 600, 200, 100, Content.Load <Texture2D>("menuOptionButton")));
            _guiManager.AddButton("BACK", new Button(850, 800, 200, 100, Content.Load <Texture2D>("backButton")));
            _guiManager.AddButton("FULLSCREEN", new Button(750, 400, 200, 100, Content.Load <Texture2D>("FullScreenButtun")));
            _guiManager.AddButton("WINDOW", new Button(950, 400, 200, 100, Content.Load <Texture2D>("WindowsButtun")));
            _guiManager.AddButton("FPSON", new Button(750, 500, 200, 100, Content.Load <Texture2D>("fpsOnButton")));
            _guiManager.AddButton("FPSOFF", new Button(950, 500, 200, 100, Content.Load <Texture2D>("fpsOffButton")));


            programState = ProgramStates.MAIN_MENU;
        }
예제 #9
0
        private void FindNotUsedFor()
        {
            ProgressEvent.Exec("Begin", 0, ProgressEventType.Start);
            ProgramState = ProgramStates.Worked;

            ListToPanel(
                GetDelete(
                    _allFiles.Count(
                        f => f.Type == AllFilesClass.ExtType.CppFile || f.Type == AllFilesClass.ExtType.HppFile),
                    Convert.ToInt32(comboBoxThreadsCount.Text),
                    new List <AllFilesClass>(_allFiles.Where(f => f.Type == AllFilesClass.ExtType.ForFile)),
                    @"[""](?<word>\w+)[.][f][o][r][""]",
                    new List <AllFilesClass.ExtType> {
                AllFilesClass.ExtType.CppFile, AllFilesClass.ExtType.HppFile
            },
                    ParseFor));

            ProgramState = ProgramStates.WaitAction;
            ProgressEvent.Exec("Complete Find Not Used For", 100, ProgressEventType.End);
        }
예제 #10
0
        private void FindNotUsedHpp()
        {
            ProgressEvent.Exec("Begin", 0, ProgressEventType.Start);
            ProgramState = ProgramStates.Worked;

            ListToPanel(
                GetDelete(
                    _allFiles.Count(
                        f => f.Type == AllFilesClass.ExtType.CppFile || f.Type == AllFilesClass.ExtType.HppFile),
                    Convert.ToInt32(comboBoxThreadsCount.Text),
                    new List <AllFilesClass>(_allFiles.Where(f => f.Type == AllFilesClass.ExtType.HppFile)),
                    @".*#\s*include\s*.*(<|\"").*(>|"")",
                    new List <AllFilesClass.ExtType> {
                AllFilesClass.ExtType.CppFile, AllFilesClass.ExtType.HppFile
            },
                    ParseHeader));

            ProgramState = ProgramStates.WaitAction;
            ProgressEvent.Exec("Complete Find Not Used Hpp", 100, ProgressEventType.End);
        }
예제 #11
0
        void camera()
        {
            // activate face sdk before using it...
            FSDK.ActivateLibrary("ANj63QzeUGKbORKF7KmC+s5J0f8hF7moXNMr1QrCeFStmCw3DTYD55rPZOERChnfpSbr3TguoGSPOPdrTwOodvoDuCeE3Jp/18G1GSeyvZT/uqK6q9MtvgSHtNFpna2sHVTdb1Az2rXxy8mHOOBgZ/PT5olt1Tsu0Gv8Go+3rdU=");
            //initialize sdk to enable capture
            FSDK.InitializeLibrary();
            FSDKCam.InitializeCapturing();
            String[] cameralist = new String[] { };
            int      count;

            //get clist of connected cameras and select the first one
            FSDKCam.GetCameraList(out cameralist, out count);
            if (count == 0)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
            FSDKCam.VideoFormatInfo[] formatList;
            FSDKCam.GetVideoFormatList(ref cameralist[0], out formatList, out count);
            String cameraName;

            cameraName = cameralist[0];
            if (FSDKCam.OpenVideoCamera(ref cameraName, ref cameraHandle) != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Error opening the first camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
            //a camera is opened, so disable controls unitl a face is detected
            //button1.Enabled = false;
            needClose = false;
            int tracker = 0;

            if (FSDK.FSDKE_OK != FSDK.LoadTrackerMemoryFromFile(ref tracker, TrackerMemoryFile))
            {
                FSDK.CreateTracker(ref tracker);
            }
            int err = 0;

            FSDK.SetTrackerMultipleParameters(tracker, "HandleArbitraryRotations=false; DetermineFaceRotationAngle=false; InternalResizeWidth=100; FaceDetectionThreshold=5;", ref err);

            FSDK.CImage image;
            Image       frameImage;

            while (!needClose)
            {
                int ImageHandle = new int();
                if (FSDKCam.GrabFrame(cameraHandle, ref ImageHandle) != FSDK.FSDKE_OK)
                {
                    Application.DoEvents();
                    continue;
                }
                image = new FSDK.CImage(ImageHandle);
                long[] IDs        = new long[256];
                long   faceCount  = new long();
                long   sizeOfLong = 8;
                FSDK.FeedFrame(tracker, 0, image.ImageHandle, ref faceCount, out IDs, sizeOfLong * 256);
                Array.Resize(ref IDs, (int)faceCount);
                frameImage = image.ToCLRImage();
                Graphics gr;
                gr = Graphics.FromImage(frameImage);
                int i;
                for (i = 0; i <= IDs.Length - 1;)
                {
                    if (pictureBox1.Image != null)
                    {
                        // a face has been detected, grab it and close our preview source
                        needClose = true;
                        //button1.Enabled = true;
                        String user;
                        user = "******";
                        try
                        {
                            if (System.IO.Directory.Exists(Application.StartupPath + "\\images"))
                            {
                                pictureBox1.Image.Save(Application.StartupPath + "\\images\\" + user + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                            }
                            else
                            {
                                System.IO.Directory.CreateDirectory(Application.StartupPath + "\\images");
                                pictureBox1.Image.Save(Application.StartupPath + "\\images\\" + user + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                            }
                        }
                        catch (Exception Ex)
                        {
                            Console.WriteLine(Ex.Message);
                        }
                        GC.Collect();
                        Application.DoEvents();
                        break;
                    }
                    //highlight face position in image
                    //    FSDK.TFacePosition facePosition = new FSDK.TFacePosition();
                    //    FSDK.GetTrackerFacePosition(tracker, 0, IDs[i], ref facePosition);
                    //    int left, top, w;
                    //    left = facePosition.xc = (int)(facePosition.w * 0.6);
                    //    top = facePosition.yc - (int)(facePosition.w * 0.5);
                    //    w = facePosition.w * (int)1.2;
                    //    string name;
                    //    int res;
                    //    res = FSDK.GetAllNames(tracker, IDs[i], out name, 65536);
                    //    if (FSDK.FSDKE_OK == res && name.Length > 0)
                    //    {
                    //        StringFormat format = new StringFormat();
                    //        format.Alignment = StringAlignment.Center;
                    //        gr.DrawString(name, new System.Drawing.Font("Arial", 16), new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen), facePosition.xc, top + w + 5, format);
                    //    }
                    //    Pen pen = Pens.LightGreen;
                    //    //this block assigns a name to the image and saves it in our tracker file, but we don't need it since we are storing to our DB Server
                    //    if (mouseX >= left && mouseX <= left + w && mouseY >= top && mouseY <= top + w)
                    //    {
                    //        pen = Pens.Blue;
                    //        if (programstate == ProgramStates.psRemember)
                    //        {
                    //            if (FSDK.FSDKE_OK == FSDK.LockID(tracker, IDs[i]))
                    //            {
                    //                //ibe == testdata
                    //                userName = "******";
                    //                if (userName == null)
                    //                {
                    //                    FSDK.SetName(tracker, IDs[i], "");
                    //                }
                    //                else
                    //                {
                    //                    FSDK.SetName(tracker, IDs[i], userName);
                    //                }
                    //                FSDK.UnlockID(tracker, IDs[i]);
                    //            }
                    //        }
                    //    }
                    //    gr.DrawRectangle(pen, left, top, w, w);
                }
                programstate      = ProgramStates.psRecognize;
                pictureBox1.Image = frameImage;
                //free captured resources to speed up program execution
                GC.Collect();
                Application.DoEvents();
            }
            //after capturing a valid face, tell the user and free resources
            //FSDK.SaveTrackerMemoryToFile(tracker, TrackerMemoryFile);
            //FSDK.FreeTracker(tracker);
            FSDKCam.CloseVideoCamera(cameraHandle);
            FSDKCam.FinalizeCapturing();
            MessageBox.Show("Face Image Successfully Captured!!!");
            loaddb();
            match_faces();
        }
예제 #12
0
 protected void setProgramStateWithoutUndo(ProgramStates state)
 {
     pState     = state;
     pStatePrev = pState;
 }
예제 #13
0
 protected void setProgramStateWithoutUndo(ProgramStates state)
 {
     pState = state;
     pStatePrev = pState;
 }
예제 #14
0
 protected virtual void OnProgramStateChanged(ProgramStates state)
 {
     var temp = ProgramStateChanged;
     if (temp != null)
         temp(state);
 }
예제 #15
0
 static void parse(string buffer)
 {
     if (buffer.IndexOf("TEST", 0) > 0)
         currentState = ProgramStates.test;
     else if (buffer.IndexOf("test", 0) > 0)
         currentState = ProgramStates.test;
     if (buffer.IndexOf("ACTION", 0) > 0)
     {
         currentState = ProgramStates.live;
     }
     else if (buffer.IndexOf("action", 0) > 0)
         currentState = ProgramStates.live;
 }
예제 #16
0
 public void LoadNewState(ProgramStates.IState state) { LoadNewState(state, true); }
예제 #17
0
 public void LoadNewState(ProgramStates.IState state, bool displayLoadingScreen)
 {
     if (displayLoadingScreen)
         ProgramState = new ProgramStates.LoadingStateState
         {
             NextState = state
         };
     else
         ProgramState = state;
 }
예제 #18
0
 public IdleState(Program p, ProgramStates s)
 {
     this.state = s;
     _program   = p;
 }
예제 #19
0
        //static ProgramStates currentState = ProgramStates.live;  // debug mode, start show first
        public static void Main()
        {
            double batV = 0;
            double dist = 1000;
            string debugMsg = "";
            RealTimeClock.SetTime(new DateTime(2010, 1, 1, 1, 1, 1));

            radioPower = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di5, true); // /Sleep pin on xbee
            radio.DataReceived += new SerialDataReceivedEventHandler(radio_DataReceived);
            radio.Open();

            // Blink board LED
            bool ledState = false;

            OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
            tubLight.Set(false); // turn it off
            Thread.Sleep(10000);// wait for programming just incase

            while (true)
            {
                // make sure the battery voltage is high enough so we don't destroy the battery!
                double test = batteryVoltage.Read();
                batV = batteryVoltage.Read() * (3.3 / 1024) / .091;
                Debug.Print(batV.ToString());
                if (batV < 12)
                {
                    radioPower.Write(true);

                    tubLight.Set(true);
                    Thread.Sleep(100);
                    tubLight.Set(false);
                    Thread.Sleep(100);
                    tubLight.Set(true);
                    Thread.Sleep(100);
                    tubLight.Set(false);

                    RealTimeClock.SetAlarm(RealTimeClock.GetTime().AddSeconds(10));
                    Power.Hibernate(Power.WakeUpInterrupt.RTCAlarm);

                }

                else
                {
                    switch (currentState)
                    {
                        case ProgramStates.idle:
                            radioPower.Write(false);
                            dist = getDistance(distanceSensor);
                            if ((dist < 3) && (currentState == ProgramStates.idle))
                            {
                                lastComms = RealTimeClock.GetTime();
                                // send out a wakeup call for around 11 seconds to get the neighbors out of sleep mode and ready to sync up
                                for (int i = 0; i < 250; i++)
                                {
                                    radio.Write(new byte[] { (byte)'$'}, 0, 1);
                                    Thread.Sleep(10);
                                }
                                debugMsg = "dist: " + dist.ToString("F2") + ", bat: " + batV.ToString("F2") + "\r";
                                radio.Write(UTF8Encoding.UTF8.GetBytes(debugMsg), 0, debugMsg.Length);
                                radio.Write(new byte[] { (byte)'$', (byte)'a', (byte)'c', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'\r' }, 0, 8);
                                radio.Write(new byte[] { (byte)'$', (byte)'a', (byte)'c', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)'\r' }, 0, 8);
                                Thread.Sleep(400);
                                currentState = ProgramStates.live;
                                radioPower.Write(true);
                            }

                            else
                            {
                                Thread.Sleep(100); // give it a moment to listen for comms.

                                led.Write(true);
                                pcbLed.Write(true);
                                Thread.Sleep(100);
                                pcbLed.Write(false);
                                led.Write(false);
                                Thread.Sleep(50);
                                TimeSpan timeDif = RealTimeClock.GetTime() - lastComms;

                                int mins = (timeDif.Days * 1440) + (timeDif.Hours * 60) + timeDif.Minutes;
                                if ((currentState == ProgramStates.idle) && mins > 1)
                                {
                                    radioPower.Write(true);
                                    RealTimeClock.SetAlarm(RealTimeClock.GetTime().AddSeconds(2));
                                    Power.Hibernate(Power.WakeUpInterrupt.RTCAlarm);
                                }
                                else
                                {
                                    Thread.Sleep(500);
                                }
                            }
                            break;
                        case ProgramStates.live:
                            playShow();
                            debugMsg = "dist: " + dist.ToString("F2") + ", bat: " + batV.ToString("F2") + "\r";
                            radio.Write(UTF8Encoding.UTF8.GetBytes(debugMsg), 0, debugMsg.Length);
                            RealTimeClock.SetAlarm(RealTimeClock.GetTime().AddSeconds(30));
                            Power.Hibernate(Power.WakeUpInterrupt.RTCAlarm);
                            currentState = ProgramStates.idle;
                            break;
                        case ProgramStates.config:
                            if (currentState == ProgramStates.config)
                                currentState = ProgramStates.idle;
                            break;
                        case ProgramStates.test:
                            doTest();
                            if (currentState == ProgramStates.test)
                                currentState = ProgramStates.idle;
                            break;
                    }
                }

            }
        }
예제 #20
0
 public ErrorState(Program p, ProgramStates s)
 {
     this.state = s;
     _program   = p;
 }
예제 #21
0
 protected void setProgramState(ProgramStates state)
 {
     pStatePrev = pState;
     pState = state;
 }
예제 #22
0
 public ScanState(Program p, ProgramStates s)
 {
     _program = p;
     state    = s;
 }
예제 #23
0
        void initMeasure(ProgramStates state)
        {
            OnLog(pState.ToString());
            if (CurrentMeasureMode != null && CurrentMeasureMode.isOperating) {
                //error. something in operation
                throw new Exception("Measure mode already in operation.");
            }
            CurrentMeasureMode.VoltageStepChangeRequested += measureMode_VoltageStepChangeRequested;
            CurrentMeasureMode.Disable += CurrentMeasureMode_Disable;
            // TODO: move inside MeasureMode
            SubscribeToCountsUpdated(deviceCountsUpdated);

            setProgramState(state);

            MeasureCancelRequested = false;
            SendSettings();
        }
예제 #24
0
 public PitchState(Program p, ProgramStates s)
 {
     _program = p;
     state    = s;
 }
예제 #25
0
 protected void setProgramState(ProgramStates state)
 {
     pStatePrev = pState;
     pState     = state;
 }
예제 #26
0
 public YawState(Program p, ProgramStates s)
 {
     _program = p;
     state    = s;
 }
예제 #27
0
 public StartupState(Program p, ProgramStates s)
 {
     this.state = s;
     _program   = p;
 }
예제 #28
0
        protected override void Update(GameTime gameTime)
        {
            mouse = Mouse.GetState();

            switch (programState)
            {
            case ProgramStates.MAIN_MENU:
            {
                IsMouseVisible = true;
                if (mouse.LeftButton == ButtonState.Pressed && _guiManager.GetButton("EXIT").ContainsButton(mouse.X, mouse.Y))
                {
                    Exit();
                }

                if (mouse.LeftButton == ButtonState.Pressed && _guiManager.GetButton("START").ContainsButton(mouse.X, mouse.Y))
                {
                    programState = ProgramStates.GAME_PLAY;
                }

                if (mouse.LeftButton == ButtonState.Pressed && _guiManager.GetButton("OPTIONS").ContainsButton(mouse.X, mouse.Y))
                {
                    programState = ProgramStates.OPTIONS;
                }
                break;
            }

            case ProgramStates.GAME_MENU:
            {
                IsMouseVisible = true;
                break;
            }

            case ProgramStates.OPTIONS:
            {
                IsMouseVisible = true;

                if (mouse.LeftButton == ButtonState.Pressed && _guiManager.GetButton("BACK").ContainsButton(mouse.X, mouse.Y))
                {
                    programState = ProgramStates.MAIN_MENU;
                }

                if (mouse.LeftButton == ButtonState.Pressed && _guiManager.GetButton("FULLSCREEN").ContainsButton(mouse.X, mouse.Y))
                {
                    _optionsManager.SetFullScreenMode(true);
                    //Такое преобразование нужно, чтобы вернуть к дефолту размеры кнопок перед очередным изменением разрешения
                    _guiManager.ResizeButtons(1 / _optionsManager.GetXscale(), 1 / _optionsManager.GetYscale());
                    //
                    _optionsManager.SetResolution(1920, 1080);
                    _guiManager.ResizeButtons(_optionsManager.GetXscale(), _optionsManager.GetYscale());
                }

                if (mouse.LeftButton == ButtonState.Pressed && _guiManager.GetButton("WINDOW").ContainsButton(mouse.X, mouse.Y))
                {
                    _optionsManager.SetFullScreenMode(false);
                    //Такое преобразование нужно, чтобы вернуть к дефолту размеры кнопок перед очередным изменением разрешения
                    _guiManager.ResizeButtons(1 / _optionsManager.GetXscale(), 1 / _optionsManager.GetYscale());
                    //
                    _optionsManager.SetResolution(1280, 720);
                    _guiManager.ResizeButtons(_optionsManager.GetXscale(), _optionsManager.GetYscale());
                }
                //Проверка кнопок настроек игры и вызов методов из класса GameOption для применения новых настроек игры
                break;
            }

            case ProgramStates.GAME_PLAY:
            {
                IsMouseVisible = false;

                if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    programState = ProgramStates.MAIN_MENU;
                    // Exit();
                }

                foreach (var brick in _bricks)
                {
                    if (brick.is_alive() && _ball.check_bricks_collision(brick))
                    {
                        _ball.changeDirection_Y();
                        brick.kill();
                        _brickCount--;
                        if (_brickCount == 0)
                        {
                            Exit();
                        }
                    }
                }

                _racket.move(Keyboard.GetState(), _viewPortRectangle);
                _ball.move();
                _ball.check_wall_collision(_viewPortRectangle);
                _ball.check_racket_collision(_racket);

                if (_ball.GetLive() == false)
                {
                    Exit();
                }
                break;
            }

            case ProgramStates.EXIT:
            {
                break;
            }
            }
            base.Update(gameTime);
        }