public void Close(bool modalResult = false) { if (OnClosing(modalResult)) { IsClosed = true; _modalResult = modalResult; UiThread.Invoke(() => ViewModelManager.CloseViewModel(this)); OnClosed(); } }
public static void OnParseEndParserItems(List <ParserError> arg1, Dictionary <int, ParsedLineInfo> lineInfos, List <ParsedItem> arg3) { if (lineInfos != null) { var lineInfoCopy = new Dictionary <int, ParsedLineInfo>(lineInfos); Task.Factory.StartNew(() => { UiThread.Invoke(() => SetFolding(ProCodeFormat.GetIndentation(lineInfoCopy))); }); } }
private void RefeshToken() { WpfTask.FactoryStartNew(() => { while (true) { if (AppId.IsNotNullOrEmpty() && AppSecret.IsNotNullOrEmpty()) { var token = AccessTokenContainer.TryGetAccessToken(AppId, AppSecret); UiThread.Invoke(() => { CurrentToken = token; }); } Thread.Sleep(1000 * 60); //一分钟刷新一次 } }); }
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { var handler = PropertyChanged; if (handler != null) { //UI thread save UiThread.Invoke(() => handler(this, new PropertyChangedEventArgs(propertyName))); } PropertyInfo property = GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if (property == null) { return; } var commands = Attribute.GetCustomAttributes(property, typeof(CommandDependencyAttribute)) .Cast <CommandDependencyAttribute>() .Select(cda => GetType().GetProperty(cda.CommandPropertyName, BindingFlags.Instance | BindingFlags.Public)) .Where(cp => cp != null) .Select(cp => cp.GetValue(this)) .OfType <ICommand>() .ToArray(); foreach (var command in commands) { var deligateCommand = command as DelegateCommandBase; if (deligateCommand != null) { //UI thread save UiThread.Invoke(() => deligateCommand.RaiseCanExecuteChanged()); } } }
private static int Message(ref object data, string htmlContent, MessageImg imageType, string title, string subTitle, List <string> buttonsList = null, bool waitResponse = true, Action <HtmlLinkClickedEventArgs> clickHandler = null, int minWidth = 450) { var clickedButton = -1; if (buttonsList == null) { buttonsList = new List <string> { "Ok", "Cancel" } } ; if (waitResponse && data != null) { clickedButton = YamuiInput.ShowDialog( Npp.Handle, "3P: " + title, HtmlHelper.FormatTitle(imageType, title, subTitle), HtmlHelper.FormatContent(htmlContent), buttonsList, ref data, Npp.NppScreen.WorkingArea.Width * 3 / 5, Npp.NppScreen.WorkingArea.Height * 9 / 10, minWidth, (sender, args) => { if (clickHandler != null) { clickHandler(args); } else { Utils.OpenPathClickHandler(sender, args); } }); } else if (waitResponse) { UiThread.Invoke(() => { object nullObject = null; clickedButton = YamuiInput.ShowDialog( Npp.Handle, "3P: " + title, HtmlHelper.FormatTitle(imageType, title, subTitle), HtmlHelper.FormatContent(htmlContent), buttonsList, ref nullObject, Npp.NppScreen.WorkingArea.Width * 3 / 5, Npp.NppScreen.WorkingArea.Height * 9 / 10, minWidth, (sender, args) => { if (clickHandler != null) { clickHandler(args); } else { Utils.OpenPathClickHandler(sender, args); } }); }); } else { UiThread.BeginInvoke(() => { YamuiInput form; object nullObject = null; clickedButton = YamuiInput.Show( Npp.Handle, "3P: " + title, HtmlHelper.FormatTitle(imageType, title, subTitle), HtmlHelper.FormatContent(htmlContent), buttonsList, ref nullObject, out form, Npp.NppScreen.WorkingArea.Width * 3 / 5, Npp.NppScreen.WorkingArea.Height * 9 / 10, minWidth, (sender, args) => { if (clickHandler != null) { clickHandler(args); } else { Utils.OpenPathClickHandler(sender, args); } }); _openedMessage.Add(form); }); } return(clickedButton); } #endregion }
public void Show() { UiThread.Invoke(() => ViewModelManager.ShowViewModel(this)); }