Beispiel #1
0
 /// <summary>
 /// 注册通道
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Client_Load(object sender, EventArgs e)
 {
     try
     {
         //设置反序列化级别
         BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
         BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
         serverProvider.TypeFilterLevel = TypeFilterLevel.Full;//支持所有类型的反序列化,级别很高
         //信道端口
         IDictionary idic = new Dictionary <string, string>();
         idic["name"] = "clientHttp";
         idic["port"] = "0";
         HttpChannel channel = new HttpChannel(idic, clientProvider, serverProvider);
         ChannelServices.RegisterChannel(channel, false);
         _remotingObject = (IRemotingObject)Activator.GetObject(typeof(IRemotingObject), "http://localhost:8022/SumMessage");
         //_remotingObject.ServerToClient += (info, toName) => { rtxMessage.AppendText(info + "\r\n"); };
         SwapObject swap = new SwapObject();
         _remotingObject.ServerToClient += swap.ToClient;
         swap.SwapServerToClient        += (info, toName) =>
         {
             rtxMessage.Invoke((MethodInvoker)(() =>
             {
                 if (toName == txtLogin.Text || toName == "")
                 {
                     rtxMessage.AppendText(info + "\r\n");
                 }
             }));
         };
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #2
0
        public bool OnItemLongClick(AdapterView parent, Android.Views.View view, int position, long id)
        {
            var               selectedItem  = ((IList)Element.ItemsSource)[(int)id];
            SwapObject        tmpObj        = new SwapObject(view, selectedItem);
            ClipData          data          = ClipData.NewPlainText(string.Empty, string.Empty);
            DragShadowBuilder shadowBuilder = new global::Android.Views.View.DragShadowBuilder(view);

            view.StartDrag(data, shadowBuilder, tmpObj, 0);

            return(true);
        }
Beispiel #3
0
        public bool OnDrag(Android.Views.View v, Android.Views.DragEvent e)
        {
            switch (e.Action)
            {
            case Android.Views.DragAction.Started:
                break;

            case Android.Views.DragAction.Entered:
                //v.SetBackgroundColor(Android.Graphics.Color.Blue);
                break;

            case Android.Views.DragAction.Exited:
                //v.SetBackgroundColor(Android.Graphics.Color.Transparent);
                break;

            case Android.Views.DragAction.Drop:
                //v.SetBackgroundColor(Android.Graphics.Color.Transparent);
                SwapObject              passObj    = (SwapObject)e.LocalState;
                Android.Views.View      view       = passObj.View;
                object                  passedItem = passObj.Item;
                Android.Widget.ListView oldParent  = (Android.Widget.ListView)view.Parent;

                BaseAdapter sourceAdapter = (oldParent.Adapter is IWrapperListAdapter) ? ((IWrapperListAdapter)oldParent.Adapter).WrappedAdapter as BaseAdapter : ((BaseAdapter)oldParent.Adapter);


                Android.Widget.ListView newParent          = Control;
                BaseAdapter             destinationAdapter = (oldParent.Adapter is IWrapperListAdapter) ? ((IWrapperListAdapter)newParent.Adapter).WrappedAdapter as BaseAdapter : ((BaseAdapter)oldParent.Adapter);


                if (DragDropListRenderer.ListMap.ContainsKey(oldParent.Id.ToString()) && DragDropListRenderer.ListMap.ContainsKey(newParent.Id.ToString()))
                {
                    var sourceList      = (IList)DragDropListRenderer.ListMap[oldParent.Id.ToString()];
                    var destinationList = (IList)DragDropListRenderer.ListMap[newParent.Id.ToString()];

                    if (sourceList.Contains(passedItem))
                    {
                        sourceList.Remove(passedItem);
                        destinationList.Add(passedItem);
                    }

                    destinationAdapter.NotifyDataSetChanged();
                    sourceAdapter.NotifyDataSetChanged();
                }


                break;

            case Android.Views.DragAction.Ended:
                break;
            }
            return(true);
        }