/// <summary>
            /// Return the equivalent enum value based on a string
            /// </summary>
            /// <param name="value">String to be evaluated</param>
            /// <returns>Category enum value</returns>
            /// <remarks></remarks>
            public static Category fromString(String value)
            {
                String s = value.ToLower();

                if (s == DATAFILE.ToString().ToLower())
                {
                    return(DATAFILE);
                }
                else if (s == GRAPHICSPLOT.ToString().ToLower())
                {
                    return(GRAPHICSPLOT);
                }
                else if (s == PDFFILE.ToString().ToLower())
                {
                    return(PDFFILE);
                }
                else if (s == RBINARY.ToString().ToLower())
                {
                    return(RBINARY);
                }
                else if (s == RSCRIPT.ToString().ToLower())
                {
                    return(RSCRIPT);
                }
                else if (s == SHELLSCRIPT.ToString().ToLower())
                {
                    return(SHELLSCRIPT);
                }
                else if (s == TEXTFILE.ToString().ToLower())
                {
                    return(TEXTFILE);
                }
                else
                {
                    return(OTHER);
                }
            }
Exemple #2
0
        static int Main(string[] argv)
        {
            //        /* the submenu */
            MENUS submenu = new MENUS(5);

            submenu[0] = new MENU("Submenu", NULL, NULL, D_DISABLED, NULL);
            submenu[1] = new MENU("", NULL, NULL, 0, NULL);
            submenu[2] = new MENU("Checked", check_callback, NULL, D_SELECTED, NULL);
            submenu[3] = new MENU("Disabled", NULL, NULL, D_DISABLED, NULL);
            submenu[4] = new MENU(null, NULL, NULL, 0, NULL);

            /* the first menu in the menubar */
            MENUS menu1 = new MENUS(4);

            menu1[0] = new MENU("Test &1 \t1", menu_callback, NULL, 0, NULL);
            menu1[1] = new MENU("Test &2 \t2", menu_callback, NULL, 0, NULL);
            menu1[2] = new MENU("&Quit \tq/Esc", Marshal.GetFunctionPointerForDelegate(d_quit), NULL, 0, NULL);
            menu1[3] = new MENU(null, NULL, NULL, 0, NULL);

            /* the second menu in the menubar */
            MENUS menu2 = new MENUS(3);

            menu2[0] = new MENU("&Test", menu_callback, NULL, 0, NULL);
            menu2[1] = new MENU("&Submenu", NULL, submenu, 0, NULL);
            menu2[2] = new MENU(null, NULL, NULL, 0, NULL);

            /* the help menu */
            MENUS helpmenu = new MENUS(2);

            helpmenu[0] = new MENU("&About \tF1", Marshal.GetFunctionPointerForDelegate(d_about), NULL, 0, NULL);
            helpmenu[1] = new MENU(null, NULL, NULL, 0, NULL);

            /* the main menu-bar */
            MENUS the_menu = new MENUS(4);

            the_menu[0] = new MENU("&First", NULL, menu1, 0, NULL);
            the_menu[1] = new MENU("&Second", NULL, menu2, 0, NULL);
            the_menu[2] = new MENU("&Help", NULL, helpmenu, 0, NULL);
            the_menu[3] = new MENU(null, NULL, NULL, 0, NULL);

            the_dialog[0] = new DIALOG(d_clear_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);

            /* these just display text, either left aligned, centered, or right aligned */
            the_dialog[1] = new DIALOG("d_text_proc", 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_text_proc"), NULL, NULL);
            the_dialog[2] = new DIALOG("d_ctext_proc", 318, 20, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_ctext_proc"), NULL, NULL);
            the_dialog[3] = new DIALOG("d_rtext_proc", 636, 20, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_rtext_proc"), NULL, NULL);

            ///* lots of descriptive text elements */
            the_dialog[4]  = new DIALOG("d_text_proc", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_menu_proc->"), NULL, NULL);
            the_dialog[5]  = new DIALOG("d_text_proc", 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_button_proc->"), NULL, NULL);
            the_dialog[6]  = new DIALOG("d_text_proc", 0, 70, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_check_proc->"), NULL, NULL);
            the_dialog[7]  = new DIALOG("d_text_proc", 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_radio_proc->"), NULL, NULL);
            the_dialog[8]  = new DIALOG("d_text_proc", 0, 130, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_edit_proc->"), NULL, NULL);
            the_dialog[9]  = new DIALOG("d_text_proc", 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_list_proc->"), NULL, NULL);
            the_dialog[10] = new DIALOG("d_text_proc", 0, 200, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_text_list_proc->"), NULL, NULL);
            the_dialog[11] = new DIALOG("d_text_proc", 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_textbox_proc->"), NULL, NULL);
            the_dialog[12] = new DIALOG("d_text_proc", 0, 300, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_slider_proc->"), NULL, NULL);
            the_dialog[13] = new DIALOG("d_text_proc", 0, 330, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_box_proc->"), NULL, NULL);
            the_dialog[14] = new DIALOG("d_text_proc", 0, 360, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_shadow_box_proc->"), NULL, NULL);
            the_dialog[15] = new DIALOG("d_text_proc", 0, 390, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_keyboard_proc. Press F1 to see me trigger the about box."), NULL, NULL);
            the_dialog[16] = new DIALOG("d_text_proc", 0, 410, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_clear_proc. I draw the white background."), NULL, NULL);
            the_dialog[17] = new DIALOG("d_text_proc", 0, 430, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_yield_proc. I make us play nice with the OS scheduler."), NULL, NULL);
            the_dialog[18] = new DIALOG("d_rtext_proc", 636, 40, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("<-d_bitmap_proc"), NULL, NULL);
            the_dialog[19] = new DIALOG("d_rtext_proc", 636, 80, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("<-d_icon_proc"), NULL, NULL);

            ///* a menu bar - note how it auto-calculates its dimension if they are not given */
            the_dialog[20] = new DIALOG("d_menu_proc", 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, the_menu, NULL, NULL);


            ///* some more GUI elements, all of which require you to specify their dimensions */
            the_dialog[21] = new DIALOG("d_button_proc", 160, 40, 160, 20, 0, 0, 't', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Toggle Me!"), NULL, NULL);
            the_dialog[22] = new DIALOG("d_check_proc", 160, 70, 160, 20, 0, 0, 'c', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Check Me!"), NULL, NULL);
            the_dialog[23] = new DIALOG("d_radio_proc", 160, 100, 160, 19, 0, 0, 's', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Select Me!"), NULL, NULL);
            the_dialog[24] = new DIALOG("d_radio_proc", 320, 100, 160, 19, 0, 0, 'o', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Or Me!"), NULL, NULL);
            the_dialog[25] = new DIALOG("d_edit_proc", 160, 130, 160, 8, 0, 0, 0, 0, LEN, 0, Marshal.StringToCoTaskMemAnsi(the_string), NULL, NULL);
            the_dialog[26] = new DIALOG("d_list_proc", 160, 150, 160, 44, 0, 0, 0, 0, 0, 0, Marshal.GetFunctionPointerForDelegate(d_listbox_getter), sel, NULL);
            the_dialog[27] = new DIALOG("d_text_list_proc", 160, 200, 160, 44, 0, 0, 0, 0, 0, 0, Marshal.GetFunctionPointerForDelegate(d_listbox_getter), NULL, NULL);
            the_dialog[28] = new DIALOG("d_textbox_proc", 160, 250, 160, 48, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi(the_text), NULL, NULL);
            the_dialog[29] = new DIALOG("d_slider_proc", 160, 300, 160, 12, 0, 0, 0, 0, 100, 0, NULL, NULL, NULL);
            the_dialog[30] = new DIALOG("d_box_proc", 160, 330, 160, 20, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);
            the_dialog[31] = new DIALOG("d_shadow_box_proc", 160, 360, 160, 20, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);

            ///* note how we don't fill in the dp field yet, because we first need to load the bitmap */
            the_dialog[32] = new DIALOG("d_bitmap_proc", 480, 40, 30, 30, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);
            the_dialog[33] = new DIALOG("d_icon_proc", 480, 80, 30, 30, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);

            ///* the quit and info buttons use our customized dialog procedure, using dp3 as callback */
            the_dialog[34] = new DIALOG(d_my_button_proc, 0, 450, 160, 20, 0, 0, 'q', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("&Quit"), NULL, Marshal.GetFunctionPointerForDelegate(d_quit));
            the_dialog[35] = new DIALOG(d_my_button_proc, 400, 150, 160, 20, 0, 0, 'i', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("&Info"), NULL, Marshal.GetFunctionPointerForDelegate(d_info1));
            the_dialog[36] = new DIALOG(d_my_button_proc, 400, 200, 160, 20, 0, 0, 'n', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("I&nfo"), NULL, Marshal.GetFunctionPointerForDelegate(d_info2));
            the_dialog[37] = new DIALOG(d_my_button_proc, 400, 300, 160, 20, 0, 0, 'f', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("In&fo"), NULL, Marshal.GetFunctionPointerForDelegate(d_info3));

            ///* the next two elements don't draw anything */
            the_dialog[38] = new DIALOG("d_keyboard_proc", 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, Marshal.GetFunctionPointerForDelegate(d_about), NULL, NULL);
            the_dialog[39] = new DIALOG("d_yield_proc", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);
            the_dialog[the_dialog.Length - 1] = new DIALOG(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);

            //char buf[256];
            byte[] buf = new byte[256];
            int    i;

            /* initialise everything */
            if (allegro_init() != 0)
            {
                return(1);
            }
            install_keyboard();
            install_mouse();
            install_timer();

            if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0)
            {
                if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0)
                {
                    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
                    allegro_message(string.Format("Unable to set any graphic mode\n{0}\n", allegro_error));
                    return(1);
                }
            }

            /* load the datafile */
            //replace_filename(buf, argv[0], "example.dat", sizeof(buf));
            //datafile = load_datafile(buf);
            replace_filename(buf, "./", "example.dat", buf.Length);
            datafile = load_datafile(Encoding.ASCII.GetString(buf));
            if (!datafile)
            {
                set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
                allegro_message(string.Format("Error loading {0}!\n", buf));
                return(1);
            }

            set_palette(datafile[THE_PALETTE].dat);

            /* set up colors */
            gui_fg_color = makecol(0, 0, 0);
            gui_mg_color = makecol(128, 128, 128);
            gui_bg_color = makecol(200, 240, 200);
            set_dialog_color(the_dialog, gui_fg_color, gui_bg_color);

            /* white color for d_clear_proc and the d_?text_procs */
            the_dialog[0].bg = makecol(255, 255, 255);
            for (i = 4; the_dialog[i].proc != NULL; i++)
            {
                if (the_dialog[i].proc == GetAddress("d_text_proc") ||
                    the_dialog[i].proc == GetAddress("d_ctext_proc") ||
                    the_dialog[i].proc == GetAddress("d_rtext_proc"))
                {
                    the_dialog[i].bg = the_dialog[0].bg;
                }
            }

            /* fill in bitmap pointers */
            the_dialog[BITMAP_OBJECT].dp = datafile[SILLY_BITMAP].dat;
            the_dialog[ICON_OBJECT].dp   = datafile[SILLY_BITMAP].dat;

            /* shift the dialog 2 pixels away from the border */
            position_dialog(the_dialog, 2, 2);

            /* do the dialog */
            do_dialog(the_dialog, -1);

            unload_datafile(datafile);

            return(0);
        }
        static int Main(string[] argv)
        {
            /* (dialog proc)     (x)   (y)   (w)   (h)   (fg)  (bg)  (key) (flags)  (d1) (d2)  (dp)           (dp2) (dp3) */
            the_dialog[0] = new DIALOG("d_clear_proc", 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, NULL, NULL, NULL);
            the_dialog[1] = new DIALOG("d_edit_proc", 12, 82, 256, 48, 255, 0, 0, 0, LEN, 0, Marshal.StringToCoTaskMemAnsi(the_string), NULL, NULL);
            the_dialog[2] = new DIALOG("d_check_proc", 12, 12, 161, 49, 255, 0, 't', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Toggle Me"), NULL, NULL);
            the_dialog[3] = new DIALOG(d_clock_proc, 242, 12, 64, 64, 255, 0, 0, 0, 0, 0, NULL, NULL, NULL);
            the_dialog[4] = new DIALOG(d_change_font_proc, 12, 142, 141, 49, 255, 0, 'f', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("Change &Font"), NULL, NULL);
            the_dialog[5] = new DIALOG("d_button_proc", 162, 142, 141, 49, 255, 0, 0, D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("Exit"), NULL, NULL);
            the_dialog[6] = new DIALOG(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);

            int item;

            //char buf[256];
            byte[] buf = new byte[256];

            if (allegro_init() != 0)
            {
                return(1);
            }
            install_keyboard();
            install_mouse();
            install_timer();

            if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0)
            {
                if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0)
                {
                    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
                    allegro_message(string.Format("Unable to set any graphic mode\n{0}\n", allegro_error));
                    return(1);
                }
            }

            set_palette(desktop_palette);

            /* We set up colors to match screen color depth (in case it changed) */
            //for (item = 0; the_dialog[item].proc; item++) {
            for (item = 0; item < the_dialog.Length - 1; item++)
            {
                the_dialog[item].fg = makecol(0, 0, 0);
                the_dialog[item].bg = makecol(255, 255, 255);
            }

            /* load the datafile */
            //replace_filename(buf, argv[0], "example.dat", sizeof(buf));
            replace_filename(buf, "./", "example.dat", buf.Length);
            //datafile = load_datafile(buf);
            datafile = load_datafile(Encoding.ASCII.GetString(buf));
            if (!datafile)
            {
                set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
                allegro_message(string.Format("Error loading {0}!\n", buf));
                return(1);
            }

            /* store a copy of the default font */
            original_font = font;

            do_dialog(the_dialog, -1);

            unload_datafile(datafile);

            return(0);
        }
Exemple #4
0
        static int Main(string[] argv)
        {
            byte[] datafile_name = new byte[256];
            int    angle = 0;
            int    x, y;
            int    text_y;
            int    color;

            if (allegro_init() != 0)
            {
                return(1);
            }
            install_keyboard();
            install_sound(DIGI_AUTODETECT, MIDI_NONE, null);
            install_timer();
            LOCK_FUNCTION(t_ticker);
            LOCK_VARIABLE(ticks);
            install_int_ex(ticker, BPS_TO_TIMER(30));

            if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0)
            {
                if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0)
                {
                    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
                    allegro_message("Unable to set any graphic mode\n" +
                                    allegro_error);
                    return(1);
                }
            }

            /* loads datafile and sets user palette saved in datafile */
            replace_filename(datafile_name, "./", "running.dat",
                             256);
            running_data = load_datafile(Encoding.ASCII.GetString((datafile_name)));
            if (!running_data)
            {
                set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
                allegro_message("Error loading " + datafile_name + "!\n");
                return(1);
            }

            /* select the palette which was loaded from the datafile */
            set_palette(running_data[PALETTE_001].dat);

            /* create and clear a bitmap for sprite buffering, big
             * enough to hold the diagonal(sqrt(2)) when rotating */
            sprite_buffer = create_bitmap((int)(82 * Math.Sqrt(2) + 2),
                                          (int)(82 * Math.Sqrt(2) + 2));
            clear_bitmap(sprite_buffer);

            x      = (sprite_buffer.w - 82) / 2;
            y      = (sprite_buffer.h - 82) / 2;
            color  = makecol(0, 80, 0);
            text_y = SCREEN_H - 10 - text_height(font);

            frame = ticks;

            /* write current sprite drawing method */
            textout_centre_ex(screen, font, "Press a key for next part...",
                              SCREEN_W / 2, 10, palette_color[1], -1);
            textout_centre_ex(screen, font, "Using draw_sprite",
                              SCREEN_W / 2, text_y, palette_color[15], -1);

            do
            {
                hline(sprite_buffer, 0, y + 82, sprite_buffer.w - 1, color);
                draw_sprite(sprite_buffer, running_data[frame_number].dat, x, y);
                animate();
            } while (!next);

            clear_keybuf();
            rectfill(screen, 0, text_y, SCREEN_W, SCREEN_H, 0);
            textout_centre_ex(screen, font, "Using draw_sprite_h_flip",
                              SCREEN_W / 2, text_y, palette_color[15], -1);

            do
            {
                hline(sprite_buffer, 0, y + 82, sprite_buffer.w - 1, color);
                draw_sprite_h_flip(sprite_buffer, running_data[frame_number].dat, x, y);
                animate();
            } while (!next);

            clear_keybuf();
            rectfill(screen, 0, text_y, SCREEN_W, SCREEN_H, 0);
            textout_centre_ex(screen, font, "Using draw_sprite_v_flip",
                              SCREEN_W / 2, text_y, palette_color[15], -1);

            do
            {
                hline(sprite_buffer, 0, y - 1, sprite_buffer.w - 1, color);
                draw_sprite_v_flip(sprite_buffer, running_data[frame_number].dat, x, y);
                animate();
            } while (!next);

            clear_keybuf();
            rectfill(screen, 0, text_y, SCREEN_W, SCREEN_H, 0);
            textout_centre_ex(screen, font, "Using draw_sprite_vh_flip",
                              SCREEN_W / 2, text_y, palette_color[15], -1);

            do
            {
                hline(sprite_buffer, 0, y - 1, sprite_buffer.w - 1, color);
                draw_sprite_vh_flip(sprite_buffer, running_data[frame_number].dat, x, y);
                animate();
            } while (!next);

            clear_keybuf();
            rectfill(screen, 0, text_y, SCREEN_W, SCREEN_H, 0);
            textout_centre_ex(screen, font, "Now with rotating - pivot_sprite",
                              SCREEN_W / 2, text_y, palette_color[15], -1);

            do
            {
                /* The last argument to pivot_sprite() is a fixed point type,
                 * so I had to use itofix() routine (integer to fixed).
                 */
                circle(sprite_buffer, x + 41, y + 41, 47, color);
                pivot_sprite(sprite_buffer, running_data[frame_number].dat, sprite_buffer.w / 2,
                             sprite_buffer.h / 2, 41, 41, itofix(angle));
                animate();
                angle -= 4;
            } while (!next);

            clear_keybuf();
            rectfill(screen, 0, text_y, SCREEN_W, SCREEN_H, 0);
            textout_centre_ex(screen, font, "Now using pivot_sprite_v_flip",
                              SCREEN_W / 2, text_y, palette_color[15], -1);

            do
            {
                /* The last argument to pivot_sprite_v_flip() is a fixed point type,
                 * so I had to use itofix() routine (integer to fixed).
                 */
                circle(sprite_buffer, x + 41, y + 41, 47, color);
                pivot_sprite_v_flip(sprite_buffer, running_data[frame_number].dat,
                                    sprite_buffer.w / 2, sprite_buffer.h / 2, 41, 41, itofix(angle));
                animate();
                angle += 4;
            } while (!next);

            unload_datafile(running_data);
            destroy_bitmap(sprite_buffer);
            return(0);
        }
Exemple #5
0
        private async Task DownloadDataFileContents(DATAFILE fileType, HttpClient client)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings();
            settings.NullValueHandling = NullValueHandling.Ignore;
            settings.Error = (sender, errorArgs) =>
            {

                logger.Error(errorArgs.ErrorContext.Error.Message);
                logger.Debug("JSON Path: {0}", errorArgs.ErrorContext.Path);
                logger.Debug("Member: {0}", errorArgs.ErrorContext.Member);
                logger.Debug("Current Object: {0}", errorArgs.CurrentObject);

                errorArgs.ErrorContext.Handled = true;
            };

            if (DownloadStarted != null)
                DownloadStarted(this, urlMap[fileType]);

            using (HttpResponseMessage response = await client.GetAsync(urlMap[fileType]))
            {
                string data = await ExctractContent(response);
                switch (fileType)
                {
                    case DATAFILE.Commodity:
                        commodities = JsonConvert.DeserializeObject<List<Commodity>>(data, settings);
                        break;
                    case DATAFILE.Listing:
                        // TODO: Implement listing CSV handling in EDDBDataProvider class.
                        logger.Warn("TODO: Implement listing CSV handling in EDDBDataProvider class.");
                        break;
                    case DATAFILE.Module:
                        modules = JsonConvert.DeserializeObject<List<Module>>(data, settings);
                        break;
                    case DATAFILE.Station:
                        stations = JsonConvert.DeserializeObject<List<Station>>(data, settings);
                        break;
                    case DATAFILE.System:
                        systems = JsonConvert.DeserializeObject<List<StarSystem>>(data, settings);
                        break;
                }
            }

            if (DownloadComplete != null)
                DownloadComplete(this, urlMap[fileType]);

            logger.Info("Completed downloading data for type: {0}", fileType.ToString());            
        }
Exemple #6
0
 private async Task CalculateUrlContentSize(DATAFILE fileType, HttpClient client)
 {
     HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Head, urlMap[fileType]);
     using (HttpResponseMessage response = await client.SendAsync(request))
     {
         logger.Debug(response.Content.Headers);
         if (response.Content.Headers.ContentLength.HasValue)
             downloadSize += response.Content.Headers.ContentLength.Value;
     }
 }