private void RenderForOrthographicCamera_(
            RenderForOrthographicCameraTickEvent evt)
        {
            var g = evt.Graphics;

            this.RenderLcd_(g);

            g.Primitives.VertexColor(Color.White);

            var registers   = this.mmu_.Registers;
            var memoryMap   = this.mmu_.MemoryMap;
            var ioAddresses = memoryMap.IoAddresses;

            var lX = 202;
            var bY = 145;

            var t = g.Text;
            var i = 0;

            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   "pc: " + ByteFormatter.ToHex16(registers.Pc.Value));

            i++;
            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   "af: " + ByteFormatter.ToHex16(registers.Af.Value));
            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   "bc: " + ByteFormatter.ToHex16(registers.Bc.Value));
            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   "de: " + ByteFormatter.ToHex16(registers.De.Value));
            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   "hl: " + ByteFormatter.ToHex16(registers.Hl.Value));
            i++;

            lX = 320;
            i  = 0;

            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   "ppu: " + ByteFormatter.ToHex8((byte)this.cpu_.PpuMode));
            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   "ly: " +
                   ByteFormatter.ToHex8(this.mmu_.MemoryMap.IoAddresses.Ly.Value));
            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   "dma: " +
                   ByteFormatter.ToHex16(this.mmu_.MemoryMap.IoAddresses
                                         .LastDmaAddress));
            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   ByteFormatter.ToHex8(ioAddresses.Lcdc.Value));
            t.Draw(lX,
                   20 * i++,
                   16,
                   16,
                   ByteFormatter.ToHex8(this.cpu_.ScanlineLcdc));

            var oam = memoryMap.Oam;

            for (i = 0; i < 40; i++)
            {
                var oamAddress = (ushort)(i * 4);
                var y          = (byte)(oam[oamAddress] - 16);
                var x          = (byte)(oam[(ushort)(oamAddress + 1)] - 8);

                var nPerRow = 7;
                var c       = i % nPerRow;
                var r       = (i - c) / nPerRow;

                t.Draw(c * 90,
                       bY + r * 20,
                       16,
                       16,
                       "(" +
                       ByteFormatter.ToHex8(x) +
                       ", " +
                       ByteFormatter.ToHex8(y) +
                       ")");
            }
        }
 private void UpdateControls()
 {
     lblMinSize.Text = ByteFormatter.ToString((int)numMinSegSize.Value);
 }
Exemple #3
0
        public void UpdateList(bool all = true)
        {
            for (int i = 0; i < lvwDownloads.Items.Count; i++)
            {
                ListViewItem item = lvwDownloads.Items[i];
                if (item == null)
                {
                    return;
                }
                //Downloader d = mapItemToDownload[item] as Downloader;
                Downloader d = DownloadManager.Instance.GetOrderedDownloader(item.Index);
                if (d == null)
                {
                    return;
                }

                DownloaderState state;

                if (item.Tag == null)
                {
                    state = DownloaderState.Working;
                }
                else
                {
                    state = (DownloaderState)item.Tag;
                }

                if (all || state != d.State || state == DownloaderState.Working || state == DownloaderState.WaitingForReconnect)
                {
                    item.Text = (d.OrderedIndex + 1).ToString();
                    int indexColumnSize = 3;
                    int indexColumn     = indexColumnSize;
                    item.SubItems[indexColumn++].Text = ByteFormatter.ToString(d.FileSize);
                    item.SubItems[indexColumn++].Text = ByteFormatter.ToString(d.Transfered);
                    item.SubItems[indexColumn++].Text = String.Format("{0:0.##}%", d.Progress);
                    item.SubItems[indexColumn++].Text = TimeSpanFormatter.ToString(d.Left);
                    item.SubItems[indexColumn++].Text = String.Format("{0:0.##}", d.Rate / 1024.0);
                    indexColumn++; // column Added
                    if (d.LastError != null)
                    {
                        item.SubItems[indexColumn].Text = d.State.ToString() + ", " + d.LastError.Message;
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(d.StatusMessage))
                        {
                            item.SubItems[indexColumn].Text = d.State.ToString();
                        }
                        else
                        {
                            item.SubItems[indexColumn].Text = d.State.ToString() + ", " + d.StatusMessage;
                        }
                    }
                    indexColumn++; // column State

                    item.SubItems[indexColumn++].Text = GetResumeStr(d);
                    item.SubItems[indexColumn++].Text = d.ResourceLocation.URL;
                    item.Tag = d.State;
                }
            }

            UpdateSegments();
        }
Exemple #4
0
        /// <summary>Write the data to an output stream.</summary>
        public override void Write(ArrayDataIO str)
        {
            // If buffer is still around we can just reuse it,
            // since nothing we've done has invalidated it.
            if (buffer == null)
            {
                if (data == null)
                {
                    throw new FitsException("Attempt to write undefined ASCII Table");
                }

                buffer = new byte[nRows * rowLen];
                bp     = new ByteParser(buffer);
                for (int i = 0; i < buffer.Length; i += 1)
                {
                    buffer[i] = (byte)' ';                    //SupportClass.Identity(' ');
                }

                ByteFormatter bf = new ByteFormatter();
                bf.TruncationThrow    = false;
                bf.TruncateOnOverflow = true;

                for (int i = 0; i < nRows; i += 1)
                {
                    for (int j = 0; j < nFields; j += 1)
                    {
                        int offset = i * rowLen + offsets[j];
                        int len    = lengths[j];

                        try
                        {
                            if (isNull_Renamed_Field != null && isNull_Renamed_Field[i * nFields + j])
                            {
                                if (nulls[j] == null)
                                {
                                    throw new FitsException("No null value set when needed");
                                }
                                bf.format(nulls[j], buffer, offset, len);
                            }
                            else
                            {
                                if (types[j] == typeof(String))
                                {
                                    String[] s = (String[])data[j];
                                    bf.format(s[i], buffer, offset, len);
                                }
                                else if (types[j] == typeof(int))
                                {
                                    int[] ia = (int[])data[j];
                                    bf.format(ia[i], buffer, offset, len);
                                }
                                else if (types[j] == typeof(float))
                                {
                                    float[] fa = (float[])data[j];
                                    bf.format(fa[i], buffer, offset, len);
                                }
                                else if (types[j] == typeof(double))
                                {
                                    double[] da = (double[])data[j];
                                    bf.format(da[i], buffer, offset, len);
                                }
                                else if (types[j] == typeof(long))
                                {
                                    long[] la = (long[])data[j];
                                    bf.format(la[i], buffer, offset, len);
                                }
                            }
                        }
                        catch (TruncationException)
                        {
                            Console.Error.WriteLine("Ignoring truncation error:" + i + "," + j);
                        }
                    }
                }
            }

            // Now write the buffer.
            try
            {
                str.Write(buffer);
                byte[] padding = new byte[FitsUtil.Padding(buffer.Length)];
                for (int i = 0; i < padding.Length; i += 1)
                {
                    padding[i] = (byte)SupportClass.Identity(' ');
                }
                if (buffer.Length > 0)
                {
                    str.Write(padding);
                }
                str.Flush();
            }
            catch (IOException)
            {
                throw new FitsException("Error writing ASCII Table data");
            }
        }
Exemple #5
0
        public void UpdateList()
        {
            lvwDownloads.BeginUpdate();

            for (int i = 0; i < lvwDownloads.Items.Count; i++)
            {
                ListViewItem item = lvwDownloads.Items[i];
                if (item == null)
                {
                    return;
                }
                Downloader d = mapItemToDownload[item] as Downloader;
                if (d == null)
                {
                    return;
                }

                DownloaderState state;

                if (item.Tag == null)
                {
                    state = DownloaderState.Working;
                }
                else
                {
                    state = (DownloaderState)item.Tag;
                }

                if (state != d.State ||
                    state == DownloaderState.Working ||
                    state == DownloaderState.WaitingForReconnect)
                {
                    item.SubItems[0].Text = d.FileName;
                    item.SubItems[1].Text = ByteFormatter.ToString(d.FileSize);
                    item.SubItems[2].Text = ByteFormatter.ToString(d.Transfered);
                    item.SubItems[3].Text = String.Format("{0:0.##}%", d.Progress);
                    item.SubItems[4].Text = TimeSpanFormatter.ToString(d.Left);
                    item.SubItems[5].Text = String.Format("{0:0.##}", d.Rate / 1024.0);

                    if (d.LastError != null)
                    {
                        item.SubItems[7].Text = d.ScheduleState.ToString() + ", " + d.LastError.Message;
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(d.StatusMessage))
                        {
                            item.SubItems[7].Text = d.ScheduleState.ToString();
                        }
                        else
                        {
                            item.SubItems[7].Text = d.ScheduleState.ToString() + ", " + d.StatusMessage;
                        }
                    }

                    item.SubItems[8].Text = GetResumeStr(d);
                    item.SubItems[9].Text = d.ResourceLocation.URL;
                    item.Tag = d.State;
                }
            }

            UpdateSegments();
            lvwDownloads.EndUpdate();
        }