예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Type type = typeof(FrameworkElement);

            // Get the DefaultStyleKeyProperty dependency
            // property of FrameworkElement
            FieldInfo fieldInfo = type.GetField(
                "DefaultStyleKeyProperty",
                BindingFlags.Static
                | BindingFlags.NonPublic);

            DependencyProperty defaultStyleKeyProperty =
                (DependencyProperty)fieldInfo.GetValue
                    (MyProgressBar);

            // Get the value of the property for the
            // progress bar element
            object defaultStyleKey =
                MyProgressBar.GetValue(defaultStyleKeyProperty);

            // Get the style from the application's resources
            Style style =
                (Style)Application.Current.FindResource
                    (defaultStyleKey);

            // Save the style to a string
            string styleXaml = XamlWriter.Save(style);
        }
예제 #2
0
        private async void RegistarUser(object sender, EventArgs e)
        {
            bool a = verificaInter();

            if (a == true)
            {
                try
                {
                    MyProgressBar.IsVisible = true;
                    Regis.IsEnabled         = false;
                    Log.IsEnabled           = false;
                    txtPassword.IsEnabled   = false;
                    txtUsername.IsEnabled   = false;
                    await MyProgressBar.ProgressTo(0.9, 500, Easing.SpringIn);

                    await Navigation.PushAsync(new Registar());

                    Regis.IsEnabled         = true;
                    Log.IsEnabled           = true;
                    txtPassword.IsEnabled   = true;
                    txtUsername.IsEnabled   = true;
                    MyProgressBar.IsVisible = false;
                    //await Navigation.PushAsync(new Registar());
                }
                finally
                {
                    Regis.IsEnabled         = true;
                    Log.IsEnabled           = true;
                    txtPassword.IsEnabled   = true;
                    txtUsername.IsEnabled   = true;
                    MyProgressBar.IsVisible = false;
                    MyProgressBar.Progress  = 0;
                    //MainProgressBar.IsVisible = false;
                    //Stackla.IsVisible = true;
                }

                //await Navigation.PushAsync(new Registar());
            }
            else
            {
                DisplayAlert("Internet", "Turn On Internet", "OK");
            }
        }
예제 #3
0
    /////////////////////////////////////////////////////////////////////////////////////

    #region [ Load/Save Database Methods ]

    /// <summary>
    /// Loads database from file.
    /// </summary>
    ///
    private void LoadDatabase(string filename, string caption, bool silent = false)
    {
        string progressInfo = "Loading database from '" + filename + "'...";

        // Remove children from client area (probably referring to the contents
        // of the current database)
        //
        UnloadAllMdiChildForms();

        // Create progress bar
        //
        MyProgressBar progress = new MyProgressBar(this, progressInfo);

        Exception         lastException = null;
        VideoRentalOutlet loadedStore   = null;
        string            elapsedTime   = string.Empty;

        // Deserialize database using our file stream with progress info.
        //
        try
        {
            FileInfo fileInfo   = new FileInfo(filename);
            long     fileLength = fileInfo.Exists ? fileInfo.Length : 0;

            using (FileStreamWithProgressBar fs = new FileStreamWithProgressBar(
                       filename, FileMode.Open, progress, fileLength)
                   )
            {
                loadedStore = VideoRentalOutlet.Deserialize(fs);

                fs.StopTimer();
                elapsedTime = " in " + fs.VerboseElapsedTime;
            }
        }
        catch (Exception ex)
        {
            lastException = ex;
        }

        progress.Quit();

        if (loadedStore != null)
        {
            VideoStore          = loadedStore;
            VideoStore.Changed += VideoStore_Changed;

            string info = VideoStore.TotalRecordsCount.ToString()
                          + " records loaded from '" + filename + "'" + elapsedTime;

            if (silent)
            {
                this.InfoMessage = info;
            }
            else
            {
                info += "\n\n\n" + VideoStore.StatisticsInfo(info.Length) + "\n";

                MessageBox.Show(info, caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            UpdateTitle();
        }
        else if (lastException != null)
        {
            MessageBox.Show(
                "There was an error while loading database.\n\n"
                + "Filename: " + filename + "\n\n"
                + "System Message:\n\n"
                + lastException.Message,
                caption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }
    }
예제 #4
0
    /////////////////////////////////////////////////////////////////////////////////////

    #region [ Methods Displaying Database Info and Contents ]

    /// <summary>
    /// Dumps full contents of database to file and shows the report in report box.
    /// </summary>
    ///
    private void DumpDatabase()
    {
        string progressInfo = "Dumping database contents as text...";

        // Create progress bar
        //
        MyProgressBar progress = new MyProgressBar(this, progressInfo);

        progress.Minimum = 0;
        progress.Maximum = VideoStore.TotalRecordsCount;

        StringBuilder sb = new StringBuilder();

        sb.AppendLine();
        sb.AppendLine("VROLib Database Format v" + VideoStore.Version);
        sb.AppendLine();

        /////////////////////////////////////////////////////////////////////////////////

        sb.AppendLine(VideoStore.FullInfo());

        /////////////////////////////////////////////////////////////////////////////////

        sb.AppendLine(VideoStore.Customers.FullInfo());

        progress.Value += VideoStore.Customers.Count;
        progress.Refresh();

        /////////////////////////////////////////////////////////////////////////////////

        sb.AppendLine(VideoStore.PriceList.FullInfo());

        progress.Value += VideoStore.PriceList.Count;
        progress.Refresh();

        /////////////////////////////////////////////////////////////////////////////////

        sb.AppendLine(VideoStore.Movies.FullInfo());

        progress.Value += VideoStore.Movies.Count;
        progress.Refresh();

        /////////////////////////////////////////////////////////////////////////////////

        sb.AppendLine(VideoStore.MovieExemplars.FullInfo());

        progress.Value += VideoStore.MovieExemplars.Count;
        progress.Refresh();

        /////////////////////////////////////////////////////////////////////////////////

        progress.Quit();

        string report = sb.ToString();

        try
        {
            System.IO.File.WriteAllText("VRO-dump.txt", report);
            sb.AppendLine("Dump saved to 'VRO-dump.txt'");
            report = sb.ToString();
        }
        catch {}

        ShowReport("Video Rental Outlet - Database Text Dump", report);
    }
예제 #5
0
    /////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Adds number of test records to existing database.
    /// </summary>
    ///
    private void AddTestRecordsToDatabase(int extraRecords = 100)
    {
        DialogResult answer = MessageBox.Show(
            "You are about to add random data to database!\n\nAre you sure?",
            "Add Test Records",
            MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
            MessageBoxDefaultButton.Button2);

        if (answer != DialogResult.Yes)
        {
            return;
        }

        string progressInfo = "Adding random records to existing database...";

        // Remove children from client area (probably referring to the contents
        // of the current database)
        //
        UnloadAllMdiChildForms();

        // Create progress bar
        //
        MyProgressBar progress = new MyProgressBar(this, progressInfo);

        // Add records using VRO_TestSuite
        //
        try
        {
            // Create VRO test suite that will be used to add records to existing databse
            //
            VRO_TestSuite.StringWriter   sb   = new VRO_TestSuite.StringWriter();
            VRO_TestSuite.TestClient_VRO test = new VRO_TestSuite.TestClient_VRO(sb);
            test.VideoStore = this.VideoStore;

            // Add records and maintain progress bar every 5th added record
            //
            for (int i = 1; i <= extraRecords; ++i)
            {
                if (i % 5 == 4)
                {
                    progress.Value = i;
                    progress.Refresh();

                    Application.DoEvents();  // increase responsiveness
                }

                try
                {
                    test.AddTestRecords();
                }
                catch
                {
                    // Ignore any database violations as we try to insert random data
                }
            }

            this.InfoMessage = "Database now contains " + VideoStore.TotalRecordsCount
                               + " records";
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString(), "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }

        progress.Quit();

        #if TEXTUI
        if (MdiClient.ActiveChild != null)
        {
            MdiClient.Focus();
        }
        #endif
    }
예제 #6
0
    /////////////////////////////////////////////////////////////////////////////////////

    #region [ Initialize Test Database and Add Test Records to Database Methods ]

    /// <summary>
    /// Initializes sample database using VRO_TestSuite (from ID132V Lab3a).
    /// </summary>
    ///
    private void InitializeTestDatabase()
    {
        DialogResult answer = MessageBox.Show(
            "You are about to delete all current data!\n\nAre you sure?",
            "Initialize Sample Database",
            MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
            MessageBoxDefaultButton.Button2);

        if (answer != DialogResult.Yes)
        {
            return;
        }

        UnloadAllMdiChildForms();

        // Create progress bar
        //
        MyProgressBar progress = new MyProgressBar(this, "Initializing database...");

        progress.Minimum = 0;
        progress.Maximum = 100;

        string report = null;

        try
        {
            VRO_TestSuite.StringWriter sb = new VRO_TestSuite.StringWriter();

            VRO_TestSuite.TestClient_VRO test = new VRO_TestSuite.TestClient_VRO(sb);

            sb.WriteLine();
            sb.WriteLine("Initializing Sample Database...");

            test.CreateSampleDatabase();

            progress.Value = 100;
            progress.Refresh();

            report = sb.ToString();

            if (test.VideoStore != null)
            {
                VideoStore          = test.VideoStore;
                VideoStore.Changed += VideoStore_Changed;

                UpdateTitle();
            }
        }
        catch (Exception ex)
        {
            report = ex.ToString();
        }

        progress.Quit();

        try
        {
            System.IO.File.WriteAllText("VRO-test.txt", report);
            report += "Report saved to to 'VRO-Test.txt'";
        }
        catch {}

        ShowReport("Video Rental Outlet - Test Suite Report", report);
    }
예제 #7
0
    /////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Serializes database to file.
    /// </summary>
    ///
    private void SaveDatabase(string filename, string caption, bool silent = false)
    {
        // Create progress bar

        string progressInfo = "Saving database to '" + filename + "'...";

        // Create progress bar
        //
        MyProgressBar progress = new MyProgressBar(this, progressInfo);

        Exception lastException = null;
        bool      succeded      = false;
        string    elapsedTime   = string.Empty;

        // Serialize database using our file stream with progress info.
        //
        try
        {
            FileInfo fileInfo   = new FileInfo(filename);
            long     fileLength = fileInfo.Exists ? fileInfo.Length : 0;

            // Anticipate file length based on records count (if file length is 0
            // or there was significant increase in database)
            //
            fileLength = Math.Max(VideoStore.TotalRecordsCount * 160, fileLength);

            using (FileStreamWithProgressBar fs = new FileStreamWithProgressBar(
                       filename, FileMode.Create, progress, fileLength)
                   )
            {
                VideoStore.Serialize(fs);

                succeded = true;
                fs.StopTimer();
                elapsedTime = " in " + fs.VerboseElapsedTime;
            }
        }
        catch (Exception ex)
        {
            lastException = ex;
        }

        progress.Quit();

        // Report status
        //
        if (succeded)
        {
            string info = VideoStore.TotalRecordsCount.ToString()
                          + " records saved to '" + filename + "'" + elapsedTime;

            if (silent)
            {
                this.InfoMessage = info;
            }
            else
            {
                MessageBox.Show(
                    info + "\n\n\n" + VideoStore.StatisticsInfo(info.Length) + "\n",
                    caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        else if (lastException != null)
        {
            MessageBox.Show(
                "There was an error while saving database.\n\n"
                + "Filename: " + filename + "\n\n"
                + "System Message:\n" + lastException.Message,
                caption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }
    }
예제 #8
0
        /// <summary>
        /// Wait for the DUT measured voltage to drop at or below threshold specified.
        /// </summary>
        /// <param name="MeasurementType">Type of measurement to configure power supply for (Expect DC Voltage)</param>
        /// <param name="Value">Measured voltage value required to be considered done.</param>
        /// <param name="TimeOut">Timeout specified in milliseconds.</param>
        /// <param name="DataOut">If requesting a measurement, measured value will be stored here.</param>
        /// <param name="ErrorResponse">Error reponse of instrument. (+0,"No error") is a normal response with no error</param>
        /// <returns></returns>
        public bool MeasurementDischarge(CONFigureSubsystem_e MeasurementType, double Value, int TimeOut, out string DataOut, out string ErrorResponse)
        {
            DataOut = ErrorResponse = null;
            double measurement =0;
            MyProgressBar ProgressBar = new MyProgressBar();

            Add(MeasurementType, MEASurementRange_e.DC100V, MEASurementResolution_e.DC100mV);
            SendCommand(out DataOut, out ErrorResponse);

            SetTimerInterval(TimeOut);

            ProgressBar.SetProgressMax(522);
            ProgressBar.SetLabelText("UUT Discharge Progress");
            ProgressBar.UpdateProgress(519);
            ProgressBar.Show();

            ProgressBar.Update();
            while (bTimeoutFlag != true)
            {

                Add(RootCommands_e.Read);
                SendCommand(out DataOut, out ErrorResponse);
                measurement = Convert.ToDouble(DataOut);

                ProgressBar.UpdateProgress(Convert.ToInt16(measurement * 100));
                ProgressBar.SetLabelText("UUT Discharge Progress, Voltage: " + String.Format("{0:0.00} VDC", measurement));

                if (measurement < Value) break;
                myWaitHandle.WaitOne(30);

            }
            ProgressBar.Close();

            tmr1.Stop();
            if (bTimeoutFlag == true)
            {
                //Timed out
                return false;
            }
            else
            {
                //Success
                return true;
            }
        }
예제 #9
0
        /// <summary>
        /// Waits for the DUT measured voltage to reach the threshold specified. Uses a progress bar for visual display.
        /// </summary>
        /// <param name="MeasurementType">Type of measurement to configure power supply for (Expect DC Voltage)</param>
        /// <param name="Value">Measured voltage value required to be considered done.</param>
        /// <param name="TimeOut">Timeout specified in milliseconds.</param>
        /// <param name="DataOut">If requesting a measurement, measured value will be stored here.</param>
        /// <param name="ErrorResponse">Error reponse of instrument. (+0,"No error") is a normal response with no error</param>
        /// <returns></returns>
        public bool MeasurementCharge(CONFigureSubsystem_e MeasurementType, double Value, int TimeOut, out string DataOut, out string ErrorResponse)
        {
            DataOut = ErrorResponse = null;
            double PreviousMeasurement = 0;
            MyProgressBar ProgressBar = new MyProgressBar();
            bool ProgressFlag = false;

            Add(MeasurementType, MEASurementRange_e.DC10V, MEASurementResolution_e.DC100mV);
            SendCommand(out DataOut, out ErrorResponse);

            SetTimerInterval(TimeOut);

            ProgressBar.SetProgressMax(522);
            ProgressBar.SetLabelText("UUT Charging Progress");
            ProgressBar.Show();
            double measurement = 0;

            ProgressBar.Update();
            while (bTimeoutFlag != true)
            {

                Add(RootCommands_e.Read);
                SendCommand(out DataOut, out ErrorResponse);
                measurement = Convert.ToDouble(DataOut);

                ProgressBar.UpdateProgress(Convert.ToInt16(measurement * 100));
                ProgressBar.SetLabelText("UUT Charging Progress, Voltage: " + String.Format("{0:0.00} VDC",measurement));

                if (measurement > Value) break;
                if (measurement > 4.5) ProgressFlag = true;

                if (ProgressFlag == false)
                {
                    if (measurement <= (PreviousMeasurement - 0.1))
                    {
                        ProgressBar.Close();
                        ErrorResponse = "PFM Circuit not charging, Current Measurement: " + measurement.ToString() + " Previous measurement: " + PreviousMeasurement.ToString() ;
                        return false;
                    }
                }
                PreviousMeasurement = measurement;
                myWaitHandle.WaitOne(50);
            }
            tmr1.Stop();
            ProgressBar.Close();

            if (bTimeoutFlag == true)
            {
                //Timed out
                ErrorResponse = "Timed Out, PFM Voltage measures: " + measurement.ToString();
                return false;
            }
            else
            {
                //Success
                return true;
            }
        }
예제 #10
0
        public GoNoGoStatusMainForm()
        {
            InitializeComponent();

            this.Text = "First Evidence GoNoGo System Monitor, version " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            m_AppData = new APPLICATION_DATA();
            m_Log = new ErrorLog(m_AppData);
            m_AppData.Logger =(object) m_Log;

            LPROCR_Lib LPRlib = new LPROCR_Lib();

            // get plate min max to draw the min/max target boxes for the user to see
            LPRlib.GetMinMaxPlateSize(ref minW, ref maxW, ref minH, ref maxH);

            // fudge the min box size so the user will make the plate bigger
            minH += 20;
            minW += 40;

            m_ReceiveDataSingleton = new object();

            jpegQ = new ThreadSafeQueue<JPEG>(30);

            m_PreviousPlateNumber = new string[4];
            m_UneditedImages = new UNEDITEDIMAGES[4];
            m_UneditedImages[0] = new UNEDITEDIMAGES();
            m_UneditedImages[1] = new UNEDITEDIMAGES();
            m_UneditedImages[2] = new UNEDITEDIMAGES();
            m_UneditedImages[3] = new UNEDITEDIMAGES();

            m_SystemStatusLock = new object();
            m_SystemStatus = new SYSTEM_STATUS_STRINGS();

            m_FullScreenPB = new bool[4];
            m_FullScreenPB[0] = false;
            m_FullScreenPB[1] = false;
            m_FullScreenPB[2] = false;
            m_FullScreenPB[3] = false;

            this.FormClosing += new FormClosingEventHandler(GoNoGoStatusMainForm_FormClosing);

            this.Resize +=new EventHandler(GoNoGoStatusMainForm_Resize);

            m_ServerConnection = new RCSClient( m_AppData);

            m_PollingThread = new Thread(PollingLoop);

            m_ServerConnection.MessageEventGenerators.OnRxChannelList += OnReceiveChannels;
            m_ServerConnection.MessageEventGenerators.OnRxJpeg += OnNewJpeg;
            m_ServerConnection.MessageEventGenerators.OnRxHealthStatus += OnRxStats;

            pb_ClickGenericHandler = new pb_ClickDelegate[4];
            pb_ClickGenericHandler[0] = pb_Click0;
            pb_ClickGenericHandler[1] = pb_Click1;
            pb_ClickGenericHandler[2] = pb_Click2;
            pb_ClickGenericHandler[3] = pb_Click3;

            m_JpegPlayControl = new JPEG_PLAY_CONTROL[4];
            m_JpegPlayControl[0] = new JPEG_PLAY_CONTROL();
            m_JpegPlayControl[1] = new JPEG_PLAY_CONTROL();
            m_JpegPlayControl[2] = new JPEG_PLAY_CONTROL();
            m_JpegPlayControl[3] = new JPEG_PLAY_CONTROL();

            progressBarPlateProcessQueueLevel = new MyProgressBar();
            progressBarPlateProcessQueueLevel.Location = new Point(10, 40);
            progressBarPlateProcessQueueLevel.Size = new Size(groupBoxPlateProcessQueLevel.Size.Width-20, 30);

            groupBoxPlateProcessQueLevel.Controls.Add(progressBarPlateProcessQueueLevel);

            buttonSaveCurrentImage.Visible = false;
            buttonSaveCurrentImage.Enabled = false;

            m_PollingThread.Start();
        }
예제 #11
0
 private void InitializeViews()
 {
     //this.GestureRecognizers.Add(new Xamarin.Forms.TapGestureRecognizer
     //{
     //    NumberOfTapsRequired = 1,
     //    Command = new Xamarin.Forms.Command(async () => { await MyLogger.Alert("Tapped"); })
     //});
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(0, Xamarin.Forms.GridUnitType.Absolute)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(4, Xamarin.Forms.GridUnitType.Star)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(4, Xamarin.Forms.GridUnitType.Star)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(50, Xamarin.Forms.GridUnitType.Absolute)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(50, Xamarin.Forms.GridUnitType.Absolute)
     });
     this.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
         Height = new Xamarin.Forms.GridLength(25, Xamarin.Forms.GridUnitType.Absolute)
     });
     this.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
         Height = new Xamarin.Forms.GridLength(5, Xamarin.Forms.GridUnitType.Absolute)
     });
     {
         LBname = new MyLabel("");
         LBname.SetBinding(MyLabel.TextProperty, new Xamarin.Forms.Binding("LBname"));
         this.Children.Add(new MyScrollView(ScrollOrientation.Horizontal)
         {
             Content = LBname
         }, 1, 0);
     }
     {
         AIprogress = new MyActivityIndicator();
         AIprogress.SetBinding(MyActivityIndicator.IsVisibleProperty, new Xamarin.Forms.Binding("AIvisible"));
         AIprogress.SetBinding(MyActivityIndicator.IsRunningProperty, new Xamarin.Forms.Binding("AIvisible"));
         this.Children.Add(AIprogress, 0, 1);
         MyGrid.SetColumnSpan(AIprogress, this.ColumnDefinitions.Count - 2);
     }
     {
         PBprogress = new MyProgressBar();
         PBprogress.SetBinding(MyProgressBar.IsVisibleProperty, new Xamarin.Forms.Binding("PBvisible"));
         PBprogress.SetBinding(MyProgressBar.ProgressProperty, new Xamarin.Forms.Binding("Progress"));
         this.Children.Add(PBprogress, 0, 1);
         MyGrid.SetColumnSpan(PBprogress, this.ColumnDefinitions.Count - 2);
     }
     {
         LBstatus = new MyLabel("");
         LBstatus.SetBinding(MyLabel.TextProperty, new Xamarin.Forms.Binding("LBstatus"));
         this.Children.Add(LBstatus, 2, 0);
     }
     {
         LBspeed = new MyLabel("1.404 MB/s");
         LBspeed.SetBinding(MyLabel.TextProperty, new Xamarin.Forms.Binding("LBspeed"));
         this.Children.Add(LBspeed, 3, 0);
     }
     {
         BTNmessage = new MyButton("");
         BTNmessage.SetBinding(MyButton.TextProperty, new Xamarin.Forms.Binding("BTNmessage"));
         BTNmessage.SetBinding(MyButton.IsEnabledProperty, new Xamarin.Forms.Binding("BTNmessageEnabled"));
         BTNmessage.SetBinding(MyButton.CommandProperty, new Xamarin.Forms.Binding("BTNmessageClicked"));
         this.Children.Add(BTNmessage, 4, 0);
         MyGrid.SetRowSpan(BTNmessage, 2);
     }
     {
         BTNcontrol = new MyButton("");
         BTNcontrol.SetBinding(MyButton.TextProperty, new Xamarin.Forms.Binding("BTNcontrol"));
         BTNcontrol.SetBinding(MyButton.IsEnabledProperty, new Xamarin.Forms.Binding("BTNcontrolEnabled"));
         BTNcontrol.SetBinding(MyButton.CommandProperty, new Xamarin.Forms.Binding("BTNcontrolClicked"));
         this.Children.Add(BTNcontrol, 5, 0);
         MyGrid.SetRowSpan(BTNcontrol, 2);
     }
 }
예제 #12
0
        public GoNoGoStatusMainForm()
        {
            InitializeComponent();

            this.Text = "First Evidence GoNoGo System Monitor, version " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            m_AppData        = new APPLICATION_DATA();
            m_Log            = new ErrorLog(m_AppData);
            m_AppData.Logger = (object)m_Log;

            LPROCR_Lib LPRlib = new LPROCR_Lib();

            // get plate min max to draw the min/max target boxes for the user to see
            LPRlib.GetMinMaxPlateSize(ref minW, ref maxW, ref minH, ref maxH);

            // fudge the min box size so the user will make the plate bigger
            minH += 20;
            minW += 40;


            m_ReceiveDataSingleton = new object();

            jpegQ = new ThreadSafeQueue <JPEG>(30);

            m_PreviousPlateNumber = new string[4];
            m_UneditedImages      = new UNEDITEDIMAGES[4];
            m_UneditedImages[0]   = new UNEDITEDIMAGES();
            m_UneditedImages[1]   = new UNEDITEDIMAGES();
            m_UneditedImages[2]   = new UNEDITEDIMAGES();
            m_UneditedImages[3]   = new UNEDITEDIMAGES();

            m_SystemStatusLock = new object();
            m_SystemStatus     = new SYSTEM_STATUS_STRINGS();


            m_FullScreenPB    = new bool[4];
            m_FullScreenPB[0] = false;
            m_FullScreenPB[1] = false;
            m_FullScreenPB[2] = false;
            m_FullScreenPB[3] = false;

            this.FormClosing += new FormClosingEventHandler(GoNoGoStatusMainForm_FormClosing);

            this.Resize += new EventHandler(GoNoGoStatusMainForm_Resize);

            m_ServerConnection = new RCSClient(m_AppData);

            m_PollingThread = new Thread(PollingLoop);


            m_ServerConnection.MessageEventGenerators.OnRxChannelList  += OnReceiveChannels;
            m_ServerConnection.MessageEventGenerators.OnRxJpeg         += OnNewJpeg;
            m_ServerConnection.MessageEventGenerators.OnRxHealthStatus += OnRxStats;

            pb_ClickGenericHandler    = new pb_ClickDelegate[4];
            pb_ClickGenericHandler[0] = pb_Click0;
            pb_ClickGenericHandler[1] = pb_Click1;
            pb_ClickGenericHandler[2] = pb_Click2;
            pb_ClickGenericHandler[3] = pb_Click3;

            m_JpegPlayControl    = new JPEG_PLAY_CONTROL[4];
            m_JpegPlayControl[0] = new JPEG_PLAY_CONTROL();
            m_JpegPlayControl[1] = new JPEG_PLAY_CONTROL();
            m_JpegPlayControl[2] = new JPEG_PLAY_CONTROL();
            m_JpegPlayControl[3] = new JPEG_PLAY_CONTROL();


            progressBarPlateProcessQueueLevel          = new MyProgressBar();
            progressBarPlateProcessQueueLevel.Location = new Point(10, 40);
            progressBarPlateProcessQueueLevel.Size     = new Size(groupBoxPlateProcessQueLevel.Size.Width - 20, 30);

            groupBoxPlateProcessQueLevel.Controls.Add(progressBarPlateProcessQueueLevel);

            buttonSaveCurrentImage.Visible = false;
            buttonSaveCurrentImage.Enabled = false;

            m_PollingThread.Start();
        }
예제 #13
0
        public bool CopyModelAndImage(MyProgressBar bar, IFeatureDataSet srcFds, IFeatureDataSet tarFds)
        {
            bool flag = true;
            int  num  = 1;

            try
            {
                tarFds.DataSource.StartEditing();
                IResourceManager resourceManager  = srcFds as IResourceManager;
                IResourceManager resourceManager2 = tarFds as IResourceManager;
                EnumResName      modelNames       = resourceManager.GetModelNames();
                int modelCount = resourceManager.GetModelCount();
                while (modelNames.MoveNext())
                {
                    if (num % 100 == 0 || num == modelCount)
                    {
                        lock (bar)
                        {
                            if (bar.CallbackCancel)
                            {
                                bar.labelTooltip.Text = StringParser.Parse("${res:View_Cancling}");
                                bool result = false;
                                return(result);
                            }
                        }
                    }
                    string current = modelNames.Current;
                    Gvitech.CityMaker.Resource.IModel model           = resourceManager.GetModel(current);
                    Gvitech.CityMaker.Resource.IModel simplifiedModel = resourceManager.GetSimplifiedModel(current);
                    if (!resourceManager2.ModelExist(current))
                    {
                        resourceManager2.AddModel(current, model, simplifiedModel);
                        LoggingService.Debug(string.Format("Copy model:{0}", current));
                    }
                    num++;
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(modelNames);
                EnumResName imageNames = resourceManager.GetImageNames();
                num = 1;
                resourceManager.GetImageCount();
                while (imageNames.MoveNext())
                {
                    if (num % 100 == 0 || num == modelCount)
                    {
                        lock (bar)
                        {
                            if (bar.CallbackCancel)
                            {
                                bar.labelTooltip.Text = StringParser.Parse("${res:View_Cancling}");
                                bool result = false;
                                return(result);
                            }
                        }
                    }
                    string current2 = imageNames.Current;
                    IImage image    = resourceManager.GetImage(current2);
                    if (image != null && !resourceManager2.ImageExist(current2))
                    {
                        resourceManager2.AddImage(current2, image);
                        LoggingService.Debug(string.Format("Copy model:{0}", current2));
                    }
                    num++;
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(imageNames);
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                flag = false;
            }
            catch (System.Exception ex2)
            {
                XtraMessageBox.Show(ex2.Message);
                flag = false;
            }
            finally
            {
                tarFds.DataSource.StopEditing(flag);
            }
            return(flag);
        }
예제 #14
0
        private async void Login(object sender, EventArgs e)
        {
            bool a      = verificaInter();
            bool testar = true;

            if (txtPassword.Text == null || txtUsername.Text == null)
            {
                if (txtPassword.Text == null && txtUsername.Text == null)
                {
                    await DisplayAlert("Error", "Please enter the username and password", "Ok");
                }
                else if (txtUsername.Text == null)
                {
                    await DisplayAlert("Error", "Please enter the username or email", "Ok");
                }
                else if (txtPassword.Text == null)
                {
                    await DisplayAlert("Error", "Please enter the password", "Ok");
                }
                a      = false;
                testar = false;
            }


            if (a == true)
            {
                String auxilia = sha256_hash(txtPassword.Text);
                var    res     = await dataService.GetLogin(txtUsername.Text, auxilia);


                // DisplayAlert("Error3", "entrou  " + txtUsername.Text, "Ok");
                try
                {
                    switch (Device.RuntimePlatform)
                    {
                    case Device.iOS:
                        //padding = 10;
                        break;

                    case Device.Android:
                        //padding = 0;

                        ble     = CrossBluetoothLE.Current;
                        adapter = CrossBluetoothLE.Current.Adapter;

                        VerEstado();
                        break;

                    case Device.UWP:
                        //padding = 0;
                        //DisplayAlert("OIOI","OLA N","ASD");
                        break;

                    default:
                        //DisplayAlert("DEF", "FED", "ASD");
                        break;
                    }
                    if (res == true)
                    {
                        String a1 = txtUsername.Text;
                        if (a1.Contains("@") == true)
                        {
                            //DisplayAlert("Error", "entrou  "+txtUsername.ToString(), "Ok");
                            try
                            {
                                MyProgressBar.IsVisible = true;
                                Regis.IsEnabled         = false;
                                Log.IsEnabled           = false;
                                txtUsername.IsEnabled   = false;
                                txtPassword.IsEnabled   = false;
                                await MyProgressBar.ProgressTo(0.9, 500, Easing.SpringIn);

                                if (flag == true)
                                {
                                    await PCLHelper.CriarArquivo("User.txt");
                                }
                                await PCLHelper.WriteTextAllAsync("User.txt", a1);

                                await Navigation.PushAsync(new Historico(a1));


                                txtPassword.Text = "";
                            }
                            finally
                            {
                                Regis.IsEnabled         = true;
                                Log.IsEnabled           = true;
                                txtUsername.IsEnabled   = true;
                                txtPassword.IsEnabled   = true;
                                MyProgressBar.IsVisible = false;
                                MyProgressBar.Progress  = 0;
                            }
                        }
                        else
                        {
                            Utilizador auxiliar = await dataService.GetUtilizadorByusernameAsync(a1);

                            try
                            {
                                MyProgressBar.IsVisible = true;
                                Regis.IsEnabled         = false;
                                Log.IsEnabled           = false;
                                await MyProgressBar.ProgressTo(0.9, 500, Easing.SpringIn);

                                if (flag == true)
                                {
                                    await PCLHelper.CriarArquivo("User.txt");
                                }
                                await PCLHelper.WriteTextAllAsync("User.txt", auxiliar.email);

                                await Navigation.PushAsync(new Historico(auxiliar.email));

                                txtPassword.Text = "";
                            }
                            finally
                            {
                                Regis.IsEnabled         = true;
                                Log.IsEnabled           = true;
                                MyProgressBar.IsVisible = false;
                                MyProgressBar.Progress  = 0;
                            }
                        }
                    }
                    else
                    {
                        await DisplayAlert("Error", "User or Password Wrong", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    //DisplayAlert("Error2", "User or Password Wrong", "Ok");
                    //Debug.WriteLine("Answer: " + ex);
                    // DisplayAlert("Alert", "User or password wrong", "Ok");
                }
            }
            else
            {
                if (testar == true)
                {
                    DisplayAlert("Internet", "Connect your device to the internet", "OK");
                }
            }
        }