public DiagramArguments(string source, DiagramType type, DiagramStyle style, bool debug = false)
 {
     Source = source;
     Type   = type;
     Style  = style;
     Debug  = debug;
 }
        //Получение выбранной диаграммы.
        private AbstractDiagram GetDiagram(DiagramType type)
        {
            AbstractDiagram diagram;

            switch (type)
            {
            case DiagramType.PieChart:
                diagram = new PieChart(DataInfo);
                break;

            case DiagramType.NormalizedHistogram:
                diagram = new NormalizedHistogram(DataInfo);
                break;

            case DiagramType.StackedHistogram:
                diagram = new StackedHistogram(DataInfo);
                break;

            case DiagramType.Plot:
                diagram = new Plot(DataInfo);
                break;

            case DiagramType.Scatter:
                diagram = new Scatter(DataInfo);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type));
            }
            return(diagram);
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="YumlFactory" /> class.
        /// </summary>
        /// <param name="diagramType">Type of the diagram.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="scale">The scale.</param>
        private YumlFactory(DiagramType diagramType = DiagramType.Plain, Direction direction = Direction.LeftToRight, Scale scale = Scale.Normal)
        {
            var options = string.Empty;

            switch (diagramType)
            {
            case DiagramType.Boring:
                options += "boring;";
                break;

            case DiagramType.Plain:
                options += "plain;";
                break;

            case DiagramType.Scruffy:
                options += "scruffy;";
                break;
            }

            switch (direction)
            {
            case Direction.LeftToRight:
                options += "dir:LR;";
                break;

            case Direction.TopToBottom:
                options += "dir:TD;";
                break;

            case Direction.RightToLeft:
                options += "dir:RL;";
                break;
            }

            switch (scale)
            {
            case Scale.Huge:
                options += "scale:180;";
                break;

            case Scale.Big:
                options += "scale:120;";
                break;

            case Scale.Normal:
                options += "scale:100;";
                break;

            case Scale.Small:
                options += "scale:80;";
                break;

            case Scale.Tiny:
                options += "scale:60;";
                break;
            }

            this.settingsFragment = options;
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="YumlFactory" /> class.
 /// </summary>
 /// <param name="types">The types.</param>
 /// <param name="diagramType">Type of the diagram.</param>
 /// <param name="direction">The direction.</param>
 /// <param name="scale">The scale.</param>
 public YumlFactory(
     IList <Type> types,
     DiagramType diagramType = DiagramType.Plain,
     Direction direction     = Direction.LeftToRight,
     Scale scale             = Scale.Normal)
     : this(diagramType, direction, scale)
 {
     this.Types = types;
 }
 public void SetChartData <T, U>(List <KeyValuePair <T, U> > data, DiagramType type)
 {
     this._data                      = ChartTypeConverter(type);
     this._data.ItemsSource          = data;
     this._data.DependentValuePath   = "Value";
     this._data.IndependentValuePath = "Key";
     // Reload the Diagram
     this.Diagram          = new Chart();
     this._data.SeriesHost = null;
     this.Diagram.Series.Add(_data);
 }
예제 #6
0
        private void oszlopToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                ToolStripMenuItem chItem = sender as ToolStripMenuItem;
                foreach (ToolStripMenuItem item in diagramToolStripMenuItem.DropDownItems)
                {
                    item.Checked = (item == chItem);
                }

                if (chartReport.LocalReport.ReportPath == null)
                {
                    return;
                }

                if (chItem == oszlopToolStripMenuItem)
                {
                    diagramType = DiagramType.Column;
                }
                else if (chItem == sordiagramToolStripMenuItem)
                {
                    diagramType = DiagramType.Bar;
                }
                else if (chItem == területToolStripMenuItem)
                {
                    diagramType = DiagramType.Area;
                }
                else if (chItem == vonalToolStripMenuItem)
                {
                    diagramType = DiagramType.Line;
                }
                else if (chItem == körToolStripMenuItem)
                {
                    diagramType = DiagramType.Pie;
                }
                else if (chItem == körsávToolStripMenuItem)
                {
                    diagramType = DiagramType.Doughnut;
                }

                refreshBtn_Click(null, null);
            }
            catch (Exception ex)
            {
            }
        }
예제 #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)AssocDays;
         hashCode = (hashCode * 397) ^ (AssocLocationSuffix != null ? AssocLocationSuffix.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AssocTrainUid != null ? AssocTrainUid.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)AssocType;
         hashCode = (hashCode * 397) ^ (BaseLocationSuffix != null ? BaseLocationSuffix.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)Category;
         hashCode = (hashCode * 397) ^ DateFrom.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)DateIndicator;
         hashCode = (hashCode * 397) ^ DateTo.GetHashCode();
         hashCode = (hashCode * 397) ^ (DiagramType != null ? DiagramType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Location != null ? Location.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MainTrainUid != null ? MainTrainUid.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)RecordIdentity;
         hashCode = (hashCode * 397) ^ (int)StpIndicator;
         return(hashCode);
     }
 }
 // Get a new Data-Series according to the DiagramType (ENUM)
 private DataPointSeries ChartTypeConverter(DiagramType type)
 {
     if (type == DiagramType.LINE)
     {
         return(new LineSeries());
     }
     else if (type == DiagramType.COLUMN)
     {
         return(new ColumnSeries());
     }
     else if (type == DiagramType.AREA)
     {
         return(new AreaSeries());
     }
     else if (type == DiagramType.PIE)
     {
         return(new PieSeries());
     }
     // Get Pie as default
     else
     {
         return(new PieSeries());
     }
 }
예제 #9
0
	    public ElementContainer(DiagramType sourceDiagramType)
	    {
	        this.sourceDiagramType = sourceDiagramType;
	    }
예제 #10
0
 /// <summary>
 /// Конструктор диалогового окна.
 /// </summary>
 /// <param name="type">Тип выбранной диаграммы.</param>
 public DrawDiagramDialog(DiagramType type)
 {
     Type = type;
     InitializeComponent();
     Repeat.IsEnabled = false;
 }
예제 #11
0
 public ElementContainer(DiagramType sourceDiagramType)
 {
     this.sourceDiagramType = sourceDiagramType;
 }
예제 #12
0
 private void StackedHistogramButtonCLick(object sender, RoutedEventArgs e)
 {
     currenType = DiagramType.StackedHistogram;
     new DrawDiagramDialog(currenType).ShowDialog();
 }
예제 #13
0
 private void NormalizedHistogramButtonClick(object sender, RoutedEventArgs e)
 {
     currenType = DiagramType.NormalizaedHistogram;
     new DrawDiagramDialog(currenType).ShowDialog();
 }
예제 #14
0
 private void PieChartButtonClick(object sender, RoutedEventArgs e)
 {
     currenType = DiagramType.Piechart;
     new DrawDiagramDialog(currenType).ShowDialog();
 }
예제 #15
0
 private void ScatterButtonOnClic(object sender, RoutedEventArgs e)
 {
     currentType = DiagramType.Scatter;
     new DrawDiagramDialog(currentType).ShowDialog();
 }
예제 #16
0
 protected override void InitializeExecute()
 {
     base.InitializeExecute();
     IsPhotoVisible = false;
     RunInBackground(() =>
     {
         using (var repo = new BodyStateRepository())
         {
             bodyStates = repo.GetListForProgress(20);
             selectedType = ViewModels.DiagramType.Weight;
             InvokeInUIThread(() => OnSelectedTypeChanged());
         }
     });
 }
예제 #17
0
        public DrawDiagramDialog(DiagramType type)
        {
            Type = type;

            InitializeComponent();
        }
예제 #18
0
 public ElementContainer(DiagramType sourceDiagramType, ClipboardCommand clipboardCommand)
 {
     this.SourceDiagramType = sourceDiagramType;
     this.ClipboardCommand  = clipboardCommand;
 }
예제 #19
0
        public static string GenerateGraphic(
            ElectionYear electionYear,
            string[] foos,
            AxisYType axisYType,
            DiagramType diagramType
            )
        {
            var fooDatas = electionYear.FooData.Where(f => !f.IsHiddenForIks).ToArray();
            var path     = Consts.LocalPath;
            Func <string, List <Election>, AxisYType, SortedDictionary <int, int> > getResults;

            if (diagramType == DiagramType.Results)
            {
                getResults = GetNumbersToResult;
            }
            else
            {
                getResults = GetNumbersToPresence;
            }

            var firstPart  = diagramType == DiagramType.Results ? "Results" : "Presence";
            var secondPart = axisYType == AxisYType.People ? "ByPeople" : "ByUIKs";

            string picName = firstPart + secondPart;

            Directory.CreateDirectory(Consts.GraphicsPath);
            var name        = Path.Combine(Consts.GraphicsPath, picName + electionYear.Year);
            var pictureName = name + ".jpg";
            var xls         = name + ".xls";
            var fi          = new FileInfo(pictureName);
            var fiXls       = new FileInfo(xls);

            if (File.Exists(pictureName))
            {
                return(fi.Name);
            }

            var what = electionYear.DirElectionInfo;

            var fileName  = path + @"\" + Consts.ElectionsDir + @"\" + what + @"\" + what + electionYear.Year + ".xml";
            var elections = ProcessData.ReadSavedData(fileName);

            object misValue = System.Reflection.Missing.Value;

            const int Width  = 400; // 467;
            const int Height = 230; // 200;

            var app       = new ApplicationClass();
            var workBook  = app.Workbooks.Add(misValue);
            var workSheet = (Worksheet)workBook.Worksheets[1];

            var chartObjects = (ChartObjects)workSheet.ChartObjects(Type.Missing);
            var chartObject  = chartObjects.Add(10, 80, (diagramType == DiagramType.Results) ? Width : 300, Height);
            var chart        = chartObject.Chart;

            chart.ChartType = XlChartType.xlXYScatterLinesNoMarkers;

            var seriesCollection = (SeriesCollection)chart.SeriesCollection(misValue);

            if (diagramType == DiagramType.Presence)
            {
                int c = 0;
                var percentsCounter = getResults(null, elections, axisYType);
                foreach (var kvp in percentsCounter)
                {
                    c++;
                    workSheet.Cells[c, 1] = kvp.Value;
                    workSheet.Cells[c, 2] = kvp.Key;
                }

                var series = seriesCollection.NewSeries();
                series.Values  = workSheet.Range["a1", "a" + c.ToString()];
                series.XValues = workSheet.Range["b1", "b" + c.ToString()];
                chart.Legend.Delete();
            }
            else
            {
                var values = new Triple <SortedDictionary <int, int>, string, int> [foos.Length];
                for (int i = 0; i < values.Length; i++)
                {
                    var value = getResults(foos[i], elections, axisYType);
                    values[i] = new Triple <SortedDictionary <int, int>, string, int>(value, foos[i], value.Count);
                }
                for (int i = 0; i < values.Length; i++)
                {
                    int c = 0;
                    foreach (var kvp in values[i].First)
                    {
                        c++;
                        workSheet.Cells[c, 2 * i + 1] = kvp.Value;
                        workSheet.Cells[c, 2 * i + 2] = kvp.Key;
                    }
                    var series = seriesCollection.NewSeries();
                    var first  = (char)('a' + 2 * i);
                    var second = (char)('a' + 2 * i + 1);
                    var foo    = fooDatas.First(f => string.Compare(f.EnglishShort, foos[i], StringComparison.CurrentCultureIgnoreCase) == 0);
                    series.Name    = string.Format("{0},\n{1}%", foo.RussianLong, foo.Result);
                    series.Values  = workSheet.Range[first.ToString() + "1", first.ToString() + c.ToString()];
                    series.XValues = workSheet.Range[second + "1", second.ToString() + c.ToString()];
                }
            }

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

            xAxis.HasTitle       = true;
            xAxis.AxisTitle.Text = diagramType == DiagramType.Results ? "Результат, %" : "Явка, %";

            xAxis.MinimumScale      = 0;
            xAxis.MajorUnit         = 10;
            xAxis.MinorUnit         = 1;
            xAxis.MinorTickMark     = XlTickMark.xlTickMarkInside;
            xAxis.HasMajorGridlines = true;
            //xAxis.HasMinorGridlines = true;
            xAxis.MaximumScale = 100;

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

            yAxis.HasTitle       = true;
            yAxis.AxisTitle.Text = (axisYType == AxisYType.UIK) ? "Количество участков" : "Количество людей на участках";
            yAxis.MaximumScale   = diagramType == DiagramType.Results
                                    ? axisYType == AxisYType.People ? 14000000 : 10000
                                    : axisYType == AxisYType.People ? 6000000 : 6000;


            chart.HasTitle = true;
            var presence = diagramType == DiagramType.Results ? "" : string.Format(", {0}%", electionYear.Presence.ToString().Replace(",", "."));

            chart.ChartTitle.Text = string.Format("{0} {1} {2}{3}", diagramType == DiagramType.Results ? "Результаты выборов" : "Явка на выборах",
                                                  (electionYear.ElectionType == ElectionType.Duma) ? "в Думу" : "президента",
                                                  electionYear.Year, presence);

            if (diagramType == DiagramType.Results)
            {
                chart.PlotArea.Width = 262;
            }
            Trace.WriteLine(chart.PlotArea.Width);
            File.Delete(pictureName);
            File.Delete(fiXls.FullName);
            //workBook.SaveAs(fiXls.FullName, XlFileFormat.xlWorkbookDefault, misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            chart.Export(fi.FullName, "JPG", misValue);
            workBook.Close(false, misValue, misValue);
            app.Quit();


            Marshal.ReleaseComObject(workSheet);
            Marshal.ReleaseComObject(workBook);
            Marshal.ReleaseComObject(app);

            return(fi.Name);
        }
예제 #20
0
 public MainControlViewModel()
 {
     this.selectedMode = DiagramType.Class;
 }
예제 #21
0
        public string drawDiagram(int count, DiagramType type)
        {
            List <Individual.User> tempUsers = users.Take(count).ToList();

            int maximum = 0;

            string[] lines = new string[count];

            switch (type)
            {
            case DiagramType.Experience:
                tempUsers = tempUsers.OrderByDescending(x => x.Experience).ToList();

                maximum = tempUsers[0].Experience;

                for (int i = 0; i < count; i++)
                {
                    lines[i] = (i + 1).ToString().Length < 2 ? $"#{i + 1} |" : $"#{i + 1}|";
                    double relPercent = users[i].Experience / ((double)maximum / 10);
                    for (int j = 0; j < relPercent; j++)
                    {
                        lines[i] += "■";
                    }
                    lines[i] += $"  ({users[i].Experience} / {Game.findUser(users[i].ID)})";
                }
                break;

            case DiagramType.Level:
                tempUsers = tempUsers.OrderByDescending(x => x.Level).ToList();

                maximum = tempUsers[0].Level;

                for (int i = 0; i < count; i++)
                {
                    lines[i] = (i + 1).ToString().Length < 2 ? $"#{i + 1} |" : $"#{i + 1}|";
                    double relPercent = users[i].Level / ((double)maximum / 10);
                    for (int j = 0; j < relPercent; j++)
                    {
                        lines[i] += "■";
                    }
                    lines[i] += $"  ({users[i].Level} / {Game.findUser(users[i].ID)})";
                }
                break;

            case DiagramType.Score:
                tempUsers = tempUsers.OrderByDescending(x => x.Score).ToList();

                maximum = tempUsers[0].Score;

                for (int i = 0; i < count; i++)
                {
                    lines[i] = (i + 1).ToString().Length < 2 ? $"#{i+1} |" : $"#{i+1}|";
                    double relPercent = users[i].Score / ((double)maximum / 10);
                    for (int j = 0; j < relPercent; j++)
                    {
                        lines[i] += "■";
                    }
                    lines[i] += $"  ({users[i].Score} / {Game.findUser(users[i].ID)})";
                }
                break;
            }

            string output = "```" + string.Join("\n", lines) + "```";

            return(output);
        }