public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            ArrayList arrayList = new ArrayList();

            if (context != null && context.Instance != null)
            {
                IServiceContainer serviceContainer = null;
                if (context.Instance is Series && ((Series)context.Instance).serviceContainer != null)
                {
                    serviceContainer = ((Series)context.Instance).serviceContainer;
                }
                if (serviceContainer == null && context.Instance is Array)
                {
                    Array array = (Array)context.Instance;
                    if (array.Length > 0 && array.GetValue(0) is Series)
                    {
                        serviceContainer = ((Series)array.GetValue(0)).serviceContainer;
                    }
                }
                if (serviceContainer != null)
                {
                    ChartImage chartImage = (ChartImage)serviceContainer.GetService(typeof(ChartImage));
                    if (chartImage != null)
                    {
                        foreach (ChartArea chartArea in chartImage.ChartAreas)
                        {
                            arrayList.Add(chartArea.Name);
                        }
                    }
                }
            }
            return(new StandardValuesCollection(arrayList));
        }
示例#2
0
        internal void Initialize()
        {
            ChartImage obj = (ChartImage)serviceContainer.GetService(typeof(ChartImage));

            obj.BeforePaint += ChartPicture_BeforePaint;
            obj.AfterPaint  += ChartPicture_AfterPaint;
        }
        public void Initialize()
        {
            ChartImage chartImage = (ChartImage)this.serviceContainer.GetService(typeof(ChartImage));

            chartImage.BeforePaint += this.ChartPicture_BeforePaint;
            chartImage.AfterPaint  += this.ChartPicture_AfterPaint;
        }
示例#4
0
        /// <summary>
        /// Gets selected data source object.
        /// </summary>
        /// <param name="chart">Chart control.</param>
        /// <returns>Data source.</returns>
        internal object GetControlDataSource(Chart chart)
        {
            object selectedDataSource = null;

            if (chart != null)
            {
                if (chart.DataSource != null)
                {
                    object dataSourceObject = chart.DataSource;
                    string fieldName        = dataSourceObject as string;
                    if (fieldName != null && this.Component != null)
                    {
                        dataSourceObject = null;
                        ISite componentSite = this.Component.Site;
                        if (componentSite != null)
                        {
                            IContainer container = (IContainer)componentSite.GetService(typeof(IContainer));
                            if (container != null)
                            {
                                dataSourceObject = container.Components[fieldName];
                            }
                        }
                    }
                    if (dataSourceObject != null && ChartImage.IsValidDataSource(dataSourceObject))
                    {
                        selectedDataSource = dataSourceObject;
                    }
                }
            }

            return(selectedDataSource);
        }
        /// <summary>
        /// Fill in the list of the data source members.
        /// </summary>
        /// <param name="context">Descriptor context.</param>
        /// <returns>Standart values collection.</returns>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            ArrayList values = new ArrayList();

            Chart  chart      = ConverterHelper.GetChartFromContext(context);
            object dataSource = null;

            if (chart != null)
            {
                if (chart != null && ChartImage.IsValidDataSource(chart.DataSource))
                {
                    dataSource = chart.DataSource;
                }

                // Check if it's Y values member
                bool usedForYValues = false;
                if (context.PropertyDescriptor != null && context.PropertyDescriptor.Name == "YValueMembers")
                {
                    usedForYValues = true;
                }

                // Populate list with all members names
                ArrayList memberNames = ChartImage.GetDataSourceMemberNames(dataSource, usedForYValues);
                foreach (string name in memberNames)
                {
                    values.Add(name);
                }

                values.Add("(none)");
            }

            return(new StandardValuesCollection(values));
        }
示例#6
0
    private void SearchResults_SelectionChanged(object sender, EventArgs e)
    {
        // figure out the initial zoom
        Debug.Assert(mSearchResults.SelectedItems.Count == 1);
        double userZoom = Program.dataConfig.getDoubleVal(new string[] { "_DefaultZoom" }, 1.0);
        double minZoom  = Program.dataConfig.getDoubleVal(new string[] { "_MinZoom" }, 0.2 * userZoom);
        double maxZoom  = Program.dataConfig.getDoubleVal(new string[] { "_MaxZoom" }, 2 * userZoom);

        if (mSearchResults.SelectedItems.Count > 0)
        {
            ChartImage chartImage = (ChartImage)mSearchResults.SelectedItems[0].Tag;
            mChartImagePictureBox.Image = chartImage.image();
            userZoom = chartImage.jsonConfig.getDoubleVal(new string[] { "defaultZoom" }, userZoom);
            minZoom  = chartImage.jsonConfig.getDoubleVal(new string[] { "minZoom" }, minZoom);
            maxZoom  = chartImage.jsonConfig.getDoubleVal(new string[] { "maxZoom" }, maxZoom);
        }
        else
        {
            mChartImagePictureBox.Image = null;
        }
        ILog logger = LogManager.GetLogger("zoom");

        logger.Info($"Setting initial image zoom: {userZoom:0.00} (min={minZoom:0.00}, max={maxZoom:0.00})");
        mCurrZoom = mDefaultZoom = userZoom;
        mMinZoom  = minZoom;
        mMaxZoom  = maxZoom;

        // show the selected chart image
        mChartImagePanel.BringToFront();
        setChartImagePanelScrollPos(0, 0);
        doMainFormResize(null);
    }
示例#7
0
        /// <summary>
        /// Initialize data manger object
        /// </summary>
        internal void Initialize()
        {
            // Attach to the Chart Picture painting events
            ChartImage chartPicture = (ChartImage)serviceContainer.GetService(typeof(ChartImage));

            chartPicture.BeforePaint += new EventHandler <ChartPaintEventArgs>(this.ChartPicture_BeforePaint);
            chartPicture.AfterPaint  += new EventHandler <ChartPaintEventArgs>(this.ChartPicture_AfterPaint);
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ChartImage chartImage = new ChartImage();

            //Response.Write(Request.Url);
            //Response.End();
            chartImage.CreateChartImage(Server.MapPath("/Upload/qrcode.png"), "http://www.baidu.com", 230, 230);
            Response.Write("二维码生成成功");
        }
示例#9
0
        /// <summary>
        /// Handles PrintPage event of the document.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="ev">Event parameters.</param>
        private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            // Get a reference to the chart image object
            if (_chartImage == null && _serviceContainer != null)
            {
                _chartImage = (ChartImage)_serviceContainer.GetService(typeof(ChartImage));
            }

            if (_chartImage != null)
            {
                // Save graphics state.
                GraphicsState transState = ev.Graphics.Save();
                try
                {
                    Rectangle marginPixel = ev.MarginBounds;
                    // Display units mean different thing depending if chart is rendered on the display or printed.
                    // Typically pixels for video displays, and 1/100 inch for printers.
                    if (ev.Graphics.PageUnit != GraphicsUnit.Pixel)
                    {
                        ev.Graphics.PageUnit = GraphicsUnit.Pixel;
                        marginPixel.X        = (int)(marginPixel.X * (ev.Graphics.DpiX / 100.0f));
                        marginPixel.Y        = (int)(marginPixel.Y * (ev.Graphics.DpiY / 100.0f));
                        marginPixel.Width    = (int)(marginPixel.Width * (ev.Graphics.DpiX / 100.0f));
                        marginPixel.Height   = (int)(marginPixel.Height * (ev.Graphics.DpiY / 100.0f));
                    }
                    // Calculate chart position rectangle
                    Rectangle chartPosition = new Rectangle(marginPixel.X, marginPixel.Y, _chartImage.Width, _chartImage.Height);

                    // Make sure chart corretly fits the margin area
                    float chartWidthScale  = ((float)marginPixel.Width) / ((float)chartPosition.Width);
                    float chartHeightScale = ((float)marginPixel.Height) / ((float)chartPosition.Height);
                    chartPosition.Width  = (int)(chartPosition.Width * Math.Min(chartWidthScale, chartHeightScale));
                    chartPosition.Height = (int)(chartPosition.Height * Math.Min(chartWidthScale, chartHeightScale));

                    // Calculate top left position so that chart is aligned in the center
                    chartPosition.X += (marginPixel.Width - chartPosition.Width) / 2;
                    chartPosition.Y += (marginPixel.Height - chartPosition.Height) / 2;

                    // Draw chart on the printer graphisc
                    this.PrintPaint(ev.Graphics, chartPosition);
                }
                finally
                {
                    // Restore graphics state.
                    ev.Graphics.Restore(transState);
                }
            }
        }
        internal virtual ArrayList GetMemberNames()
        {
            object dataSource = null;

            if (ChartWinDesigner.controlDesigner != null)
            {
                dataSource = ChartWinDesigner.controlDesigner.GetControlDataSource(_chart);
            }

            // Get list of members
            if (dataSource != null)
            {
                return(ChartImage.GetDataSourceMemberNames(dataSource, this.usedForYValue));
            }
            return(new ArrayList());
        }
示例#11
0
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            ArrayList arrayList = new ArrayList();

            if (context != null && context.Container != null)
            {
                foreach (IComponent component in context.Container.Components)
                {
                    if (ChartImage.IsValidDataSource(component))
                    {
                        arrayList.Add(component.Site.Name);
                    }
                }
            }
            arrayList.Add("(none)");
            return(new StandardValuesCollection(arrayList));
        }
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            ArrayList arrayList = new ArrayList();

            if (context != null && context.Instance != null)
            {
                IServiceContainer serviceContainer = null;
                if (context.Instance is Series && ((Series)context.Instance).serviceContainer != null)
                {
                    serviceContainer = ((Series)context.Instance).serviceContainer;
                }
                if (serviceContainer == null && context.Instance is Array)
                {
                    Array array = (Array)context.Instance;
                    if (array.Length > 0 && array.GetValue(0) is Series)
                    {
                        serviceContainer = ((Series)array.GetValue(0)).serviceContainer;
                    }
                }
                if (serviceContainer == null && context.Instance is Chart)
                {
                    serviceContainer = ((Chart)context.Instance).serviceContainer;
                }
                if (serviceContainer != null)
                {
                    ChartImage chartImage = (ChartImage)serviceContainer.GetService(typeof(ChartImage));
                    if (chartImage != null)
                    {
                        object dataSource    = null;
                        bool   usedForYValue = false;
                        if (context.PropertyDescriptor != null && context.PropertyDescriptor.Name == "ValueMembersY")
                        {
                            usedForYValue = true;
                        }
                        ArrayList dataSourceMemberNames = ChartImage.GetDataSourceMemberNames(dataSource, usedForYValue);
                        foreach (string item in dataSourceMemberNames)
                        {
                            arrayList.Add(item);
                        }
                        arrayList.Add("(none)");
                    }
                }
            }
            return(new StandardValuesCollection(arrayList));
        }
        public void ApplyPaletteColors()
        {
            if (this.Palette == ChartColorPalette.None && this.PaletteCustomColors.Length <= 0)
            {
                return;
            }
            int num = 0;

            Color[] array = (this.PaletteCustomColors.Length > 0) ? this.PaletteCustomColors : ChartPaletteColors.GetPaletteColors(this.colorPalette);
            foreach (Series item in this.series)
            {
                bool flag = false;
                if (item.ChartArea.Length > 0)
                {
                    ChartImage chartImage = (ChartImage)this.serviceContainer.GetService(typeof(ChartImage));
                    if (chartImage != null)
                    {
                        foreach (ChartArea chartArea in chartImage.ChartAreas)
                        {
                            if (chartArea.Name == item.ChartArea)
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag && item.ChartArea == "Default" && chartImage.ChartAreas.Count > 0)
                        {
                            flag = true;
                        }
                    }
                }
                if (flag && (item.Color == Color.Empty || item.tempColorIsSet))
                {
                    item.color          = array[num++];
                    item.tempColorIsSet = true;
                    if (num >= array.Length)
                    {
                        num = 0;
                    }
                }
            }
        }
示例#14
0
        /// <summary>
        /// Draws chart on the printer graphics.
        /// </summary>
        /// <param name="graphics">Printer graphics.</param>
        /// <param name="position">Position to draw in the graphics.</param>
        public void PrintPaint(Graphics graphics, Rectangle position)
        {
            // Get a reference to the chart image object
            if (_chartImage == null && _serviceContainer != null)
            {
                _chartImage = (ChartImage)_serviceContainer.GetService(typeof(ChartImage));
            }

            // Draw chart
            if (_chartImage != null)
            {
                // Change chart size to fit the new position
                int oldWidth  = _chartImage.Width;
                int oldHeight = _chartImage.Height;
                _chartImage.Width  = position.Width;
                _chartImage.Height = position.Height;

                // Save graphics state.
                GraphicsState transState = graphics.Save();

                // Set required transformation
                graphics.TranslateTransform(position.X, position.Y);

                // Set printing indicator
                _chartImage.isPrinting = true;

                // Draw chart
                _chartImage.Paint(graphics, false);

                // Clear printing indicator
                _chartImage.isPrinting = false;

                // Restore graphics state.
                graphics.Restore(transState);

                // Restore old chart position
                _chartImage.Width  = oldWidth;
                _chartImage.Height = oldHeight;
            }
        }
        /// <summary>
        /// Fill in the list of chart type names.
        /// </summary>
        /// <param name="context">Descriptor context.</param>
        /// <returns>Standard values collection.</returns>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            ArrayList values = new ArrayList();

            if (context != null && context.Container != null)
            {
                // Loop through all components in the container
                foreach (IComponent comonent in context.Container.Components)
                {
                    // Check if component can be a data source
                    if (ChartImage.IsValidDataSource(comonent))
                    {
                        // Add component name
                        values.Add(comonent.Site.Name);
                    }
                }
            }

            // Add "None" data source
            values.Add("(none)");

            return(new StandardValuesCollection(values));
        }
示例#16
0
    private void loadChartImages()
    {
        // initialize
        ILog logger = LogManager.GetLogger("startup");

        // build an index of the config entries
        HashSet <string> configIndex = new HashSet <string>(
            Program.dataConfig.data.ToObject <Dictionary <string, object> >().Keys
            );

        // locate the chart images
        string dataDir             = Path.GetFullPath(Program.dataDir);
        IEnumerable <string> files = Directory.EnumerateFiles(
            dataDir, "*.*", SearchOption.AllDirectories
            );

        foreach (string fname in files)
        {
            // load the next image
            string extn = Path.GetExtension(fname).ToLower();
            if (!mValidImageExtensions.Contains(extn))
            {
                continue;
            }
            string key;
            string fullPath = Path.GetFullPath(fname);
            if (fullPath.StartsWith(dataDir))
            {
                key = fname.Substring(dataDir.Length);
                key = key.Replace("\\", "/");
                if (key.StartsWith("/"))
                {
                    key = key.Substring(1);
                }
            }
            else
            {
                // NOTE: I don't think we should ever get here :-/ If we do, the user will have to manage
                // their configuration using full paths for the image files, but at least we will still run...
                key = fullPath;
            }
            logger.Debug($"Loading image: {key}");
            dynamic config = Program.dataConfig.data[key];
            if (config == null)
            {
                Program.logStartupMsg("unconfigured-image", fname.Substring(dataDir.Length + 1));
            }
            else
            {
                configIndex.Remove(key);
            }
            ChartImage chartImage = new ChartImage(key, fullPath, config);
            mChartImages[key] = chartImage;

            // add the image to the list
            ImageListViewItem item = chartImage.imageListViewItem;
            mSearchResults.Invoke((MethodInvoker)(() => mSearchResults.Items.Add(item)));
        }

        // log any config entries that were unused
        foreach (string key in configIndex)
        {
            if (key[0] == '_')
            {
                continue;
            }
            Program.logStartupMsg("unused-config", key);
        }

        // everything has been loaded, update the UI
        this.Invoke((MethodInvoker)onStartupCompleted);
    }
示例#17
0
 public void addChartImage(ChartImage ci)
 {
     mChartImages.Add(ci);
 }