Exemplo n.º 1
0
		public AddItemCmd(ChartObject item) : base("Create")
		{
			this.item = item;
			this.oldSelState = null;
			this.newSelState = null;
			this.zIndex = 0;
		}
Exemplo n.º 2
0
		public RemoveItemCmd(ChartObject item) : base("Delete")
		{
			this.item = item;
			this.oldSelState = null;
			this.newSelState = null;
			this.zIndex = 0;
		}
Exemplo n.º 3
0
		internal override void accept(ChartObject obj)
		{
			if (operation != null)
				operation(obj);

			if (operationIntr != null)
				operationIntr(obj, ist);
		}
Exemplo n.º 4
0
		public ChangeItemCmd(ChartObject item, string title) : base(title)
		{
			this.item = item;
			initialProps = item.createProperties();
			item.saveProperties(initialProps);

			item.flowChart.UndoManager.onChangeItem(item, this);
		}
Exemplo n.º 5
0
		internal override void accept(ChartObject obj)
		{
			if (obj is Node)
			{
				_bounds = Utilities.unionRects(
					_bounds, obj.getBoundingRect());
				_rotatedBounds = Utilities.unionRects(
					_rotatedBounds, obj.getRotatedBounds());
			}
		}
Exemplo n.º 6
0
        private Chart CreateReliChart(string name, Worksheet objSheet, Range chartRange, double minT)
        {
            ChartObjects charts = objSheet.ChartObjects() as ChartObjects;;

            // Adds a chart at x = 100, y = 300, 500 points wide and 300 tall.
            ChartObject chartObj = charts.Add(120, 320, 500, 300);
            Chart       chart    = chartObj.Chart;

            // Gets the cells that define the bounds of the data to be charted.
            chart.ChartType = XlChartType.xlXYScatterSmoothNoMarkers;
            chart.SetSourceData(chartRange, XlRowCol.xlColumns);
            SeriesCollection seriesCollection = chart.SeriesCollection() as SeriesCollection;

            seriesCollection.Item(1).Name = name;

            chart.HasTitle = false;

            Axis axis = chart.Axes(
                XlAxisType.xlValue,
                XlAxisGroup.xlPrimary) as Axis;

            axis.HasTitle          = true;
            axis.AxisTitle.Text    = "Software Reliability";
            axis.HasMajorGridlines = true;
            axis.HasMinorGridlines = false;
            axis.MaximumScale      = 1;

            axis = chart.Axes(
                XlAxisType.xlCategory,
                XlAxisGroup.xlPrimary) as Axis;

            axis.HasTitle          = true;
            axis.AxisTitle.Text    = "Time";
            axis.HasMajorGridlines = true;
            axis.HasMinorGridlines = false;
            axis.MinimumScale      = minT;

            return(chart);
        }
    public void FindAndSelectSongObjects(IList <SongObject> songObjects)
    {
        Song  song  = currentSong;
        Chart chart = currentChart;

        foundSongObjects.Clear();

        foreach (SongObject so in songObjects)
        {
            ChartObject chartObject = so as ChartObject;
            SyncTrack   syncTrack   = so as SyncTrack;
            Event       eventObject = so as Event;
            if (chartObject != null)
            {
                int insertionIndex = SongObjectHelper.FindObjectPosition(chartObject, chart.chartObjects);
                Debug.Assert(insertionIndex != SongObjectHelper.NOTFOUND, "Failed to find chart object to highlight");
                foundSongObjects.Add(chart.chartObjects[insertionIndex]);
            }
            else if (syncTrack != null)
            {
                int insertionIndex = SongObjectHelper.FindObjectPosition(syncTrack, song.syncTrack);
                Debug.Assert(insertionIndex != SongObjectHelper.NOTFOUND, "Failed to find synctrack to highlight");
                foundSongObjects.Add(song.syncTrack[insertionIndex]);
            }
            else if (eventObject != null)
            {
                int insertionIndex = SongObjectHelper.FindObjectPosition(eventObject, song.eventsAndSections);
                Debug.Assert(insertionIndex != SongObjectHelper.NOTFOUND, "Failed to find event to highlight");
                foundSongObjects.Add(song.eventsAndSections[insertionIndex]);
            }
            else
            {
                Debug.LogError("Unable to handle object " + so.ToString());
            }
        }

        currentSelectedObjects = foundSongObjects;
        foundSongObjects.Clear();
    }
Exemplo n.º 8
0
        public bool TryRemove(ChartObject chartObject)
        {
            if (chartObject == null)
            {
                throw new ArgumentNullException();
            }

            if (chartObject is Topic)
            {
                return(Remove((Topic)chartObject));
            }
            else if (chartObject is Widget)
            {
                return(Remove((Widget)chartObject));
            }
            else if (chartObject is Link)
            {
                return(Remove((Link)chartObject));
            }

            return(false);
        }
Exemplo n.º 9
0
        protected override void ObjectEnteredJudgement(ChartObject obj)
        {
            if (AutoPlay && !obj.IsInstant)
            {
                m_ticks.Add(new Tick(obj, obj.AbsolutePosition, true, true));
            }

            if (obj.IsInstant)
            {
                var chipTick = new Tick(obj, obj.AbsolutePosition, false);
                m_ticks.Add(chipTick);
            }
            else
            {
                tick_t step   = (Chart.MaxBpm >= 255 ? 2.0 : 1.0) / (4 * 4);
                tick_t margin = 2 * step;

                int numTicks = MathL.FloorToInt((double)(obj.Duration - margin) / (double)step);

                if (numTicks == 0)
                {
                    m_ticks.Add(new Tick(obj, obj.AbsolutePosition + obj.AbsoluteDuration / 2, true));
                }
                else
                {
                    tick_t pos = obj.Position + margin;
                    for (int i = 0; i < numTicks; i++)
                    {
                        time_t timeAtTick = Chart.CalcTimeFromTick(pos + i * step);
                        m_ticks.Add(new Tick(obj, timeAtTick, true));
                    }
                }
            }

            if (AutoPlay && !obj.IsInstant)
            {
                m_ticks.Add(new Tick(obj, obj.AbsoluteEndPosition, true, true));
            }
        }
Exemplo n.º 10
0
        protected override void OnPatternChartObjectsUpdated(long id, ChartObject updatedChartObject, ChartObject[] patternObjects)
        {
            var otherTriangle = updatedChartObject as ChartTriangle;

            if (otherTriangle == null)
            {
                return;
            }

            var chartObjects = Chart.Objects.ToArray();

            var objectNameId = string.Format("{0}_{1}", ObjectName, id);

            foreach (var chartObject in chartObjects)
            {
                if (chartObject == updatedChartObject ||
                    chartObject.ObjectType != ChartObjectType.Triangle ||
                    !chartObject.Name.StartsWith(objectNameId, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                var triangle = chartObject as ChartTriangle;

                if (triangle.Name.EndsWith("Left", StringComparison.InvariantCultureIgnoreCase))
                {
                    triangle.Time3 = otherTriangle.Time1;
                    triangle.Y3    = otherTriangle.Y1;
                }
                else
                {
                    triangle.Time1 = otherTriangle.Time3;
                    triangle.Y1    = otherTriangle.Y3;
                }

                triangle.Time2 = otherTriangle.Time2;
                triangle.Y2    = otherTriangle.Y2;
            }
        }
        protected override void OnPatternChartObjectsUpdated(long id, ChartObject updatedChartObject, ChartObject[] patternObjects)
        {
            var controllerLine = updatedChartObject as ChartTrendLine;

            if (controllerLine == null || controllerLine.Name.LastIndexOf("ControllerLine", StringComparison.OrdinalIgnoreCase) < 0)
            {
                return;
            }

            var startBarIndex = Chart.Bars.GetBarIndex(controllerLine.Time1, Chart.Symbol);

            var barsNumber = controllerLine.GetBarsNumber(Chart.Bars, Chart.Symbol);

            var verticalLines = patternObjects.Where(iObject => iObject.ObjectType == ChartObjectType.VerticalLine).Cast <ChartVerticalLine>().ToArray();

            foreach (var verticalLine in verticalLines)
            {
                double lineLevelPercent;

                if (!double.TryParse(verticalLine.Name.Split('_').Last(), NumberStyles.Any, CultureInfo.InvariantCulture, out lineLevelPercent))
                {
                    continue;
                }

                var level = _fibonacciLevels.FirstOrDefault(iLevel => iLevel.Percent == lineLevelPercent);

                if (level == null)
                {
                    continue;
                }

                var barsAmount = barsNumber * level.Percent;

                var lineBarIndex = controllerLine.Time2 > controllerLine.Time1 ? startBarIndex + barsAmount : startBarIndex - barsAmount;

                verticalLine.Time = Chart.Bars.GetOpenTime(lineBarIndex, Chart.Symbol);
            }
        }
Exemplo n.º 12
0
        public void CreateScatter(string chartTitle, string xTitle, string yTitle, int numberSeries)
        {
            var range = Sheet.get_Range(Report.GetCellAtOffset("B5", numberSeries, 0), Report.GetCellAtOffset("A3", 20 + numberSeries, NumberYears));
            //Worksheet operationalWorksheet = (Worksheet)workbookIndex[workbook].Sheets[sheetIndex];
            //Range chartWidthAndHeight = ParseRange(operationalWorksheet, chartLocation);
            //double width = double.Parse(chartWidthAndHeight.Cells.ColumnWidth.ToString());
            //double height = double.Parse(chartWidthAndHeight.Cells.RowHeight.ToString());

            // Column A width, plus half again column A
            //Range rngA = ParseRange(operationalWorksheet, "A");
            //double aPlusHalfA = double.Parse(rngA.Cells.ColumnWidth.ToString());

            //// The top of the chart will start below the bottom of the data?
            ////Range rngDataBottom = GetHeaderPlusSubHeaderHeight();

            ChartObjects chartObjs = (ChartObjects)Sheet.ChartObjects(Type.Missing);
            ChartObject  chartObj  = chartObjs.Add(range.Left, range.Top, range.Width, range.Height);
            Chart        xlChart   = chartObj.Chart;

            xlChart.Location(XlChartLocation.xlLocationAutomatic, Sheet.Name);

            Range sourceData = Sheet.get_Range("A3", Report.GetCellAtOffset("A3", numberSeries, NumberYears));

            xlChart.ChartType = XlChartType.xlXYScatterLines;
            xlChart.SetSourceData(sourceData, XlRowCol.xlRows);
            xlChart.HasTitle        = true;
            xlChart.ChartTitle.Text = chartTitle;

            xlChart.HasLegend        = true;
            xlChart.Legend.Position  = XlLegendPosition.xlLegendPositionBottom;
            xlChart.Legend.Font.Size = 14;
            for (int i = 1; i <= numberSeries; i++)
            {
                Series oSeries = (Series)xlChart.SeriesCollection(i);
            }

            SetXyAxis(xTitle, yTitle, xlChart);
        }
Exemplo n.º 13
0
        protected override void OnPatternChartObjectsUpdated(long id, ChartObject updatedChartObject, ChartObject[] patternObjects)
        {
            var updatedLine = updatedChartObject as ChartVerticalLine;

            if (updatedLine == null)
            {
                return;
            }

            foreach (var patternObject in patternObjects)
            {
                if (patternObject.ObjectType != ChartObjectType.VerticalLine || patternObject == updatedChartObject)
                {
                    continue;
                }

                var verticalLine = patternObject as ChartVerticalLine;

                verticalLine.Color     = updatedLine.Color;
                verticalLine.LineStyle = updatedLine.LineStyle;
                verticalLine.Thickness = updatedLine.Thickness;
            }
        }
        public async Task <IHttpActionResult> PutChartObject(int id, [NotNull] ChartObject chartObject)
        {
            if (chartObject == null)
            {
                throw new ArgumentNullException("chartObject");
            }

            if (!ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            if (id != chartObject.ChartObjectId)
            {
                return(this.BadRequest());
            }

            this.db.Entry(chartObject).State = EntityState.Modified;

            try
            {
                await this.db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!this.ChartObjectExists(id))
                {
                    return(this.NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(this.StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 15
0
        public void ExportToExcel()
        {
            var pictureColorsResult = GetPictureColors(pictureName);

            var histogram = pictureColorsResult.Item1;
            var max       = pictureColorsResult.Item2;

            var xlApp = new Application();

            Workbook  xlWorkBook  = xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
            Worksheet xlWorkSheet = xlWorkBook.Sheets[1];

            xlWorkSheet.Cells[1, 1] = pictureName;

            //for (int i = 0; i <= 255; i++)
            //{
            //    xlWorkSheet.Cells[2, i + 1] = i;
            //}

            for (int i = 1; i < histogram.Length + 1; i++)
            {
                xlWorkSheet.Cells[2, i].value2 = histogram[i - 1];
            }
            Range        chartRange;
            object       misValue  = System.Reflection.Missing.Value;
            ChartObjects xlCharts  = xlWorkSheet.ChartObjects(Type.Missing);
            ChartObject  myChart   = xlCharts.Add(10, 80, 800, 250);
            Chart        chartPage = myChart.Chart;

            chartRange = xlWorkSheet.get_Range("A2", "IV2");
            chartPage.SetSourceData(chartRange, misValue);
            chartPage.ChartType = XlChartType.xlXYScatterLinesNoMarkers;

            xlWorkBook.SaveAs(exportExcelFilePath);
            xlWorkBook.Close();
            xlApp.Quit();
        }
Exemplo n.º 16
0
        protected override void UpdateLabels(long id, ChartObject chartObject, ChartText[] labels, ChartObject[] patternObjects)
        {
            if (chartObject.ObjectType != ChartObjectType.Triangle)
            {
                return;
            }

            var triangle = chartObject as ChartTriangle;

            if (labels.Length == 0)
            {
                DrawLabels(triangle, id);

                return;
            }

            foreach (var label in labels)
            {
                switch (label.Text)
                {
                case "A":
                    label.Time = triangle.Time1;
                    label.Y    = triangle.Y1;
                    break;

                case "B":
                    label.Time = triangle.Time2;
                    label.Y    = triangle.Y2;
                    break;

                case "C":
                    label.Time = triangle.Time3;
                    label.Y    = triangle.Y3;
                    break;
                }
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Selects all charts on the sheet.
 /// </summary>
 /// <returns>True if the sheet is a chart or contains embedded
 /// charts; false if not.</returns>
 public bool SelectCharts()
 {
     if (IsChart)
     {
         Logger.Info("SelectCharts: Is a chart sheet");
         // Cast to _Chart to prevent compile-time warning
         // about ambiguity of method and event name.
         ((_Chart)Chart).Select(true);
         return(true);
     }
     else
     {
         ChartObjects cos = Worksheet.ChartObjects();
         if (cos.Count > 0)
         {
             // Select first chart object to replace current selection.
             // Remember that Excel collections are 1 based!
             Logger.Info("SelectCharts: Selecting first chart; total: {0}", cos.Count);
             ChartObject chart = cos.Item(1);
             chart.Select(true);
             Logger.Info("SelectCharts: Adding other charts to selection");
             for (int i = 1; i <= cos.Count; i++)
             {
                 chart = cos.Item(i);
                 chart.Select(false);
                 Bovender.ComHelpers.ReleaseComObject(chart);
             }
             Bovender.ComHelpers.ReleaseComObject(cos);
             return(true);
         }
         else
         {
             Logger.Info("SelectCharts: No chart objects found, returning false");
             return(false);
         }
     }
 }
Exemplo n.º 18
0
        public override void EnsureVisible(ChartObject chartObject)
        {
            if (chartObject is Topic)
            {
                Topic topic = (Topic)chartObject;

                BeginUpdateView();

                // Make sure all nodes in path is Unfolded
                bool  changed = false;
                Topic tp      = topic.ParentTopic;
                while (tp != null)
                {
                    if (tp.Folded)
                    {
                        tp.Folded = false;
                        changed   = true;
                    }
                    tp = tp.ParentTopic;
                }

                if (changed)
                {
                    EndUpdateView(ChangeTypes.All);
                }
                else
                {
                    CancelUpdateView();
                }

                Rectangle rect = topic.Bounds;
                rect.Inflate(10, 10);
                rect = PaintHelper.Zoom(rect, Zoom);
                EnsureVisible(rect);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Creates a 2-DIMENSIONAL vertical bar chart using the specified data range.
        /// </summary>
        /// <param name="dataRange">The data to use in the vertical bar chart must represent the x and y axes</param>
        /// <param name="startCol">The letter of the column the left side of the chart should start on.</param>
        /// <param name="top">The topmost pixel of the chart</param>
        /// <param name="width">The total width of the chart in pixels</param>
        /// <param name="height">The total height of the chart in pixels</param>
        /// <param name="rowCol">The XL row/col datatype to use?</param>
        /// <param name="uniqueName">Unique chart name for this worksheet</param>
        public string CreateVerticalBarChart(string dataRange, char startCol, double top, double width, double height, Microsoft.Office.Interop.Excel.XlRowCol rowCol)
        {
            Range vertBarChartData = ((Range)(ReportGlobals.XLMgr.GetRanges(dataRange))[0]);
            // Get the active sheet
            Worksheet    operationalSheet = (Worksheet)(workbookIndex[ReportGlobals.defaultWorkbookName].Sheets[ReportGlobals.defaultSheetIndex]);
            ChartObjects chartObjs        = (ChartObjects)operationalSheet.ChartObjects(Type.Missing);

            // Get the number of pixels from the left we are going to count to get to this column
            int asciiColumn = Convert.ToInt32(startCol);
            int asciiA      = Convert.ToInt32('A');
            int totalPixels = 0;

            asciiColumn = 0 + asciiColumn;
            for (int i = asciiA; i < asciiColumn; i++)
            {
                totalPixels += asciiColumn;
            }
            ChartObject chartObj = chartObjs.Add((double)totalPixels, top, width, height);
            Chart       xlChart  = chartObj.Chart;

            xlChart.SetSourceData(vertBarChartData, rowCol);
            xlChart.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered;
            return(chartObj.Name);
        }
Exemplo n.º 20
0
        protected override void UpdateLabels(long id, ChartObject chartObject, ChartText[] labels, ChartObject[] patternObjects)
        {
            var levelLines = patternObjects.Where(iObject => iObject.ObjectType == ChartObjectType.TrendLine &&
                                                  !iObject.Name.EndsWith("FirstWaveLine", StringComparison.OrdinalIgnoreCase) &&
                                                  !iObject.Name.EndsWith("SecondWaveLine", StringComparison.OrdinalIgnoreCase))
                             .Cast <ChartTrendLine>()
                             .ToDictionary(trendLine => double.Parse(trendLine.Name.Split('_').Last(), CultureInfo.InvariantCulture));

            if (levelLines == null || levelLines.Count == 0)
            {
                return;
            }

            if (labels.Length == 0)
            {
                DrawLabels(levelLines, id);

                return;
            }

            foreach (var label in labels)
            {
                var percent = double.Parse(label.Name.Split('_').Last(), CultureInfo.InvariantCulture);

                ChartTrendLine levelLine;

                if (!levelLines.TryGetValue(percent, out levelLine))
                {
                    continue;
                }

                label.Text = string.Format("{0} ({1})", percent, Math.Round(levelLine.Y1, Chart.Symbol.Digits));
                label.Time = levelLine.GetStartTime();
                label.Y    = levelLine.Y1;
            }
        }
Exemplo n.º 21
0
        private void CreatePieChart2(string workbook, int sheetIndex, string chartData, string chartLocation, string chartTitle)
        {
            Worksheet operationalWorksheet = (Worksheet)workbookIndex[workbook].Sheets[sheetIndex];
            //Range chartWidthAndHeight = ParseRange(operationalWorksheet, chartLocation);
            //double width = double.Parse(chartWidthAndHeight.Cells.ColumnWidth.ToString());
            //double height = double.Parse(chartWidthAndHeight.Cells.RowHeight.ToString());

            // Column A width, plus half again column A
            //Range rngA = ParseRange(operationalWorksheet, "A");
            //double aPlusHalfA = double.Parse(rngA.Cells.ColumnWidth.ToString());

            //// The top of the chart will start below the bottom of the data?
            ////Range rngDataBottom = GetHeaderPlusSubHeaderHeight();

            ChartObjects chartObjs = (ChartObjects)operationalWorksheet.ChartObjects(Type.Missing);
            ChartObject  chartObj  = chartObjs.Add(50, 150, 300, 300);
            Chart        xlChart   = chartObj.Chart;

            xlChart.Location(XlChartLocation.xlLocationAutomatic, operationalWorksheet.Name);

            //Range sourceData = ParseRange(operationalWorksheet, chartData);
            //Range sourceData = operationalWorksheet.get_Range("B5", "D5");
            Range sourceData2 = operationalWorksheet.get_Range("B16", "D16");

            //Range sourceData3 = operationalWorksheet.Application.Union(sourceData, sourceData2, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

            xlChart.ChartType = XlChartType.xl3DPie;
            xlChart.SetSourceData(sourceData2, XlRowCol.xlRows);
            xlChart.HasTitle        = true;
            xlChart.ChartTitle.Text = chartTitle;

            xlChart.HasLegend        = true;
            xlChart.Legend.Position  = XlLegendPosition.xlLegendPositionBottom;
            xlChart.Legend.Font.Size = 14;
            Series oSeries = (Series)xlChart.SeriesCollection(1);
        }
Exemplo n.º 22
0
 public void Remove(ChartObject mapObject)
 {
     for (int i = Count - 1; i >= 0; i--)
     {
         ChartObject[] objs = Records[i];
         if (objs != null)
         {
             int index = Array.IndexOf(objs, mapObject);
             if (index > -1)
             {
                 List <ChartObject> list = new List <ChartObject>(objs);
                 list.Remove(mapObject);
                 if (list.Count > 0)
                 {
                     Records[i] = list.ToArray();
                 }
                 else
                 {
                     Records.RemoveAt(i);
                 }
             }
         }
     }
 }
Exemplo n.º 23
0
        private void Report_Click(object sender, EventArgs e)
        {
            _app ExcelApp = new _app();

            ExcelApp.Workbooks.Add(Type.Missing);
            Worksheet sheet = (Worksheet)ExcelApp.Sheets[1];

            connection.Open();
            SqlCommand command = new SqlCommand($"select UserOrder.orderDate, count(UserOrder.orderDate) from UserOrder  group by orderDate;", connection);
            var        reader  = command.ExecuteReader();
            int        i       = 1;

            while (reader.Read())
            {
                sheet.Cells[i, 1] = reader.GetValue(0).ToString().Trim();
                sheet.Cells[i, 2] = reader.GetValue(1).ToString().Trim();
                i++;
            }
            reader.Close();
            connection.Close();
            ChartObjects xlCharts         = (ChartObjects)sheet.ChartObjects(Type.Missing);
            ChartObject  myChart          = (ChartObject)xlCharts.Add(110, 0, 350, 250);
            var          chart            = myChart.Chart;
            var          seriesCollection = (SeriesCollection)chart.SeriesCollection(Type.Missing);
            Series       series           = seriesCollection.NewSeries();

            series.XValues  = sheet.get_Range("A1", "A" + (i - 1) + "");
            series.Values   = sheet.get_Range("B1", "B" + (i - 1) + "");
            chart.ChartType = XlChartType.xlXYScatterSmooth;
            chart.ApplyDataLabels(
                Microsoft.Office.Interop.Excel.XlDataLabelsType.xlDataLabelsShowLabel,
                false, true, false, false, true, false, false,
                true, true);

            ExcelApp.Visible = true;
        }
Exemplo n.º 24
0
        protected virtual void DoSaveChart(string sheetName, string fileName, SaveChartOptions options)
        {
            options ??= new SaveChartOptions();
            var spread = options.Spreadsheet?.Workbook ?? Workbook;

            ChartObject chart = null;
            Image       chartImage;
            var         chartSheet = spread.ChartSheets[sheetName];

            if (chartSheet != null)
            {
                chart = chartSheet.Chart;
            }
            if (chart == null)
            {
                var worksheet = spread.Worksheets[sheetName];
                if (worksheet != null && worksheet.Charts.Count > Math.Max(0, options.ChartIndex ?? 0))
                {
                    chart = worksheet.Charts[options.ChartIndex ?? 0];
                }
            }

            if (chart == null)
            {
                throw new Exception("Cannot find chart.");
            }

            if (options.Size != null && options.Size.Length != 2)
            {
                throw new Exception("Invalid size of the image. Must be 2-elements integer array.");
            }
            if (options.Size != null)
            {
                var imageSize = new Size(options.Size[0], options.Size[1]);
                chartImage = chart.GetImage(imageSize).NativeImage;
            }
            else
            {
                chartImage = chart.GetImage().NativeImage;
            }

            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new Exception("Filename for image is not specified.");
            }

            fileName = Project.Current.MapPath(fileName);
            var dir = Path.GetDirectoryName(fileName);

            if (!Directory.Exists(dir))
            {
                throw new Exception($"Directory '{dir}' does not exist.");
            }

            if (File.Exists(fileName))
            {
                if (options.Replace)
                {
                    File.Delete(fileName);
                }
                else
                {
                    throw new Exception($"File '{fileName}' already exists.");
                }
            }

            System.Drawing.Imaging.ImageFormat format = (options.Format ?? GetImageFormatFromFileName(fileName)) switch
            {
                ImageFileFormat.Png => System.Drawing.Imaging.ImageFormat.Png,
                ImageFileFormat.Tiff => System.Drawing.Imaging.ImageFormat.Tiff,
                ImageFileFormat.Bmp => System.Drawing.Imaging.ImageFormat.Bmp,
                ImageFileFormat.Gif => System.Drawing.Imaging.ImageFormat.Gif,
                ImageFileFormat.Jpeg => System.Drawing.Imaging.ImageFormat.Jpeg,
                _ => System.Drawing.Imaging.ImageFormat.Png
            };
            chartImage.Save(fileName, format);

            if (options.CopyToBook)
            {
                CopyImageToBook(chartImage, options.CopyToBookScale, options.CopyToBookScale, options);
            }
        }
    }
Exemplo n.º 25
0
 private void Judge_OnHoldPressed(time_t position, ChartObject obj)
 {
     m_streamHasActiveEffects[obj.Stream] = true;
     CreateKeyBeam(obj.Stream, JudgeKind.Passive, false);
 }
Exemplo n.º 26
0
 private void Judge_OnHoldReleased(time_t position, ChartObject obj)
 {
     m_streamHasActiveEffects[obj.Stream] = false;
 }
Exemplo n.º 27
0
 private void Judge_OnChipPressed(time_t position, ChartObject obj)
 {
 }
Exemplo n.º 28
0
 public AddGroupCmd(ChartObject item, Group group) : base("Group")
 {
     this.item  = item;
     this.group = group;
 }
Exemplo n.º 29
0
    static void Main()
    {
        Console.WriteLine(loc);
        Console.Write("\nchecking authorization level");//quickly check what the user's level is

        /*
         * CHANGE THIS TO A LOGIN  \/
         */
        string Authorization = "admin";//checks login

        /*
         * CHANGE THIS TO A LOG IN /\
         */

        Console.Write("begining check process");//
        string chartName = "chart";

        Console.Write("Attempting to open file\n");//"please enter a name for the file:");
        Console.WriteLine("Please enter file name: ");
        //string file = Console.ReadLine();
        string fileName      = Console.ReadLine(); //user enters file name
        string worksheetName = "Shipment - ByCell per week";


        Application xlApp = new Application();//creates a new reference to excel

        if (xlApp == null)
        {
            Console.WriteLine("EXCEL could not be started. Check that your office installation and project references are correct.");
            return;
        }

        Workbook wb = null;//creates a wb reference

        while (wb == null)
        {
            if (!File.Exists(loc + fileName + ".xlsm"))
            {
                Console.Write("File doesn't exist.  please try again\n");
                Console.WriteLine("Please enter file name: ");
                fileName = Console.ReadLine();
            }
            else
            {
                Console.Write("File exists!  opening file");
                if (Authorization.CompareTo("admin") != 0)
                {
                    xlApp.DisplayAlerts = false;
                }
                else
                {
                }
                wb = xlApp.Workbooks.Open(loc + fileName + ".xlsm", Type.Missing, false);
            }
        }
        xlApp.Visible = true;
        Boolean   found = false;
        Worksheet ws    = null;

        //xlApp.DisplayAlerts = false;
        if (wb != null)
        {
            foreach (Worksheet sheet in wb.Sheets)
            {
                // Check the name of the current sheet
                if (sheet.Name == "Shipment - ByCell per week")
                {
                    found = true;
                    Console.Write("worksheet was found\n");
                    break; // Exit the loop now
                }
            }
            //ws = (Worksheet)wb.Worksheets[worksheetName];
        }

        else
        {
            ws = null;
        }
        if (found)
        {
            // Reference it by name
            ws = wb.Sheets[worksheetName];
            chart(ws, "C1", "N2", chartName, "1");
        }

        ws = wb.Sheets[2];              //sets ws to the second sheet as the wb.sheets[worksheetName] code was not working at the time
        xlApp.ActiveWindow.Zoom = 50;   //sets the zoom of the page out so you can see the chart as it generates
        xlApp.DisplayAlerts     = true; //allows excel to show any errors or alerts
        if (ws == null)
        {
            Console.WriteLine("\nWorksheet could not be created. Check that your office installation and project references are correct.");
        }
        chart(ws, "C1", "Z2", chartName, "1");

        bool deleted = false;

        /*AFTER CREATING AND SAVING THE CHART THE CHART IS DELETED
         * The reasoning behind this decision is so that if charts are generated constantly the file size will
         * continue to grow and take up more space than needed, this way the chart is saved and stored as an immage.
         * the immages can then be pulled to show a history of the past week.
         */
        try
        {
            ChartObject chartPageDelete = ws.ChartObjects("Chart 1");
            chartPageDelete.Delete();
            deleted = true;
        }
        catch
        {
            Console.WriteLine("\nChart with this name could not be found");
            //throw new Exception("Chart with this name could not be found");
        }
        finally
        {
            Console.WriteLine("\nthe chart was " + (deleted ? "deleted" : "not deleted"));
        }


        xlApp.DisplayAlerts = false;


        //saving the file
        Console.WriteLine("would you like to save? (Y or N)");
        string userIn = Console.ReadLine();

        if (userIn.Equals("Y") || userIn.Equals("y"))
        {
            save(xlApp, wb, fileName);
        }
        else
        {
            wb.Close();                  //closes the workbook
        }
        Marshal.ReleaseComObject(xlApp); //releases all Com objects
        xlApp.Quit();                    //closes this instance of excel
    }
Exemplo n.º 30
0
		internal override void accept(ChartObject obj)
		{
			RectangleF rcObj = obj.getRepaintRect(connections);
			invalidArea = Utilities.unionRects(invalidArea, rcObj);
		}
Exemplo n.º 31
0
        public static void CreateColClusterBarGraph(
            int left, int top, int width, int height,
            _Worksheet oSheet, Range dataRange,
            string strXAxis, string strChartTitle, double titleFontSize,
            string strXTitle, double xFontSize, List <string> listLegend,
            string strYTitle, double yFontSize, XlRowCol rowCol)
        {
            ChartObjects chartObjs = (ChartObjects)oSheet.ChartObjects(Type.Missing);
            ChartObject  chartObj  = chartObjs.Add(left + 100, top, 425, 315);
            Chart        xlChart   = chartObj.Chart;

            xlChart.SetSourceData(dataRange, Type.Missing);
            xlChart.ChartType = XlChartType.xlColumnClustered;

            xlChart.PlotBy = rowCol;

            // Xaxis data labels
            Series oS = (Series)xlChart.SeriesCollection(1);

            string strVersion = m_oXL.Application.Version;

            if (strVersion == "11.0")  // Office 2003 Excel
            {
                string strStartRow, strEndRow, strStartCol, strEndCol;
                int    nPos = -1, nEnd = -1, nStartCol, nEndCol, nStartRow, nEndRow;

                // Sample incoming: "='Total Lane-Miles Per
                // Condition'!$B$5:$F$5"; or "='Total Lane-Miles Per
                // Condition'!$B$5:$B$10";
                nPos = strXAxis.IndexOf('$');
                if (nPos > -1)
                {
                    nEnd        = strXAxis.IndexOf('$', nPos + 1);
                    strStartCol = strXAxis.Substring(nPos + 1, nEnd - nPos - 1);

                    nPos        = strXAxis.IndexOf(':');
                    strStartRow = strXAxis.Substring(nEnd + 1, nPos - nEnd - 1);

                    nPos      = strXAxis.IndexOf('$', nPos);
                    nEnd      = strXAxis.IndexOf('$', nPos + 1);
                    strEndCol = strXAxis.Substring(nPos + 1, nEnd - nPos - 1);
                    strEndRow = strXAxis.Substring(nEnd + 1);

                    nStartRow = int.Parse(strStartRow);
                    nEndRow   = int.Parse(strEndRow);

                    nStartCol = GetColumnNumber(strStartCol + strStartRow);
                    nEndCol   = GetColumnNumber(strEndCol + strStartRow);

                    nPos      = strXAxis.IndexOf('!');
                    strXAxis  = strXAxis.Substring(0, nPos + 1);
                    strXAxis += "R" + nStartRow.ToString() + "C" + nStartCol.ToString() + ":R" + nEndRow.ToString() +
                                "C" + nEndCol.ToString();
                }
            }
            oS.XValues = strXAxis;

            // Add title:
            if (strChartTitle != "")
            {
                xlChart.HasTitle        = true;
                xlChart.ChartTitle.Text = strChartTitle;
            }

            // Xaxis title
            if (strXTitle != "")
            {
                Axis xAxis = (Axis)xlChart.Axes(XlAxisType.xlCategory,
                                                XlAxisGroup.xlPrimary);
                xAxis.HasTitle            = true;
                xAxis.AxisTitle.Text      = strXTitle;
                xAxis.AxisTitle.Font.Size = xFontSize;
            }

            // legend:
            xlChart.HasLegend = false;
            if (listLegend != null)
            {
                if (listLegend.Count > 0)
                {
                    xlChart.HasLegend = true;

                    int seriesNum = 1;
                    foreach (string str in listLegend)
                    {
                        oS      = (Series)xlChart.SeriesCollection(seriesNum);
                        oS.Name = str;
                        seriesNum++;
                    }
                }
            }

            if (strYTitle != "")
            {
                Axis yAxis = (Axis)xlChart.Axes(XlAxisType.xlValue,
                                                XlAxisGroup.xlPrimary);
                yAxis.HasTitle            = true;
                yAxis.AxisTitle.Text      = strYTitle;
                yAxis.AxisTitle.Font.Size = yFontSize;
            }
        }
Exemplo n.º 32
0
		public RemoveGroupCmd(ChartObject item, Group group) : base("Ungroup")
		{
			this.item = item;
			this.group = group;
		}
Exemplo n.º 33
0
		internal override void accept(ChartObject obj)
		{
			obj.completeModify();
		}
Exemplo n.º 34
0
		public ModifyItemCmd(ChartObject item) : base("Modify")
		{
			this.item = item;
			initialState = item.createState();
			item.saveState(initialState);
		}
Exemplo n.º 35
0
		internal abstract void accept(ChartObject obj);		
Exemplo n.º 36
0
 protected override void ObjectExitedJudgement(ChartObject obj)
 {
 }
Exemplo n.º 37
0
		public AddGroupCmd(ChartObject item, Group group) : base("Group")
		{
			this.item = item;
			this.group = group;
		}
Exemplo n.º 38
0
        public ActionResult GeraExcel()
        {
            Application xlApp;
            Workbook    xlWorkBook;
            Worksheet   xlWorkSheet;
            object      misValue = System.Reflection.Missing.Value;

            xlApp       = new Application();
            xlWorkBook  = xlApp.Workbooks.Add(misValue);
            xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);

            //incluindo dados
            xlWorkSheet.Cells[1, 1] = "";
            xlWorkSheet.Cells[1, 2] = "Macoratti";
            xlWorkSheet.Cells[1, 3] = "Miriam";
            xlWorkSheet.Cells[1, 4] = "Jeffersom";

            xlWorkSheet.Cells[2, 1] = "Matemática";
            xlWorkSheet.Cells[2, 2] = "80";
            xlWorkSheet.Cells[2, 3] = "65";
            xlWorkSheet.Cells[2, 4] = "45";

            xlWorkSheet.Cells[3, 1] = "Química";
            xlWorkSheet.Cells[3, 2] = "78";
            xlWorkSheet.Cells[3, 3] = "72";
            xlWorkSheet.Cells[3, 4] = "60";

            xlWorkSheet.Cells[4, 1] = "Física";
            xlWorkSheet.Cells[4, 2] = "82";
            xlWorkSheet.Cells[4, 3] = "80";
            xlWorkSheet.Cells[4, 4] = "65";

            xlWorkSheet.Cells[5, 1] = "Português";
            xlWorkSheet.Cells[5, 2] = "75";
            xlWorkSheet.Cells[5, 3] = "82";
            xlWorkSheet.Cells[5, 4] = "68";

            Range chartRange;

            ChartObjects xlCharts  = (ChartObjects)xlWorkSheet.ChartObjects(Type.Missing);
            ChartObject  myChart   = (ChartObject)xlCharts.Add(10, 80, 300, 250);
            Chart        chartPage = myChart.Chart;

            chartRange = xlWorkSheet.get_Range("A1", "d5");
            chartPage.SetSourceData(chartRange, misValue);
            //chartPage.ChartType = XlChartType.xlColumnClustered;
            chartPage.ChartType = XlChartType.xl3DColumnClustered;

            xlWorkBook.SaveAs(@"D:\Work\Dropbox\PROJETOS AXYSWEB\xl3DColumnStacked.xls", XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue,
                              XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            liberarObjetos(xlWorkSheet);
            liberarObjetos(xlWorkBook);
            liberarObjetos(xlApp);

            ViewBag.Message = "O excel foi gerado com sucesso.";

            return(View("About"));
        }
Exemplo n.º 39
0
		public ExpandItemCmd(ChartObject item) : base("Expand")
		{
			this.item = item;
			intlVisible = item.Visible;
			intlExpanded = item.isExpanded();
		}
Exemplo n.º 40
0
            protected virtual int ExportSummary(Workbook workbook, int sheetIndex, int rowBegin)
            {
                //1.1 前月倒數2天交易日
                DateTime ldt_sdate = PbFunc.f_get_last_day("AI3", KindId, StartMonth, 2);

                //1.2 抓當月最後交易日
                DateTime ldt_edate = PbFunc.f_get_end_day("AI3", KindId, StartMonth);

                Worksheet ws            = workbook.Worksheets[sheetIndex];
                int       rowIndex      = rowBegin;
                int       emptyRowCount = rowIndex + 1 + 32;

                //1.3 get ai3 data
                DataTable dtTemp = Dao.d_ai3(KindId, ldt_sdate, ldt_edate);

                if (dtTemp.Rows.Count <= 0)
                {
                    //刪除空白列
                    if (rowIndex < emptyRowCount)
                    {
                        string selectBegin = (rowIndex + 2).ToString();
                        string selectEnd   = (emptyRowCount).ToString();
                        string cellRange   = string.Format("A{0}:G{1}", selectBegin, selectEnd);
                        ws.DeleteCells(ws.Range[cellRange], DeleteMode.EntireRow);
                    }
                    return(0);
                }

                //1.4 export to sheet
                DateTime ldt_ymd = DateTime.MinValue;

                foreach (DataRow dr in dtTemp.Rows)
                {
                    DateTime ai3_date = dr["ai3_date"].AsDateTime();
                    if (ldt_ymd != ai3_date)
                    {
                        ldt_ymd = ai3_date;
                        rowIndex++;
                        ws.Cells[rowIndex, 0].Value = ldt_ymd.ToString("MM/dd");
                    }

                    ws.Cells[rowIndex, 1].Value = dr["ai3_close_price"].AsDecimal();
                    ws.Cells[rowIndex, 3].Value = dr["ai3_m_qnty"].AsDecimal();
                    ws.Cells[rowIndex, 4].Value = dr["ai3_oi"].AsDecimal();
                    ws.Cells[rowIndex, 5].Value = dr["ai3_index"].AsDecimal();
                }//foreach (DataRow dr in dtTemp.Rows) {

                //1.5 刪除空白列(注意,沒刪除好會影響到後面sheet的圖表)
                if (rowIndex < emptyRowCount)
                {
                    string selectBegin = (rowIndex + 2).ToString();
                    string selectEnd   = (emptyRowCount).ToString();
                    string cellRange   = string.Format("A{0}:G{1}", selectBegin, selectEnd);
                    ws.DeleteCells(ws.Range[cellRange], DeleteMode.EntireRow);
                    //ken,用DeleteCells還是不行,測試結果似乎xlsx的圖表公式一直固定,不會更新
                }

                //1.6 圖表範圍重選
                ChartObject chartObjs    = workbook.ChartSheets[$"{ws.Name}a"].Chart;
                ChartData   newChartData = new ChartData();

                //黃金 or 台幣黃金期貨總成交量
                newChartData.RangeValue    = ws.Range["D4:D" + (rowIndex + 1).AsString()];
                chartObjs.Series[0].Values = newChartData;
                //黃金 or 台幣黃金期貨總未平倉量
                newChartData.RangeValue    = ws.Range["E4:E" + (rowIndex + 1).AsString()];
                chartObjs.Series[1].Values = newChartData;
                //黃金 or 台幣黃金期貨價格
                newChartData.RangeValue    = ws.Range["B4:B" + (rowIndex + 1).AsString()];
                chartObjs.Series[2].Values = newChartData;
                //現貨價格
                newChartData.RangeValue    = ws.Range["F4:F" + (rowIndex + 1).AsString()];
                chartObjs.Series[3].Values = newChartData;

                return(1);
            }
Exemplo n.º 41
0
 protected ObjectRenderable3D(ChartObject obj)
 {
     Object = obj;
 }
Exemplo n.º 42
0
 protected GlowingRenderState3D(ChartObject obj)
     : base(obj)
 {
 }
Exemplo n.º 43
0
		internal override void accept(ChartObject obj)
		{
			obj.Draw(g, shadows);
		}