当前位置: 首页>>代码示例>>C#>>正文


C# View.GetType方法代码示例

本文整理汇总了C#中Android.Views.View.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# View.GetType方法的具体用法?C# View.GetType怎么用?C# View.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Views.View的用法示例。


在下文中一共展示了View.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateEventHandler

 protected Delegate CreateEventHandler(object target, View view, MethodMapping methodMapping, out EventInfo evnt)
 {
     Delegate del = null;
     evnt = null;
     if (view != null)
     {
         evnt = view.GetType().GetEvent(methodMapping.Attribute.EventName);
         if (evnt != null)
         {
             try
             {
                 del = CreateDelegate(target, methodMapping, evnt);
             }
             catch (Exception ex)
             {
                 Geneticist.HandleError(
                     ex,
                     "Error creating delegate from '{0}' for event '{1}'.",
                     methodMapping.Method.Name,
                     methodMapping.Attribute.EventName);
             }
         }
         else
         {
             Geneticist.HandleError(
                 "Unable to find event '{0}' for method '{1}'.",
                 methodMapping.Attribute.EventName,
                 methodMapping.Method.Name);
         }
     }
     return del;
 }
开发者ID:mattleibow,项目名称:Genetics,代码行数:32,代码来源:ViewEventGene.cs

示例2: setupParent

        // hide keyboard when clicking anywhere but EditText
        protected void setupParent(View view)
        {
            //Set up touch listener for non-text box and not checkbox views to hide keyboard.
            if (!(view.OnCheckIsTextEditor()) && view.GetType() != typeof (CheckBox)
                && view.Id != Resource.Id.colorsCheckBoxesLayout)
            {
                view.Touch += (sender, args) => { hideSoftKeyboard(); };
            }

            //If a layout container, iterate over children
            if (view.GetType().BaseType == typeof(ViewGroup))
            {
                for (int i = 0; i < ((ViewGroup) view).ChildCount; i++) {
                    View innerView = ((ViewGroup) view).GetChildAt(i);
                    setupParent(innerView);
                }
            }
        }
开发者ID:TkachenkoRoman,项目名称:GoodsListApp,代码行数:19,代码来源:MainActivity.cs

示例3: Binding

    public Binding(View target, string targetProperty, object source, string sourceProperty, Func<object, object> convert, Func<object, object> convertBack)
    {
      Target = target;
      Source = source;
      TargetProperty = Target.GetType().GetProperty(targetProperty);
      SourceProperty = Source.GetType().GetProperty(sourceProperty);
      Convert = convert;
      ConvertBack = convertBack;

      Target.FocusChange += Target_FocusChange;

      var inpc = Source as INotifyPropertyChanged;
      if (inpc != null)
        inpc.PropertyChanged += Source_PropertyChanged;

      UpdateTarget();
    }
开发者ID:nschonni,项目名称:csla-svn,代码行数:17,代码来源:Binding.cs

示例4: UpdateView

        public static void UpdateView(View view, object value)
        {
            if (view != null)
            {
                string viewTypeName = view.GetType().FullName;
                switch (viewTypeName)
                {
                    // TODO: Add cases here for specialized view types, as needed
                    case "Android.Widget.ProgressBar":
                        {
                            var progressBar = (ProgressBar)view;
                            int progressValue = (int)(value ?? 0);
                            if (progressBar.Progress != progressValue) progressBar.Progress = progressValue;
                        }
                        break;

                    case "Android.Webkit.WebView":
                        {
                            var webView = (Android.Webkit.WebView)view;
                            if (value is Uri)
                            {
                                string newUrl = value.ToString();
                                if (webView.Url != newUrl) webView.LoadUrl(newUrl);
                            }
                            else
                            {
                                webView.LoadData(value == null ? "" : value.ToString(), "text/html", null);
                            }
                        }
                        break;

                    case "Macaw.UIComponents.MultiImageView":
                        {
                            if (value is Uri) value = ((Uri)value).AbsoluteUri;
                            var multiImageView = (Macaw.UIComponents.MultiImageView)view;
                            multiImageView.LoadImageList(value == null ? null : new[] { (string)value });
                            multiImageView.LoadImage(); // TODO: Update to MultiImageView 1.2 when it is published, to fix hang on no connection and to get rid of this LoadImage call.
                        }
                        break;

                    default:
                        if (view is TextView)
                        {
                            var textView = (TextView)view;
                            string text = value == null ? "" : value.ToString();
                            if (textView.Text != text) textView.Text = text;
                        }
                        else if (view is AdapterView)
                        {
                            var adapterView = (AdapterView)view;
                            var adapter = adapterView.GetAdapter() as IDataBindableListAdapter;
                            if (adapter != null)
                            {
                                int position = adapter.GetItemPosition(value);
                                if (adapterView is AbsListView)
                                {
                                    var absListView = (AbsListView)adapterView;
                                    if (!absListView.IsItemChecked(position))
                                    {
                                        absListView.SetItemChecked(position, true);
                                    }
                                }
                                else
                                {
                                    if (adapterView.SelectedItemPosition != position) adapterView.SetSelection(position);
                                }
                            }
                        }
                        else throw new NotImplementedException("View type not implemented: " + viewTypeName);
                        break;
                }
            }
        }
开发者ID:rvdplas,项目名称:QuickCross,代码行数:73,代码来源:ViewDataBindings.UI.cs

示例5: ViewDrawerIsOpenedGetDefaultValue

 private static bool ViewDrawerIsOpenedGetDefaultValue(View view, IBindingMemberInfo bindingMemberInfo)
 {
     DrawerLayout drawer = FindDrawer(view);
     if (drawer == null)
     {
         IBindingMemberInfo rootMember = BindingServiceProvider.VisualTreeManager.GetRootMember(view.GetType());
         if (rootMember != null)
             rootMember.TryObserve(view, DrawerInitializer.Instance);
         return false;
     }
     DrawerListenerImpl.GetOrAdd(drawer);
     return drawer.IsDrawerOpen(view);
 }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:13,代码来源:AppCompatModule.cs

示例6: BindViewTree

        /// <summary>
        /// Traverses the view hierarchy and updates the bindings.
        /// </summary>
        protected void BindViewTree(object dataSource, View view, IList<WeakReference> reusableBindings = null) {
            var tag = view.GetBindingTag ();

            if (tag != null) {
                if (!tag.BindingEnabled)
                    return;

                if (tag.OverrideDataSource)
                    dataSource = tag.DataSource;

                if (tag.BindingDescriptions != null) {
                    if (dataSource == null) {
                        MvxBindingTrace.Trace(
                            MvxTraceLevel.Warning,
                            "Binding view {0} with an empty data source.",
                            view.GetType().Name);
                    }

                    if (tag.Bindings.Count > 0 || dataSource != null) {
                        // Try to reuse weak reference for the tag:
                        WeakReference weakTag = null;
                        if (reusableBindings != null) {
                            for (var i = 0; i < reusableBindings.Count; i++) {
                                if (reusableBindings[i] == null)
                                    continue;
                                if (reusableBindings[i].Target == tag) {
                                    weakTag = reusableBindings[i];
                                    reusableBindings[i] = null;
                                }
                            }
                        }
                        if (weakTag == null)
                            weakTag = new WeakReference(tag);
                        _viewTags.Add(weakTag);

                        if (tag.Bindings.Count > 0) {
                            // Update old bindings only:
                            foreach (var binding in tag.Bindings) {
                                binding.DataContext = dataSource;
                            }
                        } else {
                            // Create bindings:
                            var bindings = this.GetService<IMvxBinder>()
                                .Bind(dataSource, view, tag.BindingDescriptions);
                            if (bindings != null) {
                                foreach (var binding in bindings) {
                                    tag.Bindings.Add(binding);
                                }
                            }
                        }
                    }
                }
            }

            var viewGroup = view as ViewGroup;
            if (viewGroup != null) {
                var count = viewGroup.ChildCount;
                for (var i = 0; i < count; i++) {
                    BindViewTree(dataSource, viewGroup.GetChildAt(i), reusableBindings);
                }
            }
        }
开发者ID:JoanMiro,项目名称:MvxMod,代码行数:65,代码来源:MvxActivityBindingManager.cs

示例7: GetDataContext

        protected virtual IDataContext GetDataContext(View view, Context context, IAttributeSet attrs)
        {
            var dataContext = new DataContext();
            var strings = ReadStringAttributeValue(context, attrs, Resource.Styleable.Binding, BindingAttrIndex);
            if (strings != null && strings.Count != 0)
                dataContext.Add(ViewFactoryConstants.Bindings, strings);

            SetAttributeValue(view, context, attrs, Resource.Styleable.ItemsControl,
                Resource.Styleable.ItemsControl_ItemTemplate, AttachedMemberConstants.ItemTemplate, dataContext,
                ViewFactoryConstants.ItemTemplateId);

            SetAttributeValue(view, context, attrs, Resource.Styleable.ItemsControl,
                Resource.Styleable.ItemsControl_DropDownItemTemplate, AttachedMembers.AdapterView.DropDownItemTemplate,
                dataContext,
                ViewFactoryConstants.DropDownItemTemplateId);

            SetAttributeValue(view, context, attrs, Resource.Styleable.Control,
                Resource.Styleable.Control_ContentTemplate, AttachedMemberConstants.ContentTemplate, dataContext,
                ViewFactoryConstants.ContentTemplateId);

            SetAttributeValue(view, context, attrs, Resource.Styleable.Menu,
                Resource.Styleable.Menu_MenuTemplate, AttachedMembers.Toolbar.MenuTemplate, dataContext,
                ViewFactoryConstants.MenuTemplateId);


            SetAttributeValue(view, context, attrs, Resource.Styleable.Menu,
                Resource.Styleable.Menu_PopupMenuTemplate, AttachedMembers.View.PopupMenuTemplate, dataContext,
                ViewFactoryConstants.PopupMenuTemplateId);

            strings = ReadStringAttributeValue(context, attrs, Resource.Styleable.Menu,
                new[] { Resource.Styleable.Menu_PopupMenuEvent });
            if (strings != null && strings.Count > 0)
            {
                string eventName = strings[0];
                dataContext.Add(ViewFactoryConstants.PopupMenuEvent, eventName);
                IBindingMemberInfo member = BindingServiceProvider
                    .MemberProvider
                    .GetBindingMember(view.GetType(), AttachedMembers.View.PopupMenuEvent, false, false);
                if (member != null)
                    member.SetSingleValue(view, eventName);
            }

            strings = ReadStringAttributeValue(context, attrs, Resource.Styleable.Menu,
                new[] { Resource.Styleable.Menu_PlacementTargetPath });
            if (strings != null && strings.Count > 0)
            {
                string path = strings[0];
                dataContext.Add(ViewFactoryConstants.PlacementTargetPath, path);
                IBindingMemberInfo member = BindingServiceProvider
                    .MemberProvider
                    .GetBindingMember(view.GetType(), AttachedMembers.View.PopupMenuPlacementTargetPath, false, false);
                if (member != null)
                    member.SetSingleValue(view, path);
            }

            return dataContext;
        }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:57,代码来源:ViewFactory.cs

示例8: SetAttributeValue

 private static void SetAttributeValue(View view, Context context, IAttributeSet attrs, int[] groupId,
     int requiredAttributeId, string attachedMemberName, IDataContext dataContext, DataConstant<int> constant)
 {
     int? value = ReadAttributeValueId(context, attrs, groupId, requiredAttributeId);
     if (!value.HasValue)
         return;
     dataContext.Add(constant, value.Value);
     IBindingMemberInfo member = BindingServiceProvider
         .MemberProvider
         .GetBindingMember(view.GetType(), attachedMemberName, false, false);
     if (member != null)
         member.SetSingleValue(view, value);
 }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:13,代码来源:ViewFactory.cs

示例9: AddView

		public override void AddView (View child)
		{
			try {
				base.AddView (child);
			} catch {
				Console.WriteLine ("!!!! Caught exception: Failed to add View: " + child.GetType ());
			}
		}
开发者ID:Gerhic,项目名称:Need2Park,代码行数:8,代码来源:UIView.cs

示例10: CallMappingOnView

    /**
     * Called when a view loaded and call a mapping function
     *
     * @param view         the calling view
     * @param mappedObject If available, the object to map with the view. Else add the view to mappingWaitings
     */
    public void CallMappingOnView(CarpaccioAction action, View view, Object mappedObject) {

        if (action.IsCallMapping) {

            CarpaccioLogger.d(TAG, "callMappingOnView mapping=" + mappedObject + " action=" + action.CompleteCall + " view=" + view.GetType().Name);

            string arg = action.Args[0]; //only map the first argument

            string objectName;

            string call;
            if (arg.Contains(".")) { //"$user.getName()"
                call = arg.Substring(1, arg.Length - 1); // "user.getName()"
                objectName = call.Substring(0, arg.IndexOf('.') - 1); // "user"
            } else {
                objectName = arg.Substring(1, arg.Length - 1); // "user"
                call = objectName; // "user"
            }

            //if you already have the object
            if (mappedObject != null) {
                string value = Evaluate(mappedObject, call);

                CarpaccioLogger.d(TAG, "callMappingOnView evaluate(" + call + ")" + " on " + mappedObject.GetType().Name + " returned " + value);

                action.Values = new[]{value}; //TODO

                MappingManagerCallback.CallActionOnView(action, view);
            } else {
                //add to waiting
                List<MappingWaiting> waitings = MappingWaitings.GetOrDefault(objectName) ?? new List<MappingWaiting>(); //["user"] = List<MappingWaiting>
	            waitings.Add(new MappingWaiting(view, action, call, objectName));

                CarpaccioLogger.d(TAG, "added to waiting " + call + " for " + view.GetType().Name);

                MappingWaitings.AddOrUpdate(objectName, waitings);
            }
        }
    }
开发者ID:Julien-Mialon,项目名称:MaterialViewPager.Xamarin,代码行数:45,代码来源:MappingManager.cs

示例11: UpdateView

        public static void UpdateView(View view, object value)
        {
            if (view != null)
            {
                string viewTypeName = view.GetType().FullName;
                switch (viewTypeName)
                {
                    // TODO: Add cases here for specialized view types, as needed
                    case "Android.Widget.ProgressBar":
                        {
                            var progressBar = (ProgressBar)view;
                            int progressValue = (int)(value ?? 0);
                            if (progressBar.Progress != progressValue) progressBar.Progress = progressValue;
                        }
                        break;

                    case "Android.Webkit.WebView":
                        {
                            var webView = (Android.Webkit.WebView)view;
                            if (value is Uri)
                            {
                                string newUrl = value.ToString();
                                if (webView.Url != newUrl) webView.LoadUrl(newUrl);
                            }
                            else
                            {
                                webView.LoadData(value == null ? "" : value.ToString(), "text/html", null);
                            }
                        }
                        break;

                    default:
                        if (view is TextView)
                        {
                            var textView = (TextView)view;
                            string text = value == null ? "" : value.ToString();
                            if (textView.Text != text) textView.Text = text;
                        }
                        else if (view is AdapterView)
                        {
                            var adapterView = (AdapterView)view;
                            var adapter = adapterView.GetAdapter() as IDataBindableListAdapter;
                            if (adapter != null)
                            {
                                int position = adapter.GetItemPosition(value);
                                if (adapterView is AbsListView)
                                {
                                    var absListView = (AbsListView)adapterView;
                                    if (!absListView.IsItemChecked(position))
                                    {
                                        absListView.SetItemChecked(position, true);
                                    }
                                }
                                else
                                {
                                    if (adapterView.SelectedItemPosition != position) adapterView.SetSelection(position);
                                }
                            }
                        }
                        else throw new NotImplementedException("View type not implemented: " + viewTypeName);
                        break;
                }
            }
        }
开发者ID:rvdplas,项目名称:QuickCross,代码行数:64,代码来源:ViewDataBindings.UI.cs


注:本文中的Android.Views.View.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。