private void StartButton_Click(object sender, EventArgs e)
        {
            UpdateProgressDelegate progDel = new UpdateProgressDelegate(StartProcess);

            // BeginInvoke - asynchronously call StartProcess() method (on secondary thread)
            progDel.BeginInvoke(100, null, null);

            // MessageBox.Show("Done with operation!!");
        }
Example #2
0
 public DevMetricsData CalcDevMetrics (int Huge_calcHDMX, int Huge_calcLTSH, int Huge_calcVDMX,
                                      ushort numGlyphs,
                                      byte[] phdmxPointSizes, ushort maxHdmxPointSize,
                                      byte uchPixelHeightRangeStart, byte uchPixelHeightRangeEnd,
                                      ushort[] pVDMXxResolution, ushort[] pVDMXyResolution,
                                      ushort cVDMXResolutions, UpdateProgressDelegate pUpdateProgressDelegate)
 {
     throw new NotImplementedException("UnImplemented OTFontFile.Rasterizer:CalcDevMetrics");
 }
Example #3
0
 public MainForm()
 {
     InitializeComponent();
     cboxVer.SelectedIndex = 0;
     ipAddressControl1.Text = "192.168.56.3";
     show = new ShowProgressDelegate(ShowProgress);
     update = new UpdateProgressDelegate(UpdateProgress);
     btnNewFolder.Enabled = false;
 
     ShowProgress(false);
 }
Example #4
0
 public bool RastTest (int resX, int resY, int[] arrPointSizes,
                      float stretchX, float stretchY,
                      float rotation, float skew,
                      float[,] matrix,
                      bool unknown1, bool unknown2, bool unknown3, uint unknown4,
                      RastTestErrorDelegate pRastTestErrorDelegate,
                      UpdateProgressDelegate pUpdateProgressDelegate,
                      int numGlyphs)
 {
     throw new NotImplementedException("UnImplemented OTFontFile.Rasterizer:RastTest");
 }
Example #5
0
        public Mercury()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            _cat = new Catalog();
            _addCatItem = new AddCatalogItemDelegate(DoAddCatalogItem);
            _updateProgress = new UpdateProgressDelegate(UpdateBuildProgress);
        }
        public MainWindow()
        {
            InitializeComponent();

            updateProgressDelegate = new UpdateProgressDelegate(UpdateProgress);

            v = new double[n * h];
            w = new double[h * m];
            Q = new double[h];
            T = new double[m];
        }
Example #7
0
        public static void UpdateStatus(string message, bool error)
        {
            if (Program.MainWindow.InvokeRequired)
            {
                UpdateProgressDelegate updateProgress = new UpdateProgressDelegate(UpdateStatus);
                object[] args = { message, error };
                Program.MainWindow.Invoke(updateProgress, args);
                return;
            }

            Program.MainWindow.lblStatusMessage.Text = message;
            Program.MainWindow.lblStatusMessage.ForeColor = error ? Color.Red : Color.Black;
        }
        public MainWindow()
        {
            InitializeComponent();
            UpdateProgress = UpdateProgressBar;//this delegate will be called to update progress bar
            image1 = new BitmapImage();
            image2 = new BitmapImage();
            images = new List<string>();
            dialog = new OpenFileDialog();
            dialog.Filter = "JPEG Files (*.jpg)|*.jpg";
            check = new CheckIfMatch(UpdateProgress);
            getPixel = new GetPixelStrings(UpdateProgress);

        }
Example #9
0
        public MainForm()
        {
            InitializeComponent();
            pr = new Progress(this);
            show = new ShowProgressDelegate(ShowProgress);
            update = new UpdateProgressDelegate(UpdateProgress);
            ShowProgress(false,false);
            //cboxVer.SelectedIndex = 0;
            addToStatusLog("Init()");

            //local folder path
            string path="";
            if (NFSClient.Properties.Settings.Default.DefaultLocalFolder== "home")
            path = (Environment.OSVersion.Platform == PlatformID.Unix ||
                   Environment.OSVersion.Platform == PlatformID.MacOSX)
    ? Environment.GetEnvironmentVariable("HOME")
    : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
            else
                path = NFSClient.Properties.Settings.Default.DefaultLocalFolder;
            RefreshLocal(path);


            if (NFSClient.Properties.Settings.Default.ServerName.Length > 0)
            {

                //serverListCombo.Items.AddRange(NFSClient.Properties.Settings.Default.ServerName);
                int i = 0;
                foreach (string item in NFSClient.Properties.Settings.Default.ServerName)
                {
                    serverListCombo.Items.Add(item + "  (" + NFSClient.Properties.Settings.Default.ServerAddres[i] + "@" + NFSClient.Properties.Settings.Default.DefaultProtocol[i]+ ")");
                    i++;
                }


                server_index = NFSClient.Properties.Settings.Default.lastServerId;
                serverListCombo.SelectedIndex = server_index;
                //auto connect
                if (NFSClient.Properties.Settings.Default.autoConnect)
                    connect();
            }
            else
            {
                AddServer firstTime = new AddServer(this,-1);
                firstTime.StartPosition = FormStartPosition.Manual;
                firstTime.Location = new Point(this.Location.X + (this.Width - firstTime.Width) / 2, this.Location.Y + (this.Height - firstTime.Height) / 2);
                firstTime.Show(this);
            }
        }
Example #10
0
        protected override IEnumerator OnInitCoroutine(UpdateProgressDelegate updateProgressHandler, int currentStep, int totalStep)
        {
            GameObject interactionObject = new GameObject("_InteractionManager");

            // EasyTouch
            easyTouchObject = new GameObject("EasyTouch");
            easyTouchObject.transform.parent = interactionObject.transform;
            EasyTouch com = easyTouchObject.AddComponent <EasyTouch>();

            com.enableRemote        = false;
            com.autoUpdatePickedUI  = false;
            com.enabledNGuiMode     = false;
            com.enableUIMode        = true;
            com.autoSelect          = false;
            com.StationaryTolerance = 5;

            yield return(updateProgressHandler?.Invoke(this.ToString(), currentStep, totalStep, $"初始化交互模块"));
        }
Example #11
0
        /// <summary>
        /// A general HTTP PUT method, with delegates for progress and cancelling. May throw various exceptions.
        /// </summary>
        /// <param name="progressDelegate">Delegate called periodically (500ms) with percent complete</param>
        /// <param name="cancellingDelegate">Delegate called periodically to see if need to cancel</param>
        /// <param name="uri">URI to PUT to</param>
        /// <param name="proxy">A proxy to handle the HTTP connection</param>
        /// <param name="path">Path to file to put</param>
        /// <param name="timeout_ms">Timeout for the connection in ms. 0 for no timeout.</param>
        public static void Put(UpdateProgressDelegate progressDelegate, FuncBool cancellingDelegate,
                               Uri uri, IWebProxy proxy, string path, int timeout_ms)
        {
            using (Stream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read),
                   requestStream = PUT(uri, proxy, fileStream.Length, timeout_ms))
            {
                long len = fileStream.Length;
                DataCopiedDelegate dataCopiedDelegate = delegate(long bytes)
                {
                    if (progressDelegate != null && len > 0)
                    {
                        progressDelegate((int)((bytes * 100) / len));
                    }
                };

                CopyStream(fileStream, requestStream, dataCopiedDelegate, cancellingDelegate);
            }
        }
Example #12
0
        private static async Task <List <string> > ReadPageListAsync(UpdateProgressDelegate updateProgressDelegate, CancellationToken cancellationToken)
        {
            var pageList = new List <string>();

            // Read the SNPedia page list.
            string firstQueryPage = null;

            do
            {
                var result = await CallMediaWikiAPI(string.Format(
                                                        "action=query&list=allpages&aplimit={0}{1}&format=xml",
                                                        maxPagesRequest,
                                                        firstQueryPage != null ? ("&apcontinue=" + firstQueryPage) : ""
                                                        ), cancellationToken);

                if (!cancellationToken.IsCancellationRequested && result.bSuccess)
                {
                    firstQueryPage = null;

                    // Read the query continue element.
                    var continueElement = result.resultXML.SelectSingleNode("query-continue/allpages");
                    if (continueElement != null)
                    {
                        firstQueryPage = continueElement.Attributes["apcontinue"].Value;
                    }

                    // Read the page element list.
                    var pageElements = result.resultXML.SelectNodes("query/allpages/p");
                    foreach (XmlNode pageElement in pageElements)
                    {
                        pageList.Add(pageElement.Attributes["title"].Value);
                    }

                    // Post a message to the UI thread with a progress update.
                    updateProgressDelegate(string.Format("Read {0} entries from SNPedia page list", pageList.Count), 0);
                }
                else
                {
                    break;
                }
            }while (firstQueryPage != null);

            return(pageList);
        }
Example #13
0
        private void fmImport_Load(object sender, EventArgs e)
        {
//            fb_Path.SelectedPath = Application.StartupPath;
            if (Globals.PathsToImport.Count > 0)
            {
                //currently do nothing.  basically this is for silent import
                //will have to thing stuff a bit more
            }
            else
            {
                this.cbPath.Text = sqlnexus.Properties.Settings.Default.ImportPath;
            }

            this.Left -= 100;

            updateProgress = new UpdateProgressDelegate(this.UpdateProgress);
            updateStatus   = new UpdateStatusDelegate(this.UpdateStatus);
            EnumImporters();
        }
Example #14
0
        private void ShowSplashScreen()
        {
            BackgroundWorker worker = new BackgroundWorker();

            _Splash = new SplashScreen();
            System.Windows.Threading.Dispatcher pdDispatcher = _Splash.Dispatcher;

            worker.DoWork += delegate(object s, DoWorkEventArgs args)
            {
                //create a new delegate for updating our DWGRun
                UpdateProgressDelegate update = new UpdateProgressDelegate(UpdateDWGRun);

                //invoke the dispatcher and pass the percentage and max record count
                pdDispatcher.BeginInvoke(update, 2000);
            };

            worker.RunWorkerAsync();
            _Splash.ShowDialog();
        }
Example #15
0
        private void buttonManage_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                UpdateLableDelegate    updateLabelDelegate    = new UpdateLableDelegate(statusLable.SetValue);
                UpdateProgressDelegate updateProgressDelegate = new UpdateProgressDelegate(progressBar.SetValue);

                BCFWindow bcfWindow = new BCFWindow(bcfFileDictionary, googleFolders);
                if (bcfWindow.ShowDialog() == true)
                {
                    Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Loading BCF Information..." });

                    bcfFileDictionary = new Dictionary <string, LinkedBcfFileInfo>();
                    bcfFileDictionary = bcfWindow.BCFFileDictionary;
                    bcfProjectId      = bcfWindow.BCFProjectId;
                    googleFolders     = bcfWindow.GoogleFolders;

                    if (!string.IsNullOrEmpty(bcfProjectId) && null != googleFolders)
                    {
                        bcfColorSchemeId = googleFolders.ColorSheet.Id;
                        categorySheetId  = googleFolders.CategorySheet.Id;
                        bcfWindow.Close();

                        m_handler.BCFFileDictionary = bcfFileDictionary;
                        m_handler.BCFProjectId      = bcfProjectId;
                        m_handler.BCFColorSchemeId  = bcfColorSchemeId;
                        m_handler.CategorySheetId   = categorySheetId;
                        m_handler.GoogleFolders     = googleFolders;
                        m_handler.Request.Make(RequestId.UpdateLinkedFileInfo);
                        m_event.Raise();
                        SetFocus();
                    }

                    Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Ready" });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to open BCF window.\n" + ex.Message, "Open Manage BCF", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        public void UpdateProgress(DownloadProgressChangedEventArgs e)
        {
            if (Thread.CurrentThread != Dispatcher.Thread)
            {
                UpdateProgressDelegate _delegate = new UpdateProgressDelegate(UpdateProgress);
                Dispatcher.Invoke(DispatcherPriority.Normal, _delegate, e);
            }
            else
            {
                double mult = 1.0;
                if (TotalUpdateSize > int.MaxValue)
                {
                    mult = (double)int.MaxValue / TotalUpdateSize;
                }

                progressBar.Minimum = 0;
                progressBar.Maximum = (TotalUpdateSize * mult);

                // Set the current value.  In certain circumstances, this value may
                // become invalid, so we need to test it first.
                // NOTE: Fixes bug #1770765 - Status Bar Exception
                double currValue = (CompletedUpdateSize + e.BytesReceived) * mult;
                if (currValue >= progressBar.Minimum &&
                    currValue <= progressBar.Maximum)
                {
                    progressBar.Value = currValue;
                }

                TimeSpan ts = (DateTime.Now - StartTime);

                SetParagraphText(
                    DownloadedBytesStringConverter.Convert(CompletedUpdateSize + e.BytesReceived, TotalUpdateSize) +
                    " out of " +
                    DownloadedBytesStringConverter.Convert(TotalUpdateSize) +
                    " downloaded");

                lblSpeed.Text = DownloadedBytesStringConverter.Convert(
                    (CompletedUpdateSize + e.BytesReceived) / ts.TotalSeconds,
                    "0.0") + "/sec";
            }
        }
Example #17
0
        public void UpdateProgress(DownloadProgressChangedEventArgs e)
        {
            if (progressBar.InvokeRequired)
            {
                UpdateProgressDelegate _delegate = new UpdateProgressDelegate(UpdateProgress);
                progressBar.Invoke(_delegate, new object[] { e });
            }
            else
            {
                double mult = 1.0;
                if (TotalUpdateSize > int.MaxValue)
                {
                    mult = (double)int.MaxValue / TotalUpdateSize;
                }

                progressBar.Minimum = 0;
                progressBar.Maximum = (int)(TotalUpdateSize * mult);

                // Set the current value.  In certain circumstances, this value may
                // become invalid, so we need to test it first.
                // NOTE: Fixes bug #1770765 - Status Bar Exception
                int currValue = (int)((CompletedUpdateSize + e.BytesReceived) * mult);
                if (currValue >= progressBar.Minimum &&
                    currValue <= progressBar.Maximum)
                {
                    progressBar.Value = currValue;
                }

                TimeSpan ts = (DateTime.Now - StartTime);

                lblBytes.Text =
                    DownloadedBytesStringConverter.Convert(CompletedUpdateSize + e.BytesReceived, TotalUpdateSize) +
                    " out of " +
                    DownloadedBytesStringConverter.Convert(TotalUpdateSize) +
                    " downloaded (" +
                    DownloadedBytesStringConverter.Convert(
                        (CompletedUpdateSize + e.BytesReceived) / ts.TotalSeconds,
                        "0.0") +
                    "/sec)";
            }
        }
Example #18
0
        public static void UpdateStatus(string message, bool error = false)
        {
            if (Program.MainWindow.InvokeRequired)
            {
                UpdateProgressDelegate updateProgress = UpdateStatus;
                object[] args = { message, error };
                Program.MainWindow.Invoke(updateProgress, args);
                return;
            }

            Program.MainWindow.lblStatusMessage.Text      = message;
            Program.MainWindow.lblStatusMessage.ForeColor = error ? Color.Red : Color.Black;

            if (!error)
            {
                FileLog.Info(message);
            }
            else
            {
                FileLog.Error(message);
            }
        }
Example #19
0
    public IEnumerator InitCoroutine(int batchIndex = -1, UpdateProgressDelegate updateProgressHandler = null)
    {
        //Log("InitCoroutine({0})", batchIndex);

        if (batchIndex == -1)
        {
            int step = 0;

            for (int i = 0, c = _batches.Length; i < c; ++i)
            {
                var batch = _batches[i];
                if (batch == null)
                {
                    continue;
                }

                yield return(batch.InitCoroutine(updateProgressHandler, step, _count));

                step += batch.Count;
            }
        }
        else
        {
            var batch = _batches[batchIndex];
            if (batch == null)
            {
                yield return(null);
            }

            int stepBase = 0;
            for (int i = 0, c = batchIndex; i < c; ++i)
            {
                stepBase += _batches[i].Count;
            }

            yield return(batch.InitCoroutine(updateProgressHandler, stepBase, _count));
        }
    }
Example #20
0
 private void UpdateProgress(int value)
 {
     if (progressBar1.InvokeRequired)
     {
         UpdateProgressDelegate updPbDel = new UpdateProgressDelegate(this.UpdateProgress);
         BeginInvoke(updPbDel, new object[] { value });
     }
     else
     {
         if (value < 0)
         {
             progressBar1.Value = 0;
         }
         else if (value > progressBar1.Maximum)
         {
             progressBar1.Value = progressBar1.Maximum;
         }
         else
         {
             progressBar1.Value = value;
         }
     }
 }
Example #21
0
 private void UpdateProgress(int Pourc)
 {
     // Lock this block of code to one thread at a time because of multiple
     // threads accessing it and updating control.
     lock (this)
     {
         // Check to see if the thread that is trying to access this code
         // is the GUI thread or another thread.
         if (Progress.ProgressBar.InvokeRequired)
         {
             // The thread that entered this code in not the thread that create
             // the control. Create a deleagte and then execute this procedure
             // from the GUI thread.
             UpdateProgressDelegate del = new UpdateProgressDelegate(UpdateProgress);
             Progress.ProgressBar.BeginInvoke(del, Pourc);
         }
         else
         {
             // The thread in this section of code is the GUI thread
             Progress.Value = Pourc;
         }
     }
 }
        private void UpdateProgress(string currentTask, int progress)
        {
            if (lblCurrentTask.InvokeRequired)
            {
                UpdateProgressDelegate upd = new UpdateProgressDelegate(UpdateProgress);
                Invoke(upd, new object[] { currentTask, progress });
            }
            else
            {
                lblCurrentTask.Text = currentTask;

                if (pbarMain.Maximum >= pbarMain.Value + progress)
                {
                    pbarMain.Value += progress;
                }
                else
                {
                    pbarMain.Value = pbarMain.Maximum;
                }

                pbarMain.Maximum = 20 + (FileUpdateList.Count * 10);
            }
        }
Example #23
0
        public static async Task UpdateSNPDatabaseAsync(SNPDatabase database, UpdateProgressDelegate updateProgressDelegate, CancellationToken cancellationToken)
        {
            // Read the page list.
            updateProgressDelegate("Reading SNPedia page list", 0);
            var pageList = await ReadPageListAsync(updateProgressDelegate, cancellationToken);

            // Sort the page list to ensure that genotype pages (e.g. rs1234(a;a)) are processed after the corresponding snp page (i.e. rs1234)
            pageList.Sort(StringComparer.OrdinalIgnoreCase);

            var pagesPerBatch = 50;

            for (int pageIndex = 0; pageIndex < pageList.Count; pageIndex += pagesPerBatch)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }

                await UpdatePages(database, new ArraySegment <string>(pageList.ToArray(), pageIndex, Math.Min(pageList.Count - pageIndex, pagesPerBatch)), cancellationToken);

                updateProgressDelegate(string.Format("Processed {0}/{1} pages", pageIndex, pageList.Count), (double)pageIndex / (double)pageList.Count);
            }
        }
 private void UpdateProgress(int value)
 {
     if (this.progressBar1.InvokeRequired)
     {
         UpdateProgressDelegate del = new UpdateProgressDelegate(this.UpdateProgress);
         BeginInvoke(del, value);
     }
     else
         this.progressBar1.Value = value;
 }
Example #25
0
 public override System.Collections.IEnumerator Load(UpdateProgressDelegate progress)
 {
     // Use the controllers to create the game.
     yield break;
 }
Example #26
0
		/// <summary>
		/// Receives progress reporting
		/// </summary>
		/// <param name="e">progress arguments</param>
		public void ReportProgress(ProgressArgs e)
		{
			// This gets called from another thread so we must thread marhal back to the GUI thread.
			Delegate d = new UpdateProgressDelegate( UpdateProgress );
			this.Invoke( d, new Object[] { e.Status, e.Progress } );
		}
Example #27
0
 /// <summary>
 /// Updates status. Possibly async
 /// </summary>
 private void UpdateProgress(int val)
 {
     if (!progressDlg.InvokeRequired)
         progressDlg.Value = val;
     else
     {
         // Show status asynchronously
         UpdateProgressDelegate showProgress = new UpdateProgressDelegate(UpdateProgress);
         BeginInvoke(showProgress, new object[] { val });
     }
 }
Example #28
0
 private void OnCanCancelPropertyChanged(DependencyPropertyChangedEventArgs e)
 {
     CancelButton.IsEnabled = (bool)e.NewValue;
     var updateBarDelegate = new UpdateProgressDelegate(Determinate.SetValue);
     Dispatcher.Invoke(updateBarDelegate,
         DispatcherPriority.Background, IsEnabledProperty, (bool)e.NewValue);
 }
        private RoomData FindVisibility(RoomData rd, ProgressBar progressBar)
        {
            RoomData updatedData = new RoomData(rd);

            try
            {
                LogicalOrFilter      orFilter    = new LogicalOrFilter(categoryFilters);
                ReferenceIntersector intersector = null;
                intersector = new ReferenceIntersector(orFilter, FindReferenceTarget.Face, m_view);
                intersector.FindReferencesInRevitLinks = true;

                Face          face = rd.RoomFace;
                BoundingBoxUV bb   = face.GetBoundingBox();

                IList <UV>           uvPoints = new List <UV>();
                IList <ValueAtPoint> valList  = new List <ValueAtPoint>();

                List <PointData> pointDataList = new List <PointData>();
                double           interval      = analysisSettings.Interval;
                List <double>    uList         = new List <double>();
                List <double>    vList         = new List <double>();
                GetUVArray(bb, interval, out uList, out vList);


                progressBar.Value   = 0;
                progressBar.Minimum = 0;
                progressBar.Maximum = uList.Count * vList.Count;
                UpdateProgressDelegate updateProgressDelegate = new UpdateProgressDelegate(progressBar.SetValue);


                List <XYZ> exteriorPoints = new List <XYZ>();
                List <XYZ> interiorPoints = new List <XYZ>();
                bool       sorted         = SortViewPoints(rd.BoundarySegments, out exteriorPoints, out interiorPoints);

                int    visibleCount  = 0;
                double progressValue = 0;
                foreach (double u in uList) //start from in the middle of grid
                {
                    foreach (double v in vList)
                    {
                        if (AbortFlag.GetAbortFlag())
                        {
                            return(updatedData);
                        }
                        Dispatcher.CurrentDispatcher.Invoke(updateProgressDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, progressValue });

                        UV uvPoint = new UV(u, v);
                        if (face.IsInside(uvPoint))
                        {
                            XYZ    evalPoint  = face.Evaluate(uvPoint);
                            XYZ    xyzPoint   = new XYZ(evalPoint.X, evalPoint.Y, evalPoint.Z + offsetHeight); //4.2 inches above from the floor
                            double pointValue = 0;

                            List <XYZ> viewPoints = new List <XYZ>();
                            if (exteriorPoints.Count > 0)
                            {
                                exteriorPoints = exteriorPoints.OrderBy(o => o.DistanceTo(xyzPoint)).ToList();
                                viewPoints.AddRange(exteriorPoints);
                            }
                            if (interiorPoints.Count > 0)
                            {
                                interiorPoints = interiorPoints.OrderBy(o => o.DistanceTo(xyzPoint)).ToList();
                                viewPoints.AddRange(interiorPoints);
                            }

                            if (viewPoints.Count > 0)
                            {
                                bool visible = CheckVisibilityByMaterial(intersector, xyzPoint, viewPoints);
                                if (visible)
                                {
                                    pointValue = 1; visibleCount++;
                                }
                                else
                                {
                                    pointValue = 0;
                                }
                            }

                            PointData pData = new PointData(uvPoint, xyzPoint, pointValue);
                            pointDataList.Add(pData);

                            uvPoints.Add(pData.UVPoint);
                            valList.Add(pData.ValueAtPoint);
                        }
                        progressValue++;
                    }
                }

                rd.PointDataList = pointDataList;
                double ratio = (double)visibleCount / (double)uvPoints.Count;
                rd.VisiblityRatio = ratio;
                rd.AreaWithViews  = rd.RoomArea * ratio;
                rd.SetResultParameterValue(LEEDParameters.LEED_AreaWithViews.ToString(), rd.AreaWithViews);

                //visualize
                Transform transform = Transform.CreateTranslation(new XYZ(0, 0, offsetHeight));

                int index = m_sfm.AddSpatialFieldPrimitive(face, transform);
                FieldDomainPointsByUV domainPoints = new FieldDomainPointsByUV(uvPoints);
                FieldValues           values       = new FieldValues(valList);

                m_sfm.UpdateSpatialFieldPrimitive(index, domainPoints, values, resultIndex);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to find visibility.\n" + ex.Message, "Find Visibility", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(updatedData);
        }
        private void UpdateStatus(string message, bool error)
        {
            if (lblSyncStatus.InvokeRequired)
            {
                var updateProgress = new UpdateProgressDelegate(UpdateStatus);
                object[] args = { message, error };
                lblSyncStatus.Invoke(updateProgress, args);
                return;
            }

            lblSyncStatus.Text = message;
            lblSyncStatus.ForeColor = error ? Color.Red : Color.Black;
        }
        public void UpdateProgress(DownloadProgressChangedEventArgs e)
        {
            if (progressBar.InvokeRequired)
            {
                UpdateProgressDelegate _delegate = new UpdateProgressDelegate(UpdateProgress);
                progressBar.Invoke(_delegate, new object[] { e });
            }
            else
            {
                double mult = 1.0;
                if (TotalUpdateSize > int.MaxValue)
                    mult = (double)int.MaxValue / TotalUpdateSize;

                progressBar.Minimum = 0;
                progressBar.Maximum = (int)(TotalUpdateSize * mult);
                
                // Set the current value.  In certain circumstances, this value may
                // become invalid, so we need to test it first.
                // NOTE: Fixes bug #1770765 - Status Bar Exception
                int currValue = (int)((CompletedUpdateSize + e.BytesReceived) * mult);
                if (currValue >= progressBar.Minimum &&
                    currValue <= progressBar.Maximum)
                    progressBar.Value = currValue;

                TimeSpan ts = (DateTime.Now - StartTime);
                                
                lblBytes.Text = 
                    DownloadedBytesStringConverter.Convert(CompletedUpdateSize + e.BytesReceived, TotalUpdateSize) + 
                    " out of " + 
                    DownloadedBytesStringConverter.Convert(TotalUpdateSize) +
                    " downloaded (" + 
                    DownloadedBytesStringConverter.Convert(
                        (CompletedUpdateSize + e.BytesReceived) / ts.TotalSeconds,
                        "0.0") +
                    "/sec)";
            }
        }
Example #32
0
    /// <summary>This method will transition a scene manager from on to the other, or load the first scene manager upon load.</summary>
    /// <typeparam name="TSceneManager"></typeparam>
    /// <param name="progress"></param>
    /// <param name="setup"></param>
    /// <param name="sceneManager"></param>
    /// <returns></returns>
    /// <example>
    ///     <code title="Example" description="" lang="CS">
    /// GameManager.Transition&lt;SceneManagerB&gt;(sceneManagerB=&gt;{
    ///     sceneManagerB.SetSomethingBeforeItsLoaded();
    /// }, (message,progress)=&gt; { Debug.Log(progress + "% " + message);</code>
    /// </example>
    public static Coroutine Transition <TSceneManager>(TSceneManager sceneManager, Action <TSceneManager> setup = null, UpdateProgressDelegate progress = null) where TSceneManager : SceneManager
    {
        if (sceneManager == null)
        {
            throw new Exception(String.Format("{0} is null or was not found while trying to load the game. Have you loaded the correct scene? Try", typeof(TSceneManager).Name));
        }

        if (ActiveSceneManager != null)
        {
            //ActiveSceneManager.Unload();
            ActiveSceneManager.enabled = false;
            ActiveSceneManager.gameObject.SetActive(false);
            Log("Deactivated old scene manager.");
        }

        ActiveSceneManager = sceneManager;
        ActiveSceneManager.gameObject.SetActive(true);
        ActiveSceneManager.enabled = true;
        Log("Scene Manager Enabled");
        if (setup != null)
        {
            setup(sceneManager);
        }
        ActiveSceneManager.OnLoading();
        Log("Beginning Scene Manager Loading");
        return(Instance.StartCoroutine(LoadSceneManager(progress ?? DefaultUpdateProgress)));
    }
Example #33
0
 public static Coroutine SwitchGameAndLevel <TGame>(TGame controller, Action <TGame> setup = null,
                                                    UpdateProgressDelegate progress        = null) where TGame : SceneManager
 {
     return(null);
 }
Example #34
0
        /// <summary>
        /// A general HTTP PUT method, with delegates for progress and cancelling. May throw various exceptions.
        /// </summary>
        /// <param name="progressDelegate">Delegate called periodically (500ms) with percent complete</param>
        /// <param name="cancellingDelegate">Delegate called periodically to see if need to cancel</param>
        /// <param name="uri">URI to PUT to</param>
        /// <param name="proxy">A proxy to handle the HTTP connection</param>
        /// <param name="path">Path to file to put</param>
        /// <param name="timeout_ms">Timeout for the connection in ms. 0 for no timeout.</param>
        public static void Put(UpdateProgressDelegate progressDelegate, FuncBool cancellingDelegate,
            Uri uri, IWebProxy proxy, string path, int timeout_ms)
        {
            using (Stream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read),
                requestStream = PUT(uri, proxy, fileStream.Length, timeout_ms))
            {
                long len = fileStream.Length;
                DataCopiedDelegate dataCopiedDelegate = delegate(long bytes)
                    {
                        if (progressDelegate != null && len > 0)
                            progressDelegate((int)((bytes * 100) / len));
                    };

                CopyStream(fileStream, requestStream, dataCopiedDelegate, cancellingDelegate);
            }
        }
Example #35
0
        public DevMetricsData CalcDevMetrics(int Huge_calcHDMX, int Huge_calcLTSH, int Huge_calcVDMX,
                                              ushort numGlyphs,
                                              byte[] phdmxPointSizes, ushort maxHdmxPointSize,
                                              byte uchPixelHeightRangeStart, byte uchPixelHeightRangeEnd,
                                              ushort[] pVDMXxResolution, ushort[] pVDMXyResolution,
                                              ushort cVDMXResolutions, UpdateProgressDelegate pUpdateProgressDelegate)
        {
            _lib.PropertySet("truetype", "interpreter-version", 35);
            if ( Huge_calcHDMX == 0 && Huge_calcLTSH == 0 && Huge_calcVDMX == 0 )
                return null;

            this.m_DevMetricsData = new DevMetricsData();

            if ( Huge_calcHDMX != 0 )
            {
                List<uint> requestedPixelSize = new List<uint>();
                for( ushort i = 0; i <= maxHdmxPointSize ; i++ ) {
                    if ( phdmxPointSizes[i] == 1 ) {
                        requestedPixelSize.Add((uint)i);
                    }
                }

                this.m_DevMetricsData.hdmxData = new HDMX();
                this.m_DevMetricsData.hdmxData.Records = new HDMX_DeviceRecord[requestedPixelSize.Count];

                for (int i = 0; i < requestedPixelSize.Count; i++) {
                    if ( m_UserCancelledTest ) return null;
                    trySetPixelSizes(0, requestedPixelSize[i]);
                    this.m_DevMetricsData.hdmxData.Records[i] = new HDMX_DeviceRecord();
                    this.m_DevMetricsData.hdmxData.Records[i].Widths = new byte[_face.GlyphCount];
                    for (uint glyphIndex = 0; glyphIndex < _face.GlyphCount; glyphIndex++)
                    {
                        _face.LoadGlyph(glyphIndex, LoadFlags.Default|LoadFlags.ComputeMetrics, LoadTarget.Normal);
                        this.m_DevMetricsData.hdmxData.Records[i].Widths[glyphIndex] =  (byte) _face.Glyph.Advance.X.Round();
                    }
                }
            }

            if ( Huge_calcLTSH != 0 )
            {
                this.m_DevMetricsData.ltshData = new LTSH();
                this.m_DevMetricsData.ltshData.yPels = new byte[numGlyphs];

                for (uint i = 0; i < this.m_DevMetricsData.ltshData.yPels.Length; i++) {
                    this.m_DevMetricsData.ltshData.yPels[i] = 1;
                }
                int remaining = numGlyphs;
                for (uint j = 254; j > 0; j--) {
                    if ( remaining == 0 )
                        break;
                    if ( m_UserCancelledTest ) return null;
                    trySetPixelSizes(0, j);
                    for (uint i = 0; i < this.m_DevMetricsData.ltshData.yPels.Length; i++) {
                        if ( this.m_DevMetricsData.ltshData.yPels[i] > 1 )
                            continue;
                        _face.LoadGlyph(i, LoadFlags.Default|LoadFlags.ComputeMetrics, LoadTarget.Normal);
                        int Advance_X = _face.Glyph.Advance.X.Round() ;
                        int LinearHorizontalAdvance = _face.Glyph.LinearHorizontalAdvance.Round() ;
                        if ( Advance_X == LinearHorizontalAdvance )
                            continue;
                        int difference = Advance_X - LinearHorizontalAdvance ;
                        if ( difference < 0 )
                            difference = - difference;
                        if ( ( j >= 50 ) && (difference * 50 <= LinearHorizontalAdvance) ) // compat "<="
                            continue;
                        // this is off-spec but happens to agree better...
                        difference = (_face.Glyph.Advance.X.Value << 10) - _face.Glyph.LinearHorizontalAdvance.Value;
                        if ( difference < 0 )
                            difference = - difference;
                        if ( ( j >= 50 ) && (difference * 50 <= _face.Glyph.LinearHorizontalAdvance.Value) ) // compat "<=="
                            continue;
                        // off-spec-ness ends.
                        this.m_DevMetricsData.ltshData.yPels[i] = (byte) ( j + 1 );
                        remaining--;
                    }
                }
            }

            if ( Huge_calcVDMX != 0 )
            {
                this.m_DevMetricsData.vdmxData = new VDMX();
                this.m_DevMetricsData.vdmxData.groups = new VDMX_Group[cVDMXResolutions];
                for ( int i = 0 ; i < cVDMXResolutions ; i++ )
                {
                    this.m_DevMetricsData.vdmxData.groups[i] = new VDMX_Group();
                    this.m_DevMetricsData.vdmxData.groups[i].entry = new VDMX_Group_vTable[uchPixelHeightRangeEnd
                                                                                           - uchPixelHeightRangeStart + 1];
                    for ( ushort j = uchPixelHeightRangeStart ; j <= uchPixelHeightRangeEnd ; j++ )
                    {
                        int k = j - uchPixelHeightRangeStart;
                        this.m_DevMetricsData.vdmxData.groups[i].entry[k] = new VDMX_Group_vTable() ;
                        this.m_DevMetricsData.vdmxData.groups[i].entry[k].yPelHeight = j ;

                        uint x_pixelSize = (uint) ( (pVDMXyResolution[i] == 0) ?
                                                    0 : (pVDMXxResolution[i] * j + pVDMXyResolution[i]/2 ) / pVDMXyResolution[i] );
                        if ( m_UserCancelledTest ) return null;
                        trySetPixelSizes(x_pixelSize, j);
                        short yMax = 0;
                        short yMin = 0;
                        BBox box;
                        Glyph glyph;
                        for (uint ig = 0; ig < numGlyphs; ig++) {
                            _face.LoadGlyph(ig, LoadFlags.Default|LoadFlags.ComputeMetrics, LoadTarget.Normal);
                            glyph = _face.Glyph.GetGlyph();
                            box = glyph.GetCBox(GlyphBBoxMode.Truncate);
                            if (box.Top > yMax) yMax = (short) box.Top;
                            if (box.Bottom < yMin) yMin = (short) box.Bottom;
                            glyph.Dispose();
                        }
                        this.m_DevMetricsData.vdmxData.groups[i].entry[k].yMax = yMax ;
                        this.m_DevMetricsData.vdmxData.groups[i].entry[k].yMin = yMin ;
                    }
                }
            }

            return m_DevMetricsData;
        }
Example #36
0
        private void RunNow()
        {
            try
            {
                long maxCount = System.Convert.ToInt64(_nupCycles.Value);
                UpdateProgressDelegate updateDeleg = new UpdateProgressDelegate(UpdateProgress);
                ResetFormDelegate resetDeleg = new ResetFormDelegate(ResetForm);

                bool runForEver = _chkRunForever.Checked;
                int sleepCount = 0;
                int sleepAfter = System.Convert.ToInt32(_nupSleepCycles.Value);
                int sleepTime = System.Convert.ToInt32(_nupSleep.Value);

                long uiUpdate = System.Convert.ToInt64( Math.Round((System.Convert.ToDouble(maxCount) / 100) * 2,0));
                long uiUpdateCount = 0;

                do
                {
                    for (long i = 0; i < maxCount; i++)
                    {
                        uiUpdateCount++;

                        runForEver = _chkRunForever.Checked;
                        sleepAfter = System.Convert.ToInt32(_nupSleepCycles.Value);
                        sleepTime = System.Convert.ToInt32(_nupSleep.Value);

                        if (_stop)
                        {
                            runForEver = false;
                            break;
                        }

                        if (uiUpdateCount >= uiUpdate)
                        {
                            Invoke(updateDeleg, new object[] { i, maxCount });
                            uiUpdateCount = 0;
                        }
                        //UpdateProgress(i, maxCount);

                        if (sleepTime > 0)
                        {
                            sleepCount++;
                            if (sleepCount >= sleepAfter)
                            {
                                Thread.Sleep(sleepTime);
                                sleepCount = 0;
                            }
                        }
                    }
                }
                while (runForEver);
                Invoke(updateDeleg, new object[] { maxCount, maxCount });
                Invoke(resetDeleg, null);
                    //ResetForm();

            }
            catch { }
        }
        public void UpdateProgress(DownloadProgressChangedEventArgs e)
        {
            if (Thread.CurrentThread != Dispatcher.Thread)
            {
                UpdateProgressDelegate _delegate = new UpdateProgressDelegate(UpdateProgress);
                Dispatcher.Invoke(DispatcherPriority.Normal, _delegate, e);
            }
            else
            {
                double mult = 1.0;
                if (TotalUpdateSize > int.MaxValue)
                    mult = (double)int.MaxValue / TotalUpdateSize;
                                
                progressBar.Minimum = 0;
                progressBar.Maximum = (TotalUpdateSize * mult);
                
                // Set the current value.  In certain circumstances, this value may
                // become invalid, so we need to test it first.
                // NOTE: Fixes bug #1770765 - Status Bar Exception
                double currValue = (CompletedUpdateSize + e.BytesReceived) * mult;
                if (currValue >= progressBar.Minimum &&
                    currValue <= progressBar.Maximum)
                    progressBar.Value = currValue;

                TimeSpan ts = (DateTime.Now - StartTime);
                                
                SetParagraphText(
                    DownloadedBytesStringConverter.Convert(CompletedUpdateSize + e.BytesReceived, TotalUpdateSize) + 
                    " out of " + 
                    DownloadedBytesStringConverter.Convert(TotalUpdateSize) +
                    " downloaded");
                
                lblSpeed.Text = DownloadedBytesStringConverter.Convert(
                    (CompletedUpdateSize + e.BytesReceived) / ts.TotalSeconds,
                    "0.0") + "/sec";
            }
        }
Example #38
0
 protected static string PollTaskForResult(IXenConnection connection, ref Session session,
                                           XenRef <Task> task, UpdateProgressDelegate updateProgressDelegate)
 {
     return(PollTaskForResult(connection, ref session, task, updateProgressDelegate, 0, 100));
 }
        private void backgroundWorker_DoWork(object s, DoWorkEventArgs args)
        {
            Object[] arguments = (Object[])args.Argument;
            int n = (int)arguments[0];
            int dim = (int)arguments[1];
            double d = (double)arguments[2];
            Point X = (Point)arguments[3];

            ObservableCollection<PointWrapper> sample = new ObservableCollection<PointWrapper>();
            int totalPoints = 0;
            int validPoint = 0;
            Stopwatch stopwatch = Stopwatch.StartNew();
            //MAIN PROCEDURE LOOP!!
            while (sample.Count < n)
            {

                if (bgWorker.CancellationPending)
                {
                    args.Cancel = true;
                    return;
                }

                Point point = null;

                Console.WriteLine("\nPOINT No " + (totalPoints + 1) + " \n");
                point = planeProjector.makePoint(X, d, dim);

                point = pointProcessor.processPoint(point, X);

                PointWrapper pointData = new PointWrapper(point, X, d);
                if (pointData.IsValid)
                {
                    sample.Add(pointData);
                    validPoint++;
                }
                totalPoints++;

                double time = stopwatch.ElapsedMilliseconds;
                UpdateProgressDelegate update = new UpdateProgressDelegate(UpdateProgressText);
                progressWindow.Dispatcher.BeginInvoke(update, (validPoint * 100) / n, totalPoints, time);
            }
            stopwatch.Stop();

            args.Result = sample;
        }
Example #40
0
        public DevMetricsData CalcDevMetrics(int Huge_calcHDMX, int Huge_calcLTSH, int Huge_calcVDMX,
                                             ushort numGlyphs,
                                             byte[] phdmxPointSizes, ushort maxHdmxPointSize,
                                             byte uchPixelHeightRangeStart, byte uchPixelHeightRangeEnd,
                                             ushort[] pVDMXxResolution, ushort[] pVDMXyResolution,
                                             ushort cVDMXResolutions, UpdateProgressDelegate pUpdateProgressDelegate)
        {
            _lib.PropertySet("truetype", "interpreter-version", 35);
            if (Huge_calcHDMX == 0 && Huge_calcLTSH == 0 && Huge_calcVDMX == 0)
            {
                return(null);
            }

            this.m_DevMetricsData = new DevMetricsData();

            if (Huge_calcHDMX != 0)
            {
                List <uint> requestedPixelSize = new List <uint>();
                for (ushort i = 0; i <= maxHdmxPointSize; i++)
                {
                    if (phdmxPointSizes[i] == 1)
                    {
                        requestedPixelSize.Add((uint)i);
                    }
                }

                this.m_DevMetricsData.hdmxData         = new HDMX();
                this.m_DevMetricsData.hdmxData.Records = new HDMX_DeviceRecord[requestedPixelSize.Count];

                for (int i = 0; i < requestedPixelSize.Count; i++)
                {
                    if (m_UserCancelledTest)
                    {
                        return(null);
                    }
                    trySetPixelSizes(0, requestedPixelSize[i]);
                    this.m_DevMetricsData.hdmxData.Records[i]        = new HDMX_DeviceRecord();
                    this.m_DevMetricsData.hdmxData.Records[i].Widths = new byte[_face.GlyphCount];
                    for (uint glyphIndex = 0; glyphIndex < _face.GlyphCount; glyphIndex++)
                    {
                        _face.LoadGlyph(glyphIndex, LoadFlags.Default | LoadFlags.ComputeMetrics, LoadTarget.Normal);
                        this.m_DevMetricsData.hdmxData.Records[i].Widths[glyphIndex] = (byte)_face.Glyph.Advance.X.Round();
                    }
                }
            }

            if (Huge_calcLTSH != 0)
            {
                this.m_DevMetricsData.ltshData       = new LTSH();
                this.m_DevMetricsData.ltshData.yPels = new byte[numGlyphs];

                for (uint i = 0; i < this.m_DevMetricsData.ltshData.yPels.Length; i++)
                {
                    this.m_DevMetricsData.ltshData.yPels[i] = 1;
                }
                int remaining = numGlyphs;
                for (uint j = 254; j > 0; j--)
                {
                    if (remaining == 0)
                    {
                        break;
                    }
                    if (m_UserCancelledTest)
                    {
                        return(null);
                    }
                    trySetPixelSizes(0, j);
                    for (uint i = 0; i < this.m_DevMetricsData.ltshData.yPels.Length; i++)
                    {
                        if (this.m_DevMetricsData.ltshData.yPels[i] > 1)
                        {
                            continue;
                        }
                        _face.LoadGlyph(i, LoadFlags.Default | LoadFlags.ComputeMetrics, LoadTarget.Normal);
                        int Advance_X = _face.Glyph.Advance.X.Round();
                        int LinearHorizontalAdvance = _face.Glyph.LinearHorizontalAdvance.Round();
                        if (Advance_X == LinearHorizontalAdvance)
                        {
                            continue;
                        }
                        int difference = Advance_X - LinearHorizontalAdvance;
                        if (difference < 0)
                        {
                            difference = -difference;
                        }
                        if ((j >= 50) && (difference * 50 <= LinearHorizontalAdvance))     // compat "<="
                        {
                            continue;
                        }
                        // this is off-spec but happens to agree better...
                        difference = (_face.Glyph.Advance.X.Value << 10) - _face.Glyph.LinearHorizontalAdvance.Value;
                        if (difference < 0)
                        {
                            difference = -difference;
                        }
                        if ((j >= 50) && (difference * 50 <= _face.Glyph.LinearHorizontalAdvance.Value))     // compat "<=="
                        {
                            continue;
                        }
                        // off-spec-ness ends.
                        this.m_DevMetricsData.ltshData.yPels[i] = (byte)(j + 1);
                        remaining--;
                    }
                }
            }

            if (Huge_calcVDMX != 0)
            {
                this.m_DevMetricsData.vdmxData        = new VDMX();
                this.m_DevMetricsData.vdmxData.groups = new VDMX_Group[cVDMXResolutions];
                for (int i = 0; i < cVDMXResolutions; i++)
                {
                    this.m_DevMetricsData.vdmxData.groups[i]       = new VDMX_Group();
                    this.m_DevMetricsData.vdmxData.groups[i].entry = new VDMX_Group_vTable[uchPixelHeightRangeEnd
                                                                                           - uchPixelHeightRangeStart + 1];
                    for (ushort j = uchPixelHeightRangeStart; j <= uchPixelHeightRangeEnd; j++)
                    {
                        int k = j - uchPixelHeightRangeStart;
                        this.m_DevMetricsData.vdmxData.groups[i].entry[k]            = new VDMX_Group_vTable();
                        this.m_DevMetricsData.vdmxData.groups[i].entry[k].yPelHeight = j;

                        uint x_pixelSize = (uint)((pVDMXyResolution[i] == 0) ?
                                                  0 : (pVDMXxResolution[i] * j + pVDMXyResolution[i] / 2) / pVDMXyResolution[i]);
                        if (m_UserCancelledTest)
                        {
                            return(null);
                        }
                        trySetPixelSizes(x_pixelSize, j);
                        short yMax = 0;
                        short yMin = 0;
                        BBox  box;
                        Glyph glyph;
                        for (uint ig = 0; ig < numGlyphs; ig++)
                        {
                            _face.LoadGlyph(ig, LoadFlags.Default | LoadFlags.ComputeMetrics, LoadTarget.Normal);
                            glyph = _face.Glyph.GetGlyph();
                            box   = glyph.GetCBox(GlyphBBoxMode.Truncate);
                            if (box.Top > yMax)
                            {
                                yMax = (short)box.Top;
                            }
                            if (box.Bottom < yMin)
                            {
                                yMin = (short)box.Bottom;
                            }
                            glyph.Dispose();
                        }
                        this.m_DevMetricsData.vdmxData.groups[i].entry[k].yMax = yMax;
                        this.m_DevMetricsData.vdmxData.groups[i].entry[k].yMin = yMin;
                    }
                }
            }

            return(m_DevMetricsData);
        }
Example #41
0
        private void UpdateForm_Load(object sender, EventArgs e)
        {
            _rusumeDownload = new RusumeDownload();
            _rusumeDownload.CLabeText += new RusumeDownload.CLabelTextDelegate(_rusumeDownload_CLabeText);
            _rusumeDownload.CProgressBarMaximum += new RusumeDownload.CProgressBarMaximumDeletate(_rusumeDownload_CProgressBarMaximum);
            _rusumeDownload.CProgressBarValue += new RusumeDownload.CProgressBarValueDeletate(_rusumeDownload_CProgressBarValue);
            _UpdateProgressDelegate = new UpdateProgressDelegate(UpdateProgress);
            _CProgressBarValue = new CProgressBarValue(ProgressBarValue);
            _CProgressBarMaximum = new CProgressBarMaximum(ProgressBarMaximum);
            _CLabeText = new CLabeText(LabeText);
            _ItemExitDelegateEvent += new ItemExitDelegate(UpdateForm__ItemExitDelegateEvent);
            _MsgBoxShowDelegateEvent += new MsgBoxShowDelegate(UpdateForm__MsgBoxShowDelegateEvent);

            try
            {
                if (File.Exists(FileName))
                {
                    File.Delete(FileName);
                }
            }
            catch (Exception ex)
            {
                _MsgBoxShowDelegateEvent("删除老文件错误," + ex.Message,true);
                ExitProgram();
            }
            _Thread = new Thread(new ThreadStart(StartDownLoad));
            _Thread.Start();
        }
Example #42
0
        protected static String PollTaskForResult(IXenConnection connection, ref Session session,
            XenRef<Task> task, UpdateProgressDelegate updateProgressDelegate, int min, int max)
        {
            Program.AssertOffEventThread();

            task_status_type status;
            int progress;

            do
            {
                status = (task_status_type)Task.DoWithSessionRetry(connection, ref session,
                                                                   (Task.TaskStatusOp)Task.get_status, task.opaque_ref);
                progress = min + (int)((max - min) * (double)Task.DoWithSessionRetry(connection, ref session,
                                                                                     (Task.TaskProgressOp)Task.get_progress, task.opaque_ref));

                updateProgressDelegate(progress);

                Thread.Sleep(100);
            }
            while (status == task_status_type.pending || status == task_status_type.cancelling);

            if (status == task_status_type.failure)
            {
                throw new Failure(Task.get_error_info(session, task));
            }
            else
            {
                return Task.get_result(session, task);
            }
        }
Example #43
0
 private void UpdateProgress(int value)
 {
     if (progressBar1.InvokeRequired)
     {
         UpdateProgressDelegate updPbDel = new UpdateProgressDelegate(this.UpdateProgress);
         BeginInvoke(updPbDel, new object[] { value });
     }
     else
     {
         if (value < 0)
             progressBar1.Value = 0;
         else if (value > progressBar1.Maximum)
             progressBar1.Value = progressBar1.Maximum;
         else
             progressBar1.Value = value;
     }
 }
Example #44
0
 private void OnProgressPropertyChanged(DependencyPropertyChangedEventArgs e)
 {
     Determinate.Value = (double)e.NewValue;
     var updateBarDelegate = new UpdateProgressDelegate(Determinate.SetValue);
     Dispatcher.Invoke(updateBarDelegate, DispatcherPriority.Background, RangeBase.ValueProperty, (double)e.NewValue);
 }
Example #45
0
        public bool RastTest(int resX, int resY, int[] arrPointSizes,
                             float stretchX, float stretchY,
                             float rotation, float skew,
                             float[,] matrix,
                             bool setBW, bool setGrayscale, bool setCleartype, uint CTFlags,
                             RastTestErrorDelegate pRastTestErrorDelegate,
                             UpdateProgressDelegate pUpdateProgressDelegate,
                             int numGlyphs)
        {
            int        count_sets = 0;
            LoadFlags  lf         = LoadFlags.Default;
            LoadTarget lt         = LoadTarget.Normal;

            if (setBW)
            {
                lf = LoadFlags.Default | LoadFlags.NoAutohint | LoadFlags.Monochrome | LoadFlags.ComputeMetrics;
                lt = LoadTarget.Mono;
                _lib.PropertySet("truetype", "interpreter-version", 35);

                count_sets++;
            }
            if (setGrayscale)
            {
                lf = LoadFlags.Default | LoadFlags.NoAutohint | LoadFlags.ComputeMetrics;
                lt = LoadTarget.Normal;
                _lib.PropertySet("truetype", "interpreter-version", 35);

                count_sets++;
            }
            if (setCleartype)
            {
                lf = LoadFlags.Default | LoadFlags.NoAutohint | LoadFlags.ComputeMetrics;
                lt = LoadTarget.Lcd;
                _lib.PropertySet("truetype", "interpreter-version", 40);

                count_sets++;
            }
            if (count_sets != 1)
            {
                throw new ArgumentOutOfRangeException("Only one of BW/Grayscale/Cleartype should be set");
            }

            try
            {
                TT_Diagnostics_Unset();
            }
            catch (Exception e)
            {
                throw new NotImplementedException("UnImplemented in this version of Freetype: " + FTVersion);
            };

            FTMatrix fmatrix = new FTMatrix(new Fixed16Dot16(matrix[0, 0] * stretchX), new Fixed16Dot16(matrix[0, 1] * stretchX),
                                            new Fixed16Dot16(matrix[1, 0] * stretchY), new Fixed16Dot16(matrix[1, 1] * stretchY));
            FTVector fdelta = new FTVector(new Fixed16Dot16(matrix[0, 2] * stretchX), new Fixed16Dot16(matrix[1, 2] * stretchY));
            /* matrix[2,0] = matrix[2,1] = 0, matrix[2,2] =1, not used */

            FTMatrix mskew = new FTMatrix(new Fixed16Dot16(1), new Fixed16Dot16(0),
                                          (new Fixed16Dot16(skew)).Tan(), new Fixed16Dot16(1));

            FTMatrix.Multiply(ref mskew, ref fmatrix);
            fdelta.Transform(mskew);

            FTVector rot_row1 = new FTVector(new Fixed16Dot16(1), new Fixed16Dot16(0));
            FTVector rot_row2 = new FTVector(new Fixed16Dot16(1), new Fixed16Dot16(0));

            rot_row1.Rotate(new Fixed16Dot16(rotation));
            rot_row2.Rotate(new Fixed16Dot16(rotation + 90));
            FTMatrix mrot = new FTMatrix(rot_row1, rot_row2);

            FTMatrix.Multiply(ref mrot, ref fmatrix);
            fdelta.Rotate(new Fixed16Dot16(-rotation));

            for (int i = 0; i < arrPointSizes.Length; i++)
            {
                if (m_UserCancelledTest)
                {
                    return(true);
                }
                pUpdateProgressDelegate("Processing Size " + arrPointSizes[i]);
                try{
                    _face.SetCharSize(new Fixed26Dot6(arrPointSizes[i]),
                                      new Fixed26Dot6(arrPointSizes[i]),
                                      (uint)resX, (uint)resY);
                } catch (FreeTypeException e) {
                    if (e.Error == Error.InvalidPixelSize)
                    {
                        pRastTestErrorDelegate("_rast_W_FT_InvalidPixelSize", "Setting unsupported size "
                                               + arrPointSizes[i] + " for fixed-size font.");
                        m_RastErrorCount += 1;
                        continue;
                    }
                    else
                    {
                        throw;
                    }
                }
                _face.SetTransform(fmatrix, fdelta);
                for (uint ig = 0; ig < numGlyphs; ig++)
                {
                    diagnostics_Function diagnostics =
                        (message, opcode, range_base, is_composite, IP, callTop, opc, start) =>
                    {
                        string sDetails = "Size " + arrPointSizes[i] + ", " + opcode;
                        switch (range_base)
                        {
                        case 3:
                            if (is_composite != 0)
                            {
                                sDetails += ", Composite Glyph ID " + ig;
                            }
                            else
                            {
                                sDetails += ", Glyph ID " + ig;
                            }
                            break;

                        case 1:           /* font */
                        case 2: /* cvt */ // ?
                            sDetails += ", Pre-Program";
                            break;

                        default:                      /* none */
                            sDetails += ", Unknown?"; // ?
                            break;
                        }

                        sDetails += ", At ByteOffset " + IP;

                        if (callTop > 0)
                        {
                            sDetails += ", In function " + opc + " offsetted by " + (IP - start);
                        }

                        pRastTestErrorDelegate(message, sDetails);
                        m_RastErrorCount += 1;
                        return(0);    // Not used currently.
                    };
                    TT_Diagnostics_Set(diagnostics);
                    try{
                        _face.LoadGlyph(ig, lf, lt);
                    } catch (Exception ee) {
                        if (ee is FreeTypeException)
                        {
                            FreeTypeException e = (FreeTypeException)ee;
                            if (e.Error == Error.InvalidOutline)
                            {
                                pRastTestErrorDelegate("_rast_W_FT_InvalidOutline", "Invalid Outline in Glyph " + ig);
                                m_RastErrorCount += 1;
                                continue;
                            }
                            if (e.Error == Error.InvalidArgument)
                            {
                                pRastTestErrorDelegate("_rast_W_FT_InvalidArgument", "Invalid Argument in Glyph " + ig);
                                m_RastErrorCount += 1;
                                continue;
                            }
                            if (e.Error == Error.InvalidSizeHandle)
                            {
                                pRastTestErrorDelegate("_rast_W_FT_InvalidSizeHandle", "Invalid Metrics for Glyph " + ig + " at size "
                                                       + arrPointSizes[i]);
                                m_RastErrorCount += 1;
                                continue;
                            }
                        }

                        pRastTestErrorDelegate("_rast_I_FT_Error_Supplymentary_Info", "Glyph " + ig +
                                               " at size " + arrPointSizes[i]);
                        throw;
                    }
                    TT_Diagnostics_Unset();
                }
            }
            return(true);
        }
 private void UpdateProgress(String text)
 {
     if (tbStatusBar.InvokeRequired == false)
     {
         // on the same thread
         lblProgressText.Text = text;
         progbarPrinting.PerformStep();
     }
     else
     {
         UpdateProgressDelegate updateprog = new UpdateProgressDelegate(UpdateProgress);
         this.BeginInvoke(updateprog, new object[] { text });
     }
 }
Example #47
0
 protected static string PollTaskForResult(IXenConnection connection, ref Session session,
     XenRef<Task> task, UpdateProgressDelegate updateProgressDelegate)
 {
     return PollTaskForResult(connection, ref session, task, updateProgressDelegate, 0, 100);
 }
Example #48
0
 public ProgressWindow()
 {
     InitializeComponent();
     updateLabelDelegate    = new UpdateLableDelegate(statusLabel.SetValue);
     updateProgressDelegate = new UpdateProgressDelegate(statusProgressBar.SetValue);
 }
Example #49
0
        UpdateProgressDelegate UpdatePRogress;//Calls delegate that updates ProgressBar
        public GetPixelStrings(UpdateProgressDelegate UpdateProgressBar)
        {
            UpdatePRogress = UpdateProgressBar;

        }
        private bool MainWork(string filename, int indexOfNHSNumber, Dispatcher dispatcher, ref bool wasCancelled)
        {
            _validNHSNumCount   = 0;
            _inValidNHSNumCount = 0;
            _missingNHSNumCount = 0;
            _rowsProcessed      = 0;

            // the thing that gets the digest..
            Crypto crypto = new Crypto();

            if (usingEncryptedSalt)
            {
                crypto.SetEncryptedSalt(File.ReadAllBytes(encryptedSaltFile));
            }
            else
            {
                crypto.SetPlainTextSalt(_salt);
            }

            FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read);

            FileStream writeStream;

            try
            {
                writeStream = new FileStream(_outputFolder + "\\" + "OpenPseudonymised_" + _outputFileNameOnly, FileMode.Create, FileAccess.Write);
            }
            catch (IOException)
            {
                ErrorProgressDelegate error = new ErrorProgressDelegate(ErrorProgressText);
                dispatcher.BeginInvoke(error, "OpenPseudonymiser cannot create the Output file. Is the output file already open?");
                return(false);
            }

            _inputFileStreamLength = fileStream.Length;
            long totalCharsRead = 0;

            SortedList <string, int> inputFields;
            SortedList <int, string> outputFields;

            GetInputAndOutputFields(out inputFields, out outputFields);

            WriteRunLogFile(inputFields, outputFields);

            using (StreamWriter streamWriter = new StreamWriter(writeStream))
            {
                using (StreamReader streamReader = new StreamReader(fileStream))
                {
                    // 'read off' the first line, these are the input columns headings
                    string[] inputHeadings = streamReader.ReadLine().Split(',');

                    // write the first line as the selected column headings
                    string lineToWrite = "Digest,";
                    foreach (int key in outputFields.Keys) // keys in the output are indexes (opposite to input SortedList)
                    {
                        lineToWrite += outputFields[key] + ",";
                    }

                    // Do we want to do any NHSNumber checksum validation?
                    if (_performNHSNumberValidation)
                    {
                        lineToWrite += "validNHS,";
                    }

                    // strip trailing comma
                    lineToWrite = lineToWrite.Substring(0, lineToWrite.Length - 1);
                    streamWriter.WriteLine(lineToWrite);

                    // We have no way of knowing how many lines there are in the file without opening the whole thing, which would kill the app.
                    // So we will use a fixed size buffer and manually look for lines inside it.
                    int    _bufferSize = 16384;
                    char[] readBuffer  = new char[_bufferSize];

                    StringBuilder workingBuffer = new StringBuilder(); // where we will store the left over stuff after we split the read buffer into lines

                    // read into the buffer
                    long charsRead = streamReader.Read(readBuffer, 0, _bufferSize);
                    totalCharsRead += charsRead;

                    while (charsRead > 0)
                    {
                        if (worker.CancellationPending)
                        {
                            wasCancelled = true;
                            //display cancellation message
                            CancelProgressDelegate canceller = new CancelProgressDelegate(CancelProgressText);
                            dispatcher.BeginInvoke(canceller, _rowsProcessed);
                            return(true);
                        }

                        // put the stuff we just read from the file into our working buffer
                        workingBuffer.Append(readBuffer);

                        // slice the workingBuffer into lines
                        string[] linesArray = workingBuffer.ToString().Split('\n');

                        // process all the lines EXCEPT THE LAST ONE in the lines array (the last one is likely to be incomplete)
                        for (int i = 0; i < (linesArray.Length - 1); i++)
                        {
                            string line = linesArray[i];
                            // the line should have the same number of columns as the ColumnCollection, if not then up the jagged lines count, and skip processing
                            string[] lineColumns = line.Split(',');


                            // if we get a jagged result here (i.e. length of columns does not match the headers) then try a split using quote delimited data
                            if (lineColumns.Length != ColumnCollection.Count)
                            {
                                // thanks to http://stackoverflow.com/questions/3776458/split-a-comma-separated-string-with-both-quoted-and-unquoted-strings
                                // for this bit of regex
                                Regex csvSplit = new Regex("(?:^|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)", RegexOptions.Compiled);

                                int jag = 0;
                                lineColumns = new string[csvSplit.Matches(line).Count];
                                foreach (Match match in csvSplit.Matches(line))
                                {
                                    lineColumns[jag] = match.Value.TrimStart(',');
                                    jag++;
                                }
                            }

                            // if we're still jagged then we can't do much other than skip processing this line and increment the jagged counter
                            if (lineColumns.Length != ColumnCollection.Count)
                            {
                                _jaggedLines++;
                            }
                            else
                            {
                                // get the columns for crypting using the inputFields, since this is a sorted list we always get the indexes from aphabetically ordered keys
                                SortedList <string, string> hashNameValueCollection = new SortedList <string, string>();

                                // first column is the digest
                                foreach (string key in inputFields.Keys)
                                {
                                    string theData = lineColumns[inputFields[key]];

                                    // we always process the one they selected as NHSNumber ..
                                    if (_performNHSNumberValidation)
                                    {
                                        string nhskey = inputHeadings[indexOfNHSNumber - 1];
                                        if (nhskey == key)
                                        {
                                            theData = crypto.ProcessNHSNumber(theData);
                                        }
                                    }
                                    hashNameValueCollection.Add(key, theData);
                                }
                                string digest   = crypto.GetDigest(hashNameValueCollection);
                                string validNHS = "";
                                lineToWrite = digest + ",";

                                // output the rest of the columns in the output list
                                foreach (int key in outputFields.Keys) // keys in the output are indexes (opposite to input SortedList)
                                {
                                    // Look for column heading that is a date..
                                    if (_processDateColumns.Contains(outputFields[key]))
                                    {
                                        lineToWrite += crypto.RoundDownDate(lineColumns[key]) + ",";
                                    }
                                    else
                                    {
                                        lineToWrite += lineColumns[key] + ",";
                                    }
                                }

                                // last column is the NHS Validation (if requested)
                                if (_performNHSNumberValidation)
                                {
                                    // find the NHSNumber in the list of input columns and validate it
                                    string key = inputHeadings[indexOfNHSNumber - 1];
                                    {
                                        string trimmedNHSNumber = lineColumns[indexOfNHSNumber - 1].Trim();
                                        // trimmed data is length < 1 so we call this missing NHS Number
                                        if (trimmedNHSNumber.Length < 1)
                                        {
                                            validNHS = "-1";
                                            _missingNHSNumCount++;
                                        }
                                        else
                                        {
                                            // we have data for the NHS field, is it valid?
                                            string cleanedNHSNumber = crypto.ProcessNHSNumber(trimmedNHSNumber);
                                            if (NHSNumberValidator.IsValidNHSNumber(cleanedNHSNumber))
                                            {
                                                validNHS = "1";
                                                _validNHSNumCount++;
                                            }
                                            else
                                            {
                                                validNHS = "0";
                                                _inValidNHSNumCount++;
                                            }
                                        }
                                        lineToWrite += validNHS + ",";
                                    }
                                }

                                // we're done writing the output line now. Strip trailing comma.
                                lineToWrite = lineToWrite.Substring(0, lineToWrite.Length - 1);
                                // some files have a double line break at the end of the lines, remove this.
                                lineToWrite = lineToWrite.Replace(Environment.NewLine, "").Replace("\r\n", "").Replace("\n", "").Replace("\r", "");
                                streamWriter.WriteLine(lineToWrite);
                            }
                        }
                        _rowsProcessed += linesArray.Length - 1;

                        // set the working buffer to be the last line, so the next pass can concatonate
                        string lastLine = linesArray[linesArray.Length - 1];
                        workingBuffer = new StringBuilder(lastLine);

                        UpdateProgressDelegate update = new UpdateProgressDelegate(UpdateProgressText);
                        dispatcher.BeginInvoke(update, totalCharsRead, _inputFileStreamLength, _rowsProcessed, _validNHSNumCount, _inValidNHSNumCount, _missingNHSNumCount);

                        // empty the readbuffer, or the last read will only partially fill it, and we'll have some old data in the tail
                        readBuffer = new char[_bufferSize];
                        // read the next lot
                        charsRead       = streamReader.Read(readBuffer, 0, _bufferSize);
                        totalCharsRead += charsRead;
                    }
                }
            }
            return(false);
        }
Example #51
0
        private void UpdateProgressInvoke(int currentlength)
        {
            UpdateProgressDelegate s = UpdateProgress;

            Dispatcher.BeginInvoke(s, currentlength);
        }
Example #52
0
		private void OnStepUpdate(object sender, ProgressArgs e)
		{
			// This gets called from another thread so we must thread
			// marhal back to the GUI thread.
			string text = e.Status;
			int percent = e.Progress;
			object[] args = new Object[] { text, percent };
			Delegate d = new UpdateProgressDelegate(UpdateProgress);
			this.Invoke(d, args);
		}
Example #53
0
        public bool RastTest(int resX, int resY, int[] arrPointSizes,
                             float stretchX, float stretchY,
                             float rotation, float skew,
                             float[,] matrix,
                             bool setBW, bool setGrayscale, bool setCleartype, uint CTFlags,
                             RastTestErrorDelegate pRastTestErrorDelegate,
                             UpdateProgressDelegate pUpdateProgressDelegate,
                             int numGlyphs)
        {
            int count_sets = 0;
            LoadFlags lf = LoadFlags.Default;
            LoadTarget lt = LoadTarget.Normal;
            if ( setBW )
            {
                lf = LoadFlags.Default|LoadFlags.NoAutohint|LoadFlags.Monochrome|LoadFlags.ComputeMetrics;
                lt = LoadTarget.Mono;
                _lib.PropertySet("truetype", "interpreter-version", 35);

                count_sets++;
            }
            if ( setGrayscale )
            {
                lf = LoadFlags.Default|LoadFlags.NoAutohint|LoadFlags.ComputeMetrics;
                lt = LoadTarget.Normal;
                _lib.PropertySet("truetype", "interpreter-version", 35);

                count_sets++;
            }
            if ( setCleartype )
            {
                lf = LoadFlags.Default|LoadFlags.NoAutohint|LoadFlags.ComputeMetrics;
                lt = LoadTarget.Lcd;
                _lib.PropertySet("truetype", "interpreter-version", 40);

                count_sets++;
            }
            if ( count_sets != 1 )
                throw new ArgumentOutOfRangeException("Only one of BW/Grayscale/Cleartype should be set");

            try
            {
                TT_Diagnostics_Unset();
            }
            catch (Exception e)
            {
                throw new NotImplementedException("UnImplemented in this version of Freetype: " + FTVersion);
            };

            FTMatrix fmatrix = new FTMatrix(new Fixed16Dot16( matrix[0,0] * stretchX ), new Fixed16Dot16( matrix[0,1] * stretchX ),
                                            new Fixed16Dot16( matrix[1,0] * stretchY ), new Fixed16Dot16( matrix[1,1] * stretchY ));
            FTVector fdelta = new FTVector(new Fixed16Dot16( matrix[0,2] * stretchX ), new Fixed16Dot16( matrix[1,2] * stretchY ));
            /* matrix[2,0] = matrix[2,1] = 0, matrix[2,2] =1, not used */

            FTMatrix mskew = new FTMatrix(new Fixed16Dot16( 1 ), new Fixed16Dot16( 0 ),
                                          (new Fixed16Dot16(skew)).Tan(), new Fixed16Dot16( 1 ));
            FTMatrix.Multiply(ref mskew, ref fmatrix);
            fdelta.Transform(mskew);

            FTVector rot_row1 = new FTVector(new Fixed16Dot16( 1 ), new Fixed16Dot16( 0 ));
            FTVector rot_row2 = new FTVector(new Fixed16Dot16( 1 ), new Fixed16Dot16( 0 ));
            rot_row1.Rotate(new Fixed16Dot16(rotation));
            rot_row2.Rotate(new Fixed16Dot16(rotation + 90));
            FTMatrix mrot = new FTMatrix(rot_row1, rot_row2);
            FTMatrix.Multiply(ref mrot, ref fmatrix);
            fdelta.Rotate(new Fixed16Dot16(-rotation));

            for (int i = 0; i < arrPointSizes.Length ; i++)
            {
                if ( m_UserCancelledTest ) return true;
                pUpdateProgressDelegate("Processing Size " + arrPointSizes[i]);
                _face.SetCharSize(new Fixed26Dot6(arrPointSizes[i]),
                                  new Fixed26Dot6(arrPointSizes[i]),
                                  (uint) resX, (uint) resY);
                _face.SetTransform(fmatrix, fdelta);
                for (uint ig = 0; ig < numGlyphs; ig++) {
                    diagnostics_Function diagnostics =
                        (message, opcode, range_base, is_composite, IP, callTop, opc, start) =>
                        {
                            string sDetails = "Size " + arrPointSizes[i] + ", " + opcode;
                            switch ( range_base )
                            {
                                case 3:
                                    if (is_composite != 0)
                                        sDetails += ", Composite Glyph ID " + ig;
                                    else
                                        sDetails += ", Glyph ID " + ig;
                                    break;
                                case 1: /* font */
                                case 2: /* cvt */ // ?
                                    sDetails += ", Pre-Program";
                                    break;
                                default: /* none */
                                    sDetails += ", Unknown?"; // ?
                                    break;
                            }

                            sDetails += ", At ByteOffset " + IP;

                            if (callTop > 0)
                                sDetails += ", In function " + opc + " offsetted by " + (IP - start);

                            pRastTestErrorDelegate(message, sDetails);
                            m_RastErrorCount += 1;
                            return 0; // Not used currently.
                        };
                    TT_Diagnostics_Set(diagnostics);
                    _face.LoadGlyph(ig, lf, lt);
                    TT_Diagnostics_Unset();
                }
            }
            return true;
        }
        private RoomData FindVisibilityByPointData(RoomData rd, AnalysisData aData, ProgressBar progressBar)
        {
            RoomData updatedData = new RoomData(rd);

            try
            {
                updatedData.RoomFace = FMEDataUtil.CreateFacebyFMEData(aData.RoomFace);
                if (null != updatedData.RoomFace)
                {
                    updatedData.PointDataList = FMEDataUtil.ConvertToPointDataList(updatedData.RoomFace, aData.PointValues);

                    IList <UV>           uvPoints = new List <UV>();
                    IList <ValueAtPoint> valList  = new List <ValueAtPoint>();

                    progressBar.Value   = 0;
                    progressBar.Minimum = 0;
                    progressBar.Maximum = updatedData.PointDataList.Count;
                    UpdateProgressDelegate updateProgressDelegate = new UpdateProgressDelegate(progressBar.SetValue);

                    int    visibleCount  = 0;
                    double progressValue = 0;
                    foreach (PointData ptData in updatedData.PointDataList)
                    {
                        if (AbortFlag.GetAbortFlag())
                        {
                            return(updatedData);
                        }
                        Dispatcher.CurrentDispatcher.Invoke(updateProgressDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, progressValue });

                        if (null != ptData.UVPoint && null != ptData.ValueAtPoint)
                        {
                            uvPoints.Add(ptData.UVPoint);
                            valList.Add(ptData.ValueAtPoint);
                            if (ptData.PointValue > 0)
                            {
                                visibleCount++;
                            }
                        }
                        progressValue++;
                    }

                    double ratio = (double)visibleCount / (double)uvPoints.Count;
                    updatedData.VisiblityRatio = ratio;
                    updatedData.AreaWithViews  = rd.RoomArea * ratio;
                    updatedData.SetResultParameterValue(LEEDParameters.LEED_AreaWithViews.ToString(), rd.AreaWithViews);

                    //visualize
                    Transform transform = Transform.CreateTranslation(new XYZ(0, 0, offsetHeight));
                    int       index     = m_sfm.AddSpatialFieldPrimitive(updatedData.RoomFace, transform);

                    FieldDomainPointsByUV domainPoints = new FieldDomainPointsByUV(uvPoints);
                    FieldValues           values       = new FieldValues(valList);

                    m_sfm.UpdateSpatialFieldPrimitive(index, domainPoints, values, resultIndex);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to find visibility.\n" + ex.Message, "Find Visibility", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(updatedData);
        }
Example #55
0
 public static Coroutine SwitchGame <T>(Action <T> setup, UpdateProgressDelegate progress = null) where T : SceneManager
 {
     return(null);
 }
Example #56
0
 protected virtual IEnumerator OnInitCoroutine(UpdateProgressDelegate updateProgressHandler, int currentStep, int totalStep)
 {
     OnInit();
     yield return(null);
 }
Example #57
0
 /// <summary>This method will transition a scene manager from on to the other, or load the first scene manager upon load.</summary>
 public static Coroutine Transition <T>(Action <T> setup, UpdateProgressDelegate progress = null) where T : SceneManager
 {
     return(Transition(Instance.SceneManagers.OfType <T>().First()));
 }
Example #58
0
 public abstract IEnumerator InitCoroutine(UpdateProgressDelegate updateProgressHandler, int current, int total);
Example #59
0
        public DemoForm()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;

            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox     = false;
            this.StartPosition   = FormStartPosition.CenterScreen;

            int h = Screen.PrimaryScreen.WorkingArea.Height;
            int w = Screen.PrimaryScreen.WorkingArea.Width;

            this.Height      = h;
            this.Width       = w;
            pbPreview.Width  = panel1.Width;
            pbPreview.Height = panel1.Height;
            panel3.Height    = h;
            panel3.Width     = w - (panel1.Width + panel2.Width);
            pbPreview.Height = h;


            //  LoadDynamicInput();

            pbPreview.MouseUp                    += OnMouseUp;
            btnLoad.Click                        += btnLoad_Click;
            btnRecognizeSelected.Click           += btnRecognizeSelected_Click;
            btnRecognize.Click                   += btnRecognize_Click;
            btnSave.Click                        += btnSave_Click;
            btnExtract.Click                     += ExtractData;
            btnRemoveRegion.Click                += RemoveRegion;
            btnChooseFile.Click                  += btnChooseFile_Click;
            btnTemplate.Click                    += btnTemplate_Click;
            lstLoadedImages.SelectedIndexChanged += lstLoadedImages_SelectedIndexChanged;

            btnExtract.Enabled = false;
            button1.Hide();
            // btnRecognize.Enabled = false;
            //btnSave.Enabled = false;
            //cbOutputFormats.Enabled = false;

            btnSave.Hide();
            btnRecognize.Hide();
            cbOutputFormats.Hide();
            lblOutputFormat.Hide();
            btnCancel.Hide();
            btnRecognizeSelected.Hide();
            m_bCancelRequested            = false;
            m_bActiveRecognition          = false;
            m_UpdateProgress              = new UpdateProgressDelegate(UpdateProgressSafe);
            cbOutputFormats.SelectedIndex = 2;
            m_nSelectedPageIndex          = -1;


            #region "Init the OCR SDK"
            FileInfo exeFileInfo = new FileInfo(Application.ExecutablePath);
            m_strModulePath = exeFileInfo.DirectoryName;
            string  strRedistPath = System.IO.Path.Combine(this.m_strModulePath, SmartOcrSdkExports.LIB_PATH);// m_strModulePath + "\\";
            OcrData m_OCR         = new OcrData();
            m_OCR.OCR_Init(m_Username, m_Key, strRedistPath);
            #endregion
        }
Example #60
0
        private void UpdateProgress(int Pourc)
        {
            // Lock this block of code to one thread at a time because of multiple
            // threads accessing it and updating control.
            lock (this)
            {
                // Check to see if the thread that is trying to access this code
                // is the GUI thread or another thread.
                if (Progress.ProgressBar.InvokeRequired)
                {
                    // The thread that entered this code in not the thread that create
                    // the control. Create a deleagte and then execute this procedure
                    // from the GUI thread.
                    UpdateProgressDelegate del = new UpdateProgressDelegate(UpdateProgress);
                    Progress.ProgressBar.BeginInvoke(del, Pourc);
                } else
                {
                    // The thread in this section of code is the GUI thread
                    Progress.Value = Pourc;

                }
            }
        }