示例#1
0
        private void OnFormChanged(View v)
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                Console.WriteLine("Thread working in formchanged event!");
                try
                {
                    FormChanged?.Invoke(null, new XFormChangedEventArgs()
                    {
                    });

                    //handle group show/hide
                    foreach (Groups g in FormGroups)
                    {
                        View groupView = MainFormLayout.FindViewWithTag(g.id);
                        if (groupView != null)
                        {
                            Bindings binding = DLL.GetBindingByReference(g.reference);
                            if (binding != null && binding.relevant != null)
                            {
                                var eval = XForm.Evaluate(binding.relevant);
                                if (eval != null)
                                {
                                    RunOnUiThread(() => { groupView.Visibility = (bool)eval ? ViewStates.Visible : ViewStates.Gone; });
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            });
        }
        public void OnClick(IDialogInterface dialog, int which)
        {
            switch ((DialogButtonType)which)
            {
            case DialogButtonType.Positive:
                Dictionary <string, string> update = new Dictionary <string, string>
                {
                    { "operation", "patch" },
                    { "text", editView.Text },
                    { "key", editView.Tag.ToString() }
                };

                controller.DataUpdated(update);
                ((TextView)options.FindViewWithTag(editView.Tag)).Text = editView.Text;
                dialog.Dismiss();
                break;

            case DialogButtonType.Neutral:
                Dictionary <string, string> del = new Dictionary <string, string>
                {
                    { "operation", "del" },
                    { "key", editView.Tag.ToString() }
                };
                controller.DataUpdated(del);
                options.RemoveView(options.FindViewWithTag(editView.Tag));
                dialog.Dismiss();
                break;

            default:
                dialog.Dismiss();
                break;
            }
        }
示例#3
0
        private void DrawOrders()
        {
            if (schedule == null || schedule.Count == 0)
            {
                return;
            }
            var length = schedule.Count;

            for (int i = 0; i < length; i++)
            {
                FrameLayout.LayoutParams parms;
                var lineview = gridContainer.FindViewWithTag(schedule[i]["LineNum"].ToString()) as FrameLayout;
                if (lineview == null)
                {
                    continue;
                }
                var workView = new TextView(lineview.Context);
                workView.Tag = $"work{i}";
                workView.SetBackgroundColor(Color.PaleVioletRed);
                var otherworkstarttime = (DateTime)schedule[i]["Time"];
                if (Convert.ToInt32(schedule[i]["Length"]) > 0)
                {
                    parms         = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, MinToDp(Convert.ToInt32(schedule[i]["Length"])));
                    workView.Text = $"Заказ-наряд\n№{orderId}\nДлительность: {schedule[i]["Length"]} мин.";
                }
                else
                {
                    parms         = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, MinToDp(30));
                    workView.Text = $"Заказ-наряд\n№{orderId}\nДлительность: 0 мин.";
                }
                parms.TopMargin           = MinToDp((otherworkstarttime.Hour - workStart.Hour) * 60 + otherworkstarttime.Minute - workStart.Minute);
                workView.LayoutParameters = parms;
                lineview.AddView(workView);
            }
        }
示例#4
0
        private void FindDev()
        {
            try
            {
                btn_Find.Enabled = false;

                progr_bar.Visibility = ViewStates.Visible;
                wifiManager          = (WifiManager)Application.Context.GetSystemService(WifiService);
                if (!wifiManager.IsWifiEnabled)
                {
                    wifiManager.SetWifiEnabled(true);
                }

                wifiManager.StartScan();

                for (int i = 0; i < wifiManager.ScanResults.Count; i++)
                {
                    if (wifiManager.ScanResults[i].Ssid.ToString().Contains("SH_"))
                    {
                        Button exist = (Button)m_frame_control.FindViewWithTag(wifiManager.ScanResults[i].Ssid.ToString());
                        if (exist == null)
                        {
                            LinearLayout.LayoutParams leftMarginParams = new LinearLayout.LayoutParams(-1, -2);
                            Button btn1 = new Button(this);
                            btn1.Text = wifiManager.ScanResults[i].Ssid.ToString();
                            btn1.Tag  = wifiManager.ScanResults[i].Ssid.ToString();
                            btn1.SetBackgroundResource(Resource.Drawable.btn_AddDev_selector);
                            btn1.SetTextColor(new Android.Graphics.Color(0xED, 0xED, 0xED));

                            btn1.Tag    = wifiManager.ScanResults[i].Ssid.ToString();
                            btn1.Click += Btn1_Click;

                            m_frame_control.AddView(btn1, leftMarginParams);
                        }
                    }
                }
                progr_bar.Visibility = ViewStates.Invisible;
                btn_Find.Enabled     = true;
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Short);
            }
        }
        public void ShowAvailableCars(List <string> cars)
        {
            var carCount = fieldsLayout.FindViewWithTag("carListCount") as TextView;

            if (carCount == null)
            {
                var titleField = new TextView(this.Context);
                titleField.Tag = "carListCount";
                titleField.SetPadding(15, 20, 15, 20);
                titleField.SetTextColor(Color.White);
                titleField.TextSize = 14;
                titleField.SetText("Найдено автомобилей: " + cars.Count, TextView.BufferType.Normal);
                fieldsLayout.AddView(titleField);
            }
            else
            {
                carCount.Text = "Найдено автомобилей: " + cars.Count;
            }

            var carList = fieldsLayout.FindViewWithTag("carListView") as Spinner;

            if (carList == null)
            {
                var field = new Spinner(this.Context);
                field.Tag = "carListView";
                var adapter = new SpinAdapter(this.Activity, cars);
                field.Adapter       = adapter;
                field.ItemSelected += (s, e) =>
                {
                };
                //field.ItemClick += (s, e) =>
                // {
                //     e.Position
                // };

                fieldsLayout.AddView(field);
            }
            else
            {
                carList.Adapter = new SpinAdapter(this.Activity, cars);
            }
        }
示例#6
0
        public static void ChangeLayoutHorizontal(LinearLayout ll)
        {
            ll.Orientation = Orientation.Horizontal;
            //ll.WeightSum = 2;
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(WindowManagerLayoutParams.MatchParent, WindowManagerLayoutParams.WrapContent);
            //lp.SetMargins(5, 5, 5, 5);
            ll.LayoutParameters = lp;
            //have padding on bottom line
            //play with these params, take out padding
            //ll.SetPadding(5, 5, 5, 5);
            //the params for each item in the input edit area
            LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
            LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);


            EditText edit = ll.FindViewById <EditText>(Resource.Id.textEdit);

            edit.LayoutParameters = editParams;
            edit.Gravity          = GravityFlags.Right;

            TextView text = (TextView)ll.FindViewWithTag("title");

            text.LayoutParameters = textParams;
        }