/// <summary> /// Add the specified button. /// </summary> /// <param name="button">Button.</param> public void Add(TabButton button) { if (selectedIndex == -1) { button.Active = true; selectedIndex = 0; } button.Managed = true; button.Multiple = false; button.Lean = Lean; button.Closeable = Closeable; button.Previous = Children.LastOrDefault() as TabButton; button.Toggled += OnButtonToggled; button.Closed += OnTabClose; PackStart(button); }
/// <summary> /// Raised when one tabs active status toggled. /// </summary> /// <param name="sender">Tab bar.</param> /// <param name="e">Event arguments.</param> void OnButtonToggled(object sender, EventArgs e) { TabButton button = sender as TabButton; if (button != null && SelectedItem != button) { SelectedItem = button; if (selectionChangedEvent != null) { selectionChangedEvent(sender, e); } } }
/// <summary> /// Shows the preview of specified scan data /// </summary> /// <param name="scans">List of scans with their matching thumbnail image.</param> public void ShowPreviewOf(List<BaseScan> scans) { if (scans == null || scans.Count == 0) { return; } List<string> scanTypes = new List<string>(scans[0].AvailableScanTypes()); if (currentScans != null) { foreach (BaseScan cScan in currentScans) { cScan.ScanDataChanged -= OnScanDataChanged; scanTypes.Union(cScan.AvailableScanTypes()); } } controlbar.Clear(); TabButton cbOld = null; foreach (string scanType in scanTypes) { if (currentFiberTypes.Count == 0) { currentFiberTypes.Add(scanType); } TabButton cb = new TabButton(scanType); if (cbOld != null) { cb.Previous = cbOld; } cbOld = cb; if (currentFiberTypes.Contains(scanType)) { cb.Active = true; } cb.Toggled += delegate(object sender, EventArgs e) { if (cb.Active) { AddFibertypeToShow(cb.Label); } else { if (currentFiberTypes.Count > 1) { RemoveFibertypeToShow(cb.Label); } else { cb.Active = true; } } }; controlbar.PackStart(cb); } controlbar.PackEnd(controller); // set new list of scans currentScans = scans; // register new ones foreach (BaseScan cScan in currentScans) { cScan.ScanDataChanged += OnScanDataChanged; } bool isOnlyOne = currentScans.Count == 1 && currentFiberTypes.Count == 1; gridView.Clear(); List<Widget> widgets = new List<Widget>(); foreach (BaseScan scan in scans) { if (!scan.IsScaled() && this.Size.Width > 10) { scan.RequestedBitmapSize = this.Size; } foreach (string type in currentFiberTypes) { ScanView lScanView = new ScanView(); if (isOnlyOne) { gridView.Add(lScanView); scanView = lScanView; } else { widgets.Add(lScanView); } lScanView.Initialize(scan, type, !buttonMonochrome.Active, currentScans.Count * currentFiberTypes.Count > 6); lScanView.ShowMask = buttonMask.Active; lScanView.IsThumbnail = !isOnlyOne; lScanView.ButtonPressed += delegate(object sender, ButtonEventArgs e) { if (e.MultiplePress >= 2) { currentFiberTypes.Clear(); currentFiberTypes.Add(lScanView.ScanType); ShowPreviewOf(lScanView.Scan); } }; lScanView.ShowMaskToggled += delegate { buttonMask.Toggled -= ShowMaskToggled; buttonMask.Active = lScanView.ShowMask; buttonMask.Toggled += ShowMaskToggled; }; } } if (!isOnlyOne) { gridView.AddRange(widgets); } }