Exemplo n.º 1
0
        private void InfoEntryTextChanged(EntryCell entry, OrderParameterType paramType, OrderParameter param, Picker infoPicker)
        {
            param.Value = entry.Text;
            if (infoData.ContainsKey (paramType.InfoType)) {
                Dictionary<string,InfoData> data = infoData [paramType.InfoType];
                if(data.Count > 0) {
                    Task.Factory.StartNew(() => {
                        int i = 0;
                        foreach(string value in data.Keys){
                            if(entry.Text == data[value].NexusId.ToString()){
                                if(infoPicker.Items.Count > i){
                                    Device.BeginInvokeOnMainThread(() => {
                                        infoPicker.SelectedIndex = i;
                                        infoPicker.Title = data[value].ToString();
                                    });
                                }
                                break;
                            }
                            i += 1;
                        }
                    });
                }
                else {
                    Device.BeginInvokeOnMainThread(() => {
                        infoPicker.Title = param.Value;
                    });
                }

            } else {
                Device.BeginInvokeOnMainThread(() => {
                    infoPicker.Title = param.Value;
                });
            }
        }
Exemplo n.º 2
0
 private void AddStringParam(OrderParameterType paramType, OrderParameter param)
 {
     EntryCell entry = new EntryCell {
         Label = paramType.Name,
         Text = param.Value
     };
     entry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
         if(e.PropertyName == "Text"){
             param.Value = entry.Text;
         }
     };
     LastSection.Add (entry);
 }
Exemplo n.º 3
0
        private void AddInfoParam(OrderParameterType paramType, OrderParameter param)
        {
            if (paramType.InfoType == 0) {
                AddIntegerParam (paramType, param);
                return;
            }

            string displayValue = string.IsNullOrWhiteSpace (param.DisplayValue) ? "Select " + paramType.Name : param.DisplayValue;
            Picker infoPicker = new Picker {
                Title = displayValue,
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor = Color.Silver
            };

            EntryCell entry = new EntryCell {
                Text = param.Value,
                Label = paramType.Name
            };

            if (string.IsNullOrWhiteSpace (param.Value)) {
                entry.Placeholder = paramType.DataType.ToString();
            }

            if (paramType.DataType != OrderType.DataTypes.String) {
                entry.Keyboard = Keyboard.Numeric;
            }

            //			entry.Completed += (sender, e) => {
            //				InfoEntryTextChanged(entry,paramType,param,infoPicker);
            //			};

            entry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if(e.PropertyName == "Text"){
                    InfoEntryTextChanged(entry,paramType,param,infoPicker);
                }
            };

            LastSection.Add (entry);
            LastSection.Add (new ViewCell { View = infoPicker });

            if (infoData.ContainsKey (paramType.InfoType)) {
                Task.Factory.StartNew (() => {
                    Dictionary<string,InfoData> data = infoData [paramType.InfoType];
                    if (data.Count > 0) {
                        int i = 0;
                        foreach (string value in data.Keys) {
                            infoPicker.Items.Add (value.ToString());
                            if (param.Value != null && param.Value == data[value].ToString()) {
                                Device.BeginInvokeOnMainThread(() => {
                                    infoPicker.SelectedIndex = i;
                                });
                            }
                            i += 1;
                        }
                    }
                });

            } else {
                Phoenix.Application.InfoManager.GetInfoDataByGroupId (paramType.InfoType, (results) => {
                    Dictionary<string,InfoData> data = new Dictionary<string,InfoData>();
                    int i = 0;
                    foreach(InfoData info in results){
                        if(!data.ContainsKey(info.ToString())){
                            data.Add(info.ToString(),info);
                            Device.BeginInvokeOnMainThread(() => {
                                infoPicker.Items.Add(info.ToString());
                                if (param.Value != null && param.Value == info.NexusId.ToString()) {
                                    infoPicker.SelectedIndex = i;
                                }
                            });
                            i += 1;
                        }
                    }
                    infoData.Add(paramType.InfoType,data);
                    if(data.Count < 1){
                        Device.BeginInvokeOnMainThread(() => {
                            infoPicker.IsEnabled = false;
                            infoPicker.IsVisible = false;
                        });
                    }
                });
            }
            infoPicker.Unfocused += (sender, e) => {
                if(infoPicker.SelectedIndex > 0){
                    if (infoData.ContainsKey (paramType.InfoType)) {
                        Dictionary<string,InfoData> data = infoData [paramType.InfoType];
                        string value = infoPicker.Items[infoPicker.SelectedIndex];
                        if(data.ContainsKey(value)){
                            param.Value = data[value].NexusId.ToString();
                            param.DisplayValue = data[value].ToString();
                            Device.BeginInvokeOnMainThread(() => {
                                entry.Text = data[value].NexusId.ToString();
                            });
                        }
                    }
                }
            };
        }
Exemplo n.º 4
0
 private void AddParameter(OrderParameterType paramType, OrderParameter param = null)
 {
     if (param == null) {
         param = new OrderParameter ();
         switch (paramType.DataType) {
         case OrderType.DataTypes.Integer:
             param.Value = "0";
             break;
         case OrderType.DataTypes.Boolean:
             param.Value = "False";
             break;
         case OrderType.DataTypes.String:
             param.Value = "";
             break;
         default:
             param.Value = "";
             break;
         }
         CurrentOrder.Parameters.Add (param);
     }
     if (paramType.InfoType > 0) {
         AddInfoParam (paramType, param);
         return;
     }
     switch (paramType.DataType) {
     case OrderType.DataTypes.Integer:
         AddIntegerParam (paramType, param);
         break;
     case OrderType.DataTypes.String:
         AddStringParam (paramType, param);
         break;
     case OrderType.DataTypes.Boolean:
         AddBooleanParam (paramType, param);
         break;
     default:
         AddIntegerParam (paramType, param);
         break;
     }
 }
Exemplo n.º 5
0
        private void AddBooleanParam(OrderParameterType paramType, OrderParameter param)
        {
            SwitchCell switchCell = new SwitchCell {
                Text = paramType.Name,
                On = param.Value == "True"
            };

            switchCell.OnChanged += (sender, e) => {
                param.Value = switchCell.On ? "True" : "False";
            };
            LastSection.Add (switchCell);
        }