예제 #1
0
        public bool CloseWindow(bool force)
        {
            WorkbenchSingleton.AssertMainThread();

            forceClose = force;
            Close();
            return(this.ViewContents.Count == 0);
        }
예제 #2
0
 public void HideProgress()
 {
     WorkbenchSingleton.SafeThreadAsyncCall(
         delegate {
         statusProgressBarIsVisible = false;
         statusProgressBar.Visible  = false;
         jobNamePanel.Text          = currentTaskName = "";
     });
 }
예제 #3
0
 /// <summary>
 /// Refreshes the property pad if the specified item is active.
 /// </summary>
 public static void RefreshItem(object obj)
 {
     WorkbenchSingleton.AssertMainThread();
     if (instance != null && instance.grid.SelectedObjects.Contains(obj))
     {
         instance.inUpdate             = true;
         instance.grid.SelectedObjects = instance.grid.SelectedObjects;
         instance.inUpdate             = false;
     }
 }
예제 #4
0
        public void HideProgress()
        {
//			LoggingService.Debug("HideProgress()");
            statusProgressBarIsVisible = false;
            // to allow the user to see the red progress bar as a visual clue of a failed
            // build even if it occurs close to the end of the build, we'll hide the progress bar
            // with a bit of time delay
            WorkbenchSingleton.CallLater(
                TimeSpan.FromMilliseconds(currentStatus == OperationStatus.Error ? 500 : 150),
                new Action(DoHideProgress));
        }
예제 #5
0
        /// <summary>
        /// run this method with a .net 3.5 and .net 4.0 project to generate the table above.
        /// </summary>
        void CreateReferenceToFrameworkTable()
        {
            LoggingService.Warn("Running CreateReferenceToFrameworkTable()");

            MSBuildBasedProject project = selectDialog.ConfigureProject as MSBuildBasedProject;

            if (project == null)
            {
                return;
            }

            var redistNameToRequiredFramework = new Dictionary <string, string> {
                { "Framework", null },
                { "Microsoft-Windows-CLRCoreComp", null },
                { "Microsoft.VisualStudio.Primary.Interop.Assemblies.8.0", null },
                { "Microsoft-WinFX-Runtime", "3.0" },
                { "Microsoft-Windows-CLRCoreComp.3.0", "3.0" },
                { "Microsoft-Windows-CLRCoreComp-v3.5", "3.5" },
                { "Microsoft-Windows-CLRCoreComp.4.0", "4.0" },
            };

            using (StreamWriter w = new StreamWriter("c:\\temp\\references.txt")) {
                List <ReferenceProjectItem> referenceItems = new List <ReferenceProjectItem>();
                WorkbenchSingleton.SafeThreadCall(
                    delegate {
                    foreach (ListViewItem item in fullItemList)
                    {
                        referenceItems.Add(new ReferenceProjectItem(project, item.Tag.ToString()));
                    }
                });

                MSBuildInternals.ResolveAssemblyReferences(project, referenceItems.ToArray());
                foreach (ReferenceProjectItem rpi in referenceItems)
                {
                    if (string.IsNullOrEmpty(rpi.Redist))
                    {
                        continue;
                    }
                    if (!redistNameToRequiredFramework.ContainsKey(rpi.Redist))
                    {
                        LoggingService.Error("unknown redist: " + rpi.Redist);
                    }
                    else if (redistNameToRequiredFramework[rpi.Redist] != null)
                    {
                        w.Write("\t\t\t{ \"");
                        w.Write(rpi.Include);
                        w.Write("\", \"");
                        w.Write(redistNameToRequiredFramework[rpi.Redist]);
                        w.WriteLine("\" },");
                    }
                }
            }
        }
예제 #6
0
        public void DisplayProgress(string taskName, int workDone, int totalWork)
        {
            if (taskName == null)
            {
                taskName = "";
            }
            if (totalWork < 0)
            {
                totalWork = 0;
            }
            if (workDone < 0)
            {
                workDone = 0;
            }
            if (workDone > totalWork)
            {
                workDone = totalWork;
            }

            WorkbenchSingleton.SafeThreadAsyncCall(
                delegate {
                if (!statusProgressBarIsVisible)
                {
                    statusProgressBar.Visible  = true;
                    statusProgressBarIsVisible = true;
                }

                if (totalWork == 0)
                {
                    statusProgressBar.Style = ProgressBarStyle.Marquee;
                }
                else
                {
                    statusProgressBar.Style = ProgressBarStyle.Continuous;
                    if (statusProgressBar.Maximum != totalWork)
                    {
                        if (statusProgressBar.Value > totalWork)
                        {
                            statusProgressBar.Value = 0;
                        }
                        statusProgressBar.Maximum = totalWork;
                    }
                    statusProgressBar.Value = workDone;
                }

                if (currentTaskName != taskName)
                {
                    currentTaskName   = taskName;
                    jobNamePanel.Text = StringParser.Parse(taskName);
                }
            });
        }
예제 #7
0
        /// <summary>
        /// Adds a category to the compiler message view. This method is thread-safe.
        /// </summary>
        public void AddCategory(MessageViewCategory category)
        {
            if (WorkbenchSingleton.InvokeRequired)
            {
                WorkbenchSingleton.SafeThreadAsyncCall((Action <MessageViewCategory>)AddCategory, category);
                return;
            }
            messageCategories.Add(category);
            category.TextSet      += new TextEventHandler(CategoryTextSet);
            category.TextAppended += new TextEventHandler(CategoryTextAppended);

            OnMessageCategoryAdded(EventArgs.Empty);
        }
예제 #8
0
 public void CloseAllViews()
 {
     WorkbenchSingleton.AssertMainThread();
     try {
         closeAll = true;
         foreach (IWorkbenchWindow window in this.WorkbenchWindowCollection.ToArray())
         {
             window.CloseWindow(false);
         }
     } finally {
         closeAll = false;
         OnActiveWindowChanged(this, EventArgs.Empty);
     }
 }
예제 #9
0
        void fileDeleted(object sender, FileSystemEventArgs e)
        {
            Action method = delegate {
                foreach (FileListItem fileItem in Items)
                {
                    if (fileItem.FullName.Equals(e.FullPath, StringComparison.OrdinalIgnoreCase))
                    {
                        Items.Remove(fileItem);
                        break;
                    }
                }
            };

            WorkbenchSingleton.SafeThreadAsyncCall(method);
        }
예제 #10
0
 public void AddProgress(ProgressCollector progress)
 {
     if (progress == null)
     {
         throw new ArgumentNullException("progress");
     }
     WorkbenchSingleton.AssertMainThread();
     if (currentProgress != null)
     {
         currentProgress.ProgressMonitorDisposed -= progress_ProgressMonitorDisposed;
         currentProgress.PropertyChanged         -= progress_PropertyChanged;
     }
     waitingProgresses.Push(currentProgress);             // push even if currentProgress==null
     SetActiveProgress(progress);
 }
예제 #11
0
        void fileCreated(object sender, FileSystemEventArgs e)
        {
            Action method = delegate {
                FileInfo info = new FileInfo(e.FullPath);

                ListViewItem fileItem = Items.Add(new FileListItem(e.FullPath));
                try {
                    fileItem.SubItems.Add(Math.Round((double)info.Length / 1024).ToString() + " KB");
                    fileItem.SubItems.Add(info.LastWriteTime.ToString());
                } catch (IOException) {
                    // ignore IO errors
                }
            };

            WorkbenchSingleton.SafeThreadAsyncCall(method);
        }
예제 #12
0
        void fileRenamed(object sender, RenamedEventArgs e)
        {
            Action method = delegate {
                foreach (FileListItem fileItem in Items)
                {
                    if (fileItem.FullName.Equals(e.OldFullPath, StringComparison.OrdinalIgnoreCase))
                    {
                        fileItem.FullName = e.FullPath;
                        fileItem.Text     = e.Name;
                        break;
                    }
                }
            };

            WorkbenchSingleton.SafeThreadAsyncCall(method);
        }
예제 #13
0
 void DisplayActiveCategory()
 {
     WorkbenchSingleton.DebugAssertMainThread();
     if (selectedCategory < 0)
     {
         textEditorControl.Text = "";
     }
     else
     {
         lock (messageCategories[selectedCategory].SyncRoot) {
             // accessing a categories' text takes its lock - but we have to take locks in the same
             // order as in the Append calls to prevent a deadlock
             EnqueueAppend(new AppendCall(messageCategories[selectedCategory], messageCategories[selectedCategory].Text, true));
         }
     }
 }
예제 #14
0
 public PadDescriptor GetPad(Type type)
 {
     WorkbenchSingleton.AssertMainThread();
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     foreach (PadDescriptor pad in PadContentCollection)
     {
         if (pad.Class == type.FullName)
         {
             return(pad);
         }
     }
     return(null);
 }
예제 #15
0
        public void ShowView(IViewContent content, bool switchToOpenedView)
        {
            WorkbenchSingleton.AssertMainThread();
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }
            if (ViewContentCollection.Contains(content))
            {
                throw new ArgumentException("ViewContent was already shown");
            }
            System.Diagnostics.Debug.Assert(WorkbenchLayout != null);

            LoadViewContentMemento(content);

            WorkbenchLayout.ShowView(content, switchToOpenedView);
        }
예제 #16
0
 void CategoryTextAppended(object sender, TextEventArgs e)
 {
     lock (appendCallLock) {
         pendingAppendCalls += 1;
         MessageViewCategory cat = (MessageViewCategory)sender;
         if (pendingAppendCalls < 5)
         {
             WorkbenchSingleton.SafeThreadAsyncCall(new Action <MessageViewCategory, string, string>(AppendText),
                                                    cat, cat.Text, e.Text);
         }
         else if (pendingAppendCalls == 5)
         {
             WorkbenchSingleton.SafeThreadAsyncCall(new Action <MessageViewCategory>(AppendTextCombined),
                                                    cat);
         }
     }
 }
예제 #17
0
        void SetActiveProgress(ProgressCollector progress)
        {
            WorkbenchSingleton.AssertMainThread();
            currentProgress = progress;
            if (progress == null)
            {
                statusBar.HideProgress();
                return;
            }

            progress.ProgressMonitorDisposed += progress_ProgressMonitorDisposed;
            if (progress.ProgressMonitorIsDisposed)
            {
                progress_ProgressMonitorDisposed(progress, null);
                return;
            }
            progress.PropertyChanged += progress_PropertyChanged;
        }
예제 #18
0
        public void ShowPad(PadDescriptor content)
        {
            WorkbenchSingleton.AssertMainThread();
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }
            if (padDescriptorCollection.Contains(content))
            {
                throw new ArgumentException("Pad is already loaded");
            }

            padDescriptorCollection.Add(content);

            if (WorkbenchLayout != null)
            {
                WorkbenchLayout.ShowPad(content);
            }
        }
예제 #19
0
        void DetectMonospacedThread()
        {
            Thread.Sleep(0);             // first allow UI thread to do some work
            DebugTimer.Start();
            InstalledFontCollection installedFontCollection = new InstalledFontCollection();
            Font currentFont            = defaultFont;
            List <FontDescriptor> fonts = new List <FontDescriptor>();

            int index = 0;

            foreach (FontFamily fontFamily in installedFontCollection.Families)
            {
                if (fontFamily.IsStyleAvailable(FontStyle.Regular) && fontFamily.IsStyleAvailable(FontStyle.Bold) && fontFamily.IsStyleAvailable(FontStyle.Italic))
                {
                    if (fontFamily.Name == currentFont.Name)
                    {
                        index = fonts.Count;
                    }
                    fonts.Add(new FontDescriptor(fontFamily));
                }
            }
            DebugTimer.Stop("Getting installed fonts");
            WorkbenchSingleton.SafeThreadAsyncCall(
                delegate {
                fontListComboBox.Items.AddRange(fonts.ToArray());
                fontSizeComboBox.Enabled       = true;
                fontListComboBox.Enabled       = true;
                fontListComboBox.SelectedIndex = index;
                fontSizeComboBox.Text          = currentFont.Size.ToString();
            });
            DebugTimer.Start();
            using (Bitmap newBitmap = new Bitmap(1, 1)) {
                using (Graphics g = Graphics.FromImage(newBitmap)) {
                    foreach (FontDescriptor fd in fonts)
                    {
                        fd.DetectMonospaced(g);
                    }
                }
            }
            DebugTimer.Stop("Detect Monospaced");
            fontListComboBox.Invalidate();
        }
예제 #20
0
        void ResolveVersionsWorker()
        {
            MSBuildBasedProject project = selectDialog.ConfigureProject as MSBuildBasedProject;

            if (project == null)
            {
                return;
            }

            List <ListViewItem>         itemsToResolveVersion = new List <ListViewItem>();
            List <ReferenceProjectItem> referenceItems        = new List <ReferenceProjectItem>();

            WorkbenchSingleton.SafeThreadCall(
                delegate {
                foreach (ListViewItem item in shortItemList)
                {
                    if (item.SubItems[1].Text.Contains("/"))
                    {
                        itemsToResolveVersion.Add(item);
                        referenceItems.Add(new ReferenceProjectItem(project, item.Text));
                    }
                }
            });

            MSBuildInternals.ResolveAssemblyReferences(project, referenceItems.ToArray());

            WorkbenchSingleton.SafeThreadAsyncCall(
                delegate {
                if (IsDisposed)
                {
                    return;
                }
                for (int i = 0; i < itemsToResolveVersion.Count; i++)
                {
                    if (referenceItems[i].Version != null)
                    {
                        itemsToResolveVersion[i].SubItems[1].Text = referenceItems[i].Version.ToString();
                    }
                }
            });
        }
예제 #21
0
        public bool CloseAllSolutionViews()
        {
            bool result = true;

            WorkbenchSingleton.AssertMainThread();
            try {
                closeAll = true;
                foreach (IWorkbenchWindow window in this.WorkbenchWindowCollection.ToArray())
                {
                    if (window.ActiveViewContent != null && window.ActiveViewContent.CloseWithSolution)
                    {
                        result &= window.CloseWindow(false);
                    }
                }
            } finally {
                closeAll = false;
                OnActiveWindowChanged(this, EventArgs.Empty);
            }

            return(result);
        }
예제 #22
0
        void UpdateTick(object sender, ParserUpdateStepEventArgs e)
        {
            if (!this.IsVisible)
            {
                return;
            }
            LoggingService.Debug("DefinitionViewPad.Update");
            ResolveResult res = ResolveAtCaret(e);

            if (res == null)
            {
                return;
            }
            FilePosition pos = res.GetDefinitionPosition();

            if (pos.IsEmpty)
            {
                return;
            }
            WorkbenchSingleton.SafeThreadAsyncCall(OpenFile, pos);
        }
예제 #23
0
        void fileChanged(object sender, FileSystemEventArgs e)
        {
            Action method = delegate {
                foreach (FileListItem fileItem in Items)
                {
                    if (fileItem.FullName.Equals(e.FullPath, StringComparison.OrdinalIgnoreCase))
                    {
                        FileInfo info = new FileInfo(e.FullPath);

                        try {
                            fileItem.SubItems[1].Text = Math.Round((double)info.Length / 1024).ToString() + " KB";
                            fileItem.SubItems[2].Text = info.LastWriteTime.ToString();
                        } catch (IOException) {
                            // ignore IO errors
                        }
                        break;
                    }
                }
            };

            WorkbenchSingleton.SafeThreadAsyncCall(method);
        }
예제 #24
0
 void OnParserUpdateStep(object sender, ParserUpdateStepEventArgs e)
 {
     WorkbenchSingleton.SafeThreadAsyncCall(UpdateTick, e);
 }
예제 #25
0
 void CategoryTextSet(object sender, TextEventArgs e)
 {
     WorkbenchSingleton.SafeThreadAsyncCall(new Action <MessageViewCategory, string>(SetText),
                                            (MessageViewCategory)sender, e.Text);
 }
예제 #26
0
 void LoadSolutionProjectsThreadEndedEvent(object sender, EventArgs e)
 {
     // do not invoke on this: it's possible that "this" is disposed while this method is executing
     WorkbenchSingleton.SafeThreadAsyncCall(this.RefreshSecondaryViewContents);
 }
예제 #27
0
 void CategoryTextCleared(object sender, EventArgs e)
 {
     WorkbenchSingleton.SafeThreadAsyncCall(new Action <MessageViewCategory>(ClearText),
                                            (MessageViewCategory)sender);
 }
예제 #28
0
 /// <summary>
 /// Causes the list of property descriptors to be recreated.
 /// </summary>
 protected void ReFilterProperties()
 {
     globalizedProps = null;
     WorkbenchSingleton.SafeThreadAsyncCall(delegate { PropertyPad.RefreshItem(this); });
 }