/// <summary> /// возвращает контрол с содержимым инфобокса /// </summary> /// <param name="contentType"></param> /// <returns></returns> static UserControl GetInfoContent(InfoContent contentType) { switch (contentType) { case InfoContent.RoleInfo: return(new RoleInfo()); case InfoContent.VersionHistory: return(new VersionHistoryInfo()); case InfoContent.FastStatistic: return(new Admission.View.Workspaces.EntrantClaims.InfoBoxes.FastAdmissionStatistic()); default: throw new Exception("Указанная информационная панель не зарегистрирована в DialogService"); } }
public async Task <JsonValue> FetchDataHeader(string url) { LinearLayout linearLayout = FindViewById <LinearLayout>(Resource.Id.ListLinearLayout); GridLayout gridLayout = FindViewById <GridLayout>(Resource.Id.viewLayout); ImageView imageViewas = (ImageView)FindViewById(Resource.Id.Imageview); navigationView = (NavigationView)FindViewById(Resource.Id.nav_view); string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "mintdata.db3"); var db = new SQLiteAsyncConnection(dbPath); var HomeButtonTalbe = db.Table <HomeButton>(); var InfoContentTable = db.Table <InfoContent>(); var IntroPageTable = db.Table <Intropage>(); var BackgroundNADBUttonTABLE = db.Table <BackgGroundAndButton>(); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url)); request.ContentType = "application/json"; request.Method = "GET"; try { // Send the request to the server and wait for the response: using (WebResponse response = await request.GetResponseAsync()) { // Get a stream representation of the HTTP web response: using (System.IO.Stream stream = response.GetResponseStream()) { JsonValue jsonDoc = await Task.Run(() => JsonObject.Load(stream)); JSONArray ja = new JSONArray(jsonDoc.ToString()); for (int i = 0; i < ja.Length(); i++) { JSONObject jo = ja.GetJSONObject(i); BackgGroundAndButton BaB = new BackgGroundAndButton { image = jo.GetString("BackgroundImg"), IsTrueORfalse = jo.GetBoolean("ButtonInterface"), }; BaBLisr.Add(BaB); await db.InsertOrReplaceAsync(BaB); InfoContent infoContent = new InfoContent { Content = jo.GetString("ContentText"), }; infocontentlist.Add(infoContent); await db.InsertOrReplaceAsync(infoContent); Intropage intropage = new Intropage { LastChanged = jo.GetString("LastChanged"), }; IntroPageList.Add(intropage); await db.InsertOrReplaceAsync(intropage); //Convert the Base64 from the api to and image and sets the image to the imageview GetImage = BaB.image; byte[] imgdata = Convert.FromBase64String(GetImage); var imageBitmap = Android.Graphics.BitmapFactory.DecodeByteArray(imgdata, 0, imgdata.Length); imageViewas.SetImageBitmap(imageBitmap); //Check if buttoninterfece is false or true if (BaB.IsTrueORfalse == false) { //Create listview string urlListView = Intent.GetStringExtra("APIListView"); JsonValue CreateList = await FetchListView(urlListView); } else { //Creates imagebuttons JSONArray jsonArray = ja.GetJSONObject(0).GetJSONArray("Buttons"); //Hides the linearlayout with the Listview linearLayout.Visibility = ViewStates.Gone; for (int init = 0; init < jsonArray.Length(); init++) { JSONObject jsonObject = jsonArray.GetJSONObject(init); HomeButton homeButton = new HomeButton { Column = jsonObject.GetInt("Column"), Image = jsonObject.GetString("Image"), InfoContentId = jsonObject.GetString("InfoContentID"), ModuleId = jsonObject.GetInt("ModuleID"), Row = jsonObject.GetInt("Row"), }; HomeButtonList.Add(homeButton); await db.InsertOrReplaceAsync(homeButton); GridLayout.LayoutParams paramms = new GridLayout.LayoutParams(); paramms.RowSpec = GridLayout.InvokeSpec(GridLayout.Undefined, 1f); paramms.ColumnSpec = GridLayout.InvokeSpec(GridLayout.Undefined, 1f); var buttons = new ImageButton(this); buttons.LayoutParameters = paramms; buttons.SetScaleType(ImageButton.ScaleType.FitXy); byte[] buttonimg = Convert.FromBase64String(homeButton.Image); var buttonimagemap = Android.Graphics.BitmapFactory.DecodeByteArray(buttonimg, 0, buttonimg.Length); buttons.SetImageBitmap(buttonimagemap); gridLayout.AddView(buttons); //Displays the ModuleID when a imagebutton is pressed. buttons.Click += delegate { Toast.MakeText(this, "ModuleId: " + homeButton.ModuleId.ToString(), ToastLength.Long).Show(); }; } } } // Return the JSON document: Console.Out.WriteLine("Response: {0}", jsonDoc.ToString()); return(url); } } } catch (Exception) { return(null); } }
/// <summary> /// Открывает информационное окно в обычном режиме /// </summary> /// <param name="contentType">Тип инфобокса</param> /// <param name="viewModel">Контекст данных, передаваемый в редактор</param> public static void ShowInfoBox(InfoContent contentType, object viewModel) { InfoBox infoBox = new InfoBox(GetInfoContent(contentType), viewModel); infoBox.Show(); }
private void AdaptiveInfomationData(string[] strArr) { if (null == strArr || strArr.Length <= 0) { return; } var data = new InformationData(); data.Contentlist = new List <InfoContent>(); bool m_isPublic = false; for (int i = 0; i < strArr.Length; i++) { if (string.IsNullOrEmpty(strArr[i])) { continue; } var optionArr = strArr[i].Split(new char[] { '@' }, System.StringSplitOptions.RemoveEmptyEntries);//长度至少为2 //var optionArr = strArr[i].Split('@');//长度至少为2 if (null == optionArr || optionArr.Length < 2) { continue; } if (optionArr[0] == "#")//公共信息识别 { var _info = new InfoContent(); _info.Name = optionArr[1]; _info.Value = optionArr[2]; m_PublicInformationData.Contentlist.Add(_info); m_isPublic = true; } else { switch (optionArr[0])//单位信息 { case "ID": data.ID = optionArr[1]; break; case "Link": data.Link = optionArr[1]; break; case "PanelColor": data.PanelColor = TransformHexToRGB(optionArr[1]); break; default: { if (string.IsNullOrEmpty(optionArr[0])) { continue; } var _info = new InfoContent(); _info.Name = optionArr[0]; if (optionArr.Length > 1) { _info.Value = optionArr[1]; } if (optionArr.Length > 2) { _info.ViewType = (EContentViewType)int.Parse(optionArr[2]); } if (optionArr.Length > 3) { _info.IsShowPanel = optionArr[3] == "1"; } if (optionArr.Length > 4) { _info.TextColor = TransformHexToRGB(optionArr[4]); } data.Contentlist.Add(_info); } break; } } } if (!m_isPublic) { m_InformationDataList.Add(data); } }