/// <summary> /// Sets the image source. /// </summary> /// <param name="targetButton">The target button.</param> /// <param name="model">The model.</param> /// <returns>A <see cref="Task"/> for the awaited operation.</returns> private async Task SetImageSourceAsync(Android.Widget.Button targetButton, BaseButton model) { if (targetButton == null || targetButton.Handle == IntPtr.Zero || model == null) { return; } // const int Padding = 10; var source = model.IsEnabled ? model.Source : model.DisabledSource ?? model.Source; using (var bitmap = await GetBitmapAsync(source).ConfigureAwait(false)) { if (bitmap == null) { targetButton.SetCompoundDrawables(null, null, null, null); } else { var drawable = new BitmapDrawable(bitmap); var tintColor = model.IsEnabled ? model.ImageTintColor : model.DisabledImageTintColor; if (tintColor != Color.Transparent) { drawable.SetTint(tintColor.ToAndroid()); drawable.SetTintMode(PorterDuff.Mode.SrcIn); } using (var scaledDrawable = GetScaleDrawable(drawable, GetWidth(model.ImageWidthRequest), GetHeight(model.ImageHeightRequest))) { Drawable left = null; Drawable right = null; Drawable top = null; Drawable bottom = null; //System.Diagnostics.Debug.WriteLine($"SetImageSourceAsync intptr{targetButton.Handle}"); int padding = 10; // model.Padding targetButton.CompoundDrawablePadding = RequestToPixels(padding); switch (model.Orientation) { case ImageOrientationOverride.ImageToLeft: targetButton.Gravity = GravityFlags.Left | GravityFlags.CenterVertical; left = scaledDrawable; break; case ImageOrientationOverride.ImageToRight: targetButton.Gravity = GravityFlags.Right | GravityFlags.CenterVertical; right = scaledDrawable; break; case ImageOrientationOverride.ImageOnTop: targetButton.Gravity = GravityFlags.Top | GravityFlags.CenterHorizontal; top = scaledDrawable; break; case ImageOrientationOverride.ImageOnBottom: targetButton.Gravity = GravityFlags.Bottom | GravityFlags.CenterHorizontal; bottom = scaledDrawable; break; case ImageOrientationOverride.ImageCentered: targetButton.Gravity = GravityFlags.Center; // | GravityFlags.Fill; top = scaledDrawable; break; } targetButton.SetCompoundDrawables(left, top, right, bottom); } } } }
private void UpSwitchButton(BaseButton obj) { SwitchButton(-1); }
private void OnClick(BaseButton button) { Tips.DOFillAlpha(1, 0.5f); Hide(); contentPanel.SetPanel((button as MenuButton).GetName()); }
private void NavigateButtons(Vector3 a_v3PrimaryInputDirection, List <BaseButton> a_lButtons) { if (a_v3PrimaryInputDirection.x >= m_fInputBuffer) { if (!m_bInputRecieved) { m_bInputRecieved = true; if (m_selectedButton.VolumeSlider != null) { m_selectedButton.VolumeSlider.value += 0.1f; } } } else if (a_v3PrimaryInputDirection.x <= -m_fInputBuffer) { if (!m_bInputRecieved) { m_bInputRecieved = true; if (m_selectedButton.VolumeSlider != null) { m_selectedButton.VolumeSlider.value -= 0.1f; } } } else if (a_v3PrimaryInputDirection.z >= m_fInputBuffer) { if (!m_bInputRecieved) { m_bInputRecieved = true; if (m_selectedButton == a_lButtons[0]) { m_selectedButton.IsMousedOver = false; m_selectedButton = a_lButtons[a_lButtons.Count - 1]; m_selectedButton.IsMousedOver = true; m_iSelectedButtonIndex = a_lButtons.Count - 1; } else { m_selectedButton.IsMousedOver = false; m_selectedButton = a_lButtons[m_iSelectedButtonIndex - 1]; m_selectedButton.IsMousedOver = true; --m_iSelectedButtonIndex; } } } else if (a_v3PrimaryInputDirection.z <= -m_fInputBuffer) { if (!m_bInputRecieved) { m_bInputRecieved = true; if (m_selectedButton == a_lButtons[a_lButtons.Count - 1]) { m_selectedButton.IsMousedOver = false; m_selectedButton = a_lButtons[0]; m_selectedButton.IsMousedOver = true; m_iSelectedButtonIndex = 0; } else { m_selectedButton.IsMousedOver = false; m_selectedButton = a_lButtons[m_iSelectedButtonIndex + 1]; m_selectedButton.IsMousedOver = true; ++m_iSelectedButtonIndex; } } } else { m_bInputRecieved = false; } }
/// <summary>デリゲートの設定</summary> public override void SetDelegate(BaseButton src) { this.Click += src.OnClick; this.MouseEnter += src.OnMouseEnter; this.MouseLeave += OnMouseLeave; }
private void OnGameButtonClick(BaseButton obj) { Tips.DOFillAlpha(1, 0.5f); Hide(); gameContentPanel.Open(); }
/// <summary> /// 保存微信菜单信息到DB /// </summary> /// <param name="strName"></param> /// <param name="parentCode"></param> /// <param name="strCode"></param> /// <param name="iOrder"></param> /// <param name="btn"></param> /// <param name="strUrl"></param> /// <param name="iAppId"></param> /// <returns></returns> private int SaveMenu(string strName, int parentCode, string strCode, int iOrder, BaseButton btn, string strUrl, int iAppId) { var strType = ""; if (btn is SingleButton) { var button = btn as SingleButton; strType = button.type; switch (button.type) { case "view": strUrl = (btn as SingleViewButton).url; break; case "pic_weixin": default: dynamic dd = button; strCode = dd.key; break; } } var bt = new ButtonReturnType() { ResponseMsgType = "News", Content = "", Button = new MenuButton() { key = strCode, name = strName, type = strType, url = strUrl } }; var entity = new Category() { AppId = iAppId, CategoryCode = strCode, CategoryName = strName, CategoryOrder = iOrder, ParentCode = parentCode, Function = Newtonsoft.Json.JsonConvert.SerializeObject(bt), CategoryDesc = strUrl, IsAdmin = false, IsDeleted = false }; _categoryService.Repository.Insert(entity); return(entity.Id); }
public Config() { string line; if (!System.IO.File.Exists("config.json")) { System.IO.StreamWriter writer = new System.IO.StreamWriter("config.json"); foreach (var cfgLine in defaultConfig) { writer.WriteLine(cfgLine); } writer.Close(); } System.IO.StreamReader file = new System.IO.StreamReader(@"config.json"); while ((line = file.ReadLine()) != null) { foreach (ButtonAction val in Enum.GetValues(typeof(ButtonAction))) { if (line.StartsWith(val.ToString())) { ButtonAction curAction = val; BaseButton curBtn = null; try { var index = line.IndexOf(":") + 1; var action = (line.Substring(index, line.Length - index)).Trim(); if (!action.Contains(";")) { var tmp = action.Split('.'); if (tmp.Length == 2) { switch (tmp[0].Trim().ToLower()) { case "mouse": Enum.TryParse(tmp[1].Trim(), out Interceptor.MouseState mouseStatus); actions.Add(curAction, new MouseButton(mouseStatus)); break; default: Enum.TryParse(tmp[1].Trim(), out Interceptor.Keys keyStatus); actions.Add(curAction, new KeyButton(keyStatus)); break; } } } else { var tmpActions = action.Split(';'); if (tmpActions.Length == 2) { var tmpDown = tmpActions[0].Split('.'); var tmpUp = tmpActions[1].Split('.'); if (tmpDown.Length == 2 && tmpUp.Length == 2) { switch (tmpDown[0].Trim().ToLower()) { case "mouse": Enum.TryParse(tmpDown[1].Trim(), out Interceptor.MouseState mouseDownStatus); Enum.TryParse(tmpUp[1].Trim(), out Interceptor.MouseState mouseUpStatus); actions.Add(curAction, new MouseButton(mouseDownStatus, mouseUpStatus)); break; default: Enum.TryParse(tmpDown[1].Trim(), out Interceptor.Keys keyDownStatus); Enum.TryParse(tmpUp[1].Trim(), out Interceptor.Keys keyUpStatus); actions.Add(curAction, new KeyButton(keyDownStatus, keyUpStatus)); break; } } } } } catch (Exception ex) { Console.WriteLine($"Unable to parse config"); Console.WriteLine($"Error on line: ({line})"); Console.ReadKey(); Environment.Exit(-10); } break; } } } }
/// <summary> /// 根据微信返回的Json数据得到可用的GetMenuResult结果 /// </summary> /// <param name="resultFull"></param> /// <returns></returns> public static MenuJsonResult GetMenuFromJsonResult(MenuJsonResult resultFull) { MenuJsonResult result = null; try { //重新整理按钮信息 CustomMenu bg = new CustomMenu(); foreach (var rootButton in resultFull.menu.button) { if (string.IsNullOrEmpty(rootButton.name)) { continue;//没有设置一级菜单 } var availableSubButton = rootButton.sub_button == null ? 0 : rootButton.sub_button.Count(z => !string.IsNullOrEmpty(z.name));//可用二级菜单按钮数量 if (availableSubButton == 0) { //底部单击按钮 if (rootButton.type == null || (rootButton.type.Equals("CLICK", StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(rootButton.key))) { throw new WeixinMenuException("单击按钮的key不能为空!"); } ButtonType buttontype = (ButtonType)Enum.Parse(typeof(ButtonType), rootButton.type); if (buttontype == ButtonType.click) { //点击 bg.button.Add(new ClickButton() { name = rootButton.name, key = rootButton.key, type = buttontype }); } else if (buttontype == ButtonType.view) { //URL bg.button.Add(new ViewButton() { name = rootButton.name, url = rootButton.url, type = buttontype }); } //else if (rootButton.type.Equals("LOCATION_SELECT", StringComparison.OrdinalIgnoreCase)) //{ // //弹出地理位置选择器 // bg.button.Add(new SingleLocationSelectButton() // { // name = rootButton.name, // key = rootButton.key, // type = rootButton.type // }); //} //else if (rootButton.type.Equals("PIC_PHOTO_OR_ALBUM", StringComparison.OrdinalIgnoreCase)) //{ // //弹出拍照或者相册发图 // bg.button.Add(new SinglePicPhotoOrAlbumButton() // { // name = rootButton.name, // key = rootButton.key, // type = rootButton.type // }); //} //else if (rootButton.type.Equals("PIC_SYSPHOTO", StringComparison.OrdinalIgnoreCase)) //{ // //弹出系统拍照发图 // bg.button.Add(new SinglePicSysphotoButton() // { // name = rootButton.name, // key = rootButton.key, // type = rootButton.type // }); //} //else if (rootButton.type.Equals("PIC_WEIXIN", StringComparison.OrdinalIgnoreCase)) //{ // //弹出微信相册发图器 // bg.button.Add(new SinglePicWeixinButton() // { // name = rootButton.name, // key = rootButton.key, // type = rootButton.type // }); //} //else if (rootButton.type.Equals("SCANCODE_PUSH", StringComparison.OrdinalIgnoreCase)) //{ // //扫码推事件 // bg.button.Add(new SingleScancodePushButton() // { // name = rootButton.name, // key = rootButton.key, // type = rootButton.type // }); //} //else //{ // //扫码推事件且弹出“消息接收中”提示框 // bg.button.Add(new SingleScancodeWaitmsgButton() // { // name = rootButton.name, // key = rootButton.key, // type = rootButton.type // }); //} } //else if (availableSubButton < 2) //{ // throw new WeixinMenuException("子菜单至少需要填写2个!"); //} else { //底部二级菜单 var subButton = new BaseButton(rootButton.name); bg.button.Add(subButton); foreach (var subSubButton in rootButton.sub_button) { if (string.IsNullOrEmpty(subSubButton.name)) { continue; //没有设置菜单 } if (subSubButton.type.Equals("CLICK", StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(subSubButton.key)) { throw new WeixinMenuException("单击按钮的key不能为空!"); } ButtonType buttontype = (ButtonType)Enum.Parse(typeof(ButtonType), subSubButton.type); if (buttontype == ButtonType.click) { //点击 subButton.sub_button.Add(new ClickButton() { name = subSubButton.name, key = subSubButton.key, type = buttontype }); } else if (buttontype == ButtonType.view) { //URL subButton.sub_button.Add(new ViewButton() { name = subSubButton.name, url = subSubButton.url, type = buttontype }); } //else if (subSubButton.type.Equals("LOCATION_SELECT", StringComparison.OrdinalIgnoreCase)) //{ // //弹出地理位置选择器 // subButton.sub_button.Add(new SingleLocationSelectButton() // { // name = subSubButton.name, // key = subSubButton.key, // type = subSubButton.type // }); //} //else if (subSubButton.type.Equals("PIC_PHOTO_OR_ALBUM", StringComparison.OrdinalIgnoreCase)) //{ // //弹出拍照或者相册发图 // subButton.sub_button.Add(new SinglePicPhotoOrAlbumButton() // { // name = subSubButton.name, // key = subSubButton.key, // type = subSubButton.type // }); //} //else if (subSubButton.type.Equals("PIC_SYSPHOTO", StringComparison.OrdinalIgnoreCase)) //{ // //弹出系统拍照发图 // subButton.sub_button.Add(new SinglePicSysphotoButton() // { // name = subSubButton.name, // key = subSubButton.key, // type = subSubButton.type // }); //} //else if (subSubButton.type.Equals("PIC_WEIXIN", StringComparison.OrdinalIgnoreCase)) //{ // //弹出微信相册发图器 // subButton.sub_button.Add(new SinglePicWeixinButton() // { // name = subSubButton.name, // key = subSubButton.key, // type = subSubButton.type // }); //} //else if (subSubButton.type.Equals("SCANCODE_PUSH", StringComparison.OrdinalIgnoreCase)) //{ // //扫码推事件 // subButton.sub_button.Add(new SingleScancodePushButton() // { // name = subSubButton.name, // key = subSubButton.key, // type = subSubButton.type // }); //} //else //{ // //扫码推事件且弹出“消息接收中”提示框 // subButton.sub_button.Add(new SingleScancodeWaitmsgButton() // { // name = subSubButton.name, // key = subSubButton.key, // type = subSubButton.type // }); //} } } } result = new MenuJsonResult() { Buttons = bg }; } catch (Exception ex) { throw new WeixinMenuException(ex.Message, ex); } return(result); }
private void DownSwitchButton(BaseButton obj) { SwitchButton(1); }
private void lisMenuOrder_SelectedIndexChanged(object sender, EventArgs e) { if (lisMenuOrder.SelectedItems.Count > 0) { fPnlMenuItem.Controls.Clear(); ListViewItem addItem = lisMenuOrder.SelectedItems[0]; long sales_order_detail_id = Converts.ParseLong(addItem.Name); OrderDTO updateItem = this.OrderHeads.OrderList.Where(a => a.sales_order_detail_id == sales_order_detail_id && !a.condiment_of_order_detail_id.HasValue).FirstOrDefault(); if (updateItem != null && !updateItem.is_print) { this.OrderHeads.OrderList.ForEach(s => s.Selected = false); updateItem.Selected = true; if (!updateItem.IsCondiment) { List <OrderDTO> CondimetMenu = ServiceProvider.MenuService.LoadCondiMentMenu(updateItem.menu_dining_type_id); if (CondimetMenu != null) { foreach (OrderDTO Condimentitem in CondimetMenu) { Condimentitem.IsCondiment = true; Condimentitem.sales_order_detail_id = sales_order_detail_id; BaseButton btnCondiment = new BaseButton(); btnCondiment.Theme = Theme.MSOffice2010_Yellow; btnCondiment.Width = this.defaultBtnW; btnCondiment.Height = this.defaultBtnH; btnCondiment.Text = Condimentitem.menu_name; if (Condimentitem.menu_id.HasValue) { btnCondiment.Click += new EventHandler(btnCondiment_Click); } else { Condimentitem.menu_dining_type_id = updateItem.menu_dining_type_id; btnCondiment.Click += new EventHandler(btnOpenCondiment_Click); } btnCondiment.DataObject = Condimentitem; btnCondiment.Font = this.defaultBtnFont; fPnlMenuItem.Controls.Add(btnCondiment); } } } btnAdd.Enabled = true; btnDelete.Enabled = true; btnAdd.Theme = Theme.MSOffice2010_Green; btnDelete.Theme = Theme.MSOffice2010_RED; } else if (updateItem != null) { BaseButton btnCancleMenu = new BaseButton(); btnCancleMenu.Theme = Theme.MSOffice2010_RED; btnCancleMenu.Width = this.defaultBtnW; btnCancleMenu.Height = this.defaultBtnH; btnCancleMenu.Text = "Cancle Menu"; btnCancleMenu.DataObject = updateItem; btnCancleMenu.Font = this.defaultBtnFont; btnCancleMenu.Click += new EventHandler(btnCancleMenu_Click); fPnlMenuItem.Controls.Add(btnCancleMenu); } } else { btnAdd.Enabled = false; btnDelete.Enabled = false; btnAdd.Theme = Theme.MSOffice2010_WHITE; btnDelete.Theme = Theme.MSOffice2010_WHITE; } btnAdd.Invalidate(); btnDelete.Invalidate(); }
//public void AddDialogueButton(MainButton button, bool enabled) { // button.Visible = false; // AddDialogueButton(button.Text, button.ClientScript,enabled.ToString()); //} public void AddDialogueButton(BaseButton button) { button.Visible = false; AddDialogueButton(button.Text, button.ClientScript, button.Enabled.ToString()); }
public void SetElement(BaseButton element) { elementUi = element; }
protected void Page_Load(object sender, EventArgs e) { string signature = Request["signature"]; string timestamp = Request["timestamp"]; string nonce = Request["nonce"]; string echostr = Request["echostr"]; string inputXml = string.Empty; using (StreamReader sr = new StreamReader(Request.InputStream)) { inputXml = sr.ReadToEnd(); inputXml = HttpUtility.UrlDecode(inputXml); } string updateMenu = Request["updatemenu"]; if (!string.IsNullOrWhiteSpace(updateMenu)) { foreach (var menu in Activator.WeChatMenuContainer.WeChatMenus) { try { if (!AccessTokenContainer.CheckRegistered(menu.AppId)) { AccessTokenContainer.Register(menu.AppId, menu.Secret); } AccessTokenResult tokenRes = null; try { tokenRes = AccessTokenContainer.GetTokenResult(menu.AppId); //CommonAPIs.CommonApi.GetToken(appId, appSecret); WriteContent(string.Format("获取到 token 为:{0}, 有效时间为 {1} 秒。", tokenRes.access_token, tokenRes.expires_in)); //var menuRes = CommonApi.GetMenu(tokenRes.access_token); } catch { WriteContent(string.Format("获取到 token 失败, appid: {0},secret: {1}。", menu.AppId, menu.Secret)); } try { if (tokenRes != null) { //重新整理按钮信息 ButtonGroup bg = new ButtonGroup(); foreach (var menuButton in menu.MenuButtons) { BaseButton but = null; switch (menuButton.Type) { case ButtonType.Click: but = new SingleClickButton() { name = menuButton.Name, key = menuButton.Key, type = "click" }; break; case ButtonType.View: but = new SingleViewButton() { name = menuButton.Name, url = menuButton.Url, type = "view" }; break; case ButtonType.SubButton: List <SingleButton> subButtons = new List <SingleButton>(); foreach (var subBut in menuButton.MenuSubButtons) { SingleButton singleBut = null; switch (subBut.Type) { case ButtonType.Click: singleBut = new SingleClickButton() { name = subBut.Name, key = subBut.Key, type = "click" }; break; case ButtonType.View: singleBut = new SingleViewButton() { name = subBut.Name, url = subBut.Url, type = "view" }; break; } if (singleBut != null) { subButtons.Add(singleBut); } } but = new SubButton() { name = menuButton.Name, sub_button = subButtons }; break; } if (but != null) { bg.button.Add(but); } } var result = CommonApi.CreateMenu(tokenRes.access_token, bg); WriteContent(string.Format("创建结果信息:{0}, 返回值 {1} ({2})。", result.errmsg, (int)result.errcode, result.errcode.ToString())); } } catch { WriteContent("创建菜单失败!"); } } catch (Exception) { //TODO:为简化代码,这里不处理异常(如Token过期) WriteContent("执行过程发生错误!"); } } } foreach (var proxy in Activator.WeChatProxyContainer.WeChatProxies) { string token = proxy.Token; if (Request.HttpMethod == "GET") { //get method - 仅在微信后台填写URL验证时触发 if (CheckSignature.Check(signature, timestamp, nonce, token)) { WriteContent(echostr); //返回随机字符串则表示验证通过 //如果有多个相同的Token,则第一个验证通过就返回 break; } else { //WriteContent("failed:" + signature + "," + CheckSignature.GetSignature(timestamp, nonce, token) + "。" + // "如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。"); //如果失败应该不返回任何东西,以便循环校验下一个Token continue; } } else { //post method - 当有用户想公众账号发送消息时触发 if (!CheckSignature.Check(signature, timestamp, nonce, token)) { WriteContent("参数错误!"); continue; } //v4.2.2之后的版本,可以设置每个人上下文消息储存的最大数量,防止内存占用过多,如果该参数小于等于0,则不限制 var maxRecordCount = 10; //自定义MessageHandler,对微信请求的详细判断操作都在这里面。 //var messageHandler = new CustomMessageHandler(Request.InputStream, maxRecordCount); IMessageHandler messageHandler = null; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(inputXml))) { Type type = proxy.Bundle.LoadClass(proxy.Handler); var parameters = new object[] { stream, token, proxy.AppID, proxy.Secret, maxRecordCount }; messageHandler = System.Activator.CreateInstance(type, parameters) as IMessageHandler; } try { if (messageHandler != null) { //测试时可开启此记录,帮助跟踪数据,使用前请确保App_Data文件夹存在,且有读写权限。 messageHandler.RequestDocument.Save( Server.MapPath("~/App_Data/" + DateTime.Now.Ticks + "_Request_" + messageHandler.RequestMessage.FromUserName + ".txt")); //执行微信处理过程 messageHandler.Execute(); //测试时可开启,帮助跟踪数据 messageHandler.ResponseDocument.Save( Server.MapPath("~/App_Data/" + DateTime.Now.Ticks + "_Response_" + messageHandler.ResponseMessage.ToUserName + ".txt")); WriteContent(messageHandler.ResponseDocument.ToString()); continue; } } catch (Exception ex) { using (TextWriter tw = new StreamWriter(Server.MapPath("~/App_Data/Error_" + DateTime.Now.Ticks + ".txt"))) { tw.WriteLine(ex.Message); tw.WriteLine(ex.InnerException.Message); if (messageHandler.ResponseDocument != null) { tw.WriteLine(messageHandler.ResponseDocument.ToString()); } tw.Flush(); tw.Close(); } WriteContent(""); } } } Response.End(); }
private void OnEnable() { //drawGizmos = true; compt = target as BaseButton; }
public static IObservable <Unit> OnButtonDown(this BaseButton button) { return(button.FromSignal("button_down").AsUnitObservable()); }
public static IObservable <Unit> OnPress(this BaseButton button) { return(button.FromSignal("pressed").AsUnitObservable()); }
/// <summary> /// Saves the string to local settings. MenuChanger will subsequently allow a ResumeMenu subscribed to the matching key to take control upon clicking the save slot button. /// </summary> public static void AddSetResumeKeyEvent(this BaseButton self, string key) { self.OnClick += () => MenuChangerMod.instance.Settings.resumeKey = key; }
public void AddNewBase(BaseButton infoButton) { ++baseButtonCnt; baseButton[baseButtonCnt].Attach(infoButton); baseButton[baseButtonCnt].gameObject.SetActive(true); }
/// <summary> /// Causes the button to show the given MenuPage on click. /// </summary> public static void AddShowMenuPageEvent(this BaseButton self, MenuPage next) { self.OnClick += next.Show; }
/// <summary> /// Causes the button to hide all MenuPages on click. /// </summary> public static void AddHideAllMenuPagesEvent(this BaseButton self) { self.OnClick += MenuChangerMod.HideAllMenuPages; }
/// <summary> /// Causes the button to hide the given MenuPage on click. /// </summary> public static void AddHideMenuPageEvent(this BaseButton self, MenuPage prev) { self.OnClick += prev.Hide; }
/// <summary> /// Causes the button to hide its MenuPage on click. /// </summary> public static void AddHideMenuPageEvent(this BaseButton self) { self.OnClick += self.Parent.Hide; }
public BaseButtonPressArgs(BaseButton baseButton) { this.baseButton = baseButton; }