Пример #1
0
        private void AddLastKitchenInformation(string userName)
        {
            var lastKitchenInfo = GetLastDayKitchenInfo(userName);

            if (lastKitchenInfo != null)
            {
                TableLayout.LayoutParams layoutParameters = new TableLayout.LayoutParams(
                    TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.WrapContent);
                layoutParameters.SetMargins(5, 5, 5, 5);
                layoutParameters.Weight = 1;

                SetTableHeader(layoutParameters);

                foreach (var lki in lastKitchenInfo)
                {
                    TableRow tr = new TableRow(this);
                    tr.LayoutParameters = layoutParameters;

                    TextView site = new TextView(this);
                    site.Text = lki.SiteName;
                    tr.AddView(site);

                    TextView space1 = new TextView(this);
                    space1.Text = "     ";
                    tr.AddView(space1);

                    TextView plotNo = new TextView(this);
                    plotNo.Text = lki.PlotNumber;
                    tr.AddView(plotNo);

                    TextView space2 = new TextView(this);
                    space2.Text = "     ";
                    tr.AddView(space2);

                    TextView kitchenModel = new TextView(this);
                    kitchenModel.Text = lki.KitchenModel.ToString();
                    tr.AddView(kitchenModel);

                    TextView space3 = new TextView(this);
                    space3.Text = "     ";
                    tr.AddView(space3);

                    TextView imgNo = new TextView(this);
                    imgNo.Text = lki.ImageNumber.ToString() + (lki.ImageNumber == 1 ? "pic" : "pics");
                    tr.AddView(imgNo);

                    table.AddView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent,
                                                                   TableLayout.LayoutParams.WrapContent));
                }

                // getting last kitchen images

                HttpWebRequest request = WebRequest.Create(Constant.STORAGE_URL + "/lastKitchenImages") as HttpWebRequest;
                request.Headers.Add("Authorization", "Bearer " + accessToken);

                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream       responseStream     = response.GetResponseStream();
                    StreamReader reader             = new StreamReader(responseStream);
                    var          responseFromServer = reader.ReadToEnd();

                    List <ImageViewModel> images = JsonConvert.DeserializeObject <List <ImageViewModel> >(responseFromServer);

                    CloudStorageAccount account = StorageHelpers.StorageAccount(accessToken);

                    CloudBlobClient blobClient = account.CreateCloudBlobClient();

                    CloudBlobContainer container = blobClient.GetContainerReference(Constant.IMAGE_STORAGE_CONTAINER_NAME);

                    Bitmap[] bitmaps  = new Bitmap[images.Count];
                    int      position = 0;
                    foreach (var image in images)
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            CloudBlockBlob blockBlob = container.GetBlockBlobReference(image.Name);
                            blockBlob.DownloadToStream(ms);
                            byte[] data = ms.ToArray();
                            bitmaps[position] = BitmapHelpers.DecodeSampledBitmapFromByteArray(data, 100, 100);
                        }
                        position++;
                    }

                    var gridView = FindViewById <GridView>(Resource.Id.gridView1);
                    gridView.Adapter = new ImageAdapter(this, bitmaps);
                }
            }
        }
Пример #2
0
        private void AutoComplete_ItemClick(object sender, EventArgs eventArgs)
        {
            var itemView = sender as TextView;

            if (itemView.Text == limitRows.limValueText)
            {
                autocomplete.SetText("", TextView.BufferType.Normal);
                return;
            }

            if (хdoc == null)
            {
                хdoc = XDocument.Load(Resources.GetXml(Resource.Xml.codes));
            }

            var search = itemView.Text.Split('|').Select(p => p.Trim()).ToList();

            var item  = хdoc.Root.Elements("item").Where(x => (string)x.Attribute("order") == search[0] && (string)x.Attribute("type") == search[1]).FirstOrDefault();
            var brend = item.FirstAttribute.Value;

            textView2.SetText(Html.FromHtml("<b>Бренд:</b> " + brend), TextView.BufferType.Editable);

            tableLayout.RemoveAllViewsInLayout();
            tableLayout.RemoveAllViews();

            TableLayout.LayoutParams par = new TableLayout.LayoutParams(TableLayout.LayoutParams.WrapContent, TableLayout.LayoutParams.MatchParent);
            par.SetMargins(20, 0, 20, 0);
            tableLayout.LayoutParameters = par;

            if (item != null)
            {
                var codeData = new List <string>()
                {
                    item.Attribute("series").Value,
                    item.Attribute("custom").Value,
                    item.Attribute("model").Value
                };

                var isVacon = (brend == "Vacon" ? true : false);

                txtView = new TextView(this);
                txtView.SetText(Html.FromHtml("<b>Аналог марки VLT</b>"), TextView.BufferType.Editable);
                txtView.Gravity = GravityFlags.Left;
                txtView.SetPadding(25, 25, 25, 25);
                txtView.SetTextColor(Color.Black);
                txtView.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);

                var tableRow = new TableRow(this);
                tableRow.AddView(txtView);
                tableLayout.AddView(tableRow);

                for (int i = 0; i < codeData.Count; i++)
                {
                    var txt = "<b>";
                    if (i == 0)
                    {
                        txt += "Серия:";
                    }
                    else if (i == 1)
                    {
                        txt += "Заказной код:";
                    }
                    else if (i == 2)
                    {
                        txt += "Типовой код:";
                    }
                    txt += "</b> ";

                    txtView = new TextView(this);
                    txtView.SetText(Html.FromHtml(txt + (i == 0 && isVacon ? "Micro Drive" : codeData[i])), TextView.BufferType.Editable);
                    txtView.SetBackgroundResource(Resource.Layout.finded);
                    txtView.Gravity = GravityFlags.Left;
                    txtView.SetPadding(25, 25, 25, 25);
                    txtView.SetTextColor(Color.Black);

                    tableRow = new TableRow(this);
                    tableRow.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.MatchParent);
                    tableRow.AddView(txtView);
                    tableLayout.AddView(tableRow);
                }

                if (!isVacon)
                {
                    var items = хdoc.Root.Elements("item")
                                .Where(x => (string)x.Attribute("brend") == "Vacon" &&
                                       (string)x.Attribute("custom") == item.Attribute("custom").Value &&
                                       (string)x.Attribute("series") != "VACON 10" && (string)x.Attribute("series") != "VACON NXL")
                                .ToList();

                    if (items != null && items.Count > 0)
                    {
                        txtView = new TextView(this);
                        txtView.SetText(Html.FromHtml("<b>Аналог марки Vacon</b>"), TextView.BufferType.Editable);
                        txtView.Gravity = GravityFlags.Left;
                        txtView.SetPadding(25, 50, 25, 25);
                        txtView.SetTextColor(Color.Black);
                        txtView.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);

                        tableRow = new TableRow(this);
                        tableRow.AddView(txtView);

                        tableLayout.AddView(tableRow);

                        drawItems(items, tableLayout, tableRow);
                    }
                }

                Toast.MakeText(this, "Поиск завершен", ToastLength.Short).Show();

                hideKeyBoard();

                bntSendFromMain.Visibility = ViewStates.Visible;
            }
        }
Пример #3
0
        /**
         * Programmatically build up the view hierarchy to avoid the need for resources.
         * @return View hierarchy
         */
        private View generateHierarchy(Context context)
        {
            Resources resources = this.Resources;

            FrameLayout.LayoutParams _params;
            int fivePx   = Util.dpToPx(5, resources);
            int tenPx    = Util.dpToPx(10, resources);
            int twentyPx = Util.dpToPx(20, resources);

            TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams(
                0,
                ViewGroup.LayoutParams.WrapContent,
                1f);
            tableLayoutParams.SetMargins(0, 0, fivePx, 0);
            LinearLayout seekWrapper;

            FrameLayout root = new FrameLayout(context);

            _params = new LayoutParams(ViewGroup.LayoutParams.MatchParent, Util.dpToPx(300, resources));
            root.LayoutParameters = _params;

            FrameLayout container = new FrameLayout(context);

            _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
            _params.SetMargins(0, twentyPx, 0, 0);
            container.LayoutParameters = _params;
            container.SetBackgroundColor(Color.Argb(100, 0, 0, 0));
            root.AddView(container);

            mSpringSelectorSpinner = new Spinner(context, SpinnerMode.Dialog);
            _params         = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            _params.Gravity = GravityFlags.Top;
            _params.SetMargins(tenPx, tenPx, tenPx, 0);
            mSpringSelectorSpinner.LayoutParameters = _params;
            container.AddView(mSpringSelectorSpinner);

            LinearLayout linearLayout = new LinearLayout(context);

            _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            _params.SetMargins(0, 0, 0, Util.dpToPx(80, resources));
            _params.Gravity = GravityFlags.Bottom;
            linearLayout.LayoutParameters = _params;
            linearLayout.Orientation      = Android.Widget.Orientation.Vertical;
            container.AddView(linearLayout);
            seekWrapper = new LinearLayout(context);

            _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            _params.SetMargins(tenPx, tenPx, tenPx, twentyPx);
            seekWrapper.SetPadding(tenPx, tenPx, tenPx, tenPx);
            seekWrapper.LayoutParameters = _params;
            seekWrapper.Orientation      = Android.Widget.Orientation.Horizontal;
            linearLayout.AddView(seekWrapper);

            mTensionSeekBar = new SeekBar(context);
            mTensionSeekBar.LayoutParameters = tableLayoutParams;
            seekWrapper.AddView(mTensionSeekBar);

            mTensionLabel = new TextView(Context);
            mTensionLabel.SetTextColor(mTextColor);

            _params = new LayoutParams(
                Util.dpToPx(50, resources),
                ViewGroup.LayoutParams.MatchParent);
            mTensionLabel.Gravity          = GravityFlags.CenterVertical | GravityFlags.Left;
            mTensionLabel.LayoutParameters = _params;
            mTensionLabel.SetMaxLines(1);
            seekWrapper.AddView(mTensionLabel);

            seekWrapper = new LinearLayout(context);
            _params     = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            _params.SetMargins(tenPx, tenPx, tenPx, twentyPx);
            seekWrapper.SetPadding(tenPx, tenPx, tenPx, tenPx);
            seekWrapper.LayoutParameters = _params;
            seekWrapper.Orientation      = Android.Widget.Orientation.Horizontal;
            linearLayout.AddView(seekWrapper);

            mFrictionSeekBar = new SeekBar(context);
            mFrictionSeekBar.LayoutParameters = tableLayoutParams;
            seekWrapper.AddView(mFrictionSeekBar);

            mFrictionLabel = new TextView(Context);
            mFrictionLabel.SetTextColor(mTextColor);
            _params = new LayoutParams(Util.dpToPx(50, resources), ViewGroup.LayoutParams.MatchParent);
            mFrictionLabel.Gravity          = GravityFlags.CenterVertical | GravityFlags.Left;
            mFrictionLabel.LayoutParameters = _params;
            mFrictionLabel.SetMaxLines(1);
            seekWrapper.AddView(mFrictionLabel);

            View nub = new View(context);

            _params              = new LayoutParams(Util.dpToPx(60, resources), Util.dpToPx(40, resources));
            _params.Gravity      = GravityFlags.Top | GravityFlags.Center;
            nub.LayoutParameters = _params;

            nub.SetOnTouchListener(new OnNubTouchListener()
            {
                Touch = (View, motionEvent) =>
                {
                    if (motionEvent.Action == MotionEventActions.Down)
                    {
                        togglePosition();
                    }
                    return(true);
                }
            });
            nub.SetBackgroundColor(Color.Argb(255, 0, 164, 209));
            root.AddView(nub);
            return(root);
        }
Пример #4
0
        //int count = 1;



        protected override void OnCreate(Bundle bundle)
        {
            // string path = "C:/Users/mof1/Documents/Visual Studio 2015/Projects/NDSSF/NDSSF/recordings/test.3gpp";
            System.Diagnostics.Debug.Write("------------------------->OnCreate()");
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.STE4_tokens);
            //  Context context= new Context(BaseContext);
            int borderWidth  = 10;
            int borderHeight = 5;
            int thickness    = 2;
            // LinearLayout l1 = FindViewById<LinearLayout>(Resource.Id)
            ImageView selectionBorder = BorderDrawer.generateBorderImageView(this, borderWidth, borderHeight, thickness, Color.White);

            //  string next;
            // Get our button from the layout resource,
            // and attach an event to it
            string[] array = { "sun", "moon", "try", "sun", "moon", "try" };
            int      m     = array.Length;

            LinearLayout Dp = FindViewById <LinearLayout>(Resource.Id.linearLayout1);

            LinearLayout.LayoutParams li = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            TableLayout.LayoutParams  lp = new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.WrapContent);
            TableLayout linear           = new TableLayout(this);

            //   TableRow row = FindViewById<TableRow>(Resource.Id.row1);
            TableRow.LayoutParams tableRowParams = new TableRow.LayoutParams();
            tableRowParams.SetMargins(1, 1, 1, 1);
            tableRowParams.Weight = 1;

            TableRow tableRow = new TableRow(this);

            tableRow.SetGravity(GravityFlags.Top);
            tableRow.SetBackgroundColor(Color.Black);



            for (int i = 0; i < m; i++)
            {
                TextView tv = new TextView(this);
                tv.SetBackgroundColor(Color.Gray);
                tv.SetTextColor(Color.Black);
                tv.SetTypeface(null, TypefaceStyle.Bold);
                tv.Gravity = GravityFlags.Center;


                tv.Id = i;
                //int id = tv.FindViewById<Button>(i);

                int n = tv.Id;

                //   tv.SetText(Resource.Id.textView1_tab);
                lp.SetMargins(1, 1, 1, 1);
                tv.Text = array[i];

                tv.SetWidth(50);
                tv.SetHeight(50);
                li.RightMargin  = 5;
                li.LeftMargin   = 5;
                li.TopMargin    = 5;
                li.BottomMargin = 5;
                tableRow.AddView(tv, tableRowParams);
                tableRow.SetGravity(GravityFlags.Top);
            }
            //tv.SetBackgroundColor("red");

            linear.AddView(tableRow, lp);
            Dp.AddView(linear, li);
            ImageButton next_ste5 = FindViewById <ImageButton>(Resource.Id.imageButton_next);
        }
Пример #5
0
        protected async override void OnCreate(Bundle bundle)
        {
            // string path = "C:/Users/mof1/Documents/Visual Studio 2015/Projects/NDSSF/NDSSF/recordings/test.3gpp";
            System.Diagnostics.Debug.Write("------------------------->OnCreate()");
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.STE5);
            string[] array = { "sun", "moon", "try", "sun", "moon", "try" };
            int      m     = array.Length;

            LinearLayout Dp = FindViewById <LinearLayout>(Resource.Id.linearLayout1);

            LinearLayout.LayoutParams li = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            TableLayout.LayoutParams  lp = new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.WrapContent);
            TableLayout linear           = new TableLayout(this);

            //   TableRow row = FindViewById<TableRow>(Resource.Id.row1);
            TableRow.LayoutParams tableRowParams = new TableRow.LayoutParams();
            tableRowParams.SetMargins(1, 1, 1, 1);
            tableRowParams.Weight = 1;

            TableRow tableRow = new TableRow(this);

            tableRow.SetGravity(GravityFlags.Top);
            tableRow.SetBackgroundColor(Color.Black);



            for (int i = 0; i < m; i++)
            {
                TextView tv = new TextView(this);
                tv.SetBackgroundColor(Color.Gray);
                tv.SetTextColor(Color.Black);
                tv.SetTypeface(null, TypefaceStyle.Bold);
                tv.Gravity = GravityFlags.Center;


                tv.Id = i;
                //int id = tv.FindViewById<Button>(i);

                int n = tv.Id;

                //   tv.SetText(Resource.Id.textView1_tab);
                lp.SetMargins(1, 1, 1, 1);
                tv.Text = array[i];

                tv.SetWidth(50);
                tv.SetHeight(50);
                li.RightMargin  = 5;
                li.LeftMargin   = 5;
                li.TopMargin    = 5;
                li.BottomMargin = 5;
                tableRow.AddView(tv, tableRowParams);
                tableRow.SetGravity(GravityFlags.Top);
                tv.SetBackgroundColor(Color.Beige);
                tv.SetSelectAllOnFocus(true);
                tv.RequestFocus();

                // tv.SetSelectAllOnFocus(FocusablesFlags.TouchMode);
            }
            //tv.SetBackgroundColor("red");

            linear.AddView(tableRow, lp);
            Dp.AddView(linear, li);
            //  Dp.SetGravity(GravityFlags.Top);
            // Dp.SetGravity.



            //  l1.AddView(tv);



            Toast.MakeText(this, "Database is updated", ToastLength.Short).Show();
            nlistview = FindViewById <ListView>(Resource.Id.listViewR);


            wordList = (await DataRepository.Words.GetAll());
            // wordStrings = new List<string>();

            MyServiceItemsAdapter       = new MyAdapter3(this, wordList);
            nlistview.Adapter           = MyServiceItemsAdapter;
            nlistview.FastScrollEnabled = true;
            Button btn = FindViewById <Button>(Resource.Id.button1);

            btn.Click += delegate { StartActivity(typeof(STE4_tokens)); };

            Button btn2 = FindViewById <Button>(Resource.Id.button3);

            btn2.Click += delegate { StartActivity(typeof(STE5_custom)); };
            Button btn3 = FindViewById <Button>(Resource.Id.button4);

            btn3.Click += delegate { StartActivity(typeof(tester)); };
        }