private void getTag_Click(object sender, RoutedEventArgs e) { int count = 0; var tags = mHelper.GetTagByGroup(mCurrentDatabase, mTagGroup, 0, out count); if (tags != null) { taglist.ItemsSource = tags.Select(e => e.Item1.Name).ToList(); } }
///// <summary> ///// ///// </summary> //private void UpdateTags() //{ // mTags.Clear(); // var tags = mHelper.GetTagByGroup(CurrentDatabase, CurrentGroup != null ? CurrentGroup.FullName : "", 0); // if (tags != null) // { // foreach (var vv in tags) // { // var vtag = new TagViewModel() { Name = vv.Item1.Name, Desc = vv.Item1.Desc, Type = vv.Item1.Type.ToString(), ReadWriteMode = vv.Item1.ReadWriteType.ToString(), Group = CurrentGroup != null ? CurrentGroup.FullName : "" }; // if (vv.Item1 is Cdy.Tag.NumberTagBase) // { // vtag.MaxValue = (vv.Item1 as Cdy.Tag.NumberTagBase).MaxValue; // vtag.MinValue = (vv.Item1 as Cdy.Tag.NumberTagBase).MinValue; // } // if (vv.Item1 is Cdy.Tag.FloatingTagBase) // { // vtag.Precision = (vv.Item1 as Cdy.Tag.FloatingTagBase).Precision; // } // mTags.Add(vtag); // } // } //} /// <summary> /// /// </summary> private void ContinueQueryTags() { if (mIsBusy) { return; } mIsBusy = true; try { if (mRequery) { mRequery = false; Application.Current.Dispatcher.Invoke(new Action(() => { mTags.Clear(); })); mCurrentPageIndex = 0; string group = CurrentGroup != null?CurrentGroup.FullName.Replace(CurrentDatabase + ".", "") : ""; if (group == CurrentDatabase) { group = ""; } var tags = mHelper.GetTagByGroup(CurrentDatabase, group, mCurrentPageIndex, out mLastPageCount, mFilters); if (tags != null) { foreach (var vv in tags) { var vtag = new TagViewModel() { Name = vv.Item1.Name, Desc = vv.Item1.Desc, Type = vv.Item1.Type.ToString(), ReadWriteMode = vv.Item1.ReadWriteType.ToString(), Group = CurrentGroup != null ? CurrentGroup.FullName : "" }; if (vv.Item1 is Cdy.Tag.NumberTagBase) { vtag.MaxValue = (vv.Item1 as Cdy.Tag.NumberTagBase).MaxValue; vtag.MinValue = (vv.Item1 as Cdy.Tag.NumberTagBase).MinValue; } if (vv.Item1 is Cdy.Tag.FloatingTagBase) { vtag.Precision = (vv.Item1 as Cdy.Tag.FloatingTagBase).Precision; } Application.Current?.Dispatcher.Invoke(new Action(() => { mTags.Add(vtag); })); } } } else { if (mCurrentPageIndex >= mLastPageCount) { return; } mCurrentPageIndex++; var tags = mHelper.GetTagByGroup(CurrentDatabase, CurrentGroup != null ? CurrentGroup.FullName : "", mCurrentPageIndex, out mLastPageCount, mFilters); if (tags != null && tags.Count > 0) { foreach (var vv in tags) { var vtag = new TagViewModel() { Name = vv.Item1.Name, Desc = vv.Item1.Desc, Type = vv.Item1.Type.ToString(), ReadWriteMode = vv.Item1.ReadWriteType.ToString(), Group = CurrentGroup != null ? CurrentGroup.FullName : "" }; if (vv.Item1 is Cdy.Tag.NumberTagBase) { vtag.MaxValue = (vv.Item1 as Cdy.Tag.NumberTagBase).MaxValue; vtag.MinValue = (vv.Item1 as Cdy.Tag.NumberTagBase).MinValue; } if (vv.Item1 is Cdy.Tag.FloatingTagBase) { vtag.Precision = (vv.Item1 as Cdy.Tag.FloatingTagBase).Precision; } Application.Current?.Dispatcher.Invoke(new Action(() => { mTags.Add(vtag); })); } } else { mCurrentPageIndex--; } } } catch { } mIsBusy = false; }