Exemplo n.º 1
0
        //redraw scale command
        public void ReDrawScaleCmd()
        {
            YAxisCtl yaxisctl = this.FindName("yaxis") as YAxisCtl;

            BasicWaveChartUC wavechartuc  = this.FindName("ControlContainer") as BasicWaveChartUC;
            Canvas           windowcanvas = wavechartuc.FindName("WindowCanvas") as Canvas;
            Polyline         xaxis_ply    = wavechartuc.FindName("xaxis_ply") as Polyline;

            xaxis_ply.Points.Clear();
            double hlinevalue = this.Height - topblank;

            if (this.XScaleLineNumber == 0)
            {
                return;
            }
            int scalenumber = (int)(wavechartuc.NumberOfDValue / this.XScaleLineNumber);

            for (int i = 0; i <= scalenumber; i++)
            {
                xaxis_ply.Points.Add(new Point(i * XScaleLineNumber * granulity_width, hlinevalue));
                if (i % this.XCommentNumber == 0)
                {
                    xaxis_ply.Points.Add(new Point(i * XScaleLineNumber * granulity_width, hlinevalue - bigScaleHeight));
                }
                else
                {
                    xaxis_ply.Points.Add(new Point(i * XScaleLineNumber * granulity_width, hlinevalue - littleScaleHeight));
                }
                xaxis_ply.Points.Add(new Point(i * XScaleLineNumber * granulity_width, hlinevalue));
            }

            xaxis_ply.Points.Add(new Point(wavechartuc.NumberOfDValue * granulity_width, hlinevalue));      //todo replace
            xaxis_ply.Points.Add(new Point(wavechartuc.NumberOfDValue * granulity_width, hlinevalue - 20)); //todo replace
            xaxis_ply.Points.Add(new Point(wavechartuc.NumberOfDValue * granulity_width, hlinevalue));      //todo replace

            switch (this.XArrowStyle)
            {
            case ArrowStyleEnm.SOLID:
            case ArrowStyleEnm.HOLLOW:
            {
                xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone - this.arrowheight, hlinevalue));
                xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone - this.arrowheight, hlinevalue - this.arrowheight / 2));
                xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone - this.arrowheight, hlinevalue + this.arrowheight / 2));
                xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone, hlinevalue));
                xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone - this.arrowheight, hlinevalue - this.arrowheight / 2));
                //pf.IsFilled = true;
                break;
            }

            case ArrowStyleEnm.NONE:
            default:
            {
                xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone, hlinevalue));
                break;
            }
            }
        }
Exemplo n.º 2
0
        public void Enable()
        {
            try
            {
                ContextMenu menus = ucctl.TryFindResource("wavemenu") as ContextMenu;
                foreach (MenuItem item in menus.Items)
                {
                    if (item.Header.ToString() == "积分")
                    {
                        item.Visibility = Visibility.Visible;
                    }
                }
                ;
            }
            catch { }

            hostcontext.container      = ucctl.FindName("WindowCanvas");
            hostcontext.xaxis          = ucctl.FindName("xaxis");
            hostcontext.yaxis          = ucctl.FindName("yaxis");
            hostcontext.optimizeCanvas = ucctl.FindName("optimizeCanvas") as OptimizeCanvas;
            (hostcontext.container as Canvas).Children.Add(mainhandle);
            (hostcontext.container as Canvas).Children.Add(mainhandle.GetBrother());
            Canvas.SetLeft(mainhandle, hostcontext.container.Width / 3);
            Canvas.SetTop(mainhandle, 0);
            Canvas.SetLeft(mainhandle.GetBrother(), hostcontext.container.Width / 3 + 100);
            Canvas.SetTop(mainhandle.GetBrother(), 0);
            //convert the handle
            ScaleTransform scaletrs = new ScaleTransform();

            scaletrs.ScaleY = -1;
            TranslateTransform movetrs = new TranslateTransform();

            movetrs.Y = mainhandle.Height;
            TransformGroup grouptrs = new TransformGroup();

            grouptrs.Children.Add(scaletrs);
            grouptrs.Children.Add(movetrs);
            mainhandle.RenderTransform = grouptrs;
            mainhandle.GetBrother().RenderTransform = grouptrs;
            //open move feature
            MoveFeature.SetEnble(mainhandle, true);
            MoveFeature.SetEnble(mainhandle.GetBrother(), true);
            //hidden
            mainhandle.Visibility = Visibility.Hidden;
            mainhandle.GetBrother().Visibility = Visibility.Hidden;
            mainhandle.Name = "twohandle";
            //register move handle
            mainhandle.Move_Ev += MainHandleMoveHdlr;
            mainhandle.GetBrother().Move_Ev += brotherHandleMoveHdlr;
            //polygon
            hostcontext.optimizeCanvas.Children.Add(areagon);
            areagon.Stroke          = new SolidColorBrush(Colors.Black);
            areagon.StrokeThickness = 4;
            areagon.Fill            = new SolidColorBrush(Colors.Red);
            //comment
            hostcontext.container.Children.Add(commenttx);
            ScaleTransform scaletrs_comment = new ScaleTransform();

            scaletrs_comment.ScaleY = -1;
            TranslateTransform movetrs_comment = new TranslateTransform();

            movetrs_comment.Y = commenttx.Height;
            TransformGroup grouptrs_comment = new TransformGroup();

            grouptrs_comment.Children.Add(scaletrs_comment);
            grouptrs_comment.Children.Add(movetrs_comment);
            commenttx.RenderTransform = grouptrs_comment;
        }