示例#1
0
        private void NpmController_CommandCompleted(object sender, NpmCommandCompletedEventArgs e)
        {
            lock (_commandCountLock) {
                --_npmCommandsExecuting;
                if (_npmCommandsExecuting < 0)
                {
                    _npmCommandsExecuting = 0;
                }
            }

            string message;

            if (e.WithErrors)
            {
                message = SR.GetString(
                    e.Cancelled ? SR.NpmCancelledWithErrors : SR.NpmCompletedWithErrors,
                    e.CommandText
                    );
            }
            else if (e.Cancelled)
            {
                message = SR.GetString(SR.NpmCancelled, e.CommandText);
            }
            else
            {
                message = SR.GetString(SR.NpmSuccessfullyCompleted, e.CommandText);
            }

            ForceUpdateStatusBarWithNpmActivitySafe(message);

            StopNpmIdleTimer();
            _npmIdleTimer = new Timer(
                _ => UIThread.Invoke(() => _projectNode.CheckForLongPaths(e.Arguments).HandleAllExceptions(SR.ProductName).DoNotWait()),
                null, 1000, Timeout.Infinite);
        }
示例#2
0
        public void AddedAsRole(object azureProjectHierarchy, string roleType)
        {
            var hier = azureProjectHierarchy as IVsHierarchy;

            if (hier == null)
            {
                return;
            }

            UIThread.Invoke(() => {
                string caption;
                object captionObj;
                if (ErrorHandler.Failed(_innerVsHierarchy.GetProperty(
                                            (uint)VSConstants.VSITEMID.Root,
                                            (int)__VSHPROPID.VSHPROPID_Caption,
                                            out captionObj
                                            )) || string.IsNullOrEmpty(caption = captionObj as string))
                {
                    return;
                }

                UpdateServiceDefinition(
                    hier,
                    roleType,
                    caption,
                    new ServiceProvider(GetSite())
                    );
            });
        }
示例#3
0
        /// <summary>
        /// Evaluates the result of an add operation.
        /// </summary>
        /// <param name="result">The <paramref name="VSADDRESULT"/> returned by the Add methods</param>
        /// <param name="path">The full path of the item added.</param>
        /// <returns>A ProjectItem object.</returns>
        private EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path)
        {
            return(UIThread.Invoke <EnvDTE.ProjectItem>(() => {
                if (result != VSADDRESULT.ADDRESULT_Failure)
                {
                    if (Directory.Exists(path))
                    {
                        path = CommonUtils.EnsureEndSeparator(path);
                    }
                    HierarchyNode nodeAdded = this.NodeWithItems.ProjectMgr.FindNodeByFullPath(path);
                    Debug.Assert(nodeAdded != null, "We should have been able to find the new element in the hierarchy");
                    if (nodeAdded != null)
                    {
                        EnvDTE.ProjectItem item = null;
                        var fileNode = nodeAdded as FileNode;
                        if (fileNode != null)
                        {
                            item = new OAFileItem(this.Project, fileNode);
                        }
                        else
                        {
                            item = new OAProjectItem(this.Project, nodeAdded);
                        }

                        return item;
                    }
                }
                return null;
            }));
        }
示例#4
0
        private void startLoadingReaderUsingLoginForm()
        {
            //check is there is a WP.COM blog
            List <Blog> blogs    = DataService.Current.Blogs.ToList();
            string      username = null;
            string      pass     = null;

            foreach (Blog currentBlog in blogs)
            {
                if (currentBlog.Xmlrpc.EndsWith("wordpress.com/xmlrpc.php"))
                {
                    username = currentBlog.Username;
                    pass     = currentBlog.Password;
                    break;
                }
            }

            string responseContent = "<head>"
                                     + "<script type=\"text/javascript\">"
                                     + "function submitform(){document.loginform.submit();} </script>"
                                     + "</head>"
                                     + "<body onload=\"submitform()\">"
                                     + "<form style=\"visibility:hidden;\" name=\"loginform\" id=\"loginform\" action=\"" + Constants.WORDPRESS_LOGIN_URL + "\" method=\"post\">"
                                     + "<input type=\"text\" name=\"log\" id=\"user_login\" value=\"" + username + "\"/></label>"
                                     + "<input type=\"password\" name=\"pwd\" id=\"user_pass\" value=\"" + pass + "\" /></label>"
                                     + "<input type=\"submit\" name=\"wp-submit\" id=\"wp-submit\" value=\"Log In\" />"
                                     + "<input type=\"hidden\" name=\"redirect_to\" value=\"" + Constants.WORDPRESS_READER_URL + "\" />"
                                     + "</form>"
                                     + "</body>";

            UIThread.Invoke(() =>
            {
                browser.NavigateToString(responseContent);
            });
        }
示例#5
0
 /// <summary>
 /// Sets the value of the property at the specified index.
 /// </summary>
 /// <param name="index1">The index of the item to set.</param>
 /// <param name="index2">Reserved for future use.</param>
 /// <param name="index3">Reserved for future use.</param>
 /// <param name="index4">Reserved for future use.</param>
 /// <param name="value">The value to set.</param>
 public void set_IndexedValue(object index1, object index2, object index3, object index4, object value)
 {
     Debug.Assert(pi.GetIndexParameters().Length == 0);
     UIThread.Invoke(() => {
         this.Value = value;
     });
 }
示例#6
0
        /// <summary>
        /// Adds an item to the project.
        /// </summary>
        /// <param name="path">The full path of the item to add.</param>
        /// <param name="op">The <paramref name="VSADDITEMOPERATION"/> to use when adding the item.</param>
        /// <returns>A ProjectItem object. </returns>
        protected virtual EnvDTE.ProjectItem AddItem(string path, VSADDITEMOPERATION op)
        {
            CheckProjectIsValid();
            return(UIThread.Invoke <EnvDTE.ProjectItem>(() => {
                ProjectNode proj = this.Project.ProjectNode;
                EnvDTE.ProjectItem itemAdded = null;
                using (AutomationScope scope = new AutomationScope(this.Project.ProjectNode.Site)) {
                    VSADDRESULT[] result = new VSADDRESULT[1];
                    ErrorHandler.ThrowOnFailure(proj.AddItem(this.NodeWithItems.ID, op, path, 0, new string[1] {
                        path
                    }, IntPtr.Zero, result));

                    string realPath = null;
                    if (op != VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE)
                    {
                        string fileName = Path.GetFileName(path);
                        string fileDirectory = proj.GetBaseDirectoryForAddingFiles(this.NodeWithItems);
                        realPath = Path.Combine(fileDirectory, fileName);
                    }
                    else
                    {
                        realPath = path;
                    }

                    itemAdded = this.EvaluateAddResult(result[0], realPath);
                }

                return itemAdded;
            }));
        }
示例#7
0
        private void LoginSuccess()
        {
            var rootModel = CreateRootModel();

            if (rootModel == null)
            {
                return;
            }

            //xAppStartManager.BeforeInit();
            //ThreadPool.UnsafeQueueUserWorkItem(o => Current.LoadModuleAssemblies(), null);
            Current.LoadModuleAssemblies();

            //xUIThread.BeginInvoke(LoadResource);
            UIThread.Invoke(() =>
            {
                LoadResource();
                ShowMainWindow(rootModel);
            });

            //xAppStartManager.AfterInit();

            AttachInitializeModules();
            //Luna.Infrastructure.Presenters.VersionHelper.CheckVersion();
        }
示例#8
0
        private void startLoadingPostUsingLoginForm()
        {
            if (string.IsNullOrEmpty(_targetURL) || string.IsNullOrEmpty(App.MasterViewModel.CurrentBlog.Password) ||
                string.IsNullOrEmpty(App.MasterViewModel.CurrentBlog.Username) || string.IsNullOrEmpty(App.MasterViewModel.CurrentBlog.loginURL()))
            {
                MessageBox.Show("Can't open the page!");
                if (NavigationService.CanGoBack)
                {
                    NavigationService.GoBack();
                }
                return;
            }

            string responseContent = "<head>"
                                     + "<script type=\"text/javascript\">"
                                     + "function submitform(){document.loginform.submit();} </script>"
                                     + "</head>"
                                     + "<body onload=\"submitform()\">"
                                     + "<form style=\"visibility:hidden;\" name=\"loginform\" id=\"loginform\" action=\"" + App.MasterViewModel.CurrentBlog.loginURL() + "\" method=\"post\">"
                                     + "<input type=\"text\" name=\"log\" id=\"user_login\" value=\"" + App.MasterViewModel.CurrentBlog.Username + "\"/></label>"
                                     + "<input type=\"password\" name=\"pwd\" id=\"user_pass\" value=\"" + App.MasterViewModel.CurrentBlog.Password + "\" /></label>"
                                     + "<input type=\"submit\" name=\"wp-submit\" id=\"wp-submit\" value=\"Log In\" />"
                                     + "<input type=\"hidden\" name=\"redirect_to\" value=\"" + System.Uri.EscapeUriString(_targetURL) + "\" />"
                                     + "</form>"
                                     + "</body>";

            UIThread.Invoke(() =>
            {
                browser.NavigateToString(responseContent);
            });
        }
示例#9
0
        /// <summary>
        /// Gets a value indicating whether the project item is open in a particular view type.
        /// </summary>
        /// <param name="viewKind">A Constants.vsViewKind* indicating the type of view to check./param>
        /// <returns>A Boolean value indicating true if the project is open in the given view type; false if not. </returns>
        public override bool get_IsOpen(string viewKind)
        {
            CheckProjectIsValid();

            // Validate input params
            Guid logicalViewGuid = VSConstants.LOGVIEWID_Primary;

            try {
                if (!(String.IsNullOrEmpty(viewKind)))
                {
                    logicalViewGuid = new Guid(viewKind);
                }
            } catch (FormatException) {
                // Not a valid guid
                throw new ArgumentException(SR.GetString(SR.ParameterMustBeAValidGuid), "viewKind");
            }

            bool isOpen = false;

            using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) {
                UIThread.Invoke(() => {
                    IVsUIHierarchy hier;
                    uint itemid;

                    IVsWindowFrame windowFrame;

                    isOpen = VsShellUtilities.IsDocumentOpen(this.Node.ProjectMgr.Site, this.Node.Url, logicalViewGuid, out hier, out itemid, out windowFrame);
                });
            }

            return(isOpen);
        }
示例#10
0
        /// <summary>
        /// Removes the item from its project and its storage.
        /// </summary>
        public virtual void Delete()
        {
            CheckProjectIsValid();

            using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) {
                UIThread.Invoke(() => this.node.Remove(true));
            }
        }
示例#11
0
        /// <summary>
        /// Expands the view of Solution Explorer to show project items.
        /// </summary>
        public virtual void ExpandView()
        {
            CheckProjectIsValid();

            using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) {
                UIThread.Invoke(() => node.ExpandItem(EXPANDFLAGS.EXPF_ExpandFolder));
            }
        }
示例#12
0
 public void OnReport(IReport report)
 {
     UIThread.Invoke(
         new Action(() =>
     {
         _game.OnReport(report);
     }));
 }
示例#13
0
            /// <summary>
            /// Navigates to the object that is represented by the specified route.
            /// </summary>
            /// <param name="route">The route of the object to navigate to.</param>
            /// <param name="data">The data to pass with the navigation request.</param>
            /// <returns><c>true</c> if successfully navigated; otherwise, <c>false</c>.</returns>
            public bool Navigate(string route, object data)
            {
                if (UIThread.CheckAccess())
                {
                    return(collection.Navigate(route, data));
                }

                return(UIThread.Invoke(() => collection.Navigate(route, data), DispatcherPriority.Normal));
            }
示例#14
0
        /// <summary>
        /// Removes the project from the current solution.
        /// </summary>
        public virtual void Delete()
        {
            CheckProjectIsValid();

            using (AutomationScope scope = new AutomationScope(this.project.Site)) {
                UIThread.Invoke(() => {
                    this.project.Remove(false);
                });
            }
        }
示例#15
0
        /// <summary>
        /// Raises the <see cref="ICommand.CanExecuteChanged"/> event for the current <see cref="DelegateCommand{T}"/>.
        /// </summary>
        public void RaiseChanged()
        {
            if (UIThread.CheckAccess())
            {
                OnCanExecuteChanged();

                return;
            }

            UIThread.Invoke(OnCanExecuteChanged, DispatcherPriority.Normal);
        }
示例#16
0
        private void RequestReady(IAsyncResult asyncResult)
        {
            var             req    = asyncResult.AsyncState as HttpWebRequest;
            BluePrintHolder holder = null;

            try
            {
                using (WebResponse wrs = req.EndGetResponse(asyncResult))
                {
                    var path = wrs.ResponseUri.ToString().Replace("http://mybouwapp.nl/Images/Blueprints/", "");
                    var foo  = wrs.GetResponseStream();

                    var bar    = foo.CloneToMemoryStream();
                    var foobar = bar.ToArray();
                    holder = (from h in bluePrints
                              where (h.statusInfo == BluePrintStatus.Downloading || h.statusInfo == BluePrintStatus.Retrying) && h.filepath == path
                              select h).FirstOrDefault();
                    holder.pixelData  = foobar;
                    holder.statusInfo = BluePrintStatus.Complete;

                    while (lockacumu)
                    {
                    }
                    lockacumu = true;

                    //  Acumulator.Instance().BlueprintRequestReady(path, foobar, null);
                    lockacumu = false;
                    UIThread.Invoke(() => Acumulator.Instance().BB.ReloadImage());
                }
            }
            catch (Exception e)
            {
                var path = req.RequestUri.ToString().Replace("http://mybouwapp.nl/Images/Blueprints/", "");
                holder = (from h in bluePrints
                          where (h.statusInfo == BluePrintStatus.Downloading || h.statusInfo == BluePrintStatus.Retrying) && h.filepath == path
                          select h).FirstOrDefault();
                if (holder != null)
                {
                    holder.statusInfo = BluePrintStatus.Retrying;
                    if (holder.numRetry < 3)
                    {
                        holder.numRetry++;
                        DownloadBlueprint(holder.filepath, holder.ruimteId, holder.ruimteSetNr);
                    }
                    else
                    {
                        holder.statusInfo = BluePrintStatus.Failed;
                        UIThread.Invoke(() => LogHelper.SendLog("download failed after retry: " + e.Message, LogType.error));
                    }
                }
            }
        }
示例#17
0
        public MainWindow(string[] strArgs)
        {
            InitializeComponent();
            //-----参数的处理-----
            var compareKey = string.Empty;

            foreach (var strArg in strArgs)
            {
                compareKey = "-Mouse=";
                if (strArg.StartsWith(compareKey))
                {
                    //指定Mouse历史文件路径
                    var fileName = strArg.Remove(0, compareKey.Length);
                    var mouseHis = CustomEventLogger.GetHookMouseEventArgses(fileName);
                    MouseHisDataList = new ObservableCollection <HookMouseEventArgs>(mouseHis);
                }
                else
                {
                    compareKey = "-Key=";
                    if (strArg.StartsWith(compareKey))
                    {
                        //指定Key历史文件路径
                        var fileName = strArg.Remove(0, compareKey.Length);
                        var keyHis   = CustomEventLogger.GetHookKeyEventArgses(fileName);
                        KeyHisDataList = new ObservableCollection <HookKeyEventArgs>(keyHis);
                    }
                    else
                    {
                        //设定关键词
                        var keyValueIndex = strArg.IndexOf('=');                    //获取关键词分隔符
                        var key           = strArg.Substring(1, keyValueIndex - 1); //取得关键词
                        var value         = strArg.Substring(keyValueIndex + 1);    //取得替换值
                        foreach (var hookKeyEventArgse in KeyHisDataList)
                        {
                            if (hookKeyEventArgse.InputString == key)
                            {
                                hookKeyEventArgse.InputString = value;
                            }
                        }
                    }
                }
            }
            //-----直接执行-----
            argAction = () =>
            {
                ManagedTask.FactoryStart(() =>
                {
                    SimulateAll();
                    UIThread.Invoke(Close);//执行完关闭
                });
            };
        }
示例#18
0
 /// <summary>
 /// Saves the project item.
 /// </summary>
 /// <param name="fileName">The file name with which to save the solution, project, or project item. If the file exists, it is overwritten</param>
 /// <returns>true if the rename was successful. False if Save as failes</returns>
 public override bool SaveAs(string fileName)
 {
     try {
         UIThread.Invoke(() => {
             this.DoSave(true, fileName);
         });
     } catch (InvalidOperationException) {
         return(false);
     } catch (COMException) {
         return(false);
     }
     return(true);
 }
        public void OnLoadLastNotificationCompleted(object sender, XMLRPCCompletedEventArgs <IntResponseObject> args)
        {
            UIThread.Invoke(() =>
            {
                loadingContentProgressBar.Opacity = 0.0;
            });

            XmlRemoteProcedureCall <IntResponseObject> rpc = sender as XmlRemoteProcedureCall <IntResponseObject>;

            rpc.Completed -= OnLoadLastNotificationCompleted;

            PushNotificationsHelper.Instance.OnLoadLastNotificationCompleted(sender, args);
        }
 public void KillSpinner()
 {
     UIThread.Invoke(() =>
     {
         if (null != _rootVisual && null != _currentWaitElement)
         {
             _rootVisual.Children.Remove(_currentWaitElement);
             _rootVisual.SizeChanged -= OnSizeChanged;
             _currentWaitElement      = null;
         }
     });
     Waiting = false;
 }
示例#21
0
        public void TestNpmUIArrowKeyBehavior()
        {
            using (var app = new VisualStudioApp()) {
                UIThread.InitializeAndAlwaysInvokeToCurrentThread();
                UIThread.Invoke(() => {
                    NpmPackageInstallWindow npmWindow = OpenNpmWindowAndWaitForReady();

                    System.Windows.Input.Keyboard.Focus(npmWindow.FilterTextBox);
                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Down);
                    WaitForUIInputIdle();

                    var selectedItem = GetSelectedPackageListItemContainer(npmWindow);
                    Assert.IsTrue(selectedItem.IsKeyboardFocused, "Focus should be on newly selected item");
                    Assert.AreEqual(0, npmWindow._packageList.SelectedIndex);

                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Down);
                    WaitForUIInputIdle();

                    Assert.AreEqual(1, npmWindow._packageList.SelectedIndex);

                    npmWindow.FilterTextBox.Focus();
                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Up);
                    WaitForUIInputIdle();

                    Assert.IsTrue(npmWindow.FilterTextBox.IsKeyboardFocused, "Focus should remain on filter box");
                    Assert.AreEqual(1, npmWindow._packageList.SelectedIndex, "Pressing up while in filter box should maintain current selection");

                    selectedItem = GetSelectedPackageListItemContainer(npmWindow);
                    selectedItem.Focus();
                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Up);
                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Up);
                    WaitForUIInputIdle();

                    Assert.IsTrue(npmWindow.FilterTextBox.IsKeyboardFocused, "Focus should move to filter textbox after pressing up key while on topmost package is selected");

                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Up);
                    WaitForUIInputIdle();

                    Assert.IsTrue(npmWindow.FilterTextBox.IsKeyboardFocused, "Focus should remain on textbox while pressing up when topmost package is selected");
                    Assert.IsFalse(npmWindow.InstallButton.IsEnabled, "Install button should not be enabled when filter box has focus");

                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Enter);
                    WaitForUIInputIdle();

                    selectedItem = GetSelectedPackageListItemContainer(npmWindow);
                    Assert.IsTrue(selectedItem.IsKeyboardFocused, "Focus should be on newly selected item");
                    Assert.AreEqual(0, npmWindow._packageList.SelectedIndex);
                });
            }
        }
示例#22
0
        public void TestNpmUIInitialization()
        {
            using (var app = new VisualStudioApp()) {
                // Initialize call is required because NTVS does not autoload its package
                // We may not be on UI thread, but Dev11 and Dev12 know how to sort that out.
                UIThread.InitializeAndAlwaysInvokeToCurrentThread();
                UIThread.Invoke(() => {
                    NpmPackageInstallWindow npmWindow = OpenNpmWindowAndWaitForReady();

                    Assert.IsTrue(npmWindow.FilterTextBox.IsKeyboardFocused, "FilterTextBox should be keyboard focused");
                    Assert.AreEqual(0, npmWindow._packageList.SelectedIndex, "First item in package list should be selected");
                });
            }
        }
示例#23
0
        /// <summary>
        /// Opens the file item in the specified view.
        /// </summary>
        /// <param name="ViewKind">Specifies the view kind in which to open the item (file)</param>
        /// <returns>Window object</returns>
        public override EnvDTE.Window Open(string viewKind)
        {
            CheckProjectIsValid();

            IVsWindowFrame windowFrame = null;
            IntPtr         docData     = IntPtr.Zero;

            using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) {
                UIThread.Invoke(() => {
                    try {
                        // Validate input params
                        Guid logicalViewGuid = VSConstants.LOGVIEWID_Primary;
                        try {
                            if (!(String.IsNullOrEmpty(viewKind)))
                            {
                                logicalViewGuid = new Guid(viewKind);
                            }
                        } catch (FormatException) {
                            // Not a valid guid
                            throw new ArgumentException(SR.GetString(SR.ParameterMustBeAValidGuid), "viewKind");
                        }

                        uint itemid;
                        IVsHierarchy ivsHierarchy;
                        uint docCookie;
                        IVsRunningDocumentTable rdt = this.Node.ProjectMgr.Site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
                        if (rdt == null)
                        {
                            throw new InvalidOperationException("Could not get running document table from the services exposed by this project");
                        }

                        ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, this.Node.Url, out ivsHierarchy, out itemid, out docData, out docCookie));

                        // Open the file using the IVsProject interface
                        // We get the outer hierarchy so that projects can customize opening.
                        var project = Node.ProjectMgr.GetOuterInterface <IVsProject>();
                        ErrorHandler.ThrowOnFailure(project.OpenItem(Node.ID, ref logicalViewGuid, docData, out windowFrame));
                    } finally {
                        if (docData != IntPtr.Zero)
                        {
                            Marshal.Release(docData);
                        }
                    }
                });
            }

            // Get the automation object and return it
            return((windowFrame != null) ? VsShellUtilities.GetWindowObject(windowFrame) : null);
        }
        private void OnUploadMediaRPCCompleted(object sender, XMLRPCCompletedEventArgs <Media> args)
        {
            UploadFileRPC rpc = sender as UploadFileRPC;

            rpc.Completed -= OnUploadMediaRPCCompleted;

            lock (_syncRoot)
            {
                _mediaUploadRPCs.Remove(rpc);
                if (args.Cancelled)
                {
                    return;
                }

                if (args.Items.Count == 0 || args.Error != null)
                {
                    //uh oh, media upload problem
                    App.WaitIndicationService.KillSpinner();
                    //Move
                    UIThread.Invoke(() =>
                    {
                        ApplicationBar.IsVisible = true;
                        if (!_messageBoxIsShown)
                        {
                            _messageBoxIsShown      = true;
                            String msg              = args.Error != null ? args.Error.Message : _localizedStrings.Prompts.MediaError;
                            MessageBoxResult result = MessageBox.Show(msg, _localizedStrings.Prompts.MediaError, MessageBoxButton.OK);
                            _messageBoxIsShown      = false;
                        }
                    });
                    this.emptyImagesUploadingQueue();
                    return;
                }
                else
                {
                    //Image uploaded correctly. Upload the next picture in the list
                    if (_mediaUploadRPCs.Count > 0)
                    {
                        UploadFileRPC item = _mediaUploadRPCs.First() as UploadFileRPC;
                        item.ExecuteAsync();
                        return;
                    }

                    App.WaitIndicationService.KillSpinner();
                    SavePost();
                }
            }//end lock
        }
 private void showFeaturedImageLoadingError(Exception ex)
 {
     UIThread.Invoke(() =>
     {
         featuredImage.Visibility      = Visibility.Collapsed;
         featuredImageError.Visibility = Visibility.Visible;
         if (ex != null && ex.Message != null)
         {
             featuredImageError.Text = "Sorry, something went wrong while loading the image.\n" + ex.Message;
         }
         else
         {
             featuredImageError.Text = "Sorry, something went wrong while loading the image.";
         }
     });
 }
示例#26
0
        public static void HandleException(this PhoneApplicationPage page, Exception exception, string title = "", string message = "")
        {
            Utils.Tools.LogException(message, exception);

            if (!string.IsNullOrEmpty(message))
            {
                MessageBox.Show(message, title, MessageBoxButton.OK);
            }
            else if (exception is WordPress.Model.NoConnectionException)
            {
                StringTable _localizedStrings = App.Current.Resources["StringTable"] as StringTable;
                MessageBox.Show(_localizedStrings.Prompts.NoConnectionErrorContent, _localizedStrings.PageTitles.Error, MessageBoxButton.OK);
            }
            else
            {
                if (exception is WordPress.Model.XmlRPCParserException) //cannot parse the XML-RPC response document
                {
                    UIThread.Invoke(() =>
                    {
                        ErrorPage.Exception = exception;
                        (App.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Source = new Uri("/ErrorPage.xaml", UriKind.Relative);
                    });
                }
                else if (exception is WordPress.Model.XmlRPCException) //the XML-RPC document contains a fault error
                {
                    MessageBox.Show(exception.Message);
                }
                else
                {
                    if (exception is System.Net.WebException)
                    {
                        //Error while accessing the network, or the server does reply with an HTTP error code
                        MessageBox.Show(exception.Message);
                    }
                    else
                    {
                        //show the nice help page.
                        UIThread.Invoke(() =>
                        {
                            ErrorPage.Exception = exception;
                            (App.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Source = new Uri("/ErrorPage.xaml", UriKind.Relative);
                        });
                    }
                }
            }
        }
示例#27
0
 protected override void OnInitialize()
 {
     BeginLoading();
     new Thread(() =>
     {
         Application.Current.Resources["AbsentEventTypes"] = _shiftDispatcherModel.GetAllAbsenetTypes();
         _attendances          = _shiftDispatcherModel.GetAgents(_schedule);
         _refreshLaborHourOnly = true;
         UIThread.Invoke(() =>
         {
             Agents = _attendances.Cast <IEnumerable>().ToList();
             EndLoading();
         });
         _refreshLaborHourOnly = false;
     }).Start();
     base.OnInitialize();
 }
示例#28
0
        /// <summary>
        /// 模拟鼠标操作
        /// </summary>
        public static void SimulateMouseBehavior(IList <HookMouseEventArgs> MouseHisDataList)
        {
            if (MouseHisDataList.Count == 0)
            {
                return;
            }
            //----遍历历史记录,重新执行一遍-----
            var lastHis     = MouseHisDataList.First();
            var hisDataList = MouseHisDataList.ToList();

            foreach (var hookMouseEventArgse in hisDataList)
            {
                var timeDiff = hookMouseEventArgse.EventTimeStamp - lastHis.EventTimeStamp;
                Thread.Sleep(timeDiff);//休眠
                MouseSimulator.Position = hookMouseEventArgse.MousePosition;
                switch (hookMouseEventArgse.MouseEventType)
                {
                case MouseEventType.MouseDown:
                    MouseSimulator.MouseDown(hookMouseEventArgse.ClickButton);
                    UIThread.Invoke(() =>
                    {
                        ShowMouseIndicator(MouseIndicatorWinView, hookMouseEventArgse.MousePosition, new SolidColorBrush(Color.FromRgb(255, 0, 0)));
                    });
                    break;

                case MouseEventType.MouseUp:
                    MouseSimulator.MouseUp(hookMouseEventArgse.ClickButton);
                    UIThread.Invoke(() =>
                    {
                        ShowMouseIndicator(MouseIndicatorWinView, hookMouseEventArgse.MousePosition, new SolidColorBrush(Color.FromRgb(26, 58, 246)));
                    });
                    break;

                case MouseEventType.MouseWheel:
                    MouseSimulator.MouseWheel(hookMouseEventArgse.MouseWheelDelta);
                    break;

                case MouseEventType.MouseMove:
                    MouseSimulator.MouseMove(hookMouseEventArgse.MousePosition.X, hookMouseEventArgse.MousePosition.Y, true);
                    HideMouseIndicator(MouseIndicatorWinView);
                    break;
                }
                lastHis = hookMouseEventArgse;
            }
        }
示例#29
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (this.NavigationContext.QueryString.TryGetValue("blog_id", out blog_id) &&
                this.NavigationContext.QueryString.TryGetValue("comment_id", out comment_id))
            {
                List <Blog> blogs = DataService.Current.Blogs.ToList();
                foreach (Blog currentBlog in blogs)
                {
                    if (currentBlog.isWPcom() || currentBlog.hasJetpack())
                    {
                        string currentBlogID = currentBlog.isWPcom() ? Convert.ToString(currentBlog.BlogId) : currentBlog.getJetpackClientID();
                        if (currentBlogID == blog_id)
                        {
                            BlogName.Text = currentBlog.BlogName;
                            _currentBlog  = currentBlog;
                        }
                    }
                }
            }

            if (_currentBlog == null)
            {
                if (NavigationService.CanGoBack)
                {
                    NavigationService.GoBack();
                }
                return;
            }

            GetAllCommentsRPC rpc = new GetAllCommentsRPC(_currentBlog);

            rpc.Number     = 20;
            rpc.Offset     = 0;
            rpc.Completed += OnFetchCurrentBlogCommentsCompleted;

            rpc.ExecuteAsync();

            UIThread.Invoke(() =>
            {
                ApplicationBar.IsVisible = false;
                App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.Loading);
            });
        }
示例#30
0
        public void TestNpmUITabKeyBehavior()
        {
            using (var app = new VisualStudioApp()) {
                UIThread.InitializeAndAlwaysInvokeToCurrentThread();
                UIThread.Invoke(() => {
                    NpmPackageInstallWindow npmWindow = OpenNpmWindowAndWaitForReady();

                    npmWindow.FilterTextBox.Focus();
                    WaitForUIInputIdle();

                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab);
                    WaitForUIInputIdle();

                    var selectedItem = GetSelectedPackageListItemContainer(npmWindow);
                    Assert.IsTrue(selectedItem.IsKeyboardFocused);

                    // Install button disabled, must key down to select "installable" package
                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Down);
                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab);
                    WaitForUIInputIdle();

                    Assert.IsTrue(npmWindow.DependencyComboBox.IsKeyboardFocused);

                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab);
                    WaitForUIInputIdle();

                    Assert.IsTrue(npmWindow.SaveToPackageJsonCheckbox.IsKeyboardFocused);

                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab);
                    WaitForUIInputIdle();

                    Assert.IsTrue(npmWindow.SelectedVersionComboBox.IsKeyboardFocused);

                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab);
                    WaitForUIInputIdle();

                    Assert.IsTrue(npmWindow.ArgumentsTextBox.IsKeyboardFocused);

                    TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab);
                    WaitForUIInputIdle();

                    Assert.IsTrue(npmWindow.InstallButton.IsKeyboardFocused);
                });
            }
        }