Esempio n. 1
0
        static private void EndEditBitmap(IAsyncResult ar)
        {
            DelegateEditBitmap dlgt = (DelegateEditBitmap)ar.AsyncState;
            // Complete the call.
            Int16  itemP;
            Bitmap bmpCurrent = dlgt.EndInvoke(out Result, out itemP, ar);

            lock (bmp[itemP])
            {
                if (bmpCurrent != null)
                {
                    bmp[itemP] = (Bitmap)bmpCurrent.Clone();
                    bmpCurrent.Dispose();
                }
            }

            Debug.WriteLine("item " + itemP.ToString());

            if (semaforScreenItems.Contains(itemP))
            {
                semaforScreenItems.Remove(itemP);
            }
        }
Esempio n. 2
0
        private void FDataEdit()
        {
            try
            {
                if (im != null)
                {
                    Int16[] semaforScreenItemsP;

                    // Array of items that is displaied (maped) on screen (can be one or 2 elements by coefficient > 4)
                    semaforScreenItems  = new List <Int16>(DetermineScreenItem());
                    semaforScreenItemsP = semaforScreenItems.ToArray();
                    // Items of the screen are processed on the first

                    Result = HRESULT.S_OK;
                    foreach (Int16 item in semaforScreenItems)
                    {
                        Int16 itemP      = item;
                        Int16 itemWidthP = itemWidth;
                        if (bmp[item] != null)
                        {
                            FEditThread        threadEditBitmap   = new FEditThread(item, getModeEditStruct(), (Int16)bmp[item].Width, stSerOb.UseAdjustment, height_frame_bmp);
                            DelegateEditBitmap delegateEditThread = new DelegateEditBitmap(threadEditBitmap.FDataEditThread);
                            AsyncCallback      callbackEditBitmap = new AsyncCallback(EndEditBitmap);
                            IAsyncResult       ar = delegateEditThread.BeginInvoke(out Result, out itemP, callbackEditBitmap, delegateEditThread);
                        }
                        else
                        {
                            semaforScreenItems.Remove(item);
                            if ((Result != HRESULT.S_OK) || (semaforScreenItems.Count == 0))
                            {
                                Mode = MODE.NotActive;
                                return;
                            }
                        }
                    }
                    while ((semaforScreenItems.Count != 0) && (Mode != MODE.Scan) && (Result == HRESULT.S_OK))
                    {
                        //                  Thread.Sleep(1000);
                    }
                    Debug.WriteLine("update ");
                    Invalidate();
                    Update();

                    if (Result != HRESULT.S_OK)
                    {
                        Mode = MODE.NotActive;
                        return;
                    }

                    for (Int16 item = 0; item < bmp.Length; item++)
                    {
                        if (Array.IndexOf(semaforScreenItemsP, item) == -1)
                        {
                            Int16 itemWidthP = itemWidth;
                            if (bmp[item] != null)
                            {
                                FEditThread        threadEditBitmap   = new FEditThread(item, getModeEditStruct(), (Int16)bmp[item].Width, stSerOb.UseAdjustment, height_frame_bmp);
                                DelegateEditBitmap delegateEditThread = new DelegateEditBitmap(threadEditBitmap.FDataEditThread);
                                AsyncCallback      callbackEditBitmap = new AsyncCallback(EndEditBitmap);
                                IAsyncResult       ar = delegateEditThread.BeginInvoke(out Result, out item, callbackEditBitmap, delegateEditThread);
                            }
                            else
                            {
                                semaforScreenItems.Remove(item);
                                if ((Result != HRESULT.S_OK) && (semaforScreenItems.Count == 0))
                                {
                                    Mode = MODE.NotActive;
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
            Mode = MODE.NotActive;
        }