public AnnotationMutableObjectBaseCore(IAnnotation annotation) {
			this.title = annotation.Title;
			if (annotation.URL != null) {
				this.url = annotation.URL.ToString();
			}
			this.type = annotation.Type;
			if (annotation.Text != null) {
				/* foreach */
				foreach (ITextTypeWrapper currentTextType  in  annotation.Text) {
					this.texts.Add(new TextTypeWrapperMutableCore(currentTextType));
				}
			}
		}
 public void Annotate(IAnnotation annotation)
 {
     if (null == _annotations) {
         _annotations = new Dictionary<Oid, IAnnotation>();
     }
     else {
         if (_annotations.ContainsKey(annotation.Id)) {
             throw new InvalidOperationException();
         }
     }
     _annotations.Add(annotation.Id, annotation);
     return;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AnnotationMutableCore"/> class.
        /// </summary>
        /// <param name="annotation">
        /// The annotation. 
        /// </param>
        public AnnotationMutableCore(IAnnotation annotation)
            : base(annotation)
        {
            this._id = annotation.Id;
            this._title = annotation.Title;
            this._type = annotation.Type;
            if (annotation.Uri != null)
            {
                this.uri = annotation.Uri;
            }

            if (annotation.Text != null)
            {
                foreach (ITextTypeWrapper currentTextType in annotation.Text)
                {
                    this._text.Add(new TextTypeWrapperMutableCore(currentTextType));
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Constructor, annotation hit</summary>
 /// <param name="annotation">Annotation item</param>
 /// <param name="label">Editable text part, or null if hit on edge</param>
 public AnnotationHitEventArgs(IAnnotation annotation, DiagramLabel label)
 {
     Item = annotation;
     Part = label;
 }
Exemple #5
0
 /// <summary>
 ///     Checks if the given <paramref name="annotation" /> is handled by convention when
 ///     applied to the given <paramref name="index" />.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="false" />.
 /// </remarks>
 /// <param name="index">The <see cref="IIndex" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="false" />.</returns>
 protected virtual bool IsHandledByConvention(IIndex index, IAnnotation annotation)
 => false;
 /// <summary>
 /// Constructor, annotation hit</summary>
 /// <param name="annotation">Annotation item</param>
 /// <param name="scrollBar">Specifies a hit on an item's scroll bar part</param>
 public AnnotationHitEventArgs(IAnnotation annotation, DiagramScrollBar scrollBar)
 {
     Item = annotation;
     Part = scrollBar;
 }
        private void annotationsListView_SelectedIndexChanged( object sender, EventArgs e )
        {
            if( lastSelectedAnnotation != null )
                lastSelectedAnnotation.OptionsChanged -= new EventHandler( OnAnnotationChanged );

            if( clearing )
                return;

            if( annotationsListView.SelectedIndices.Count > 0 &&
                currentSpectrum.AnnotationList.Count > annotationsListView.SelectedIndices[0] )
            {
                if (lastSelectedAnnotation == null ||
                    lastSelectedAnnotation.OptionsPanel != currentSpectrum.AnnotationList[annotationsListView.SelectedIndices[0]].OptionsPanel)
                {
                    splitContainer.Panel2.Controls.Clear();
                    splitContainer.Panel2.Controls.Add(currentSpectrum.AnnotationList[annotationsListView.SelectedIndices[0]].OptionsPanel);
                }
                lastSelectedAnnotation = currentSpectrum.AnnotationList[annotationsListView.SelectedIndices[0]];
                lastSelectedAnnotation.OptionsChanged += new EventHandler(OnAnnotationChanged);

                removeAnnotationButton.Enabled = true;
            } else
            {
                splitContainer.Panel2.Controls.Clear();
                lastSelectedAnnotation = null;
                removeAnnotationButton.Enabled = false;
            }
            splitContainer.Panel2.Refresh();
        }
 private void InsertChar(IAnnotation annotation, TextEditor annotationEditor, char charValue)
 {
     var transactionContext = AdaptedControl.ContextAs<ITransactionContext>();
     transactionContext.DoTransaction(() =>
         {
             DeleteTextSelection(annotation);
             InsertText(annotation, new string(charValue, 1));
             annotationEditor.SetSelection(TextEditor.SelectionMode.Right, 1, false, false);
         }, EditAnnotation);
 }
        // Insert text into annotation without adjusting caret position
        private void InsertText(IAnnotation annotation, string text)
        {
            if (m_annotationEditors.ContainsKey(annotation))
            {
                var textProperty = annotation.GetType().GetProperty("Text");
                if (textProperty.CanWrite)
                {
                 

                    //DeleteTextSelection(annotation);
                    var annotationEditor = m_annotationEditors[annotation];
                    var newValue = annotationEditor.InsertTextAt(annotation.Text, text);
                    textProperty.SetValue(annotation, newValue, null);                 

                }

            }
        }
Exemple #10
0
 /// <summary>
 ///     Returns a data annotation attribute code fragment for the given <paramref name="annotation" />,
 ///     or <see langword="null" /> if no data annotation exists for it.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="null" />.
 /// </remarks>
 /// <param name="entityType">The <see cref="IEntityType" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="null" />.</returns>
 protected virtual AttributeCodeFragment?GenerateDataAnnotation(IEntityType entityType, IAnnotation annotation)
 => null;
Exemple #11
0
 /// <summary>
 ///     Returns a data annotation attribute code fragment for the given <paramref name="annotation" />,
 ///     or <see langword="null" /> if no data annotation exists for it.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="null" />.
 /// </remarks>
 /// <param name="property">The <see cref="IProperty" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="null" />.</returns>
 protected virtual AttributeCodeFragment?GenerateDataAnnotation(IProperty property, IAnnotation annotation)
 => null;
Exemple #12
0
 /// <summary>
 ///     Returns a fluent API call for the given <paramref name="annotation" />, or <see langword="null" />
 ///     if no fluent API call exists for it.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="null" />.
 /// </remarks>
 /// <param name="navigation">The <see cref="ISkipNavigation" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="null" />.</returns>
 protected virtual MethodCallCodeFragment?GenerateFluentApi(ISkipNavigation navigation, IAnnotation annotation)
 => null;
Exemple #13
0
 /// <summary>
 ///     Returns a fluent API call for the given <paramref name="annotation" />, or <see langword="null" />
 ///     if no fluent API call exists for it.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="null" />.
 /// </remarks>
 /// <param name="index">The <see cref="IIndex" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="null" />.</returns>
 protected virtual MethodCallCodeFragment?GenerateFluentApi(IIndex index, IAnnotation annotation)
 => null;
Exemple #14
0
 /// <summary>
 ///     Returns a fluent API call for the given <paramref name="annotation" />, or <see langword="null" />
 ///     if no fluent API call exists for it.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="null" />.
 /// </remarks>
 /// <param name="foreignKey">The <see cref="IForeignKey" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="null" />.</returns>
 protected virtual MethodCallCodeFragment?GenerateFluentApi(IForeignKey foreignKey, IAnnotation annotation)
 => null;
Exemple #15
0
 /// <summary>
 ///     Returns a fluent API call for the given <paramref name="annotation" />, or <see langword="null" />
 ///     if no fluent API call exists for it.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="null" />.
 /// </remarks>
 /// <param name="property">The <see cref="IProperty" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="null" />.</returns>
 protected virtual MethodCallCodeFragment?GenerateFluentApi(IProperty property, IAnnotation annotation)
 => null;
Exemple #16
0
 /// <summary>
 ///     Returns a fluent API call for the given <paramref name="annotation" />, or <see langword="null" />
 ///     if no fluent API call exists for it.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="null" />.
 /// </remarks>
 /// <param name="entityType">The <see cref="IEntityType" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="null" />.</returns>
 protected virtual MethodCallCodeFragment?GenerateFluentApi(IEntityType entityType, IAnnotation annotation)
 => null;
Exemple #17
0
 public sxMarkup(IAnnotation ann)
 {
     m_ann = ann;
 }
 private string GenerateAnnotation(IAnnotation annotation)
 {
     return($".HasAnnotation({_cSharpUtilities.DelimitString(annotation.Name)}, {_cSharpUtilities.GenerateLiteral((dynamic)annotation.Value)})");
 }
 // 'location' is in world coordinates
 private void MoveAnnotation(IAnnotation annotation, Point location)
 {
     var bounds = new Rectangle(location.X, location.Y, 0, 0);
     m_layoutContext.SetBounds(annotation, bounds, BoundsSpecified.Location);
 }
Exemple #20
0
 public void AddAnnotation(IAnnotation annotation)
 {
     Trace.Record(annotation);
 }
 public void PasteFromClipboard(IAnnotation annotation)
 {
     if (m_annotationEditors.ContainsKey(annotation))
     {
         var annotationEditor = m_annotationEditors[annotation];
         string text = Clipboard.GetText();
         DeleteTextSelection(annotation);
         InsertText(annotation, text);
         annotationEditor.SetSelection(TextEditor.SelectionMode.RightChar, text.Length, false, false);
     }
     
 }
 public string TextSelected(IAnnotation annotation)
 {
     if (m_annotationEditors.ContainsKey(annotation))
     {
         var annotationData = m_annotationEditors[annotation];
         return annotation.Text.Substring(annotationData.SelectionStart, annotationData.SelectionLength);
     }
     return string.Empty;
 }
 /// <summary>
 /// Constructor, annotation hit</summary>
 /// <param name="annotation">Annotation item</param>
 /// <param name="titleBar">the title bar at the top of the annotation</param>
 public AnnotationHitEventArgs(IAnnotation annotation, DiagramTitleBar titleBar)
 {
     Item = annotation;
     Part = titleBar;
 }
Exemple #26
0
 /// <summary>
 ///     Checks if the given <paramref name="annotation" /> is handled by convention when
 ///     applied to the given <paramref name="property" />.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="false" />.
 /// </remarks>
 /// <param name="property">The <see cref="IProperty" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="false" />.</returns>
 protected virtual bool IsHandledByConvention(IProperty property, IAnnotation annotation)
 => false;
Exemple #27
0
 private void MoveAnnotation(IAnnotation annotation, Point location)
 {
     Rectangle bounds;
     m_layoutContext.GetBounds(annotation, out bounds);
     bounds.Location = location;
     m_layoutContext.SetBounds(annotation, bounds, BoundsSpecified.Location);
 }
Exemple #28
0
        private void DrawAnnotation(IAnnotation annotation, DiagramDrawingStyle style, D2dGraphics g, bool drawText, RectangleF graphBound)
        {
            // fill background
            Rectangle bounds = annotation.Bounds;

            Color backColor = m_coloringContext == null
                                  ? SystemColors.Info
                                  : m_coloringContext.GetColor(ColoringTypes.BackColor, annotation);
            Color foreColor = m_coloringContext == null
                        ? SystemColors.WindowText
                        : m_coloringContext.GetColor(ColoringTypes.ForeColor, annotation);

            // keep the width of border in 2 pixel after transformation to avoid D2d antialiasing away the line
            float borderThickness = 2.0f/m_scaleX;
            g.FillRectangle(bounds, backColor);

            g.DrawRectangle(bounds, m_theme.GetOutLineBrush(style), borderThickness);
       
            //// draw titlebar
            //if (style == DiagramDrawingStyle.LastSelected || style == DiagramDrawingStyle.Selected)
            //{
            //    var titleBarRect = new RectangleF(bounds.X, bounds.Y, bounds.Width, Margin.Top - 1);
            //    g.FillRectangle(titleBarRect, ControlPaint.Dark(backColor));
            //}
            //// line seperate titlebar from text content     
            //g.DrawLine(bounds.X, bounds.Y + Margin.Top-1, bounds.X + bounds.Width, bounds.Y + Margin.Top-1, ControlPaint.Dark(backColor), borderThickness);
            
            // draw content
            if (drawText)
            {
                var contentBounds = new RectangleF(bounds.X + Margin.Left, bounds.Y + Margin.Top,
                                               bounds.Width - Margin.Size.Width, bounds.Height - Margin.Size.Height);
                contentBounds.Width = Math.Max(contentBounds.Width, MinimumWidth);
                contentBounds.Height = Math.Max(contentBounds.Height, MinimumHeight);
                var textBounds = contentBounds;
                
                TextEditor textEditor;
                if (!m_annotationEditors.TryGetValue(annotation,out textEditor))
                {
                    // first assume no v-scroll bar needed
                    var textLayout = D2dFactory.CreateTextLayout(annotation.Text, m_theme.TextFormat, contentBounds.Width, contentBounds.Height);
                    if (m_theme.TextFormat.Underlined)
                        textLayout.SetUnderline(true, 0, annotation.Text.Length);
                    if (m_theme.TextFormat.Strikeout)
                        textLayout.SetStrikethrough(true, 0, annotation.Text.Length);

                    if (textLayout.Height >  textLayout.LayoutHeight) // need v-scroll bar
                    {
                        textLayout.LayoutWidth = contentBounds.Width - ScrollBarWidth - 2 * ScrollBarMargin;
                      
                    }

                    textEditor = new TextEditor
                    {
                        TextLayout = textLayout,
                        TextFormat = m_theme.TextFormat,
                        TopLine =  0,
                        VerticalScrollBarVisibe = textLayout.Height > textLayout.LayoutHeight
                    };
                    m_annotationEditors.Add(annotation, textEditor);                        
                }
                else if (textEditor.TextLayout.Text != annotation.Text) // text content changed, for example, undo,redo
                {                
                    textEditor.ResetText(annotation.Text);                    
                }

                int topLine = textEditor.TopLine;
                textEditor.VerticalScrollBarVisibe = textEditor.TextLayout.Height > textEditor.TextLayout.LayoutHeight;

                if (textEditor.VerticalScrollBarVisibe)
                    textBounds.Width -= ScrollBarWidth + 2 * ScrollBarMargin;
                if (Math.Abs(textEditor.TextLayout.LayoutWidth - textBounds.Width) +
                    Math.Abs(textEditor.TextLayout.LayoutHeight - textBounds.Height) > 1.0)
                {
                    textEditor.TextLayout.LayoutWidth = textBounds.Width; // layout width and height can be updated
                    textEditor.TextLayout.LayoutHeight = textBounds.Height;
                    textEditor.Validate();
                }

                float yOffset = textEditor.GetLineYOffset(topLine);                
                PointF origin = new PointF(contentBounds.Location.X, contentBounds.Location.Y - yOffset);

                g.PushAxisAlignedClip(contentBounds);

               

                // adjust caret.
                // pull out this code to the caller.
                if ( annotation == m_editingAnnotation  && m_caretCreated)
                {                    
                    var caretRect = textEditor.GetCaretRect();
                    caretRect.Offset(origin);                   
                    // set Windows caret position                  
                    if (contentBounds.IntersectsWith(caretRect) && AdaptedControl.Focused)
                    {
                        Matrix3x2F xform = m_transformAdapter != null ? m_transformAdapter.Transform
                            : g.Transform;
                        var caretClientRect = Matrix3x2F.Transform(xform, caretRect);
                        float ratio = m_scaleX*m_theme.TextFormat.FontHeight/CaretHeight;                      
                        if (ratio > 1.1f || ratio < 0.9f) // adjust caret height
                        {
                            CaretHeight = (int)(m_scaleX*m_theme.TextFormat.FontHeight);
                            User32.DestroyCaret();
                            User32.CreateCaret(AdaptedControl.Handle, IntPtr.Zero, CaretWidth, CaretHeight);
                        }
                        // align bottom    
                        User32.SetCaretPos((int) caretClientRect.X, (int)(caretClientRect.Y + caretClientRect.Height - CaretHeight));
                        if (!m_rmbPressed)
                            AdaptedControl.HasKeyboardFocus = true;
                    }
                    else
                        HideCaret();
                }

                // draw the selection range above the text.
                if (textEditor.SelectionLength > 0)
                {
                    D2dBrush hibrush = AdaptedControl.Focused ? m_theme.TextHighlightBrush : m_solidBrush;
                    var hitTestMetrics = textEditor.TextLayout.HitTestTextRange(textEditor.SelectionStart, textEditor.SelectionLength, 0, 0);
                    for (int i = 0; i < hitTestMetrics.Length; ++i)
                    {
                        var highlightRect = new RectangleF(hitTestMetrics[i].Point.X, hitTestMetrics[i].Point.Y, hitTestMetrics[i].Width,
                                                           hitTestMetrics[i].Height);
                        highlightRect.Offset(origin);
                        g.FillRectangle(highlightRect, hibrush);
                    }
                }
                
                // draw text 
                g.DrawTextLayout(origin, textEditor.TextLayout, foreColor);

                

                g.PopAxisAlignedClip();

                // draw v-scroll bar
               // if (contentBounds.Height < textEditor.TextLayout.Height)
                if(textEditor.VerticalScrollBarVisibe)
                {
                    float visibleLines = textEditor.GetVisibleLines();
                    float vMin = topLine * contentBounds.Height / textEditor.TextLayout.LineCount;
                    float vMax = (topLine + visibleLines - 1) * contentBounds.Height / textEditor.TextLayout.LineCount;
                   // if (m_scrolling)
                   // {
                        var trackBounds = new RectangleF(contentBounds.Right - ScrollBarMargin - ScrollBarWidth, contentBounds.Y, ScrollBarWidth, contentBounds.Height);
                        g.FillRectangle(trackBounds, Color.Gainsboro);                    
                   // }
                    var thumbBounds = new RectangleF(contentBounds.Right - ScrollBarMargin - ScrollBarWidth, contentBounds.Y + vMin, ScrollBarWidth, vMax - vMin);
                    g.FillRectangle(thumbBounds, Color.DimGray);
                }                
            }                
        }
Exemple #29
0
        public void OpenFile( string filepath, object idOrIndex, IAnnotation annotation, string spectrumListFilters )
        {
            try
            {
                OnLoadDataSourceProgress("Opening data source: " + Path.GetFileNameWithoutExtension(filepath), 0);

                string[] spectrumListFilterList = spectrumListFilters.Split(';');

                if (!dataSourceMap.ContainsKey(filepath))
                {
                    var newSource = new ManagedDataSource(new SpectrumSource(filepath));
                    dataSourceMap.Add(filepath, newSource);

                    if (spectrumListFilters.Length > 0)
                        SpectrumListFactory.wrap(newSource.Source.MSDataFile, spectrumListFilterList);

                    initializeManagedDataSource( newSource, idOrIndex, annotation, spectrumListFilterList );
                } else
                {
                    GraphForm graph = OpenFileUsesCurrentGraphForm && CurrentGraphForm != null ? CurrentGraphForm
                                                                                               : OpenGraph(OpenFileGivesFocus);
                    ManagedDataSource source = dataSourceMap[filepath];

                    int index = -1;
                    if( idOrIndex is int )
                        index = (int) idOrIndex;
                    else if( idOrIndex is string )
                    {
                        SpectrumList sl = source.Source.MSDataFile.run.spectrumList;
                        int findIndex = sl.find( idOrIndex as string );
                        if( findIndex != sl.size() )
                            index = findIndex;
                    }

                    // conditionally load the spectrum at the specified index
                    if( index > -1 )
                    {
                        MassSpectrum spectrum = source.GetMassSpectrum( index );

                        if (spectrumListFilters.Length > 0)
                            SpectrumListFactory.wrap(source.Source.MSDataFile, spectrumListFilterList);

                        spectrum.AnnotationSettings = defaultScanAnnotationSettings;

                        if( annotation != null )
                            spectrum.AnnotationList.Add( annotation );

                        if (source.Source.Spectra.Count < source.Source.MSDataFile.run.spectrumList.size() &&
                            source.SpectrumListForm.IndexOf(spectrum) < 0)
                        {
                            source.SpectrumListForm.Add(spectrum);
                            source.Source.Spectra.Add(spectrum);
                        }

                        showData(graph, spectrum);
                    } else
                    {
                        if( source.Source.Chromatograms.Count > 0 )
                            showData(graph, source.Source.Chromatograms[0]);
                        else
                            showData(graph, source.Source.Spectra[0]);
                    }
                }

            } catch( Exception ex )
            {
                string message = ex.Message;
                if( ex.InnerException != null )
                    message += "\n\nAdditional information: " + ex.InnerException.Message;
                MessageBox.Show( message,
                                "Error opening source file",
                                MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                0, false );
                OnLoadDataSourceProgress("Failed to load data: " + ex.Message, 100);
            }
        }
Exemple #30
0
 /// <summary>
 ///     Checks if the given <paramref name="annotation" /> is handled by convention when
 ///     applied to the given <paramref name="foreignKey" />.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="false" />.
 /// </remarks>
 /// <param name="foreignKey">The <see cref="IForeignKey" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="false" />.</returns>
 protected virtual bool IsHandledByConvention(IForeignKey foreignKey, IAnnotation annotation)
 => false;
Exemple #31
0
        /// <summary>
        /// Tests when the annotation is selected and the adapted control has keyboard focus</summary>
        /// <param name="annotation">IAnnotation to test</param>
        /// <returns>True iff the annotation is selected and the adapted control has keyboard focus</returns>
        public bool CanInsertText(IAnnotation annotation)
        {
            return m_selectionContext.SelectionContains(annotation) && AdaptedControl.HasKeyboardFocus;

        }
Exemple #32
0
 public IAnnotationObject(IAnnotation IAnnotationinstance)
 {
     IAnnotationInstance = IAnnotationinstance;
 }
		public AnnotationObjectBaseCore(IAnnotation annotation) {
			this.title = annotation.Title;
			this.url = annotation.URL;
			this.type = annotation.Type;
			this.text = Org.Sdmxsource.Sdmx.Util.Objects.LocaleUtil.BuildLocalMap(annotation.Text);
		}
Exemple #34
0
        /// <summary>Draws the specified series definition on the view.</summary>
        /// <param name="annotations">The list of annotations</param>
        private void DrawOnView(IEnumerable <IAnnotation> annotations)
        {
            var range = graphView.AxisMaximum(AxisPosition.Bottom) - graphView.AxisMinimum(AxisPosition.Bottom);

            double minimumX         = graphView.AxisMinimum(AxisPosition.Bottom) + range * 0.03;
            double maximumX         = graphView.AxisMaximum(AxisPosition.Bottom);
            double minimumY         = graphView.AxisMinimum(AxisPosition.Left);
            double maximumY         = graphView.AxisMaximum(AxisPosition.Left);
            double lowestAxisScale  = Math.Min(minimumX, minimumY);
            double largestAxisScale = Math.Max(maximumX, maximumY);

            for (int i = 0; i < annotations.Count(); i++)
            {
                IAnnotation annotation = annotations.ElementAt(i);
                if (annotation is TextAnnotation textAnnotation)
                {
                    double interval = (maximumY - lowestAxisScale) / 8; // fit 8 annotations on graph.

                    object x, y;
                    bool   leftAlign = textAnnotation.leftAlign;
                    bool   topAlign  = textAnnotation.topAlign;
                    if (textAnnotation.Name != null && textAnnotation.Name.StartsWith("Regression"))
                    {
                        if (graph.AnnotationLocation == AnnotationPosition.TopLeft)
                        {
                            x = minimumX;
                            y = maximumY - i * interval;
                        }
                        else if (graph.AnnotationLocation == AnnotationPosition.TopRight)
                        {
                            x         = minimumX + range * 0.95;
                            y         = maximumY - i * interval;
                            leftAlign = false;
                        }
                        else if (graph.AnnotationLocation == AnnotationPosition.BottomRight)
                        {
                            x         = minimumX + range * 0.95;
                            y         = minimumY + i * interval;
                            leftAlign = false;
                            topAlign  = false;
                        }
                        else
                        {
                            x        = minimumX;
                            y        = minimumY + i * interval;
                            topAlign = false;
                        }

                        //y = largestAxisScale - (i * interval);
                    }
                    else
                    {
                        x = textAnnotation.x;
                        y = textAnnotation.y;
                    }

                    graphView.DrawText(textAnnotation.text,
                                       x,
                                       y,
                                       leftAlign,
                                       topAlign,
                                       textAnnotation.textRotation,
                                       AxisPosition.Bottom,
                                       AxisPosition.Left,
                                       GetColour(textAnnotation.colour));
                }
                else if (annotation is LineAnnotation lineAnnotation)
                {
                    graphView.DrawLine(
                        lineAnnotation.x1,
                        lineAnnotation.y1,
                        lineAnnotation.x2,
                        lineAnnotation.y2,
                        lineAnnotation.type,
                        lineAnnotation.thickness,
                        GetColour(lineAnnotation.colour),
                        lineAnnotation.InFrontOfSeries,
                        lineAnnotation.ToolTip);
                }
                else
                {
                    throw new Exception($"Unknown annotation type {annotation.GetType()}");
                }
            }
        }
Exemple #35
0
        /// <summary>
        ///     <para>
        ///         Returns a fluent API call for the given <paramref name="annotation" />, or <see langword="null" />
        ///         if no fluent API call exists for it.
        ///     </para>
        ///     <para>
        ///         The default implementation always returns <see langword="null" />.
        ///     </para>
        /// </summary>
        /// <param name="entityType"> The <see cref="IEntityType" />. </param>
        /// <param name="annotation"> The <see cref="IAnnotation" />. </param>
        /// <returns> <see langword="null" />. </returns>
        protected virtual MethodCallCodeFragment?GenerateFluentApi(IEntityType entityType, IAnnotation annotation)
        {
            Check.NotNull(entityType, nameof(entityType));
            Check.NotNull(annotation, nameof(annotation));

            return(null);
        }
Exemple #36
0
        /// <summary>
        ///     <para>
        ///         Returns a fluent API call for the given <paramref name="annotation" />, or <see langword="null" />
        ///         if no fluent API call exists for it.
        ///     </para>
        ///     <para>
        ///         The default implementation always returns <see langword="null" />.
        ///     </para>
        /// </summary>
        /// <param name="property"> The <see cref="IProperty" />. </param>
        /// <param name="annotation"> The <see cref="IAnnotation" />. </param>
        /// <returns> <see langword="null" />. </returns>
        protected virtual MethodCallCodeFragment?GenerateFluentApi(IProperty property, IAnnotation annotation)
        {
            Check.NotNull(property, nameof(property));
            Check.NotNull(annotation, nameof(annotation));

            return(null);
        }
Exemple #37
0
        /// <summary>
        /// Tests when the annotation is selected and the adapted control has keyboard focus</summary>
        /// <param name="annotation">IAnnotation to test</param>
        /// <returns>True iff the adapted control has input focus,  the annotation node is selected, 
        /// and text selected for the annotation node</returns>
        public bool CanCopyText(IAnnotation annotation)
        {
            if (m_selectionContext.GetSelection<IAnnotation>().Contains(annotation) &&
                AdaptedControl.Focused)
            {
                string textSelected = TextSelected(annotation);
                return !string.IsNullOrEmpty(textSelected);
            }

            return false;
        }
Exemple #38
0
        /// <summary>
        ///     <para>
        ///         Returns a fluent API call for the given <paramref name="annotation" />, or <see langword="null" />
        ///         if no fluent API call exists for it.
        ///     </para>
        ///     <para>
        ///         The default implementation always returns <see langword="null" />.
        ///     </para>
        /// </summary>
        /// <param name="foreignKey"> The <see cref="IForeignKey" />. </param>
        /// <param name="annotation"> The <see cref="IAnnotation" />. </param>
        /// <returns> <see langword="null" />. </returns>
        protected virtual MethodCallCodeFragment?GenerateFluentApi(IForeignKey foreignKey, IAnnotation annotation)
        {
            Check.NotNull(foreignKey, nameof(foreignKey));
            Check.NotNull(annotation, nameof(annotation));

            return(null);
        }
        private Rectangle GetBounds(IAnnotation annotation)
        {
            Rectangle bounds = annotation.Bounds;
            if (bounds.Size.IsEmpty && m_theme != null)
            {
                D2dGraphics g = ((D2dAdaptableControl)this.AdaptedControl).D2dGraphics;

                // calculate size of text block
                SizeF textSizeF = g.MeasureText(annotation.Text, m_theme.TextFormat);
                bounds.Size = new Size((int)textSizeF.Width + 2 * Margin.Size.Width, (int)textSizeF.Height + 2 * Margin.Size.Height);

                // Don't update the IAnnotation. http://forums.ship.scea.com/jive/thread.jspa?threadID=10751
                //annotation.SetTextSize(textSize);
            }
            return bounds;
        }
Exemple #40
0
        /// <summary>
        ///     <para>
        ///         Returns a fluent API call for the given <paramref name="annotation" />, or <see langword="null" />
        ///         if no fluent API call exists for it.
        ///     </para>
        ///     <para>
        ///         The default implementation always returns <see langword="null" />.
        ///     </para>
        /// </summary>
        /// <param name="navigation"> The <see cref="ISkipNavigation" />. </param>
        /// <param name="annotation"> The <see cref="IAnnotation" />. </param>
        /// <returns> <see langword="null" />. </returns>
        protected virtual MethodCallCodeFragment?GenerateFluentApi(ISkipNavigation navigation, IAnnotation annotation)
        {
            Check.NotNull(navigation, nameof(navigation));
            Check.NotNull(annotation, nameof(annotation));

            return(null);
        }
 // Delete any existing selection
 public void DeleteTextSelection(IAnnotation annotation)
 {
     if (m_annotationEditors.ContainsKey(annotation))
     {             
         var textProperty = annotation.GetType().GetProperty("Text");
         if (textProperty.CanWrite)
         {
             var annotationEditor = m_annotationEditors[annotation];
             annotationEditor.UpdateSelectionRange();
             if (annotationEditor.SelectionLength > 0)
             {                  
                 var newValue = annotationEditor.RemoveTextAt(annotation.Text, annotationEditor.SelectionStart,
                                                              annotationEditor.SelectionLength);
                 textProperty.SetValue(annotation, newValue, null);
                 annotationEditor.SetSelection(TextEditor.SelectionMode.AbsoluteLeading, annotationEditor.SelectionStart, false, false);
                 
             }
         }
      
     }
 }
Exemple #42
0
        /// <summary>
        ///     <para>
        ///         Returns a data annotation attribute code fragment for the given <paramref name="annotation" />,
        ///         or <see langword="null" /> if no data annotation exists for it.
        ///     </para>
        ///     <para>
        ///         The default implementation always returns <see langword="null" />.
        ///     </para>
        /// </summary>
        /// <param name="entityType"> The <see cref="IEntityType" />. </param>
        /// <param name="annotation"> The <see cref="IAnnotation" />. </param>
        /// <returns> <see langword="null" />. </returns>
        protected virtual AttributeCodeFragment?GenerateDataAnnotation(IEntityType entityType, IAnnotation annotation)
        {
            Check.NotNull(entityType, nameof(entityType));
            Check.NotNull(annotation, nameof(annotation));

            return(null);
        }
 private void CopyToClipboard(IAnnotation annotation)
 {
     string textSelected = TextSelected(annotation);
     if (!string.IsNullOrEmpty(textSelected))
         Clipboard.SetText(textSelected);
 }
Exemple #44
0
        /// <summary>
        ///     <para>
        ///         Returns a data annotation attribute code fragment for the given <paramref name="annotation" />,
        ///         or <see langword="null" /> if no data annotation exists for it.
        ///     </para>
        ///     <para>
        ///         The default implementation always returns <see langword="null" />.
        ///     </para>
        /// </summary>
        /// <param name="property"> The <see cref="IProperty" />. </param>
        /// <param name="annotation"> The <see cref="IAnnotation" />. </param>
        /// <returns> <see langword="null" />. </returns>
        protected virtual AttributeCodeFragment?GenerateDataAnnotation(IProperty property, IAnnotation annotation)
        {
            Check.NotNull(property, nameof(property));
            Check.NotNull(annotation, nameof(annotation));

            return(null);
        }
 // return true when the annotation is selected and the adapted control has keyboard focus
 public bool CanCopyText(IAnnotation annotation)
 {
     return m_selectionContext.GetSelection<IAnnotation>().Contains(annotation) &&
         AdaptedControl.HasKeyboardFocus;
 }
Exemple #46
0
        private void Record(Trace trace, IAnnotation annotation)
        {
            var record = new Record(trace.CurrentSpan, TimeUtils.UtcNow, annotation);

            _tracer.Record(record);
        }
 /// <summary>
 /// Constructor, annotation hit</summary>
 /// <param name="annotation">Annotation item</param>
 /// <param name="border">Specifies a hit on an item's border part</param>
 public AnnotationHitEventArgs(IAnnotation annotation, DiagramBorder border)
 {
     Item = annotation;
     Part = border;
 }
Exemple #48
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public override MethodCallCodeFragment GenerateFluentApi(IKey key, IAnnotation annotation)
 => annotation.Name == SqlServerAnnotationNames.Clustered
         ? (bool)annotation.Value == false
             ? new MethodCallCodeFragment(nameof(SqlServerIndexBuilderExtensions.ForSqlServerIsClustered), false)
             : new MethodCallCodeFragment(nameof(SqlServerIndexBuilderExtensions.ForSqlServerIsClustered))
         : null;
        private void DrawAnnotation(IAnnotation annotation, DiagramDrawingStyle style, D2dGraphics g, bool drawText, RectangleF graphBound)
        {
            // fill background
            Rectangle bounds = annotation.Bounds;

            Color backColor = m_coloringContext == null
                                  ? SystemColors.Info
                                  : (Color) m_coloringContext.GetColor(ColoringTypes.BackColor, annotation);
            // keep the width of border in 1 pixel after transformation to avoid D2d antialiasing away the line
            float borderThickness = 1.0f/m_scaleX;
            g.FillRectangle(bounds, backColor);
            g.DrawRectangle(bounds, ControlPaint.Dark(backColor), borderThickness, null);
       
            // draw titlebar
            if (style == DiagramDrawingStyle.LastSelected || style == DiagramDrawingStyle.Selected)
            {
                var titleBarRect = new RectangleF(bounds.X, bounds.Y, bounds.Width, Margin.Top - 1);
                g.FillRectangle(titleBarRect, ControlPaint.Dark(backColor));
            }
            // line seperate titlebar from text content     
            g.DrawLine(bounds.X, bounds.Y + Margin.Top-1, bounds.X + bounds.Width, bounds.Y + Margin.Top-1, ControlPaint.Dark(backColor), borderThickness);

            // draw content
            if (drawText)
            {
                var contentBounds = new RectangleF(bounds.X + Margin.Left, bounds.Y + Margin.Top,
                                               bounds.Width - Margin.Size.Width, bounds.Height - Margin.Size.Height);

                contentBounds.Width = Math.Max(contentBounds.Width, MinimumWidth);
                contentBounds.Height = Math.Max(contentBounds.Height, MinimumHeight);
                var textBounds = contentBounds;              
    
                int topLine = 0;
                D2dTextLayout textLayout = null;

                if (m_annotationEditors.ContainsKey(annotation))
                {
                                     
                    var annotationEditor = m_annotationEditors[annotation];
                    if (annotationEditor.TextLayout.Text != annotation.Text) // text content changed, for example, undo,redo
                    {
                        annotationEditor.ResetText(annotation.Text);
                    }
                    topLine = annotationEditor.TopLine;
                    textLayout = m_annotationEditors[annotation].TextLayout;
                    annotationEditor.VerticalScrollBarVisibe = textLayout.Height > textLayout.LayoutHeight;

                    if (m_annotationEditors[annotation].VerticalScrollBarVisibe)
                        textBounds.Width -= ScrollBarWidth + 2 * ScrollBarMargin;
                    textLayout.LayoutWidth = textBounds.Width;
                    textLayout.LayoutHeight = textBounds.Height;
                 
                }

                if (textLayout == null)
                {
                    // first assume no v-scroll bar needed
                    textLayout = D2dFactory.CreateTextLayout(annotation.Text, m_theme.TextFormat, contentBounds.Width, contentBounds.Height);
                    if (m_theme.TextFormat.Underlined)
                        textLayout.SetUnderline(true, 0, annotation.Text.Length);
                    if (m_theme.TextFormat.Strikeout)
                        textLayout.SetStrikethrough(true, 0, annotation.Text.Length);

                    if (textLayout.Height >  textLayout.LayoutHeight) // need v-scroll bar
                    {
                        textLayout.LayoutWidth = contentBounds.Width - ScrollBarWidth - 2*ScrollBarMargin;
                      
                    }
                    m_annotationEditors.Add(annotation, new TextEditor()
                        {
                            TextLayout = textLayout,
                            TextFormat = m_theme.TextFormat,
                            TopLine =  topLine,
                            VerticalScrollBarVisibe = textLayout.Height > textLayout.LayoutHeight
                        });
                }

                var annotationData = m_annotationEditors[annotation];
                PointF origin = new PointF(contentBounds.Location.X, contentBounds.Location.Y - topLine *  m_theme.TextFormat.FontHeight);

                g.PushAxisAlignedClip(contentBounds);

                // draw the selection range behind the text.
                if (annotationData.SelectionLength > 0)
                {
                    var hitTestMetrics = textLayout.HitTestTextRange(annotationData.SelectionStart, annotationData.SelectionLength, 0, 0);
                    for (int i = 0; i < hitTestMetrics.Length; ++i)
                    {

                        var highlightRect = new RectangleF(hitTestMetrics[i].Point.X, hitTestMetrics[i].Point.Y, hitTestMetrics[i].Width,
                                                           hitTestMetrics[i].Height);
                        highlightRect.Offset(origin);
                        g.FillRectangle(highlightRect, m_theme.TextHighlightBrush);
                    }               
                }

                // draw caret
                
                if ( style == DiagramDrawingStyle.Selected || style == DiagramDrawingStyle.LastSelected)
                {
                    textLayout = annotationData.TextLayout;
                    var caretRect = m_annotationEditors[annotation].GetCaretRect();
                    caretRect.Offset(origin);
                    //g.FillRectangle(caretRect, m_theme.HotBrush);

                    // set Windows caret position                  
                    if (m_editingText && contentBounds.IntersectsWith(caretRect) && graphBound.IntersectsWith(caretRect) && AdaptedControl.Focused)
                    {
                        var caretClientRect = GdiUtil.Transform(m_transformAdapter.Transform, caretRect);
                        float ratio = m_scaleX*m_theme.TextFormat.FontHeight/CaretHeight;                      
                        if (ratio > 1.1f || ratio < 0.9f) // adjust caret height
                        {
                            CaretHeight = (int)(m_scaleX*m_theme.TextFormat.FontHeight);
                            User32.DestroyCaret();
                            User32.CreateCaret(AdaptedControl.Handle, IntPtr.Zero, CaretWidth, CaretHeight);
                        }
                        // align bottom    
                        User32.SetCaretPos((int) caretClientRect.X, (int)(caretClientRect.Y + caretClientRect.Height - CaretHeight));
                        if (!m_rmbPressed)
                            AdaptedControl.HasKeyboardFocus = true;
                    }
                    else
                        HideCaret();
                }

                // draw text 
                g.DrawTextLayout(origin, textLayout, m_theme.TextBrush); 

                g.PopAxisAlignedClip();

                // draw v-scroll bar
                if (contentBounds.Height < textLayout.Height)
                {
                    float visibleLines = contentBounds.Height / m_theme.TextFormat.FontHeight;
                    float vMin = topLine * textLayout.LayoutHeight / textLayout.LineCount;
                    float vMax = (topLine + visibleLines-1) * textLayout.LayoutHeight / textLayout.LineCount;
                    if (m_scrolling)
                    {
                        var trackBounds = new RectangleF(contentBounds.Right - ScrollBarMargin - ScrollBarWidth, contentBounds.Y, ScrollBarWidth, contentBounds.Height);
                        g.FillRectangle(trackBounds, Color.Gainsboro);                    
                    }
                    var thumbBounds = new RectangleF(contentBounds.Right - ScrollBarMargin - ScrollBarWidth, contentBounds.Y + vMin, ScrollBarWidth, vMax - vMin);
                    g.FillRectangle(thumbBounds, Color.DimGray);
                }                
            }
            else
                HideCaret();
        }
 public bool IsHandledByConvention(IModel model, IAnnotation annotation)
 {
     throw new NotImplementedException();
 }
 public void DidSelectAnnotation (MapView mapView, IAnnotation annotation)
 {
     // Just show the user which one was pressed
     new UIAlertView ("Annotation Tapped", "You tapped on: " + annotation.GetTitle (), null, "OK")
         .Show ();
 }
 public bool IsHandledByConvention(IEntityType entityType, IAnnotation annotation)
 {
     throw new NotImplementedException();
 }
Exemple #53
0
        private void DrawAnnotation(IAnnotation annotation, DiagramDrawingStyle style, Graphics g)
        {
            Rectangle bounds = annotation.Bounds;
            if (bounds.Size.IsEmpty)
            {
                // calculate size of text block
                SizeF textSizeF = g.MeasureString(annotation.Text, m_theme.Font);
                Size textSize = new Size((int)Math.Ceiling(textSizeF.Width), (int)Math.Ceiling(textSizeF.Height));
                bounds.Size = textSize;
                annotation.SetTextSize(textSize);
            }
            g.FillRectangle(SystemBrushes.Info, bounds);
            if ((style & DiagramDrawingStyle.Ghosted) == 0)
            {
                g.DrawString(annotation.Text, m_theme.Font, SystemBrushes.WindowText, bounds);

                Pen pen = null;
                if ((style & DiagramDrawingStyle.LastSelected) != 0)
                    pen = m_theme.LastHighlightPen;
                else if ((style & DiagramDrawingStyle.Selected) != 0)
                    pen = m_theme.HighlightPen;

                if (pen != null)
                    g.DrawRectangle(pen, bounds);
            }
        }
 public bool IsHandledByConvention(IProperty property, IAnnotation annotation)
 {
     throw new NotImplementedException();
 }
Exemple #55
0
        // Gets a possibly imperfect bounding box around the annotation. Only DrawAnnotation, when
        //  using the Graphics object, can be perfect.
        private Rectangle GetBounds(IAnnotation annotation)
        {
            Rectangle bounds = annotation.Bounds;
            if (bounds.Size.IsEmpty)
            {
                // calculate size of text block
                SizeF textSizeF = TextRenderer.MeasureText(annotation.Text, m_theme.Font);
                Size textSize = new Size((int)textSizeF.Width, (int)textSizeF.Height);
                bounds.Size = textSize;

                // Don't update the IAnnotation. http://forums.ship.scea.com/jive/thread.jspa?threadID=10751
                //annotation.SetTextSize(textSize);
            }
            return bounds;
        }
 public bool IsHandledByConvention(IForeignKey foreignKey, IAnnotation annotation)
 {
     throw new NotImplementedException();
 }
Exemple #57
0
 public void OpenFile(string filepath, object idOrIndex, IAnnotation annotation)
 {
     OpenFile(filepath, idOrIndex, annotation, "");
 }
 public bool IsHandledByConvention(IIndex index, IAnnotation annotation)
 {
     throw new NotImplementedException();
 }
Exemple #59
0
        private void initializeManagedDataSource( ManagedDataSource managedDataSource, object idOrIndex, IAnnotation annotation, string[] spectrumListFilters )
        {
            try
            {
                SpectrumSource source = managedDataSource.Source;
                MSData msDataFile = source.MSDataFile;
                ChromatogramListForm chromatogramListForm = managedDataSource.ChromatogramListForm;
                SpectrumListForm spectrumListForm = managedDataSource.SpectrumListForm;

                chromatogramListForm.CellDoubleClick += new ChromatogramListCellDoubleClickHandler( chromatogramListForm_CellDoubleClick );
                chromatogramListForm.CellClick += new ChromatogramListCellClickHandler( chromatogramListForm_CellClick );
                chromatogramListForm.GotFocus += new EventHandler( form_GotFocus );

                spectrumListForm.CellDoubleClick += new SpectrumListCellDoubleClickHandler( spectrumListForm_CellDoubleClick );
                spectrumListForm.CellClick += new SpectrumListCellClickHandler( spectrumListForm_CellClick );
                spectrumListForm.FilterChanged += new SpectrumListFilterChangedHandler( spectrumListForm_FilterChanged );
                spectrumListForm.GotFocus += new EventHandler( form_GotFocus );

                bool firstChromatogramLoaded = false;
                bool firstSpectrumLoaded = false;
                GraphForm firstGraph = null;

                ChromatogramList cl = msDataFile.run.chromatogramList;
                SpectrumList sl = msDataFile.run.spectrumList;
                //sl = new SpectrumList_Filter( sl, new SpectrumList_FilterAcceptSpectrum( acceptSpectrum ) );

                if (sl.size()+cl.size() == 0)
                    throw new Exception("Error loading metadata: no spectra or chromatograms");

                Type indexType = typeof(MassSpectrum);
                int index = -1;
                if( idOrIndex is int )
                    index = (int) idOrIndex;
                else if( idOrIndex is string )
                {
                    int findIndex = sl.find(idOrIndex as string);
                    if (findIndex != sl.size())
                        index = findIndex;

                    if (index == -1)
                    {
                        indexType = typeof(Chromatogram);
                        findIndex = cl.find(idOrIndex as string);
                        if (findIndex != cl.size())
                            index = findIndex;
                    }
                }

                // conditionally load the spectrum at the specified index first
                if( index > -1 )
                {
                    GraphItem item = null;
                    if (indexType == typeof(MassSpectrum))
                    {
                        MassSpectrum spectrum = managedDataSource.GetMassSpectrum(index);
                        if (spectrumListFilters.Length > 0)
                            spectrum = managedDataSource.GetMassSpectrum(spectrum, spectrumListFilters);

                        spectrum.AnnotationSettings = defaultScanAnnotationSettings;
                        spectrumListForm.Add(spectrum);
                        source.Spectra.Add(spectrum);

                        firstSpectrumLoaded = true;

                        if (ShowSpectrumListForNewSources)
                        {
                            spectrumListForm.Show(DockPanel, DockState.DockBottom);
                            Application.DoEvents();
                        }

                        if (annotation != null)
                            spectrum.AnnotationList.Add(annotation);

                        item = spectrum;
                    }
                    else
                    {
                        Chromatogram chromatogram = managedDataSource.GetChromatogram(index);

                        chromatogram.AnnotationSettings = defaultChromatogramAnnotationSettings;
                        chromatogramListForm.Add(chromatogram);
                        source.Chromatograms.Add(chromatogram);

                        firstChromatogramLoaded = true;

                        if (ShowChromatogramListForNewSources)
                        {
                            chromatogramListForm.Show(DockPanel, DockState.DockBottom);
                            Application.DoEvents();
                        }

                        item = chromatogram;
                    }

                    firstGraph = OpenFileUsesCurrentGraphForm && CurrentGraphForm != null ? CurrentGraphForm
                                                                                          : OpenGraph(OpenFileGivesFocus);

                    showData(firstGraph, item);
                    return;
                }

                int ticIndex = cl.find( "TIC" );
                if( ticIndex < cl.size() )
                {
                    pwiz.CLI.msdata.Chromatogram tic = cl.chromatogram( ticIndex );
                    Chromatogram ticChromatogram = managedDataSource.GetChromatogram( ticIndex );
                    ticChromatogram.AnnotationSettings = defaultChromatogramAnnotationSettings;
                    chromatogramListForm.Add( ticChromatogram );
                    source.Chromatograms.Add( ticChromatogram );
                    if( !firstSpectrumLoaded )
                    {
                        firstGraph = OpenGraph( true );
                        showData( firstGraph, ticChromatogram );
                        firstChromatogramLoaded = true;

                        if (ShowChromatogramListForNewSources)
                        {
                            chromatogramListForm.Show(DockPanel, DockState.DockBottom);
                            Application.DoEvents();
                        }
                    }
                }

                // get spectrum type from fileContent if possible, otherwise from first spectrum
                CVParam spectrumType = msDataFile.fileDescription.fileContent.cvParamChild( CVID.MS_spectrum_type );
                if( spectrumType.cvid == CVID.CVID_Unknown && sl.size() > 0 )
                    spectrumType = sl.spectrum( 0 ).cvParamChild( CVID.MS_spectrum_type );

                // load the rest of the chromatograms
                for( int i = 0; i < cl.size(); ++i )
                {
                    if( i == ticIndex )
                        continue;

                    Chromatogram chromatogram = managedDataSource.GetChromatogram( i );

                    if (OnLoadDataSourceProgress(String.Format("Loading chromatograms from {0} ({1} of {2})...",
                                                           managedDataSource.Source.Name, (i + 1), cl.size()),
                                                 (i + 1) * 100 / cl.size()))
                        return;

                    chromatogram.AnnotationSettings = defaultChromatogramAnnotationSettings;
                    chromatogramListForm.Add( chromatogram );
                    source.Chromatograms.Add( chromatogram );
                    if( !firstSpectrumLoaded && !firstChromatogramLoaded )
                    {
                        firstChromatogramLoaded = true;

                        if (ShowChromatogramListForNewSources)
                        {
                            chromatogramListForm.Show(DockPanel, DockState.DockBottom);
                            Application.DoEvents();
                        }

                        firstGraph = OpenGraph( true );
                        showData(firstGraph, chromatogram );
                    }
                    Application.DoEvents();
                }

                // get all scans by sequential access
                for( int i = 0; i < sl.size(); ++i )
                {
                    if( i == index ) // skip the preloaded spectrum
                        continue;

                    MassSpectrum spectrum = managedDataSource.GetMassSpectrum( i );

                    if (((i + 1) % 100) == 0 || (i + 1) == sl.size())
                    {
                        if (OnLoadDataSourceProgress(String.Format("Loading spectra from {0} ({1} of {2})...",
                                                               managedDataSource.Source.Name, (i + 1), sl.size()),
                                                     (i + 1) * 100 / sl.size()))
                            return;
                    }

                    spectrum.AnnotationSettings = defaultScanAnnotationSettings;
                    spectrumListForm.Add( spectrum );
                    source.Spectra.Add( spectrum );
                    if( !firstSpectrumLoaded )
                    {
                        firstSpectrumLoaded = true;
                        spectrumListForm.Show( DockPanel, DockState.DockBottom );
                        Application.DoEvents();
                        if( firstChromatogramLoaded )
                        {
                            GraphForm spectrumGraph = CreateGraph();
                            spectrumGraph.Show( firstGraph.Pane, DockPaneAlignment.Bottom, 0.5 );
                            showData(spectrumGraph, spectrum );
                        } else
                        {
                            firstGraph = OpenGraph( true );
                            showData(firstGraph, spectrum );
                        }
                    }
                    Application.DoEvents();
                }

                OnLoadDataSourceProgress("Finished loading source metadata.", 100);

            } catch( Exception ex )
            {
                string message = "SeeMS encountered an error reading metadata from \"" + managedDataSource.Source.CurrentFilepath + "\" (" + ex.ToString() + ")";
                if( ex.InnerException != null )
                    message += "\n\nAdditional information: " + ex.InnerException.ToString();
                MessageBox.Show( message,
                                "Error reading source metadata",
                                MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                0, false );
                OnLoadDataSourceProgress("Failed to load data: " + ex.Message, 100);
            }
        }
Exemple #60
0
 /// <summary>
 ///     Checks if the given <paramref name="annotation" /> is handled by convention when
 ///     applied to the given <paramref name="key" />.
 /// </summary>
 /// <remarks>
 ///     The default implementation always returns <see langword="false" />.
 /// </remarks>
 /// <param name="key">The <see cref="IKey" />.</param>
 /// <param name="annotation">The <see cref="IAnnotation" />.</param>
 /// <returns><see langword="false" />.</returns>
 protected virtual bool IsHandledByConvention(IKey key, IAnnotation annotation)
 => false;