示例#1
0
        /// <summary>
        /// Determines where the center of the pie chart will be located.
        /// </summary>
        /// <param name="legend">The information about the legend.</param>
        /// <param name="fontHeight">The height of the font being used.</param>
        /// <returns>The center point of the pie chart.</returns>
        PointF calculatePieCenter(LegendInfo legend, int fontHeight)
        {
            float x = 0, y = 0;

            switch (this.LegendPosition)
            {
            case ChartLegendPosition.Left:
                x = (this.Width.ToPixels() + legend.Size.Width) / 2;
                y = (this.Height.ToPixels() + fontHeight * 3) / 2f;
                break;

            case ChartLegendPosition.Right:
                x = (this.Width.ToPixels() - legend.Size.Width) / 2;
                y = (this.Height.ToPixels() + fontHeight * 3) / 2f;
                break;

            case ChartLegendPosition.Top:
                x = this.Width.ToPixels() / 2f;
                y = (this.Height.ToPixels() + fontHeight * 3 + legend.Size.Height) / 2;
                break;

            case ChartLegendPosition.Bottom:
                x = this.Width.ToPixels() / 2f;
                y = (this.Height.ToPixels() - legend.Size.Height + fontHeight * 3) / 2;
                break;
            }
            return(new PointF(x, y));
        }
示例#2
0
        /// <summary>
        /// Draws the legend for the pie chart.
        /// </summary>
        /// <param name="legend">The information about the legend.</param>
        /// <param name="fontHeight">The height of the font being used.</param>
        void drawLegend(LegendInfo legend, int fontHeight)
        {
            float halfFontHeight = fontHeight / 2f;
            float x = legend.StartingPoint.X;
            float y = legend.StartingPoint.Y;

            for (int i = 0; i < this.Values.Count; ++i)
            {
                // When we have too many items to fit on a single row or column (depending on the legend's position), we will move to the next row or column when we have filled one in.
                if (i > 0 && i % legend.MaxItems == 0)
                {
                    if (this.LegendPosition == ChartLegendPosition.Left || this.LegendPosition == ChartLegendPosition.Right)
                    {
                        y  = legend.StartingPoint.Y;
                        x += legend.LabelWidth + halfFontHeight;
                    }
                    else
                    {
                        x  = legend.StartingPoint.X;
                        y += fontHeight + 1;
                    }
                }

                // Creates a group for the legend, then adds the colored square and the text.
                var g = new HtmlGenericControl("g");
                g.Attributes.Add("transform", string.Format("translate({0} {1})", x, y));

                var rect = new HtmlGenericControl("rect");
                rect.Attributes.Add("x", "1");
                rect.Attributes.Add("y", (halfFontHeight - 3.5f).ToString());
                rect.Attributes.Add("width", "7");
                rect.Attributes.Add("height", "7");
                rect.Attributes.Add("fill", ColorTranslator.ToHtml(this.GetColorAt(i)));
                g.Controls.Add(rect);

                var text = new HtmlGenericControl("text")
                {
                    InnerText = this.Values[i].Text
                };
                text.Attributes.Add("x", "12");
                text.Attributes.Add("y", halfFontHeight.ToString());
                text.Attributes.Add("dominant-baseline", "central");
                text.Attributes.Add("fill", "#000");
                g.Controls.Add(text);

                this.SVG.Controls.Add(g);

                // Moves the position ahead depending on the legend's position.
                if (this.LegendPosition == ChartLegendPosition.Left || this.LegendPosition == ChartLegendPosition.Right)
                {
                    y += fontHeight + 1;
                }
                else
                {
                    x += legend.LabelWidth + halfFontHeight;
                }
            }
        }
示例#3
0
 /// <summary>
 /// Determines what size the pie's radius should be based on the size of the area where the pie chart will display.
 /// </summary>
 /// <param name="legend">The information about the legend.</param>
 /// <param name="fontHeight">The height of the font being used.</param>
 void calculatePieRadius(LegendInfo legend, int fontHeight)
 {
     if (this.LegendPosition == ChartLegendPosition.Left || this.LegendPosition == ChartLegendPosition.Right)
     {
         this.PieRadius = (decimal)Math.Min(this.Width.ToPixels() - legend.Size.Width, this.Height.ToPixels() - fontHeight * 3);
     }
     else
     {
         this.PieRadius = (decimal)Math.Min(this.Width.ToPixels(), this.Height.ToPixels() - fontHeight * 3 - legend.Size.Height);
     }
     this.PieRadius /= 2;
     this.PieRadius -= fontHeight;
 }
        private void ContextMenuEventHandler(object sender, ContextMenuEventArgs e)
        {
            (sender as FrameworkElement).ContextMenu = null;
            var        vm   = (e.OriginalSource as FrameworkElement)?.DataContext;
            TocItem    item = null;
            LegendInfo info = null;

            if (vm is LegendInfo li)
            {
                info = li;
                var parent = System.Windows.Media.VisualTreeHelper.GetParent(e.OriginalSource as DependencyObject) as FrameworkElement;
                while (parent != null)
                {
                    if (parent.DataContext is TocItem tocItem)
                    {
                        item = tocItem;
                        break;
                    }

                    parent = System.Windows.Media.VisualTreeHelper.GetParent(parent) as FrameworkElement;
                }
            }

            if (vm is TocItem ti)
            {
                item = ti;
            }

            if (vm != null)
            {
                if (TableOfContentContextMenuOpening != null)
                {
                    var ctm  = new ContextMenu();
                    var args = new TableOfContentsContextMenuEventArgs(sender, e)
                    {
                        MenuItems          = ctm.Items,
                        TableOfContentItem = item?.Content,
                        LegendInfo         = info,
                        Menu = ctm
                    };
                    TableOfContentContextMenuOpening?.Invoke(this, args);
                    e.Handled = args.Handled;
                    if (args.MenuItems.Count > 0)
                    {
                        (sender as FrameworkElement).ContextMenu = args.Menu;
                    }
                }
            }
        }
示例#5
0
    /// <summary>
    /// <LegendInfo><Legends></Legends><\LegendInfo>
    /// </summary>
    /// <param name="ThemeID"></param>
    /// <returns>File Name WithPath</returns>
    public string DownloadLegends(string ThemeID, string fileName)
    {
        string RetVal = string.Empty;
        Map diMap = null;
        string TempFileWPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath + Constants.FolderName.TempCYV, DateTime.Now.Ticks.ToString() + ".xml");
        string LegendColor = string.Empty;
        string LegendTitle = string.Empty;
        Theme theme;
        LegendInfo LegendInfo = new LegendInfo();

        try
        {
            //step To load map from session/ NewMap/ From preserved file
            //<LegendInfo><Legends></Legends><\LegendInfo>
            diMap = this.GetSessionMapObject();
            theme = diMap.Themes[ThemeID];
            LegendInfo.LegendBreakCount = theme.BreakCount;
            LegendInfo.LegendBreakType = theme.BreakType;
            LegendInfo.LegendChartType = theme.ChartType;

            if (theme.Legends != null && theme.Legends.Count > 0)
            {
                LegendInfo.Legends = theme.Legends;
            }

            this.SerializeObject(TempFileWPath, LegendInfo);

            RetVal = TempFileWPath;
        }
        catch (Exception ex)
        {
            RetVal = "false" + Constants.Delimiters.ParamDelimiter + ex.Message;
            Global.CreateExceptionString(ex, null);
        }
        finally
        {
        }

        return RetVal;
    }
示例#6
0
        /// <summary>
        /// A function to add a few legends for the plot. This remembers them for
        /// later attachment to a plot.
        /// </summary>
        /// <param name="associations"></param>
        public static void Legend(IScopeContext c, IDictionary <object, object> associations)
        {
            // Sign up for all the legends we are going to have to attach.
            c.ExecutionContext.AddPostCallHook("plot", "legend", (obj, result) =>
            {
                (result as DrawingContext).AddPreplotHook(SetLegendColors);
                return(result);
            });
            c.ExecutionContext.AddPostCallHook("draw", "legend", (obj, result) =>
            {
                (result as DrawingContext).AddPreplotHook(SetLegendColors);
                return(result);
            });

            // Next, record the legend info.
            foreach (var item in associations)
            {
                var s = item.Key as string;
                if (s == null)
                {
                    Console.WriteLine("In legend generation unable to parse as a string {0}.", item.Key.ToString());
                }
                else
                {
                    if (item.Value.GetType() == typeof(int))
                    {
                        _legendInfo[s] = new LegendInfo()
                        {
                            Color = (int)item.Value, Title = s
                        };
                    }
                    else if (item.Value is IDictionary <object, object> )
                    {
                        var linfo = new LegendInfo()
                        {
                            Title = s
                        };
                        var dict = item.Value as IDictionary <object, object>;
                        if (!dict.ContainsKey("Color"))
                        {
                            Console.WriteLine("Dictionary for legend does not contain a Color key!");
                        }
                        else
                        {
                            linfo.Color = (int)dict["Color"];
                        }

                        if (dict.ContainsKey("Title"))
                        {
                            linfo.Title = (string)dict["Title"];
                        }

                        linfo.LeaveOut = false;
                        if (dict.ContainsKey("LeaveOut"))
                        {
                            linfo.LeaveOut = (bool)dict["LeaveOut"];
                        }

                        linfo.LineStyle = 1;
                        if (dict.ContainsKey("LineStyle"))
                        {
                            linfo.LineStyle = (int)dict["LineStyle"];
                        }

                        linfo.MarkerStyle = 1;
                        if (dict.ContainsKey("MarkerStyle"))
                        {
                            linfo.MarkerStyle = (int)dict["MarkerStyle"];
                        }

                        _legendInfo[s] = linfo;
                    }
                    else
                    {
                        Console.WriteLine("In legend generation unable to parse {0} into an integer or a dictionary of values (with Title and Color as members).", item.Value.ToString());
                    }
                }
            }
        }
 public void Update(LegendInfo info)
 {
     _symbolDisplay.Symbol = info?.Symbol;
     _textLabel.Text       = info?.Name;
 }
示例#8
0
 internal void Update(LegendInfo info)
 {
     _symbolDisplay.Symbol = info?.Symbol;
     _textView.Text        = info?.Name;
 }
 public LegendContentInfo(LegendInfo legend, Func <double, bool> visibleAtScaleCalculation)
 {
     Name = legend.Name;
     _visibleAtScaleCalculation = visibleAtScaleCalculation;
 }
示例#10
0
        private string GetLegendContent(string ribbonID, bool isLable)
        {
            if (ribbonID == "btnStartPronto")
            {
                ribbonID = IsEnableBookmarkButton ? ribbonID : "btnHidePronto";
            }
            if (Wkl.MainCtrl.CommonCtrl.CommonProfile.DataSegmentInfo == null)
            {
                Pdw.Core.Kernal.DataSegmentHelper.GetListDomain();
            }
            LegendInfo legend = Wkl.MainCtrl.CommonCtrl.CommonProfile.DataSegmentInfo.GetLegendByName(ribbonID);

            switch (ribbonID)
            {
            case "TabProntoDoc":
                return(isLable ? "ProntoDoc" : "");

            case "ProntoPlugin":
                return(isLable ? "Plugin" : "Command of ProntoDoc plugin");

            case "btnStartPronto":
            case "btnHidePronto":
                return(IsEnableBookmarkButton ? (isLable ? Properties.Resources.ipm_RibbonBtnShow : "Show the right panel") :
                       (isLable ? Properties.Resources.ipm_RibbonBtnHide : "Hide the right panel"));

            //
            case "Controls":
                return(isLable ? "Controls" : "Command of ProntoDoc Plugin");

            case "btnReconstruct":
                return(isLable ? "Reconstruct" : "Auto fix and reconstruct Template");

            case "btnPreviewOsql":
                return(isLable ? "Preview" : "Preview Osql Statement");

            //
            case "Bookmarks":
                return(isLable ? "Bookmarks" : "Bookmarks Template");

            case "btnBookmarks":
                return(isLable ? "Bookmarks" : "Show all bookmarks of Template");

            case "btnHighlightBookmark":
                return(isLable ? "Highlight Bookmark" : "Highlight or un-highlight Bookmarks");

            //
            case "DomainTree":
                return(isLable ? "Domain Tree Font Size" : "Change Domain Tree Size");

            case "btnFontAsc":
                return(isLable ? "Ascending" : "Increase Domain Tree Font Size");

            case "btnFontDesc":
                return(isLable ? "Descending" : "Decrease Domain Tree Font Size");

            //
            case "DataSection":
                return(isLable ? "Data Section" : "Data Section");

            case "btnForEach":
                return(isLable ? "For-each" : "Define repeat data section");

            case "chkCollapseForeach":
                return(isLable ? "Collapse For-each" : "Collapse or expand collation of foreach tag");

            case "btnComment":
                return(isLable ? "New Comment" : "Add comment into template");

            case "btnValidate":
                return(isLable ? "Validate" : "Validate and highlight incorrect bookmarks by selected color");

            //
            case "ProntoPdeIntegrate":
                return(isLable ? "Pde Integreate" : "Intergrate with pde template");

            case "btnPdeIntergrateImport":
                return(isLable ? "Import" : "Open a pde template to import");

            //HACK:FORM CONTROLS - GetLegendContent
            case "PdmTemplate":
                return(isLable ? "Pdm Template" : "Controls to design HTML tags");

            case "btnTextInput":
                return(isLable ? "TextBox" : "<input type=\"text\" />");

            case "btnTextArea":
                return(isLable ? "TextArea" : "<textarea />");

            case "btnButton":
                return(isLable ? "Button" : "<input type=\"button|submit|reset\" />");

            case "btnCheckBox":
                return(isLable ? "CheckBox" : "<input type=\"checkbox\" />");

            case "btnRadio":
                return(isLable ? "Radio" : "<input type=\"radio\" />");

            case "btnSelect":
                return(isLable ? "Select" : "<select />");

            case "btnCheckBoxList":
                return(isLable ? "CheckBox List" : "Group of <input type=\"checkbox\" />");

            case "btnRadioList":
                return(isLable ? "Radio List" : "Group of <input type=\"radio\" />");

            default:
                return(string.Empty);
            }
        }
示例#11
0
        public static DataSegmentInfo GetAllDomain(string DllPath)
        {
            try
            {
                DataSegmentInfo dsInfo = new DataSegmentInfo();
                hDll = NativeMethods.LoadLibrary(DllPath);

                if (hDll != IntPtr.Zero)
                {
                    IntPtr pAddressOfFunctionToCall            = NativeMethods.GetProcAddress(hDll, FunctionName.GetBlockNumberOfHeader);
                    GetBlockNumberOfHeader getBlockNumOfHeader = (GetBlockNumberOfHeader)Marshal.GetDelegateForFunctionPointer(
                        pAddressOfFunctionToCall,
                        typeof(GetBlockNumberOfHeader));
                    int intBlockNo = getBlockNumOfHeader();

                    pAddressOfFunctionToCall = NativeMethods.GetProcAddress(hDll, FunctionName.GetHeaderLength);
                    GetHeaderLength getHeaderLength = (GetHeaderLength)Marshal.GetDelegateForFunctionPointer(
                        pAddressOfFunctionToCall,
                        typeof(GetHeaderLength));
                    int intHeaderLength = getHeaderLength();

                    object obj = ReadObject(1, intBlockNo, intHeaderLength, true);
                    if (obj == null)
                    {
                        return(null);
                    }

                    List <DSHeaderInfo> dsHeaderInfos = (List <DSHeaderInfo>)obj;
                    if (dicHeaderInfo == null)
                    {
                        dicHeaderInfo = new Dictionary <string, DSHeaderInfo>();
                        foreach (DSHeaderInfo dsHeader in dsHeaderInfos)
                        {
                            // get icon
                            if (dsHeader.IsIcon)
                            {
                                Icon icon = (Icon)ReadObject(dsHeader.StartBlock, dsHeader.EndBlock, dsHeader.Length, false);
                                dsInfo.Icons.Add(icon);
                                continue;
                            }

                            // get legend
                            if (dsHeader.IsLanguage)
                            {
                                LegendInfo legend = (LegendInfo)ReadObject(dsHeader.StartBlock, dsHeader.EndBlock, dsHeader.Length, false);
                                dsInfo.LegendInfos.Add(legend);
                                continue;
                            }

                            // get domain name
                            dsInfo.DSHeaderInfos.Add(dsHeader);
                            dicHeaderInfo.Add(dsHeader.Name.ToLower(), dsHeader);
                        }
                    }
                    NativeMethods.FreeLibrary(hDll);
                }

                return(dsInfo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }