Beispiel #1
0
 private void DeleteFacetCategory(FacetCategory f)
 {
     f.IsSelected = false;
     AvailableFacets.Items.Add(f);
     SelectedFacets.Items.Remove(f);
     ImagePreview.Children.Remove(CurrentFacetCategory.tb);
     StatusBlock.Text     = DefaultStatusLine;
     CurrentFacetCategory = null;
 }
Beispiel #2
0
        public static void CreateFacetCategories(UIParameters Up)
        {
            // Query information
            Up.FacetCategories.Add(new FacetCategory("InputOrder", "Number", "0", true));
            Up.FacetCategories.Add(new FacetCategory("QueryLen", "Number", "0", true));
            FacetCategory fc = new FacetCategory("QueryName", "String", false);

            fc.IsMetaDataVisible  = false;
            fc.IsWordWheelVisible = true;
            Up.FacetCategories.Add(fc);
            FacetCategory fc_seq = new FacetCategory("QuerySequence", "String", false);

            fc.IsMetaDataVisible  = false;
            fc.IsWordWheelVisible = false;
            Up.FacetCategories.Add(fc_seq);

            // BLAST alignment information
            Up.FacetCategories.Add(new FacetCategory("Rank", "Number", "0", true));
            Up.FacetCategories.Add(new FacetCategory("Annotated", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Score", "Number", "0.0", true));
            Up.FacetCategories.Add(new FacetCategory("EValue", "String", false));
            Up.FacetCategories.Add(new FacetCategory("Identity", "Number", "0.00", true));
            Up.FacetCategories.Add(new FacetCategory("Span", "Number", "0.00", true));
            Up.FacetCategories.Add(new FacetCategory("AlignLen", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("NextScore", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Strand", "String", false));
            Up.FacetCategories.Add(new FacetCategory("SubjStart", "Number", "0", false));
            Up.FacetCategories.Add(new FacetCategory("SubjLen", "Number", "0", false));
            // Gene information
            Up.FacetCategories.Add(new FacetCategory("Gene", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("GI", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("Accession", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("Definition", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Product", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Function", "LongString", false));
            // Organism information
            Up.FacetCategories.Add(new FacetCategory("Lineage", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Organism", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Species", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Genus", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Kingdom", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Phylum", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Class", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Order", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Family", "String", true));
            // References
            Up.FacetCategories.Add(new FacetCategory("RefCount", "Number", "0", true));
            fc = new FacetCategory("References", "Link", false);
            fc.IsMetaDataVisible  = true;
            fc.IsWordWheelVisible = false;
            Up.FacetCategories.Add(fc);
            Up.FacetCategories.Add(new FacetCategory("SubmissionDate", "DateTime", true));
        }
Beispiel #3
0
        private void LoadItemInPreview(FacetCategory fc, Color c, double x, double y, int z, double fontSize)
        {
            fc.tb.FontSize = fontSize;
            SolidColorBrush b = new SolidColorBrush(c);

            fc.tb.Foreground = b;
            fc.tb.SetValue(Canvas.LeftProperty, x * Image.ScaleFactor);
            fc.tb.SetValue(Canvas.TopProperty, y * Image.ScaleFactor);
            fc.tb.SetValue(Canvas.ZIndexProperty, z);
            AddFacetCategoryToImage2(fc);
            AvailableFacets.Items.Remove(fc);
        }
Beispiel #4
0
        public static void CreateFacetCategories(UIParameters Up)
        {
            // Query information
            Up.FacetCategories.Add(new FacetCategory("InputOrder", "Number", "0", true));
            Up.FacetCategories.Add(new FacetCategory("QueryLen", "Number", "0", true));
            FacetCategory fc = new FacetCategory("QueryName", "String", false);
            fc.IsMetaDataVisible = false;
            fc.IsWordWheelVisible = true;
            Up.FacetCategories.Add(fc);
            FacetCategory fc_seq = new FacetCategory("QuerySequence", "String", false);
            fc.IsMetaDataVisible = false;
            fc.IsWordWheelVisible = false;
            Up.FacetCategories.Add(fc_seq);

            // BLAST alignment information
            Up.FacetCategories.Add(new FacetCategory("Rank", "Number", "0", true));
            Up.FacetCategories.Add(new FacetCategory("Annotated", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Score", "Number", "0.0", true));
            Up.FacetCategories.Add(new FacetCategory("EValue", "String", false));
            Up.FacetCategories.Add(new FacetCategory("Identity", "Number", "0.00", true));
            Up.FacetCategories.Add(new FacetCategory("Span", "Number", "0.00", true));
            Up.FacetCategories.Add(new FacetCategory("AlignLen", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("NextScore", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Strand", "String", false));
            Up.FacetCategories.Add(new FacetCategory("SubjStart", "Number", "0", false));
            Up.FacetCategories.Add(new FacetCategory("SubjLen", "Number", "0", false));
            // Gene information
            Up.FacetCategories.Add(new FacetCategory("Gene", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("GI", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("Accession", "Link", false));
            Up.FacetCategories.Add(new FacetCategory("Definition", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Product", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Function", "LongString", false));
            // Organism information
            Up.FacetCategories.Add(new FacetCategory("Lineage", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Organism", "LongString", false));
            Up.FacetCategories.Add(new FacetCategory("Species", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Genus", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Kingdom", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Phylum", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Class", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Order", "String", true));
            Up.FacetCategories.Add(new FacetCategory("Family", "String", true));
            // References
            Up.FacetCategories.Add(new FacetCategory("RefCount", "Number", "0", true));
            fc = new FacetCategory("References", "Link", false);
            fc.IsMetaDataVisible = true;
            fc.IsWordWheelVisible = false;
            Up.FacetCategories.Add(fc);
            Up.FacetCategories.Add(new FacetCategory("SubmissionDate", "DateTime", true));
        }
Beispiel #5
0
        /// <summary>
        /// Delete a facet from the image preview
        /// </summary>

        private void DeleteFacetFromImage_Click(object sender, RoutedEventArgs e)
        {
            Object o = SelectedFacets.SelectedItem;

            if (o == null)
            {
                MessageBox.Show("To remove a facet category select it from the Image Facets.");
            }
            else
            {
                FacetCategory f = (FacetCategory)SelectedFacets.SelectedItem;
                DeleteFacetCategory(f);
                //Xslider.Value = initialX * Image.ScaleFactor;
                //Yslider.Value = initialY * Image.ScaleFactor;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Adds a FacetCategory to the image preview
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddFacetToImage_Click(object sender, RoutedEventArgs e)
        {
            Object o = AvailableFacets.SelectedItem;

            if (o == null)
            {
                //MessageBox.Show("To add a facet category select it from the Available Categories.");
            }
            else
            {
                FacetCategory f = (FacetCategory)o;
                f.IsSelected = true;
                SelectedFacets.Items.Add(f);
                AvailableFacets.Items.Remove(f);
                AddFacetCategoryToImage(f);
            }
        }
Beispiel #7
0
        public void SetImagePreviewBackground()
        {
            ItemDetails.Text = "";
            Item          item = Up.Collection.Items[CurrentItemIndex];
            FacetCategory fc   = CurrentBackgroundFacetCategory;

            foreach (Facet f in item.Facets)
            {
                ItemDetails.Text += String.Format("{0} -- {1}\r\n", f.Name, f[0].Value);

                if (fc.Name == f.Name)
                {
                    int bgIndex = f.Rank;
                    if (bgIndex >= BgColors.Count())
                    {
                        bgIndex = BgColors.Count() - 1;
                    }
                    //MessageBox.Show(String.Format("{0} {1} {2} {3} {4} {5}", BgColors[bgIndex].ToString(), fc.Name, CurrentItemIndex, bgIndex, f[0].Value, f.Rank));
                    ImagePreview.Background = new SolidColorBrush(BgColors[bgIndex]);
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Draw and save the image to file.
        /// </summary>
        /// <param name="imagePath">Local path to save the image.</param>
        /// <param name="BackgroundFacetCategory">Facet Category that specifies the BG color.</param>
        /// <param name="BackgroundColorScheme">The color scheme used for the BG color</param>
        public void DrawAndSaveImage(string imagePath, FacetCategory BackgroundFacetCategory, IList <Media.Color> BackgroundColorScheme)
        {
            // Init the image and graphic.
            Bitmap   image   = new Bitmap(Width, Height);
            Graphics graphic = Graphics.FromImage(image);

            graphic.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            graphic.TextRenderingHint = TextRenderingHint.AntiAlias;

            // Init the BG to white, and set it to the appropriate color based on the color scheme and BackgroundFacetCategory
            Rectangle bg  = new Rectangle(0, 0, Width, Height);
            Color     bgc = Color.White;

            foreach (Facet f in Item.Facets)
            {
                if (f.Name == BackgroundFacetCategory.Name)
                {
                    int bgIndex = f.Rank;
                    // If Rank exceeds the total number of available colors, set it to the last one.
                    if (bgIndex >= BackgroundColorScheme.Count())
                    {
                        bgIndex = BackgroundColorScheme.Count() - 1;
                    }

                    // Set the BG color.
                    bgc = Color.FromArgb(BackgroundColorScheme[bgIndex].A,
                                         BackgroundColorScheme[bgIndex].R,
                                         BackgroundColorScheme[bgIndex].G,
                                         BackgroundColorScheme[bgIndex].B);
                    SolidBrush b = new SolidBrush(bgc);
                    graphic.FillRectangle(b, bg);
                }
            }

            // From bottom-most to top-most layer ...
            for (int zIndex = MinZIndex; zIndex <= MaxZIndex; zIndex++)
            {
                foreach (FacetCategory fc in FacetCategories)
                {
                    // If the FacetCategory is selected to be drawn
                    if (fc.IsSelected && fc.Z == zIndex)
                    {
                        // Iterate over all the Facet for an item ...
                        foreach (Facet facet in Item.Facets)
                        {
                            // if the facet is found ...
                            if (facet.Name == fc.Name)
                            {
                                // Set the font size, family, weight, and style
                                Font font = new Font(fc.FontFamily.ToString(), (float)(fc.FontSize * Image.FontScaleFactor));
                                if (fc.FontWeight.ToString() == "Bold" && fc.FontStyle.ToString() == "Italic")
                                {
                                    font = new Font(fc.FontFamily.ToString(), fc.FontSize, FontStyle.Bold | FontStyle.Italic);
                                }
                                if (fc.FontWeight.ToString() == "Bold" && fc.FontStyle.ToString() == "Normal")
                                {
                                    font = new Font(fc.FontFamily.ToString(), fc.FontSize, FontStyle.Bold);
                                }
                                if (fc.FontWeight.ToString() == "Normal" && fc.FontStyle.ToString() == "Italic")
                                {
                                    font = new Font(fc.FontFamily.ToString(), fc.FontSize, FontStyle.Italic);
                                }

                                // Set the font color
                                Color fontFGColor = Color.FromArgb(fc.FontForegroundColor.A, fc.FontForegroundColor.R, fc.FontForegroundColor.G, fc.FontForegroundColor.B);
                                Color fontBGColor = Color.FromArgb(fc.FontBackgroundColor.A, fc.FontBackgroundColor.R, fc.FontBackgroundColor.G, fc.FontBackgroundColor.B);
                                //Color c = new Pen(fc.FontForegroundColor).Color;
                                SolidBrush fontFGBrush = new SolidBrush(fontFGColor);
                                SolidBrush fontBGBrush = new SolidBrush(fontBGColor);

                                // Set point to draw the text
                                Point p = new Point((int)Math.Round(fc.X / Image.ScaleFactor, 0), (int)Math.Round(fc.Y / Image.ScaleFactor, 0));

                                // String to draw
                                string str = facet[0].Value;
                                // Convert to more human readable DateTime. Default is longish xs:DateTime (required for Pivot).
                                if (facet[0].Type == "DateTime")
                                {
                                    try
                                    {
                                        DateTime dt = new DateTime();
                                        dt  = DateTime.ParseExact(facet[0].Value, "o", null);
                                        str = dt.ToString("dd-MMM-yyyy");
                                    }
                                    catch
                                    {
                                        Console.WriteLine("Error parsing DateTime: " + facet[0].Value);
                                    }
                                }

                                // Determine height and width of the string
                                SizeF stringSize = graphic.MeasureString(str, font);
                                float textWidth  = stringSize.Width;
                                float textHeight = stringSize.Height;

                                // If width exceeds the image width, wrap text.
                                if (stringSize.Width > Width)
                                {
                                    textWidth  = Width;
                                    textHeight = stringSize.Height * (float)Math.Ceiling(stringSize.Width / Width);
                                }

                                // Bounding color filled box around the text
                                Rectangle box = new Rectangle(p.X, p.Y, (int)Math.Round(textWidth, 0), (int)Math.Round(textHeight, 0));
                                graphic.FillRectangle(fontBGBrush, box);

                                // Draw the text.
                                RectangleF textRect = new RectangleF(p.X, p.Y, textWidth, textHeight);
                                graphic.DrawString(str, font, fontFGBrush, textRect);

                                Color outlineColor = Color.LightGray;
                                Pen   outlinePen   = new Pen(outlineColor);
                                outlinePen.Width = 1;
                                graphic.DrawRectangle(outlinePen, box);
                                Font legendFont = new Font("Segoe UI", 10);

                                if (font.Size < 10)
                                {
                                    legendFont = new Font("Segoe UI", font.Size);
                                }
                                SolidBrush legendBrush = new SolidBrush(outlineColor);
                                stringSize = graphic.MeasureString(str, legendFont);
                                Point legendPos = new Point(p.X, p.Y - (int)stringSize.Height);
                                graphic.DrawString(fc.Name, legendFont, legendBrush, legendPos);
                            }
                        }
                    }
                }
            }
            // Save the image.
            image.Save(imagePath);
        }
Beispiel #9
0
        /// <summary>
        /// Draw and save the image to file.
        /// </summary>
        /// <param name="imagePath">Local path to save the image.</param>
        /// <param name="BackgroundFacetCategory">Facet Category that specifies the BG color.</param>
        /// <param name="BackgroundColorScheme">The color scheme used for the BG color</param>
        public void DrawAndSaveImage(string imagePath, FacetCategory BackgroundFacetCategory, IList<Media.Color> BackgroundColorScheme)
        {
            // Init the image and graphic.
            Bitmap image = new Bitmap(Width, Height);
            Graphics graphic = Graphics.FromImage(image);
            graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            graphic.TextRenderingHint = TextRenderingHint.AntiAlias;

            // Init the BG to white, and set it to the appropriate color based on the color scheme and BackgroundFacetCategory
            Rectangle bg = new Rectangle(0, 0, Width, Height);
            Color bgc = Color.White;
            foreach (Facet f in Item.Facets)
            {
                if (f.Name == BackgroundFacetCategory.Name)
                {
                    int bgIndex = f.Rank;
                    // If Rank exceeds the total number of available colors, set it to the last one.
                    if (bgIndex >= BackgroundColorScheme.Count())
                    {
                        bgIndex = BackgroundColorScheme.Count() - 1;
                    }
                    
                    // Set the BG color.
                    bgc = Color.FromArgb(BackgroundColorScheme[bgIndex].A,
                                         BackgroundColorScheme[bgIndex].R,
                                         BackgroundColorScheme[bgIndex].G,
                                         BackgroundColorScheme[bgIndex].B);
                    SolidBrush b = new SolidBrush(bgc);
                    graphic.FillRectangle(b, bg);
                }
            }

            // From bottom-most to top-most layer ...
            for (int zIndex = MinZIndex; zIndex <= MaxZIndex; zIndex++)
            {
                foreach (FacetCategory fc in FacetCategories)
                {
                    // If the FacetCategory is selected to be drawn
                    if (fc.IsSelected && fc.Z == zIndex)
                    {
                        
                        // Iterate over all the Facet for an item ...
                        foreach (Facet facet in Item.Facets)
                        {
                            // if the facet is found ...
                            if (facet.Name == fc.Name)
                            {
                                // Set the font size, family, weight, and style
                                Font font = new Font(fc.FontFamily.ToString(), (float)(fc.FontSize * Image.FontScaleFactor));
                                if (fc.FontWeight.ToString() == "Bold" && fc.FontStyle.ToString() == "Italic")
                                {
                                    font = new Font(fc.FontFamily.ToString(), fc.FontSize, FontStyle.Bold | FontStyle.Italic);
                                }
                                if (fc.FontWeight.ToString() == "Bold" && fc.FontStyle.ToString() == "Normal")
                                {
                                    font = new Font(fc.FontFamily.ToString(), fc.FontSize, FontStyle.Bold);
                                }
                                if (fc.FontWeight.ToString() == "Normal" && fc.FontStyle.ToString() == "Italic")
                                {
                                    font = new Font(fc.FontFamily.ToString(), fc.FontSize, FontStyle.Italic);
                                }

                                // Set the font color
                                Color fontFGColor = Color.FromArgb(fc.FontForegroundColor.A, fc.FontForegroundColor.R, fc.FontForegroundColor.G, fc.FontForegroundColor.B);
                                Color fontBGColor = Color.FromArgb(fc.FontBackgroundColor.A, fc.FontBackgroundColor.R, fc.FontBackgroundColor.G, fc.FontBackgroundColor.B);
                                //Color c = new Pen(fc.FontForegroundColor).Color;
                                SolidBrush fontFGBrush = new SolidBrush(fontFGColor);
                                SolidBrush fontBGBrush = new SolidBrush(fontBGColor);
                                
                                // Set point to draw the text
                                Point p = new Point((int)Math.Round(fc.X/Image.ScaleFactor, 0), (int)Math.Round(fc.Y/Image.ScaleFactor, 0));
                                
                                // String to draw
                                string str = facet[0].Value;
                                // Convert to more human readable DateTime. Default is longish xs:DateTime (required for Pivot).
                                if (facet[0].Type == "DateTime")
                                {
                                    try
                                    {
                                        DateTime dt = new DateTime();
                                        dt = DateTime.ParseExact(facet[0].Value, "o", null);
                                        str = dt.ToString("dd-MMM-yyyy");
                                    }
                                    catch
                                    {
                                        Console.WriteLine("Error parsing DateTime: " + facet[0].Value);
                                    }
                                }
                                
                                // Determine height and width of the string
                                SizeF stringSize = graphic.MeasureString(str, font);
                                float textWidth = stringSize.Width;
                                float textHeight = stringSize.Height;
                                
                                // If width exceeds the image width, wrap text.
                                if (stringSize.Width > Width)
                                {
                                    textWidth = Width;
                                    textHeight = stringSize.Height * (float)Math.Ceiling(stringSize.Width / Width);
                                }
                                
                                // Bounding color filled box around the text
                                Rectangle box = new Rectangle(p.X, p.Y, (int)Math.Round(textWidth,0), (int)Math.Round(textHeight,0));
                                graphic.FillRectangle(fontBGBrush, box);
                                
                                // Draw the text.
                                RectangleF textRect = new RectangleF(p.X, p.Y, textWidth, textHeight);
                                graphic.DrawString(str, font, fontFGBrush, textRect);

                                Color outlineColor = Color.LightGray;
                                Pen outlinePen = new Pen(outlineColor);
                                outlinePen.Width = 1;
                                graphic.DrawRectangle(outlinePen, box);
                                Font legendFont = new Font("Segoe UI", 10);
                                
                                if (font.Size < 10)
                                {
                                    legendFont = new Font("Segoe UI", font.Size);
                                }
                                SolidBrush legendBrush = new SolidBrush(outlineColor);
                                stringSize = graphic.MeasureString(str, legendFont);
                                Point legendPos = new Point(p.X, p.Y - (int)stringSize.Height);
                                graphic.DrawString(fc.Name, legendFont, legendBrush, legendPos);
                            }
                        }
                    }
                }
            }
            // Save the image.
            image.Save(imagePath);
        }
Beispiel #10
0
        /// <summary>
        /// Does the grunt work of adding the FacetCategory to the image preview.
        /// </summary>
        /// <param name="f"></param>
        private void AddFacetCategoryToImage(FacetCategory f)
        {
            // Load item data of the currently viewed item
            if (ImagePreview.Children.Contains(f.tb))
            {
                //MessageBox.Show("Image already contains this category.");
                return;
            }

            Item item = Up.Collection.Items[CurrentItemIndex];
            // Set the name of the image preview item and it's value to that of the facet.
            f.tb.Name = f.Name;
            foreach (Facet facet in item.Facets)
            {
                if (facet.Name == f.Name)
                {
                    if (facet.Type == "DateTime")
                    {
                        try
                        {
                            DateTime dt = new DateTime();
                            dt = DateTime.ParseExact(facet[0].Value, "o", null);
                            f.tb.Text = dt.ToString("dd-MMM-yyyy");

                        }
                        catch
                        {
                            f.tb.Text = "N/A";
                        }
                    }
                    else
                    {
                        f.tb.Text = facet[0].Value;
                    }
                }
            }

            // Set the various text attributes.
            f.tb.FontSize = GetFontSize();
            f.tb.FontWeight = ToggleBold();
            f.tb.FontStyle = ToggleItalic();
            f.tb.FontFamily = GetFontFamily();
            f.tb.Foreground = ForeColorPicker.CurrentColor;
            f.tb.Background = GetFontColor(Color.FromArgb(0, 0, 0, 0));
            //f.tb.Background = BackColorPicker.CurrentColor;
            
            //f.tb.Foreground = GetFontColor(customForegroundCP.SelectedColor);
            //f.tb.Background = GetFontColor(customBackgroundCP.SelectedColor);
            
            f.tb.Width = GetTextWidth(f.tb);
            f.tb.Height = GetTextHeight(f.tb);

            // Set the sliders to the location of the item
            f.tb.SetValue(Canvas.LeftProperty, initialX * Image.ScaleFactor);
            f.tb.SetValue(Canvas.TopProperty, initialY * Image.ScaleFactor);
            f.tb.SetValue(Canvas.ZIndexProperty, initialZIndex);
            // Add event handlers for mouse over and out events.

            
            f.tb.MouseEnter += new MouseEventHandler(FacetCategoryMouseEnter);
            f.tb.MouseLeftButtonDown += new MouseButtonEventHandler(FacetCategoryMouseLeftButtonDown);
            f.tb.MouseLeftButtonUp += new MouseButtonEventHandler(FacetCategoryMouseLeftButtonUp);
            f.tb.MouseLeave += new MouseEventHandler(FacetCategoryMouseLeave);
            f.tb.Style = App.Current.Resources["DraggableObject"] as Style;

            // Add the item to the image preview and setup other UI elements.

            SetBlur(f.tb);
            ImagePreview.Children.Add(f.tb);
            
            if (CurrentFacetCategory != null)
            {
                int j = ImagePreview.Children.IndexOf(CurrentFacetCategory.tb);
                TextBlock tb2 = (TextBlock)ImagePreview.Children[j];
                RemoveBlur(tb2);
            }

            CurrentFacetCategory = f;
            StatusBlock.Text = "Editing " + CurrentFacetCategory.DisplayName;
            //Xslider.Value = initialX * Image.ScaleFactor;
            //Yslider.Value = initialY * Image.ScaleFactor;
            SetImagePreviewBackground();
        }
Beispiel #11
0
 private void DeleteFacetCategory(FacetCategory f)
 {
     f.IsSelected = false;
     AvailableFacets.Items.Add(f);
     SelectedFacets.Items.Remove(f);
     ImagePreview.Children.Remove(CurrentFacetCategory.tb);
     StatusBlock.Text = DefaultStatusLine;
     CurrentFacetCategory = null;
 }
Beispiel #12
0
 private void LoadItemInPreview(FacetCategory fc, Color c, double x, double y, int z, double fontSize)
 {
     fc.tb.FontSize = fontSize;
     SolidColorBrush b = new SolidColorBrush(c);
     fc.tb.Foreground = b;
     fc.tb.SetValue(Canvas.LeftProperty, x * Image.ScaleFactor);
     fc.tb.SetValue(Canvas.TopProperty, y * Image.ScaleFactor);
     fc.tb.SetValue(Canvas.ZIndexProperty, z);
     AddFacetCategoryToImage2(fc);
     AvailableFacets.Items.Remove(fc);
 }
Beispiel #13
0
        /*
        private void SetBackColor(object sender, RoutedEventArgs args)
        {
            if (CurrentFacetCategory != null)
            {
                CurrentFacetCategory.tb.Background = BackColorPicker.CurrentColor;
            }
        }
        */

        /// <summary>
        /// Runs when the UI is loaded (i.e. visible).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserControl8_Loaded(object sender, RoutedEventArgs e)
        {

            AvailableFacets.Focus();
            TotalItemCount.Text = "of " + Up.Collection.Items.Count();
            SetImagePreviewBackground(); // Set the background to the currently selected FacetCat. 
            FacetCategory rank = new FacetCategory();
            FacetCategory gene = new FacetCategory();
            FacetCategory queryName = new FacetCategory();
            FacetCategory species = new FacetCategory();
            FacetCategory product = new FacetCategory();
            FacetCategory identity = new FacetCategory();
            if (FirstTimeLoaded)
            {
                foreach (FacetCategory fc in Up.FacetCategories)
                {
                    
                    switch (fc.Name)
                    {
                        //case "Rank":
                        //    rank = fc;
                        //    break;
                        case "Gene":
                            gene = fc;
                            break;
                        case "QueryName":
                            queryName = fc;
                            break;
                        case "Species":
                            species = fc;
                            break;
                        case "Product":
                            product = fc;
                            break;
                        case "Identity":
                            identity = fc;
                            break;
                        
                        default:
                            break;
                    }
                }
                //rank.IsSelected = true;
                //SelectedFacets.Items.Add(rank);
                //AvailableFacets.Items.Remove(rank);
                //LoadItemInPreview(rank,      Color.FromArgb(255, 150, 150, 150), 150, -10, MinZIndex, 192);
                
                gene.IsSelected = true;
                SelectedFacets.Items.Add(gene);
                AvailableFacets.Items.Remove(gene);
                CurrentFacetCategory = gene;
                StatusBlock.Text = "Editing " + gene.DisplayName;
                LoadItemInPreview(gene,      Color.FromArgb(255, 0, 165, 0), 120, 120, MaxZIndex, 72);
                LoadItemInPreview(species,   Color.FromArgb(255, 165, 0, 0), 100, 275, MaxZIndex, 18);
                LoadItemInPreview(product, Color.FromArgb(255, 0, 0, 0), 20, 420, MaxZIndex, 10);
                LoadItemInPreview(queryName, Color.FromArgb(255, 0, 0, 0), 10, 10, MaxZIndex, 14);
                LoadItemInPreview(identity, Color.FromArgb(255, 0, 0, 0), 380, 10, MaxZIndex, 24);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Does the grunt work of adding the FacetCategory to the image preview.
        /// </summary>
        /// <param name="f"></param>
        private void AddFacetCategoryToImage(FacetCategory f)
        {
            // Load item data of the currently viewed item
            if (ImagePreview.Children.Contains(f.tb))
            {
                //MessageBox.Show("Image already contains this category.");
                return;
            }

            Item item = Up.Collection.Items[CurrentItemIndex];

            // Set the name of the image preview item and it's value to that of the facet.
            f.tb.Name = f.Name;
            foreach (Facet facet in item.Facets)
            {
                if (facet.Name == f.Name)
                {
                    if (facet.Type == "DateTime")
                    {
                        try
                        {
                            DateTime dt = new DateTime();
                            dt        = DateTime.ParseExact(facet[0].Value, "o", null);
                            f.tb.Text = dt.ToString("dd-MMM-yyyy");
                        }
                        catch
                        {
                            f.tb.Text = "N/A";
                        }
                    }
                    else
                    {
                        f.tb.Text = facet[0].Value;
                    }
                }
            }

            // Set the various text attributes.
            f.tb.FontSize   = GetFontSize();
            f.tb.FontWeight = ToggleBold();
            f.tb.FontStyle  = ToggleItalic();
            f.tb.FontFamily = GetFontFamily();
            f.tb.Foreground = ForeColorPicker.CurrentColor;
            f.tb.Background = GetFontColor(Color.FromArgb(0, 0, 0, 0));
            //f.tb.Background = BackColorPicker.CurrentColor;

            //f.tb.Foreground = GetFontColor(customForegroundCP.SelectedColor);
            //f.tb.Background = GetFontColor(customBackgroundCP.SelectedColor);

            f.tb.Width  = GetTextWidth(f.tb);
            f.tb.Height = GetTextHeight(f.tb);

            // Set the sliders to the location of the item
            f.tb.SetValue(Canvas.LeftProperty, initialX * Image.ScaleFactor);
            f.tb.SetValue(Canvas.TopProperty, initialY * Image.ScaleFactor);
            f.tb.SetValue(Canvas.ZIndexProperty, initialZIndex);
            // Add event handlers for mouse over and out events.


            f.tb.MouseEnter          += new MouseEventHandler(FacetCategoryMouseEnter);
            f.tb.MouseLeftButtonDown += new MouseButtonEventHandler(FacetCategoryMouseLeftButtonDown);
            f.tb.MouseLeftButtonUp   += new MouseButtonEventHandler(FacetCategoryMouseLeftButtonUp);
            f.tb.MouseLeave          += new MouseEventHandler(FacetCategoryMouseLeave);
            f.tb.Style = App.Current.Resources["DraggableObject"] as Style;

            // Add the item to the image preview and setup other UI elements.

            SetBlur(f.tb);
            ImagePreview.Children.Add(f.tb);

            if (CurrentFacetCategory != null)
            {
                int       j   = ImagePreview.Children.IndexOf(CurrentFacetCategory.tb);
                TextBlock tb2 = (TextBlock)ImagePreview.Children[j];
                RemoveBlur(tb2);
            }

            CurrentFacetCategory = f;
            StatusBlock.Text     = "Editing " + CurrentFacetCategory.DisplayName;
            //Xslider.Value = initialX * Image.ScaleFactor;
            //Yslider.Value = initialY * Image.ScaleFactor;
            SetImagePreviewBackground();
        }
Beispiel #15
0
        /*
         * private void SetBackColor(object sender, RoutedEventArgs args)
         * {
         *  if (CurrentFacetCategory != null)
         *  {
         *      CurrentFacetCategory.tb.Background = BackColorPicker.CurrentColor;
         *  }
         * }
         */

        /// <summary>
        /// Runs when the UI is loaded (i.e. visible).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserControl8_Loaded(object sender, RoutedEventArgs e)
        {
            AvailableFacets.Focus();
            TotalItemCount.Text = "of " + Up.Collection.Items.Count();
            SetImagePreviewBackground(); // Set the background to the currently selected FacetCat.
            FacetCategory rank      = new FacetCategory();
            FacetCategory gene      = new FacetCategory();
            FacetCategory queryName = new FacetCategory();
            FacetCategory species   = new FacetCategory();
            FacetCategory product   = new FacetCategory();
            FacetCategory identity  = new FacetCategory();

            if (FirstTimeLoaded)
            {
                foreach (FacetCategory fc in Up.FacetCategories)
                {
                    switch (fc.Name)
                    {
                    //case "Rank":
                    //    rank = fc;
                    //    break;
                    case "Gene":
                        gene = fc;
                        break;

                    case "QueryName":
                        queryName = fc;
                        break;

                    case "Species":
                        species = fc;
                        break;

                    case "Product":
                        product = fc;
                        break;

                    case "Identity":
                        identity = fc;
                        break;

                    default:
                        break;
                    }
                }
                //rank.IsSelected = true;
                //SelectedFacets.Items.Add(rank);
                //AvailableFacets.Items.Remove(rank);
                //LoadItemInPreview(rank,      Color.FromArgb(255, 150, 150, 150), 150, -10, MinZIndex, 192);

                gene.IsSelected = true;
                SelectedFacets.Items.Add(gene);
                AvailableFacets.Items.Remove(gene);
                CurrentFacetCategory = gene;
                StatusBlock.Text     = "Editing " + gene.DisplayName;
                LoadItemInPreview(gene, Color.FromArgb(255, 0, 165, 0), 120, 120, MaxZIndex, 72);
                LoadItemInPreview(species, Color.FromArgb(255, 165, 0, 0), 100, 275, MaxZIndex, 18);
                LoadItemInPreview(product, Color.FromArgb(255, 0, 0, 0), 20, 420, MaxZIndex, 10);
                LoadItemInPreview(queryName, Color.FromArgb(255, 0, 0, 0), 10, 10, MaxZIndex, 14);
                LoadItemInPreview(identity, Color.FromArgb(255, 0, 0, 0), 380, 10, MaxZIndex, 24);
            }
        }