Beispiel #1
0
 public override void AddAction(string varName,
                                string strAction, string argument = "")
 {
     ActionDelegate += (arg1, arg2) => {
         UIVariable.GetAction(strAction, varName, "\"" + arg2 + "\"");
     };
 }
Beispiel #2
0
        public ImageEditor(string name, string text, Context context,
                           int width = 0, int height = 0) :
            base(UIType.CUSTOM, name)
        {
            m_data   = text;
            Context  = context;
            m_width  = width;
            m_height = height;

            Editor             = new SfImageEditor(Context);
            Editor.ImageSaved += (sender, args) => {
                if (!string.IsNullOrEmpty(m_actionDoneEdit))
                {
                    UIVariable.GetAction(m_actionDoneEdit, WidgetName, args.Location);
                }
                m_editing = false;
            };
            Editor.EndReset += (sender, args) => {
                if (m_editing)
                {
                    if (!string.IsNullOrEmpty(m_actionDoneEdit))
                    {
                        UIVariable.GetAction(m_actionDoneEdit, WidgetName, "");
                    }
                    //ActionDelegate?.Invoke(WidgetName, "");
                    m_editing = false;
                }
            };
            Editor.Visibility = ViewStates.Invisible;
            ViewX             = Editor;

            Instance = this;
        }
Beispiel #3
0
        public ImageEditor(string name, string initArg, CGRect rect) :
            base(UIType.CUSTOM, name)
        {
            m_data = initArg;
            m_rect = rect;

            m_sfImageEditor             = new SfImageEditor(m_rect);
            m_sfImageEditor.ImageSaved += (sender, args) => {
                if (!string.IsNullOrEmpty(m_actionDoneEdit))
                {
                    UIVariable.GetAction(m_actionDoneEdit, WidgetName, "\"" + args.Location + "\"");
                }
                m_editing = false;
            };
            m_sfImageEditor.EndReset += (sender, args) => {
                if (m_editing)
                {
                    if (!string.IsNullOrEmpty(m_actionDoneEdit))
                    {
                        UIVariable.GetAction(m_actionDoneEdit, WidgetName, "");
                    }
                    //ActionDelegate?.Invoke(WidgetName, "");
                    m_editing = false;
                }
            };
            m_sfImageEditor.Hidden = true;
            ViewX = m_sfImageEditor;
        }
Beispiel #4
0
        public void ExecuteAction(string arg)
        {
            Tuple <string, string> action;

            if (m_actions.TryGetValue(Name, out action))
            {
                UIVariable.GetAction(action.Item1, action.Item2, arg);
            }
        }
Beispiel #5
0
        public virtual void AddData(List <string> data, string varName, string title, string extra)
        {
            if (ViewX is UIPickerView)
            {
                UIPickerView pickerView = ViewX as UIPickerView;

                TypePickerViewModel model = pickerView.Model as TypePickerViewModel;
                if (model == null)
                {
                    model = new TypePickerViewModel(AppDelegate.GetCurrentController());
                }
                model.Data = data;

                if (!string.IsNullOrWhiteSpace(title))
                {
                    model.RowSelected += (row) => {
                        UIVariable.GetAction(title, varName, row.ToString());
                    };
                }
                if (!string.IsNullOrWhiteSpace(extra))
                {
                    var al = UtilsiOS.GetAlignment(extra);
                    model.Alignment = al.Item2;
                }

                model.SetSize((int)pickerView.Bounds.Width, (int)pickerView.Bounds.Height / 4);
                pickerView.Model = model;
            }
            else if (ViewX is UITableView)
            {
                UITableView tableView = ViewX as UITableView;

                TableViewSource source = tableView.Source as TableViewSource;
                if (source == null)
                {
                    source = new TableViewSource();
                }
                source.Data      = data;
                tableView.Source = source;
                tableView.ReloadData();
            }
            else if (m_picker != null)
            {
                TypePickerViewModel model = m_picker.Model as TypePickerViewModel;
                model.Data = data;

                if (!string.IsNullOrEmpty(extra))
                {
                    Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al =
                        UtilsiOS.GetAlignment(extra);
                    model.Alignment = al.Item2;
                }
                m_picker.Model = model;

                SetText(data[0], extra, true /* triggered */);
            }
        }
Beispiel #6
0
        public static void RunOnMainThread(string strAction, string arg1, string arg2 = null, string arg3 = null)
        {
#if  __ANDROID__
            scripting.Droid.MainActivity.TheView.RunOnUiThread(() =>
            {
#elif __IOS__
            scripting.iOS.AppDelegate.GetCurrentController().InvokeOnMainThread(() =>
            {
#endif
                UIVariable.GetAction(strAction, arg1, arg2, arg3);
#if __ANDROID__ || __IOS__
            });
#endif
        }
Beispiel #7
0
        public static void  RegisterCallbacks(string strAction)
        {
            OnIAPOK    = null;
            OnIAPError = null;

            InAppBilling.OnIAPOK += (productIds) =>
            {
                UIVariable.GetAction(strAction, "", productIds);
            };
            InAppBilling.OnIAPError += (errorStr) =>
            {
                UIVariable.GetAction(strAction, errorStr, "");
            };
            s_prevAction = strAction;
        }
Beispiel #8
0
        void ImagePicker_FinishedPickingMedia(object sender,
                                              UIImagePickerMediaPickedEventArgs e)
        {
            m_imagePicker.DismissModalViewController(true);
            var path = e.MediaUrl;

            m_sfImageEditor.Image  = e.OriginalImage;
            m_sfImageEditor.Hidden = false;

            m_editing = true;
            if (!string.IsNullOrEmpty(m_actionStarting))
            {
                UIVariable.GetAction(m_actionStarting, WidgetName, "");
            }
            //AppDelegate.GetCurrentController().ShowViewController(
            //  new ImageEditorViewController(e.OriginalImage), null);
        }
Beispiel #9
0
        public static void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (data == null)
            {
                data = mainIntent;
            }
            if ((resultCode != Result.Ok) || (data == null))
            {
                return;
            }
            if (resultCode == Result.Ok)
            {
                var uri = data.Data;
                ImageEditor.Instance.m_editing = true;
                if (!string.IsNullOrEmpty(ImageEditor.Instance.m_actionStarting))
                {
                    UIVariable.GetAction(ImageEditor.Instance.m_actionStarting, ImageEditor.Instance.WidgetName, "");
                }
                if (requestCode == SELECT_FROM_GALLERY)
                {
                    try {
                        ImageEditor.Instance.Path          = GetPathToImage(uri);
                        ImageEditor.Instance.Editor.Bitmap = BitmapFactory.DecodeFile(ImageEditor.Instance.Path);

                        //MainActivity.TheView.StartActivity(typeof(SfImageEditorActivity));
                    } catch (Exception ex) {
                        System.Console.WriteLine("Exception: " + ex);
                    }
                }
                else if (requestCode == SELECT_FROM_CAMERA)
                {
                    try {
                        mainIntent.PutExtra("image-path", m_imageCaptureUri.Path);
                        mainIntent.PutExtra("scale", true);
                        ImageEditor.Instance.Path          = m_imageCaptureUri.Path;
                        ImageEditor.Instance.Editor.Bitmap = BitmapFactory.DecodeFile(ImageEditor.Instance.Path);
                        //MainActivity.TheView.StartActivity(typeof(SfImageEditorActivity));
                    } catch (Exception ex) {
                        System.Console.WriteLine("Exception: " + ex);
                    }
                }
            }
        }
Beispiel #10
0
        public virtual void AddAction(string varName,
                                      string strAction, string argument = "")
        {
            if (!string.IsNullOrWhiteSpace(argument))
            {
                if (argument.Equals("FINISHED"))
                {
                    if (ViewX is ListView)
                    {
                        ListView listView = ViewX as ListView;
                        listView.NothingSelected += (sender, e) =>
                        {
                            UIVariable.GetAction(strAction, varName, "");
                        };
                    }
                    return;
                }
            }
            if (string.IsNullOrWhiteSpace(strAction))
            {
                return;
            }
            if (ViewX is Button)
            {
                Button button = ViewX as Button;
                button.Click += (sender, e) =>
                {
                    UIVariable.GetAction(strAction, varName, argument);
                };
            }
            else if (ViewX is EditText)
            {
                if (argument.Equals("FINISHED"))
                {
                }
                else
                {
                    EditText editText = ViewX as EditText;
                    editText.TextChanged += (sender, e) =>
                    {
                        UIVariable.GetAction(strAction, varName, e.Text.ToString());
                    };
                }
            }
            else if (ViewX is Switch)
            {
                Switch sw = ViewX as Switch;
                sw.CheckedChange += (sender, e) =>
                {
                    UIVariable.GetAction(strAction, varName, e.ToString());
                };
            }
            else if (ViewX is SeekBar)
            {
                SeekBar slider = ViewX as SeekBar;
                slider.ProgressChanged += (sender, e) =>
                {
                    UIVariable.GetAction(strAction, varName, e.Progress.ToString());
                };
            }
            else if (ViewX is NumberPicker)
            {
                NumberPicker pickerView = ViewX as NumberPicker;
                pickerView.ValueChanged += (sender, e) =>
                {
                    UIVariable.GetAction(strAction, varName, e.NewVal.ToString());
                };
            }
            else if (ViewX is Spinner)
            {
                Spinner spinner = ViewX as Spinner;
                spinner.ItemSelected += (sender, e) =>
                {
                    var adapter = spinner.Adapter as TextImageAdapter;
                    var item    = adapter != null?adapter.Position2Text(e.Position) : "";

                    UIVariable.GetAction(strAction, varName, item);
                };
            }
            else if (ViewX is ListView)
            {
                ListView listView = ViewX as ListView;
                listView.ItemClick += (sender, e) =>
                {
                    UIVariable.GetAction(strAction, varName, e.Position.ToString());
                };
            }
            else
            {
                ActionDelegate += (arg1, arg2) =>
                {
                    UIVariable.GetAction(strAction, varName, arg2);
                };
            }

            m_actions[Name] = new Tuple <string, string>(strAction, varName);
        }
Beispiel #11
0
 public virtual void AddAction(string varName,
                               string strAction, string argument = "")
 {
     if (!string.IsNullOrWhiteSpace(argument))
     {
         if (argument.Equals("FINISHED"))
         {
             if (ViewX is UITextField)
             {
                 UITextField textField = ViewX as UITextField;
                 textField.EditingDidEnd += (sender, e) => {
                     UIVariable.GetAction(strAction, varName, "\"" + textField.Text + "\"");
                 };
             }
             return;
         }
     }
     if (WidgetType == UIVariable.UIType.COMBOBOX)
     {
         ActionDelegate += (arg1, arg2) => {
             UIVariable.GetAction(strAction, arg1, "\"" + arg2 + "\"");
         };
     }
     else if (ViewX is UIButton)
     {
         UIButton button = ViewX as UIButton;
         button.TouchUpInside += (sender, e) => {
             UIVariable.GetAction(strAction, varName, "\"" + argument + "\"");
         };
     }
     else if (ViewX is UISwitch)
     {
         UISwitch sw = ViewX as UISwitch;
         sw.ValueChanged += (sender, e) => {
             UIVariable.GetAction(strAction, varName, "\"" + sw.On + "\"");
         };
     }
     else if (ViewX is UITextField)
     {
         UITextField textField = ViewX as UITextField;
         textField.EditingChanged += (sender, e) => {
             UIVariable.GetAction(strAction, varName, "\"" + textField.Text + "\"");
         };
     }
     else if (ViewX is UISlider)
     {
         UISlider slider = ViewX as UISlider;
         slider.ValueChanged += (sender, e) => {
             UIVariable.GetAction(strAction, varName, "\"" + slider.Value + "\"");
         };
     }
     else if (ViewX is UISegmentedControl)
     {
         UISegmentedControl seg = ViewX as UISegmentedControl;
         seg.ValueChanged += (sender, e) => {
             UIVariable.GetAction(strAction, varName, "\"" + seg.SelectedSegment + "\"");
         };
     }
     else if (ViewX is UIPickerView)
     {
         UIPickerView        pickerView = ViewX as UIPickerView;
         TypePickerViewModel model      = pickerView.Model as TypePickerViewModel;
         if (model == null)
         {
             model = new TypePickerViewModel(AppDelegate.GetCurrentController());
         }
         model.RowSelected += (row) => {
             UIVariable.GetAction(strAction, varName, row.ToString());
         };
         pickerView.Model = model;
     }
     else if (ViewX is UITableView)
     {
         UITableView     tableView = ViewX as UITableView;
         TableViewSource source    = tableView.Source as TableViewSource;
         if (source == null)
         {
             source = new TableViewSource();
         }
         source.RowSelectedDel += (row) => {
             UIVariable.GetAction(strAction, varName, "\"" + row + "\"");
         };
         tableView.Source = source;
     }
     else
     {
         ActionDelegate += (arg1, arg2) => {
             UIVariable.GetAction(strAction, varName, "\"" + arg2 + "\"");
         };
     }
 }