コード例 #1
0
        private void DrawVerticalCoordinatesLines(DrawingContext drawingContext, DrawSetting drawSetting)
        {
            int    coordinateStep      = drawSetting.GetCoordinateStep();
            double scaleCoordinateStep = drawSetting.GetScaleCoordinateStep();

            double stepCounterHorizontalAxis23 = 0;

            for (double i = drawSetting.BasePoint.X; i > 0; i -= scaleCoordinateStep)
            {
                drawingContext.DrawLine(drawSetting.GraphBoltPen, new Point(i, 0), new Point(i, drawSetting.DrawSize.Width));
                Point p1 = new Point(i, drawSetting.BasePoint.Y);
                Point p2 = new Point(i, drawSetting.BasePoint.Y + 10);
                drawingContext.DrawLine(drawSetting.CoordinatesGraphPen, p1, p2);
                drawingContext.DrawText(drawSetting.GetFormattedCoordinatesText(stepCounterHorizontalAxis23.ToString()), p2);
                stepCounterHorizontalAxis23 -= coordinateStep;
            }

            int stepCounterHorizontalAxis14 = 0;

            for (double i = drawSetting.BasePoint.X; i < drawSetting.DrawSize.Width; i += scaleCoordinateStep)
            {
                drawingContext.DrawLine(drawSetting.GraphBoltPen, new Point(i, 0), new Point(i, drawSetting.DrawSize.Width));
                Point p1 = new Point(i, drawSetting.BasePoint.Y);
                Point p2 = new Point(i, drawSetting.BasePoint.Y + 10);
                drawingContext.DrawLine(drawSetting.CoordinatesGraphPen, p1, p2);
                drawingContext.DrawText(drawSetting.GetFormattedCoordinatesText(stepCounterHorizontalAxis14.ToString()), p2);
                stepCounterHorizontalAxis14 += coordinateStep;
            }
        }
コード例 #2
0
 string joinKey; //get/set personal key when joining current session
 public Common()
 {
     InitializeComponent();
     isDark         = false;
     wageUpVoteCtr  = 0;
     currentSession = new Dictionary <string, JoinMember>();
     wageCollection = new Dictionary <string, bool>();
     monitor        = new Dictionary <string, string>();
     drawSetting    = new DrawSetting();
     firebase       = new FirebaseClient(
         FirebaseConstants.URL,
         new FirebaseOptions
     {
         AuthTokenAsyncFactory = () => Task.FromResult(FirebaseConstants.SECRET)
     });
     var settings = firebase
                    .Child("Current/Setting")
                    .AsObservable <DrawSetting>()
                    .Subscribe(s => getSetting(s));
     var winner = firebase
                  .Child("Current/Winner")
                  .AsObservable <Winner>()
                  .Subscribe(w => getWinner(w));
     var flag = firebase
                .Child("Current/Session")
                .AsObservable <JoinMember>()
                .Subscribe(m => getJoinMembers(m));
     var logs = firebase
                .Child("Current/Log")
                .AsObservable <Monitor>()
                .Subscribe(l => getMonitor(l));
 }
コード例 #3
0
        private void DrawHorizontalCoordinatesLines(DrawingContext drawingContext, DrawSetting drawSetting)
        {
            int    coordinateStep      = drawSetting.GetCoordinateStep();
            double scaleCoordinateStep = drawSetting.GetScaleCoordinateStep();

            double stepCounterVerticalAxis12 = 0;

            for (double i = drawSetting.BasePoint.Y; i > 0; i -= scaleCoordinateStep)
            {
                drawingContext.DrawLine(drawSetting.GraphBoltPen, new Point(0, i), new Point(drawSetting.DrawSize.Width, i));
                Point p1 = new Point(drawSetting.BasePoint.X, i);
                Point p2 = new Point(drawSetting.BasePoint.X + 10, i);
                drawingContext.DrawLine(drawSetting.CoordinatesGraphPen, p1, p2);
                drawingContext.DrawText(drawSetting.GetFormattedCoordinatesText(stepCounterVerticalAxis12.ToString()), p2);
                stepCounterVerticalAxis12 += coordinateStep;
            }

            int stepCounterVerticalAxis34 = 0;

            for (double i = drawSetting.BasePoint.Y; i < drawSetting.DrawSize.Height; i += scaleCoordinateStep)
            {
                drawingContext.DrawLine(drawSetting.GraphBoltPen, new Point(0, i), new Point(drawSetting.DrawSize.Width, i));
                Point p1 = new Point(drawSetting.BasePoint.X, i);
                Point p2 = new Point(drawSetting.BasePoint.X + 10, i);
                drawingContext.DrawLine(drawSetting.CoordinatesGraphPen, p1, p2);
                drawingContext.DrawText(drawSetting.GetFormattedCoordinatesText(stepCounterVerticalAxis34.ToString()), p2);
                stepCounterVerticalAxis34 -= coordinateStep;
            }
        }
コード例 #4
0
        private void DrawCoordinates(DrawingContext drawingContext, DrawSetting drawSetting)
        {
            DrawHorizontalCoordinatesLines(drawingContext, drawSetting);
            DrawVerticalCoordinatesLines(drawingContext, drawSetting);

            drawingContext.DrawLine(drawSetting.CoordinatesGraphPen, new Point(drawSetting.BasePoint.X, 0), new Point(drawSetting.BasePoint.X, drawSetting.DrawSize.Height));
            drawingContext.DrawLine(drawSetting.CoordinatesGraphPen, new Point(0, drawSetting.BasePoint.Y), new Point(drawSetting.DrawSize.Width, drawSetting.BasePoint.Y));
        }
コード例 #5
0
        private async void BtnWageUp_Click(object sender, EventArgs e)
        {
            int wageCtr = 0;

            if (currentSession.Count == 1)
            {
                MessageBox.Show("Needs 2 or more participants to vote");
                return;
            }
            btnWageUp.Enabled            = false;
            AuthUser.Instance.wageUpVote = true;
            var members = await firebase
                          .Child("Current/Session")
                          .OnceAsync <JoinMember>();

            foreach (var member in members)
            {
                if (member.Key != joinKey && member.Object.wageUpVote)
                {
                    wageCtr++;
                }
            }

            if (wageCtr < currentSession.Count - 1)
            {
                await firebase
                .Child("Current/Session")
                .Child(joinKey)
                .PutAsync(JoinMember.save());

                await firebase
                .Child("Current/Log")
                .PostAsync(Monitor.wageVote());
            }
            else
            {
                foreach (var member in members)
                {
                    await firebase
                    .Child("Current/Session")
                    .Child(member.Key)
                    .PutAsync(JoinMember.upWage(member.Object));
                }
                await firebase
                .Child("Current/Setting")
                .Child(drawSetting.Key)
                .PutAsync(DrawSetting.increaseWage(drawSetting.EnableWageVote));

                await firebase
                .Child("Current/Log")
                .PostAsync(Monitor.wageVote());

                await firebase
                .Child("Current/Log")
                .PostAsync(Monitor.wageUp());
            }
        }
コード例 #6
0
        private void DrawProfile(DrawingContext drawingContext, DrawSetting drawSetting, List <Point> drawPoints)
        {
            List <Point> scalePoints = GetScaleTrajectoryPoints(drawPoints, drawSetting.Scale);

            for (int i = 1; i < scalePoints.Count; i++)
            {
                Point previousPoint = scalePoints[i - 1];
                previousPoint.Offset(drawSetting.BasePoint.X, drawSetting.BasePoint.Y);
                Point currentPoint = scalePoints[i];
                currentPoint.Offset(drawSetting.BasePoint.X, drawSetting.BasePoint.Y);
                drawingContext.DrawLine(drawSetting.TrajectoryPen, previousPoint, currentPoint);
            }
        }
コード例 #7
0
        private void InitializeDrawSetting(DrawSetting drawSetting, Size drawSize, List <Point> drawPoints)
        {
            Rect   rectTrajectory        = GetRectTrajectory(drawPoints);
            Rect   marginsRectTrajectory = GetMarginsRectTrajectory(rectTrajectory, drawSetting);
            double scale     = GetSacel(marginsRectTrajectory.Size, drawSize);
            Rect   scaleRect = GetSacelRectTrajectory(marginsRectTrajectory, scale);
            double offsetX   = drawSize.Width / 2 - scaleRect.Width / 2 - scaleRect.X;
            double offsetY   = drawSize.Height / 2 - scaleRect.Height / 2 - scaleRect.Y;

            drawSetting.SetScale(scale);
            drawSetting.SetDarwSize(drawSize);
            drawSetting.SetBasePoint(new Point(offsetX, offsetY));
        }
コード例 #8
0
        private Image GetCoordinatesImage(DrawSetting drawSetting)
        {
            Image image = new Image();

            image.Name = GetFullImageName(ImageNames.Coordinates);
            DrawingVisual  drawingVisual  = new DrawingVisual();
            DrawingContext drawingContext = drawingVisual.RenderOpen();

            DrawCoordinates(drawingContext, DrawSetting);

            drawingContext.Close();

            RenderTargetBitmap bmp = new RenderTargetBitmap((int)drawSetting.DrawSize.Width, (int)drawSetting.DrawSize.Height, 96, 96, PixelFormats.Pbgra32);

            bmp.Render(drawingVisual);
            bmp.Freeze();
            image.Source = bmp;
            return(image);
        }
コード例 #9
0
        private Image GetProfileImage(DrawSetting drawSetting, long id, List <Point> drawPoints)
        {
            Image image = new Image();

            image.Name = GetFullImageName(GetWellboreImageName(id));
            DrawingVisual  drawingVisual  = new DrawingVisual();
            DrawingContext drawingContext = drawingVisual.RenderOpen();

            DrawProfile(drawingContext, DrawSetting, drawPoints);

            drawingContext.Close();

            RenderTargetBitmap bmp = new RenderTargetBitmap((int)drawSetting.DrawSize.Width, (int)drawSetting.DrawSize.Height, 96, 96, PixelFormats.Pbgra32);

            bmp.Render(drawingVisual);
            bmp.Freeze();
            image.Source = bmp;
            return(image);
        }
コード例 #10
0
        private void ReDraw()
        {
            if (DrawingRange == null)
            {
                return;
            }

            RemoveAllChildren();
            Size drawSize = new Size((int)DrawingRange.ActualWidth, (int)DrawingRange.ActualHeight);

            if (drawSize.Width == 0 || drawSize.Height == 0)
            {
                DrawSetting.Reset();
                return;
            }
            List <Point> allProfilePoints = new List <Point>();

            foreach (KeyValuePair <long, List <Point> > profilePoints in wellboreProfilePoints)
            {
                allProfilePoints.AddRange(profilePoints.Value);
            }

            if (allProfilePoints.Count == 0)
            {
                return;
            }

            InitializeDrawSetting(DrawSetting, drawSize, allProfilePoints);
            Image graphImage = GetGraphImage(DrawSetting);

            DrawingRange.Children.Add(graphImage);

            Image coordinateImage = GetCoordinatesImage(DrawSetting);

            DrawingRange.Children.Add(coordinateImage);

            foreach (KeyValuePair <long, List <Point> > profilePoints in wellboreProfilePoints)
            {
                Image profileImage = GetProfileImage(DrawSetting, profilePoints.Key, profilePoints.Value);
                DrawingRange.Children.Add(profileImage);
            }
        }
コード例 #11
0
        private void DrawVerticalGridLines(DrawingContext drawingContext, DrawSetting drawSetting)
        {
            double scaleGraphStep = drawSetting.GetScaleGrapthStep();

            int stepCounterHorizontalAxis23 = 0;

            for (double i = drawSetting.BasePoint.X; i > 0; i = i - scaleGraphStep)
            {
                drawingContext.DrawLine(drawSetting.GraphPen, new Point(i, 0), new Point(i, drawSetting.DrawSize.Height));
                stepCounterHorizontalAxis23 += drawSetting.GrapthStep;
            }

            int stepCounterHorizontalAxis14 = 0;

            for (double i = drawSetting.BasePoint.X; i < drawSetting.DrawSize.Width; i += scaleGraphStep)
            {
                drawingContext.DrawLine(drawSetting.GraphPen, new Point(i, 0), new Point(i, drawSetting.DrawSize.Height));
                stepCounterHorizontalAxis14 += drawSetting.GrapthStep;
            }
        }
コード例 #12
0
        private void DrawHorizontalGridLines(DrawingContext drawingContext, DrawSetting drawSetting)
        {
            double scaleGraphStep = drawSetting.GetScaleGrapthStep();

            double stepCounterVerticalAxis12 = 0;

            for (double i = drawSetting.BasePoint.Y; i > 0; i -= scaleGraphStep)
            {
                drawingContext.DrawLine(drawSetting.GraphPen, new Point(0, i), new Point(drawSetting.DrawSize.Width, i));
                stepCounterVerticalAxis12 += drawSetting.GrapthStep;
            }

            int stepCounterVerticalAxis34 = 0;

            for (double i = drawSetting.BasePoint.Y; i < drawSetting.DrawSize.Height; i += scaleGraphStep)
            {
                drawingContext.DrawLine(drawSetting.GraphPen, new Point(0, i), new Point(drawSetting.DrawSize.Width, i));
                stepCounterVerticalAxis34 -= drawSetting.GrapthStep;
            }
        }
コード例 #13
0
ファイル: AnimationForm.cs プロジェクト: majitaki/OSM2018
        void UserInitialize()
        {
            foreach (LayoutEnum layout in Enum.GetValues(typeof(LayoutEnum)))
            {
                this.comboBoxLayout.Items.Add(layout.ToString());
            }
            this.comboBoxLayout.SelectedIndex = 0;

            this.MyDrawSetting = new DrawSetting();

            this.ViewScale     = 1;
            this.ViewX         = 0;
            this.ViewY         = 0;
            this.ViewOriginX   = 0;
            this.ViewOriginY   = 0;
            this.NodeSizeScale = this.trackBarRadius.Value;

            this.MouseWheel += new MouseEventHandler(this.pictureboxAnimation_MouseWheel);

            this.comboBoxLayout.SelectedIndex = 0;
        }
コード例 #14
0
 public DrawRangeControlViewModel()
 {
     DrawSetting = new DrawSetting();
     CanvasSizeChangedDCommand = new DelegateCommand(CanvasSizeChanged);
     wellboreProfilePoints     = new Dictionary <long, List <Point> >();
 }
コード例 #15
0
 private Rect GetMarginsRectTrajectory(Rect rectTrajectory, DrawSetting drawSetting)
 {
     return(new Rect(new Point(rectTrajectory.X - drawSetting.Margins / 2, rectTrajectory.Y - drawSetting.Margins / 2),
                     new Size(rectTrajectory.Width + drawSetting.Margins, rectTrajectory.Height + drawSetting.Margins)));
 }
コード例 #16
0
 private void DrawGrid(DrawingContext drawingContext, DrawSetting drawSetting)
 {
     DrawHorizontalGridLines(drawingContext, drawSetting);
     DrawVerticalGridLines(drawingContext, drawSetting);
 }