Exemplo n.º 1
0
            protected override void OnCreate(ref CreateWindowPacket packet)
            {
                this.m_textBox1 = StaticBox.Create(hParent: this.Handle,
                                                   styles: WindowStyles.WS_CHILD | WindowStyles.WS_VISIBLE, exStyles: 0);

                // You can use this to create the static box like this as well.
                // But there's rarely any performance benefit in doing so, and
                // this doesn't have a WindowProc that's connected.
                this.m_textBox2 = WindowFactory.CreateExternalWindow("static", hParent: this.Handle,
                                                                     styles: WindowStyles.WS_CHILD | WindowStyles.WS_VISIBLE, exStyles: 0);

                this.m_layout.ClientArea = this.GetClientRect();
                this.m_layout.Margin     = new Rectangle(10, 10, 10, 10);
                this.m_layout.Children.Add(this.m_textBox1);
                this.m_layout.Children.Add(this.m_textBox2);
                this.m_layout.PerformLayout();

                var r = new Random();

                this.m_task = Task.Run(() =>
                {
                    while (this.m_times < Iterations)
                    {
                        this.m_times++;
                        this.SetPosition(50, 50, 1200 - r.Next(0, 1100), 900 - r.Next(0, 800));
                    }
                    this.m_endTime = DateTime.Now;
                    this.m_done    = true;
                    this.SetPosition(50, 50, 700, 500);
                });
                this.m_startTime = DateTime.Now;
                base.OnCreate(ref packet);
            }
Exemplo n.º 2
0
    public static Sizer MyDialogFunc( Window parent, bool call_fit, bool set_sizer )
    {
        BoxSizer item0 = new BoxSizer( Orientation.wxVERTICAL );

        StaticBox item2 = new StaticBox( parent, -1, "Copyright" );
        item2.Font = new wx.Font( 16, wx.FontFamily.wxROMAN, wx.FontStyle.wxNORMAL, wx.FontWeight.wxNORMAL );
        StaticBoxSizer item1 = new StaticBoxSizer( item2, Orientation.wxVERTICAL );

        StaticText item3 = new StaticText( parent, ID_TEXT, "Copyright 2002 T. Coon. 1000,- ¤.", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item3.ForegroundColour = Colour.wxBLUE;
        item3.Font = new wx.Font( 16, wx.FontFamily.wxROMAN, wx.FontStyle.wxNORMAL, wx.FontWeight.wxNORMAL );
        item1.Add( item3, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        item0.Add( item1, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        StaticLine item4 = new StaticLine( parent, ID_LINE, Window.wxDefaultPosition, new Size(20,-1), StaticLine.wxLI_HORIZONTAL );
        item0.Add( item4, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        Button item5 = new Button( parent, Window.wxID_OK, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item0.Add( item5, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        if (set_sizer)
        {
            parent.SetSizer( item0 );
            if (call_fit)
                item0.SetSizeHints( parent );
        }

        return item0;
    }
Exemplo n.º 3
0
    public static Sizer MyDialogFunc(Window parent, bool call_fit, bool set_sizer)
    {
        BoxSizer item0 = new BoxSizer(Orientation.wxVERTICAL);

        StaticBox      item2 = new StaticBox(parent, -1, "Controls will remember their values");
        StaticBoxSizer item1 = new StaticBoxSizer(item2, Orientation.wxVERTICAL);

        FlexGridSizer item3 = new FlexGridSizer(0, 2, 0, 0);

        item3.AddGrowableCol(0);
        item3.AddGrowableCol(1);

        StaticText item4 = new StaticText(parent, ID_TEXT, "wxSpinCtrl:", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item4.Name = "TestName";
        item3.Add(item4, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        SpinCtrl item5 = new SpinCtrl(parent, ID_MY_NUMBER, "0", Window.wxDefaultPosition, new Size(130, -1), SpinCtrl.wxSP_ARROW_KEYS | SpinCtrl.wxSP_WRAP, 0, 100, 0);

        item3.Add(item5, 0, Stretch.wxGROW | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        StaticText item6 = new StaticText(parent, ID_TEXT, "wxTextCtrl:", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item3.Add(item6, 0, Alignment.wxALIGN_RIGHT | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        TextCtrl item7 = new TextCtrl(parent, ID_MY_TEXT, "", Window.wxDefaultPosition, new Size(130, -1), 0);

        item3.Add(item7, 0, Stretch.wxGROW | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        item1.Add(item3, 1, Stretch.wxGROW | Direction.wxALL, 5);

        item0.Add(item1, 0, Stretch.wxGROW | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        StaticLine item8 = new StaticLine(parent, ID_LINE, Window.wxDefaultPosition, new Size(300, -1), StaticLine.wxLI_HORIZONTAL);

        item0.Add(item8, 0, Stretch.wxGROW | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        Button item9 = new Button(parent, Window.wxID_OK, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item0.Add(item9, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        if (set_sizer)
        {
            parent.SetSizer(item0);
            if (call_fit)
            {
                item0.SetSizeHints(parent);
            }
        }

        return(item0);
    }
Exemplo n.º 4
0
    public static Sizer PageTwoFunc(Window parent, bool call_fit, bool set_sizer)
    {
        BoxSizer item0 = new BoxSizer(Orientation.wxVERTICAL);

        StaticBox      item2 = new StaticBox(parent, -1, "Checks");
        StaticBoxSizer item1 = new StaticBoxSizer(item2, Orientation.wxHORIZONTAL);

        CheckBox item3 = new CheckBox(parent, ID_CHECKBOX, "Check", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item1.Add(item3, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        CheckBox item4 = new CheckBox(parent, ID_CHECKBOX, "Check", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item1.Add(item4, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        CheckBox item5 = new CheckBox(parent, ID_CHECKBOX, "Check", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item1.Add(item5, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        item0.Add(item1, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        StaticBox      item7 = new StaticBox(parent, -1, "Buttons");
        StaticBoxSizer item6 = new StaticBoxSizer(item7, Orientation.wxVERTICAL);

        Button item8 = new Button(parent, ID_BUTTON, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item6.Add(item8, 0, Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        Button item9 = new Button(parent, ID_BUTTON, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item6.Add(item9, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        Button item10 = new Button(parent, ID_BUTTON, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item6.Add(item10, 0, Stretch.wxGROW | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        item0.Add(item6, 0, Stretch.wxGROW | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        if (set_sizer)
        {
            parent.SetSizer(item0);
            if (call_fit)
            {
                item0.SetSizeHints(parent);
            }
        }

        return(item0);
    }
Exemplo n.º 5
0
    public static Sizer frmSobre(Window parent, bool call_fit, bool set_sizer)
    {
        BoxSizer item0 = new BoxSizer(Orientation.wxVERTICAL);

        StaticBox      item2 = new StaticBox(parent, -1, "");
        StaticBoxSizer item1 = new StaticBoxSizer(item2, Orientation.wxVERTICAL);

        StaticBitmap item3 = new StaticBitmap(parent, ID_STATICBITMAP, ListaBitmaps(6), Window.wxDefaultPosition, Window.wxDefaultSize);

        item1.Add(item3, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        StaticText item4 = new StaticText(parent, ID_TEXT, "Versão: 1.0.0", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item1.Add(item4, 0, Alignment.wxALIGN_RIGHT | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        StaticText item5 = new StaticText(parent, ID_TEXT, "Todos os direitos reservados para: Henrique F. de Souza", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item1.Add(item5, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        StaticText item6 = new StaticText(parent, ID_TEXT, "Sistema integrante do projeto Livrus Virtus,", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item1.Add(item6, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        StaticText item7 = new StaticText(parent, ID_TEXT, "versão programado no wxDesigner.", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item1.Add(item7, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        item0.Add(item1, 0, Stretch.wxGROW | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        Button item8 = new Button(parent, BTN_OK, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item8.Name = "btnOk";
        item0.Add(item8, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        if (set_sizer)
        {
            // parent.SetAutoLayout( true );
            parent.SetSizer(item0);
            if (call_fit)
            {
                item0.Fit(parent);
                item0.SetSizeHints(parent);
            }
        }

        return(item0);
    }
Exemplo n.º 6
0
            protected override void OnCreate(ref CreateWindowPacket packet)
            {
                this.m_textBox = StaticBox.Create(
                    "Ahoy!",
                    hParent: this.Handle);

                this.m_editBox = EditBox.Create(
                    "Nothing here yet.",
                    hParent: this.Handle,
                    controlStyles:
                    EditBox.EditStyles.ES_MULTILINE | EditBox.EditStyles.ES_WANTRETURN |
                    (EditBox.EditStyles)WindowStyles.WS_VSCROLL);

                this.m_layout.ClientArea = this.GetClientRect();
                this.m_layout.Margin     = new Rectangle(10, 10, 10, 10);
                this.m_layout.Children.Add(this.m_textBox);
                this.m_layout.Children.Add(this.m_editBox);
                this.m_layout.PerformLayout();
                this.m_timerProc = (wnd, uMsg, eventId, millis) =>
                {
                    try
                    {
                        this.m_timesExecuted++;
                        Input.InitKeyboardInput(out this.m_inputs[0], VirtualKey.H, false);
                        Input.InitKeyboardInput(out this.m_inputs[1], VirtualKey.H, true);
                        Input.InitKeyboardInput(out this.m_inputs[3], VirtualKey.E, false);
                        Input.InitKeyboardInput(out this.m_inputs[4], VirtualKey.E, true);
                        Input.InitKeyboardInput(out this.m_inputs[5], VirtualKey.L, false);
                        Input.InitKeyboardInput(out this.m_inputs[6], VirtualKey.L, true);
                        Input.InitKeyboardInput(out this.m_inputs[7], VirtualKey.L, false);
                        Input.InitKeyboardInput(out this.m_inputs[8], VirtualKey.L, true);
                        Input.InitKeyboardInput(out this.m_inputs[9], VirtualKey.O, false);
                        Input.InitKeyboardInput(out this.m_inputs[10], VirtualKey.O, true);
                        var x = User32Helpers.SendInput(this.m_inputs);
                    }
                    catch (Exception ex) {
                        this.m_editBox.SetText($"ERROR: {ex.Message}\r\n{ex.StackTrace}");
                    }
                };

                this.m_timerId = User32Methods.SetTimer(this.Handle, IntPtr.Zero, 20, this.m_timerProc);
                base.OnCreate(ref packet);
            }
Exemplo n.º 7
0
    public static Sizer MyDialogFunc( Window parent, bool call_fit, bool set_sizer )
    {
        BoxSizer item0 = new BoxSizer( Orientation.wxVERTICAL );

        StaticBox item2 = new StaticBox( parent, -1, "Controls will remember their values" );
        StaticBoxSizer item1 = new StaticBoxSizer( item2, Orientation.wxVERTICAL );

        FlexGridSizer item3 = new FlexGridSizer( 0, 2, 0, 0 );
        item3.AddGrowableCol( 0 );
        item3.AddGrowableCol( 1 );

        StaticText item4 = new StaticText( parent, ID_TEXT, "wxSpinCtrl:", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item4.Name = "TestName";
        item3.Add( item4, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        SpinCtrl item5 = new SpinCtrl( parent, ID_MY_NUMBER, "0", Window.wxDefaultPosition, new Size(130,-1), SpinCtrl.wxSP_ARROW_KEYS|SpinCtrl.wxSP_WRAP, 0, 100, 0 );
        item3.Add( item5, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        StaticText item6 = new StaticText( parent, ID_TEXT, "wxTextCtrl:", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item3.Add( item6, 0, Alignment.wxALIGN_RIGHT|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        TextCtrl item7 = new TextCtrl( parent, ID_MY_TEXT, "", Window.wxDefaultPosition, new Size(130,-1), 0 );
        item3.Add( item7, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        item1.Add( item3, 1, Stretch.wxGROW|Direction.wxALL, 5 );

        item0.Add( item1, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        StaticLine item8 = new StaticLine( parent, ID_LINE, Window.wxDefaultPosition, new Size(300,-1), StaticLine.wxLI_HORIZONTAL );
        item0.Add( item8, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        Button item9 = new Button( parent, Window.wxID_OK, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item0.Add( item9, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        if (set_sizer)
        {
            parent.SetSizer( item0 );
            if (call_fit)
                item0.SetSizeHints( parent );
        }

        return item0;
    }
Exemplo n.º 8
0
    public static Sizer MyDialogFunc(Window parent, bool call_fit, bool set_sizer)
    {
        BoxSizer item0 = new BoxSizer(Orientation.wxVERTICAL);

        StaticBox item2 = new StaticBox(parent, -1, "Copyright");

        item2.Font = new wx.Font(16, wx.FontFamily.wxROMAN, wx.FontStyle.wxNORMAL, wx.FontWeight.wxNORMAL);
        StaticBoxSizer item1 = new StaticBoxSizer(item2, Orientation.wxVERTICAL);

        StaticText item3 = new StaticText(parent, ID_TEXT, "Copyright 2002 T. Coon. 1000,- ¤.", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item3.ForegroundColour = Colour.wxBLUE;
        item3.Font             = new wx.Font(16, wx.FontFamily.wxROMAN, wx.FontStyle.wxNORMAL, wx.FontWeight.wxNORMAL);
        item1.Add(item3, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        item0.Add(item1, 0, Stretch.wxGROW | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        StaticLine item4 = new StaticLine(parent, ID_LINE, Window.wxDefaultPosition, new Size(20, -1), StaticLine.wxLI_HORIZONTAL);

        item0.Add(item4, 0, Stretch.wxGROW | Alignment.wxALIGN_CENTER_VERTICAL | Direction.wxALL, 5);

        Button item5 = new Button(parent, Window.wxID_OK, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0);

        item0.Add(item5, 0, Alignment.wxALIGN_CENTER | Direction.wxALL, 5);

        if (set_sizer)
        {
            parent.SetSizer(item0);
            if (call_fit)
            {
                item0.SetSizeHints(parent);
            }
        }

        return(item0);
    }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //Class which encapsulate webservices.

            /* var _autoCompleteService = new AutoCompleteService();
             *
             * _searchView = v.FindViewById<AutoCompleteTextView>(Resource.Id.SearchBox);
             *
             * _searchView.TextChanged += async (sender, e) =>
             * {
             *   try
             *   {
             *       //async call which fetch suggestin from webservices.
             *       var results = await _autoCompleteService.SearchSuggestionAsync(_searchView.Text);
             *       var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, results.ToList());
             *       _searchView.Adapter = adapter;
             *   }
             *   catch
             *   {
             *   }
             * };
             *
             * _searchView.AfterTextChanged += (sender, e) =>
             * {
             *   if (!_searchView.IsPopupShowing && _searchView.Text.Length > 0)
             *   {
             *       _searchView.ShowDropDown();
             *   }
             * };
             *
             * SetContentView(Resource.Layout.Main);
             * ////////*/

            //setting the view for the Activity
            ////////
            SetContentView(Resource.Layout.activity_container_selection);
            //Get autoComplete1 AutoCompleteTextView and btn_Hello Button control from the Main.xaml Layout.

            box_name1       = FindViewById <AutoCompleteTextView>(Resource.Id.box_name1);
            box_selection   = FindViewById <Button>(Resource.Id.box_selection);
            btn_box_registr = FindViewById <Button>(Resource.Id.btn_box_registr);
            btn_back_a      = FindViewById <ImageButton>(Resource.Id.btn_back_a);
            preloader       = FindViewById <ProgressBar>(Resource.Id.preloader);

            string dir_path = "/storage/emulated/0/Android/data/GeoGeometry.GeoGeometry/files/";

            //string array used for displayling AutoComplete Suggestion

            /*var names = new string[] { "Anoop", "Arjit", "Akshay", "Ankit", "Rakesh" };
             * //Use ArrayAdapter for filling the View in other words AutoCompleteTextView with the list of names(Array).
             * //Use SimpleSpinnerItem(Predefined layout in Android Resources) for displaying the dropdown list
             * ArrayAdapter adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, names);
             * box_name1.Adapter = adapter;*/


            ///////////

            /*SetContentView(Resource.Layout.activity_container_selection);
             *
             * box_name1 = FindViewById<AutoCompleteTextView>(Resource.Id.box_name1);
             * box_selection = FindViewById<Button>(Resource.Id.box_selection);
             * btn_back_a = FindViewById<ImageButton>(Resource.Id.btn_back_a);
             * preloader = FindViewById<ProgressBar>(Resource.Id.preloader);
             *
             * btn_back_a.Click += (s, e) =>
             * {
             *  Finish();
             * };*/
            box_name1.TextChanged += async(sender, e) =>
            {
                try
                {
                    //async call which fetch suggestin from webservices.
                    RegisterBoxModel register = new RegisterBoxModel
                    {
                        Name = box_name1.Text,
                    };

                    var myHttpClient = new HttpClient();

                    var uri = ("http://iot.tmc-centert.ru/api/container/getboxesbyname?name=" + box_name1.Text);


                    HttpResponseMessage response = await myHttpClient.GetAsync(uri);

                    AuthApiData <ListResponse <ContainerResponse> > o_data = new AuthApiData <ListResponse <ContainerResponse> >();

                    string s_result;
                    using (HttpContent responseContent = response.Content)
                    {
                        s_result = await responseContent.ReadAsStringAsync();
                    }

                    o_data = JsonConvert.DeserializeObject <AuthApiData <ListResponse <ContainerResponse> > >(s_result);
                    var o_boxes_data = o_data.ResponseData;
                    StaticBox.AddInfoObjects(o_boxes_data);

                    //запись в файл
                    using (FileStream fs = new FileStream(dir_path + "box_list.txt", FileMode.OpenOrCreate))
                    {
                        await System.Text.Json.JsonSerializer.SerializeAsync <ListResponse <ContainerResponse> >(fs, o_boxes_data);
                    }
                    //чтение данных с файла
                    using (FileStream fs = new FileStream(dir_path + "box_list.txt", FileMode.OpenOrCreate))
                    {
                        ListResponse <ContainerResponse> containers = await System.Text.Json.JsonSerializer.DeserializeAsync <ListResponse <ContainerResponse> >(fs);

                        var name = containers.Objects[0].Name;
                    }

                    var boxes = o_data.ResponseData.Objects.Select(b => new BoxNames
                    {
                        Name = b.Name
                    }).ToList();

                    int      count  = boxes.Count();
                    string[] names1 = new string[count];

                    for (int i = 0; i < boxes.Count(); i++)
                    {
                        names1[i] = boxes[i].Name;
                    }

                    ArrayAdapter adapter1 = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, names1);
                    box_name1.Adapter = adapter1;
                }
                catch
                {
                }
            };

            //box_name1.AfterTextChanged += (sender, e) =>
            //{
            //    if (!box_name1.IsPopupShowing && box_name1.Text.Length > 0)
            //    {

            //        box_name1.ShowDropDown();
            //    }
            //};

            //SetContentView(Resource.Layout.activity_container_selection);

            box_selection.Click += async delegate
            {
                preloader.Visibility = Android.Views.ViewStates.Visible;
                box_selection.Click += btn_Submit_Click;

                /*
                 * XmlSerializer serializer = new XmlSerializer(typeof(ListResponse<ContainerResponse>));
                 * //Сериализация
                 * using (FileStream fs = new FileStream(dir_path + "box_list.xml", FileMode.OpenOrCreate))
                 *  serializer.Serialize(fs,);
                 * /*
                 * ListResponse<ContainerResponse> boxess = new ListResponse<ContainerResponse>();
                 * using (FileStream fs = new FileStream(dir_path + "box_list.txt", FileMode.OpenOrCreate))
                 * {
                 * await System.Text.Json.JsonSerializer.DeserializeAsync<ListResponse<ContainerResponse>>(fs);
                 * }
                 */
                /*
                 *
                 */



                ListResponse <ContainerResponse> boxess = new ListResponse <ContainerResponse>();
                var Res = ContainerSelection.DeserializeListResponse(dir_path + "box_list.txt");
                if (Res != null)
                {
                    boxess = Res;
                }

                var name = box_selection.Text;
                var uri  = "http://iot.tmc-centert.ru/api/container/getbox?id=" + box_selection.Id;
            };

            btn_box_registr.Click += async delegate
            {
                Intent ContainerRegisterActivity = new Intent(this, typeof(Auth.RegisterBoxActivity));
                StartActivity(ContainerRegisterActivity);
                this.Finish();
            };
        }
Exemplo n.º 10
0
        private async void GetOrderParameters()
        {
            try
            {
                var o_data = new ServiceResponseObject <OrderObjectResponse <OrderParameters, SensorResponse, StageResponse> >();
                o_data = await OrderService.GetSensorParameters(StaticOrder.Order_id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    StaticBox.AddInfoSensors(o_data.ResponseData.SENSORS_STATUS);
                    StaticOrder.AddInfoOrder(o_data.ResponseData.ORDER);

                    Id.Text              = (o_data.ResponseData.ORDER.id == null) ? "неизвестно" : o_data.ResponseData.ORDER.id;
                    Weight.Text          = (o_data.ResponseData.SENSORS_STATUS.weight == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.weight;
                    Temperature.Text     = (o_data.ResponseData.SENSORS_STATUS.temperature == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.temperature;
                    Battery.Text         = (o_data.ResponseData.SENSORS_STATUS.battery == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.battery;
                    Illumination.Text    = (o_data.ResponseData.SENSORS_STATUS.illumination == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.illumination;
                    Humidity.Text        = (o_data.ResponseData.SENSORS_STATUS.humidity == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.humidity;
                    Events.Text          = (o_data.ResponseData.ORDER.event_count == null) ? "неизвестно" : StaticOrder.Event_Count + " шт.";
                    progressBar.Progress = (o_data.ResponseData.ORDER.order_stage_id == null) ? 0 : Convert.ToInt32(o_data.ResponseData.ORDER.order_stage_id);
                    if (progressBar.Progress != 0)
                    {
                        Status.Text = progressBar.Progress.ToString() + ". " + o_data.ResponseData.STAGES[progressBar.Progress - 1].name;
                    }
                    else
                    {
                        Status.Text = "неизвестно";
                    }
                    Cost.Text = (o_data.ResponseData.ORDER.payment_amount == null) ? "неизвестно" : StaticOrder.Payment_Amount + " руб.";
                    if (o_data.ResponseData.ORDER.payment_status == "1")
                    {
                        Payment.Text = "Оплачено";
                        Payment.SetTextColor(Color.ParseColor("#8EF892"));
                    }
                    else if (o_data.ResponseData.ORDER.payment_status == "0")
                    {
                        Payment.Text = "Не оплачено";
                        Payment.SetTextColor(Color.ParseColor("#EC8F9B"));
                    }
                    else
                    {
                        Payment.Text = "неизвестно";
                    }

                    if (o_data.ResponseData.SENSORS_STATUS.gate == "1")
                    {
                        Lock.Text     = "Опущена";
                        btn_Lock.Text = "Поднять";
                    }
                    else if (o_data.ResponseData.SENSORS_STATUS.gate == "0")
                    {
                        Lock.Text     = "Поднята";
                        btn_Lock.Text = "Опустить";
                    }
                    else
                    {
                        Lock.Text     = "Неизвестно";
                        btn_Lock.Text = "Неизвестно";
                    }

                    //if (o_data.ResponseData.SENSORS_STATUS.fold == "1")
                    //{
                    //    Fold.Text = "Разложен";
                    //}
                    //else if (o_data.ResponseData.SENSORS_STATUS.fold == "0")
                    //{
                    //    Fold.Text = "Сложен";
                    //}
                    //else
                    //{
                    //    Fold.Text = "Неизвестно";
                    //}

                    //if (o_data.ResponseData.SENSORS_STATUS.gate == "1")
                    //{
                    //    Gate.Text = "Закрыта";
                    //}
                    //else if (o_data.ResponseData.SENSORS_STATUS.gate == "0")
                    //{
                    //    Gate.Text = "Открыта";
                    //}
                    //else
                    //{
                    //    Gate.Text = "Неизвестно";
                    //}

                    btn_Lock.Enabled = (StaticOrder.Order_Stage_Id == "1" ||
                                        StaticOrder.Order_Stage_Id == "4" ||
                                        StaticOrder.Order_Stage_Id == "7" ||
                                        StaticOrder.Order_Stage_Id == "5" ||
                                        StaticOrder.Order_Stage_Id == "8") ? false : true;

                    btn_Pay.Enabled = (StaticOrder.Order_Stage_Id == "5") ? true : false;

                    btn_Photo.Enabled = (StaticOrder.Order_Stage_Id == "7" ||
                                         StaticOrder.Order_Stage_Id == "8" ||
                                         StaticOrder.Order_Stage_Id == "1") ? false : true;

                    btn_Video.Enabled = (StaticOrder.Order_Stage_Id == "7" ||
                                         StaticOrder.Order_Stage_Id == "8" ||
                                         StaticOrder.Order_Stage_Id == "1") ? false : true;
                }
            }
            catch (System.Exception ex)
            {
                Toast.MakeText(Activity, ex.Message, ToastLength.Long).Show();
            }
        }
Exemplo n.º 11
0
    public static Sizer PageTwoFunc( Window parent, bool call_fit, bool set_sizer )
    {
        BoxSizer item0 = new BoxSizer( Orientation.wxVERTICAL );

        StaticBox item2 = new StaticBox( parent, -1, "Checks" );
        StaticBoxSizer item1 = new StaticBoxSizer( item2, Orientation.wxHORIZONTAL );

        CheckBox item3 = new CheckBox( parent, ID_CHECKBOX, "Check", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item1.Add( item3, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        CheckBox item4 = new CheckBox( parent, ID_CHECKBOX, "Check", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item1.Add( item4, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        CheckBox item5 = new CheckBox( parent, ID_CHECKBOX, "Check", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item1.Add( item5, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        item0.Add( item1, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        StaticBox item7 = new StaticBox( parent, -1, "Buttons" );
        StaticBoxSizer item6 = new StaticBoxSizer( item7, Orientation.wxVERTICAL );

        Button item8 = new Button( parent, ID_BUTTON, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item6.Add( item8, 0, Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        Button item9 = new Button( parent, ID_BUTTON, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item6.Add( item9, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        Button item10 = new Button( parent, ID_BUTTON, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item6.Add( item10, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        item0.Add( item6, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        if (set_sizer)
        {
            parent.SetSizer( item0 );
            if (call_fit)
                item0.SetSizeHints( parent );
        }

        return item0;
    }
Exemplo n.º 12
0
        private async void GetInfoAboutBox(string dir_path)
        {
            try
            {
                ContainerResponse container = new ContainerResponse();

                //извлечение данных контейнера из файла
                //using (FileStream fs = new FileStream(dir_path + "box_data.txt", FileMode.OpenOrCreate))
                //{
                //    container = await System.Text.Json.JsonSerializer.DeserializeAsync<ContainerResponse>(fs);
                //}

                //пример чтения данных с файла
                string file_data_remember;
                using (FileStream file = new FileStream(dir_path + "box_data.txt", FileMode.Open, FileAccess.Read))
                {
                    // преобразуем строку в байты
                    byte[] array = new byte[file.Length];
                    // считываем данные
                    file.Read(array, 0, array.Length);
                    // декодируем байты в строку
                    file_data_remember = Encoding.Default.GetString(array);
                    file.Close();
                }

                container = JsonConvert.DeserializeObject <ContainerResponse>(file_data_remember);

                string name = container.Name;//!!!!


                //if(s_payment.Text == "Оплачено")
                //{
                var myHttpClient = new HttpClient();

                var uri = new Uri("http://iot.tmc-centert.ru/api/container/getbox?id=" + container.SmartBoxId);
                HttpResponseMessage response = await myHttpClient.GetAsync(uri);

                AuthApiData <BoxDataResponse> o_data = new AuthApiData <BoxDataResponse>();

                string s_result;
                using (HttpContent responseContent = response.Content)
                {
                    s_result = await responseContent.ReadAsStringAsync();
                }

                o_data = JsonConvert.DeserializeObject <AuthApiData <BoxDataResponse> >(s_result);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    if (o_data.Status == "0")
                    {
                        Toast.MakeText(this, o_data.Message, ToastLength.Long).Show();
                        BoxDataResponse exported_data = new BoxDataResponse();
                        exported_data = o_data.ResponseData;

                        StaticBox.AddInfoBox(exported_data);
                        //добавляем инфу о найденном контейнере
                        //container_name.Text = exported_data.Name.ToString();
                        //container_name.Text = name;

                        s_temperature.Text  = exported_data.Temperature;
                        s_light.Text        = exported_data.Light.ToString();
                        s_humidity.Text     = exported_data.Wetness;
                        StaticBox.Longitude = exported_data.Longitude;
                        StaticBox.Latitude  = exported_data.Latitude;
                        s_longitude.Text    = StaticBox.Longitude.ToString();
                        s_latitude.Text     = StaticBox.Latitude.ToString();
                        //coordinates lat lon
                        s_weight.Text = "100.0";
                        //progressBar.Progress = 6;

                        Text3.Text = "ПИН-код доступа отобразится после оплаты";

                        //status_view.Text = "6. Ожидание выгрузки";
                        if (s_payment.Text == "Оплачено")
                        {
                            s_pin_access_code.Text = (exported_data.Code == null) ? "0000" : "1324";// !!!!
                        }
                        else
                        {
                            s_pin_access_code.Text = "****";
                        }
                        if (exported_data.IsOpenedDoor.ToString() == "true")
                        {
                            s_lock_unlock_door.Text = "разблокирована";
                        }
                        else
                        {
                            s_lock_unlock_door.Text = "заблокирована";
                        }
                        s_cost.Text = "39537.5";


                        //var boxState = s_open_close_container.Text;
                        //var doorState = s_lock_unlock_door.Text;
                    }
                    else
                    {
                        Toast.MakeText(this, o_data.Message, ToastLength.Long).Show();
                    }
                }

                //else if(s_payment.Text == "Не оплачено")
                //{
                //    s_temperature.Text = "****";
                //    s_light.Text = "****";
                //    s_humidity.Text = "****";
                //    s_weight.Text = "****";
                //    s_pin_access_code.Text = "****";
                //    s_lock_unlock_door.Text = "****";
                //    s_cost.Text = "1000";
                //    container_name.Text = name;
                //    s_latitude.Text = "****";
                //    s_longitude.Text = "****";
                //}
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "" + ex.Message, ToastLength.Long).Show();
            }
        }
Exemplo n.º 13
0
        private async void GetOrderParameters()
        {
            var o_data = new ServiceResponseObject <OrderObjectResponse <OrderParameters, SensorResponse, StageResponse> >();

            StaticOrder.Order_id = StaticTask.order_id;
            o_data = await OrderService.GetSensorParameters(StaticTask.order_id);

            if (o_data.Status == HttpStatusCode.OK)
            {
                Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                Id.Text           = (o_data.ResponseData.ORDER.id == null) ? "неизвестно" : o_data.ResponseData.ORDER.id;
                Weight.Text       = (o_data.ResponseData.SENSORS_STATUS.weight == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.weight;
                Temperature.Text  = (o_data.ResponseData.SENSORS_STATUS.temperature == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.temperature;
                Battery.Text      = (o_data.ResponseData.SENSORS_STATUS.battery == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.battery;
                Illumination.Text = (o_data.ResponseData.SENSORS_STATUS.illumination == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.illumination;
                Humidity.Text     = (o_data.ResponseData.SENSORS_STATUS.humidity == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.humidity;
                //Gate.Text = (o_data.ResponseData.SENSORS_STATUS.gate == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.gate;
                //Lock.Text = (o_data.ResponseData.SENSORS_STATUS.Lock == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.Lock;
                //Fold.Text = (o_data.ResponseData.SENSORS_STATUS.fold == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.fold;
                Events.Text = (o_data.ResponseData.ORDER.event_count == null) ? "неизвестно" : o_data.ResponseData.ORDER.event_count;

                StaticOrder.AddInfoOrder(o_data.ResponseData.ORDER);
                StaticBox.AddInfoSensors(o_data.ResponseData.SENSORS_STATUS);

                if (o_data.ResponseData.SENSORS_STATUS.Lock == "1")
                {
                    Lock.Text = "Закрыт";
                }
                else if (o_data.ResponseData.SENSORS_STATUS.Lock == "0")
                {
                    Lock.Text = "Открыт";
                }
                else
                {
                    Lock.Text = "Неизвестно";
                }

                if (o_data.ResponseData.SENSORS_STATUS.fold == "1")
                {
                    Fold.Text = "Разложен";
                }
                else if (o_data.ResponseData.SENSORS_STATUS.fold == "0")
                {
                    Fold.Text = "Сложен";
                }
                else
                {
                    Fold.Text = "Неизвестно";
                }

                if (o_data.ResponseData.SENSORS_STATUS.gate == "1")
                {
                    Gate.Text = "Закрыта";
                }
                else if (o_data.ResponseData.SENSORS_STATUS.gate == "0")
                {
                    Gate.Text = "Открыта";
                }
                else
                {
                    Gate.Text = "Неизвестно";
                }
            }
            else
            {
                Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
            }
        }
Exemplo n.º 14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_registerbox);


            box_name        = FindViewById <EditText>(Resource.Id.box_name);
            btn_registerbox = FindViewById <Button>(Resource.Id.btn_registerbox);
            preloader       = FindViewById <ProgressBar>(Resource.Id.preloader);
            btn_back_a      = FindViewById <ImageButton>(Resource.Id.btn_back_a);

            btn_back_a.Click += (s, e) =>
            {
                Finish();
            };

            string dir_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            string file_data_remember;


            btn_registerbox.Click += async delegate
            {
                try
                {
                    preloader.Visibility = Android.Views.ViewStates.Visible;

                    RegisterBoxModel register = new RegisterBoxModel
                    {
                        Name = box_name.Text,
                    };
                    var myHttpClient = new HttpClient();

                    var uri = new Uri("http://iot-tmc-cen.1gb.ru/api/container/create?name=" + register.Name);

                    //GetAsync
                    HttpResponseMessage response = await myHttpClient.PostAsync(uri.ToString(), new StringContent(JsonConvert.SerializeObject(register.Name), Encoding.UTF8, "application/json"));

                    string s_result;
                    using (HttpContent responseContent = response.Content)
                    {
                        s_result = await responseContent.ReadAsStringAsync();
                    }
                    AuthApiData <ContainerResponse> o_data = new AuthApiData <ContainerResponse>();
                    o_data = JsonConvert.DeserializeObject <AuthApiData <ContainerResponse> >(s_result);
                    //AuthApiData <ListResponse< ContainerResponse >> o_data
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        if (o_data.Status == "0")
                        {
                            Toast.MakeText(this, o_data.Message, ToastLength.Long).Show();

                            //ListReponse<T>
                            ContainerResponse o_box_data = new ContainerResponse();
                            o_box_data = o_data.ResponseData;

                            StaticBox.AddInfoAuth(o_box_data);


                            //using (FileStream file = new FileStream(dir_path + "box_data.txt", FileMode.OpenOrCreate))
                            //{
                            //    // преобразуем строку в байты
                            //    byte[] array = Encoding.Default.GetBytes("0" + JsonConvert.SerializeObject(o_box_data));
                            //    // запись массива байтов в файл
                            //    file.Write(array, 0, array.Length);
                            //}
                            //using (FileStream fs = new FileStream(dir_path + "box_data.txt", FileMode.OpenOrCreate))
                            //{
                            //    await System.Text.Json.JsonSerializer.SerializeAsync<ContainerResponse>(fs,o_box_data);
                            //}

                            using (FileStream file = new FileStream(dir_path + "box_data.txt", FileMode.OpenOrCreate, FileAccess.Write))
                            {
                                // преобразуем строку в байты
                                byte[] array = Encoding.Default.GetBytes(JsonConvert.SerializeObject(o_box_data));
                                // запись массива байтов в файл
                                file.Write(array, 0, array.Length);
                            }
                            //using (FileStream fs = new FileStream(dir_path + "box_data.txt", FileMode.OpenOrCreate))
                            //{
                            //    ContainerResponse container = await System.Text.Json.JsonSerializer.DeserializeAsync<ContainerResponse>(fs);
                            //    var name = container.Name;
                            //}

                            preloader.Visibility = Android.Views.ViewStates.Invisible;

                            // Переход на страницу водителя.
                            Intent Driver = new Intent(this, typeof(Auth.DriverActivity));
                            Driver.PutExtra("idAction", "2");
                            StartActivity(Driver);
                        }
                        else
                        {
                            Toast.MakeText(this, o_data.Message, ToastLength.Long).Show();
                        }
                    }
                    ClearField();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "" + ex.Message, ToastLength.Long).Show();
                }
            };

            /// <summary>
            /// Метод очистки полей.
            /// </summary>
            void ClearField()
            {
                box_name.Text = "";
            }
        }
Exemplo n.º 15
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            var options = new JsonSerializerOptions
            {
                WriteIndented = true
            };

            //Class which encapsulate webservices.

            /* var _autoCompleteService = new AutoCompleteService();
             *
             * _searchView = v.FindViewById<AutoCompleteTextView>(Resource.Id.SearchBox);
             *
             * _searchView.TextChanged += async (sender, e) =>
             * {
             *   try
             *   {
             *       //async call which fetch suggestin from webservices.
             *       var results = await _autoCompleteService.SearchSuggestionAsync(_searchView.Text);
             *       var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, results.ToList());
             *       _searchView.Adapter = adapter;
             *   }
             *   catch
             *   {
             *   }
             * };
             *
             * _searchView.AfterTextChanged += (sender, e) =>
             * {
             *   if (!_searchView.IsPopupShowing && _searchView.Text.Length > 0)
             *   {
             *       _searchView.ShowDropDown();
             *   }
             * };
             *
             * SetContentView(Resource.Layout.Main);
             * ////////*/

            //setting the view for the Activity
            ////////
            SetContentView(Resource.Layout.activity_container_selection);
            //Get autoComplete1 AutoCompleteTextView and btn_Hello Button control from the Main.xaml Layout.

            box_name1     = FindViewById <AutoCompleteTextView>(Resource.Id.box_name1);
            box_selection = FindViewById <Button>(Resource.Id.box_selection);
            //btn_box_registr = FindViewById<Button>(Resource.Id.btn_box_registr);
            btn_back_a = FindViewById <ImageButton>(Resource.Id.btn_back_a);
            preloader  = FindViewById <ProgressBar>(Resource.Id.preloader);

            string dir_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            //string file_data_remember;
            //using (FileStream file = new FileStream(dir_path + "user_data.txt", FileMode.Open, FileAccess.Read))
            //{
            //        // преобразуем строку в байты
            //        byte[] array = new byte[file.Length];
            //        // считываем данные
            //        file.Read(array, 0, array.Length);
            //        // декодируем байты в строку
            //        file_data_remember = Encoding.Default.GetString(array);
            //        file.Close();
            // }

            var role = StaticUser.UserRole;

            //AuthResponseData user = JsonConvert.DeserializeObject<AuthResponseData>(file_data_remember);

            //if (role == "user")
            //{
            //    btn_box_registr.Visibility = ViewStates.Invisible;
            //}
            //else if(role == "driver")
            //{
            //    btn_box_registr.Visibility = ViewStates.Visible;
            //}

            //string array used for displayling AutoComplete Suggestion

            /*var names = new string[] { "Anoop", "Arjit", "Akshay", "Ankit", "Rakesh" };
             * //Use ArrayAdapter for filling the View in other words AutoCompleteTextView with the list of names(Array).
             * //Use SimpleSpinnerItem(Predefined layout in Android Resources) for displaying the dropdown list
             * ArrayAdapter adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, names);
             * box_name1.Adapter = adapter;*/

            ///////////

            /*SetContentView(Resource.Layout.activity_container_selection);
             *
             * box_name1 = FindViewById<AutoCompleteTextView>(Resource.Id.box_name1);
             * box_selection = FindViewById<Button>(Resource.Id.box_selection);
             * btn_back_a = FindViewById<ImageButton>(Resource.Id.btn_back_a);
             * preloader = FindViewById<ProgressBar>(Resource.Id.preloader);
             *
             * btn_back_a.Click += (s, e) =>
             * {
             *  Finish();
             * };*/
            box_name1.TextChanged += async(sender, e) =>
            {
                try
                {
                    //async call which fetch suggestin from webservices.
                    RegisterBoxModel register = new RegisterBoxModel
                    {
                        Name = box_name1.Text,
                    };

                    var myHttpClient = new HttpClient();

                    var uri = new Uri("http://iot.tmc-centert.ru/api/container/getboxesbyname?name=" + box_name1.Text);


                    HttpResponseMessage response = await myHttpClient.GetAsync(uri);

                    AuthApiData <ListResponse <ContainerResponse> > o_data = new AuthApiData <ListResponse <ContainerResponse> >();

                    string s_result;
                    using (HttpContent responseContent = response.Content)
                    {
                        s_result = await responseContent.ReadAsStringAsync();
                    }

                    o_data.ResponseData = new ListResponse <ContainerResponse>();
                    o_data = JsonConvert.DeserializeObject <AuthApiData <ListResponse <ContainerResponse> > >(s_result);
                    ListResponse <ContainerResponse> o_boxes_data = new ListResponse <ContainerResponse>();
                    o_boxes_data.Objects = o_data.ResponseData.Objects;

                    //StaticBox.AddInfoObjects(o_boxes_data);
                    StaticBox.AddInfoObjects(o_boxes_data);
                    //запись в file


                    //using (FileStream fs = new FileStream(dir_path + "box_list.txt", FileMode.OpenOrCreate))
                    //{
                    //    await System.Text.Json.JsonSerializer.SerializeAsync<ListResponse<ContainerResponse>>(fs, o_boxes_data, options);
                    //}
                    //чтение данных с файла
                    //using (FileStream fs = new FileStream(dir_path + "box_list.txt", FileMode.OpenOrCreate))
                    //{
                    //    ListResponse<ContainerResponse> containers = await System.Text.Json.JsonSerializer.DeserializeAsync<ListResponse<ContainerResponse>>(fs);

                    //    var name = containers.Objects[0].Name;
                    //}

                    var boxes = o_data.ResponseData.Objects.Select(b => new BoxNames
                    {
                        Name = b.Name
                    }).ToList();

                    int      count  = boxes.Count();
                    string[] names1 = new string[count];

                    var name4 = box_selection.Text;

                    for (int i = 0; i < boxes.Count(); i++)
                    {
                        names1[i] = boxes[i].Name;
                    }

                    ArrayAdapter adapter1 = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, names1);
                    box_name1.Adapter = adapter1;
                }
                catch
                {
                }
            };

            //box_name1.AfterTextChanged += (sender, e) =>
            //{
            //    if (!box_name1.IsPopupShowing && box_name1.Text.Length > 0)
            //    {

            //        box_name1.ShowDropDown();
            //    }
            //};

            //SetContentView(Resource.Layout.activity_container_selection);

            box_selection.Click += async delegate
            {
                preloader.Visibility = Android.Views.ViewStates.Visible;
                box_selection.Click += btn_Submit_Click;

                /*
                 * XmlSerializer serializer = new XmlSerializer(typeof(ListResponse<ContainerResponse>));
                 * //Сериализация
                 * using (FileStream fs = new FileStream(dir_path + "box_list.xml", FileMode.OpenOrCreate))
                 *  serializer.Serialize(fs,);
                 * /*
                 * ListResponse<ContainerResponse> boxess = new ListResponse<ContainerResponse>();
                 * using (FileStream fs = new FileStream(dir_path + "box_list.txt", FileMode.OpenOrCreate))
                 * {
                 * await System.Text.Json.JsonSerializer.DeserializeAsync<ListResponse<ContainerResponse>>(fs);
                 * }
                 */
                /*
                 *
                 */



                //ListResponse<ContainerResponse> boxess = new ListResponse<ContainerResponse>();
                //var Res = ContainerSelection.DeserializeListResponse(dir_path + "box_list.txt");
                //if (Res!=null)
                //{
                //    boxess = Res;
                //}

                ContainerResponse box = new ContainerResponse();
                ListResponse <ContainerResponse> boxes = new ListResponse <ContainerResponse>();
                foreach (var box1 in StaticBox.Objects)
                {
                    boxes.Objects.Add(box1);
                }
                box = boxes.Objects.Where(f => f.Name == box_name1.Text).FirstOrDefault();

                //using (FileStream fs = new FileStream(dir_path + "box_list.txt", FileMode.OpenOrCreate))
                //{
                //    Objects = (ListResponse<ContainerResponse>)await System.Text.Json.JsonSerializer.DeserializeAsync<ListResponse<ContainerResponse>>(fs);
                //    box = Objects.Objects.Where(f => f.Name == box_name1.Text).FirstOrDefault();
                //}

                //using (FileStream fs = new FileStream(dir_path + "box_data.txt", FileMode.OpenOrCreate))
                //{
                //    await System.Text.Json.JsonSerializer.SerializeAsync<ContainerResponse>(fs, box);
                //}

                using (FileStream file = new FileStream(dir_path + "box_data.txt", FileMode.OpenOrCreate, FileAccess.Write))
                {
                    // преобразуем строку в байты
                    byte[] array = Encoding.Default.GetBytes(JsonConvert.SerializeObject(box));
                    // запись массива байтов в файл
                    file.Write(array, 0, array.Length);
                }


                //using (FileStream ddd = new FileStream(dir_path + "box_list.txt", FileMode.OpenOrCreate))
                //{

                //    await System.Text.Json.JsonSerializer.SerializeAsync<ContainerResponse>(ddd, box);

                //}
                if (role == "driver")
                {
                    Intent Driver = new Intent(this, typeof(Auth.DriverActivity));
                    Driver.PutExtra("idAction", "2");// через объект идёт обращение к .
                    StartActivity(Driver);
                }
                else
                {
                    Intent UserBox = new Intent(this, typeof(Auth.ActivityUserBox));
                    UserBox.PutExtra("idMethod", "2");// через объект идёт обращение к .
                    StartActivity(UserBox);
                }

                //var box_name = box_name1.Text;
                //var uri = "http://iot.tmc-centert.ru/api/container/getbox?id=" + id;
                //этот запрос делать в драйаавер активити
            };

            //btn_box_registr.Click += async delegate
            //{
            //    Intent ContainerRegisterActivity = new Intent(this, typeof(Auth.RegisterBoxActivity));
            //    StartActivity(ContainerRegisterActivity);
            //    this.Finish();
            //};

            btn_back_a.Click += async delegate
            {
                Intent ContainerRegisterActivity = new Intent(this, typeof(Auth.RegisterBoxActivity));
                StartActivity(ContainerRegisterActivity);
                this.Finish();
            };
        }
Exemplo n.º 16
0
        private async void GetBoxParameters()
        {
            var o_data = new ServiceResponseObject <InfoBoxResponse>();

            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                o_data = await BoxService.GetInfoBox(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();

                    StaticBox.AddInfoSensors(o_data.ResponseData.SENSORS_STATUS);
                    StaticBox.AddInfoContainer(o_data.ResponseData.CONTAINER, o_data.ResponseData.EVENT_COUNT);
                    StaticBox.AddInfoAlarms(o_data.ResponseData.ALARMS_STATUS);

                    BoxTextIdValue.Text      = (o_data.ResponseData.CONTAINER.id == null) ? "неизвестно" : o_data.ResponseData.CONTAINER.id;
                    BoxTexWeight.Text        = (o_data.ResponseData.SENSORS_STATUS.weight == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.weight;
                    BoxTextTemperature.Text  = (o_data.ResponseData.SENSORS_STATUS.temperature == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.temperature;
                    BoxTexBattery.Text       = (o_data.ResponseData.SENSORS_STATUS.battery == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.battery;
                    BoxTextIllumination.Text = (o_data.ResponseData.SENSORS_STATUS.illumination == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.illumination;
                    BoxTextHumidity.Text     = (o_data.ResponseData.SENSORS_STATUS.humidity == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.humidity;
                    BoxTextEvents.Text       = (o_data.ResponseData.EVENT_COUNT == null) ? "неизвестно" : StaticBox.event_count + " шт.";



                    if (o_data.ResponseData.SENSORS_STATUS.gate == "1")
                    {
                        //BoxTextLock.Text = "Закрыт";

                        BoxTextGate.Text = "Закрыта";
                        btn_gate.Text    = "Поднять";
                    }
                    else if (o_data.ResponseData.SENSORS_STATUS.gate == "0")
                    {
                        //BoxTextLock.Text = "Открыт";

                        BoxTextGate.Text = "Открыта";
                        btn_gate.Text    = "Опустить";
                    }
                    else
                    {
                        //BoxTextLock.Text = "Неизвестно";

                        BoxTextGate.Text = "Неизвестно";
                        btn_gate.Text    = "Неизвестно";
                        btn_gate.Enabled = false;
                    }

                    if (o_data.ResponseData.SENSORS_STATUS.fold == "1")
                    {
                        BoxTextFold.Text = "Сложен";
                        btn_fold.Text    = "Разложить";
                    }
                    else if (o_data.ResponseData.SENSORS_STATUS.fold == "0")
                    {
                        BoxTextFold.Text = "Разложен";
                        btn_fold.Text    = "Сложить";
                    }
                    else
                    {
                        BoxTextFold.Text = "Неизвестно";
                        btn_fold.Text    = "Неизвестно";
                    }
                }
                else
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// сбор информации о контейнере
        /// </summary>
        /// <param name="dir_path"></param>
        private async void GetInfoAboutBox(string dir_path)
        {
            try
            {
                ContainerResponse container = new ContainerResponse();

                //извлечение данных контейнера из файла
                //using (FileStream fs = new FileStream(dir_path + "box_data.txt", FileMode.OpenOrCreate))
                //{
                //    container = await System.Text.Json.JsonSerializer.DeserializeAsync<ContainerResponse>(fs);
                //}

                //пример чтения данных с файла
                string file_data_remember;
                using (FileStream file = new FileStream(dir_path + "box_data.txt", FileMode.Open, FileAccess.Read))
                {
                    // преобразуем строку в байты
                    byte[] array = new byte[file.Length];
                    // считываем данные
                    file.Read(array, 0, array.Length);
                    // декодируем байты в строку
                    file_data_remember = Encoding.Default.GetString(array);
                    file.Close();
                }

                container = JsonConvert.DeserializeObject <ContainerResponse>(file_data_remember);


                var myHttpClient = new HttpClient();

                var uri = new Uri("http://iot.tmc-centert.ru/api/container/getbox?id=" + container.SmartBoxId);
                HttpResponseMessage response = await myHttpClient.GetAsync(uri);

                AuthApiData <BoxDataResponse> o_data = new AuthApiData <BoxDataResponse>();

                string s_result;
                using (HttpContent responseContent = response.Content)
                {
                    s_result = await responseContent.ReadAsStringAsync();
                }

                o_data = JsonConvert.DeserializeObject <AuthApiData <BoxDataResponse> >(s_result);// !!!!
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    if (o_data.Status == "0")
                    {
                        Toast.MakeText(this, o_data.Message, ToastLength.Long).Show();
                        BoxDataResponse exported_data = new BoxDataResponse();
                        exported_data = o_data.ResponseData;


                        StaticBox.AddInfoBox(exported_data);
                        //добавляем инфу о найденном контейнере
                        container_name.Text         = container.Name;
                        s_open_close_container.Text = /*(exported_data.IsOpenedBox == false) ? "закрыт" : "раскрыт";*/ "открыт";
                        //s_weight.Text = exported_data.Weight.Replace(",",".");
                        s_weight.Text           = "100.0";
                        s_lock_unlock_door.Text = (exported_data.IsOpenedDoor == false) ? "заблокирована" : "разблокирована";
                        //progressBar.Progress = 6;
                        //status_view.Text = "6. Ожидание выгрузки";
                        var boxState  = s_open_close_container.Text;
                        var doorState = s_lock_unlock_door.Text;

                        if (exported_data.BoxState == ContainerState.onBase)
                        {
                            a_situation = "На складе";
                        }
                        else if (exported_data.BoxState == ContainerState.onCar)
                        {
                            a_situation = "На автомобиле";
                        }
                        else if (exported_data.BoxState == ContainerState.onConsignee)
                        {
                            a_situation = "Выгруженным у грузоотправителя";
                        }
                        else if (exported_data.BoxState == ContainerState.onShipper)
                        {
                            a_situation = "После разгрузки у грузополучателя";
                        }

                        s_temperature.Text        = exported_data.Temperature.Replace(",", ".");
                        s_light.Text              = exported_data.Light.ToString();
                        s_humidity.Text           = exported_data.Wetness.Replace(",", ".");
                        s_battery.Text            = exported_data.BatteryPower.Replace(",", ".");
                        btn_lock_unlock_door.Text = "Заблокировать/Разблокировать";
                        s_signal_strength.Text    = "Хороший";
                    }
                    else
                    {
                        Toast.MakeText(this, o_data.Message, ToastLength.Long).Show();
                    }
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "" + ex.Message, ToastLength.Long).Show();
            }
        }