/// <summary>Hit when the selected item changes in the treeview.</summary>
        /// <param name="sender">trvProject</param>
        /// <param name="e">RoutedPropertyChangedEventArgs</param>
        private void trvProject_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            try
            {
                this.btnNewTask.IsEnabled     = true;
                this.btnAutoRefresh.IsEnabled = true;
                e.Handled = true;
                //If it's a TreeViewArtifact item.
                if (this.trvProject.SelectedItem != null && this.trvProject.SelectedItem.GetType() == typeof(TreeViewArtifact))
                {
                    //Only if it's NOT not a folder.
                    TreeViewArtifact selItem = this.trvProject.SelectedItem as TreeViewArtifact;

                    //Also refresh the properties window
                    if (Pane != null && Pane is toolSpiraExplorer)
                    {
                        //https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsuishell.refreshpropertybrowser(v=vs.120).aspx
                        IVsUIShell shell = ((toolSpiraExplorer)Pane).GetVSService(typeof(SVsUIShell)) as IVsUIShell;
                        if (shell != null)
                        {
                            shell.RefreshPropertyBrowser(-1);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "trvProject_SelectedItemChanged()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        /// <summary>Creates a new instance of the control.</summary>
        public cntlTTipIncident(TreeViewArtifact dataItem)
        {
            //Initialize.
            InitializeComponent();

            //Load the item's data.
            this.DataItem = dataItem;

            //Set images.
            this.imgProject.Source  = StaticFuncs.getImage("imgProject", new System.Windows.Size(16, 16)).Source;
            this.imgIncident.Source = StaticFuncs.getImage("imgIncident", new System.Windows.Size(16, 16)).Source;
            this.imgRelease.Source  = StaticFuncs.getImage("imgRelease", new System.Windows.Size(16, 16)).Source;
            //Set strings.
            this.txtItemId.Text     = StaticFuncs.getCultureResource.GetString("app_Incident_Id") + ":";
            this.txtProject.Text    = StaticFuncs.getCultureResource.GetString("app_Project") + ":";
            this.txtOwner.Text      = StaticFuncs.getCultureResource.GetString("app_General_Owner") + ":";
            this.txtStatusType.Text = StaticFuncs.getCultureResource.GetString("app_Incident_StatusType") + ":";
            this.txtEstimate.Text   = StaticFuncs.getCultureResource.GetString("app_General_EstEffort") + ":";
            this.txtProjected.Text  = StaticFuncs.getCultureResource.GetString("app_General_ProjEffort") + ":";
            this.txtPriority.Text   = StaticFuncs.getCultureResource.GetString("app_General_Priority") + ":";
            this.txtSeverity.Text   = StaticFuncs.getCultureResource.GetString("app_Incident_Severity") + ":";
            this.txtDetected.Text   = StaticFuncs.getCultureResource.GetString("app_Incident_DetectedRelease") + ":";
            this.txtResolved.Text   = StaticFuncs.getCultureResource.GetString("app_Incident_ResolvedRelease") + ":";
            this.txtVerified.Text   = StaticFuncs.getCultureResource.GetString("app_Incident_VerifiedRelease") + ":";
        }
        public cntlTTipUser(TreeViewArtifact dataItem)
        {
            this._dataitem = dataItem;

            //Initialize.
            InitializeComponent();

            //Set images.
            this.imgUser.Source = StaticFuncs.getImage("imgUser", new System.Windows.Size(16, 16)).Source;
        }
 public frmDetailsTask(TreeViewArtifact artifactDetails, ToolWindowPane parentWindow)
     : this(parentWindow)
 {
     try
     {
         this.ArtifactDetail = artifactDetails;
     }
     catch (Exception ex)
     {
         Logger.LogMessage(ex, ".ctor()");
         MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        /// <summary>
        /// Opens the artifact in a web browser
        /// </summary>
        /// <param name="treeViewArtifact"></param>
        public void OpenDetailsToolWindow(TreeViewArtifact treeViewArtifact)
        {
            string METHOD = CLASS + "OpenDetailsToolWindow";

            try
            {
                //We need to get the URL, and then launch it.
                string strUrl = ((SpiraProject)treeViewArtifact.ArtifactParentProject.ArtifactTag).ServerURL.ToString();

                Business.SpiraTeam_Client.SoapServiceClient client = StaticFuncs.CreateClient(strUrl);

                if (treeViewArtifact.ArtifactType != Inflectra.SpiraTest.IDEIntegration.VisualStudio2012.Business.TreeViewArtifact.ArtifactTypeEnum.None)
                {
                    //Users need to use the resource URL
                    string strArtUrl;
                    if (treeViewArtifact.ArtifactType == Inflectra.SpiraTest.IDEIntegration.VisualStudio2012.Business.TreeViewArtifact.ArtifactTypeEnum.User)
                    {
                        //Resources = -11,
                        strArtUrl = client.System_GetArtifactUrl(/*Resources*/ -11, treeViewArtifact.ArtifactParentProject.ArtifactId, treeViewArtifact.ArtifactId, null);
                    }
                    else
                    {
                        strArtUrl = client.System_GetArtifactUrl((int)treeViewArtifact.ArtifactType, treeViewArtifact.ArtifactParentProject.ArtifactId, treeViewArtifact.ArtifactId, null);
                    }

                    //In case the API hasn't been updated to return the full URL..
                    if (strArtUrl.StartsWith("~"))
                    {
                        strUrl = strArtUrl.Replace("~", strUrl);
                    }

                    try
                    {
                        System.Diagnostics.Process.Start(strUrl);
                    }
                    catch (Exception ex)
                    {
                        Logger.LogMessage(ex);
                        MessageBox.Show("Error launching browser.", "Launch URL", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "OpenDetailsToolWindow()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #6
0
 /// <summary>Hit when the user wants to refresh the list.</summary>
 /// <param name="sender">btnRefresh, btnShowClosed</param>
 /// <param name="e">Event Args</param>
 private void btnRefresh_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         TreeViewArtifact selItem = this.trvProject.SelectedItem as TreeViewArtifact;
         if (selItem != null)
         {
             this.refreshTreeNodeServerData(selItem);
         }
     }
     catch (Exception ex)
     {
         Logger.LogMessage(ex, "btnRefresh_Click()");
         MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        public cntlTTipRequirement(TreeViewArtifact dataItem)
        {
            this._dataitem = dataItem;

            //Initialize.
            InitializeComponent();

            //Set images.
            this.imgProject.Source  = StaticFuncs.getImage("imgProject", new System.Windows.Size(16, 16)).Source;
            this.imgIncident.Source = StaticFuncs.getImage("imgIncident", new System.Windows.Size(16, 16)).Source;
            this.imgRelease.Source  = StaticFuncs.getImage("imgRelease", new System.Windows.Size(16, 16)).Source;
            //Set strings.
            this.txtItemId.Text  = StaticFuncs.getCultureResource.GetString("app_Requirement_ID") + ":";
            this.txtProject.Text = StaticFuncs.getCultureResource.GetString("app_Project") + ":";
            this.txtOwner.Text   = StaticFuncs.getCultureResource.GetString("app_General_Owner") + ":";
            this.txtStatus.Text  = StaticFuncs.getCultureResource.GetString("app_General_Status") + ":";
            this.txtPlanned.Text = StaticFuncs.getCultureResource.GetString("app_Requirement_PlannedEff") + ":";
            this.txtAssRel.Text  = StaticFuncs.getCultureResource.GetString("app_General_Release") + ":";
        }
 /// <summary>Hit when the user wants to open up a related Task</summary>
 /// <param name="sender">Hyperlink</param>
 /// <param name="e">RoutedEventArgs</param>
 private void Hyperlink_OpenTask_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Hyperlink link = sender as Hyperlink;
         if (link != null)
         {
             TreeViewArtifact taskArt = link.Tag as TreeViewArtifact;
             if (taskArt != null)
             {
                 ((SpiraExplorerPackage)this.ParentWindowPane.Package).OpenDetailsToolWindow(taskArt);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.LogMessage(ex, "Hyperlink_OpenTask_Click()");
         MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 /// <summary>Possibly hit when the user double-clicks on an item in the treenode.</summary>
 /// <param name="sender">Object</param>
 /// <param name="e">MouseButtonEventArgs</param>
 /// <remarks>Must be public so the TreeNodeArtifact can access the funtion.</remarks>
 private void TreeNode_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     try
     {
         //If it's not a folder and an artifact, open a details screen.
         //Try to get the data item.
         ContentControl trvContainer = sender as ContentControl;
         if (trvContainer != null)
         {
             Grid trvGrid = trvContainer.Content as Grid;
             if (trvGrid != null)
             {
                 TreeViewArtifact trvArtifact = trvGrid.DataContext as TreeViewArtifact;
                 if (trvArtifact != null)
                 {
                     if (!trvArtifact.ArtifactIsFolder &&
                         (trvArtifact.ArtifactType == TreeViewArtifact.ArtifactTypeEnum.Incident ||
                          trvArtifact.ArtifactType == TreeViewArtifact.ArtifactTypeEnum.Requirement ||
                          trvArtifact.ArtifactType == TreeViewArtifact.ArtifactTypeEnum.User ||
                          trvArtifact.ArtifactType == TreeViewArtifact.ArtifactTypeEnum.Task))
                     {
                         //Okay then, let's open up the details.
                         ((SpiraExplorerPackage)this.Pane.Package).OpenDetailsToolWindow(trvArtifact);
                     }
                 }
             }
         }
         else
         {
             if (sender is TreeViewArtifact)
             {
                 ((SpiraExplorerPackage)this.Pane.Package).OpenDetailsToolWindow((sender as TreeViewArtifact));
             }
         }
     }
     catch (Exception ex)
     {
         Logger.LogMessage(ex, "TreeNode_MouseDoubleClick()");
         MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #10
0
        /// <summary>Creates the standard nodes. Run at class creation.</summary>
        private void CreateStandardNodes()
        {
            try
            {
                //Define our standard nodes here.
                // - No Projects
                this._nodeNoProjects = new TreeViewArtifact(this.refreshTreeNodeServerData);
                this._nodeNoProjects.ArtifactName = "No projects selected for this solution.";
                this._nodeNoProjects.ArtifactIsNo = true;

                // - No Solution
                this._nodeNoSolution = new TreeViewArtifact(this.refreshTreeNodeServerData);
                this._nodeNoSolution.ArtifactName = "No solution open.";
                this._nodeNoSolution.ArtifactIsNo = true;
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "CreateStandardNodes()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        /// <summary>Returns the details window if it exists, otherwise null.</summary>
        /// <param name="Artifact">The TreeViewArtifact to get it's detailswindow.</param>
        /// <returns>A toolSpiraExplorerDetails if found, null otherwise.</returns>
        public toolSpiraExplorerDetails FindExistingToolWindow(TreeViewArtifact Artifact, bool create = false)
        {
            toolSpiraExplorerDetails retWindow = null;

            try
            {
                if (SpiraExplorerPackage._windowDetails == null)
                {
                    SpiraExplorerPackage._windowDetails = new Dictionary <TreeViewArtifact, int>();
                }

                //Get the window ID if it already exists.
                int NextId = -1;
                if (SpiraExplorerPackage._windowDetails.ContainsKey(Artifact)) //Get the ID if it exists.
                {
                    NextId = SpiraExplorerPackage._windowDetails[Artifact];
                }
                else //Figure out the next ID.
                {
                    SpiraExplorerPackage._numWindowIds++;
                    NextId = SpiraExplorerPackage._numWindowIds;
                    SpiraExplorerPackage._windowDetails.Add(Artifact, SpiraExplorerPackage._numWindowIds);
                }

                //Now try to grab the window..
                retWindow = this.FindToolWindow(typeof(toolSpiraExplorerDetails), NextId, false) as toolSpiraExplorerDetails;

                if (retWindow == null && create)
                {
                    retWindow = this.FindToolWindow(typeof(toolSpiraExplorerDetails), NextId, true) as toolSpiraExplorerDetails;
                }
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "Error creating window.");
                retWindow = null;
            }

            return(retWindow);
        }
        public cntlTTipTask(TreeViewArtifact dataItem)
        {
            this._dataitem = dataItem;

            //Initialize.
            InitializeComponent();

            //Set images.
            this.imgProject.Source  = StaticFuncs.getImage("imgProject", new System.Windows.Size(16, 16)).Source;
            this.imgIncident.Source = StaticFuncs.getImage("imgIncident", new System.Windows.Size(16, 16)).Source;
            this.imgTaskTime.Source = StaticFuncs.getImage("imgTaskTime", new System.Windows.Size(16, 16)).Source;
            //Set strings.
            this.txtItemId.Text    = StaticFuncs.getCultureResource.GetString("app_Task_ID") + ":";
            this.txtProject.Text   = StaticFuncs.getCultureResource.GetString("app_Project") + ":";
            this.txtOwner.Text     = StaticFuncs.getCultureResource.GetString("app_General_Owner") + ":";
            this.txtPriority.Text  = StaticFuncs.getCultureResource.GetString("app_General_Priority") + ":";
            this.txtRelease.Text   = StaticFuncs.getCultureResource.GetString("app_Global_AssociatedRelease") + ":";
            this.txtStatus.Text    = StaticFuncs.getCultureResource.GetString("app_General_Status") + ":";
            this.txtStartDate.Text = StaticFuncs.getCultureResource.GetString("app_General_StartDate") + ":";
            this.txtEndDate.Text   = StaticFuncs.getCultureResource.GetString("app_General_EndDate") + ":";
            this.tstProjEff.Text   = StaticFuncs.getCultureResource.GetString("app_General_ProjEffort") + ":";
            this.tstActEff.Text    = StaticFuncs.getCultureResource.GetString("app_General_ActEffort") + ":";
            this.tstRemEff.Text    = StaticFuncs.getCultureResource.GetString("app_General_RemEffort") + ":";
        }
Example #13
0
        /// <summary>Hit when the selected item changes in the treeview.</summary>
        /// <param name="sender">trvProject</param>
        /// <param name="e">RoutedPropertyChangedEventArgs</param>
        private void trvProject_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            try
            {
                e.Handled = true;

                //If it's a TreeViewArtifact item.
                if (this.trvProject.SelectedItem != null && this.trvProject.SelectedItem.GetType() == typeof(TreeViewArtifact))
                {
                    //Only if it's NOT not a folder.
                    TreeViewArtifact selItem = this.trvProject.SelectedItem as TreeViewArtifact;
                    this.btnRefresh.IsEnabled = (selItem != null && selItem.ArtifactIsFolder);
                }
                else
                {
                    this.btnRefresh.IsEnabled = false;
                }
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "trvProject_SelectedItemChanged()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void OpenDetailsToolWindow(TreeViewArtifact Artifact)
        {
            string METHOD = CLASS + "OpenDetailsToolWindow";

            try
            {
                //Find the existing window..
                toolSpiraExplorerDetails window = this.FindExistingToolWindow(Artifact, true);

                if (window != null)
                {
                    //If the window is hidden and is not in an unsaved state, reload window contents.
                    //   If window is not hidden, simply bring it to foreground.
                    //   If window is not created, load window contents.
                    //   If window is hidden and in an unsaved state, simply bring it to foreground.

                    //See if we need to reset the content.
                    if (!window.IsContentSet || (window.IsHidden && !window.IsChanged))
                    {
                        //Generate the details screen.
                        object detailContent = null;
                        switch (Artifact.ArtifactType)
                        {
                        case TreeViewArtifact.ArtifactTypeEnum.Incident:
                            frmDetailsIncident detIncident = new frmDetailsIncident(Artifact, window);
                            detailContent = detIncident;
                            break;

                        case TreeViewArtifact.ArtifactTypeEnum.Requirement:
                            frmDetailsRequirement detRequirement = new frmDetailsRequirement(Artifact, window);
                            detailContent = detRequirement;
                            break;

                        case TreeViewArtifact.ArtifactTypeEnum.Task:
                            frmDetailsTask detTask = new frmDetailsTask(Artifact, window);
                            detailContent = detTask;
                            break;
                        }
                        //Set toolwindow's content.
                        if (detailContent != null)
                        {
                            ((cntrlDetailsForm)window.FormControl).Content = detailContent;
                        }
                    }

                    //Get the frame.
                    IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                    windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_MdiChild);
                    Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
                    ((dynamic)((cntrlDetailsForm)window.FormControl).Content).IsHidden = false;
                }
                else
                {
                    //Log an error.
                    Logger.LogMessage(METHOD, "Could not create window.", EventLogEntryType.Error);
                    MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_WindowOpenErrorMessage"), StaticFuncs.getCultureResource.GetString("app_General_WindowOpenError"), MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "OpenDetailsToolWindow()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void _client_CommunicationFinished(object sender, AsyncCompletedEventArgs e)
        {
            try
            {
                if (e.Error == null)
                {
                    try
                    {
                        if (e.GetType() == typeof(Connection_Authenticate2CompletedEventArgs))
                        {
                            Connection_Authenticate2CompletedEventArgs evt = e as Connection_Authenticate2CompletedEventArgs;
                            if (evt.Result)
                            {
                                this._client.User_RetrieveByUserNameAsync(this.id, false);
                            }
                        }
                        else if (e.GetType() == typeof(User_RetrieveByUserNameCompletedEventArgs))
                        {
                            User_RetrieveByUserNameCompletedEventArgs evt = e as User_RetrieveByUserNameCompletedEventArgs;
                            if (evt != null)
                            {
                                this._client.Project_RetrieveAsync();
                            }
                            else
                            {
                                throw new Exception("Results are null.");
                            }
                        }
                        else if (e.GetType() == typeof(Project_RetrieveCompletedEventArgs))
                        {
                            _Projects.Clear();

                            Project_RetrieveCompletedEventArgs evt = e as Project_RetrieveCompletedEventArgs;

                            //Load projects here.
                            if (evt != null && evt.Result.Count > 0)
                            {
                                SpiraProject matchingProject = null;
                                foreach (RemoteProject RemoteProj in evt.Result)
                                {
                                    Business.SpiraProject Project = new Business.SpiraProject();
                                    Project.ProjectId = RemoteProj.ProjectId.Value;
                                    Project.ServerURL = new Uri(this.address);
                                    Project.UserName  = this.id;
                                    Project.UserPass  = this.password;
                                    Project.UserID    = int.Parse(this.id);

                                    TreeViewArtifact nProject = new TreeViewArtifact(spiraExplorer.refresh);
                                    nProject.ArtifactTag      = Project;
                                    nProject.ArtifactId       = ((Business.SpiraProject)nProject.ArtifactTag).ProjectId;
                                    nProject.ArtifactName     = ((Business.SpiraProject)nProject.ArtifactTag).ProjectName;
                                    nProject.ArtifactType     = TreeViewArtifact.ArtifactTypeEnum.Project;
                                    nProject.ArtifactIsFolder = true;
                                    nProject.Parent           = null;

                                    _Projects.Add(nProject);

                                    if (SpiraContext.ProjectId == Project.ProjectId)
                                    {
                                        matchingProject = Project;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogMessage(ex);
                    }
                }
                else
                {
                    Logger.LogMessage(e.Error);
                }
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "_client_CommunicationFinished()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
            //Access the SLN/SUO file to get the associated Spira URL, credentials and project
            if (SpiraContext.HasSolutionProps)
            {
                spiraExplorer.loadProject(SpiraContext.ProjectId);
            }
        }