/// <summary> /// Shows a Form for the specified model. /// </summary> /// <param name="rootModel">The root model.</param> /// <param name="context">The context.</param> /// <param name="settings">The optional Form settings.</param> /// <param name="rootForm">The root form.</param> public virtual void ShowWindow(object rootModel, object context = null, IDictionary <string, object> settings = null, Window rootForm = null) { #if WISEJ if (ApplicationContext.MainWindow == null && ApplicationContext.MainPage == null) #else if (ApplicationContext.MainWindow == null) #endif { var root = CreateWindow(rootModel, true, context, settings, rootForm); var applicationContext = new ApplicationContext(root); if (root.Visible) { root.Visible = false; } root.ShowDialog(); } else // modeless { var window = CreateWindow(rootModel, false, context, settings, rootForm); if (FormStartPosition.CenterParent == window.StartPosition && null != window.Owner) { window.StartPosition = FormStartPosition.Manual; window.Location = new Point( window.Owner.Location.X + (window.Owner.Width - window.Width) / 2, window.Owner.Location.Y + (window.Owner.Height - window.Height) / 2); } #if WISEJ //window.TopMost = true; window.Show(); #else Execute.OnUIThread(() => { window.Show(); }); #endif } }
/*/// <summary> * /// Shows a popup at the current mouse position. * /// </summary> * /// <param name="rootModel">The root model.</param> * /// <param name="context">The view context.</param> * /// <param name="settings">The optional popup settings.</param> * public virtual void ShowPopup(object rootModel, object context = null, * IDictionary<string, object> settings = null) * { * var popup = CreatePopup(rootModel, settings); * var view = ViewLocator.LocateForModel(rootModel, popup, context); * * popup.Child = view; * //popup.SetValue(View.IsGeneratedProperty, true); * * ViewModelBinder.Bind(rootModel, popup, null); * Action.SetTargetWithoutContext(view, rootModel); * * var activatable = rootModel as IActivate; * if (activatable != null) * { * activatable.Activate(); * } * * var deactivator = rootModel as IDeactivate; * if (deactivator != null) * { * popup.Closed += delegate { deactivator.Deactivate(true); }; * } * * popup.IsOpen = true; * popup.CaptureMouse(); * } * * /// <summary> * /// Creates a popup for hosting a popup window. * /// </summary> * /// <param name="rootModel">The model.</param> * /// <param name="settings">The optional popup settings.</param> * /// <returns>The popup.</returns> * protected virtual Popup CreatePopup(object rootModel, IDictionary<string, object> settings) * { * var popup = new Popup(); * * if (ApplySettings(popup, settings)) * { * if (!settings.ContainsKey("PlacementTarget") && !settings.ContainsKey("Placement")) * popup.Placement = PlacementMode.MousePoint; * if (!settings.ContainsKey("AllowsTransparency")) * popup.AllowsTransparency = true; * } * else * { * popup.AllowsTransparency = true; * popup.Placement = PlacementMode.MousePoint; * } * * return popup; * }*/ /// <summary> /// For the specified model, shows a Form that is supposed to be the main application form. /// </summary> /// <param name="rootModel">The root model.</param> /// <param name="context">The context.</param> /// <param name="settings">The optional Form settings.</param> public virtual void ShowMainWindow(object rootModel, object context = null, IDictionary <string, object> settings = null) { if (ApplicationContext.StartupForm != null) { Window root = CreateWindow(rootModel, true, context, settings, ApplicationContext.StartupForm); new ApplicationContext(root); } #if WINFORMS else { Window root = CreateWindow(rootModel, true, context, settings); var applicationContext = new ApplicationContext(root); Execute.OnUIThread(() => { //applicationContext.MainForm.ShowDialog(); Application.Run(applicationContext); }); } #endif }
/// <summary> /// Shows a modal dialog Form for the specified model. /// </summary> /// <param name="rootModel">The root model.</param> /// <param name="context">The context.</param> /// <param name="settings">The optional dialog settings.</param> /// <returns>The return value should denote whether the dialog result was afirmative.</returns> public virtual bool?ShowDialog(object rootModel, object context = null, IDictionary <string, object> settings = null) { DialogResult result = DialogResult.OK; Execute.OnUIThread(() => { using (var dlg = CreateWindow(rootModel, true, context, settings)) { dlg.ShowDialog(); result = dlg.DialogResult; } }); if (result == DialogResult.OK || result == DialogResult.Yes) { return(true); } if (result == DialogResult.Cancel || result == DialogResult.No) { return(true); } return(null); }
/// <summary> /// Raises a change notification indicating that all bindings should be refreshed. /// </summary> public void Refresh() { Execute.OnUIThread(() => OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, 0))); }
/// <summary> /// Inserts the item. /// </summary> /// <param name="index">The index.</param> /// <param name="item">The item.</param> protected override void InsertItem(int index, T item) { Execute.OnUIThread(() => base.InsertItem(index, item)); }
/// <summary> /// Clears the items contained by the collection. /// </summary> protected sealed override void ClearItems() { Execute.OnUIThread(ClearItemsBase); }
/// <summary> /// Removes the item at the specified position. /// </summary> /// <param name = "index">The position used to identify the item to remove.</param> protected sealed override void RemoveItem(int index) { Execute.OnUIThread(() => RemoveItemBase(index)); }
/// <summary> /// Sets the item at the specified position. /// </summary> /// <param name = "index">The index to set the item at.</param> /// <param name = "item">The item to set.</param> protected sealed override void SetItem(int index, T item) { Execute.OnUIThread(() => SetItemBase(index, item)); }
/// <summary> /// Moves the item within the collection. /// </summary> /// <param name="oldIndex">The old position of the item.</param> /// <param name="newIndex">The new position of the item.</param> protected sealed override void MoveItem(int oldIndex, int newIndex) { Execute.OnUIThread(() => MoveItemBase(oldIndex, newIndex)); }