Exemple #1
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         foreach (RaindropObj current in this.m_rainFG)
         {
             current.Dispose();
         }
         this.m_rainFG.Clear();
         this.m_rainFG = null;
         this.m_mountain1 = null;
         this.m_mountain2 = null;
         if (this.m_rainSFX != null)
         {
             this.m_rainSFX.Dispose();
         }
         this.m_rainSFX = null;
         this.m_tree1 = null;
         this.m_tree2 = null;
         this.m_tree3 = null;
         this.m_fern1 = null;
         this.m_fern2 = null;
         this.m_fern3 = null;
         this.m_introText.Dispose();
         this.m_introText = null;
         base.Dispose();
     }
 }
Exemple #2
0
 public RoomObj()
 {
     this.GameObjList = new List<GameObj>();
     this.TerrainObjList = new List<TerrainObj>();
     this.DoorList = new List<DoorObj>();
     this.EnemyList = new List<EnemyObj>();
     this.BorderList = new List<BorderObj>();
     this.TempEnemyList = new List<EnemyObj>();
     this.LevelType = GameTypes.LevelType.NONE;
     this.m_indexText = new TextObj(Game.PixelArtFontBold);
     this.m_indexText.FontSize = 150f;
     this.m_indexText.Align = Types.TextAlign.Centre;
     this.m_roomInfoText = new TextObj(Game.PixelArtFontBold);
     this.m_roomInfoText.FontSize = 30f;
     this.m_roomInfoText.Align = Types.TextAlign.Centre;
     this.m_fairyChestText = new TextObj(Game.JunicodeFont);
     this.m_fairyChestText.FontSize = 26f;
     this.m_fairyChestText.Position = new Vector2(300f, 20f);
     this.m_fairyChestText.DropShadow = new Vector2(2f, 2f);
     this.m_fairyChestText.Text = "";
     this.m_pauseBG = new SpriteObj("Blank_Sprite");
     this.m_pauseBG.TextureColor = Color.Black;
     this.m_pauseBG.Opacity = 0f;
     this.IsReversed = false;
 }
Exemple #3
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         this.m_buttonText = null;
         base.Dispose();
     }
 }
 public FullScreenOptionsObj(OptionsScreen parentScreen)
     : base(parentScreen, "Fullscreen")
 {
     this.m_toggleText = (this.m_nameText.Clone() as TextObj);
     this.m_toggleText.X = (float)this.m_optionsTextOffset;
     this.m_toggleText.Text = "No";
     this.AddChild(this.m_toggleText);
 }
 public ToggleDirectInputOptionsObj(OptionsScreen parentScreen)
     : base(parentScreen, "Use DInput Gamepads")
 {
     this.m_toggleText = (this.m_nameText.Clone() as TextObj);
     this.m_toggleText.X = (float)this.m_optionsTextOffset;
     this.m_toggleText.Text = "No";
     this.AddChild(this.m_toggleText);
 }
 public ResolutionOptionsObj(OptionsScreen parentScreen)
     : base(parentScreen, "Resolution")
 {
     this.m_toggleText = (this.m_nameText.Clone() as TextObj);
     this.m_toggleText.X = (float)this.m_optionsTextOffset;
     this.m_toggleText.Text = "null";
     this.AddChild(this.m_toggleText);
 }
Exemple #7
0
 public static void RandomIntro(TextObj textObj, int wordWrap = 0)
 {
     textObj.Text = WordBuilder.intro[CDGMath.RandomInt(0, WordBuilder.intro.Length - 1)] + WordBuilder.middle[CDGMath.RandomInt(0, WordBuilder.middle.Length - 1)] + WordBuilder.end[CDGMath.RandomInt(0, WordBuilder.end.Length - 1)];
     if (wordWrap > 0)
     {
         textObj.WordWrap(wordWrap);
     }
 }
 public QuickDropOptionsObj(OptionsScreen parentScreen)
     : base(parentScreen, "Enable Quick Drop")
 {
     this.m_toggleText = (this.m_nameText.Clone() as TextObj);
     this.m_toggleText.X = (float)this.m_optionsTextOffset;
     this.m_toggleText.Text = "No";
     this.AddChild(this.m_toggleText);
 }
 public ReduceQualityOptionsObj(OptionsScreen parentScreen)
     : base(parentScreen, "Reduce Shader Quality")
 {
     this.m_toggleText = (this.m_nameText.Clone() as TextObj);
     this.m_toggleText.X = (float)this.m_optionsTextOffset;
     this.m_toggleText.Text = "No";
     this.AddChild(this.m_toggleText);
 }
Exemple #10
0
 public override void LoadContent()
 {
     this.m_text = new TextObj(Game.JunicodeLargeFont);
     this.m_text.FontSize = 20f;
     this.m_text.Text = "This is a demo of Rogue Legacy.\nThere may be bugs, and some assets are missing, but we hope you enjoy it.";
     this.m_text.ForceDraw = true;
     this.m_text.Position = new Vector2(660f - (float)this.m_text.Width / 2f, 360f - (float)this.m_text.Height / 2f - 30f);
     base.LoadContent();
 }
Exemple #11
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         this.m_text.Dispose();
         this.m_text = null;
         base.Dispose();
     }
 }
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         this.m_toggleText = null;
         this.m_displayModeList.Clear();
         this.m_displayModeList = null;
         base.Dispose();
     }
 }
Exemple #13
0
 public MapScreen(ProceduralLevelScreen level)
 {
     this.m_mapDisplay = new MapObj(false, level);
     this.m_alzheimersQuestionMarks = new TextObj(Game.JunicodeLargeFont);
     this.m_alzheimersQuestionMarks.FontSize = 30f;
     this.m_alzheimersQuestionMarks.ForceDraw = true;
     this.m_alzheimersQuestionMarks.Text = "?????";
     this.m_alzheimersQuestionMarks.Align = Types.TextAlign.Centre;
     this.m_alzheimersQuestionMarks.Position = new Vector2(660f, 360f - (float)this.m_alzheimersQuestionMarks.Height / 2f);
 }
Exemple #14
0
 public OptionsObj(OptionsScreen parentScreen, string name)
 {
     this.m_parentScreen = parentScreen;
     this.m_nameText = new TextObj(Game.JunicodeFont);
     this.m_nameText.FontSize = 12f;
     this.m_nameText.Text = name;
     this.m_nameText.DropShadow = new Vector2(2f, 2f);
     this.AddChild(this.m_nameText);
     base.ForceDraw = true;
 }
Exemple #15
0
 public KeyIconObj()
 {
     SpriteObj obj = new SpriteObj("KeyboardButton_Sprite");
     this.AddChild(obj);
     this.m_buttonText = new TextObj(Game.PixelArtFont);
     this.m_buttonText.FontSize = 16f;
     this.m_buttonText.DropShadow = new Vector2(1f, 1f);
     this.m_buttonText.Align = Types.TextAlign.Centre;
     this.m_buttonText.Y = (float)(-(float)(this.m_buttonText.Height / 2));
     this.AddChild(this.m_buttonText);
     this.m_buttonText.Visible = false;
 }
Exemple #16
0
 public FairyChestObj(PhysicsManager physicsManager)
     : base(physicsManager)
 {
     this.m_lockSprite = new SpriteObj("Chest4Unlock_Sprite");
     this.m_errorSprite = new SpriteObj("CancelIcon_Sprite");
     this.m_errorSprite.Visible = false;
     this.m_timerText = new TextObj(Game.JunicodeFont);
     this.m_timerText.FontSize = 18f;
     this.m_timerText.DropShadow = new Vector2(2f, 2f);
     this.m_timerText.Align = Types.TextAlign.Centre;
     this.m_player = Game.ScreenManager.Player;
 }
Exemple #17
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         Console.WriteLine("Disposing CDG Splash Screen");
         this.m_logo.Dispose();
         this.m_logo = null;
         this.m_loadingText.Dispose();
         this.m_loadingText = null;
         base.Dispose();
     }
 }
Exemple #18
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         this.m_enemyNameText.Dispose();
         this.m_enemyNameText = null;
         this.m_enemyLevelText.Dispose();
         this.m_enemyLevelText = null;
         this.m_enemyHPBar.Dispose();
         this.m_enemyHPBar = null;
         base.Dispose();
     }
 }
Exemple #19
0
 public override void LoadContent()
 {
     this.m_text = new TextObj(Game.JunicodeLargeFont);
     this.m_text.FontSize = 20f;
     this.m_text.Text = "Thanks for playing the Rogue Legacy Demo. You're pretty good at games.";
     this.m_text.ForceDraw = true;
     this.m_text.Position = new Vector2(660f - (float)this.m_text.Width / 2f, 360f - (float)this.m_text.Height / 2f - 30f);
     this.m_playerShrug = new SpriteObj("PlayerShrug_Sprite");
     this.m_playerShrug.ForceDraw = true;
     this.m_playerShrug.Position = new Vector2(660f, (float)(this.m_text.Bounds.Bottom + 100));
     this.m_playerShrug.Scale = new Vector2(3f, 3f);
     base.LoadContent();
 }
Exemple #20
0
 public EnemyHUDObj()
     : base("EnemyHUD_Sprite")
 {
     base.ForceDraw = true;
     this.m_enemyNameText = new TextObj(null);
     this.m_enemyNameText.Font = Game.JunicodeFont;
     this.m_enemyNameText.FontSize = 10f;
     this.m_enemyNameText.Align = Types.TextAlign.Right;
     this.m_enemyLevelText = new TextObj(null);
     this.m_enemyLevelText.Font = Game.EnemyLevelFont;
     this.m_enemyHPBar = new SpriteObj("EnemyHPBar_Sprite");
     this.m_enemyHPBar.ForceDraw = true;
     this.m_enemyHPBarLength = this.m_enemyHPBar.SpriteRect.Width;
 }
Exemple #21
0
        protected internal override void Deactivate(Player player)
        {
            Event<MapEnterEventArgs>.Handler -= MapScreenEntered;
            Event<MapDrawEventArgs>.Handler -= MapScreenDraw;
            Event<MapExitEventArgs>.Handler -= MapScreenExited;

            if (questionMarkText != null)
            {
                questionMarkText.Dispose();
                questionMarkText = null;
            }

            base.Deactivate(player);
        }
Exemple #22
0
        private void MapScreenEntered(MapEnterEventArgs args)
        {
            questionMarkText = new TextObj(Game.Fonts.JunicodeLargeFont)
            {
                FontSize = 30f,
                ForceDraw = true,
                Text = "?????",
                Align = Types.TextAlign.Centre,
                Position = new Vector2(660f, 360f - questionMarkText.Height / 2f)
            };

            if (!args.IsTeleporter)
                args.DrawNothing = true;
        }
Exemple #23
0
 public SkillObj(string spriteName)
     : base(spriteName)
 {
     this.StatType = 0;
     this.DisplayStat = false;
     base.Visible = false;
     base.ForceDraw = true;
     this.LevelText = new TextObj(Game.JunicodeFont);
     this.LevelText.FontSize = 10f;
     this.LevelText.Align = Types.TextAlign.Centre;
     this.LevelText.OutlineWidth = 2;
     this.InputDescription = "";
     base.OutlineWidth = 2;
     this.m_coinIcon = new SpriteObj("UpgradeIcon_Sprite");
 }
Exemple #24
0
 public override void LoadContent()
 {
     this.m_logo = new SpriteObj("CDGLogo_Sprite");
     this.m_logo.Position = new Vector2(660f, 360f);
     this.m_logo.Rotation = 90f;
     this.m_logo.ForceDraw = true;
     this.m_loadingText = new TextObj(Game.JunicodeFont);
     this.m_loadingText.FontSize = 18f;
     this.m_loadingText.Align = Types.TextAlign.Right;
     this.m_loadingText.Text = "...Loading";
     this.m_loadingText.TextureColor = new Color(100, 100, 100);
     this.m_loadingText.Position = new Vector2(1280f, 630f);
     this.m_loadingText.ForceDraw = true;
     this.m_loadingText.Opacity = 0f;
     base.LoadContent();
 }
Exemple #25
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         Console.WriteLine("Disposing Text Screen");
         this.m_text.Dispose();
         this.m_text = null;
         this.m_smoke1.Dispose();
         this.m_smoke1 = null;
         this.m_smoke2.Dispose();
         this.m_smoke2 = null;
         this.m_smoke3.Dispose();
         this.m_smoke3 = null;
         base.Dispose();
     }
 }
Exemple #26
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         Console.WriteLine("Disposing SkillUnlock Screen");
         this.m_picturePlate.Dispose();
         this.m_picturePlate = null;
         this.m_picture.Dispose();
         this.m_picture = null;
         this.m_text = null;
         this.m_title.Dispose();
         this.m_title = null;
         this.m_titlePlate.Dispose();
         this.m_titlePlate = null;
         this.m_plate.Dispose();
         this.m_plate = null;
         base.Dispose();
     }
 }
Exemple #27
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         Console.WriteLine("Disposing Profile Card Screen");
         this.m_frontCard.Dispose();
         this.m_frontCard = null;
         this.m_backCard.Dispose();
         this.m_backCard = null;
         this.m_playerName = null;
         this.m_money = null;
         this.m_levelClass = null;
         this.m_playerHUD = null;
         this.m_frontTrait1 = null;
         this.m_frontTrait2 = null;
         this.m_playerBG = null;
         this.m_classDescription = null;
         this.m_author = null;
         this.m_playerStats = null;
         this.m_equipmentTitle = null;
         this.m_runesTitle = null;
         this.m_equipmentList.Clear();
         this.m_equipmentList = null;
         this.m_runeBackTitleList.Clear();
         this.m_runeBackTitleList = null;
         this.m_runeBackDescriptionList.Clear();
         this.m_runeBackDescriptionList = null;
         this.m_playerSprite.Dispose();
         this.m_playerSprite = null;
         this.m_spellIcon.Dispose();
         this.m_spellIcon = null;
         this.m_tombStoneSprite.Dispose();
         this.m_tombStoneSprite = null;
         this.m_cancelText.Dispose();
         this.m_cancelText = null;
         this.m_dataList1.Clear();
         this.m_dataList1 = null;
         this.m_dataList2.Clear();
         this.m_dataList2 = null;
         base.Dispose();
     }
 }
Exemple #28
0
        private void DisplayCalibrationCurve()
        {
            CalibrationCurveOptions options = Settings.Default.CalibrationCurveOptions;

            zedGraphControl.GraphPane.YAxis.Type             = zedGraphControl.GraphPane.XAxis.Type
                                                             = options.LogPlot ? AxisType.Log : AxisType.Linear;
            zedGraphControl.GraphPane.Legend.IsVisible       = options.ShowLegend;
            _scatterPlots    = null;
            CalibrationCurve = null;
            SrmDocument document = DocumentUiContainer.DocumentUI;

            if (!document.Settings.HasResults)
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_No_results_available;
                return;
            }
            PeptideDocNode      peptide      = null;
            PeptideGroupDocNode peptideGroup = null;
            SequenceTree        sequenceTree = _skylineWindow.SequenceTree;

            if (null != sequenceTree)
            {
                PeptideTreeNode peptideTreeNode = sequenceTree.GetNodeOfType <PeptideTreeNode>();
                if (null != peptideTreeNode)
                {
                    peptide = peptideTreeNode.DocNode;
                }
                PeptideGroupTreeNode peptideGroupTreeNode = sequenceTree.GetNodeOfType <PeptideGroupTreeNode>();
                if (null != peptideGroupTreeNode)
                {
                    peptideGroup = peptideGroupTreeNode.DocNode;
                }
            }

            if (null == peptide)
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings
                    .CalibrationForm_DisplayCalibrationCurve_Select_a_peptide_to_see_its_calibration_curve;
                return;
            }
            PeptideQuantifier peptideQuantifier = PeptideQuantifier.GetPeptideQuantifier(document.Settings, peptideGroup,
                                                                                         peptide);
            CalibrationCurveFitter curveFitter = new CalibrationCurveFitter(peptideQuantifier, document.Settings);

            if (peptideQuantifier.QuantificationSettings.RegressionFit == RegressionFit.NONE)
            {
                if (string.IsNullOrEmpty(
                        peptideQuantifier.QuantificationSettings.NormalizationMethod.IsotopeLabelTypeName))
                {
                    zedGraphControl.GraphPane.Title.Text =
                        QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_Use_the_Quantification_tab_on_the_Peptide_Settings_dialog_to_control_the_conversion_of_peak_areas_to_concentrations_;
                }
                else
                {
                    if (!peptide.InternalStandardConcentration.HasValue)
                    {
                        zedGraphControl.GraphPane.Title.Text =
                            string.Format(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_convert_peak_area_ratios_to_concentrations__specify_the_internal_standard_concentration_for__0__, peptide);
                    }
                    else
                    {
                        zedGraphControl.GraphPane.Title.Text = null;
                    }
                }
            }
            else
            {
                if (curveFitter.GetStandardConcentrations().Any())
                {
                    zedGraphControl.GraphPane.Title.Text = null;
                }
                else
                {
                    zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_fit_a_calibration_curve__set_the_Sample_Type_of_some_replicates_to_Standard__and_specify_their_concentration_;
                }
            }

            zedGraphControl.GraphPane.XAxis.Title.Text = curveFitter.GetXAxisTitle();
            zedGraphControl.GraphPane.YAxis.Title.Text = curveFitter.GetYAxisTitle();
            CalibrationCurve = curveFitter.GetCalibrationCurve();
            double minX = double.MaxValue, maxX = double.MinValue;

            _scatterPlots = new CurveList();
            foreach (var sampleType in SampleType.ListSampleTypes())
            {
                if (!Options.DisplaySampleType(sampleType))
                {
                    continue;
                }
                PointPairList pointPairList = new PointPairList();
                for (int iReplicate = 0;
                     iReplicate < document.Settings.MeasuredResults.Chromatograms.Count;
                     iReplicate++)
                {
                    ChromatogramSet chromatogramSet = document.Settings.MeasuredResults.Chromatograms[iReplicate];
                    if (!Equals(sampleType, chromatogramSet.SampleType))
                    {
                        continue;
                    }
                    double?y = curveFitter.GetYValue(iReplicate);
                    double?x = curveFitter.GetSpecifiedXValue(iReplicate)
                               ?? curveFitter.GetCalculatedXValue(CalibrationCurve, iReplicate);
                    if (y.HasValue && x.HasValue)
                    {
                        PointPair point = new PointPair(x.Value, y.Value)
                        {
                            Tag = iReplicate
                        };
                        pointPairList.Add(point);
                        if (!Options.LogPlot || x.Value > 0)
                        {
                            minX = Math.Min(minX, x.Value);
                        }
                        maxX = Math.Max(maxX, x.Value);
                    }
                }
                if (pointPairList.Any())
                {
                    var lineItem = zedGraphControl.GraphPane.AddCurve(sampleType.ToString(), pointPairList,
                                                                      sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    lineItem.Symbol.Fill    = new Fill(sampleType.Color);
                    _scatterPlots.Add(lineItem);
                }
            }
            List <string> labelLines = new List <String>();
            RegressionFit regressionFit = document.Settings.PeptideSettings.Quantification.RegressionFit;

            if (regressionFit != RegressionFit.NONE)
            {
                if (minX <= maxX)
                {
                    int interpolatedLinePointCount = 100;
                    if (!options.LogPlot)
                    {
                        if (regressionFit == RegressionFit.LINEAR_THROUGH_ZERO)
                        {
                            minX = Math.Min(0, minX);
                        }
                        if (regressionFit != RegressionFit.QUADRATIC)
                        {
                            interpolatedLinePointCount = 2;
                        }
                    }
                    LineItem interpolatedLine = CreateInterpolatedLine(CalibrationCurve, minX, maxX,
                                                                       interpolatedLinePointCount, Options.LogPlot);
                    if (null != interpolatedLine)
                    {
                        zedGraphControl.GraphPane.CurveList.Add(interpolatedLine);
                    }
                }
                labelLines.Add(CalibrationCurve.ToString());

                if (CalibrationCurve.RSquared.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_ +
                                   CalibrationCurve.RSquared.Value.ToString("0.####")); // Not L10N
                }
                if (!Equals(curveFitter.QuantificationSettings.RegressionWeighting, RegressionWeighting.NONE))
                {
                    labelLines.Add(string.Format("{0}: {1}", // Not L10N
                                                 QuantificationStrings.Weighting, curveFitter.QuantificationSettings.RegressionWeighting));
                }
            }

            if (options.ShowSelection)
            {
                double?ySelected = curveFitter.GetYValue(_skylineWindow.SelectedResultsIndex);
                double?xSelected = curveFitter.GetCalculatedXValue(CalibrationCurve, _skylineWindow.SelectedResultsIndex);
                if (xSelected.HasValue && ySelected.HasValue)
                {
                    ArrowObj arrow = new ArrowObj(xSelected.Value, ySelected.Value, xSelected.Value,
                                                  ySelected.Value)
                    {
                        Line = { Color = GraphSummary.ColorSelected }
                    };
                    zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
                }

                var quantificationResult = curveFitter.GetQuantificationResult(_skylineWindow.SelectedResultsIndex);
                if (quantificationResult.CalculatedConcentration.HasValue)
                {
                    labelLines.Add(string.Format("{0} = {1}", // Not L10N
                                                 QuantificationStrings.Calculated_Concentration, quantificationResult));
                }
                else if (!quantificationResult.NormalizedArea.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_replicate_has_missing_or_truncated_transitions);
                }
            }
            if (labelLines.Any())
            {
                TextObj text = new TextObj(TextUtil.LineSeparate(labelLines), .01, 0,
                                           CoordType.ChartFraction, AlignH.Left, AlignV.Top)
                {
                    IsClippedToChartRect = true,
                    ZOrder   = ZOrder.E_BehindCurves,
                    FontSpec = GraphSummary.CreateFontSpec(Color.Black),
                };
                zedGraphControl.GraphPane.GraphObjList.Add(text);
            }
        }
Exemple #29
0
        private GraphPane DoGraphPane()
        {
            DateTime objSDateTime = dateTimePickerStart.Value.AddDays(-1);
            DateTime objEDateTime = dateTimePickerEnd.Value.AddDays(1);

            GraphPane myPane = new GraphPane();

            // Set the titles and axis labels
            myPane.YAxis.Title.Text = "Price (£)";

//            myPane.XAxis.Scale.MajorUnit = DateUnit.Day;

            myPane.XAxis.Type = AxisType.Date;

//            myPane.BarSettings.Type = BarType.SortedOverlay;
//            myPane.XAxis.Scale.MinAuto = false;
//            myPane.XAxis.Scale.MaxAuto = false;
            myPane.XAxis.Scale.Format = "dd-MM";
//            myPane.XAxis.Scale.Min = (double)new XDate(objSDateTime);
//            myPane.XAxis.Scale.Max = (double)new XDate(objEDateTime);

#if false
            // Generate a red curve with diamond symbols, and "Alpha" in the legend
            LineItem myCurve = myPane.AddCurve("Alpha",
                                               list, Color.Red, SymbolType.Diamond);
            // Fill the symbols with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Generate a blue curve with circle symbols, and "Beta" in the legend
            myCurve = myPane.AddCurve("Beta",
                                      list2, Color.Blue, SymbolType.Circle);
            // Fill the symbols with white
            myCurve.Symbol.Fill = new Fill(Color.White);
            // Associate this curve with the Y2 axis
            myCurve.IsY2Axis = true;

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.Red;
            myPane.YAxis.Title.FontSpec.FontColor = Color.Red;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            myPane.YAxis.MajorGrid.IsZeroLine = false;
            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;
            // Manually set the axis range
            myPane.YAxis.Scale.Min = -30;
            myPane.YAxis.Scale.Max = 30;

            // Enable the Y2 axis display
            myPane.Y2Axis.IsVisible = true;
            // Make the Y2 axis scale blue
            myPane.Y2Axis.Scale.FontSpec.FontColor = Color.Blue;
            myPane.Y2Axis.Title.FontSpec.FontColor = Color.Blue;
            // turn off the opposite tics so the Y2 tics don't show up on the Y axis
            myPane.Y2Axis.MajorTic.IsOpposite = false;
            myPane.Y2Axis.MinorTic.IsOpposite = false;
            // Display the Y2 axis grid lines
            myPane.Y2Axis.MajorGrid.IsVisible = true;
            // Align the Y2 axis labels so they are flush to the axis
            myPane.Y2Axis.Scale.Align = AlignP.Inside;

            // Fill the axis background with a gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f);
#endif
            // Add a text box with instructions
            TextObj text = new TextObj(
                "Zoom: left mouse & drag\nPan: middle mouse & drag\nContext Menu: right mouse\nSave As Image: On Context Menu\nCopyright Dynamic Devices 2006",
                0.02f, 0.95f, CoordType.ChartFraction, AlignH.Left, AlignV.Bottom);
            text.FontSpec.StringAlignment = StringAlignment.Near;
            //          myPane.GraphObjList.Add(text);


            // OPTIONAL: Show tooltips when the mouse hovers over a point
            //            zg1.IsShowPointValues = true;
            //            zg1.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler);

            // OPTIONAL: Add a custom context menu item
            //            zg1.ContextMenuBuilder += new ZedGraphControl.ContextMenuBuilderEventHandler(
            //                            MyContextMenuBuilder);

            // OPTIONAL: Handle the Zoom Event
            //            zg1.ZoomEvent += new ZedGraphControl.ZoomEventHandler(MyZoomEvent);

            // Size the control to fit the window
            //            SetSetSize();

            return(myPane);
        }
        public LineGraphBandDemo() : base("A demo of a bar graph with a region highlighted.",
                                          "Line Graph Band Demo", DemoType.Line)
        {
            GraphPane myPane = base.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text       = "Line Graph with Band Demo";
            myPane.XAxis.Title.Text = "Sequence";
            myPane.YAxis.Title.Text = "Temperature, C";

            // Enter some random data values
            double[] y  = { 100, 115, 75, 22, 98, 40, 10 };
            double[] y2 = { 90, 100, 95, 35, 80, 35, 35 };
            double[] y3 = { 80, 110, 65, 15, 54, 67, 18 };
            double[] x  = { 100, 200, 300, 400, 500, 600, 700 };

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);

            // Generate a red curve with "Curve 1" in the legend
            LineItem myCurve = myPane.AddCurve("Curve 1", x, y, Color.Red);

            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Generate a blue curve with "Curve 2" in the legend
            myCurve = myPane.AddCurve("Curve 2", x, y2, Color.Blue);
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Generate a green curve with "Curve 3" in the legend
            myCurve = myPane.AddCurve("Curve 3", x, y3, Color.Green);
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Manually set the x axis range
            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 800;
            // Display the Y axis grid lines
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;

            // Draw a box item to highlight a value range
            BoxObj box = new BoxObj(0, 100, 800, 30, Color.Empty,
                                    Color.FromArgb(150, Color.LightGreen));

            box.Fill = new Fill(Color.White, Color.FromArgb(200, Color.LightGreen), 45.0F);
            // Use the BehindAxis zorder to draw the highlight beneath the grid lines
            box.ZOrder = ZOrder.E_BehindAxis;
            myPane.GraphObjList.Add(box);

            // Add a text item to label the highlighted range
            TextObj text = new TextObj("Optimal\nRange", 750, 85, CoordType.AxisXYScale,
                                       AlignH.Right, AlignV.Center);

            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.IsBold           = true;
            text.FontSpec.IsItalic         = true;
            myPane.GraphObjList.Add(text);
        }
        void GenerateGraphData()
        {
            PointPairList stab = new PointPairList();

            stab.Add(0, MainV2.comPort.MAV.param["IM_STAB_COL_1"].Value);
            stab.Add(40, MainV2.comPort.MAV.param["IM_STAB_COL_2"].Value);
            stab.Add(60, MainV2.comPort.MAV.param["IM_STAB_COL_3"].Value);
            stab.Add(100, MainV2.comPort.MAV.param["IM_STAB_COL_4"].Value);

            PointPairList acro = new PointPairList();

            double _acro_col_expo = MainV2.comPort.MAV.param["IM_ACRO_COL_EXP"].Value;

            // 100 point curve
            for (int a = 0; a <= 100; a++)
            {
                double col_in       = (a - 50.0) / 50.0;
                double col_in3      = col_in * col_in * col_in;
                double col_out      = (_acro_col_expo * col_in3) + ((1 - _acro_col_expo) * col_in);
                double acro_col_out = 500 + col_out * 500;

                acro.Add(a, acro_col_out);
            }

            zedGraphControl1.GraphPane.CurveList.Clear();
            zedGraphControl1.GraphPane.GraphObjList.Clear();

            var myCurve = zedGraphControl1.GraphPane.AddCurve("Stabalize Collective", stab, Color.DodgerBlue, SymbolType.Circle);

            foreach (PointPair pp in stab)
            {
                // Add a another text item to to point out a graph feature
                TextObj text = new TextObj(pp.X.ToString(), pp.X, pp.Y);
                // rotate the text 90 degrees
                text.FontSpec.Angle     = 0;
                text.FontSpec.FontColor = Color.White;
                // Align the text such that the Right-Center is at (700, 50) in user scale coordinates
                text.Location.AlignH = AlignH.Right;
                text.Location.AlignV = AlignV.Center;
                // Disable the border and background fill options for the text
                text.FontSpec.Fill.IsVisible   = false;
                text.FontSpec.Border.IsVisible = false;
                zedGraphControl1.GraphPane.GraphObjList.Add(text);
            }

            zedGraphControl1.GraphPane.AddCurve("Acro Collective", acro, Color.Yellow, SymbolType.None);

            double posx = map(MainV2.comPort.MAV.cs.ch6out, MainV2.comPort.MAV.param["H_COL_MIN"].Value,
                              MainV2.comPort.MAV.param["H_COL_MAX"].Value, 0, 100);

            // set current marker
            var m_cursorLine = new LineObj(Color.Black, posx, 0, posx, 1);

            m_cursorLine.Location.CoordinateFrame = CoordType.XScaleYChartFraction; // This do the trick !
            m_cursorLine.IsClippedToChartRect     = true;
            m_cursorLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            m_cursorLine.Line.Width = 2f;
            m_cursorLine.Line.Color = Color.Red;
            m_cursorLine.ZOrder     = ZOrder.E_BehindCurves;
            zedGraphControl1.GraphPane.GraphObjList.Add(m_cursorLine);

            try
            {
                //zedGraphControl1.AxisChange();
            }
            catch
            {
            }
            // Force a redraw
            zedGraphControl1.Invalidate();
        }
Exemple #32
0
        public override void DrawGraph()
        {
            string graphTitle;

            //饼组成部分标签
            string[] labels = null;
            //饼组成部分的值
            double[] values = null;
            //合计
            double total = 0;

            if (base.XAxisScaleRefrence == DataTableStruct.Rows)
            {
                labels = new string[base.DataSource.Rows.Count];
                values = new double[base.DataSource.Rows.Count];

                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    labels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                    if (Convert.IsDBNull(base.DataSource.Rows[i][base.ShowValueColumns[index].ColumnField]))
                    {
                        values[i] = 0;
                    }
                    else
                    {
                        values[i] = Convert.ToDouble(base.DataSource.Rows[i][base.ShowValueColumns[index].ColumnField]);
                        total    += values[i];
                    }
                }

                graphTitle = base.ShowValueColumns[index].ColumnName;
            }
            else
            {
                labels = new string[base.ShowValueColumns.Length];
                values = new double[base.ShowValueColumns.Length];

                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    labels[i] = base.ShowValueColumns[i].ColumnName;
                    if (Convert.IsDBNull(base.DataSource.Rows[index][base.ShowValueColumns[i].ColumnField]))
                    {
                        values[i] = 0;
                    }
                    else
                    {
                        values[i] = Convert.ToDouble(base.DataSource.Rows[index][base.ShowValueColumns[i].ColumnField]);
                    }

                    total += values[i];
                }
                graphTitle = base.DataSource.Rows[index][base.CNNameColumn].ToString();
            }

            #region 显示图形
            base.GraphContainer.Controls.Clear();

            ZedGraph.ZedGraphControl grphTx = new ZedGraph.ZedGraphControl();

            grphTx.IsEnableHZoom     = false;
            grphTx.IsEnableVZoom     = false;
            grphTx.IsEnableWheelZoom = false;
            grphTx.Dock = System.Windows.Forms.DockStyle.Fill;


            ZedGraph.GraphPane myPane = grphTx.GraphPane;
            myPane.Title.Text = graphTitle;
            //字体
            //myPane.Title.FontSpec.IsItalic = true;
            //myPane.Title.FontSpec.Size = 24f;
            //myPane.Title.FontSpec.Family = "Verdana";
            myPane.Fill = new Fill(Color.White, Color.Goldenrod, 45.0f);
            myPane.Chart.Fill.IsVisible = false;
            myPane.Legend.Position      = LegendPos.Float;
            myPane.Legend.Location      = new Location(0.95f, 0.15f, CoordType.PaneFraction, AlignH.Right, AlignV.Top);
            myPane.Legend.FontSpec.Size = 10f;
            myPane.Legend.IsHStack      = false;
            //画饼状部分
            for (int i = 0; i < labels.Length; i++)
            {
                Color color;
                if (base.Colors == null)
                {
                    color = GetColor();
                }
                else
                {
                    color = base.Colors[i];
                }

                PieItem segment = myPane.AddPieSlice(values[i], color, color, 45f, 0, labels[i]);
            }

            CurveList curves = myPane.CurveList;

            TextObj text = new TextObj("合计:\n" + total.ToString(), 0.18F, 0.40F, CoordType.PaneFraction);
            text.Location.AlignH           = AlignH.Center;
            text.Location.AlignV           = AlignV.Bottom;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill             = new Fill(Color.White, Color.FromArgb(255, 100, 100), 45F);
            text.FontSpec.StringAlignment  = StringAlignment.Center;
            myPane.GraphObjList.Add(text);

            // Create a drop shadow for the total value text item
            TextObj text2 = new TextObj(text);
            text2.FontSpec.Fill = new Fill(Color.Black);
            text2.Location.X   += 0.008f;
            text2.Location.Y   += 0.01f;
            myPane.GraphObjList.Add(text2);


            grphTx.AxisChange();

            base.GraphContainer.Controls.Add(grphTx);
            #endregion
        }
Exemple #33
0
        ///// <summary>
        /////     设置字体格式
        ///// </summary>
        ///// <param name="doc"></param>
        ///// <param name="table"></param>
        ///// <param name="setText"></param>
        ///// <returns></returns>
        //public XWPFParagraph SetCellText(XWPFDocument doc, XWPFTable table, string setText)
        //{
        //    //table中的文字格式设置
        //    var para = new CT_P();
        //    var pCell = new XWPFParagraph(para, table.Body);
        //    pCell.Alignment = ParagraphAlignment.CENTER; //字体居中
        //    pCell.VerticalAlignment = TextAlignment.CENTER; //字体居中

        //    var r1c1 = pCell.CreateRun();
        //    r1c1.SetText(setText);
        //    r1c1.FontSize = 12;
        //    r1c1.SetFontFamily("华文楷体", FontCharRange.None); //设置雅黑字体

        //    return pCell;
        //}

        ///// <summary>
        /////     设置单元格格式
        ///// </summary>
        ///// <param name="doc">doc对象</param>
        ///// <param name="table">表格对象</param>
        ///// <param name="setText">要填充的文字</param>
        ///// <param name="align">文字对齐方式</param>
        ///// <param name="textPos">rows行的高度</param>
        ///// <returns></returns>
        //public XWPFParagraph SetCellText(XWPFDocument doc, XWPFTable table, string setText, ParagraphAlignment align,
        //    int textPos)
        //{
        //    var para = new CT_P();
        //    var pCell = new XWPFParagraph(para, table.Body);
        //    //pCell.Alignment = ParagraphAlignment.LEFT;//字体
        //    pCell.Alignment = align;

        //    var r1c1 = pCell.CreateRun();
        //    r1c1.SetText(setText);
        //    r1c1.FontSize = 12;
        //    r1c1.SetFontFamily("华文楷体", FontCharRange.None); //设置雅黑字体
        //    r1c1.SetTextPosition(textPos); //设置高度

        //    return pCell;
        //}



        #endregion

        /// <summary>
        /// 绘制拟合图
        /// </summary>
        /// <param name="dataGridView1"></param>
        /// <param name="zedGraphControl4"></param>
        /// <param name="Y"></param>
        /// <param name="FitY"></param>
        /// <param name="order"></param>
        /// <param name="PointNaem"></param>

        public static void GraphFitY(int Width, int Height, ZedGraphControl zedGraphControl4, Matrix Y, Matrix FitY, int order, string PointNaem, DataGridView dataGridView1 = null, bool F*g = true)
        {
            zedGraphControl4.BorderStyle = System.Windows.Forms.BorderStyle.None;
            MasterPane masterpane = zedGraphControl4.MasterPane;//获取zedGraphControl1的面板

            //去掉面板中所有的子面板,默认会有一个面板在里面,清除默认面板
            masterpane.PaneList.Clear();
            int Days = Y.Rows;

            if (F*g)
            {
                zedGraphControl4.Visible = true;
            }
            else
            {
                zedGraphControl4.Visible = false;
            }
            zedGraphControl4.IsShowCursorValues = true;//该值确定当鼠标位于ZedGraph.Chart.Rect内时是否将显示显示当前比例尺值的工具提示。
            zedGraphControl4.IsEnableSelection  = true;
            //创建一个面板
            GraphPane graphpane  = new GraphPane(); //拟合图
            GraphPane graphpane1 = new GraphPane(); //残差图

            graphpane.XAxis.Scale.Max = Days;       //设置最大刻度                                           //设置公共信息
            SetGraphics(graphpane);
            SetGraphics(graphpane1);
            graphpane.YAxis.MajorGrid.IsZeroLine  = false;
            graphpane1.YAxis.MajorGrid.IsZeroLine = false;
            //创建点序列
            PointPairList list = new PointPairList();//创建点的集合

            if (dataGridView1 != null)
            {
                dataGridView1.RowHeadersVisible = false;//隐藏行头
                dataGridView1.Columns.Add("col1", "期数");
                dataGridView1.Columns.Add("col2", "观测值(mm)");
                dataGridView1.Columns.Add("col3", "拟合值(mm)");
                dataGridView1.Columns.Add("col4", "残差(mm)");
                foreach (DataGridViewColumn item in dataGridView1.Columns)//单元格居中
                {
                    item.SortMode = DataGridViewColumnSortMode.NotSortable;
                    item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    item.DefaultCellStyle.BackColor = Color.Gainsboro;
                }
                dataGridView1.AutoSizeColumnsMode       = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView1.EnableHeadersVisualStyles = false;//在启动了可视样式的时候,BackColor和ForeColor的值会被忽略。
                dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Aqua;
                dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
            double[] y     = new double[Days];
            double[] _y    = new double[Days];
            double[] x     = new double[Days];
            double[] error = new double[Days];
            double   sd    = 0;


            if (!F*g)
            {
                zedGraphControl4.Size = new Size(920 - 120, 480);
                graphpane.Rect        = new RectangleF(15, 30, 900 - 120, 280);  //设置分图的大小和位置
                graphpane.Chart.Rect  = new RectangleF(95, 80, 750 - 120, 200);
                graphpane1.Rect       = new RectangleF(15, 320, 900 - 120, 150); //设置分图的大小和位置
                graphpane1.Chart.Rect = new RectangleF(95, 330, 750 - 120, 80);
            }
            else
            {
                zedGraphControl4.Size = new Size((int)(0.94117 * Width), (int)(0.65753 * Height));
                graphpane.Rect        = new RectangleF((int)(0.01764 * Width), (int)(0.04109 * Height), (int)(0.91764 * Width), (int)(0.38356 * Height)); //设置分图的大小和位置900, 300
                graphpane.Chart.Rect  = new RectangleF((int)(0.01764 * Width) + 60, (int)(0.04109 * Height) + 40, (int)(0.74117 * Width), (int)(0.27397 * Height));
                graphpane1.Rect       = new RectangleF((int)(0.01764 * Width), (int)(0.43835 * Height), (int)(0.91764 * Width), (int)(0.20547 * Height)); //设置分图的大小和位置
                graphpane1.Chart.Rect = new RectangleF((int)(0.01764 * Width) + 60, (int)(0.45205 * Height), (int)(0.74117 * Width), (int)(0.27397 * Height) - 100 - (int)(0.01369 * Height));
            }
            for (int i = 0; i < Days; i++)
            {
                x[i]     = i + 1;
                y[i]     = Y[i, 0];
                _y[i]    = FitY[i, 0];
                error[i] = FitY[i, 0] - Y[i, 0];
                if (dataGridView1 != null)
                {
                    dataGridView1.Rows.Add();
                    dataGridView1[3, i].Value = Math.Round(error[i], 2);
                    dataGridView1[0, i].Value = "第" + (order + 1 + i).ToString() + "期";
                    dataGridView1[1, i].Value = Math.Round(y[i], 2);
                    dataGridView1[2, i].Value = Math.Round(_y[i], 2);
                }
                sd += Math.Pow(error[i], 2);
            }
            sd /= Days;
            sd  = Math.Sqrt(sd);

            graphpane.YAxis.Title.Text            = "位移量/mm";
            graphpane.YAxis.Title.FontSpec.Family = "Arial";
            graphpane.XAxis.Scale.IsVisible       = false;
            graphpane.XAxis.Scale.MajorStep       = x.Length / graphpane.Rect.Width * 60;
            graphpane.YAxis.Title.FontSpec.Size   = 15;
            graphpane.YAxis.Title.FontSpec.IsBold = false;
            graphpane.Legend.Position             = LegendPos.TopCenter;
            graphpane.Legend.Border.IsVisible     = false;
            graphpane.Legend.FontSpec.Family      = "Arial";
            graphpane.Legend.FontSpec.Size        = 15;
            graphpane.Legend.FontSpec.IsBold      = false;
            graphpane1.XAxis.Scale.Max            = Days;//设置最大刻度
            double min, max;

            if ((min = Math.Abs(error.Min())) > (max = Math.Abs(error.Max())))
            {
                graphpane1.YAxis.Scale.Max = (int)min + 1;    //设置最小刻度
                graphpane1.YAxis.Scale.Min = -(int)min - 1;   //设置最大刻度
            }
            else
            {
                graphpane1.YAxis.Scale.Max = (int)max + 1;                       //设置最小刻度
                graphpane1.YAxis.Scale.Min = -(int)max - 1;                      //设置最大刻度
            }
            graphpane1.YAxis.Scale.MajorStep       = graphpane1.YAxis.Scale.Max; //设置大刻度步长
            graphpane1.XAxis.Scale.IsSkipLastLabel = false;

            graphpane1.YAxis.Title.Text            = "△/mm";
            graphpane1.YAxis.Title.FontSpec.Family = "Arial";
            graphpane1.YAxis.Title.FontSpec.Size   = 15;
            graphpane1.YAxis.Title.FontSpec.IsBold = false;

            graphpane1.XAxis.Title.Text            = "期数";
            graphpane1.XAxis.Title.FontSpec.Family = "Arial";
            graphpane1.XAxis.Title.FontSpec.Size   = 15;
            graphpane1.XAxis.Title.FontSpec.IsBold = false;


            LineItem myline  = graphpane.AddCurve("观测值", null, y, Color.SpringGreen, SymbolType.None);
            LineItem myline1 = graphpane.AddCurve("拟合值", null, _y, Color.Red, SymbolType.None);
            LineItem myline3 = graphpane1.AddCurve("残差", null, error, Color.Red, SymbolType.None);

            myline.Line.Width           = 1.5F; //线宽
            myline1.Line.Width          = 1.5F; //线宽
            myline3.Line.Width          = 1.5F; //线宽
            graphpane1.Legend.IsVisible = false;

            float   width  = graphpane.Chart.Rect.Width;
            float   heigh  = graphpane.Chart.Rect.Height;
            float   width1 = graphpane1.Chart.Rect.Width;
            float   heigh1 = graphpane1.Chart.Rect.Height;
            TextObj text   = new TextObj(PointNaem, 2 / width, 2 / heigh); //定义文本对象

            text.Location.AlignV           = AlignV.Top;                   //确定文本的x轴为于文本的最上端
            text.Location.AlignH           = AlignH.Left;                  //确定文本的y轴为于文本的最左端
            text.Location.CoordinateFrame  = CoordType.ChartFraction;      //设置文本的坐标系统,原点位于内框的左上角
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.FontColor        = Color.Blue;
            text.FontSpec.Size             = 15;
            graphpane.GraphObjList.Add(text);
            TextObj text1 = new TextObj(PointNaem, 2 / width1, 2 / heigh1); //定义文本对象

            text1.Location.AlignV           = AlignV.Top;                   //确定文本的x轴为于文本的最上端
            text1.Location.AlignH           = AlignH.Left;                  //确定文本的y轴为于文本的最左端
            text1.Location.CoordinateFrame  = CoordType.ChartFraction;      //设置文本的坐标系统,原点位于内框的左上角
            text1.FontSpec.Border.IsVisible = false;
            text1.FontSpec.FontColor        = Color.Blue;
            text1.FontSpec.Size             = 15;
            graphpane1.GraphObjList.Add(text1);
            graphpane1.XAxis.Scale.MajorStep = x.Length / graphpane.Rect.Width * 60;
            TextObj text2 = new TextObj("RMS=" + Math.Round(sd, 2) + "mm", 2 / width1, (heigh1 - 2) / heigh1); //定义文本对象

            text2.Location.AlignV           = AlignV.Bottom;                                                   //确定文本的x轴为于文本的最下端
            text2.Location.AlignH           = AlignH.Left;                                                     //确定文本的y轴为于文本的最左端
            text2.Location.CoordinateFrame  = CoordType.ChartFraction;                                         //设置文本的坐标系统,原点位于内框的左上角
            text2.FontSpec.Border.IsVisible = false;
            text2.FontSpec.FontColor        = Color.Blue;
            text2.FontSpec.Size             = 15;
            graphpane1.GraphObjList.Add(text2);
            masterpane.Add(graphpane);
            masterpane.Add(graphpane1);
            Graphics gd = zedGraphControl4.CreateGraphics();

            masterpane.AxisChange(gd);
            zedGraphControl4.Refresh();
        }
        public MasterSampleDemo() : base("Code Project MasterPane Sample",
                                         "MasterPane Sample", DemoType.Tutorial)
        {
            MasterPane myMaster = base.MasterPane;

            // Remove the default GraphPane that comes with ZedGraphControl
            myMaster.PaneList.Clear();

            // Set the masterpane title
            myMaster.Title.Text      = "ZedGraph MasterPane Example";
            myMaster.Title.IsVisible = true;

            // Fill the masterpane background with a color gradient
            myMaster.Fill = new Fill(Color.White, Color.MediumSlateBlue, 45.0F);

            // Set the margins to 10 points
            myMaster.Margin.All = 10;

            // Enable the masterpane legend
            myMaster.Legend.IsVisible = true;
            myMaster.Legend.Position  = LegendPos.TopCenter;

            // Add a priority stamp
            TextObj text = new TextObj("Priority", 0.88F, 0.12F);

            text.Location.CoordinateFrame  = CoordType.PaneFraction;
            text.FontSpec.Angle            = 15.0F;
            text.FontSpec.FontColor        = Color.Red;
            text.FontSpec.IsBold           = true;
            text.FontSpec.Size             = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color     = Color.Red;
            text.FontSpec.Fill.IsVisible   = false;
            text.Location.AlignH           = AlignH.Left;
            text.Location.AlignV           = AlignV.Bottom;
            myMaster.GraphObjList.Add(text);

            // Add a draft watermark
            text = new TextObj("DRAFT", 0.5F, 0.5F);
            text.Location.CoordinateFrame  = CoordType.PaneFraction;
            text.FontSpec.Angle            = 30.0F;
            text.FontSpec.FontColor        = Color.FromArgb(70, 255, 100, 100);
            text.FontSpec.IsBold           = true;
            text.FontSpec.Size             = 100;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible   = false;
            text.Location.AlignH           = AlignH.Center;
            text.Location.AlignV           = AlignV.Center;
            text.ZOrder = ZOrder.B_BehindLegend;
            myMaster.GraphObjList.Add(text);

            // Initialize a color and symbol type rotator
            ColorSymbolRotator rotator = new ColorSymbolRotator();

            // Create some new GraphPanes
            for (int j = 0; j < 5; j++)
            {
                // Create a new graph - rect dimensions do not matter here, since it
                // will be resized by MasterPane.AutoPaneLayout()
                GraphPane myPane = new GraphPane(new Rectangle(10, 10, 10, 10),
                                                 "Case #" + (j + 1).ToString(),
                                                 "Time, Days",
                                                 "Rate, m/s");

                // Fill the GraphPane background with a color gradient
                myPane.Fill          = new Fill(Color.White, Color.LightYellow, 45.0F);
                myPane.BaseDimension = 6.0F;

                // Make up some data arrays based on the Sine function
                PointPairList list = new PointPairList();
                for (int i = 0; i < 36; i++)
                {
                    double x = (double)i + 5;
                    double y = 3.0 * (1.5 + Math.Sin((double)i * 0.2 + (double)j));
                    list.Add(x, y);
                }

                // Add a curve to the Graph, use the next sequential color and symbol
                LineItem myCurve = myPane.AddCurve("Type " + j.ToString(),
                                                   list, rotator.NextColor, rotator.NextSymbol);
                // Fill the symbols with white to make them opaque
                myCurve.Symbol.Fill = new Fill(Color.White);

                // Add the GraphPane to the MasterPane
                myMaster.Add(myPane);
            }

            using (Graphics g = this.ZedGraphControl.CreateGraphics())
            {
                // Tell ZedGraph to auto layout the new GraphPanes
                myMaster.SetLayout(g, PaneLayout.ExplicitRow32);
                myMaster.AxisChange(g);
                //g.Dispose();
            }
        }
Exemple #35
0
        /// <summary>
        /// Первичная настройка компонента вывода графиков.
        /// </summary>
        /// <param name="zc"></param>
        public static void SetupGraph(ZedGraphControl zc)
        {
            var mas = zc.MasterPane;

            mas.Legend.IsVisible    = false;
            mas.IsCommonScaleFactor = false;
            mas.Border.IsVisible    = false;

            var gp = zc.GraphPane;
            var sx = gp.XAxis.Scale;
            var sy = gp.YAxis.Scale;

            gp.Border.IsVisible = false;

            // axis
            gp.IsFontsScaled    = false;
            gp.XAxis.Title.Text = "Время, с";
            gp.YAxis.Title.Text = "Напряжение, В";
            gp.Legend.IsVisible = false;
            gp.Title.IsVisible  = false;
            //gp.XAxis.Type = AxisType.Date;

            // grid

            /*gp.XAxis.MinorGrid.DashOff = gp.XAxis.MajorGrid.DashOff =
             *  gp.YAxis.MinorGrid.DashOff = gp.YAxis.MajorGrid.DashOff = 0;*/
            gp.XAxis.MinorGrid.DashOn        = gp.XAxis.MajorGrid.DashOn =
                gp.YAxis.MinorGrid.DashOn    = gp.YAxis.MajorGrid.DashOn = 0;
            gp.XAxis.MinorGrid.Color         = gp.YAxis.MinorGrid.Color = Color.FromArgb(240, 240, 240);
            gp.XAxis.MajorGrid.Color         = gp.YAxis.MajorGrid.Color = Color.FromArgb(220, 220, 220);
            gp.XAxis.MajorGrid.IsVisible     = gp.YAxis.MajorGrid.IsVisible =
                gp.XAxis.MinorGrid.IsVisible = gp.YAxis.MinorGrid.IsVisible = true;

            // scale
            sx.Min = X0;
            //sx.Max = X1;
            //sy.MinAuto = sy.MaxAuto = true;
            sy.Min     = Y0;
            sy.Max     = Y1;
            sx.MaxAuto = true;

            // curves
            gp.CurveList.Clear();
            LineItem curve;

            // main curve
            curve = new LineItem("V+", new LODPPL(), Color.Black, SymbolType.None, defaultMainLineWidth);
            gp.CurveList.Add(curve);
            curve = new LineItem("V-", new LODPPL(), Color.Red, SymbolType.None, defaultMainLineWidth);
            gp.CurveList.Add(curve);

            curve = new LineItem("S+", new LODPPL(), Color.Blue, SymbolType.None, defaultMainLineWidth);
            gp.CurveList.Add(curve);
            curve = new LineItem("S-", new LODPPL(), Color.Red, SymbolType.None, defaultMainLineWidth);
            gp.CurveList.Add(curve);


            curve = new LineItem("AA", new LODPPL(), Color.Blue, SymbolType.None, defaultMainLineWidth);
            gp.CurveList.Add(curve);


            curve = new LineItem("BB", new LODPPL(), Color.Blue, SymbolType.None, defaultMainLineWidth);
            gp.CurveList.Add(curve);

            // snapshot
            curve = new LineItem("SNAPSHOT", new PointPairList(), Color.Green, SymbolType.None);
            // gp.CurveList.Add(curve);
            // hidden autoscale limit hint points
            curve = new LineItem("5min", new PointPairList(), Color.Transparent, SymbolType.None);
            curve.AddPoint(0, double.NaN);
            curve.AddPoint(4 * 60, double.NaN); // FIXME: manual tuned for DUMB USER
            gp.CurveList.Add(curve);

            // objects
            LineObj hline;

            hline = new LineObj(Color.Blue, 0, 0, 1, 0)
            {
                Tag = "P+", IsVisible = true
            };
            hline.ZOrder = ZOrder.E_BehindCurves;
            hline.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            gp.GraphObjList.Add(hline);
            hline = new LineObj(Color.Blue, 0, 0, 1, 0)
            {
                Tag = "P-", IsVisible = true
            };
            hline.ZOrder = ZOrder.E_BehindCurves;
            hline.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            gp.GraphObjList.Add(hline);
            hline = new LineObj(Color.Red, 0, 0, 1, 0)
            {
                Tag = "D+", IsVisible = true
            };
            hline.ZOrder = ZOrder.E_BehindCurves;
            hline.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            gp.GraphObjList.Add(hline);
            hline = new LineObj(Color.Red, 0, 0, 1, 0)
            {
                Tag = "D-", IsVisible = true
            };
            hline.ZOrder = ZOrder.E_BehindCurves;
            hline.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            gp.GraphObjList.Add(hline);
            TextObj to;

            to = new TextObj("00:00:00  000.000", 0.98, 0.99, CoordType.PaneFraction, AlignH.Right, AlignV.Bottom)
            {
                Tag = "COORD", IsVisible = true
            };
            to.FontSpec.Size = 16;
            gp.GraphObjList.Add(textCoord = to);
            to = new TextObj("+0.000", 1, 0, CoordType.ChartFraction, AlignH.Right, AlignV.Top)
            {
                Tag = "V+", IsVisible = true
            };
            to.FontSpec.Size            = 16;
            gp.GraphObjList.Add(textPos = to);
            to = new TextObj("-0.000", 1, 1, CoordType.ChartFraction, AlignH.Right, AlignV.Bottom)
            {
                Tag = "V-", IsVisible = true
            };
            to.FontSpec.Size            = 16;
            gp.GraphObjList.Add(textNeg = to);

            // events
            zc.MouseDownEvent += new ZedGraphControl.ZedMouseEventHandler(zc_MouseDownEvent);
            zc.MouseMoveEvent += new ZedGraphControl.ZedMouseEventHandler(zc_MouseMoveEvent);
            zc.MouseUpEvent   += new ZedGraphControl.ZedMouseEventHandler(zc_MouseUpEvent);
            zc.MouseWheel     += new System.Windows.Forms.MouseEventHandler(zc_MouseWheel);
            zc.MouseEnter     += new EventHandler(zc_MouseEnter);
            zc.ZoomEvent      += new ZedGraphControl.ZoomEventHandler(zc_ZoomEvent);
            zc.Paint          += new PaintEventHandler(zc_Paint);
            zc.GraphPane.XAxis.ScaleFormatEvent += new Axis.ScaleFormatHandler(XAxis_ScaleFormatEvent);

            zc.AxisChange();
        }
Exemple #36
0
 public override void LoadContent()
 {
     Game.HSVEffect.Parameters["Saturation"].SetValue(0);
     this.m_background = new BackgroundObj("LineageScreenBG_Sprite");
     this.m_background.SetRepeated(true, true, base.Camera, null);
     this.m_background.X -= 6600f;
     this.m_bgShadow = new SpriteObj("LineageScreenShadow_Sprite");
     this.m_bgShadow.Scale = new Vector2(11f, 11f);
     this.m_bgShadow.Y -= 10f;
     this.m_bgShadow.ForceDraw = true;
     this.m_bgShadow.Opacity = 0.9f;
     this.m_bgShadow.Position = new Vector2(660f, 360f);
     this.m_titleText = new SpriteObj("LineageTitleText_Sprite");
     this.m_titleText.X = 660f;
     this.m_titleText.Y = 72f;
     this.m_titleText.ForceDraw = true;
     int num = 20;
     this.m_descriptionPlate = new ObjContainer("LineageScreenPlate_Character");
     this.m_descriptionPlate.ForceDraw = true;
     this.m_descriptionPlate.Position = new Vector2((float)(1320 - this.m_descriptionPlate.Width - 30), (float)(720 - this.m_descriptionPlate.Height) / 2f);
     TextObj textObj = new TextObj(Game.JunicodeFont);
     textObj.FontSize = 12f;
     textObj.Align = Types.TextAlign.Centre;
     textObj.OutlineColour = new Color(181, 142, 39);
     textObj.OutlineWidth = 2;
     textObj.Text = "Sir Skunky the IV";
     textObj.OverrideParentScale = true;
     textObj.Position = new Vector2((float)this.m_descriptionPlate.Width / 2f, 15f);
     textObj.LimitCorners = true;
     this.m_descriptionPlate.AddChild(textObj);
     TextObj textObj2 = textObj.Clone() as TextObj;
     textObj2.FontSize = 10f;
     textObj2.Text = "Knight";
     textObj2.Align = Types.TextAlign.Left;
     textObj2.X = (float)num;
     textObj2.Y += 40f;
     this.m_descriptionPlate.AddChild(textObj2);
     KeyIconTextObj keyIconTextObj = new KeyIconTextObj(Game.JunicodeFont);
     keyIconTextObj.FontSize = 8f;
     keyIconTextObj.OutlineColour = textObj2.OutlineColour;
     keyIconTextObj.OutlineWidth = 2;
     keyIconTextObj.OverrideParentScale = true;
     keyIconTextObj.Position = textObj2.Position;
     keyIconTextObj.Text = "Class description goes here";
     keyIconTextObj.Align = Types.TextAlign.Left;
     keyIconTextObj.Y += 30f;
     keyIconTextObj.X = (float)(num + 20);
     keyIconTextObj.LimitCorners = true;
     this.m_descriptionPlate.AddChild(keyIconTextObj);
     for (int i = 0; i < 2; i++)
     {
         TextObj textObj3 = textObj2.Clone() as TextObj;
         textObj3.Text = "TraitName";
         textObj3.X = (float)num;
         textObj3.Align = Types.TextAlign.Left;
         if (i > 0)
         {
             textObj3.Y = this.m_descriptionPlate.GetChildAt(this.m_descriptionPlate.NumChildren - 1).Y + 50f;
         }
         this.m_descriptionPlate.AddChild(textObj3);
         TextObj textObj4 = textObj2.Clone() as TextObj;
         textObj4.Text = "TraitDescription";
         textObj4.X = (float)(num + 20);
         textObj4.FontSize = 8f;
         textObj4.Align = Types.TextAlign.Left;
         this.m_descriptionPlate.AddChild(textObj4);
     }
     TextObj textObj5 = textObj2.Clone() as TextObj;
     textObj5.Text = "SpellName";
     textObj5.FontSize = 10f;
     textObj5.X = (float)num;
     textObj5.Align = Types.TextAlign.Left;
     this.m_descriptionPlate.AddChild(textObj5);
     KeyIconTextObj keyIconTextObj2 = new KeyIconTextObj(Game.JunicodeFont);
     keyIconTextObj2.OutlineColour = new Color(181, 142, 39);
     keyIconTextObj2.OutlineWidth = 2;
     keyIconTextObj2.OverrideParentScale = true;
     keyIconTextObj2.Position = new Vector2((float)this.m_descriptionPlate.Width / 2f, 15f);
     keyIconTextObj2.Y += 40f;
     keyIconTextObj2.Text = "SpellDescription";
     keyIconTextObj2.X = (float)(num + 20);
     keyIconTextObj2.FontSize = 8f;
     keyIconTextObj2.Align = Types.TextAlign.Left;
     keyIconTextObj2.LimitCorners = true;
     this.m_descriptionPlate.AddChild(keyIconTextObj2);
     this.m_masterArray = new List<LineageObj>();
     this.m_currentBranchArray = new List<LineageObj>();
     Vector2 arg_47E_0 = Vector2.Zero;
     this.m_confirmText = new KeyIconTextObj(Game.JunicodeFont);
     this.m_confirmText.ForceDraw = true;
     this.m_confirmText.FontSize = 12f;
     this.m_confirmText.DropShadow = new Vector2(2f, 2f);
     this.m_confirmText.Position = new Vector2(1280f, 630f);
     this.m_confirmText.Align = Types.TextAlign.Right;
     this.m_navigationText = new KeyIconTextObj(Game.JunicodeFont);
     this.m_navigationText.Align = Types.TextAlign.Right;
     this.m_navigationText.FontSize = 12f;
     this.m_navigationText.DropShadow = new Vector2(2f, 2f);
     this.m_navigationText.Position = new Vector2(this.m_confirmText.X, this.m_confirmText.Y + 40f);
     this.m_navigationText.ForceDraw = true;
     this.m_rerollText = new KeyIconTextObj(Game.JunicodeFont);
     this.m_rerollText.Align = Types.TextAlign.Right;
     this.m_rerollText.FontSize = 12f;
     this.m_rerollText.DropShadow = new Vector2(2f, 2f);
     this.m_rerollText.ForceDraw = true;
     this.m_rerollText.Position = new Vector2(1280f, 40f);
     base.LoadContent();
 }
        private void ChangeGraph()
        {
            int days = m_oDateRanges.Where(x => x.Item3).First().Item1;
            List <HistoricalQuoteDetails> oH = m_oSecAnalysis.GetDataForRange(DateTime.Now.AddDays(-days), DateTime.Now);

            string[] xData = days > 1 ?
                             oH.Select(h => h.Date.ToShortDateString()).ToArray()
                :
                             oH.Select(h => h.Date.ToShortTimeString()).ToArray();
            double[] yData = oH.Select(h => Convert.ToDouble(h.Close)).ToArray();

            ZedGraphControl PriceGraph = CreatePriceGraph(xData, yData);

            List <Tuple <string, double[]> > AdditionalGraphs = new List <Tuple <string, double[]> >();

            foreach (var TA in m_oIndicator.Where(t => t.Item3 == true).ToList())
            {
                switch (TA.Item1)
                {
                case TA_Indicator.Trend:
                    break;

                case TA_Indicator.MA:
                    break;

                case TA_Indicator.MA20_50_200:
                    break;

                case TA_Indicator.EMA:
                    break;

                case TA_Indicator.Bollinger:
                    GetBollinger(days).ForEach(x =>
                                               AdditionalGraphs.Add(new Tuple <string, double[]>(TA_Indicator.Bollinger.ToString(), x.ToArray()
                                                                                                 )));
                    break;

                case TA_Indicator.Crossover:
                    break;

                default:
                    break;
                }
            }
            foreach (var GS in m_oGraphSettings.Where(t => t.Item3 == true).ToList())
            {
                switch (GS.Item1)
                {
                case TA_Settings.Volume:
                    var oVolumeInfoList = m_oSecAnalysis.GetRangeOfVolumeIndicator(DateTime.Now.AddDays(-days), DateTime.Now)
                                          .Where(h => h.Item1.Date >= DateTime.Now.AddDays(-days).Date&& h.Item1.Date <= DateTime.Now.Date)
                                          .OrderBy(x => x.Item1)
                                          .ToList();

                    if (oVolumeInfoList.Count() > 0)
                    {
                        foreach (VolumeIndicatorType VolumeType in Enum.GetValues(typeof(VolumeIndicatorType)))
                        {
                            if ((VolumeType != VolumeIndicatorType.Unknown && VolumeType != VolumeIndicatorType.VolumeClimaxPlusHighVolumeChurn) && oVolumeInfoList.Where(z => z.Item2.VolumeIndicatorType.Equals(VolumeType)).Count() > 0)
                            {
                                AdditionalGraphs.Add(new Tuple <string, double[]>(VolumeType.ToString(),
                                                                                  yData.Select((s, i2) => new { i2, s })
                                                                                  .Select(t => (t.i2 < oVolumeInfoList.Count()) ? oVolumeInfoList[t.i2].Item2.VolumeIndicatorType.Equals(VolumeType) ? t.s : 0 : 0).ToArray()));
                            }
                        }
                    }
                    break;

                case TA_Settings.High_Low:
                    PriceGraph.GraphPane.GraphObjList.Add(DrawLine(yData.Max(), yData.Count(), GS.Item1.ToString()));
                    var text = new TextObj("High", 1, yData.Max() - 10, CoordType.ChartFraction, AlignH.Left, AlignV.Top);
                    text.ZOrder = ZOrder.A_InFront;
                    PriceGraph.GraphPane.GraphObjList.Add(text);
                    PriceGraph.GraphPane.GraphObjList.Add(DrawLine(yData.Min(), yData.Count(), GS.Item1.ToString()));
                    var textlow = new TextObj("Low", 1, yData.Min() + 10, CoordType.ChartFraction, AlignH.Left, AlignV.Top);
                    textlow.ZOrder = ZOrder.A_InFront;
                    PriceGraph.GraphPane.GraphObjList.Add(textlow);
                    break;

                default:
                    break;
                }
            }


            var pane = PriceGraph.GraphPane;

            AdditionalGraphs.ForEach(x =>
                                     pane.CurveList.Add(CreateLineItemFromData(x.Item2, x.Item1)
                                                        ));
            if (AdditionalGraphs.Count() > 0)
            {
                pane.YAxis.Scale.Max = AdditionalGraphs.Select(x => x.Item2.Max()).Max() * 1.0005;
                pane.YAxis.Scale.Min = AdditionalGraphs.SelectMany(d => d.Item2).Where(x => x > 0).Min() * 0.9995;
            }

            PriceGraph.Refresh();
            PriceGraph.Name = "StockChart";
            PriceGraph.Dock = DockStyle.Fill;
            if (!panel_chart.Controls.ContainsKey(PriceGraph.Name))
            {
                panel_chart.Controls.Add(PriceGraph);
                //if (AdditionalGraphs.Where(x=>x.Item1.Equals(TA_Settings.Volume.ToString())).Count() > 0)
                //if (Volume.Count() > 0 && ShowVolume)
                //    panel_vol.Controls.Add(oZGP_vol);
            }
            else
            {
                panel_chart.Controls.RemoveByKey(PriceGraph.Name);
                panel_chart.Controls.Add(PriceGraph);

                // panel_vol.Controls.RemoveByKey(oZGP_vol.Name);
                //if (Volume.Count() > 0 && ShowVolume)
                //    panel_vol.Controls.Add(oZGP_vol);
            }

            tableLayoutPanel_Graph.Visible = true;
        }
Exemple #38
0
        public MasterPaneDemo() : base("A Demo of the MasterPane",
                                       "MasterPane Demo", DemoType.General, DemoType.Special)
        {
            MasterPane myMaster = base.MasterPane;

            // Remove the default pane that comes with the ZedGraphControl.MasterPane
            myMaster.PaneList.Clear();

            // Set the master pane title
            myMaster.Title.Text      = "MasterPane Test";
            myMaster.Title.IsVisible = true;

            // Fill the pane background with a color gradient
            myMaster.Fill = new Fill(Color.White, Color.MediumSlateBlue, 45.0F);

            // Set the margins and the space between panes to 10 points
            myMaster.Margin.All   = 10;
            myMaster.InnerPaneGap = 10;

            // Enable the master pane legend
            myMaster.Legend.IsVisible = true;
            myMaster.Legend.Position  = LegendPos.TopCenter;

            // Add a confidential stamp
            TextObj text = new TextObj("Confidential", 0.80F, 0.12F);

            text.Location.CoordinateFrame = CoordType.PaneFraction;
            // angle the text at 15 degrees
            text.FontSpec.Angle            = 15.0F;
            text.FontSpec.FontColor        = Color.Red;
            text.FontSpec.IsBold           = true;
            text.FontSpec.Size             = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color     = Color.Red;
            text.FontSpec.Fill.IsVisible   = false;
            text.Location.AlignH           = AlignH.Left;
            text.Location.AlignV           = AlignV.Bottom;
            myMaster.GraphObjList.Add(text);

            // Add a draft watermark
            text = new TextObj("DRAFT", 0.5F, 0.5F);
            text.Location.CoordinateFrame = CoordType.PaneFraction;
            // tilt the text at 30 degrees
            text.FontSpec.Angle = 30.0F;
            // Use the alpha value (70) to make the text semi-transparent (a watermark)
            text.FontSpec.FontColor        = Color.FromArgb(70, 255, 100, 100);
            text.FontSpec.IsBold           = true;
            text.FontSpec.Size             = 100;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible   = false;
            text.Location.AlignH           = AlignH.Center;
            text.Location.AlignV           = AlignV.Center;
            text.ZOrder = ZOrder.B_BehindLegend;
            myMaster.GraphObjList.Add(text);

            for (int j = 0; j < 6; j++)
            {
                // Create a new GraphPane
                GraphPane myPane = new GraphPane();
                myPane.Title.Text       = "My Test Graph #" + (j + 1).ToString();
                myPane.XAxis.Title.Text = "X Axis";
                myPane.YAxis.Title.Text = "Y Axis";

                // Fill the pane background with a color gradient
                myPane.Fill = new Fill(Color.White, Color.LightYellow, 45.0F);
                // Reduce the base dimension to 6 inches, since these panes tend to be smaller
                myPane.BaseDimension = 6.0F;

                // Make up some data arrays based on the Sine function
                PointPairList list = new PointPairList();
                for (int i = 0; i < 36; i++)
                {
                    double x = (double)i + 5;
                    double y = 3.0 * (1.5 + Math.Sin((double)i * 0.2 + (double)j));
                    list.Add(x, y);
                }

                // Generate a red curve with diamond symbols
                LineItem myCurve = myPane.AddCurve("label" + j.ToString(),
                                                   list, Color.Red, SymbolType.Diamond);

                // Add the new GraphPane to the MasterPane
                myMaster.Add(myPane);
            }

            // Tell ZedGraph to auto layout all the panes
            using (Graphics g = base.ZedGraphControl.CreateGraphics())
            {
                myMaster.SetLayout(g, PaneLayout.SquareColPreferred);
                myMaster.AxisChange(g);
            }
        }
Exemple #39
0
        public void CreateChart(ZedGraphControl zgc)
        {
            GraphPane myPane = zgc.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text       = "Elevation above ground";
            myPane.XAxis.Title.Text = "Distance (m)";
            myPane.YAxis.Title.Text = "Elevation (m)";

            LineItem myCurve;

            myCurve = myPane.AddCurve("Planned Path", list1, Color.Red, SymbolType.None);
            myCurve = myPane.AddCurve("Google", list2, Color.Green, SymbolType.None);
            myCurve = myPane.AddCurve("SRTM", list3, Color.Blue, SymbolType.None);

            foreach (PointPair pp in list1)
            {
                // Add a another text item to to point out a graph feature
                TextObj text = new TextObj((string)pp.Tag, pp.X, pp.Y);
                // rotate the text 90 degrees
                text.FontSpec.Angle     = 90;
                text.FontSpec.FontColor = Color.White;
                // Align the text such that the Right-Center is at (700, 50) in user scale coordinates
                text.Location.AlignH = AlignH.Right;
                text.Location.AlignV = AlignV.Center;
                // Disable the border and background fill options for the text
                text.FontSpec.Fill.IsVisible   = false;
                text.FontSpec.Border.IsVisible = false;
                myPane.GraphObjList.Add(text);
            }

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = distance;

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.Red;
            myPane.YAxis.Title.FontSpec.FontColor = Color.Red;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            myPane.YAxis.MajorGrid.IsZeroLine = true;
            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;
            // Manually set the axis range
            //myPane.YAxis.Scale.Min = -1;
            //myPane.YAxis.Scale.Max = 1;

            // Fill the axis background with a gradient
            //myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f);

            // Calculate the Axis Scale Ranges
            try
            {
                zg1.AxisChange();
            }
            catch
            {
            }
        }
Exemple #40
0
        /// <summary>
        /// Create the heat map or single scan graph.
        /// </summary>
        private void CreateGraph()
        {
            if (_msDataFileScanHelper.MsDataSpectra == null)
            {
                return;
            }

            GraphPane.CurveList.Clear();
            GraphPane.GraphObjList.Clear();

            bool hasDriftDimension = _msDataFileScanHelper.MsDataSpectra.Length > 1;
            bool useHeatMap        = hasDriftDimension && !Settings.Default.SumScansFullScan;

            filterBtn.Visible          = spectrumBtn.Visible = hasDriftDimension;
            graphControl.IsEnableVPan  = graphControl.IsEnableVZoom = useHeatMap;
            GraphPane.Legend.IsVisible = useHeatMap;

            if (hasDriftDimension)
            {
                // Is there actually any drift time filtering available?
                double minDriftTime, maxDriftTime;
                _msDataFileScanHelper.GetDriftRange(out minDriftTime, out maxDriftTime, ChromSource.unknown); // Get range of drift times for all products and precursors
                if ((minDriftTime == double.MinValue) && (maxDriftTime == double.MaxValue))
                {
                    filterBtn.Visible = false;
                    filterBtn.Checked = false;
                }
            }

            if (useHeatMap)
            {
                ZoomYAxis(); // Call this again now that cues are there to indicate need for drift scale
                CreateDriftTimeHeatmap();
            }
            else
            {
                CreateSingleScan();
            }

            // Add extraction boxes.
            for (int i = 0; i < _msDataFileScanHelper.ScanProvider.Transitions.Length; i++)
            {
                var transition = _msDataFileScanHelper.ScanProvider.Transitions[i];
                if (transition.Source != _msDataFileScanHelper.Source)
                {
                    continue;
                }
                var color1        = Blend(transition.Color, Color.White, 0.60);
                var color2        = Blend(transition.Color, Color.White, 0.95);
                var extractionBox = new BoxObj(
                    transition.ProductMz - transition.ExtractionWidth.Value / 2,
                    0.0,
                    transition.ExtractionWidth.Value,
                    1.0,
                    Color.Transparent,
                    transition.Color,
                    Color.White)
                {
                    Location             = { CoordinateFrame = CoordType.XScaleYChartFraction },
                    ZOrder               = ZOrder.F_BehindGrid,
                    Fill                 = new Fill(color1, color2, 90),
                    IsClippedToChartRect = true,
                };
                GraphPane.GraphObjList.Add(extractionBox);
            }

            // Add labels.
            for (int i = 0; i < _msDataFileScanHelper.ScanProvider.Transitions.Length; i++)
            {
                var transition = _msDataFileScanHelper.ScanProvider.Transitions[i];
                if (transition.Source != _msDataFileScanHelper.Source)
                {
                    continue;
                }
                var label = new TextObj(transition.Name, transition.ProductMz, 0.02, CoordType.XScaleYChartFraction, AlignH.Center, AlignV.Top)
                {
                    ZOrder = ZOrder.D_BehindAxis,
                    IsClippedToChartRect = true,
                    Tag = i
                };
                label.FontSpec.Border.IsVisible = false;
                label.FontSpec.FontColor        = Blend(transition.Color, Color.Black, 0.30);
                label.FontSpec.IsBold           = true;
                label.FontSpec.Fill             = new Fill(Color.FromArgb(180, Color.White));
                GraphPane.GraphObjList.Add(label);
            }

            double retentionTime = _msDataFileScanHelper.MsDataSpectra[0].RetentionTime ?? _msDataFileScanHelper.ScanProvider.Times[_msDataFileScanHelper.ScanIndex];

            GraphPane.Title.Text = string.Format(Resources.GraphFullScan_CreateGraph__0_____1_F2__min_, _msDataFileScanHelper.FileName, retentionTime);

            FireSelectedScanChanged(retentionTime);
        }
Exemple #41
0
        private void CreateGraph_Two(ZedGraphControl zgc)
        {
            // get a reference to the GraphPane
            GraphPane myPane = zgc.GraphPane;


            // Make up some data arrays based on the Sine function
            double        x, y1, y2;
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();

            for (int i = 0; i < 36; i++)
            {
                x  = (double)i + 5;
                y1 = 1.5 + Math.Sin((double)i * 0.2);
                y2 = 3.0 * (1.5 + Math.Sin((double)i * 0.2));
                list1.Add(x, y1);
                list2.Add(x, y2);
            }

            // Generate a red curve with diamond
            // symbols, and "Porsche" in the legend
            LineItem myCurve = myPane.AddCurve("曲线1", list1, Color.Red, SymbolType.Diamond);

            // Generate a blue curve with circle
            // symbols, and "Piper" in the legend
            LineItem myCurve2 = myPane.AddCurve("曲线2", list2, Color.Blue, SymbolType.Circle);

            // Tell ZedGraph to refigure the
            // axes since the data have changed

            try
            {
                // Change the color of the title
                myPane.Title.FontSpec.FontColor = Color.Green;

                // Add gridlines to the plot, and make them gray
                myPane.XAxis.MajorGrid.IsVisible = true;
                myPane.YAxis.MajorGrid.IsVisible = true;
                myPane.XAxis.MajorGrid.Color     = Color.LightGray;
                myPane.YAxis.MajorGrid.Color     = Color.LightGray;

                // Move the legend location
                myPane.Legend.Position = ZedGraph.LegendPos.Bottom;

                // Make both curves thicker
                myCurve.Line.Width  = 2.0F;
                myCurve2.Line.Width = 2.0F;

                // Fill the area under the curves
                myCurve.Line.Fill  = new Fill(Color.White, Color.Red, 45F);
                myCurve2.Line.Fill = new Fill(Color.White, Color.Blue, 45F);

                // Increase the symbol sizes, and fill them with solid white
                myCurve.Symbol.Size  = 8.0F;
                myCurve2.Symbol.Size = 8.0F;
                myCurve.Symbol.Fill  = new Fill(Color.White);
                myCurve2.Symbol.Fill = new Fill(Color.White);

                // Add a background gradient fill to the axis frame
                myPane.Chart.Fill = new Fill(Color.White,
                                             Color.FromArgb(255, 255, 210), -45F);

                // Add a caption and an arrow
                TextObj myText = new TextObj("Interesting\nPoint", 230F, 70F);
                myText.FontSpec.FontColor = Color.Red;
                myText.Location.AlignH    = AlignH.Center;
                myText.Location.AlignV    = AlignV.Top;
                myPane.GraphObjList.Add(myText);
                ArrowObj myArrow = new ArrowObj(Color.Red, 12F, 230F, 70F, 280F, 55F);
                myPane.GraphObjList.Add(myArrow);//The final "dressed-up" graph will look like this:
            }
            catch { }

            zgc.AxisChange();
        }
Exemple #42
0
        public OverlayBarDemo() : base(
                "The BarType.Overlay 'stacks' the bars without actually summing up the values " +
                "(i.e., they are drawn on top of eachother)\n" +
                "The data must be sorted for this type of chart to be effective\n" +
                "You can also use BarType.Stack and BarType.SortedOverlay for similar effects",
                "Overlay Bar Chart",
                DemoType.Bar)
        {
            GraphPane myPane = base.GraphPane;

            // Set the title and axis label
            myPane.Title.Text       = "Overlay Bar Graph Demo";
            myPane.YAxis.Title.Text = "Value";

            // Enter some data values
            double[] y  = { 100, 115, 75, -22, 98, 40, -10 };
            double[] y2 = { 90, 100, 95, -35, 80, 35, 35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, 18 };

            // Manually sum up the curves
            for (int i = 0; i < y.GetLength(0); i++)
            {
                y2[i] += y[i];
            }
            for (int i = 0; i < y2.GetLength(0); i++)
            {
                y3[i] += y2[i];
            }


            // Generate a red bar with "Curve 1" in the legend
            CurveItem myCurve = myPane.AddBar("Curve 1", null, y, Color.Red);

            // Generate a blue bar with "Curve 2" in the legend
            myCurve = myPane.AddBar("Curve 2", null, y2, Color.Blue);

            // Generate a green bar with "Curve 3" in the legend
            myCurve = myPane.AddBar("Curve 3", null, y3, Color.Green);

            // Draw the X tics between the labels instead of at the labels
            myPane.XAxis.MajorTic.IsBetweenLabels = true;

            // Set the XAxis to the ordinal type
            myPane.XAxis.Type = AxisType.Ordinal;

            //Add Labels to the curves

            // Shift the text items up by 5 user scale units above the bars
            const float shift = 5;

            for (int i = 0; i < y.Length; i++)
            {
                // format the label string to have 1 decimal place
                string lab = y3[i].ToString("F1");
                // create the text item (assumes the x axis is ordinal or text)
                // for negative bars, the label appears just above the zero value
                TextObj text = new TextObj(lab, (float)(i + 1), (float)(y3[i] < 0 ? 0.0 : y3[i]) + shift);
                // tell Zedgraph to use user scale units for locating the TextObj
                text.Location.CoordinateFrame = CoordType.AxisXYScale;
                // AlignH the left-center of the text to the specified point
                text.Location.AlignH           = AlignH.Left;
                text.Location.AlignV           = AlignV.Center;
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible   = false;
                // rotate the text 90 degrees
                text.FontSpec.Angle = 90;
                // add the TextObj to the list
                myPane.GraphObjList.Add(text);
            }

            // Indicate that the bars are overlay type, which are drawn on top of eachother
            myPane.BarSettings.Type = BarType.Overlay;

            // Fill the axis background with a color gradientC:\Documents and Settings\champioj\Desktop\ZedGraph-4.9-CVS\demo\ZedGraph.Demo\StepChartDemo.cs
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0F);

            base.ZedGraphControl.AxisChange();

            // Add one step to the max scale value to leave room for the labels
            myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep;
        }
Exemple #43
0
        /// <summary>
        /// 图形描绘
        /// </summary>
        public override void DrawGraph()
        {
            #region 图形所需数据
            //线条数组[线条数] [每条线的刻度值]
            double[][] lines;
            //X轴刻度
            double[] xAixsScale;
            //线条标注
            string[] labels;
            //X轴刻度标注
            string[] xAxisScaleLabels;

            if (base.XAxisScaleRefrence == DataTableStruct.Rows)
            {
                xAixsScale       = new double[base.DataSource.Rows.Count];
                xAxisScaleLabels = new string[base.DataSource.Rows.Count];
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    xAixsScale[i]       = i;
                    xAxisScaleLabels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                }
                //要绘制的线条数为数据列数
                lines = new double[base.ShowValueColumns.Length][];
                //线条标注
                labels = new string[lines.Length];
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    labels[i] = base.ShowValueColumns[i].ColumnName;
                }


                //填充每条线的数据值
                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = new double[xAixsScale.Length];
                    for (int j = 0; j < base.DataSource.Rows.Count; j++)
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]))
                        {
                            lines[i][j] = 0;
                        }
                        else
                        {
                            lines[i][j] = Convert.ToDouble(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]);
                        }
                    }
                }
            }
            else
            {
                xAixsScale       = new double[base.ShowValueColumns.Length];
                xAxisScaleLabels = new string[base.ShowValueColumns.Length];
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    xAixsScale[i]       = i;
                    xAxisScaleLabels[i] = base.ShowValueColumns[i].ColumnName;
                }
                //要绘制的线条数为数据集的纪录数
                lines = new double[base.DataSource.Rows.Count][];
                //线条标注
                labels = new string[lines.Length];
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    labels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                }
                //填充每条线的数据值
                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = new double[xAixsScale.Length];
                    for (int j = 0; j < base.ShowValueColumns.Length; j++)
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]))
                        {
                            lines[i][j] = 0;
                        }
                        else
                        {
                            lines[i][j] = Convert.ToDouble(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]);
                        }
                    }
                }
            }

            int maxXaisxScale = xAixsScale.Length;

            //Console.Beep();

            #endregion

            #region 显示图形
            base.GraphContainer.Controls.Clear();

            ZedGraph.ZedGraphControl grphTx = new ZedGraph.ZedGraphControl();

            grphTx.IsEnableHZoom     = false;
            grphTx.IsEnableVZoom     = false;
            grphTx.IsEnableWheelZoom = false;
            grphTx.Dock = System.Windows.Forms.DockStyle.Fill;


            ZedGraph.GraphPane myPane = grphTx.GraphPane;
            myPane.Title.Text       = base.GraphTitle;
            myPane.XAxis.Title.Text = base.XAxisTitle;
            myPane.YAxis.Title.Text = base.YAxisTitle;

            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);
            //线条显示
            for (int i = 0; i < lines.Length; i++)
            {
                Color color;
                if (base.Colors == null)
                {
                    color = GetColor();
                }
                else
                {
                    color = base.Colors[i];
                }

                ZedGraph.LineItem myCurve = myPane.AddCurve(labels[i], xAixsScale, lines[i], color);

                myCurve.Symbol.Fill = new Fill(Color.White);
            }

            //X轴属性
            myPane.XAxis.Scale.Min            = 0;                //X轴刻度起始值
            myPane.XAxis.Scale.Max            = maxXaisxScale;    //X轴刻度最大值
            myPane.XAxis.Scale.TextLabels     = xAxisScaleLabels; //x轴刻度中文标注
            myPane.XAxis.Type                 = AxisType.Text;    //类型
            myPane.XAxis.Scale.FontSpec.Angle = 90;               //文字方向
            myPane.XAxis.Scale.FontSpec.Size = 11F;               //文字大小

            // Display the Y axis grid lines
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;


            BoxObj box = new BoxObj(0, 100, 1, 30, Color.Empty,
                                    Color.FromArgb(150, Color.LightGreen));
            box.Fill = new Fill(Color.White, Color.FromArgb(200, Color.LightGreen), 45.0F);

            box.ZOrder = ZOrder.E_BehindCurves;

            box.IsClippedToChartRect = true;

            box.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            myPane.GraphObjList.Add(box);

            TextObj text = new TextObj("", 0.95f, 85, CoordType.AxisXYScale,
                                       AlignH.Right, AlignV.Center);
            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.IsBold           = true;
            text.FontSpec.IsItalic         = true;
            text.Location.CoordinateFrame  = CoordType.XChartFractionYScale;
            text.IsClippedToChartRect      = true;

            myPane.GraphObjList.Add(text);

            myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);

            grphTx.AxisChange();

            base.GraphContainer.Controls.Add(grphTx);
            #endregion
        }
Exemple #44
0
        private void drawLabels(Graphics g)
        {
            foreach (GraphObj pa in _pointAnnotations)
            {
                GraphObjList.Remove(pa);
            }
            _pointAnnotations.Clear();
            _manualLabels.Clear();

            Axis xAxis = XAxis;
            Axis yAxis = YAxis;

            yAxis.Scale.MinAuto = false;
            if (LockYAxisMinAtZero)
            {
                yAxis.Scale.Min = 0;
            }
            if (LockYAxisMaxAtZero)
            {
                yAxis.Scale.Max = 0;
            }


            // ensure that the chart rectangle is the right size
            AxisChange(g);
            // then setup axes scales to enable the Transform method
            xAxis.Scale.SetupScaleData(this, xAxis);
            yAxis.Scale.SetupScaleData(this, yAxis);

            if (Chart.Rect.Width < 1 || Chart.Rect.Height < 1)
            {
                return;
            }

            _overlapDetector = AllowLabelOverlap ? null : new OverlapDetector();
            Region chartRegion = new Region(Chart.Rect);
            Region clipRegion  = new Region();

            clipRegion.MakeEmpty();
            var previousClip = g.Clip.Clone();

            g.SetClip(Rect, CombineMode.Replace);
            g.SetClip(chartRegion, CombineMode.Exclude);

            /*Bitmap clipBmp = new Bitmap(Convert.ToInt32(Chart.Rect.Width), Convert.ToInt32(Chart.Rect.Height));
             * Graphics clipG = Graphics.FromImage(clipBmp);
             * clipG.Clear(Color.White);
             * clipG.FillRegion(new SolidBrush(Color.Black), g.Clip);
             * clipBmp.Save("C:\\clip.bmp");*/


            // some dummy labels for very fast clipping
            string baseLabel = @"0";

            foreach (CurveItem item in CurveList)
            {
                IMSGraphItemInfo info = item.Tag as IMSGraphItemInfo;
                if (info != null)
                {
                    PointAnnotation annotation = info.AnnotatePoint(new PointPair(0, 0));
                    if (annotation != null &&
                        annotation.Label != null &&
                        annotation.Label.Length > baseLabel.Length)
                    {
                        baseLabel = annotation.Label;
                    }
                }
            }

            TextObj baseTextObj = new TextObj(baseLabel, 0, 0);

            baseTextObj.FontSpec.Border.IsVisible = false;
            baseTextObj.FontSpec.Fill.IsVisible   = false;
            PointF[] pts = baseTextObj.FontSpec.GetBox(g, baseLabel, 0, 0,
                                                       AlignH.Center, AlignV.Bottom, 1.0f, new SizeF());
            float baseLabelWidth  = pts[1].X - pts[0].X;
            float baseLabelHeight = pts[2].Y - pts[0].Y;

            baseLabelWidth  = (float)xAxis.Scale.ReverseTransform(xAxis.Scale.Transform(0) + baseLabelWidth);
            baseLabelHeight = (float)yAxis.Scale.ReverseTransform(yAxis.Scale.Transform(0) - baseLabelHeight);
            float labelLengthToWidthRatio = baseLabelWidth / baseLabel.Length;

            float xAxisPixel = yAxis.Scale.Transform(0);

            double xMin = xAxis.Scale.Min;
            double xMax = xAxis.Scale.Max;
            double yMin = yAxis.Scale.Min;
            double yMax = yAxis.Scale.Max;

            // add manual annotations with TextObj priority over curve annotations
            foreach (CurveItem item in CurveList)
            {
                var         info   = item.Tag as IMSGraphItemExtended;
                MSPointList points = item.Points as MSPointList;
                if (info == null || points == null)
                {
                    continue;
                }

                info.AddPreCurveAnnotations(this, g, points, _pointAnnotations);
                AddAnnotations(g);
            }

            // add automatic labels for MSGraphItems
            foreach (CurveItem item in CurveList)
            {
                IMSGraphItemInfo info   = item.Tag as IMSGraphItemInfo;
                MSPointList      points = item.Points as MSPointList;
                if (info == null || points == null)
                {
                    continue;
                }

                if (info.ToString().Length == 0)
                {
                    continue;
                }

                PointPairList fullList               = points.FullList;
                List <int>    maxIndexList           = points.ScaledMaxIndexList;
                var           annotationsPrioritized = new Dictionary <PointAnnotation, int>();
                for (int i = 0; i < maxIndexList.Count; ++i)
                {
                    if (maxIndexList[i] < 0)
                    {
                        continue;
                    }
                    PointPair pt = fullList[maxIndexList[i]];

                    if (pt.X < xMin || pt.Y > yMax || pt.Y < yMin)
                    {
                        continue;
                    }
                    if (pt.X > xMax)
                    {
                        break;
                    }

                    float yPixel = yAxis.Scale.Transform(pt.Y);

                    // labelled points must be at least 3 pixels off the X axis
                    if (Math.Abs(xAxisPixel - yPixel) < 3)
                    {
                        continue;
                    }

                    PointAnnotation annotation = info.AnnotatePoint(pt);
                    if (annotation != null)
                    {
                        annotationsPrioritized.Add(annotation, i);
                    }
                }

                // Give the higher ranked point priority
                foreach (var annotation in annotationsPrioritized.Keys.OrderBy(a => a.ZOrder ?? int.MaxValue))
                {
                    if (annotation.ExtraAnnotation != null)
                    {
                        GraphObjList.Add(annotation.ExtraAnnotation);
                        _pointAnnotations.Add(annotation.ExtraAnnotation);
                    }

                    if (string.IsNullOrEmpty(annotation.Label))
                    {
                        continue;
                    }

                    float pointLabelWidth = labelLengthToWidthRatio * annotation.Label.Split('\n').Max(o => o.Length);

                    var       i      = annotationsPrioritized[annotation];
                    PointPair pt     = fullList[maxIndexList[i]];
                    float     yPixel = yAxis.Scale.Transform(pt.Y);
                    var       shift  = pt.Y < 0 ? 5 : -5;
                    double    labelY = yAxis.Scale.ReverseTransform(yPixel + shift);

                    if (!AllowCurveOverlap)
                    {
                        // do fast check for overlap against all MSGraphItems
                        bool overlap = false;
                        foreach (CurveItem item2 in CurveList)
                        {
                            MSPointList points2 = item2.Points as MSPointList;
                            if (points2 != null)
                            {
                                int nearestMaxIndex = points2.GetNearestMaxIndexToBin(i);
                                if (nearestMaxIndex < 0)
                                {
                                    continue;
                                }
                                RectangleF r = new RectangleF((float)pt.X - pointLabelWidth / 2,
                                                              (float)labelY - baseLabelHeight,
                                                              pointLabelWidth,
                                                              baseLabelHeight);
                                overlap = detectLabelCurveOverlap(this, points2.FullList, nearestMaxIndex, item2 is StickItem, r);
                                if (overlap)
                                {
                                    break;
                                }
                            }
                        }

                        if (overlap)
                        {
                            continue;
                        }
                    }

                    TextObj text = new TextObj(annotation.Label, pt.X, labelY,
                                               CoordType.AxisXYScale, AlignH.Center, pt.Y < 0 ? AlignV.Top : AlignV.Bottom)
                    {
                        ZOrder               = ZOrder.A_InFront,
                        FontSpec             = annotation.FontSpec,
                        IsClippedToChartRect = true
                    };

                    var  textRect = _labelBoundsCache.GetLabelBounds(text, this, g);
                    bool overlap2 = _overlapDetector != null && _overlapDetector.Overlaps(textRect);
                    _manualLabels[text] = textRect;
                    if (!overlap2)
                    {
                        _pointAnnotations.Add(text);
                        AddAnnotations(g);
                    }
                }
            }

            // add manual annotations
            foreach (CurveItem item in CurveList)
            {
                IMSGraphItemInfo info   = item.Tag as IMSGraphItemInfo;
                MSPointList      points = item.Points as MSPointList;
                if (info == null || points == null)
                {
                    continue;
                }

                info.AddAnnotations(this, g, points, _pointAnnotations);
                AddAnnotations(g);
            }

            autoScaleForManualLabels(g);
            g.Clip = previousClip;
        }
Exemple #45
0
        private void PopulateGraph(int rowIndex)
        {
            var myPane = new GraphPane();

            myPane = zedGraphControl1.GraphPane;

            myPane.CurveList.Clear();
            myPane.GraphObjList.Clear();
            myPane.Fill = new Fill();

            //legend
            myPane.Legend.Position         = LegendPos.Bottom;
            myPane.Legend.FontSpec.Size    = 20;
            myPane.Legend.Border.IsVisible = false;

            myPane.Title.Text       = "Efficiency Per Hour";
            myPane.BarSettings.Type = BarType.Stack;

            //x axis
            myPane.XAxis.Title.Text            = "Hours";
            myPane.XAxis.Title.FontSpec.Size   = 20;
            myPane.XAxis.Title.FontSpec.IsBold = false;
            myPane.XAxis.Scale.MajorStep       = 1;
            myPane.XAxis.MinorTic.Size         = 0;
            myPane.XAxis.Scale.Min             = startpC - 0.5;
            myPane.XAxis.Scale.Max             = endpC + 0.5;
            myPane.XAxis.MajorTic.IsInside     = false;
            myPane.XAxis.MajorTic.IsOutside    = true;

            //y axis
            myPane.YAxis.Title.Text            = "Amount (%)";
            myPane.YAxis.Title.FontSpec.Size   = 20;
            myPane.YAxis.Title.FontSpec.IsBold = false;
            myPane.YAxis.Scale.MajorStep       = 10;
            myPane.YAxis.MinorTic.Size         = 0;
            zedGraphControl1.IsEnableZoom      = false;
            zedGraphControl1.IsShowContextMenu = false;

            var lstEff    = new PointPairList();
            var yAxisVals = new List <int>();

            var i = 6;

            for (var c = 9; c <= dgvEfficiency.Columns.Count - 1; c += 1)
            {
                var value = dgvEfficiency.Rows[rowIndex].Cells[c].Value.ToString();

                if (string.IsNullOrEmpty(value))
                {
                    i += 1;
                    continue;
                }

                value = value.Substring(0, value.Length - 1);
                int.TryParse(value, out var val);

                int zAxisValue = 0;

                if (val > 90)
                {
                    zAxisValue = 200;
                }
                if (val <= 90 && val >= 70)
                {
                    zAxisValue = 80;
                }
                if (val < 70)
                {
                    zAxisValue = -150;
                }

                yAxisVals.Add(val);
                lstEff.Add(i, val, zAxisValue);

                i += 1;
            }

            if (yAxisVals.Count <= 0)
            {
                myPane.YAxis.Scale.Max = 3;
            }
            else
            {
                myPane.YAxis.Scale.Max = yAxisVals.Max() + 35;
            }

            BarItem barItem = myPane.AddBar(string.Empty, lstEff, Color.AliceBlue);

            Color [] colors = new Color[] { Color.FromArgb(235, 105, 112),
                                            Color.FromArgb(255, 255, 70),
                                            Color.FromArgb(125, 255, 121) };

            barItem.Bar.Fill          = new Fill(colors);
            barItem.Bar.Fill.RangeMax = 90;
            barItem.Bar.Fill.RangeMin = 70;
            barItem.Bar.Fill.Type     = FillType.GradientByZ;
            //barItem.Bar.Fill.SecondaryValueGradientColor = Color.Empty;
            foreach (var bar in lstEff)
            {
                string key = dgvEfficiency.Rows[rowIndex].Cells[3].Value.ToString() + "_" +
                             dgvEfficiency.Rows[rowIndex].Cells[4].Value.ToString();

                if (string.IsNullOrEmpty(key) || !_totalPieces.ContainsKey(key) || bar.Y == 0)
                {
                    continue;
                }

                var     numOfPieces = _totalPieces[key];
                TextObj barLabel    = new TextObj(numOfPieces.ToString(), bar.X, bar.Y + 10);
                barLabel.FontSpec.Size             = 20;
                barLabel.FontSpec.Border.IsVisible = false;
                myPane.GraphObjList.Add(barLabel);
            }

            myPane.Fill = new Fill(Color.FromArgb(250, 250, 255));
            zedGraphControl1.AxisChange();
            zedGraphControl1.Refresh();
        }
Exemple #46
0
        /// <summary>
        /// We know which labels are overlapping the data points, but we need to make sure the labels that will be
        /// displayed can fit in the scale using the Min/MaxGrace properties and adjusting the label fractions if appropriate:
        /// TextObjs with CoordType.AxisXYScale coordinates will move proportionally with Min/MaxGrace, but ChartFraction
        /// coordinates will not.
        /// </summary>
        protected void autoScaleForManualLabels(Graphics g)
        {
            Axis yAxis   = YAxis;
            bool maxAuto = yAxis.Scale.MaxAuto;

            try
            {
                if (maxAuto)
                {
                    AxisChange(g);
                }

                double yMaxRequired = 0;
                foreach (var kvp in _manualLabels)
                {
                    TextObj text = kvp.Key;
                    if (text.Location.X < XAxis.Scale.Min || text.Location.X > XAxis.Scale.Max)
                    {
                        continue;
                    }

                    if (!YAxis.Scale.IsLog && !IsYChartFractionObject(text))
                    {
                        double axisHeight = YAxis.Scale.Max - YAxis.Scale.Min;

                        PointF[] pts = text.FontSpec.GetBox(g, text.Text, 0, 0, text.Location.AlignH, text.Location.AlignV, 1.0f,
                                                            new SizeF());
                        float pixelShift = 0;
                        var   rectPeak   = _labelBoundsCache.GetLabelBounds(text, this, g);
                        foreach (var id in _manualLabels.Keys.Where(IsYChartFractionObject))
                        {
                            var rectID = _labelBoundsCache.GetLabelBounds(id, this, g);

                            // If the rectangles overlap
                            if (Math.Min(rectID.Right, rectPeak.Right) - Math.Max(rectID.Left, rectPeak.Left) > 0 &&
                                Math.Min(rectID.Bottom, rectPeak.Bottom) - Math.Max(rectID.Top, rectPeak.Top) > 0)
                            {
                                pixelShift = Math.Max(rectID.Height + 7, pixelShift);   // 7 pixel gap between labels
                            }
                        }
                        double y2Pos       = yAxis.Scale.ReverseTransform(pts[2].Y);
                        double labelHeight =
                            Math.Abs(yAxis.Scale.ReverseTransform(pts[0].Y - pixelShift) - y2Pos);
                        // If separating the labels takes too much space, just revert to showing them aligned
                        if (labelHeight >= axisHeight / 2)
                        {
                            labelHeight = Math.Abs(yAxis.Scale.ReverseTransform(pts[0].Y) - y2Pos);
                        }

                        if (labelHeight < axisHeight / 2)
                        {
                            // Ensure that the YAxis will have enough space to show the label.
                            // Only do this if the labelHeight is going to take up less than half the space on the graph, because
                            // otherwise the graph will be shrunk too much to have any useful information.

                            // When calculating the scaling required, take into account that the height of the label
                            // itself will not shrink when we shrink the YAxis.
                            var labelYMaxRequired = (text.Location.Y - labelHeight * YAxis.Scale.Min / axisHeight) /
                                                    (1 - labelHeight / axisHeight);
                            yMaxRequired = Math.Max(yMaxRequired, labelYMaxRequired);
                        }
                    }

                    if (!GraphObjList.Any(
                            o =>
                            (o is TextObj) && ((TextObj)o).Location == text.Location &&
                            ((TextObj)o).Text == text.Text))
                    {
                        if (_pointAnnotations.Contains(text))
                        {
                            GraphObjList.Add(text);
                        }
                    }
                }

                if (maxAuto && yMaxRequired > 0)
                {
                    yAxis.Scale.Max = Math.Max(yAxis.Scale.Max, yMaxRequired);
                }
            }
            finally
            {
                // Reset the value of MaxAuto since it may have been changed to false when Scale.Max was changed.
                yAxis.Scale.MaxAuto = maxAuto;
            }
        }
Exemple #47
0
        private void DisplayCalibrationCurve()
        {
            Text = TabText = _originalFormTitle;
            CalibrationCurveOptions options = Settings.Default.CalibrationCurveOptions;

            zedGraphControl.GraphPane.YAxis.Type = options.LogYAxis ? AxisType.Log : AxisType.Linear;
            zedGraphControl.GraphPane.XAxis.Type = options.LogXAxis ? AxisType.Log : AxisType.Linear;
            bool logPlot = options.LogXAxis || options.LogYAxis;

            zedGraphControl.GraphPane.Legend.IsVisible = options.ShowLegend;
            _scatterPlots    = null;
            CalibrationCurve = null;
            FiguresOfMerit   = FiguresOfMerit.EMPTY;
            SrmDocument document = DocumentUiContainer.DocumentUI;

            if (!document.Settings.HasResults)
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_No_results_available;
                return;
            }
            PeptideDocNode      peptide;
            PeptideGroupDocNode peptideGroup;

            if (!TryGetSelectedPeptide(out peptideGroup, out peptide))
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings
                    .CalibrationForm_DisplayCalibrationCurve_Select_a_peptide_to_see_its_calibration_curve;
                return;
            }
            if (-1 == document.Children.IndexOf(peptideGroup))
            {
                zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_peptide_is_no_longer_part_of_the_Skyline_document_;
                return;
            }
            PeptideQuantifier peptideQuantifier = PeptideQuantifier.GetPeptideQuantifier(document, peptideGroup,
                                                                                         peptide);
            CalibrationCurveFitter curveFitter = new CalibrationCurveFitter(peptideQuantifier, document.Settings);

            Text = TabText = TextUtil.SpaceSeparate(_originalFormTitle + ':', peptideQuantifier.PeptideDocNode.ModifiedSequenceDisplay);
            if (curveFitter.IsotopologResponseCurve && Settings.Default.CalibrationCurveOptions.SingleReplicate)
            {
                curveFitter.IsotopologReplicateIndex = _skylineWindow.SelectedResultsIndex;
            }
            if (peptideQuantifier.QuantificationSettings.RegressionFit == RegressionFit.NONE)
            {
                if (!(peptideQuantifier.NormalizationMethod is NormalizationMethod.RatioToLabel))
                {
                    zedGraphControl.GraphPane.Title.Text =
                        QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_Use_the_Quantification_tab_on_the_Peptide_Settings_dialog_to_control_the_conversion_of_peak_areas_to_concentrations_;
                }
                else
                {
                    if (!peptide.InternalStandardConcentration.HasValue)
                    {
                        zedGraphControl.GraphPane.Title.Text =
                            string.Format(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_convert_peak_area_ratios_to_concentrations__specify_the_internal_standard_concentration_for__0__, peptide);
                    }
                    else
                    {
                        zedGraphControl.GraphPane.Title.Text = null;
                    }
                }
            }
            else
            {
                if (curveFitter.GetStandardConcentrations().Any())
                {
                    zedGraphControl.GraphPane.Title.Text = null;
                }
                else
                {
                    zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_fit_a_calibration_curve__set_the_Sample_Type_of_some_replicates_to_Standard__and_specify_their_concentration_;
                }
            }

            zedGraphControl.GraphPane.XAxis.Title.Text = curveFitter.GetXAxisTitle();
            zedGraphControl.GraphPane.YAxis.Title.Text = curveFitter.GetYAxisTitle();
            CalibrationCurve = curveFitter.GetCalibrationCurve();
            FiguresOfMerit   = curveFitter.GetFiguresOfMerit(CalibrationCurve);
            double minX = double.MaxValue, maxX = double.MinValue;
            double minY = double.MaxValue;

            _scatterPlots = new CurveList();

            var sampleTypes = curveFitter.IsotopologResponseCurve
                ? new[] { SampleType.STANDARD }
                : SampleType.ListSampleTypes().Where(Options.DisplaySampleType);

            foreach (var sampleType in sampleTypes)
            {
                PointPairList pointPairList         = new PointPairList();
                PointPairList pointPairListExcluded = new PointPairList();
                foreach (var standardIdentifier in curveFitter.EnumerateCalibrationPoints())
                {
                    if (null == standardIdentifier.LabelType)
                    {
                        ChromatogramSet chromatogramSet = document.Settings.MeasuredResults.Chromatograms[standardIdentifier.ReplicateIndex];
                        if (!Equals(sampleType, chromatogramSet.SampleType))
                        {
                            continue;
                        }
                    }
                    double?y           = curveFitter.GetYValue(standardIdentifier);
                    double?xCalculated = curveFitter.GetCalculatedXValue(CalibrationCurve, standardIdentifier);
                    double?x           = curveFitter.GetSpecifiedXValue(standardIdentifier)
                                         ?? xCalculated;
                    if (y.HasValue && x.HasValue)
                    {
                        PointPair point = new PointPair(x.Value, y.Value)
                        {
                            Tag = standardIdentifier
                        };
                        if (sampleType.AllowExclude && null == standardIdentifier.LabelType && peptide.IsExcludeFromCalibration(standardIdentifier.ReplicateIndex))
                        {
                            pointPairListExcluded.Add(point);
                        }
                        else
                        {
                            pointPairList.Add(point);
                        }
                        if (!IsNumber(x) || !IsNumber(y))
                        {
                            continue;
                        }
                        if (!logPlot || x.Value > 0)
                        {
                            minX = Math.Min(minX, x.Value);
                        }
                        if (!logPlot || y.Value > 0)
                        {
                            minY = Math.Min(minY, y.Value);
                        }
                        maxX = Math.Max(maxX, x.Value);
                        if (IsNumber(xCalculated))
                        {
                            maxX = Math.Max(maxX, xCalculated.Value);
                            if (!logPlot || xCalculated.Value > 0)
                            {
                                minX = Math.Min(minX, xCalculated.Value);
                            }
                        }
                    }
                }
                if (pointPairList.Any())
                {
                    var lineItem = zedGraphControl.GraphPane.AddCurve(sampleType.ToString(), pointPairList,
                                                                      sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    lineItem.Symbol.Fill    = new Fill(sampleType.Color);
                    _scatterPlots.Add(lineItem);
                }
                if (pointPairListExcluded.Any())
                {
                    string curveLabel = pointPairList.Any() ? null : sampleType.ToString();
                    var    lineItem   = zedGraphControl.GraphPane.AddCurve(curveLabel, pointPairListExcluded,
                                                                           sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    _scatterPlots.Add(lineItem);
                }
            }
            List <string> labelLines    = new List <String>();
            RegressionFit regressionFit = document.Settings.PeptideSettings.Quantification.RegressionFit;

            if (regressionFit != RegressionFit.NONE)
            {
                if (minX <= maxX)
                {
                    int interpolatedLinePointCount = 100;
                    if (!logPlot && regressionFit != RegressionFit.LINEAR_IN_LOG_SPACE)
                    {
                        if (regressionFit == RegressionFit.LINEAR_THROUGH_ZERO)
                        {
                            minX = Math.Min(0, minX);
                        }
                        if (regressionFit != RegressionFit.QUADRATIC)
                        {
                            interpolatedLinePointCount = 2;
                        }
                    }
                    double[] xValues;
                    if (CalibrationCurve.TurningPoint.HasValue)
                    {
                        xValues = new[] { minX, CalibrationCurve.TurningPoint.Value, maxX };
                    }
                    else
                    {
                        xValues = new[] { minX, maxX };
                    }
                    Array.Sort(xValues);
                    LineItem interpolatedLine = CreateInterpolatedLine(CalibrationCurve, xValues,
                                                                       interpolatedLinePointCount, logPlot);
                    if (null != interpolatedLine)
                    {
                        zedGraphControl.GraphPane.CurveList.Add(interpolatedLine);
                    }
                }
                labelLines.Add(CalibrationCurve.ToString());

                if (CalibrationCurve.RSquared.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_ +
                                   CalibrationCurve.RSquared.Value.ToString("0.####")); // Not L10N
                }
                if (!Equals(curveFitter.QuantificationSettings.RegressionWeighting, RegressionWeighting.NONE))
                {
                    labelLines.Add(string.Format("{0}: {1}", // Not L10N
                                                 QuantificationStrings.Weighting, curveFitter.QuantificationSettings.RegressionWeighting));
                }
                if (options.ShowFiguresOfMerit)
                {
                    string strFiguresOfMerit = FiguresOfMerit.ToString();
                    if (!string.IsNullOrEmpty(strFiguresOfMerit))
                    {
                        labelLines.Add(strFiguresOfMerit);
                    }
                }
            }

            CalibrationPoint?selectionIdentifier = null;

            if (options.ShowSelection)
            {
                if (curveFitter.IsotopologResponseCurve)
                {
                    var labelType = (_skylineWindow.SequenceTree.SelectedNode as SrmTreeNode)
                                    ?.GetNodeOfType <TransitionGroupTreeNode>()?.DocNode.LabelType;
                    if (labelType != null)
                    {
                        selectionIdentifier =
                            new CalibrationPoint(_skylineWindow.SelectedResultsIndex,
                                                 labelType);
                    }
                }
                else
                {
                    selectionIdentifier =
                        new CalibrationPoint(_skylineWindow.SelectedResultsIndex, null);
                }
            }
            if (selectionIdentifier.HasValue)
            {
                double?ySelected = curveFitter.GetYValue(selectionIdentifier.Value);
                if (IsNumber(ySelected))
                {
                    double?     xSelected         = curveFitter.GetCalculatedXValue(CalibrationCurve, selectionIdentifier.Value);
                    var         selectedLineColor = Color.FromArgb(128, GraphSummary.ColorSelected);
                    const float selectedLineWidth = 2;
                    double?     xSpecified        = curveFitter.GetSpecifiedXValue(selectionIdentifier.Value);
                    if (IsNumber(xSelected))
                    {
                        ArrowObj arrow = new ArrowObj(xSelected.Value, ySelected.Value, xSelected.Value,
                                                      ySelected.Value)
                        {
                            Line = { Color = GraphSummary.ColorSelected }
                        };
                        zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
                        var verticalLine = new LineObj(xSelected.Value, ySelected.Value, xSelected.Value,
                                                       options.LogYAxis ? double.MinValue : 0)
                        {
                            Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                            Location             = { CoordinateFrame = CoordType.AxisXYScale },
                            ZOrder               = ZOrder.E_BehindCurves,
                            IsClippedToChartRect = true
                        };
                        zedGraphControl.GraphPane.GraphObjList.Add(verticalLine);
                        if (IsNumber(xSpecified))
                        {
                            var horizontalLine = new LineObj(xSpecified.Value, ySelected.Value, xSelected.Value,
                                                             ySelected.Value)
                            {
                                Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                                Location             = { CoordinateFrame = CoordType.AxisXYScale },
                                ZOrder               = ZOrder.E_BehindCurves,
                                IsClippedToChartRect = true
                            };
                            zedGraphControl.GraphPane.GraphObjList.Add(horizontalLine);
                        }
                    }
                    else
                    {
                        // We were not able to map the observed intensity back to the calibration curve, but we still want to
                        // indicate where the currently selected point is.
                        if (IsNumber(xSpecified))
                        {
                            // If the point has a specified concentration, then use that.
                            ArrowObj arrow = new ArrowObj(xSpecified.Value, ySelected.Value, xSpecified.Value,
                                                          ySelected.Value)
                            {
                                Line = { Color = GraphSummary.ColorSelected }
                            };
                            zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
                        }
                        else
                        {
                            // Otherwise, draw a horizontal line at the appropriate y-value.
                            var horizontalLine = new LineObj(minX, ySelected.Value, maxX, ySelected.Value)
                            {
                                Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                                Location             = { CoordinateFrame = CoordType.AxisXYScale },
                                IsClippedToChartRect = true,
                            };
                            ZedGraphControl.GraphPane.GraphObjList.Add(horizontalLine);
                        }
                    }
                }

                var quantificationResult = curveFitter.GetQuantificationResult(_skylineWindow.SelectedResultsIndex);
                if (quantificationResult.CalculatedConcentration.HasValue)
                {
                    labelLines.Add(string.Format("{0} = {1}", // Not L10N
                                                 QuantificationStrings.Calculated_Concentration, quantificationResult));
                }
                else if (!quantificationResult.NormalizedArea.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_replicate_has_missing_or_truncated_transitions);
                }
            }
            if (Options.ShowFiguresOfMerit)
            {
                if (IsNumber(FiguresOfMerit.LimitOfDetection))
                {
                    var lodLine = new LineObj(Color.DarkMagenta, FiguresOfMerit.LimitOfDetection.Value, 0,
                                              FiguresOfMerit.LimitOfDetection.Value, 1)
                    {
                        Location = { CoordinateFrame = CoordType.XScaleYChartFraction }
                    };
                    zedGraphControl.GraphPane.GraphObjList.Add(lodLine);
                }
                if (IsNumber(FiguresOfMerit.LimitOfQuantification))
                {
                    var loqLine = new LineObj(Color.DarkCyan, FiguresOfMerit.LimitOfQuantification.Value, 0,
                                              FiguresOfMerit.LimitOfQuantification.Value, 1)
                    {
                        Location = { CoordinateFrame = CoordType.XScaleYChartFraction }
                    };
                    zedGraphControl.GraphPane.GraphObjList.Add(loqLine);
                }
            }
            if (labelLines.Any())
            {
                TextObj text = new TextObj(TextUtil.LineSeparate(labelLines), .01, 0,
                                           CoordType.ChartFraction, AlignH.Left, AlignV.Top)
                {
                    IsClippedToChartRect = true,
                    ZOrder   = ZOrder.E_BehindCurves,
                    FontSpec = GraphSummary.CreateFontSpec(Color.Black),
                };
                zedGraphControl.GraphPane.GraphObjList.Add(text);
            }
        }
Exemple #48
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         this.LevelText.Dispose();
         this.LevelText = null;
         this.m_coinIcon.Dispose();
         this.m_coinIcon = null;
         base.Dispose();
     }
 }
Exemple #49
0
        public override void LoadContent()
        {
            m_title           = new SpriteObj("ProfileSelectTitle_Sprite");
            m_title.ForceDraw = true;
            var textObj = new TextObj(Game.JunicodeFont);

            textObj.Align        = Types.TextAlign.Centre;
            textObj.Text         = "- START NEW LEGACY - ";
            textObj.TextureColor = Color.White;
            textObj.OutlineWidth = 2;
            textObj.FontSize     = 10f;
            textObj.Position     = new Vector2(0f, -(textObj.Height / 2f));
            m_slot1Container     = new ObjContainer("ProfileSlotBG_Container");
            var obj = textObj.Clone() as TextObj;

            m_slot1Container.AddChild(obj);
            var spriteObj = new SpriteObj("ProfileSlot1Text_Sprite");

            spriteObj.Position = new Vector2(-130f, -35f);
            m_slot1Container.AddChild(spriteObj);
            var textObj2 = textObj.Clone() as TextObj;

            m_slot1Container.AddChild(textObj2);
            textObj2.Position = new Vector2(120f, 15f);
            var textObj3 = textObj.Clone() as TextObj;

            textObj3.Position = new Vector2(-120f, 15f);
            m_slot1Container.AddChild(textObj3);
            m_slot1Container.ForceDraw = true;
            m_slot2Container           = new ObjContainer("ProfileSlotBG_Container");
            var obj2 = textObj.Clone() as TextObj;

            m_slot2Container.AddChild(obj2);
            var spriteObj2 = new SpriteObj("ProfileSlot2Text_Sprite");

            spriteObj2.Position = new Vector2(-130f, -35f);
            m_slot2Container.AddChild(spriteObj2);
            var textObj4 = textObj.Clone() as TextObj;

            m_slot2Container.AddChild(textObj4);
            textObj4.Position = new Vector2(120f, 15f);
            var textObj5 = textObj.Clone() as TextObj;

            textObj5.Position = new Vector2(-120f, 15f);
            m_slot2Container.AddChild(textObj5);
            m_slot2Container.ForceDraw = true;
            m_slot3Container           = new ObjContainer("ProfileSlotBG_Container");
            var obj3 = textObj.Clone() as TextObj;

            m_slot3Container.AddChild(obj3);
            var spriteObj3 = new SpriteObj("ProfileSlot3Text_Sprite");

            spriteObj3.Position = new Vector2(-130f, -35f);
            m_slot3Container.AddChild(spriteObj3);
            var textObj6 = textObj.Clone() as TextObj;

            m_slot3Container.AddChild(textObj6);
            textObj6.Position = new Vector2(120f, 15f);
            var textObj7 = textObj.Clone() as TextObj;

            textObj7.Position = new Vector2(-120f, 15f);
            m_slot3Container.AddChild(textObj7);
            m_slot3Container.ForceDraw = true;
            m_slotArray.Add(m_slot1Container);
            m_slotArray.Add(m_slot2Container);
            m_slotArray.Add(m_slot3Container);
            m_confirmText                  = new KeyIconTextObj(Game.JunicodeFont);
            m_confirmText.Text             = "to select profile";
            m_confirmText.DropShadow       = new Vector2(2f, 2f);
            m_confirmText.FontSize         = 12f;
            m_confirmText.Align            = Types.TextAlign.Right;
            m_confirmText.Position         = new Vector2(1290f, 570f);
            m_confirmText.ForceDraw        = true;
            m_cancelText                   = new KeyIconTextObj(Game.JunicodeFont);
            m_cancelText.Text              = "to exit screen";
            m_cancelText.Align             = Types.TextAlign.Right;
            m_cancelText.DropShadow        = new Vector2(2f, 2f);
            m_cancelText.FontSize          = 12f;
            m_cancelText.Position          = new Vector2(m_confirmText.X, m_confirmText.Y + 40f);
            m_cancelText.ForceDraw         = true;
            m_navigationText               = new KeyIconTextObj(Game.JunicodeFont);
            m_navigationText.Text          = "to navigate profiles";
            m_navigationText.Align         = Types.TextAlign.Right;
            m_navigationText.DropShadow    = new Vector2(2f, 2f);
            m_navigationText.FontSize      = 12f;
            m_navigationText.Position      = new Vector2(m_confirmText.X, m_confirmText.Y + 80f);
            m_navigationText.ForceDraw     = true;
            m_deleteProfileText            = new KeyIconTextObj(Game.JunicodeFont);
            m_deleteProfileText.Text       = "to delete profile";
            m_deleteProfileText.Align      = Types.TextAlign.Left;
            m_deleteProfileText.DropShadow = new Vector2(2f, 2f);
            m_deleteProfileText.FontSize   = 12f;
            m_deleteProfileText.Position   = new Vector2(20f, m_confirmText.Y + 80f);
            m_deleteProfileText.ForceDraw  = true;
            base.LoadContent();
        }
Exemple #50
0
        public PieChartDemo() : base("A demo showing some pie chart features of ZedGraph",
                                     "Pie Chart Demo", DemoType.Pie)
        {
            GraphPane myPane = base.GraphPane;

            // Set the pane title
            myPane.Title.Text = "2004 ZedGraph Sales by Region\n ($M)";

            // Enter some data values
            double [] values       = { 15, 15, 40, 20 };
            double [] values2      = { 250, 50, 400, 50 };
            Color []  colors       = { Color.Red, Color.Blue, Color.Green, Color.Yellow };
            double [] displacement = { .0, .0, .0, .0 };
            string [] labels       = { "Europe", "Pac Rim", "South America", "Africa" };

            // Fill the pane and axis background with solid color
            myPane.Fill            = new Fill(Color.Cornsilk);
            myPane.Chart.Fill      = new Fill(Color.Cornsilk);
            myPane.Legend.Position = LegendPos.Right;

            // Create some pie slices
            PieItem segment1 = myPane.AddPieSlice(20, Color.Navy, .20, "North");
            PieItem segment2 = myPane.AddPieSlice(40, Color.Salmon, 0, "South");
            PieItem segment3 = myPane.AddPieSlice(30, Color.Yellow, .0, "East");
            PieItem segment4 = myPane.AddPieSlice(10.21, Color.LimeGreen, 0, "West");
            PieItem segment5 = myPane.AddPieSlice(10.5, Color.Aquamarine, .3, "Canada");

            // Add some more slices as an array
            PieItem [] slices = new PieItem[values2.Length];
            slices = myPane.AddPieSlices(values2, labels);

            // Modify the slice label types
            ((PieItem)slices[0]).LabelType    = PieLabelType.Name_Value;
            ((PieItem)slices[1]).LabelType    = PieLabelType.Name_Value_Percent;
            ((PieItem)slices[2]).LabelType    = PieLabelType.Name_Value;
            ((PieItem)slices[3]).LabelType    = PieLabelType.Name_Value;
            ((PieItem)slices[1]).Displacement = .2;
            segment1.LabelType = PieLabelType.Name_Percent;
            segment2.LabelType = PieLabelType.Name_Value;
            segment3.LabelType = PieLabelType.Percent;
            segment4.LabelType = PieLabelType.Value;
            segment5.LabelType = PieLabelType.Name_Value;
            segment2.LabelDetail.FontSpec.FontColor = Color.Red;

            // Sum up the values
            CurveList curves = myPane.CurveList;
            double    total  = 0;

            for (int x = 0; x < curves.Count; x++)
            {
                total += ((PieItem)curves[x]).Value;
            }

            // Add a text item to highlight total sales
            TextObj text = new TextObj("Total 2004 Sales - " + "$" + total.ToString() + "M", 0.85F, 0.80F, CoordType.PaneFraction);

            text.Location.AlignH           = AlignH.Center;
            text.Location.AlignV           = AlignV.Bottom;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill             = new Fill(Color.White, Color.PowderBlue, 45F);
            text.FontSpec.StringAlignment  = StringAlignment.Center;
            myPane.GraphObjList.Add(text);

            // Add a colored background behind the pie
            BoxObj box = new BoxObj(0, 0, 1, 1, Color.Empty, Color.PeachPuff);

            box.Location.CoordinateFrame = CoordType.ChartFraction;
            box.Border.IsVisible         = false;
            box.Location.AlignH          = AlignH.Left;
            box.Location.AlignV          = AlignV.Top;
            box.ZOrder = ZOrder.E_BehindCurves;
            myPane.GraphObjList.Add(box);

            base.ZedGraphControl.AxisChange();
        }
        private static void TestProcess(Dictionary <string, string> informalExpMap)
        {
            // init
            Console.WriteLine("----- Test Process Text: -----");
            string inText = "u rolling &amp;amp; pls(12years).";
            // test process:  must use ArrayList<TextObj>
            List <TokenObj> inTokenList  = TextObj.TextToTokenList(inText);
            List <TokenObj> outTokenList = new List <TokenObj>(inTokenList.Select(token => XmlHtmlHandler.Process(token))
                                                               .Select(token => LeadingPuncSplitter.Process(token)).SelectMany(token => TextObj.FlatTokenToArrayList(token))
                                                               .Select(token => LeadingDigitSplitter.Process(token)).SelectMany(token => TextObj.FlatTokenToArrayList(token))
                                                               .Select(token => InformalExpHandler.Process(token, informalExpMap)).ToList());

            // result
            string outText = TextObj.TokenListToText(outTokenList);

            // print out
            Console.WriteLine("--------- LeadingDigitSplitter( ) Test ----------");
            Console.WriteLine("In: [" + inText + "]");
            Console.WriteLine("Out: [" + outText + "]");
            Console.WriteLine("----- Details -----------");
            int index = 0;

            foreach (TokenObj tokenObj in outTokenList)
            {
                Console.WriteLine(index + "|" + tokenObj.ToHistString());
                index++;
            }
        }
Exemple #52
0
        /// <summary>
        ///
        /// </summary>

        protected void PlotStrategyTradepoints(application.Strategy.Data.TradePoints tradePoints, baseClass.controls.graphPanel toPanel)
        {
            ClearStrategyTradepoints(toPanel);
            Charts.DrawCurve[] curveList = myCurveList.CurveInPane(toPanel.Name);
            if (curveList.Length == 0)
            {
                return;
            }
            CurveItem curveItem = curveList[0].Curve;

            TradePointInfo tradePointInfo;

            for (int idx = 0; idx < tradePoints.Count; idx++)
            {
                tradePointInfo = (TradePointInfo)tradePoints[idx];
                if (!tradePointInfo.isValid)
                {
                    continue;
                }

                TextObj obj = new TextObj();
                obj.FontSpec.Size             = Settings.sysTradePointMarkerFontSize;
                obj.FontSpec.IsBold           = true;
                obj.FontSpec.Border.IsVisible = true;
                obj.FontSpec.Fill.IsVisible   = true;
                obj.FontSpec.Fill.Color       = Settings.sysTradePointMarkerColorBG;
                switch (toPanel.myGraphObj.myViewportState.myAxisType)
                {
                case Charts.AxisType.DateAsOrdinal:
                    obj.Location.X = tradePointInfo.DataIdx + 1;
                    break;

                default:
                    obj.Location.X = curveItem.Points[tradePointInfo.DataIdx].X;
                    break;
                }
                obj.Location.Y = curveItem.Points[tradePointInfo.DataIdx].Y;
                obj.Location.CoordinateFrame = CoordType.AxisXYScale;

                obj.Location.AlignH = AlignH.Center;
                switch (tradePointInfo.TradeAction)
                {
                case AppTypes.TradeActions.Buy:
                case AppTypes.TradeActions.Accumulate:
                    obj.Text = Settings.sysTradePointMarkeBUY;
                    obj.FontSpec.FontColor = Settings.sysTradePointMarkerColorBUY;
                    break;

                case AppTypes.TradeActions.Sell:
                case AppTypes.TradeActions.ClearAll:
                    obj.Text = Settings.sysTradePointMarkerSELL;
                    obj.FontSpec.FontColor = Settings.sysTradePointMarkerColorSELL;
                    break;

                default:
                    obj.Text = Settings.sysTradePointMarkerOTHER;
                    obj.FontSpec.FontColor = Settings.sysTradePointMarkerColorOTHER;
                    break;
                }
                toPanel.myGraphObj.myGraphPane.GraphObjList.Add(obj);
            }
            toPanel.myGraphObj.UpdateChart();
        }
Exemple #53
0
        private void DisplayCalibrationCurve()
        {
            CalibrationCurveOptions options = Settings.Default.CalibrationCurveOptions;

            zedGraphControl.GraphPane.YAxis.Type             = zedGraphControl.GraphPane.XAxis.Type
                                                             = options.LogPlot ? AxisType.Log : AxisType.Linear;
            zedGraphControl.GraphPane.Legend.IsVisible       = options.ShowLegend;
            _scatterPlots    = null;
            CalibrationCurve = null;
            FiguresOfMerit   = FiguresOfMerit.EMPTY;
            SrmDocument document = DocumentUiContainer.DocumentUI;

            if (!document.Settings.HasResults)
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_No_results_available;
                return;
            }
            PeptideDocNode      peptide;
            PeptideGroupDocNode peptideGroup;

            if (!TryGetSelectedPeptide(out peptideGroup, out peptide))
            {
                zedGraphControl.GraphPane.Title.Text =
                    QuantificationStrings
                    .CalibrationForm_DisplayCalibrationCurve_Select_a_peptide_to_see_its_calibration_curve;
                return;
            }
            if (-1 == document.Children.IndexOf(peptideGroup))
            {
                zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_peptide_is_no_longer_part_of_the_Skyline_document_;
                return;
            }
            PeptideQuantifier peptideQuantifier = PeptideQuantifier.GetPeptideQuantifier(document, peptideGroup,
                                                                                         peptide);
            CalibrationCurveFitter curveFitter = new CalibrationCurveFitter(peptideQuantifier, document.Settings);

            if (peptideQuantifier.QuantificationSettings.RegressionFit == RegressionFit.NONE)
            {
                if (!(peptideQuantifier.NormalizationMethod is NormalizationMethod.RatioToLabel))
                {
                    zedGraphControl.GraphPane.Title.Text =
                        QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_Use_the_Quantification_tab_on_the_Peptide_Settings_dialog_to_control_the_conversion_of_peak_areas_to_concentrations_;
                }
                else
                {
                    if (!peptide.InternalStandardConcentration.HasValue)
                    {
                        zedGraphControl.GraphPane.Title.Text =
                            string.Format(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_convert_peak_area_ratios_to_concentrations__specify_the_internal_standard_concentration_for__0__, peptide);
                    }
                    else
                    {
                        zedGraphControl.GraphPane.Title.Text = null;
                    }
                }
            }
            else
            {
                if (curveFitter.GetStandardConcentrations().Any())
                {
                    zedGraphControl.GraphPane.Title.Text = null;
                }
                else
                {
                    zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_fit_a_calibration_curve__set_the_Sample_Type_of_some_replicates_to_Standard__and_specify_their_concentration_;
                }
            }

            zedGraphControl.GraphPane.XAxis.Title.Text = curveFitter.GetXAxisTitle();
            zedGraphControl.GraphPane.YAxis.Title.Text = curveFitter.GetYAxisTitle();
            CalibrationCurve = curveFitter.GetCalibrationCurve();
            FiguresOfMerit   = curveFitter.GetFiguresOfMerit(CalibrationCurve);
            double minX = double.MaxValue, maxX = double.MinValue;
            double minY = double.MaxValue;

            _scatterPlots = new CurveList();
            foreach (var sampleType in SampleType.ListSampleTypes())
            {
                if (!Options.DisplaySampleType(sampleType))
                {
                    continue;
                }
                PointPairList pointPairList         = new PointPairList();
                PointPairList pointPairListExcluded = new PointPairList();
                for (int iReplicate = 0;
                     iReplicate < document.Settings.MeasuredResults.Chromatograms.Count;
                     iReplicate++)
                {
                    ChromatogramSet chromatogramSet = document.Settings.MeasuredResults.Chromatograms[iReplicate];
                    if (!Equals(sampleType, chromatogramSet.SampleType))
                    {
                        continue;
                    }
                    double?y           = curveFitter.GetYValue(iReplicate);
                    double?xCalculated = curveFitter.GetCalculatedXValue(CalibrationCurve, iReplicate);
                    double?x           = curveFitter.GetSpecifiedXValue(iReplicate)
                                         ?? xCalculated;
                    if (y.HasValue && x.HasValue)
                    {
                        PointPair point = new PointPair(x.Value, y.Value)
                        {
                            Tag = iReplicate
                        };
                        if (sampleType.AllowExclude && peptide.IsExcludeFromCalibration(iReplicate))
                        {
                            pointPairListExcluded.Add(point);
                        }
                        else
                        {
                            pointPairList.Add(point);
                        }
                        if (double.IsNaN(x.Value) || double.IsInfinity(x.Value) ||
                            double.IsNaN(y.Value) || double.IsInfinity(y.Value))
                        {
                            continue;
                        }
                        if (!Options.LogPlot || x.Value > 0)
                        {
                            minX = Math.Min(minX, x.Value);
                        }
                        if (!Options.LogPlot || y.Value > 0)
                        {
                            minY = Math.Min(minY, y.Value);
                        }
                        maxX = Math.Max(maxX, x.Value);
                        if (xCalculated.HasValue)
                        {
                            maxX = Math.Max(maxX, xCalculated.Value);
                            if (!Options.LogPlot || xCalculated.Value > 0)
                            {
                                minX = Math.Min(minX, xCalculated.Value);
                            }
                        }
                    }
                }
                if (pointPairList.Any())
                {
                    var lineItem = zedGraphControl.GraphPane.AddCurve(sampleType.ToString(), pointPairList,
                                                                      sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    lineItem.Symbol.Fill    = new Fill(sampleType.Color);
                    _scatterPlots.Add(lineItem);
                }
                if (pointPairListExcluded.Any())
                {
                    string curveLabel = pointPairList.Any() ? null : sampleType.ToString();
                    var    lineItem   = zedGraphControl.GraphPane.AddCurve(curveLabel, pointPairListExcluded,
                                                                           sampleType.Color, sampleType.SymbolType);
                    lineItem.Line.IsVisible = false;
                    _scatterPlots.Add(lineItem);
                }
            }
            List <string> labelLines    = new List <String>();
            RegressionFit regressionFit = document.Settings.PeptideSettings.Quantification.RegressionFit;

            if (regressionFit != RegressionFit.NONE)
            {
                if (minX <= maxX)
                {
                    int interpolatedLinePointCount = 100;
                    if (!options.LogPlot)
                    {
                        if (regressionFit == RegressionFit.LINEAR_THROUGH_ZERO)
                        {
                            minX = Math.Min(0, minX);
                        }
                        if (regressionFit != RegressionFit.QUADRATIC)
                        {
                            interpolatedLinePointCount = 2;
                        }
                    }
                    double[] xValues;
                    if (CalibrationCurve.TurningPoint.HasValue)
                    {
                        xValues = new[] { minX, CalibrationCurve.TurningPoint.Value, maxX };
                    }
                    else
                    {
                        xValues = new[] { minX, maxX };
                    }
                    Array.Sort(xValues);
                    LineItem interpolatedLine = CreateInterpolatedLine(CalibrationCurve, xValues,
                                                                       interpolatedLinePointCount, Options.LogPlot);
                    if (null != interpolatedLine)
                    {
                        zedGraphControl.GraphPane.CurveList.Add(interpolatedLine);
                    }
                }
                labelLines.Add(CalibrationCurve.ToString());

                if (CalibrationCurve.RSquared.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_ +
                                   CalibrationCurve.RSquared.Value.ToString("0.####")); // Not L10N
                }
                if (!Equals(curveFitter.QuantificationSettings.RegressionWeighting, RegressionWeighting.NONE))
                {
                    labelLines.Add(string.Format("{0}: {1}", // Not L10N
                                                 QuantificationStrings.Weighting, curveFitter.QuantificationSettings.RegressionWeighting));
                }
                string strFiguresOfMerit = FiguresOfMerit.ToString();
                if (!string.IsNullOrEmpty(strFiguresOfMerit))
                {
                    labelLines.Add(strFiguresOfMerit);
                }
            }

            if (options.ShowSelection)
            {
                double?ySelected = curveFitter.GetYValue(_skylineWindow.SelectedResultsIndex);
                double?xSelected = curveFitter.GetCalculatedXValue(CalibrationCurve, _skylineWindow.SelectedResultsIndex);
                if (xSelected.HasValue && ySelected.HasValue)
                {
                    const float selectedLineWidth = 2;
                    ArrowObj    arrow             = new ArrowObj(xSelected.Value, ySelected.Value, xSelected.Value,
                                                                 ySelected.Value)
                    {
                        Line = { Color = GraphSummary.ColorSelected }
                    };
                    zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow);
                    var selectedLineColor = Color.FromArgb(128, GraphSummary.ColorSelected);
                    var verticalLine      = new LineObj(xSelected.Value, ySelected.Value, xSelected.Value, options.LogPlot ? double.MinValue : 0)
                    {
                        Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                        Location             = { CoordinateFrame = CoordType.AxisXYScale },
                        ZOrder               = ZOrder.E_BehindCurves,
                        IsClippedToChartRect = true
                    };
                    zedGraphControl.GraphPane.GraphObjList.Add(verticalLine);
                    double?xSpecified = curveFitter.GetSpecifiedXValue(_skylineWindow.SelectedResultsIndex);
                    if (xSpecified.HasValue)
                    {
                        var horizontalLine = new LineObj(xSpecified.Value, ySelected.Value, xSelected.Value,
                                                         ySelected.Value)
                        {
                            Line                 = { Color = selectedLineColor, Width = selectedLineWidth },
                            Location             = { CoordinateFrame = CoordType.AxisXYScale },
                            ZOrder               = ZOrder.E_BehindCurves,
                            IsClippedToChartRect = true
                        };
                        zedGraphControl.GraphPane.GraphObjList.Add(horizontalLine);
                    }
                }

                var quantificationResult = curveFitter.GetQuantificationResult(_skylineWindow.SelectedResultsIndex);
                if (quantificationResult.CalculatedConcentration.HasValue)
                {
                    labelLines.Add(string.Format("{0} = {1}", // Not L10N
                                                 QuantificationStrings.Calculated_Concentration, quantificationResult));
                }
                else if (!quantificationResult.NormalizedArea.HasValue)
                {
                    labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_replicate_has_missing_or_truncated_transitions);
                }
            }
            if (labelLines.Any())
            {
                TextObj text = new TextObj(TextUtil.LineSeparate(labelLines), .01, 0,
                                           CoordType.ChartFraction, AlignH.Left, AlignV.Top)
                {
                    IsClippedToChartRect = true,
                    ZOrder   = ZOrder.E_BehindCurves,
                    FontSpec = GraphSummary.CreateFontSpec(Color.Black),
                };
                zedGraphControl.GraphPane.GraphObjList.Add(text);
            }
        }
Exemple #54
0
        public LineageObj(LineageScreen screen, bool createEmpty = false)
        {
            Name                                      = "";
            m_frameSprite                             = new SpriteObj("LineageScreenFrame_Sprite");
            m_frameSprite.Scale                       = new Vector2(2.8f, 2.8f);
            m_frameSprite.DropShadow                  = new Vector2(4f, 6f);
            m_plaqueSprite                            = new SpriteObj("LineageScreenPlaque1Long_Sprite");
            m_plaqueSprite.Scale                      = new Vector2(1.8f, 2f);
            m_playerSprite                            = new ObjContainer("PlayerIdle_Character");
            m_playerSprite.AnimationDelay             = 0.1f;
            m_playerSprite.Scale                      = new Vector2(2f, 2f);
            m_playerSprite.OutlineWidth               = 2;
            m_playerSprite.GetChildAt(10).Visible     = false;
            m_playerSprite.GetChildAt(11).Visible     = false;
            m_playerSprite.GetChildAt(1).TextureColor = Color.Red;
            m_playerSprite.GetChildAt(7).TextureColor = Color.Red;
            m_playerSprite.GetChildAt(14).Visible     = false;
            m_playerSprite.GetChildAt(16).Visible     = false;
            var textureColor = new Color(251, 156, 172);

            m_playerSprite.GetChildAt(13).TextureColor = textureColor;
            m_playerName               = new TextObj(Game.JunicodeFont);
            m_playerName.FontSize      = 10f;
            m_playerName.Text          = "Sir Skunky IV";
            m_playerName.Align         = Types.TextAlign.Centre;
            m_playerName.OutlineColour = new Color(181, 142, 39);
            m_playerName.OutlineWidth  = 2;
            m_playerName.Y             = m_textYPos;
            m_playerName.LimitCorners  = true;
            AddChild(m_playerName);
            m_classTextObj               = new TextObj(Game.JunicodeFont);
            m_classTextObj.FontSize      = 8f;
            m_classTextObj.Align         = Types.TextAlign.Centre;
            m_classTextObj.OutlineColour = new Color(181, 142, 39);
            m_classTextObj.OutlineWidth  = 2;
            m_classTextObj.Text          = "the Knight";
            m_classTextObj.Y             = m_playerName.Y + m_playerName.Height - 8f;
            m_classTextObj.LimitCorners  = true;
            AddChild(m_classTextObj);
            m_trait1Title               = new TextObj(Game.JunicodeFont);
            m_trait1Title.FontSize      = 8f;
            m_trait1Title.Align         = Types.TextAlign.Centre;
            m_trait1Title.OutlineColour = new Color(181, 142, 39);
            m_trait1Title.OutlineWidth  = 2;
            m_trait1Title.Y             = m_classTextObj.Y + m_classTextObj.Height + 5f;
            m_trait1Title.Text          = "";
            m_trait1Title.LimitCorners  = true;
            AddChild(m_trait1Title);
            m_trait2Title              = (m_trait1Title.Clone() as TextObj);
            m_trait2Title.Y           += 20f;
            m_trait2Title.Text         = "";
            m_trait2Title.LimitCorners = true;
            AddChild(m_trait2Title);
            m_ageText              = (m_trait1Title.Clone() as TextObj);
            m_ageText.Text         = "xxx - xxx";
            m_ageText.Visible      = false;
            m_ageText.LimitCorners = true;
            AddChild(m_ageText);
            m_spellIcon = new SpriteObj("Blank_Sprite");
            m_spellIcon.OutlineWidth = 1;
            m_spellIconHolder        = new SpriteObj("BlacksmithUI_IconBG_Sprite");
            if (!createEmpty)
            {
                IsFemale = false;
                if (CDGMath.RandomInt(0, 1) > 0)
                {
                    IsFemale = true;
                }
                if (IsFemale)
                {
                    CreateFemaleName(screen);
                }
                else
                {
                    CreateMaleName(screen);
                }
                Traits = TraitType.CreateRandomTraits();
                Class  = ClassType.GetRandomClass();
                m_classTextObj.Text = "the " + ClassType.ToString(Class, IsFemale);
                while (Class == 7 || Class == 15)
                {
                    if (Traits.X != 12f && Traits.Y != 12f)
                    {
                        break;
                    }
                    Traits = TraitType.CreateRandomTraits();
                }
                while ((Class == 1 || Class == 9 || Class == 16) && (Traits.X == 31f || Traits.Y == 31f))
                {
                    Traits = TraitType.CreateRandomTraits();
                }
                var spellList = ClassType.GetSpellList(Class);
                do
                {
                    Spell = spellList[CDGMath.RandomInt(0, spellList.Length - 1)];
                } while ((Spell == 11 || Spell == 4 || Spell == 6) && (Traits.X == 31f || Traits.Y == 31f));
                Array.Clear(spellList, 0, spellList.Length);
                Age      = (byte)CDGMath.RandomInt(18, 30);
                ChildAge = (byte)CDGMath.RandomInt(2, 5);
                UpdateData();
            }
        }
        }// InitializeEngine()

        //
        //
        // ****          Process Event           ****
        //
        public void ProcessEvent(EventArgs e)
        {
            // Initialize and validate
            if (!m_IsGraphsInitialized)
            {   // Graphs not initialized yet. Just store these events.
                m_InitialEvents.Add(e);
                return;
            }
            else if (m_InitialEvents.Count > 0)
            {   // The graphs have just been initialized, so
                // lets extract all the previously stored initial events.
                List <EventArgs> events = new List <EventArgs>();
                events.AddRange(m_InitialEvents);       // add already acrued events.
                m_InitialEvents.Clear();                // clearing this signals we are ready for normal operation.
                events.Add(e);                          // add the latest event also.
                foreach (EventArgs anEvent in events)
                {
                    ProcessEvent(anEvent);
                }
            }
            if (e.GetType() != typeof(EngineEventArgs))
            {
                return;
            }
            //
            // Process Engine Events
            //
            EngineEventArgs eArgs = (EngineEventArgs)e;

            EngineEventArgs.EventType   eventType   = eArgs.MsgType;
            EngineEventArgs.EventStatus eventStatus = eArgs.Status;
            if (eventStatus != EngineEventArgs.EventStatus.Confirm)
            {
                return;                                 // we only process confirmations.
            }
            if (eArgs.DataObjectList != null)
            {
                foreach (object o in eArgs.DataObjectList)
                {
                    // *****************************************
                    // ****		Curve Definitiion List		****
                    // *****************************************
                    Type dataType = o.GetType();
                    //if (dataType == typeof(List<CurveDefinition>))
                    if (dataType == typeof(CurveDefinitionList))
                    {   // Given a list of curve definitions, update pre-defined curves,
                        // or create new curves.  These must be created by the windows thread.
                        // These are usually only received at the start of the run when all parameters are broadcasted.
                        List <CurveDefinition>            list = ((CurveDefinitionList)o).CurveDefinitions;
                        Dictionary <int, EngineEventArgs> requestedGraphRequests = new Dictionary <int, EngineEventArgs>(); // place to put CurveDefs for not yet created graphs.
                        foreach (CurveDefinition cDef in list)
                        {
                            ZedGraphControl zg1;
                            lock (GraphListLock)
                            {
                                if (!m_GraphList.TryGetValue(cDef.GraphID, out zg1))
                                {               // Since we can't find this GraphID, request it to be created below.
                                    m_ZedGraphIDRequested.Add(cDef.GraphID);
                                    zg1 = null; // this signals that graph doesn't exit.
                                }
                            }
                            if (zg1 == null && !requestedGraphRequests.ContainsKey(cDef.GraphID))
                            {                                                     // We couldn't find GraphID, so request it to be created it now!
                                // Also make sure we only request it once thru this loop, just to save time.
                                AddGraph(this, eArgs);                            // Asynch call will call ProcessEvent() again.
                                EngineEventArgs newEvent = new EngineEventArgs(); // Event we will restack until after graph exists.
                                newEvent.DataObjectList = new List <object>();
                                newEvent.Status         = EngineEventArgs.EventStatus.Confirm;
                                requestedGraphRequests.Add(cDef.GraphID, newEvent);// Mark this ID as having just been requested.
                            }
                            if (requestedGraphRequests.ContainsKey(cDef.GraphID))
                            {             // This is a curve for a graph we just requested... push onto wait list.
                                requestedGraphRequests[cDef.GraphID].DataObjectList.Add(cDef);
                                continue; // skip
                            }

                            UpdateCurveDefinition(zg1, cDef);
                        }//next curveDefn
                        // Push any unfulfilled requests back onto queue.
                        foreach (EngineEventArgs eeArgs in requestedGraphRequests.Values)
                        {
                            m_InitialEvents.Add(eeArgs);
                        }
                    }
                    // *****************************************
                    // ****			ZGraphPoints		    ****
                    // *****************************************
                    else if (dataType == typeof(ZGraphPoints))
                    {   // This is a list of ZGraphPoint objects. This message is from the AllParameter broadcast
                        // at the beginning of the run.  A new ZGraphControl will request all parameter values
                        // only when first created.   Therefore, if we are an old ZGraphControl, it probably is not
                        // for us.
                        if (m_LoadedHistory)
                        {
                            return;
                        }
                        m_LoadedHistory = true;
                        List <ZGraphPoint> pointList = ((ZGraphPoints)o).Points;
                        foreach (ZGraphPoint zpt in pointList)
                        {
                            ZedGraphControl zg1;
                            if (!m_GraphList.TryGetValue(zpt.GraphID, out zg1))
                            {   // No currently existing graph with this id.
                                continue;
                            }
                            CurveItem curve = null;
                            if (zg1.GraphPane != null)
                            {
                                curve = zg1.GraphPane.CurveList[zpt.CurveName];
                                if (curve == null)
                                {       // a new curve showed up - create a new curve, and plot this point anyway.
                                    Color newColor = m_DefaultColors[zg1.GraphPane.CurveList.Count % m_DefaultColors.Length];
                                    curve = zg1.GraphPane.AddCurve(zpt.CurveName, new PointPairList(), newColor, SymbolType.None);
                                }
                            }
                            // Add/replace points in the plot.
                            IPointListEdit ip = null;
                            if (curve != null)
                            {
                                ip = curve.Points as IPointListEdit;
                            }
                            if (ip != null)
                            {
                                if (zpt.IsReplaceAtX)
                                {                                      // This is a request to replace point with new one.
                                    int foundIndex = -1;
                                    for (int i = 0; i < ip.Count; ++i) // search for X-value of point to replace
                                    {
                                        if (ip[i].X == zpt.X)          // very unsafe
                                        {
                                            foundIndex = i;
                                            break;                                              // stop looking
                                        }
                                    }
                                    if (foundIndex > -1)
                                    {
                                        ip[foundIndex].Y = zpt.Y;
                                    }
                                    else
                                    {
                                        ip.Add(zpt.X, zpt.Y);
                                        // sort?
                                    }
                                }
                                else
                                {
                                    ip.Add(zpt.X, zpt.Y);               // simple serial addition of new data point.
                                }
                            }
                        }//next zpt
                    }
                    // *****************************************
                    // ****			List<ZGraphPoint>		****
                    // *****************************************

                    /*
                     * else if (dataType == typeof(List<ZGraphPoint>))
                     * {   // This is a list of ZGraphPoints.  This message is from the AllParameter broadcast
                     *  // at the beginning of the run.  A new ZGraphControl will request all parameter values
                     *  // only when first created.   Therefore, if we are an old ZGraphControl, it probably is not
                     *  // for us.
                     *  List<ZGraphPoint> pointList = (List<ZGraphPoint>) o;
                     *  foreach (ZGraphPoint zpt in pointList)
                     *  {
                     *      ZedGraphControl zg1;
                     *      if (!m_GraphList.TryGetValue(zpt.GraphID, out zg1))
                     *      {	// No currently existing graph with this id.
                     *          continue;
                     *      }
                     *      CurveItem curve = null;
                     *      if (zg1.GraphPane != null)
                     *      {
                     *          curve = zg1.GraphPane.CurveList[zpt.CurveName];
                     *          if (curve == null)
                     *          {	// a new curve showed up - create a new curve, and plot this point anyway.
                     *              Color newColor = m_DefaultColors[zg1.GraphPane.CurveList.Count % m_DefaultColors.Length];
                     *              curve = zg1.GraphPane.AddCurve(zpt.CurveName, new PointPairList(), newColor, SymbolType.None);
                     *          }
                     *      }
                     *      // Add/replace points in the plot.
                     *      IPointListEdit ip = null;
                     *      if (curve != null)
                     *          ip = curve.Points as IPointListEdit;
                     *      if (ip != null)
                     *      {
                     *          if (zpt.IsReplaceAtX)
                     *          {	// This is a request to replace point with new one.
                     *              int foundIndex = -1;
                     *              for (int i = 0; i < ip.Count; ++i)	// search for X-value of point to replace
                     *                  if (ip[i].X == zpt.X)			// very unsafe
                     *                  {
                     *                      foundIndex = i;
                     *                      break;						// stop looking
                     *                  }
                     *              if (foundIndex > -1)
                     *                  ip[foundIndex].Y = zpt.Y;
                     *              else
                     *              {
                     *                  ip.Add(zpt.X, zpt.Y);
                     *                  // sort?
                     *              }
                     *
                     *          }
                     *          else
                     *              ip.Add(zpt.X, zpt.Y);		// simple serial addition of new data point.
                     *      }
                     *  }//next zpt
                     * }
                     */
                    // *****************************************
                    // ****			Curve Definition		****
                    // *****************************************
                    else if (dataType == typeof(CurveDefinition))
                    {
                        CurveDefinition zNewCurve = (CurveDefinition)o;
                        ZedGraphControl zg1;
                        if (!m_GraphList.TryGetValue(zNewCurve.GraphID, out zg1))
                        {             // New graph ID!
                            continue; // TODO: Create new graph on the fly.
                        }
                        UpdateCurveDefinition(zg1, zNewCurve);
                    }
                    // *****************************************
                    // ****			ZGraphPoint			    ****
                    // *****************************************
                    else if (dataType == typeof(ZGraphText))
                    {
                        ZGraphText      zpt = (ZGraphText)o;
                        ZedGraphControl zg1;
                        if (!m_GraphList.TryGetValue(zpt.GraphID, out zg1))
                        {       // No currently existing graph with this id.
                            continue;
                        }

                        TextObj text = new TextObj(zpt.Text, zpt.X, zpt.Y);

                        text.FontSpec.Angle  = zpt.FontAngle;
                        text.Location.AlignH = zpt.FontAlignH;
                        text.Location.AlignV = zpt.FontAlignV;

                        text.FontSpec.Size             = zpt.FontSize;
                        text.FontSpec.Border.IsVisible = zpt.FontBorderIsVisible;
                        text.FontSpec.Fill.IsVisible   = zpt.FontFillIsVisible;

                        zg1.GraphPane.GraphObjList.Add(text);
                    }
                    // *****************************************
                    // ****			ZGraphPoint			    ****
                    // *****************************************
                    else if (dataType == typeof(ZGraphPoint))
                    {
                        ZGraphPoint     zpt = (ZGraphPoint)o;
                        ZedGraphControl zg1;
                        if (!m_GraphList.TryGetValue(zpt.GraphID, out zg1))
                        {       // No currently existing graph with this id.
                            continue;
                        }
                        CurveItem curve = null;
                        if (zg1.GraphPane != null)
                        {
                            curve = zg1.GraphPane.CurveList[zpt.CurveName];
                            if (curve == null)
                            {   // a new curve showed up - create a new curve, and plot this point anyway.
                                Color newColor = m_DefaultColors[zg1.GraphPane.CurveList.Count % m_DefaultColors.Length];
                                curve = zg1.GraphPane.AddCurve(zpt.CurveName, new PointPairList(), newColor, SymbolType.None);
                            }
                        }
                        // Add/replace points in the plot.
                        IPointListEdit ip = null;
                        if (curve != null)
                        {
                            ip = curve.Points as IPointListEdit;
                        }
                        if (ip != null)
                        {
                            if (zpt.IsReplaceAtX)
                            {                                      // This is a request to replace point with new one.
                                int foundIndex = -1;
                                for (int i = 0; i < ip.Count; ++i) // search for X-value of point to replace
                                {
                                    if (ip[i].X == zpt.X)          // very unsafe
                                    {
                                        foundIndex = i;
                                        break;                                          // stop looking
                                    }
                                }
                                if (foundIndex > -1)
                                {
                                    ip[foundIndex].Y = zpt.Y;
                                }
                                else
                                {
                                    ip.Add(zpt.X, zpt.Y);
                                    // sort?
                                }
                            }
                            else
                            {
                                ip.Add(zpt.X, zpt.Y);           // simple serial addition of new data point.
                            }
                        }
                    }// ZPoint
                }
                m_IsUpdateRequired = true;
                //Regenerate(this, EventArgs.Empty);
            } //if e.DataObjectList is empty
        }     // ProcessEvent()
Exemple #56
0
 //设置Memo
 public void setMemo(TextObj memo)
 {
     depthTimeChart1.myPane.GraphObjList.Add(memo);
 }
Exemple #57
0
        private void CreateBarLabels(GraphPane pane, bool isBarCenter, string valueFormat)
        {
            pane.GraphObjList.Clear();

            bool isVertical = pane.BarSettings.Base == BarBase.X;

            // Make the gap between the bars and the labels = 2% of the axis range
            float labelOffset;

            if (isVertical)
            {
                labelOffset = (float)(pane.YAxis.Scale.Max - pane.YAxis.Scale.Min) * 0.02f;
            }
            else
            {
                labelOffset = (float)(pane.XAxis.Scale.Max - pane.XAxis.Scale.Min) * 0.02f;
            }

            // keep a count of the number of BarItems
            int curveIndex = 0;

            // Get a valuehandler to do some calculations for us
            ValueHandler valueHandler = new ValueHandler(pane, true);

            // Loop through each curve in the list
            foreach (CurveItem curve in pane.CurveList)
            {
                // work with BarItems only
                BarItem bar = curve as BarItem;
                if (bar != null)
                {
                    IPointList points = curve.Points;

                    // Loop through each point in the BarItem
                    for (int i = 0; i < points.Count; i++)
                    {
                        // Get the high, low and base values for the current bar
                        // note that this method will automatically calculate the "effective"
                        // values if the bar is stacked
                        double baseVal, lowVal, hiVal;
                        valueHandler.GetValues(curve, i, out baseVal, out lowVal, out hiVal);

                        // Get the value that corresponds to the center of the bar base
                        // This method figures out how the bars are positioned within a cluster
                        float centerVal = (float)valueHandler.BarCenterValue(bar,
                                                                             bar.GetBarWidth(pane), i, baseVal, curveIndex);

                        // Create a text label -- note that we have to go back to the original point
                        // data for this, since hiVal and lowVal could be "effective" values from a bar stack
                        string barLabelText = (isVertical ? points[i].Y : points[i].X).ToString(valueFormat);
                        barLabelText = barLabelText.Replace(".000", "");

                        // Calculate the position of the label -- this is either the X or the Y coordinate
                        // depending on whether they are horizontal or vertical bars, respectively
                        float position;
                        if (isBarCenter)
                        {
                            position = (float)(hiVal + lowVal) / 2.0f;
                        }
                        else
                        {
                            position = (float)hiVal + labelOffset;
                        }

                        // Create the new TextObj
                        TextObj label;
                        if (isVertical)
                        {
                            label = new TextObj(barLabelText, centerVal, position);
                        }
                        else
                        {
                            label = new TextObj(barLabelText, position, centerVal);
                        }

                        // Configure the TextObj
                        label.Location.CoordinateFrame  = CoordType.AxisXYScale;
                        label.FontSpec.Size             = 12;
                        label.FontSpec.FontColor        = Color.Black;
                        label.FontSpec.Angle            = isVertical ? 0 : 90;
                        label.Location.AlignH           = isBarCenter ? AlignH.Center : AlignH.Left;
                        label.Location.AlignV           = AlignV.Center;
                        label.FontSpec.Border.IsVisible = false;
                        label.FontSpec.Fill.IsVisible   = false;

                        // Add the TextObj to the GraphPane
                        pane.GraphObjList.Add(label);

                        //if(curveIndex == 1)
                        //{
                        //    string total = (points[i].Y + pane.CurveList[0].Points[i].Y).ToString();
                        //    TextObj totallabel = new TextObj(total, centerVal, position + hiVal - lowVal);
                        //    totallabel.Location.CoordinateFrame = CoordType.AxisXYScale;
                        //    totallabel.FontSpec.Size = 12;
                        //    totallabel.FontSpec.FontColor = Color.Black;
                        //    totallabel.FontSpec.Angle = isVertical ? 0 : 90;
                        //    totallabel.Location.AlignH = isBarCenter ? AlignH.Center : AlignH.Left;
                        //    totallabel.Location.AlignV = AlignV.Center;
                        //    totallabel.FontSpec.Border.IsVisible = false;
                        //    totallabel.FontSpec.Fill.IsVisible = false;
                        //    pane.GraphObjList.Add(totallabel);
                        //}
                    }
                }
                curveIndex++;
            }
        }
Exemple #58
0
        public static void GraphDataSource(int Width, int Height, ZedGraphControl zedGraphControl5, double[,] DataSource, string PointNaem, DataGridView dataGridView4 = null)
        {
            zedGraphControl5.BorderStyle = System.Windows.Forms.BorderStyle.None;
            MasterPane masterpane = zedGraphControl5.MasterPane;//获取zedGraphControl1的面板

            //去掉面板中所有的子面板,默认会有一个面板在里面,清除默认面板
            masterpane.PaneList.Clear();
            int Days = DataSource.GetLength(0);

            zedGraphControl5.Visible            = true;
            zedGraphControl5.IsShowCursorValues = true;//该值确定当鼠标位于ZedGraph.Chart.Rect内时是否将显示显示当前比例尺值的工具提示。
            zedGraphControl5.IsEnableSelection  = true;
            //创建一个面板
            GraphPane graphpane = new GraphPane(); //拟合图

            graphpane.XAxis.Scale.Max = Days;      //设置最大刻度                                           //设置公共信息
            SetGraphics(graphpane);
            graphpane.YAxis.MajorGrid.IsZeroLine = false;
            //创建点序列
            PointPairList list = new PointPairList();//创建点的集合

            if (dataGridView4 != null)
            {
                dataGridView4.RowHeadersVisible = false;//隐藏行头
                dataGridView4.Columns.Add("col1", "期数");
                dataGridView4.Columns.Add("col2", "观测值(mm)");
                foreach (DataGridViewColumn item in dataGridView4.Columns)//单元格居中
                {
                    item.SortMode = DataGridViewColumnSortMode.NotSortable;
                    item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    item.DefaultCellStyle.BackColor = Color.Gainsboro;
                }
                dataGridView4.AutoSizeColumnsMode       = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView4.EnableHeadersVisualStyles = false;//在启动了可视样式的时候,BackColor和ForeColor的值会被忽略。
                dataGridView4.ColumnHeadersDefaultCellStyle.BackColor = Color.Aqua;
                dataGridView4.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
            double[] y = new double[Days];
            double[] x = new double[Days];
            for (int i = 0; i < Days; i++)
            {
                x[i] = i + 1;
                y[i] = DataSource[i, 0];
                if (dataGridView4 != null)
                {
                    dataGridView4.Rows.Add();
                    dataGridView4[0, i].Value = "第" + (1 + i).ToString() + "期";
                    dataGridView4[1, i].Value = Math.Round(y[i], 2);
                }
            }



            zedGraphControl5.Size = new Size((int)(0.96740 * Width), (int)(0.59834 * Height));
            graphpane.Rect        = new RectangleF((int)(0.015778 * Width), (int)(0.04126 * Height), (int)(0.94637 * Width), (int)(0.55020 * Height));//设置分图的大小和位置900, 300
            graphpane.Chart.Rect  = new RectangleF((int)(0.015778 * Width) + 55, (int)(0.11004 * Height), (int)(0.78864 * Width), (int)(0.55020 * Height) - 40 - (int)(0.11004 * Height));


            graphpane.XAxis.Title.Text            = "期数";
            graphpane.XAxis.Title.FontSpec.Family = "Arial";
            graphpane.XAxis.Title.FontSpec.Size   = 15;
            graphpane.XAxis.Title.FontSpec.IsBold = false;
            graphpane.XAxis.Title.IsVisible       = true;

            graphpane.YAxis.Title.Text            = "位移量/mm";
            graphpane.YAxis.Title.FontSpec.Family = "Arial";
            graphpane.XAxis.Scale.IsVisible       = true;
            graphpane.XAxis.Scale.MajorStep       = x.Length / graphpane.Rect.Width * 60;
            graphpane.YAxis.Title.FontSpec.Size   = 15;
            graphpane.YAxis.Title.FontSpec.IsBold = false;
            graphpane.Legend.Position             = LegendPos.TopCenter;
            graphpane.Legend.Border.IsVisible     = false;
            graphpane.Legend.FontSpec.Family      = "Arial";
            graphpane.Legend.FontSpec.Size        = 15;
            graphpane.Legend.FontSpec.IsBold      = false;
            graphpane.Legend.IsVisible            = false;
            LineItem myline = graphpane.AddCurve("观测值", null, y, Color.DeepPink, SymbolType.None);

            myline.Line.Width = 1.5F;//线宽

            float width = graphpane.Chart.Rect.Width;
            float heigh = graphpane.Chart.Rect.Height;

            TextObj text = new TextObj(PointNaem, 2 / width, 2 / heigh); //定义文本对象

            text.Location.AlignV           = AlignV.Top;                 //确定文本的x轴为于文本的最上端
            text.Location.AlignH           = AlignH.Left;                //确定文本的y轴为于文本的最左端
            text.Location.CoordinateFrame  = CoordType.ChartFraction;    //设置文本的坐标系统,原点位于内框的左上角
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.FontColor        = Color.Blue;
            text.FontSpec.Size             = 15;
            graphpane.GraphObjList.Add(text);
            masterpane.Add(graphpane);

            Graphics gd = zedGraphControl5.CreateGraphics();

            masterpane.AxisChange(gd);

            zedGraphControl5.Refresh();
        }
Exemple #59
0
 public override void LoadContent(GraphicsDevice graphics)
 {
     this.m_continueText = new KeyIconTextObj(Game.JunicodeFont);
     this.m_continueText.FontSize = 14f;
     this.m_continueText.Align = Types.TextAlign.Right;
     this.m_continueText.Position = new Vector2(1270f, 650f);
     this.m_continueText.ForceDraw = true;
     this.m_continueText.Opacity = 0f;
     this.m_background = new BackgroundObj("LineageScreenBG_Sprite");
     this.m_background.SetRepeated(true, true, Game.ScreenManager.Camera, null);
     this.m_background.X -= 6600f;
     this.m_background.Opacity = 0.7f;
     this.m_endingMask = new SpriteObj("Blank_Sprite");
     this.m_endingMask.ForceDraw = true;
     this.m_endingMask.TextureColor = Color.Black;
     this.m_endingMask.Scale = new Vector2(1330f / (float)this.m_endingMask.Width, 730f / (float)this.m_endingMask.Height);
     this.m_cameraPosList = new List<Vector2>();
     this.m_frameList = new List<SpriteObj>();
     this.m_nameList = new List<TextObj>();
     this.m_slainCountText = new List<TextObj>();
     foreach (GameObj current in base.GameObjList)
     {
         if (current is WaypointObj)
         {
             this.m_cameraPosList.Add(default(Vector2));
         }
     }
     CultureInfo cultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
     cultureInfo.NumberFormat.CurrencyDecimalSeparator = ".";
     foreach (GameObj current2 in base.GameObjList)
     {
         if (current2 is WaypointObj)
         {
             int index = int.Parse(current2.Name, NumberStyles.Any, cultureInfo);
             this.m_cameraPosList[index] = current2.Position;
         }
     }
     float num = 150f;
     foreach (EnemyObj current3 in base.EnemyList)
     {
         current3.Initialize();
         current3.PauseEnemy(true);
         current3.IsWeighted = false;
         current3.PlayAnimation(true);
         current3.UpdateCollisionBoxes();
         SpriteObj spriteObj = new SpriteObj("LineageScreenFrame_Sprite");
         spriteObj.DropShadow = new Vector2(4f, 6f);
         if (current3.Difficulty == GameTypes.EnemyDifficulty.MINIBOSS)
         {
             spriteObj.ChangeSprite("GiantPortrait_Sprite");
             this.FixMiniboss(current3);
         }
         spriteObj.Scale = new Vector2(((float)current3.Width + num) / (float)spriteObj.Width, ((float)current3.Height + num) / (float)spriteObj.Height);
         if (spriteObj.ScaleX < 1f)
         {
             spriteObj.ScaleX = 1f;
         }
         if (spriteObj.ScaleY < 1f)
         {
             spriteObj.ScaleY = 1f;
         }
         spriteObj.Position = new Vector2(current3.X, (float)current3.Bounds.Top + (float)current3.Height / 2f);
         this.m_frameList.Add(spriteObj);
         TextObj textObj = new TextObj(Game.JunicodeFont);
         textObj.FontSize = 12f;
         textObj.Align = Types.TextAlign.Centre;
         textObj.Text = current3.Name;
         textObj.OutlineColour = new Color(181, 142, 39);
         textObj.OutlineWidth = 2;
         textObj.Position = new Vector2(spriteObj.X, (float)(spriteObj.Bounds.Bottom + 40));
         this.m_nameList.Add(textObj);
         TextObj textObj2 = new TextObj(Game.JunicodeFont);
         textObj2.FontSize = 10f;
         textObj2.Align = Types.TextAlign.Centre;
         textObj2.OutlineColour = new Color(181, 142, 39);
         textObj2.Text = "Slain: 0";
         textObj2.OutlineWidth = 2;
         textObj2.HeadingX = (float)current3.Type;
         textObj2.HeadingY = (float)current3.Difficulty;
         textObj2.Position = new Vector2(spriteObj.X, (float)(spriteObj.Bounds.Bottom + 80));
         this.m_slainCountText.Add(textObj2);
         byte type = current3.Type;
         if (type <= 15)
         {
             if (type != 1)
             {
                 if (type != 7)
                 {
                     if (type == 15)
                     {
                         if (current3.Difficulty == GameTypes.EnemyDifficulty.MINIBOSS)
                         {
                             if (current3.Flip == SpriteEffects.None)
                             {
                                 current3.X -= 25f;
                             }
                             else
                             {
                                 current3.X += 25f;
                             }
                         }
                     }
                 }
                 else if (current3.Difficulty == GameTypes.EnemyDifficulty.MINIBOSS)
                 {
                     current3.X += 30f;
                     current3.Y -= 20f;
                 }
             }
             else
             {
                 (current3 as EnemyObj_BallAndChain).BallAndChain.Visible = false;
                 (current3 as EnemyObj_BallAndChain).BallAndChain2.Visible = false;
             }
         }
         else if (type != 20)
         {
             if (type != 29)
             {
                 if (type == 32)
                 {
                     if (current3.Difficulty == GameTypes.EnemyDifficulty.MINIBOSS)
                     {
                         spriteObj.Visible = false;
                     }
                 }
             }
             else
             {
                 if (current3.Difficulty == GameTypes.EnemyDifficulty.ADVANCED)
                 {
                     (current3 as EnemyObj_LastBoss).ForceSecondForm(true);
                     current3.ChangeSprite("EnemyLastBossIdle_Character");
                     current3.PlayAnimation(true);
                 }
                 spriteObj.ChangeSprite("GiantPortrait_Sprite");
                 spriteObj.Scale = Vector2.One;
                 spriteObj.Scale = new Vector2(((float)current3.Width + num) / (float)spriteObj.Width, ((float)current3.Height + num) / (float)spriteObj.Height);
                 textObj.Position = new Vector2(spriteObj.X, (float)(spriteObj.Bounds.Bottom + 40));
                 textObj2.Position = new Vector2(spriteObj.X, (float)(spriteObj.Bounds.Bottom + 80));
             }
         }
         else
         {
             current3.ChangeSprite("EnemyZombieWalk_Character");
             current3.PlayAnimation(true);
         }
         SpriteObj spriteObj2 = new SpriteObj("LineageScreenPlaque1Long_Sprite");
         spriteObj2.Scale = new Vector2(1.8f, 1.8f);
         spriteObj2.Position = new Vector2(spriteObj.X, (float)(spriteObj.Bounds.Bottom + 80));
         this.m_plaqueList.Add(spriteObj2);
     }
     base.LoadContent(graphics);
 }
Exemple #60
0
        public static void GraphPreY(int Width, int Height, ZedGraphControl zedGraphControl2, Matrix _PreY, Matrix PreEoror, Matrix PreYSource, int DeformationDays, string PointName, DataGridView dataGridView2 = null, int MulStep = 1, bool F*g = true)
        {
            MasterPane masterpane = zedGraphControl2.MasterPane;

            masterpane.PaneList.Clear();
            if (F*g)
            {
                zedGraphControl2.Visible = true;
            }
            else
            {
                zedGraphControl2.Visible = false;
            }

            zedGraphControl2.IsShowCursorValues = true;//该值确定当鼠标位于ZedGraph.Chart.Rect内时是否将显示显示当前比例尺值的工具提示。
            zedGraphControl2.IsEnableSelection  = true;
            zedGraphControl2.BorderStyle        = System.Windows.Forms.BorderStyle.None;

            int       PreDays    = _PreY.Rows;
            GraphPane graphpane  = new GraphPane(); //预测拟合图
            GraphPane graphpane1 = new GraphPane(); //预测残差图

            graphpane.XAxis.Scale.Max = PreDays;
            //设置公共信息
            SetGraphics(graphpane);
            SetGraphics(graphpane1);
            graphpane.YAxis.MajorGrid.IsZeroLine  = false;
            graphpane1.YAxis.MajorGrid.IsZeroLine = false;
            graphpane1.XAxis.Scale.Max            = PreDays;
            graphpane1.YAxis.MajorGrid.IsVisible  = false;


            graphpane.YAxis.Title.Text             = "位移量/mm";
            graphpane.Legend.FontSpec.Family       = "Arial";
            graphpane.YAxis.Title.FontSpec.Size    = 15;
            graphpane.YAxis.Title.FontSpec.IsBold  = false;
            graphpane.Legend.Position              = LegendPos.TopCenter;
            graphpane.Legend.Border.IsVisible      = false;
            graphpane.Legend.FontSpec.Size         = 15;
            graphpane.YAxis.Title.FontSpec.Family  = "Arial";
            graphpane.Legend.FontSpec.IsBold       = false;
            graphpane.YAxis.Scale.MajorStep        = 2;
            graphpane.Legend.IsShowLegendSymbols   = true;
            graphpane1.YAxis.Title.Text            = "△/mm";
            graphpane1.YAxis.Title.FontSpec.Size   = 15;
            graphpane1.YAxis.Title.FontSpec.IsBold = false;
            graphpane1.YAxis.Title.FontSpec.Family = "Arial";

            graphpane1.XAxis.Title.Text            = "期数";
            graphpane1.XAxis.Title.FontSpec.Family = "Arial";
            graphpane1.XAxis.Title.FontSpec.Size   = 15;
            graphpane1.XAxis.Title.FontSpec.IsBold = false;
            double[] y     = new double[PreDays];
            double[] _y    = new double[PreDays];
            double[] x     = new double[PreDays];
            double[] error = new double[PreDays];
            if (dataGridView2 != null)
            {
                dataGridView2.RowHeadersVisible = false;//隐藏行头
                dataGridView2.Columns.Add("col1", "期数");
                dataGridView2.Columns.Add("col2", "观测值(mm)");
                dataGridView2.Columns.Add("col3", "预测值(mm)");
                dataGridView2.Columns.Add("col4", "残差(mm)");
                foreach (DataGridViewColumn item in dataGridView2.Columns)//单元格居中
                {
                    item.SortMode = DataGridViewColumnSortMode.NotSortable;
                    item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    item.DefaultCellStyle.BackColor = Color.Gainsboro;
                }

                dataGridView2.AutoSizeColumnsMode       = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView2.EnableHeadersVisualStyles = false;//在启动了可视样式的时候,BackColor和ForeColor的值会被忽略。
                dataGridView2.ColumnHeadersDefaultCellStyle.BackColor = Color.Aqua;
                dataGridView2.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
            string[] _x = new string[PreDays];
            double   sd = 0.0;

            for (int i = 0; i < PreDays; i++)
            {
                x[i] = DeformationDays + i + MulStep - 1;

                _y[i] = _PreY[i, 0];
                y[i]  = PreYSource[i, 0];

                error[i] = PreEoror[i, 0];
                sd      += Math.Pow(error[i], 2);
                _x[i]    = (DeformationDays + i + 1 + MulStep - 1).ToString();
                //获取曲线的点序列
                if (dataGridView2 != null)
                {
                    dataGridView2.Rows.Add();
                    dataGridView2[0, i].Value = "第" + (DeformationDays + i + 1 + MulStep - 1).ToString() + "期";
                    dataGridView2[1, i].Value = Math.Round(y[i], 2);
                    dataGridView2[2, i].Value = Math.Round(_y[i], 2);
                    dataGridView2[3, i].Value = Math.Round(error[i], 2);
                }
            }
            sd /= PreDays;
            sd  = Math.Sqrt(sd);
            if (!F*g)
            {
                zedGraphControl2.Size = new Size(920 - 120, 480);
                graphpane.Rect        = new RectangleF(15, 30, 900 - 120, 280);  //设置分图的大小和位置
                graphpane.Chart.Rect  = new RectangleF(95, 80, 750 - 120, 200);
                graphpane1.Rect       = new RectangleF(15, 320, 900 - 120, 150); //设置分图的大小和位置
                graphpane1.Chart.Rect = new RectangleF(95, 330, 750 - 120, 80);
            }
            else
            {
                zedGraphControl2.Size = new Size((int)(0.94117 * Width), (int)(0.65753 * Height));
                graphpane.Rect        = new RectangleF((int)(0.01764 * Width), (int)(0.04109 * Height), (int)(0.91764 * Width), (int)(0.38356 * Height)); //设置分图的大小和位置900, 300
                graphpane.Chart.Rect  = new RectangleF((int)(0.01764 * Width) + 60, (int)(0.04109 * Height) + 40, (int)(0.74117 * Width), (int)(0.27397 * Height));
                graphpane1.Rect       = new RectangleF((int)(0.01764 * Width), (int)(0.43835 * Height), (int)(0.91764 * Width), (int)(0.20547 * Height)); //设置分图的大小和位置
                graphpane1.Chart.Rect = new RectangleF((int)(0.01764 * Width) + 60, (int)(0.45205 * Height), (int)(0.74117 * Width), (int)(0.27397 * Height) - 100 - (int)(0.01369 * Height));
            }



            graphpane.XAxis.Scale.IsVisible   = false;
            graphpane.Legend.Position         = LegendPos.TopCenter;
            graphpane.Legend.Border.IsVisible = false;
            graphpane.XAxis.Scale.MajorStep   = x.Length / graphpane.Rect.Width * 60;



            graphpane1.XAxis.Scale.MajorStep = x.Length / graphpane.Rect.Width * 60;
            double min, max;

            if ((min = Math.Abs(error.Min())) > (max = Math.Abs(error.Max())))
            {
                graphpane1.YAxis.Scale.Max = (int)min + 1;    //设置最小刻度
                graphpane1.YAxis.Scale.Min = -(int)min - 1;   //设置最大刻度
            }
            else
            {
                graphpane1.YAxis.Scale.Max = (int)max + 1;                 //设置最小刻度
                graphpane1.YAxis.Scale.Min = -(int)max - 1;                //设置最大刻度
            }
            graphpane1.YAxis.Scale.MajorStep = graphpane1.YAxis.Scale.Max; //设置大刻度步长
            LineItem myline  = graphpane.AddCurve("观测值", null, y, Color.Green, SymbolType.Diamond);
            LineItem myline1 = graphpane.AddCurve("预测值", null, _y, Color.Red, SymbolType.Circle);
            LineItem myline3 = graphpane1.AddCurve("残差", null, error, Color.Red, SymbolType.Circle);

            graphpane1.XAxis.Type             = AxisType.Text;
            graphpane1.XAxis.Scale.TextLabels = _x;
            myline.Symbol.Size = 3.0F;                  //设置节点形状大小
            myline.Symbol.Fill = new Fill(Color.Green); //设置节点填充
            myline.Line.Width  = 1;                     //线宽

            zedGraphControl2.IsShowCursorValues = true;
            myline1.Symbol.Size = 3.0F;                        //设置节点形状大小
            myline1.Symbol.Fill = new Fill(Color.Red);         //设置节点填充
            myline1.Line.Width  = 1;                           //线宽

            myline3.Symbol.Size         = 3.0F;                //设置节点形状大小
            myline3.Symbol.Fill         = new Fill(Color.Red); //设置节点填充
            myline3.Line.Width          = 1;                   //线宽
            graphpane1.Legend.IsVisible = false;

            myline.Symbol.Size  = 5.0F;                             //设置节点形状大小
            myline.Symbol.Fill  = new Fill(Color.Green);            //设置节点填充
            myline.Line.Width   = 1;                                //线宽
            myline1.Symbol.Size = 5.0F;                             //设置节点形状大小
            myline1.Symbol.Fill = new Fill(Color.Red);              //设置节点填充
            myline1.Line.Width  = 1;                                //线宽

            myline3.Symbol.Size              = 5.0F;                //设置节点形状大小
            myline3.Symbol.Fill              = new Fill(Color.Red); //设置节点填充
            myline3.Line.Width               = 1;                   //线宽
            graphpane1.Legend.IsVisible      = false;
            graphpane1.XAxis.Scale.MajorStep = x.Length / graphpane.Rect.Width * 60;
            float   width  = graphpane.Chart.Rect.Width;
            float   heigh  = graphpane.Chart.Rect.Height;
            float   width1 = graphpane1.Chart.Rect.Width;
            float   heigh1 = graphpane1.Chart.Rect.Height;
            TextObj text   = new TextObj(PointName + ":" + MulStep + "步预测", 2 / width, 2 / heigh); //定义文本对象

            text.Location.AlignV           = AlignV.Top;                                           //确定文本的x轴为于文本的最上端
            text.Location.AlignH           = AlignH.Left;                                          //确定文本的y轴为于文本的最左端
            text.Location.CoordinateFrame  = CoordType.ChartFraction;                              //设置文本的坐标系统,原点位于内框的左上角
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.FontColor        = Color.Blue;
            text.FontSpec.Size             = 15;
            graphpane.GraphObjList.Add(text);
            TextObj text1 = new TextObj(PointName, 2 / width1, 2 / heigh1); //定义文本对象

            text1.Location.AlignV           = AlignV.Top;                   //确定文本的x轴为于文本的最上端
            text1.Location.AlignH           = AlignH.Left;                  //确定文本的y轴为于文本的最左端
            text1.Location.CoordinateFrame  = CoordType.ChartFraction;      //设置文本的坐标系统,原点位于内框的左上角
            text1.FontSpec.Border.IsVisible = false;
            text1.FontSpec.FontColor        = Color.Blue;
            text1.FontSpec.Size             = 15;
            graphpane1.GraphObjList.Add(text1);
            graphpane1.XAxis.Scale.MajorStep = x.Length / graphpane.Rect.Width * 60;
            TextObj text2 = new TextObj("RMS=" + Math.Round(sd, 2) + "mm", 2 / width1, (heigh1 - 2) / heigh1); //定义文本对象

            text2.Location.AlignV           = AlignV.Bottom;                                                   //确定文本的x轴为于文本的最下端
            text2.Location.AlignH           = AlignH.Left;                                                     //确定文本的y轴为于文本的最左端
            text2.Location.CoordinateFrame  = CoordType.ChartFraction;                                         //设置文本的坐标系统,原点位于内框的左上角
            text2.FontSpec.Border.IsVisible = false;
            text2.FontSpec.FontColor        = Color.Blue;
            text2.FontSpec.Size             = 15;
            graphpane1.GraphObjList.Add(text2);
            masterpane.Add(graphpane);
            masterpane.Add(graphpane1);
            Graphics gd = zedGraphControl2.CreateGraphics();

            masterpane.AxisChange(gd);
            zedGraphControl2.Refresh();
        }