public static HtmlHelper HtmlHelper(this ControllerContext controllerContext) { var dummyView = new DummyView(); var viewContext = new ViewContext(controllerContext, dummyView, controllerContext.Controller.ViewData, controllerContext.Controller.TempData, controllerContext.HttpContext.Response.Output); var htmlHelper = new HtmlHelper(viewContext, dummyView); return htmlHelper; }
public DummyView GetDummy(string textField, string textArea, string select, string radio) { DummyView dummy = new DummyView(); dummy.TextFieldValue = textField; dummy.TextAreaValue = textArea; dummy.DateTimeValue = DateTime.Now.AddHours(-1); dummy.SelectStringValue = select; dummy.SelectIntValue = SelectionStringToInt(select); dummy.RadioStringValue = radio; dummy.RadioIntValue = SelectionStringToInt(radio); dummy.CheckboxStringValues = new List <string>(new string[] { select, radio }); dummy.CheckboxIntValues = new List <int?>(new int?[] { SelectionStringToInt(select), SelectionStringToInt(radio) }); DummyItemView dummyItem; for (int i = 0; i < 5; i++) { dummyItem = new DummyItemView(); dummyItem.ID = Guid.NewGuid(); dummyItem.Name = "Dummy " + i; dummyItem.Quantity = i * 2; dummyItem.UnitCost = i * 10; dummy.DummyItems.Add(dummyItem); } return(dummy); }
public static HtmlHelper HtmlHelper(this ControllerContext controllerContext) { var dummyView = new DummyView(); var viewContext = new ViewContext(controllerContext, dummyView, controllerContext.Controller.ViewData, controllerContext.Controller.TempData, controllerContext.HttpContext.Response.Output); var htmlHelper = new HtmlHelper(viewContext, dummyView); return(htmlHelper); }
private static PXAdapter CreateAdapter(SubcontractEntry graph, POOrder subcontract) { var dummyView = new DummyView(graph, subcontract); return(new PXAdapter(dummyView) { Menu = nameof(Approve) }); }
public ExpandableAnimationListener(AnimatedExpandableListAdapter adaptor, int state, int groupPosition, DummyView dummyView, ExpandableListView listView, GroupInfo info) { this.adaptor = adaptor; this.state = state; this.groupPosition = groupPosition; this.dummyView = dummyView; this.listView = listView; this.info = info; }
public void Should_be_able_to_add_a_view() { var readerWriter = new InMemoryProjectionReaderWriter<Guid, DummyView>(new ConcurrentDictionary<Guid, DummyView>()); var view = new DummyView() { Id = Guid.NewGuid(), }; var addedView = readerWriter.Add(view.Id, view); Assert.AreEqual(view, addedView); }
public void HookClick() { if (_interceptMouse.IsHooked || _dv != null) { return; } _dv = new DummyView(); _dv.Show(); _interceptMouse.SetHook(); RaisePropertyChanged(nameof(Hooked)); }
private static HtmlHelper CreateHtmlHelper() { //The only "real" element in the HtmlHelper is the HttpContext //the rest in not actually used by the antiforgery code var controllerContext = new ControllerContext(HttpContextSource.Current, new RouteData(), new DummyController()); IView view = new DummyView(); var viewData = new ViewDataDictionary(); var tempData = new TempDataDictionary(); TextWriter writer = new StringWriter(); var viewContext = new ViewContext(controllerContext, view, viewData, tempData, writer); IViewDataContainer dataContainer = new DummyViewDataContainer(); var helper = new HtmlHelper(viewContext, dataContainer); return(helper); }
public void Should_not_be_able_to_add_a_view_with_existing_key() { var readerWriter = new InMemoryProjectionReaderWriter<Guid, DummyView>(new ConcurrentDictionary<Guid, DummyView>()); var key = Guid.NewGuid(); var view1 = new DummyView() { Id = key, Anything = Guid.NewGuid().ToString() }; var view2 = new DummyView() { Id = key, Anything = Guid.NewGuid().ToString() }; readerWriter.Add(key, view1); readerWriter.Add(key, view2); }
public void VerifyBaseMethodExecutesOnceAtCall() { var view = new DummyView(); var vm = new DummyVm(); int called = 0; called.ShouldBe(0); BindingCore.CreateBinding(view, vm, d => d.DummyProperty, (v, text) => { v.TextProperty = text; called++; }); called.ShouldBe(1); }
public void VerifyBaseMethodDisposeUnhooksBindings() { var view = new DummyView(); var vm = new DummyVm(); int called = 0; var binding = BindingCore.CreateBinding(view, vm, d => d.DummyProperty, (dummyView, s) => { dummyView.TextProperty = s; called++; }); called.ShouldBe(1); view.TextProperty.ShouldBe(vm.DummyProperty); vm.DummyProperty = "Random value"; called.ShouldBe(2); view.TextProperty.ShouldBe(vm.DummyProperty); binding.Dispose(); vm.DummyProperty = "Random value numer 2"; called.ShouldBe(2); view.TextProperty.ShouldNotBe(vm.DummyProperty); vm.DummyProperty = "Random value numer 3"; called.ShouldBe(2); view.TextProperty.ShouldNotBe(vm.DummyProperty); }
private static HtmlHelper CreateHtmlHelper() { //The only "real" element in the HtmlHelper is the HttpContext //the rest in not actually used by the antiforgery code var controllerContext = new ControllerContext(HttpContextSource.Current, new RouteData(), new DummyController()); IView view = new DummyView(); var viewData = new ViewDataDictionary(); var tempData = new TempDataDictionary(); TextWriter writer = new StringWriter(); var viewContext = new ViewContext(controllerContext, view, viewData, tempData, writer); IViewDataContainer dataContainer = new DummyViewDataContainer(); var helper = new HtmlHelper(viewContext, dataContainer); return helper; }
public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) { GroupInfo info = GetGroupInfo(groupPosition); if (info.animating) { // If this group is animating, return the a DummyView... if (convertView is DummyView == false) { convertView = new DummyView(parent.Context); convertView.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, 0); } if (childPosition < info.firstChildPosition) { convertView.LayoutParameters.Height = 0; return(convertView); } ExpandableListView listView = (ExpandableListView)parent; DummyView dummyView = (DummyView)convertView; // Clear the views that the dummy view draws. dummyView.ClearViews(); // Set the style of the divider dummyView.SetDivider(listView.Divider, parent.MeasuredWidth, listView.DividerHeight); // Make measure specs to measure child views int measureSpecW = MeasureSpec.MakeMeasureSpec(parent.Width, MeasureSpecMode.Exactly); int measureSpecH = MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified); int totalHeight = 0; int clipHeight = parent.Height; int len = GetRealChildrenCount(groupPosition); for (int i = info.firstChildPosition; i < len; i++) { View childView = GetRealChildView(groupPosition, i, (i == len - 1), null, parent); LayoutParams p = (LayoutParams)childView.LayoutParameters; if (p == null) { p = (LayoutParams)GenerateDefaultLayoutParams(); childView.LayoutParameters = p; } int lpHeight = p.Height; int childHeightSpec; if (lpHeight > 0) { childHeightSpec = MeasureSpec.MakeMeasureSpec(lpHeight, MeasureSpecMode.Exactly); } else { childHeightSpec = measureSpecH; } childView.Measure(measureSpecW, childHeightSpec); totalHeight += childView.MeasuredHeight; if (totalHeight < clipHeight) { // we only need to draw enough views to fool the user... dummyView.AddFakeView(childView); } else { dummyView.AddFakeView(childView); // if this group has too many views, we don't want to // calculate the height of everything... just do a light // approximation and break int averageHeight = totalHeight / (i + 1); totalHeight += (len - i - 1) * averageHeight; break; } } int state; if (dummyView.Tag == null) { state = STATE_IDLE; } else { state = ((Integer)dummyView.Tag).IntValue(); } if (info.expanding && state != STATE_EXPANDING) { ExpandAnimation ani = new ExpandAnimation(dummyView, 0, totalHeight, info); ani.Duration = ANIMATION_DURATION; ExpandableAnimationListener expandAnimationListener = new ExpandableAnimationListener(this, state, groupPosition, dummyView, listView, info); ani.SetAnimationListener(expandAnimationListener); dummyView.StartAnimation(ani); dummyView.Tag = STATE_EXPANDING; } else if (!info.expanding && state != STATE_COLLAPSING) { if (info.dummyHeight == -1) { info.dummyHeight = totalHeight; } ExpandAnimation ani = new ExpandAnimation(dummyView, info.dummyHeight, 0, info); ani.Duration = ANIMATION_DURATION; ExpandableAnimationListener collapseAnimationListener = new ExpandableAnimationListener(this, state, groupPosition, dummyView, listView, info); ani.SetAnimationListener(collapseAnimationListener); dummyView.StartAnimation(ani); dummyView.Tag = STATE_COLLAPSING; } return(convertView); } else { return(GetRealChildView(groupPosition, childPosition, isLastChild, convertView, parent)); } }
public void VerifyBaseMethodThrowsIfInvokedWithNullParameters() { DummyView nullView = null; DummyView valueView = new DummyView(); DummyVm nullVm = null; DummyVm valueVm = new DummyVm(); Should.Throw<ArgumentNullException>( () => BindingCore.CreateBinding(nullView, valueVm, vm => vm.DummyProperty, (m, t) => m.TextProperty = t)); Should.Throw<ArgumentNullException>( () => BindingCore.CreateBinding(valueView, nullVm, vm => vm.DummyProperty, (m, t) => m.TextProperty = t)); Should.Throw<ArgumentNullException>( () => BindingCore.CreateBinding<DummyView, DummyVm, string>(valueView, valueVm, null, (m, t) => m.TextProperty = t)); Should.Throw<ArgumentNullException>( () => BindingCore.CreateBinding(valueView, valueVm, vm => vm.DummyProperty, null)); var binding = BindingCore.CreateBinding(valueView, valueVm, vm => vm.DummyProperty, (m, t) => m.TextProperty = t); binding.ShouldNotBeNull(); }
public void VerifyBaseMethodDisposeWhenReferenceIsLost() { var view = new DummyView(); var vm = new DummyVm(); int called = 0; BindingCore.CreateBinding(view, vm, d => d.DummyProperty, (dummyView, s) => { dummyView.TextProperty = s; called++; }); called.ShouldBe(1); vm.DummyProperty = "Random value"; called.ShouldBe(2); view = null; GC.Collect(); vm.DummyProperty = "Random value number 2"; called.ShouldBe(2); }
/** * Override {@link #getChildView(int, int, bool, View, ViewGroup)} instead. */ public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) { try { GroupInfo info = getGroupInfo(groupPosition); info.ChildViewCallCount += 1;; if (info.animating) { // If this group is animating, return the a DummyView... if (convertView is DummyView == false) { convertView = new DummyView(parent.Context); convertView.LayoutParameters = new AbsListView.LayoutParams(LayoutParams.MatchParent, 0); } if (childPosition < info.firstChildPosition) { // The reason why we do this is to support the collapse // this group when the group view is not visible but the // children of this group are. When notifyDataSetChanged // is called, the ExpandableListView tries to keep the // list position the same by saving the first visible item // and jumping back to that item after the views have been // refreshed. Now the problem is, if a group has 2 items // and the first visible item is the 2nd child of the group // and this group is collapsed, then the dummy view will be // used for the group. But now the group only has 1 item // which is the dummy view, thus when the ListView is trying // to restore the scroll position, it will try to jump to // the second item of the group. But this group no longer // has a second item, so it is forced to jump to the next // group. This will cause a very ugly visual glitch. So // the way that we counteract this is by creating as many // dummy views as we need to maintain the scroll position // of the ListView after notifyDataSetChanged has been // called. convertView.LayoutParameters.Height = 0; return(convertView); } AnimatedExpandableListView listView = (AnimatedExpandableListView)parent; DummyView dummyView = (DummyView)convertView; // Clear the views that the dummy view draws. dummyView.clearViews(); // Set the style of the divider dummyView.setDivider(listView.Divider, parent.MeasuredWidth, listView.DividerHeight); // Make measure specs to measure child views int measureSpecW = MeasureSpec.MakeMeasureSpec(parent.Width, MeasureSpecMode.Exactly); int measureSpecH = MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified); int totalHeight = 0; int clipHeight = parent.Height; int len = getRealChildrenCount(groupPosition); for (int i = info.firstChildPosition; i < len; i++) { View childView = getRealChildView(groupPosition, i, (i == len - 1), null, parent); LayoutParams p = (LayoutParams)childView.LayoutParameters; if (p == null) { p = (AbsListView.LayoutParams)generateDefaultLayoutParams(); childView.LayoutParameters = p; } int lpHeight = p.Height; int childHeightSpec; if (lpHeight > 0) { childHeightSpec = MeasureSpec.MakeMeasureSpec(lpHeight, MeasureSpecMode.Exactly); } else { childHeightSpec = measureSpecH; } childView.Measure(measureSpecW, childHeightSpec); totalHeight += childView.MeasuredHeight; if (totalHeight < clipHeight) { // we only need to draw enough views to fool the user... dummyView.addFakeView(childView); } else { dummyView.addFakeView(childView); // if this group has too many views, we don't want to // calculate the height of everything... just do a light // approximation and break int averageHeight = totalHeight / (i + 1); totalHeight += (len - i - 1) * averageHeight; break; } } object o = dummyView.Tag; Java.Lang.Number state = o == null ? STATE_IDLE : (Java.Lang.Number)o; if (info.expanding && state != STATE_EXPANDING && info.ChildViewCallCount <= 1) //&& info.ChildViewCallCount<=1 { //new System.Threading.Thread(new System.Threading.ThreadStart(delegate //{ // _activity.RunOnUiThread(() => //{ ExpandAnimation ani = new ExpandAnimation(dummyView, 0, totalHeight, info, _activity, this); ani.Duration = this.parent.getAnimationDuration(); //ani.SetInterpolator(_activity, Android.Resource.Animation.LinearInterpolator); ani.Interpolator = new AccelerateDecelerateInterpolator(); ani.SetAnimationListener(new CustomAnimateListener(STATE_EXPANDING, groupPosition, dummyView, info, listView, this, listView.OnAnimationEnd)); //ani.FillAfter = false; dummyView.StartAnimation(ani); //ani.RepeatCount = Animation.StartOnFirstFrame; /*****************Another Animation Implementation***************** * ValueAnimator animator = ValueAnimator.OfInt(0, totalHeight); * animator.SetDuration(this.parent.getAnimationDuration()); * animator.SetInterpolator(new AccelerateDecelerateInterpolator()); * * animator.Update += (object sender, ValueAnimator.AnimatorUpdateEventArgs e) => * { * * * var value = (int)animator.AnimatedValue; * if (factor != value) * { * factor = value; * ViewGroup.LayoutParams layoutParams = dummyView.LayoutParameters; * layoutParams.Height = value; * dummyView.LayoutParameters = layoutParams; * Console.System.Diagnostics.Debug.WriteLine("Value: " + value.ToString()); * } * * }; * animator.AddListener(new CustomAnimateListener(STATE_EXPANDING, groupPosition, dummyView, info, listView, this)); * * ************************/ dummyView.Tag = STATE_EXPANDING; // }); //})).Start(); } else if (!info.expanding && state != STATE_COLLAPSING && info.ChildViewCallCount <= 1) //&& info.ChildViewCallCount<=1 { if (info.dummyHeight == -1) { info.dummyHeight = totalHeight; } //new System.Threading.Thread(new System.Threading.ThreadStart(delegate //{ // _activity.RunOnUiThread(() => //{ ExpandAnimation ani = new ExpandAnimation(dummyView, info.dummyHeight, 0, info, _activity, this); ani.Duration = this.parent.getAnimationDuration(); //ani.SetInterpolator(_activity, Android.Resource.Animation.AccelerateInterpolator); ani.Interpolator = new AccelerateDecelerateInterpolator(); ani.SetAnimationListener(new CustomAnimateListener(STATE_COLLAPSING, groupPosition, dummyView, info, listView, this, listView.OnAnimationEnd)); long i = ani.ComputeDurationHint(); dummyView.StartAnimation(ani); /**********************************Another animation implementation******************** * ValueAnimator animator = ValueAnimator.OfInt(totalHeight, 0); * animator.SetDuration(this.parent.getAnimationDuration()); * animator.SetInterpolator(new AccelerateDecelerateInterpolator()); * animator.Update += (object sender, ValueAnimator.AnimatorUpdateEventArgs e) => * { * var value = (int)animator.AnimatedValue; * if (factor != value) * { * factor = value; * ViewGroup.LayoutParams layoutParams = dummyView.LayoutParameters; * layoutParams.Height = value; * dummyView.LayoutParameters = layoutParams; * Console.System.Diagnostics.Debug.WriteLine("Value: " + value.ToString()); * } * }; * animator.AddListener(new CustomAnimateListener(STATE_COLLAPSING,groupPosition,dummyView,info,listView,this)); * animator.Start(); * ****************************************/ dummyView.Tag = STATE_COLLAPSING; // }); //})).Start(); } return(convertView); } else { info.ChildViewCallCount = 0; return(getRealChildView(groupPosition, childPosition, isLastChild, convertView, parent)); } } catch (System.Exception ex) { string s = ex.Message; CustomLogger.CustomLog("From Activity: " + BitopiSingelton.Instance.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", BitopiSingelton.Instance.User != null ? BitopiSingelton.Instance.User.UserName : ""); return(null); } }
public void VerifyBaseMethodGetsInvokedWhenPropertyChanges() { var view = new DummyView(); var vm = new DummyVm(); int called = 0; BindingCore.CreateBinding(view, vm, d => d.DummyProperty, (dummyView, s) => { dummyView.TextProperty = s; called++; }); called.ShouldBe(1); vm.DummyProperty = "Random value"; called.ShouldBe(2); vm.DummyProperty = "Random value number 2"; called.ShouldBe(3); }
public void VerifyBaseMethodThrowsIfGetValIsNotVmProperty() { DummyView view = new DummyView(); DummyVm vm = new DummyVm(); Should.Throw<ArgumentException>( () => BindingCore.CreateBinding(vm, vm, model => "1", (model, val) => model.DummyProperty = val)); var binding = BindingCore.CreateBinding(view, vm, model => model.DummyProperty, (model, val) => model.TextProperty = val); binding.ShouldNotBeNull(); }