Ejemplo n.º 1
0
 void DestroyPad(Pad pad)
 {
     lock (outputMonitors) {
         outputMonitors.Remove(pad);
     }
     pad.Destroy();
 }
Ejemplo n.º 2
0
        public SearchProgressMonitor GetSearchProgressMonitor(bool bringToFront, bool focusPad = false, CancellationTokenSource cancellationTokenSource = null)
        {
            Pad    pad   = null;
            string title = GettextCatalog.GetString("Search Results");

            int instanceNum = -1;

            lock (searchMonitors) {
                // Look for an available pad
                for (int n = 0; n < searchMonitors.Count; n++)
                {
                    Pad             mpad = (Pad)searchMonitors [n];
                    SearchResultPad rp   = (SearchResultPad)mpad.Content;
                    if (rp.InstanceNum > instanceNum)
                    {
                        instanceNum = rp.InstanceNum;
                    }
                    if (rp.AllowReuse)
                    {
                        pad = mpad;
                        break;
                    }
                }
            }
            if (pad != null)
            {
                if (bringToFront)
                {
                    pad.BringToFront(focusPad);
                }
                return(new SearchProgressMonitor(pad, cancellationTokenSource));
            }

            instanceNum++;

            string newPadId  = "SearchPad - " + title + " - " + instanceNum;
            string basePadId = "SearchPad - " + title + " - 0";

            if (instanceNum > 0)
            {
                title += " (" + (instanceNum + 1) + ")";
            }

            SearchResultPad monitorPad = new SearchResultPad(instanceNum)
            {
                FocusPad = focusPad
            };

            pad        = IdeApp.Workbench.ShowPad(monitorPad, newPadId, title, basePadId + "/Center Bottom", Stock.FindIcon);
            pad.Sticky = true;
            lock (searchMonitors) {
                searchMonitors.Add(pad);

                if (searchMonitors.Count > 1)
                {
                    // This is needed due to ContextBoundObject not being able to do a reflection access on private fields
                    var searchMonitorsCopy = searchMonitors;
                    // Additional search pads will be destroyed when hidden
                    pad.Window.PadHidden += delegate {
                        lock (searchMonitorsCopy) {
                            searchMonitorsCopy.Remove(pad);
                        }
                        pad.Destroy();
                    };
                }
            }

            if (bringToFront)
            {
                pad.BringToFront(focusPad);
            }

            return(new SearchProgressMonitor(pad, cancellationTokenSource));
        }
Ejemplo n.º 3
0
        Pad CreateMonitorPad(string id, string title, string icon, bool bringToFront, bool allowMonitorReuse, bool show)
        {
            Pad pad = null;

            if (icon == null)
            {
                icon = Stock.OutputIcon;
            }

            if (id == null)
            {
                id = title;
            }

            int instanceCount = -1;

            if (allowMonitorReuse)
            {
                lock (outputMonitors) {
                    // Look for an available pad
                    for (int n = 0; n < outputMonitors.Count; n++)
                    {
                        Pad mpad = (Pad)outputMonitors [n];
                        DefaultMonitorPad mon = (DefaultMonitorPad)mpad.Content;
                        if (mon.TypeTag == id)
                        {
                            if (mon.InstanceNum > instanceCount)
                            {
                                instanceCount = mon.InstanceNum;
                            }
                            if (mon.AllowReuse)
                            {
                                pad = mpad;
                                break;
                            }
                        }
                    }
                }
                if (pad != null)
                {
                    if (bringToFront)
                    {
                        pad.BringToFront();
                    }
                    return(pad);
                }
            }

            instanceCount++;
            DefaultMonitorPad monitorPad = new DefaultMonitorPad(id, icon, instanceCount);

            string newPadId  = "OutputPad-" + id + "-" + instanceCount;
            string basePadId = "OutputPad-" + id + "-0";

            if (instanceCount > 0)
            {
                // Translate the title before adding the count
                title  = GettextCatalog.GetString(title);
                title += " (" + (instanceCount + 1) + ")";
            }

            if (show)
            {
                pad = IdeApp.Workbench.ShowPad(monitorPad, newPadId, title, basePadId + "/Center Bottom", icon);
            }
            else
            {
                pad = IdeApp.Workbench.AddPad(monitorPad, newPadId, title, basePadId + "/Center Bottom", icon);
            }

            monitorPad.StatusSourcePad = pad;
            pad.Sticky = true;
            outputMonitors.Add(pad);

            if (instanceCount > 0)
            {
                // Additional output pads will be destroyed when hidden
                pad.Window.PadHidden += delegate {
                    outputMonitors.Remove(pad);
                    pad.Destroy();
                };
            }

            pad.AutoHide = true;

            if (bringToFront)
            {
                pad.Visible = true;
                pad.BringToFront();
            }

            return(pad);
        }
Ejemplo n.º 4
0
 void DestroyPad(Pad pad)
 {
     outputMonitors.Remove (pad);
     pad.Destroy ();
 }