private void RebuildCrmEntries()
        {
            try
            {
                var entries = _wcfCrmClient.GetAllCrmEntries();
                _internalCrmEntries = new ObservableCollectionEx <CrmEntry>();
                _internalCrmEntries.AddItems(entries);

                CrmEntries        = CollectionViewSource.GetDefaultView(_internalCrmEntries);
                CrmEntries.Filter = FilterItem;

                if (_internalCrmEntries.Count > 0)
                {
                    SelectedCrmEntry = _internalCrmEntries.First();
                }

                RaisePropertyChanged("CrmEntries");
            }
            catch (Exception ex)
            {
                Messenger.Default.Send(new NotificationMessage(ex.Message, ShowWcfWarningWindow));
            }
        }
        private void ShowAmoebaInfomation()
        {
            try
            {
                for (; ;)
                {
                    var information = _amoebaManager.Information;
                    var dic         = new Dictionary <string, string>();

#if DEBUG
                    dic["InformationControl_BufferManagerSize"] = NetworkConverter.ToSizeString(_bufferManager.Size);
#endif

                    dic["InformationControl_SentByteCount"]     = NetworkConverter.ToSizeString(_amoebaManager.SentByteCount);
                    dic["InformationControl_ReceivedByteCount"] = NetworkConverter.ToSizeString(_amoebaManager.ReceivedByteCount);

                    dic["InformationControl_CreateConnectionCount"]  = ((long)information["CreateConnectionCount"]).ToString();
                    dic["InformationControl_AcceptConnectionCount"]  = ((long)information["AcceptConnectionCount"]).ToString();
                    dic["InformationControl_BlockedConnectionCount"] = ((long)information["BlockedConnectionCount"]).ToString();

                    dic["InformationControl_SurroundingNodeCount"] = ((int)information["SurroundingNodeCount"]).ToString();
                    dic["InformationControl_RelayBlockCount"]      = ((long)information["RelayBlockCount"]).ToString();

                    dic["InformationControl_LockSpace"]  = NetworkConverter.ToSizeString(((long)information["LockSpace"])).ToString();
                    dic["InformationControl_FreeSpace"]  = NetworkConverter.ToSizeString(((long)information["FreeSpace"])).ToString();
                    dic["InformationControl_UsingSpace"] = NetworkConverter.ToSizeString(((long)information["UsingSpace"])).ToString();

                    dic["InformationControl_NodeCount"]     = ((int)information["OtherNodeCount"]).ToString();
                    dic["InformationControl_SeedCount"]     = ((int)information["SeedCount"]).ToString();
                    dic["InformationControl_BlockCount"]    = ((int)information["BlockCount"]).ToString();
                    dic["InformationControl_DownloadCount"] = ((int)information["DownloadingCount"]).ToString();
                    dic["InformationControl_UploadCount"]   = ((int)information["UploadingCount"]).ToString();
                    dic["InformationControl_ShareCount"]    = ((int)information["ShareCount"]).ToString();

                    dic["InformationControl_PushNodeCount"]         = ((long)information["PushNodeCount"]).ToString();
                    dic["InformationControl_PushBlockLinkCount"]    = ((long)information["PushBlockLinkCount"]).ToString();
                    dic["InformationControl_PushBlockRequestCount"] = ((long)information["PushBlockRequestCount"]).ToString();
                    dic["InformationControl_PushBlockCount"]        = ((long)information["PushBlockCount"]).ToString();
                    dic["InformationControl_PushSeedRequestCount"]  = ((long)information["PushSeedRequestCount"]).ToString();
                    dic["InformationControl_PushSeedCount"]         = ((long)information["PushSeedCount"]).ToString();

                    dic["InformationControl_PullNodeCount"]         = ((long)information["PullNodeCount"]).ToString();
                    dic["InformationControl_PullBlockLinkCount"]    = ((long)information["PullBlockLinkCount"]).ToString();
                    dic["InformationControl_PullBlockRequestCount"] = ((long)information["PullBlockRequestCount"]).ToString();
                    dic["InformationControl_PullBlockCount"]        = ((long)information["PullBlockCount"]).ToString();
                    dic["InformationControl_PullSeedRequestCount"]  = ((long)information["PullSeedRequestCount"]).ToString();
                    dic["InformationControl_PullSeedCount"]         = ((long)information["PullSeedCount"]).ToString();

                    this.Dispatcher.Invoke(DispatcherPriority.ContextIdle, new Action(() =>
                    {
                        foreach (var item in dic)
                        {
                            _infomationListViewItemCollection.First(n => n.Id == item.Key).Value = item.Value;
                        }
                    }));

                    Thread.Sleep(1000 * 10);
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #3
0
        private unsafe void BackgroundBlockRenderer()
        {
#if DEBUG
            Debug.WriteLine("BackgroundBlockRenderer: Started");
#endif
            if (_graphicBuffer == null)
            {
#if DEBUG
                Debug.WriteLine("BackgroundBlockRenderer: Aborted (graphic = null)");
#endif
                return;
            }
            IsRendering = true;
            try
            {
                while (true)
                {
                    TilesetEntryModel dirtyBlock = null;
                    try
                    {
                        dirtyBlock = _blocks.First(p => p.Dirty);
                    }
                    catch (InvalidOperationException)
                    {
                        break;
                    }
                    RenderProgress = 100 - (int)((100f / (float)_blocks.Count) * (float)_blocks.Count(p => p.Dirty));

                    //targets for tile copies
                    WriteableBitmap newBlockImage        = new WriteableBitmap(16, 16, 96, 96, PixelFormats.Bgra32, null);
                    WriteableBitmap newBlockImageOverlay = new WriteableBitmap(16, 16, 96, 96, PixelFormats.Bgra32, null);
                    newBlockImage.Lock();
                    byte *blockData = (byte *)newBlockImage.BackBuffer;
                    newBlockImageOverlay.Lock();
                    byte *blockDataOverlay = (byte *)newBlockImageOverlay.BackBuffer;

                    //copy tiles
                    for (int k = 0; k < 5; k += 4)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            //TODO hflip and vflip
                            Int32Rect       pos            = new Int32Rect((i == 1 || i == 3) ? 8 : 0, (i == 2 || i == 3) ? 8 : 0, 8, 8);
                            WriteableBitmap tile           = GetTile(dirtyBlock.Tilemap[i + k].TileID);
                            IList <Color>   currentPalette = _palettes[dirtyBlock.Tilemap[i + k].PalIndex].Value.Colors.Select(p => p.Color).ToList();
                            currentPalette[0] = Color.FromArgb(0, 0, 0, 0); //color 0 = transparent
                            ChangePalette(ref tile, new BitmapPalette(currentPalette));
                            WriteableBitmap fbitmap = new WriteableBitmap(new FormatConvertedBitmap(tile, PixelFormats.Bgra32, null, 0));
                            fbitmap.Lock();
                            byte *fbData = (byte *)fbitmap.BackBuffer;
                            ((k == 0) ? newBlockImage : newBlockImageOverlay).WritePixels(pos, (IntPtr)fbData, 256, 32);
                            fbitmap.Unlock();
                        }
                    }

                    newBlockImageOverlay.AddDirtyRect(new Int32Rect(0, 0, 16, 16));
                    newBlockImageOverlay.Unlock();
                    newBlockImage.AddDirtyRect(new Int32Rect(0, 0, 16, 16));
                    newBlockImage.Unlock();

                    //merge targets
                    AddTransparentBlock(newBlockImage, newBlockImageOverlay);
                    newBlockImage.Freeze();

                    Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
                    {
                        dirtyBlock.Graphic = newBlockImage;
                        dirtyBlock.Dirty   = false;
                    }));
                }
            }
            catch (ThreadAbortException)
            {
#if DEBUG
                Debug.WriteLine("BackgroundBlockRenderer: Aborted");
#endif
            }
#if DEBUG
            Debug.WriteLine("BackgroundBlockRenderer: Ended");
#endif
            IsRendering = false;
        }