/** * Runs a insert child operation on the current widget. * @param operation The widget operation that needs to be applied on the current widget. */ protected void InsertChild(WidgetOperation operation) { IWidget child = mRuntime.GetModule <NativeUIModule>().GetWidgetSync(operation.Handle); // child.SetParent(this); this.InsertChild(child, operation.Index); }
public AddWindow(WidgetOperation widgetOperation) { InitializeComponent(); AddWindowViewModel addWindowViewModel = new AddWindowViewModel(widgetOperation); DataContext = addWindowViewModel; }
public EditWindow(WidgetOperation widgetOperation) { InitializeComponent(); EditWindowViewModel editWindowViewModel = new EditWindowViewModel(widgetOperation); DataContext = editWindowViewModel; }
/** * Runs a WidgetOperation on the current widget. * @param operation The widget operation (could be a ADD, INSERT, REMOVE, SET or GET) that * needs to be applied on the current widget. */ public new void RunOperation(WidgetOperation operation) { switch (operation.Type) { case WidgetOperation.OperationType.SET: SetProperty(operation); break; case WidgetOperation.OperationType.ADD: AddChild(operation); break; case WidgetOperation.OperationType.INSERT: InsertChild(operation); break; case WidgetOperation.OperationType.REMOVE: RemoveChild(operation); break; case WidgetOperation.OperationType.GET: // do nothing - when a get syscall is called and the widget is not created, // the last valid set value is returned and if it doesn't exist, we wait for // the widget creation and run the get operation. A get operation never // gets into the queue break; } }
/** * Runs a add child operation on the current widget. * @param operation The widget operation that needs to be applied on the current widget. */ protected void AddChild(WidgetOperation operation) { IWidget child = mRuntime.GetModule <NativeUIModule>().GetWidgetSync(operation.Handle); child.SetParent(this); this.AddChild(child); }
public void EditWidget(object parameter) { // // create WidgetOperation object to pass with the current SelectedWidget object // open add window // WidgetOperation widgetOperation = new WidgetOperation() { Status = WidgetOperation.OperationStatus.CANCEL, Widget = SelectedWidget }; Window editWidgetWindow = new EditWindow(widgetOperation); editWidgetWindow.ShowDialog(); // // TODO consider refactoring and use a class with the Widget object and status // if (widgetOperation.Status != WidgetOperation.OperationStatus.CANCEL) { Widgets.Remove(SelectedWidget); Widgets.Add(widgetOperation.Widget); SelectedWidget = widgetOperation.Widget; } }
public EditWindowViewModel(WidgetOperation widgetOperation) { UserWidget = widgetOperation.Widget; _widgetOperation = widgetOperation; ButtonSaveCommand = new RelayCommand(new Action <object>(EditWidget)); ButtonCancelCommand = new RelayCommand(new Action <object>(CancelEditWidget)); }
/** * Runs all the operations from the operation queue. Must be run on the UI thread. */ public new void RunOperationQueue() { // run all the pending operations from the widget operation queue while (mOperationQueue.Count > 0) { WidgetOperation currentOperation = mOperationQueue.Dequeue(); RunOperation(currentOperation); } }
/** * Handles the property setting for a widget. If the widget is not yet created, the * set operation goes into the operation queue. * @param widget The widget that recieved a set property syscall. * @param propertyName The name of the property to be set. * @param propertyValue The value of the property to be set. */ public void SetProperty(IWidget widget, string propertyName, string propertyValue) { if (widget is WidgetBaseMock) { // we check to see if the property is valid Type widgetType = mRuntime.GetModule <NativeUIModule>().GetWidgetType(widget.GetHandle()); CheckPropertyValidity(widgetType, propertyName, propertyValue); WidgetOperation setOperation = WidgetOperation.CreateSetOperation(propertyName, propertyValue); widget.AddOperation(setOperation); } else { widget.SetProperty(propertyName, propertyValue); } }
/** * Handles the remove child. If the parent is not yet created, the remove operation goes into the operation * queue. If the parent exists but the child hasn't been created, we wait for the child creation and then * remove it from the parent. * @param child The child widget. */ public void RemoveChild(IWidget child) { if (child.GetParent() is WidgetBaseMock) { WidgetOperation removeChildOperation = new WidgetOperation(WidgetOperation.OperationType.REMOVE, child.GetHandle()); child.GetParent().AddOperation(removeChildOperation); } else { if (child is WidgetBaseMock) { child = mRuntime.GetModule <NativeUIModule>().GetWidgetSync(child.GetHandle()); } MoSync.Util.RunActionOnMainThread(() => { child.RemoveFromParent(); }, false); } }
public void AddWidget(object parameter) { // // create WidgetOperation object to pass // open add window // WidgetOperation widgetOperation = new WidgetOperation() { Status = WidgetOperation.OperationStatus.CANCEL, Widget = new Widget() }; Window addWdigetWindow = new AddWindow(widgetOperation); addWdigetWindow.ShowDialog(); if (widgetOperation.Status != WidgetOperation.OperationStatus.CANCEL) { Widgets.Add(widgetOperation.Widget); } }
/** * Handles the add child. If the parent is not yet created, the add operation goes into the operation * queue. If the parent exists but the child hasn't been created, we wait for the child creation and then * add it to the parent. * @param parent The parent widget. * @param child The child widget. */ public void AddChild(IWidget parent, IWidget child) { if (parent is WidgetBaseMock) { WidgetOperation addChildOperation = new WidgetOperation(WidgetOperation.OperationType.ADD, child.GetHandle()); parent.AddOperation(addChildOperation); } else { if (child is WidgetBaseMock) { child = mRuntime.GetModule <NativeUIModule>().GetWidgetSync(child.GetHandle()); } MoSync.Util.RunActionOnMainThread(() => { child.SetParent(parent); parent.AddChild(child); }, false); } }
/** * Handles the insert child. If the parent is not yet created, the insert operation goes into the operation * queue. If the parent exists but the child hasn't been created, we wait for the child creation and then * insert it into the parent. * @param parent The parent widget. * @param child The child widget. */ public void InsertChild(IWidget parent, IWidget child, int index) { if (parent is WidgetBaseMock) { WidgetOperation insertChildOperation = WidgetOperation.CreateInsertOperation(child.GetHandle(), index); parent.AddOperation(insertChildOperation); } else { if (child is WidgetBaseMock) { child = mRuntime.GetModule <NativeUIModule>().GetWidgetSync(child.GetHandle()); } MoSync.Util.RunActionOnMainThread(() => { child.SetParent(parent); parent.InsertChild(child, index); }, true); } }
/** * Handles the remove child. If the parent is not yet created, the remove operation goes into the operation * queue. If the parent exists but the child hasn't been created, we wait for the child creation and then * remove it from the parent. * @param child The child widget. */ public void RemoveChild(IWidget child) { IWidget parent = child.GetParent(); if (parent is WidgetBaseMock) { WidgetOperation removeChildOperation = WidgetOperation.CreateRemoveOperation(child.GetHandle()); parent.AddOperation(removeChildOperation); } else { if (child is WidgetBaseMock) { child = mRuntime.GetModule <NativeUIModule>().GetWidgetSync(child.GetHandle()); } MoSync.Util.RunActionOnMainThread(() => { child.RemoveFromParent(); }, true); } }
/** * Runs a set property operation on the current widget. * @param operation The widget operation that needs to be applied on the current widget. */ protected void SetProperty(WidgetOperation operation) { PropertyInfo pinfo; MoSyncWidgetPropertyAttribute pattr = GetPropertyAttribute(operation.Property, out pinfo); Exception exception = null; try { SetProperty(pinfo, operation.Value); } catch (Exception e) { exception = e; } if (null != exception) { if (exception.InnerException is InvalidPropertyValueException) { throw new InvalidPropertyValueException(); } } }
public void AddWidget(object parameter) { // // create WidgetOperation object to pass // open add window // WidgetOperation widgetOperation = new WidgetOperation() { Status = WidgetOperation.OperationStatus.CANCEL, Widget = new Widget() }; Window addWdigetWindow = new AddWindow(widgetOperation); addWdigetWindow.ShowDialog(); // // TODO consider refactoring and use a class with the Widget object and status // if (widgetOperation.Status != WidgetOperation.OperationStatus.CANCEL) { Widgets.Add(widgetOperation.Widget); } }
/** * Runs a WidgetOperation on the current widget. * @param operation The widget operation (could be a ADD, INSERT, REMOVE, SET or GET) that * needs to be applied on the current widget. */ protected void RunOperation(WidgetOperation operation) { switch (operation.Type) { case WidgetOperation.OperationType.SET: SetProperty(operation); break; case WidgetOperation.OperationType.GET: break; case WidgetOperation.OperationType.ADD: AddChild(operation); break; case WidgetOperation.OperationType.INSERT: InsertChild(operation); break; case WidgetOperation.OperationType.REMOVE: RemoveChild(operation); break; } }
/** * Runs a remove child operation on the current widget. * @param operation The widget operation that needs to be applied on the current widget. */ protected void RemoveChild(WidgetOperation operation) { IWidget child = mRuntime.GetModule<NativeUIModule>().GetWidgetSync(operation.Handle); child.RemoveFromParent(); }
/** * Runs a insert child operation on the current widget. * @param operation The widget operation that needs to be applied on the current widget. */ protected void InsertChild(WidgetOperation operation) { IWidget child = mRuntime.GetModule<NativeUIModule>().GetWidgetSync(operation.Handle); child.SetParent(this); this.InsertChild(child, operation.Index); }
/** * Runs a set property operation on the current widget. * @param operation The widget operation that needs to be applied on the current widget. */ protected void SetProperty(WidgetOperation operation) { PropertyInfo pinfo; MoSyncWidgetPropertyAttribute pattr = GetPropertyAttribute(operation.Property, out pinfo); Exception exception = null; try { SetProperty(pinfo, operation.Value); } catch (Exception e) { exception = e; } if (null != exception) if (exception.InnerException is InvalidPropertyValueException) throw new InvalidPropertyValueException(); }
/** * Runs a remove child operation on the current widget. * @param operation The widget operation that needs to be applied on the current widget. */ protected void RemoveChild(WidgetOperation operation) { IWidget child = mRuntime.GetModule <NativeUIModule>().GetWidgetSync(operation.Handle); child.RemoveFromParent(); }