public async Task <IActionResult> Edit(int id, [Bind("Id,ValueText,CreatedAt,ValueTextSentiment,SnapShotId")] HeadLine headLine)
        {
            if (id != headLine.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(headLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HeadLineExists(headLine.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SnapShotId"] = new SelectList(_context.SnapShots, "Id", "Id", headLine.SnapShotId);
            return(View(headLine));
        }
Exemple #2
0
        public HistoryHeadShapeLines(Dictionary <Guid, MeshUndoInfo> partsInfo, IEnumerable <HeadLine> lines, TexturingInfo texturingInfo, bool isProfile)
        {
            if (partsInfo != null)
            {
                foreach (var info in partsInfo)
                {
                    this.partsInfo.Add(info.Key, info.Value.Clone());
                }
            }
            else
            {
                this.partsInfo = null;
            }

            if (lines != null)
            {
                foreach (var line in lines)
                {
                    var currentLine = new HeadLine();
                    Lines.Add(currentLine);
                    foreach (var point in line)
                    {
                        currentLine.Add(point.Clone() as MirroredHeadPoint);
                    }
                }
            }

            TexturingInfo  = texturingInfo.Clone();
            this.isProfile = isProfile;
        }
        public void Create_WaternetWithPhreaticLineAndHeadLinesAndWaternetLines_ReturnWaternetCalculatorResult()
        {
            // Setup
            var headLine = new HeadLine
            {
                Name   = "line 1",
                Points =
                {
                    new CSharpWrapperPoint2D(0, 0),
                    new CSharpWrapperPoint2D(1, 1)
                }
            };
            var phreaticLine = new HeadLine
            {
                Name   = "line 2",
                Points =
                {
                    new CSharpWrapperPoint2D(2, 2),
                    new CSharpWrapperPoint2D(3, 3)
                }
            };
            var referenceLine = new ReferenceLine
            {
                Name   = "line 3",
                Points =
                {
                    new CSharpWrapperPoint2D(4, 4),
                    new CSharpWrapperPoint2D(5, 5)
                },
                AssociatedHeadLine = headLine
            };

            var waternet = new Waternet
            {
                HeadLines =
                {
                    headLine
                },
                PhreaticLine   = phreaticLine,
                ReferenceLines =
                {
                    referenceLine
                }
            };

            // Call
            WaternetCalculatorResult result = WaternetCalculatorResultCreator.Create(waternet);

            // Assert
            WaternetCalculatorOutputAssert.AssertPhreaticLines(new[]
            {
                phreaticLine,
                headLine
            }, result.PhreaticLines.ToArray());

            WaternetCalculatorOutputAssert.AssertReferenceLines(new[]
            {
                referenceLine
            }, result.WaternetLines.ToArray());
        }
        void ReleaseDesignerOutlets()
        {
            if (HeadLine != null)
            {
                HeadLine.Dispose();
                HeadLine = null;
            }

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

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

            if (Title != null)
            {
                Title.Dispose();
                Title = null;
            }
        }
        public async Task <IActionResult> Create([Bind("Id,ValueText,CreatedAt,ValueTextSentiment,SnapShotId")] HeadLine headLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(headLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SnapShotId"] = new SelectList(_context.SnapShots, "Id", "Id", headLine.SnapShotId);
            return(View(headLine));
        }
Exemple #6
0
    public void SetHeadLineText(string inHeadLineName, string inHeadLineText, HeadLine.E_Importence inImportence)
    {
        HeadLine headLine = new HeadLine(inHeadLineName, inHeadLineText, inImportence);

        if (string.IsNullOrEmpty(inHeadLineName) == false)
        {
            int index = m_HeadLines.FindIndex(x => x.Name == inHeadLineName);
            if (index >= 0)
            {
                m_HeadLines[index] = headLine;
                return;
            }
        }

        m_HeadLines.Add(headLine);
    }
Exemple #7
0
        public override void Undo()
        {
            if (partsInfo == null)
            {
                ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Clear();
                foreach (var line in Lines)
                {
                    var currentLine = new HeadLine();
                    ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Add(currentLine);
                    foreach (var point in line)
                    {
                        currentLine.Add(point.Clone() as MirroredHeadPoint);
                    }
                }
            }
            else
            {
                foreach (var meshInfo in partsInfo)
                {
                    if (!ProgramCore.MainForm.ctrlRenderControl.headMeshesController.RenderMesh.Parts.Contains(meshInfo.Key))
                    {
                        continue;
                    }

                    var mesh = ProgramCore.MainForm.ctrlRenderControl.headMeshesController.RenderMesh.Parts[meshInfo.Key];
                    mesh.Undo(meshInfo.Value);
                }

                if (isProfile)
                {
                    ProgramCore.MainForm.ctrlRenderControl.autodotsShapeHelper.ShapeProfileInfo = TexturingInfo.Clone();
                }
                else
                {
                    ProgramCore.MainForm.ctrlRenderControl.autodotsShapeHelper.ShapeInfo = TexturingInfo.Clone();
                }

                ProgramCore.MainForm.ctrlRenderControl.autodotsShapeHelper.TransformRects();
            }

            ProgramCore.MainForm.ctrlTemplateImage.UpdateUserCenterPositions(false, true);
        }
Exemple #8
0
        private static void SetCompleteKernelOutput(WaternetKernelStub kernel)
        {
            var headLine = new HeadLine
            {
                Name   = "line 1",
                Points =
                {
                    new CSharpWrapperPoint2D(0, 0),
                    new CSharpWrapperPoint2D(1, 1)
                }
            };

            kernel.Waternet = new CSharpWrapperWaternet
            {
                HeadLines =
                {
                    headLine
                },
                PhreaticLine = new HeadLine
                {
                    Name   = "line 2",
                    Points =
                    {
                        new CSharpWrapperPoint2D(2, 2),
                        new CSharpWrapperPoint2D(3, 3)
                    }
                },
                ReferenceLines =
                {
                    new ReferenceLine
                    {
                        Name   = "line 3",
                        Points =
                        {
                            new CSharpWrapperPoint2D(4, 4),
                            new CSharpWrapperPoint2D(5, 5)
                        },
                        AssociatedHeadLine = headLine
                    }
                }
            };
        }
        public void pictureTemplate_MouseUp(object sender, MouseEventArgs e)
        {
            startMousePoint = Vector2.Zero;
            if (e.Button == MouseButtons.Left)
            {
                headLastPoint = Vector2.Zero;
                switch (ProgramCore.MainForm.ctrlRenderControl.ScaleMode)
                {
                    case ScaleMode.Zoom:
                        tempOffsetPoint = Vector2.Zero;
                        break;
                    case ScaleMode.None:

                        #region Обычные режимы

                        switch (ProgramCore.MainForm.ctrlRenderControl.Mode)
                        {
                            case Mode.HeadAutodotsFirstTime:
                            case Mode.HeadAutodots:
                                {
                                    if (ProgramCore.Project.ShapeFlip != FlipType.None)
                                        return;

                                    if (!startMove && !dblClick)
                                    {
                                        if (!shiftKeyPressed)
                                            ProgramCore.MainForm.ctrlRenderControl.headController.AutoDots.ClearSelection();

                                        if (e.X >= MouthTransformed.X - HalfPointRectSize && e.X <= MouthTransformed.X + HalfPointRectSize && e.Y >= MouthTransformed.Y - HalfPointRectSize && e.Y <= MouthTransformed.Y + HalfPointRectSize)       // рот
                                            ProgramCore.MainForm.ctrlRenderControl.headController.SelectAutdotsMouth();
                                        else if (e.X >= LeftEyeTransformed.X - HalfPointRectSize && e.X <= LeftEyeTransformed.X + HalfPointRectSize && e.Y >= LeftEyeTransformed.Y - HalfPointRectSize && e.Y <= LeftEyeTransformed.Y + HalfPointRectSize)  // левый глаз
                                            ProgramCore.MainForm.ctrlRenderControl.headController.SelectAutodotsLeftEye();
                                        else if (e.X >= RightEyeTransformed.X - HalfPointRectSize && e.X <= RightEyeTransformed.X + HalfPointRectSize && e.Y >= RightEyeTransformed.Y - HalfPointRectSize && e.Y <= RightEyeTransformed.Y + HalfPointRectSize)  // правый глаз
                                            ProgramCore.MainForm.ctrlRenderControl.headController.SelectAutodotsRightEye();
                                        else if (e.X >= NoseTransformed.X - HalfPointRectSize && e.X <= NoseTransformed.X + HalfPointRectSize && e.Y >= NoseTransformed.Y - HalfPointRectSize && e.Y <= NoseTransformed.Y + HalfPointRectSize) // нос
                                            ProgramCore.MainForm.ctrlRenderControl.headController.SelectAutodotsNose();
                                        else if (e.X >= CentralFacePoint.X - HalfPointRectSize && e.X <= CentralFacePoint.X + HalfPointRectSize && e.Y >= CentralFacePoint.Y - HalfPointRectSize && e.Y <= CentralFacePoint.Y + HalfPointRectSize) // прямоугольник и выделение всех точек
                                        {
                                            if (RectTransformMode)
                                            {
                                                RectTransformMode = false;
                                                ProgramCore.MainForm.ctrlRenderControl.headController.AutoDots.ClearSelection();
                                            }
                                            else
                                            {
                                                RectTransformMode = true;
                                                UpdateUserCenterPositions(true, true);

                                                ProgramCore.MainForm.ctrlRenderControl.headController.SelectAutodotsFaceEllipse();
                                            }
                                        }
                                        else
                                            ProgramCore.MainForm.ctrlRenderControl.headController.UpdateAutodotsPointSelection(e.X, e.Y, true);
                                    }
                                    else
                                    {
                                        RecalcEyeMouthRect();

                                        if (ProgramCore.MainForm.ctrlRenderControl.Mode == Mode.HeadAutodots)
                                        {
                                            ProgramCore.MainForm.ctrlRenderControl.CalcReflectedBitmaps();
                                            ProgramCore.MainForm.ctrlRenderControl.headController.EndAutodots(false);
                                            ProgramCore.MainForm.ctrlRenderControl.ApplySmoothedTextures();

                                            for (var i = 0; i < ProgramCore.MainForm.ctrlRenderControl.headController.AutoDots.Count; i++)      // после слияние с ShapeDots. Проверить!
                                            {
                                                var p = ProgramCore.MainForm.ctrlRenderControl.headController.AutoDots[i];

                                                if (p.Selected)
                                                    ProgramCore.MainForm.ctrlRenderControl.autodotsShapeHelper.Transform(p.Value, i); // точка в мировых координатах
                                            }
                                        }
                                    }
                                }
                                break;
                            /*      case Mode.HeadShapedots:
                                      if (ProgramCore.Project.ShapeFlip != FlipType.None)
                                          return;

                                      if (!startMove && !dblClick)
                                      {
                                          if (!shiftKeyPressed)
                                              ProgramCore.MainForm.ctrlRenderControl.headController.ShapeDots.ClearSelection();

                                          if (e.X >= MouthTransformed.X - HalfPointRectSize && e.X <= MouthTransformed.X + HalfPointRectSize && e.Y >= MouthTransformed.Y - HalfPointRectSize && e.Y <= MouthTransformed.Y + HalfPointRectSize) // рот
                                              ProgramCore.MainForm.ctrlRenderControl.headController.SelectShapedotsMouth();
                                          else if (e.X >= LeftEyeTransformed.X - HalfPointRectSize && e.X <= LeftEyeTransformed.X + HalfPointRectSize && e.Y >= LeftEyeTransformed.Y - HalfPointRectSize && e.Y <= LeftEyeTransformed.Y + HalfPointRectSize) // левый глаз
                                              ProgramCore.MainForm.ctrlRenderControl.headController.SelectShapedotsLeftEye();
                                          else if (e.X >= RightEyeTransformed.X - HalfPointRectSize && e.X <= RightEyeTransformed.X + HalfPointRectSize && e.Y >= RightEyeTransformed.Y - HalfPointRectSize && e.Y <= RightEyeTransformed.Y + HalfPointRectSize) // правый глаз
                                              ProgramCore.MainForm.ctrlRenderControl.headController.SelectShapedotsRightEye();
                                          else if (e.X >= NoseTransformed.X - HalfPointRectSize && e.X <= NoseTransformed.X + HalfPointRectSize && e.Y >= NoseTransformed.Y - HalfPointRectSize && e.Y <= NoseTransformed.Y + HalfPointRectSize) // нос
                                              ProgramCore.MainForm.ctrlRenderControl.headController.SelectShapedotsNose();
                                          else if (e.X >= CentralFacePoint.X - HalfPointRectSize && e.X <= CentralFacePoint.X + HalfPointRectSize && e.Y >= CentralFacePoint.Y - HalfPointRectSize && e.Y <= CentralFacePoint.Y + HalfPointRectSize) // прямоугольник и выделение всех точек
                                          {
                                              if (RectTransformMode)
                                              {
                                                  RectTransformMode = false;
                                                  ProgramCore.MainForm.ctrlRenderControl.headController.ShapeDots.ClearSelection();
                                              }
                                              else
                                              {
                                                  RectTransformMode = true;
                                                  UpdateUserCenterPositions(true, true);

                                                  ProgramCore.MainForm.ctrlRenderControl.headController.SelectShapedotsFaceEllipse();
                                              }
                                          }
                                          else
                                              ProgramCore.MainForm.ctrlRenderControl.headController.UpdateShapedotsPointSelection(e.X, e.Y, true);
                                      }
                                      else
                                      {
                                          for (var i = 0; i < ProgramCore.MainForm.ctrlRenderControl.headController.ShapeDots.Count; i++)
                                          {
                                              var p = ProgramCore.MainForm.ctrlRenderControl.headController.ShapeDots[i];

                                              if (p.Selected)
                                                  ProgramCore.MainForm.ctrlRenderControl.autodotsShapeHelper.Transform(p.Value, i); // точка в мировых координатах
                                          }
                                      }
                                      break;*/
                            case Mode.HeadAutodotsLassoStart:
                                headAutodotsLassoPoints.Add(new Vector2(e.X, e.Y));
                                break;
                            /*    case Mode.HeadShapedotsLassoStart:
                                    headShapedotsLassoPoints.Add(new Vector2(e.X, e.Y));
                                    break;*/
                            case Mode.HeadLine:
                                {
                                    if (ProgramCore.Project.ShapeFlip != FlipType.None)
                                        return;

                                    if (ProgramCore.MainForm.HeadFront)
                                    {
                                        #region вид спереди

                                        if (!startMove && !dblClick)
                                        {
                                            #region Проверяем, начали ли что-то обводить линиями

                                            var firstTime = false;
                                            if (e.X >= MouthTransformed.X - 2.5 && e.X <= MouthTransformed.X + 2.5 && e.Y >= MouthTransformed.Y - 2.5 && e.Y <= MouthTransformed.Y + 2.5) // рот
                                            {
                                                if (ProgramCore.MainForm.ctrlRenderControl.HeadLineMode != MeshPartType.Lip)
                                                {
                                                    firstTime = true;
                                                    ProgramCore.MainForm.ctrlRenderControl.HeadLineMode = MeshPartType.Lip;
                                                }
                                            }
                                            else if (e.X >= LeftEyeTransformed.X - 2.5 && e.X <= LeftEyeTransformed.X + 2.5 && e.Y >= LeftEyeTransformed.Y - 2.5 && e.Y <= LeftEyeTransformed.Y + 2.5) // левый глаз
                                            {
                                                firstTime = true;
                                                ProgramCore.MainForm.ctrlRenderControl.HeadLineMode = MeshPartType.LEye;
                                            }
                                            else if (e.X >= RightEyeTransformed.X - 2.5 && e.X <= RightEyeTransformed.X + 2.5 && e.Y >= RightEyeTransformed.Y - 2.5 && e.Y <= RightEyeTransformed.Y + 2.5) // правый глаз
                                            {
                                                firstTime = true;
                                                ProgramCore.MainForm.ctrlRenderControl.HeadLineMode = MeshPartType.REye;
                                            }
                                            else if (e.X >= NoseTransformed.X - 2.5 && e.X <= NoseTransformed.X + 2.5 && e.Y >= NoseTransformed.Y - 2.5 && e.Y <= NoseTransformed.Y + 2.5) // нос
                                            {
                                                firstTime = true;
                                                ProgramCore.MainForm.ctrlRenderControl.HeadLineMode = MeshPartType.Nose;
                                            }
                                            else if (e.X >= CentralFacePoint.X - 2.5 && e.X <= CentralFacePoint.X + 2.5 && e.Y >= CentralFacePoint.Y - 2.5 && e.Y <= CentralFacePoint.Y + 2.5)
                                            {
                                                firstTime = true;
                                                ProgramCore.MainForm.ctrlRenderControl.HeadLineMode = MeshPartType.Head;
                                            }

                                            #endregion

                                            if (firstTime)          // выбираем режим линии
                                            {
                                                ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Clear();
                                                ProgramCore.MainForm.ctrlRenderControl.autodotsShapeHelper.ResetPoints(ProgramCore.MainForm.ctrlRenderControl.HeadLineMode);
                                            }
                                            else if (ProgramCore.MainForm.ctrlRenderControl.HeadLineMode != MeshPartType.None)          // добавляем новые точки
                                            {
                                                var point = new MirroredHeadPoint(headLastPointRelative, headLastPointRelative, false);
                                                point.UpdateWorldPoint();

                                                #region Проверка на количество линий и режим выделения

                                                if (ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Count > 1)
                                                {
                                                    var condition = false;
                                                    switch (ProgramCore.MainForm.ctrlRenderControl.HeadLineMode)
                                                    {
                                                        case MeshPartType.Lip:
                                                            if (ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Count > 2)
                                                                condition = true;
                                                            break;
                                                        default:
                                                            if (ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Count > 1)

                                                                condition = true;
                                                            break;
                                                    }

                                                    if (condition) // если ничего не выделили - начинаем рисовать новую линию. иначе уходим в режим выделения и таскания точек
                                                    {
                                                        if (!shiftKeyPressed)
                                                            ProgramCore.MainForm.ctrlRenderControl.headController.ClearPointsSelection();

                                                        if (ProgramCore.MainForm.ctrlRenderControl.headController.UpdatePointSelection(point.Value.X, point.Value.Y))
                                                            LineSelectionMode = true;
                                                        else
                                                        {
                                                            if (LineSelectionMode)
                                                            {
                                                                LineSelectionMode = false;
                                                                ProgramCore.MainForm.ctrlRenderControl.headController.ClearPointsSelection();
                                                                break;
                                                            }
                                                            else
                                                                ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Clear();
                                                        }
                                                    }
                                                }

                                                #endregion

                                                if (!LineSelectionMode)
                                                {
                                                    #region Добавляем новые точки линии

                                                    if (ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Count == 0)
                                                    {
                                                        var line = new HeadLine();
                                                        line.Add(point);
                                                        ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Add(line);
                                                    }
                                                    else
                                                    {
                                                        var currentLine = ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Last();
                                                        var hasIntersections = false;

                                                        if (currentLine.Count > 1) // проверка на пересечения линий
                                                        {
                                                            var lastPoint = currentLine.Last();

                                                            float ua, ub;
                                                            for (var i = currentLine.Count - 2; i >= 0; i--)
                                                            {
                                                                var pointA = currentLine[i];
                                                                var pointB = currentLine[i + 1];
                                                                if (AutodotsShapeHelper.GetUaUb(ref lastPoint.Value, ref point.Value, ref pointA.Value, ref pointB.Value, out ua, out ub))
                                                                {
                                                                    if (ua > 0 && ua < 1 && ub > 0 && ub < 1)
                                                                    {
                                                                        hasIntersections = true;
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                        }

                                                        var inAnotherPoint = false;
                                                        if (ProgramCore.MainForm.ctrlRenderControl.HeadLineMode == MeshPartType.Lip && ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Count == 2)
                                                        {
                                                            // ЭТо вторая линия губ
                                                            foreach (var lPoint in ProgramCore.MainForm.ctrlRenderControl.headController.Lines.First())
                                                                if (point.Value.X >= lPoint.Value.X - 0.25 && point.Value.X <= lPoint.Value.X + 0.25 && point.Value.Y >= lPoint.Value.Y - 0.25 && point.Value.Y <= lPoint.Value.Y + 0.25 && !currentLine.Contains(lPoint))
                                                                {
                                                                    if (currentLine.Count == 0)
                                                                        currentLine.Add(lPoint);
                                                                    else
                                                                    {
                                                                        currentLine.Add(lPoint);
                                                                        ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Add(new HeadLine());
                                                                    }
                                                                    inAnotherPoint = true;
                                                                    break;
                                                                }
                                                            if (currentLine.Count == 0) //первую точку добавляем всегда в пересечении с другой точкой.
                                                                inAnotherPoint = true;
                                                        }

                                                        // прочие случаи
                                                        if (!hasIntersections && !inAnotherPoint)
                                                        {
                                                            var firstPoint = currentLine.First();
                                                            if (point.Value.X >= firstPoint.Value.X - 0.25 && point.Value.X <= firstPoint.Value.X + 0.25 && point.Value.Y >= firstPoint.Value.Y - 0.25 && point.Value.Y <= firstPoint.Value.Y + 0.25)
                                                            {
                                                                currentLine.Add(firstPoint);
                                                                ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Add(new HeadLine());
                                                            }
                                                            else
                                                                currentLine.Add(point);
                                                        }
                                                    }

                                                    #endregion
                                                }
                                            }
                                        }

                                        #endregion
                                    }
                                    else
                                    {
                                        #region Вид сбоку

                                        if (isProfileSmoothing)
                                            return;

                                        if (!startMove && !dblClick)
                                        {
                                            var point = new MirroredHeadPoint(headLastPointRelative, headLastPointRelative, false);
                                            point.UpdateWorldPoint();

                                            #region Проверка на количество линий и режим выделения
                                            if (ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Count > 1) // если ничего не выделили - начинаем рисовать новую линию. иначе уходим в режим выделения и таскания точек
                                            {
                                                if (!shiftKeyPressed)
                                                    ProgramCore.MainForm.ctrlRenderControl.headController.ClearPointsSelection();

                                                if (ProgramCore.MainForm.ctrlRenderControl.headController.UpdatePointSelection(point.Value.X, point.Value.Y))
                                                    LineSelectionMode = true;
                                                else
                                                {
                                                    if (LineSelectionMode)
                                                    {
                                                        LineSelectionMode = false;
                                                        ProgramCore.MainForm.ctrlRenderControl.headController.ClearPointsSelection();
                                                        break;
                                                    }
                                                }
                                            }
                                            #endregion

                                            if (!LineSelectionMode)
                                            {
                                                #region Добавляем новые точки линии

                                                if (ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Count == 0)
                                                {
                                                    var line = new HeadLine();
                                                    line.Add(point);
                                                    ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Add(line);
                                                }
                                                else
                                                {
                                                    var currentLine = ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Last();
                                                    var hasIntersections = false;

                                                    if (currentLine.Count > 1) // проверка на пересечения линий
                                                    {
                                                        var lastPoint = currentLine.Last();

                                                        float ua, ub;
                                                        for (var i = currentLine.Count - 2; i >= 0; i--)
                                                        {
                                                            var pointA = currentLine[i];
                                                            var pointB = currentLine[i + 1];
                                                            if (AutodotsShapeHelper.GetUaUb(ref lastPoint.Value, ref point.Value, ref pointA.Value, ref pointB.Value, out ua, out ub))
                                                            {
                                                                if (ua > 0 && ua < 1 && ub > 0 && ub < 1)
                                                                {
                                                                    hasIntersections = true;
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }

                                                    // прочие случаи
                                                    if (!hasIntersections)
                                                        currentLine.Add(point);
                                                }

                                                #endregion
                                            }
                                        }

                                        #endregion
                                    }

                                }
                                break;
                            case Mode.None:
                                {
                                    if (ProgramCore.MainForm.HeadProfile)
                                    {
                                        switch (ControlPointsMode)
                                        {
                                            case ProfileControlPointsMode.SetControlPoints:  // в профиле. расставляем опорные точки
                                                {
                                                    if (headLastPointRelative != Vector2.Zero)
                                                    {
                                                        profileControlPoints[profileControlPointIndex].ValueMirrored = headLastPointRelative;
                                                        ++profileControlPointIndex;

                                                        if (profileControlPointIndex == 4)
                                                        {
                                                            ControlPointsMode = ProfileControlPointsMode.MoveControlPoints;
                                                            profileControlPointIndex = 0;
                                                        }
                                                    }
                                                }
                                                break;
                                            case ProfileControlPointsMode.MoveControlPoints:  // выделяем и двигаем опорные точки
                                                {
                                                    if (!startMove && !dblClick)
                                                    {
                                                        if (!shiftKeyPressed)
                                                            foreach (var point in profileControlPoints)
                                                                point.Selected = false;

                                                        foreach (var point in profileControlPoints)
                                                        {
                                                            var pointK = new Vector2(point.ValueMirrored.X * ProgramCore.MainForm.ctrlTemplateImage.ImageTemplateWidth + ProgramCore.MainForm.ctrlTemplateImage.ImageTemplateOffsetX,
                                                                                     point.ValueMirrored.Y * ProgramCore.MainForm.ctrlTemplateImage.ImageTemplateHeight + ProgramCore.MainForm.ctrlTemplateImage.ImageTemplateOffsetY);
                                                            if (e.X >= pointK.X - 5 && e.X <= pointK.X + 5 && e.Y >= pointK.Y - 5 && e.Y <= pointK.Y + 5)
                                                            {
                                                                point.Selected = true;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                                break;
                                            case ProfileControlPointsMode.UpdateRightLeft:  // выделяем и двигаем опорные точки
                                                {
                                                    if (!startMove && !dblClick)
                                                    {
                                                        if (!shiftKeyPressed)
                                                            foreach (var point in profileControlPoints)
                                                                point.Selected = false;

                                                        for (var i = 0; i < profileControlPoints.Count; i += 3)
                                                        {
                                                            var point = profileControlPoints[i];
                                                            var pointK = new Vector2(point.ValueMirrored.X * ProgramCore.MainForm.ctrlTemplateImage.ImageTemplateWidth + ProgramCore.MainForm.ctrlTemplateImage.ImageTemplateOffsetX,
                                                                                     point.ValueMirrored.Y * ProgramCore.MainForm.ctrlTemplateImage.ImageTemplateHeight + ProgramCore.MainForm.ctrlTemplateImage.ImageTemplateOffsetY);
                                                            if (e.X >= pointK.X - 5 && e.X <= pointK.X + 5 && e.Y >= pointK.Y - 5 && e.Y <= pointK.Y + 5)
                                                            {
                                                                point.Selected = true;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    else if (startMove)
                                                    {
                                                        UpdateProfileRectangle();
                                                    }
                                                }
                                                break;
                                        }
                                    }
                                }
                                break;
                        }

                        #endregion

                        break;
                }
            }

            moveRectIndex = -1;

            startMove = false;
            leftMousePressed = false;
            dblClick = false;
            headLastPointRelative = Vector2.Zero;
            headTempPoints.Clear();
            Cursor = Cursors.Arrow;
        }
Exemple #10
0
        public async Task RunAtTimeOf(DateTime now)
        {
            var curConfig = _ctx.Configs.FirstOrDefault();

            if (curConfig == null)
            {
                return;
            }

            var allSites = _ctx.NewsSites.ToList();

            foreach (var site in allSites)
            {
                HttpClient client = _clientFactory.CreateClient("GetHeadLines");
                client.Timeout = TimeSpan.FromMinutes(5);
                string json = JsonConvert.SerializeObject(new
                {
                    SiteName = site.Name,
                    SiteUrl  = site.Url
                });

                StringContent       data     = new StringContent(json, Encoding.UTF8, applicationJson);
                HttpResponseMessage response = null;
                try
                {
                    response = await client.PostAsync(curConfig.URLForScrapping, data);
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Following Error occured Message {ex.Message}");
                    _logger.LogError($"Following Error occured StackTrace {ex.StackTrace}");
                    _logger.LogError($"Following Error occured InnerException {ex.InnerException}");
                }

                string result = response.Content.ReadAsStringAsync().Result;

                try
                {
                    var listOfHeadLines = JsonConvert.DeserializeObject <HeadLineDto>(result);

                    var newSnapShot = new SnapShot()
                    {
                        NewsSiteId  = site.Id,
                        ImageHashId = listOfHeadLines.photoIdName,
                        CreatedAt   = DateTime.UtcNow,
                    };

                    _ctx.SnapShots.Add(newSnapShot);

                    await _ctx.SaveChangesAsync();

                    foreach (var item in listOfHeadLines.headLines)
                    {
                        string jsonSentiment = JsonConvert.SerializeObject(new
                        {
                            data = item
                        });

                        StringContent       dataJsonSentiment = new StringContent(jsonSentiment, Encoding.UTF8, applicationJson);
                        HttpResponseMessage responseSentiment = null;
                        try
                        {
                            responseSentiment = await client.PostAsync(curConfig.URLForSentiment, dataJsonSentiment);
                        }
                        catch (Exception ex)
                        {
                            _logger.LogError($"Following Error occured Message {ex.Message}");
                            _logger.LogError($"Following Error occured StackTrace {ex.StackTrace}");
                            _logger.LogError($"Following Error occured InnerException {ex.InnerException}");
                        }

                        string resultSentiment = responseSentiment.Content.ReadAsStringAsync().Result;

                        HeadLine newHeadLine = new HeadLine()
                        {
                            ValueText  = item,
                            CreatedAt  = DateTime.UtcNow,
                            SnapShotId = newSnapShot.Id
                        };
                        _ctx.HeadLines.Add(newHeadLine);

                        await _ctx.SaveChangesAsync();

                        try
                        {
                            var newSentiment = JsonConvert.DeserializeObject <Sentiment>(resultSentiment);
                            newSentiment.HeadLineId = newHeadLine.Id;
                            _ctx.Sentiments.Add(newSentiment);

                            await _ctx.SaveChangesAsync();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Following DeserializeObject Error occured content of result {result}");
                    _logger.LogError($"Following DeserializeObject Error occured Message {ex.Message}");
                    _logger.LogError($"Following DeserializeObject Error occured StackTrace {ex.StackTrace}");
                    _logger.LogError($"Following DeserializeObject Error occured InnerException {ex.InnerException}");
                }
            }
        }
 /// <summary>
 /// Asserts whether <paramref name="actual"/> is equal to <paramref name="expected"/>.
 /// </summary>
 /// <param name="expected">The expected <see cref="HeadLine"/>.</param>
 /// <param name="actual">The actual <see cref="WaternetPhreaticLineResult"/>.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="actual"/>
 /// is not equal to <paramref name="expected"/>.</exception>
 private static void AssertPhreaticLine(HeadLine expected, WaternetPhreaticLineResult actual)
 {
     Assert.AreEqual(expected.Name, actual.Name);
     CollectionAssert.AreEqual(expected.Points.Select(p => new Point2D(p.X, p.Z)), actual.Geometry);
 }
Exemple #12
0
        private async void mainWorkAsync()
        {
            Response <LoginResponse> loginResponse = new Response <LoginResponse>();

            loginResponse.content = new LoginResponse();

            try
            {
                JsonObject loginContent2 = await ExecuteMethod2("{\"op\":\"login\",\"user\":\"" + username + "\",\"password\":\"" + password + "\"}");

                // JsonObject loginContent2 = tempJsonArray.GetNamedObject("content");
                try
                {
                    loginResponse.content.error = (string)loginContent2.GetNamedString("error");
                    MessageDialog serverErrorMessage = new MessageDialog(loginResponse.content.error);
                    await serverErrorMessage.ShowAsync();
                }
                catch
                {
                    loginResponse.content.api_level  = (int)loginContent2.GetNamedNumber("api_level");
                    loginResponse.content.session_id = (string)loginContent2.GetNamedString("session_id");

                    string session_id = loginResponse.content.session_id;

                    // MessageDialog checkLogin = new MessageDialog(loginContent2.ToString());
                    // await checkLogin.ShowAsync();

                    JsonArray feedListJson = await ExecuteMethod("{\"op\":\"getFeeds\",\"sid\":\"" + session_id + "\",\"cat_id\":\"" + "-3" + "\",\"unread_only\":\"" + "true" + "\",\"include_nested\":\"" + "true" + "\"}");

                    for (int i = 0; i < feedListJson.Count; i++)
                    // foreach (JsonValue feedJson in feedListJson)
                    {
                        JsonObject feedJson2 = JsonObject.Parse(feedListJson[i].ToString());


                        // MessageDialog checkFeedJson = new MessageDialog(feedJson2.ToString());
                        // await checkFeedJson.ShowAsync();


                        Feed tempFeed = new Feed();
                        tempFeed.headline = new ObservableCollection <HeadLine>();

                        tempFeed.feed_url     = feedJson2.GetNamedString("feed_url");
                        tempFeed.title        = feedJson2.GetNamedString("title");
                        tempFeed.id           = ((int)feedJson2.GetNamedNumber("id")).ToString();
                        tempFeed.unread       = ((int)feedJson2.GetNamedNumber("unread")).ToString();
                        tempFeed.has_icon     = feedJson2.GetNamedBoolean("has_icon").ToString();
                        tempFeed.cat_id       = ((int)feedJson2.GetNamedNumber("cat_id")).ToString();
                        tempFeed.last_updated = ((int)feedJson2.GetNamedNumber("last_updated")).ToString();
                        tempFeed.order_id     = ((int)feedJson2.GetNamedNumber("order_id")).ToString();

                        JsonArray headListJson = await ExecuteMethod("{\"op\":\"getHeadlines\",\"sid\":\"" + session_id + "\",\"feed_id\":\"" + tempFeed.id + "\",\"view_mode\":\"" + "unread\"}");

                        // for (int j = 0; j < headListJson.Count; j++)
                        foreach (JsonValue headJson in headListJson)
                        {
                            JsonObject headJson2 = new JsonObject();
                            headJson2 = JsonObject.Parse(headJson.ToString());
                            // MessageDialog checkHeadJson = new MessageDialog(headJson.ToString());
                            // await checkHeadJson.ShowAsync();

                            HeadLine tempHead = new HeadLine();

                            tempFeed.headline.Add(tempHead);

                            /*
                             * tempFeed.headline[j].id = (int)headJson2.GetNamedNumber("id");
                             * tempFeed.headline[j].unread = headJson2.GetNamedBoolean("unread");
                             * tempFeed.headline[j].marked = headJson2.GetNamedBoolean("marked");
                             * tempFeed.headline[j].published = headJson2.GetNamedBoolean("published");
                             * tempFeed.headline[j].updated = (int)headJson2.GetNamedNumber("updated");
                             * tempFeed.headline[j].is_updated = headJson2.GetNamedBoolean("is_updated");
                             * tempFeed.headline[j].title = headJson2.GetNamedString("title");
                             * tempFeed.headline[j].link = headJson2.GetNamedString("link");
                             * tempFeed.headline[j].feed_id = headJson2.GetNamedString("feed_id");
                             * tempFeed.headline[j].feed_title = headJson2.GetNamedString("feed_title");
                             */

                            tempHead.id         = (int)headJson2.GetNamedNumber("id");
                            tempHead.unread     = headJson2.GetNamedBoolean("unread");
                            tempHead.marked     = headJson2.GetNamedBoolean("marked");
                            tempHead.published  = headJson2.GetNamedBoolean("published");
                            tempHead.updated    = (int)headJson2.GetNamedNumber("updated");
                            tempHead.is_updated = headJson2.GetNamedBoolean("is_updated");
                            tempHead.title      = headJson2.GetNamedString("title");
                            tempHead.link       = headJson2.GetNamedString("link");
                            tempHead.feed_id    = headJson2.GetNamedString("feed_id");
                            tempHead.feed_title = headJson2.GetNamedString("feed_title");

                            // JsonArray tempArrayTags = headJson2.GetNamedArray("tags");

                            /*
                             * for (uint i = 0; i < tempArrayTags.Count; i++)
                             * {
                             *  tempHead.tags[i] = tempArrayTags.GetObjectAt(i).GetString();
                             * }
                             */
                            // MessageDialog checkTags = new MessageDialog(headJson2.GetNamedString("tags"));
                            // await checkTags.ShowAsync();
                            tempFeed.headline.Add(tempHead);
                            HeadList.Add(tempHead);
                        }
                        FeedList.Add(tempFeed);
                        FeedList[i].headline = new ObservableCollection <HeadLine>();
                        // MessageDialog checkCount = new MessageDialog(HeadList.Count.ToString());
                        // await checkCount.ShowAsync();

                        /*
                         * for (int l = 0; l < HeadList.Count; l++)
                         * {
                         *  FeedList[i].headline.Add(HeadList[l]);
                         * }
                         */
                        ObservableCollection <HeadLine> headListForAdd = new ObservableCollection <HeadLine>();
                        foreach (HeadLine h in HeadList)
                        {
                            headListForAdd.Add(h);
                        }
                        ListHeadList.Add(headListForAdd);
                        for (int k = 0; k < HeadList.Count; k++)
                        {
                            SelectedFeed.headline.Add(HeadList[k]);
                        }
                        HeadList.Clear();
                    }

                    // MessageDialog checkGetFeeds = new MessageDialog(feedListJson.ToString());
                    // await checkGetFeeds.ShowAsync();


                    JsonObject logoutContent = await ExecuteMethod2("{\"op\":\"logout\",\"sid\":\"" + session_id + "\"}");

                    // MessageDialog checkLogout = new MessageDialog("logout" + logoutContent.ToString());
                    // await checkLogout.ShowAsync();
                }
            }
            catch (Exception ex)
            {
                MessageDialog GeneralError = new MessageDialog(ex.ToString());
                await GeneralError.ShowAsync();
            }
        }
        public override void Undo()
        {
            if (partsInfo == null)
            {
                ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Clear();
                foreach (var line in Lines)
                {
                    var currentLine = new HeadLine();
                    ProgramCore.MainForm.ctrlRenderControl.headController.Lines.Add(currentLine);
                    foreach (var point in line)
                        currentLine.Add(point.Clone() as MirroredHeadPoint);
                }
            }
            else
            {
                foreach (var meshInfo in partsInfo)
                {
                    if (!ProgramCore.MainForm.ctrlRenderControl.headMeshesController.RenderMesh.Parts.Contains(meshInfo.Key))
                        continue;

                    var mesh = ProgramCore.MainForm.ctrlRenderControl.headMeshesController.RenderMesh.Parts[meshInfo.Key];
                    mesh.Undo(meshInfo.Value);
                }

                if (isProfile)
                    ProgramCore.MainForm.ctrlRenderControl.autodotsShapeHelper.ShapeProfileInfo = TexturingInfo.Clone();
                else
                    ProgramCore.MainForm.ctrlRenderControl.autodotsShapeHelper.ShapeInfo = TexturingInfo.Clone();

                ProgramCore.MainForm.ctrlRenderControl.autodotsShapeHelper.TransformRects();
            }

            ProgramCore.MainForm.ctrlTemplateImage.UpdateUserCenterPositions(false, true);
        }
        public HistoryHeadShapeLines(Dictionary<Guid, MeshUndoInfo> partsInfo, IEnumerable<HeadLine> lines, TexturingInfo texturingInfo, bool isProfile)
        {
            if (partsInfo != null)
                foreach (var info in partsInfo)
                    this.partsInfo.Add(info.Key, info.Value.Clone());
            else this.partsInfo = null;

            if (lines != null)
                foreach (var line in lines)
                {
                    var currentLine = new HeadLine();
                    Lines.Add(currentLine);
                    foreach (var point in line)
                        currentLine.Add(point.Clone() as MirroredHeadPoint);
                }

            TexturingInfo = texturingInfo.Clone();
            this.isProfile = isProfile;
        }
 private static WaternetPhreaticLineResult CreatePhreaticLineResult(HeadLine phreaticLine)
 {
     return(new WaternetPhreaticLineResult(phreaticLine.Name,
                                           phreaticLine.Points.Select(p => new Point2D(p.X, p.Z)).ToArray()));
 }