/** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取MsgView对象从而各种设置 */ public MsgView GetMsgView(int position) { if (position >= mTabCount) { position = mTabCount - 1; } View tabView = mTabsContainer.GetChildAt(position); MsgView tipView = (MsgView)tabView.FindViewById(Resource.Id.rtv_msg_tip); return(tipView); }
/** 隐藏未读消息 */ public void HideMsg(int position) { if (position >= mTabCount) { position = mTabCount - 1; } View tabView = mTabsContainer.GetChildAt(position); MsgView tipView = (MsgView)tabView.FindViewById(Resource.Id.rtv_msg_tip);//.findViewById(R.id.rtv_msg_tip); if (tipView != null) { tipView.Visibility = ViewStates.Gone;// .SetVisibility(ViewStates.Gone); } }
public FormMain(SCIPackage package, SCIPackage translate) { _package = package; _translate = translate; InitializeComponent(); Text = package.GameDirectory; SetStyle(ControlStyles.OptimizedDoubleBuffer, true); sc.Panel2.Controls.Add(hexViewer = new HexViewer()); sc.Panel2.Controls.Add(textViewer = new TextViewer()); sc.Panel2.Controls.Add(fontView = new FontView()); sc.Panel2.Controls.Add(scriptView = new ScriptView()); sc.Panel2.Controls.Add(vocabView = new VocabView()); sc.Panel2.Controls.Add(msgView = new MsgView()); sc.Panel2.Controls.Add(picView = new PicView()); foreach (ResType resType in Enum.GetValues(typeof(ResType))) { var resources = package.GetResources(resType); if (!resources.Any()) { continue; } TreeNode tnRes = tv.Nodes.Add(ResTypeName(resType)); tnRes.ImageKey = "folder"; tnRes.SelectedImageKey = tnRes.ImageKey; foreach (var res in resources) { TreeNode tnRec = tnRes.Nodes.Add(res.ToString()); tnRec.ImageKey = ResTypeKey(resType); tnRec.SelectedImageKey = tnRec.ImageKey; tnRec.Tag = res; } } if (_translate == null) { tsbTranslated.Checked = false; tsbTranslated.Visible = false; tsbSave.Visible = false; } }
public T ShowMsg <T>(MsgEnum msgType, string content, Vector3 msgPosition) where T : MsgView { string msgName = EnumUtil.GetEnumName(msgType); GameObject objMsg = CreateMsg(msgName); if (objMsg) { MsgView msgView = objMsg.GetComponent <MsgView>(); msgView.SetContent(content); RectTransform rtfMsg = (RectTransform)msgView.transform; rtfMsg.anchoredPosition = msgPosition; return(msgView as T); } else { LogUtil.LogError("没有找到指定Msg:" + "Resources/" + resUrl + msgName); return(null); } }
/** 设置未读消息偏移,原点为文字的右上角.当控件高度固定,消息提示位置易控制,显示效果佳 */ public void SetMsgMargin(int position, float leftPadding, float bottomPadding) { if (position >= mTabCount) { position = mTabCount - 1; } View tabView = mTabsContainer.GetChildAt(position); MsgView tipView = (MsgView)tabView.FindViewById(Resource.Id.rtv_msg_tip); if (tipView != null) { TextView tv_tab_title = (TextView)tabView.FindViewById(Resource.Id.tv_tab_title); mTextPaint.TextSize = mTextsize;// SetTextSize(mTextsize); float textWidth = mTextPaint.MeasureText(tv_tab_title.Text.ToString()); float textHeight = mTextPaint.Descent() - mTextPaint.Ascent(); MarginLayoutParams lp = (MarginLayoutParams)tipView.LayoutParameters;//.getLayoutParams(); lp.LeftMargin = mTabWidth >= 0 ? (int)(mTabWidth / 2 + textWidth / 2 + dp2px(leftPadding)) : (int)(mTabPadding + textWidth + dp2px(leftPadding)); lp.TopMargin = mHeight > 0 ? (int)(mHeight - textHeight) / 2 - dp2px(bottomPadding) : 0; tipView.LayoutParameters = lp;//.setLayoutParams(lp); } }
/** * 显示未读消息 * * @param position 显示tab位置 * @param num num小于等于0显示红点,num大于0显示数字 */ public void ShowMsg(int position, int num) { if (position >= mTabCount) { position = mTabCount - 1; } View tabView = mTabsContainer.GetChildAt(position); MsgView tipView = (MsgView)tabView.FindViewById(Resource.Id.rtv_msg_tip); if (tipView != null) { UnreadMsgUtils.Show(tipView, num); if (mInitSetMap.Get(position) && mInitSetMap.Get(position)) { return; } SetMsgMargin(position, 4, 2); mInitSetMap.Put(position, true); } }