Exemple #1
0
        static void Main()
        {
            CreateRes();

            //读入主题包
            byte[] theme = File.ReadAllBytes(".\\Default.ext");

            theApp = new ExApp(theme);
            skin   = new ExSkin(null, null, "你好世界", 0, 0, 600, 400,
                                EWS_BUTTON_CLOSE | EWS_BUTTON_MIN | EWS_CENTERWINDOW | EWS_HASICON |
                                EWS_TITLE | EWS_MOVEABLE | EWS_MAINWINDOW, 0, 0, 0, WndProc
                                );

            if (skin.Validate)
            {
                TestCustomCtrl.RegisterControl();
                //设置背景色
                skin.SetLong(EWL_CRBKG, Color.Blue.ToArgb());

                //ExBaseCtrl ctrl1 = new ExBaseCtrl(skin, "Button", "你好", 50, 50, 200, 35);
                ExButton btn1 = new ExButton(skin, "你好", 50, 50, 150, 40);

                byte[]   img  = File.ReadAllBytes(".\\Res\\bkg.png");
                ExStatic img1 = new ExStatic(skin, img, 50, 110, 300, 200);
                img1.SetBackgroundPlayState(true, false, false);

                ExEdit edit1 = new ExEdit(img1, "测试", 25, 25, 100, 30);

                TestCustomCtrl custom = new TestCustomCtrl(skin, "abc", 360, 110, 50, 50);


                //挂接事件
                btn1.HandleEvent(NM_CLICK,
                                 //lambda delegate
                                 (IntPtr hObj, int nID, int nCode, int wParam, int lParam) =>
                {
                    ExMessageBox.Show(new ExControl(hObj), "单击按钮" + skin.Text, btn1.ClassName, MB_ICONINFORMATION, 0);

                    btn1.Text = "测试";

                    return(false);
                }
                                 );

                //显示
                skin.Visible = true;

                //运行程序
                theApp.Run();
            }
        }
Exemple #2
0
        public async Task GeocodeMainOperationFlow()
        {
            //Validation of Excel stuff Fiirst! - Dont waste calls if API needlessly
            await GeoCodeOperationValidation();

            if (XlValidated)
            {
                if (tbxAPIkey.Text == String.Empty)
                {
                    MessageBox.Show("Key looks Empty, please revise?");
                    XLBook.Close(SaveChanges: false);
                    ExApp.Quit();
                    return;
                }
                else
                {
                    if (tbxAPIkey.Text.Length < 30)
                    {
                        MessageBox.Show("That APi key doesn't look right?");
                        XLBook.Close(SaveChanges: false);
                        ExApp.Quit();
                        return;
                    }
                    else
                    {
                        APIKey = tbxAPIkey.Text;

                        //Loop through each row
                        for (int i = 2; i < XLUsedRange.Rows.Count + 1; i++)
                        {
                            //Collect the Cells we want to Read/Write from
                            Range subRegionCell = (Range)XLUsedRange.Cells[i, subRegionCol];
                            Range countryCell   = (Range)XLUsedRange.Cells[i, CountryCol];
                            Range latCell       = (Range)XLUsedRange.Cells[i, LatCol];
                            Range longCell      = (Range)XLUsedRange.Cells[i, LongCol];


                            string subRegionVal = subRegionCell.Value;
                            string countryVal   = countryCell.Value;

                            string concat = subRegionVal + "," + countryVal;

                            var Reqest = new MapRequest();

                            Reqest.location   = concat;
                            Reqest.maxResults = 1;

                            var json     = JsonConvert.SerializeObject(Reqest);
                            var data     = new StringContent(json, Encoding.UTF8, "application/json");
                            var url      = $"http://open.mapquestapi.com/geocoding/v1/address?key=" + APIKey;
                            var response = await Client.PostAsync(url, data);

                            var result = response.Content.ReadAsStringAsync().Result;

                            //Root is a base class in MapsResponse.Cs, its the anticipated response from MapsQuest GeoCoding Api
                            var receivedModel = JsonConvert.DeserializeObject <Root>(result);

                            try
                            {
                                ExApp.ScreenUpdating = true;
                                ExApp.Visible        = true;

                                double lat = receivedModel.results[0].locations[0].latLng.lat;
                                double lng = receivedModel.results[0].locations[0].latLng.lng;

                                latCell.Value  = lat;
                                longCell.Value = lng;
                            }
                            catch (Exception ex)
                            {
                                //if it fails close stuff down on prompt.
                                MessageBox.Show("Problem detected at response");
                                MessageBox.Show(ex.Message);
                                var quit = MessageBox.Show("Do you want to Close Excel without saving Changes?", "Quit Excel?", MessageBoxButtons.YesNo);

                                if (quit == DialogResult.Yes)
                                {
                                    ExApp.DisplayAlerts = false;
                                    XLBook.Close(SaveChanges: false);
                                    ExApp.Quit();
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }