static void SaveMesh( LineModel lineModel )
    {
        Mesh mesh = new Mesh();

        if ( lineModel != null ) {
            List<int> indexList = new List<int>();
            for ( int i = 0; i < lineModel.lineSegments.Length - 1; ++i ) {
                int index = lineModel.lineSegments[i];
                int nextIndex = lineModel.lineSegments[i + 1];

                if ( index != int.MinValue && nextIndex != int.MinValue ) {
                    indexList.Add( index - 1 );
                    indexList.Add( nextIndex - 1 );
                }
            }
            mesh.vertices = lineModel.vertices;
            mesh.SetIndices( indexList.ToArray(), MeshTopology.Lines, 0 );
            Color[] colors = new Color[mesh.vertexCount];
            for ( int i = 0; i < colors.Length; ++i ) {
                colors[i] = new Color( 1f, 1f, 1f, 1f );
            }
            mesh.colors = colors;

            string meshPathAndName = AssetDatabase.GenerateUniqueAssetPath(
            Path.GetDirectoryName(modelPath) + "/" + modelName + "_Mesh" + ".asset");

            AssetDatabase.CreateAsset(mesh, meshPathAndName);
            AssetDatabase.SaveAssets();
        }
    }
Beispiel #2
0
 private void OnLineSelected(LineModel lineModel)
 {
     View.Refresh(lineModel);
 }
Beispiel #3
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string cardId = txtCardId.Text;

            if (chbOtherDate.IsChecked == true)
            {
                if (threadOtherDate.IsBusy == false)
                {
                    this.Cursor         = Cursors.Wait;
                    txtCardId.IsEnabled = false;

                    DateTime      date      = dpOtherDate.SelectedDate.Value.Date;
                    List <Object> arguments = new List <Object>();
                    arguments.Add(cardId);
                    arguments.Add(date);
                    threadOtherDate.RunWorkerAsync(arguments);
                }
            }
            else
            {
                PersonalModel personal = personalList.Where(p => p.CardId == cardId || p.WorkerId == cardId).FirstOrDefault();
                if (personal == null)
                {
                    MessageBox.Show("This Worker Not Found!", this.Title, MessageBoxButton.OK, MessageBoxImage.Warning);
                    txtCardId.Focus();
                    txtCardId.SelectAll();
                    return;
                }
                workerLoginViewToImport = workerLoginViewList.Where(w => w.CardId == personal.CardId && w.WorkerId == personal.WorkerId).FirstOrDefault();
                if (workerLoginViewToImport != null)
                {
                    dgWorkerLogin.SelectedItem = workerLoginViewToImport;
                    string    lineWork = workerLoginViewToImport.LineWork;
                    LineModel line     = lineList.Where(l => l.LineId == lineWork).FirstOrDefault();
                    if (line != null)
                    {
                        lineWork = line.Name;
                    }
                    MessageBox.Show(String.Format("Id: {0}\nName: {1}\nPosition: {2}\nWork at Line: LINE {3}", workerLoginViewToImport.WorkerId, workerLoginViewToImport.Name, workerLoginViewToImport.Position, lineWork), this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                    txtCardId.Focus();
                    txtCardId.SelectAll();
                    return;
                }
                workerLoginViewToImport = new WorkerLoginViewModel
                {
                    CardId   = personal.CardId,
                    WorkerId = personal.WorkerId,
                    Name     = personal.Name,
                    Line     = personal.Department,
                    LineWork = btnLogin.Tag.ToString(),
                    Position = personal.Position,
                };

                workerLoginToImport = new WorkerLoginModel
                {
                    CardId   = personal.CardId,
                    WorkerId = personal.WorkerId,
                    LineId   = btnLogin.Tag.ToString(),
                };

                if (bwInsertWorkerLogin.IsBusy == false)
                {
                    this.Cursor         = Cursors.Wait;
                    resultInsert        = false;
                    txtCardId.IsEnabled = false;
                    bwInsertWorkerLogin.RunWorkerAsync();
                }
            }
        }
Beispiel #4
0
 private void OnUpdateLineReceived(LineModel line)
 {
     View.UpdateLine(line);
 }
        private Dictionary <int, Connection> SetLines(List <Connection> connections)
        {
            var gridCopy = Grid.Clone() as int[, ];
            int id       = 1;

            var  redo = new Dictionary <int, Connection>();
            bool cont = true;

            connections.Reverse();
            var shuffled = connections.OrderBy(x => new Random().Next()).ToList();

            foreach (var connection in /*shuffled*/ connections)
            {
                //var gridCopy = Grid.Clone() as int[,];
                int x1 = 0, x2 = 0, y1 = 0, y2 = 0;

                for (int i = 0; i < gridCopy.GetLength(0); i++)
                {
                    for (int j = 0; j < gridCopy.GetLength(1); j++)
                    {
                        if (gridCopy[i, j] == connection.GetFirstNodeId())
                        {
                            if (j > 0 && i > 0 && j < gridCopy.GetLength(1) - 1 && i < gridCopy.GetLength(0) - 1 && gridCopy[i, j - 1] == int.MaxValue && gridCopy[i, j + 1] == int.MaxValue && gridCopy[i - 1, j] == int.MaxValue && gridCopy[i + 1, j] == int.MaxValue)
                            {
                                if (!redo.ContainsKey(id))
                                {
                                    redo.Add(id, connection);
                                }
                                cont = false;
                            }
                            gridCopy[i, j] = 1;
                            x1             = i;
                            y1             = j;
                        }
                        else if (gridCopy[i, j] == connection.GetSecondNodeId())
                        {
                            if (j > 0 && i > 0 && j < gridCopy.GetLength(1) - 1 && i < gridCopy.GetLength(0) - 1 && gridCopy[i, j - 1] == int.MaxValue && gridCopy[i, j + 1] == int.MaxValue && gridCopy[i - 1, j] == int.MaxValue && gridCopy[i + 1, j] == int.MaxValue)
                            {
                                if (!redo.ContainsKey(id))
                                {
                                    redo.Add(id, connection);
                                }
                                cont = false;
                            }
                            gridCopy[i, j] = 2;
                            x2             = i;
                            y2             = j;
                        }
                        else if (gridCopy[i, j] > 0)
                        {
                            gridCopy[i, j] = int.MaxValue;
                        }
                    }
                }

                if ((x2 == 0 && y2 == 0) || (x1 == 0 && y1 == 0))
                {
                    id++;
                    gridCopy = Grid.Clone() as int[, ];
                    continue;
                }

                if (cont)
                {
                    LineModel newLine = null;
                    int[][]   moves1  = null;
                    int[][]   moves2  = null;

                    if (x1 > x2 && y1 >= y2)
                    {
                        moves1 = MovesProvider.UpLeft;
                        moves2 = MovesProvider.LeftUp;
                    }
                    else if (x1 > x2 && y1 < y2)
                    {
                        moves1 = MovesProvider.UpRight;
                        moves2 = MovesProvider.RightUp;
                    }
                    else if (x1 <= x2 && y1 >= y2)
                    {
                        moves1 = MovesProvider.DownLeft;
                        moves2 = MovesProvider.LeftDown;
                    }
                    else if (x1 <= x2 && y1 < y2)
                    {
                        moves1 = MovesProvider.DownRight;
                        moves2 = MovesProvider.RightDown;
                    }

                    var optTurns = Math.Abs(x1 - x2) == 0 || Math.Abs(y1 - y2) == 0 ? 0 : 1;

                    newLine = new LeeAlgorithmInterpreter().DoYourJob(gridCopy, moves1, moves2, /*(Math.Abs(x1 - x2) + Math.Abs(y1 - y2)) + 4*/
                                                                      Grid.GetLength(1) + Grid.GetLength(0), optTurns, id, x1, y1, x2, y2);
                    if (newLine.GetPointsOfLine().Count != 0)
                    {
                        Lines.Add(newLine);
                        if (!newLine.IsReversed)
                        {
                            newLine.AddPointAtStartOfLine(x1, y1);
                        }
                        else
                        {
                            newLine.AddPointAtEndOfLine(x2, y2);
                        }
                    }
                    else
                    {
                        redo.Add(id, connection);
                    }
                }
                else
                {
                    cont = true;
                }
                id++;
                gridCopy = Grid.Clone() as int[, ];
                foreach (var line in Lines)
                {
                    for (int i = 1; i < line.GetPointsOfLine().Count - 1; i++)
                    {
                        gridCopy[line.GetPointsOfLine()[i].x, line.GetPointsOfLine()[i].y] = int.MaxValue;
                    }
                }
            }
            return(redo);
        }
Beispiel #6
0
 public void AddLine(ActionType actionType, LineModel line)
 {
     _undoLines.Push(new Tuple <ActionType, ILineModel>(actionType, line));
 }
Beispiel #7
0
 public static void CompleteLine(LineModel nextLine, Vec <Coordinate> focusPosition)
 {
     nextLine.P1      = focusPosition;
     nextLine.IsBaked = true;
 }
        private Dictionary <int, Connection> SetLines(Dictionary <int, Connection> connections)
        {
            var gridCopy            = Grid.Clone() as int[, ];
            var thirdIterationLines = new List <LineModel>();
            var redoLast            = new Dictionary <int, Connection>();

            foreach (var connectionWithId in connections)
            {
                int x1 = 0, x2 = 0, y1 = 0, y2 = 0;

                for (int i = 0; i < gridCopy.GetLength(0); i++)
                {
                    for (int j = 0; j < gridCopy.GetLength(1); j++)
                    {
                        if (gridCopy[i, j] == connectionWithId.Value.GetFirstNodeId())
                        {
                            gridCopy[i, j] = 1;
                            x1             = i;
                            y1             = j;
                        }
                        else if (gridCopy[i, j] == connectionWithId.Value.GetSecondNodeId())
                        {
                            gridCopy[i, j] = 2;
                            x2             = i;
                            y2             = j;
                        }
                        else if (gridCopy[i, j] > 0)
                        {
                            gridCopy[i, j] = int.MaxValue;
                        }
                    }
                }

                LineModel newLine = null;
                int[][]   moves1  = null;
                int[][]   moves2  = null;

                if (x1 > x2 && y1 >= y2)
                {
                    moves1 = MovesProvider.UpLeft;
                    moves2 = MovesProvider.LeftUp;
                }
                else if (x1 > x2 && y1 < y2)
                {
                    moves1 = MovesProvider.UpRight;
                    moves2 = MovesProvider.RightUp;
                }
                else if (x1 <= x2 && y1 >= y2)
                {
                    moves1 = MovesProvider.DownLeft;
                    moves2 = MovesProvider.LeftDown;
                }
                else if (x1 <= x2 && y1 < y2)
                {
                    moves1 = MovesProvider.DownRight;
                    moves2 = MovesProvider.RightDown;
                }

                var optTurns = Math.Abs(x1 - x2) == 0 || Math.Abs(y1 - y2) == 0 ? 0 : 1;

                newLine = new LeeAlgorithmInterpreter().DoYourJob(gridCopy, moves1, moves2, gridCopy.GetLength(0) + gridCopy.GetLength(1), optTurns, connectionWithId.Key, x1, y1, x2, y2);
                if (newLine.GetPointsOfLine().Count != 0)
                {
                    Lines.Add(newLine);
                    if (!newLine.IsReversed)
                    {
                        newLine.AddPointAtStartOfLine(x1, y1);
                    }
                    else
                    {
                        newLine.AddPointAtEndOfLine(x2, y2);
                    }
                }
                else
                {
                    redoLast.Add(connectionWithId.Key, connectionWithId.Value);
                }

                thirdIterationLines.Add(newLine);
                gridCopy = Grid.Clone() as int[, ];
                foreach (var line in thirdIterationLines)
                {
                    for (int i = 1; i < line.GetPointsOfLine().Count - 1; i++)
                    {
                        gridCopy[line.GetPointsOfLine()[i].x, line.GetPointsOfLine()[i].y] = int.MaxValue;
                    }
                }
            }
            return(redoLast);
        }
Beispiel #9
0
        public void Update(LineModel model)
        {
            var helper = DependencyResolver.Current.GetService <ILineHelper>();

            helper.SaveLine(model);
        }
Beispiel #10
0
        private string ToLine(LineModel lineModel)
        {
            var blocksData = lineModel.BlocksData.SelectMany(x => new[] { x.WaitingMs, x.ProcessingMs, x.Description });

            return(new[] { lineModel.DataBatchId }.Concat(blocksData).JoinWith("\t"));
        }
Beispiel #11
0
 {//============================================== In the MetaDataRoot hierarchy  ==============
     internal DiagItemModel_7F2(LineModel owner, Item item) : base(owner, item)
     {
     }
Beispiel #12
0
 internal PropertyCheckModel_618(LineModel owner, Item item, Property prop) : base(owner, item, prop)
 {
 }
Beispiel #13
0
 public async Task <double> MinutesBeyondLimit(LineModel line, PackageIncludesModel packageIncludes)
 {
     return(await invoice.GetNumberOfMinutesAsync(line.ToDto1(), packageIncludes.ToDto1()));
 }
Beispiel #14
0
 public async Task <double> GetMinutesLeft(PackageIncludesModel packageIncludes, LineModel line)
 {
     return(await invoice.CalculateNumberOfMinutesLeftInPackageAsync(packageIncludes.MaxMinute, line.ToDto1()));
 }
Beispiel #15
0
 public static void UpdateLine(LineModel nextLine, Vec <Coordinate> focusPosition)
 {
     nextLine.P1 = focusPosition;
 }
Beispiel #16
0
 private void UpdateLineModel(LineModel lineModel)
 {
     _lineModel = lineModel;
 }
Beispiel #17
0
 public static void AbortLine(LineModel nextLine)
 {
     nextLine.P0.ForEach(c => c.UnregisterGeometryAndTryToDelete(nextLine));
 }
        private void SetLinesWithoutObstacles(Dictionary <int, Connection> connections)
        {
            var gridCopy = Grid.Clone() as int[, ];

            foreach (var connectionWithId in connections)
            {
                int x1 = 0, x2 = 0, y1 = 0, y2 = 0;

                for (int i = 0; i < gridCopy.GetLength(0); i++)
                {
                    for (int j = 0; j < gridCopy.GetLength(1); j++)
                    {
                        if (gridCopy[i, j] == connectionWithId.Value.GetFirstNodeId())
                        {
                            gridCopy[i, j] = 1;
                            x1             = i;
                            y1             = j;
                        }
                        else if (gridCopy[i, j] == connectionWithId.Value.GetSecondNodeId())
                        {
                            gridCopy[i, j] = 2;
                            x2             = i;
                            y2             = j;
                        }
                        else if (gridCopy[i, j] > 0)
                        {
                            gridCopy[i, j] = int.MaxValue;
                        }
                    }
                }

                LineModel newLine = null;
                int[][]   moves1  = null;
                int[][]   moves2  = null;

                if (x1 > x2 && y1 >= y2)
                {
                    moves1 = MovesProvider.UpLeft;
                    moves2 = MovesProvider.LeftUp;
                }
                else if (x1 > x2 && y1 < y2)
                {
                    moves1 = MovesProvider.UpRight;
                    moves2 = MovesProvider.RightUp;
                }
                else if (x1 <= x2 && y1 >= y2)
                {
                    moves1 = MovesProvider.DownLeft;
                    moves2 = MovesProvider.LeftDown;
                }
                else if (x1 <= x2 && y1 < y2)
                {
                    moves1 = MovesProvider.DownRight;
                    moves2 = MovesProvider.RightDown;
                }

                var optTurns = Math.Abs(x1 - x2) == 0 || Math.Abs(y1 - y2) == 0 ? 0 : 1;

                newLine = new LeeAlgorithmInterpreter().DoYourJob(gridCopy, moves1, moves2, (Math.Abs(x1 - x2) + Math.Abs(y1 - y2)) + 4, optTurns, connectionWithId.Key, x1, y1, x2, y2);
                if (newLine.GetPointsOfLine().Count != 0)
                {
                    Lines.Add(newLine);
                    if (!newLine.IsReversed)
                    {
                        newLine.AddPointAtStartOfLine(x1, y1);
                    }
                    else
                    {
                        newLine.AddPointAtEndOfLine(x2, y2);
                    }
                }
            }
        }
Beispiel #19
0
        public static void Initialize(FactoryContext context)
        {
            context.Database.EnsureCreated();

            if (context.Lines.Any())
            {
                return;
            }

            var lines = new LineModel[]
            {
                new LineModel {
                    Name = "A"
                },
                new LineModel {
                    Name = "B"
                },
                new LineModel {
                    Name = "C"
                },
                new LineModel {
                    Name = "D"
                },
                new LineModel {
                    Name = "E"
                },
                new LineModel {
                    Name = "F"
                }
            };

            foreach (LineModel l in lines)
            {
                context.Lines.Add(l);
            }
            context.SaveChanges();


            if (context.Users.Any())
            {
                return;
            }

            var users = new UserModel[]
            {
                new UserModel {
                    Name = "Matej", LineID = 1
                },
                new UserModel {
                    Name = "Petr", LineID = 2
                },
            };

            foreach (UserModel u in users)
            {
                context.Users.Add(u);
            }
            context.SaveChanges();

            var buggies = new BuggyModel[]
            {
                new BuggyModel {
                    BuggyID = 150, Name = "A1"
                },
                new BuggyModel {
                    BuggyID = 250, Name = "B1"
                },
                new BuggyModel {
                    BuggyID = 350, Name = "A2"
                },
                new BuggyModel {
                    BuggyID = 450, Name = "A3"
                },
                new BuggyModel {
                    BuggyID = 550, Name = "A5"
                },
                new BuggyModel {
                    BuggyID = 650, Name = "B3"
                }
            };

            foreach (BuggyModel b in buggies)
            {
                context.Buggies.Add(b);
            }
            context.SaveChanges();

            var routes = new RouteModel[]
            {
                new RouteModel {
                    LineID = 1, BuggyID = 150
                },
                new RouteModel {
                    LineID = 1, BuggyID = 250
                },
                new RouteModel {
                    LineID = 1, BuggyID = 350
                },
                new RouteModel {
                    LineID = 4, BuggyID = 450
                },
                new RouteModel {
                    LineID = 5, BuggyID = 550
                },
                new RouteModel {
                    LineID = 6, BuggyID = 650
                },
                new RouteModel {
                    LineID = 2, BuggyID = 250
                },
                new RouteModel {
                    LineID = 3, BuggyID = 350
                },
                new RouteModel {
                    LineID = 6, BuggyID = 150
                },
            };

            foreach (RouteModel r in routes)
            {
                context.Routes.Add(r);
            }
            context.SaveChanges();
        }
Beispiel #20
0
        public static JsonModel Get_Globe_Helper(string Type)
        {
            JsonModel jsm = null;

            try
            {
                GlobeClueType GlobeClueType  = (GlobeClueType)Enum.Parse(typeof(GlobeClueType), Type);
                object        Globe_ClueBase = null;//获取
                switch (GlobeClueType)
                {
                case GlobeClueType.Special:
                    Globe_ClueBase = SpecialModel.Get_Globe(Constant.Globe_Clue_List, Constant.Globe_List, Constant.Size_Special_List);
                    break;

                case GlobeClueType.Normal:
                    Globe_ClueBase = NormalModel.Get_Globe(Constant.Globe_Clue_List, Constant.Globe_List);    //获取
                    break;

                case GlobeClueType.SpecialNormal:
                    Globe_ClueBase = SpecialNormalModel.Get_Globe(Constant.Globe_Clue_List, Constant.Globe_List, Constant.Size_SpecialNormal_List);    //获取
                    break;

                case GlobeClueType.NormalSix:
                    Globe_ClueBase = NormalSixModel.Get_Globe(Constant.Globe_Clue_List, Constant.Size_Six_List);    //获取
                    break;

                case GlobeClueType.Line:
                    Globe_ClueBase = LineModel.Get_Globe(Constant.Globe_Clue_List, Constant.Globe_List);    //获取
                    break;

                case GlobeClueType.Wave:
                    Globe_ClueBase = WaveModel.Get_Globe(Constant.Globe_Clue_List, Constant.Wave_List, Constant.Globe_List);    //获取
                    break;

                case GlobeClueType.Detail:
                    Globe_ClueBase = DetailModel.Get_Globe(Constant.Globe_Clue_List, Constant.Animal_Info_List, Constant.Globe_List, Constant.Detail_List);    //获取
                    break;

                case GlobeClueType.SpecialAnimal:
                    Globe_ClueBase = SpecialAnimalModel.Get_Globe(Constant.Globe_Clue_List, Constant.Animal_Info_List, Constant.Globe_List);    //获取
                    break;

                case GlobeClueType.CombineAnimal:
                    Globe_ClueBase = CombineAnimalModel.Get_Globe(Constant.Globe_Clue_List, Constant.Animal_Info_List, Constant.Globe_List);    //获取
                    break;

                case GlobeClueType.LineAnimal:
                    Globe_ClueBase = LineAnimalModel.Get_Globe(Constant.Globe_Clue_List, Constant.Animal_Info_List, Constant.Globe_List);    //获取
                    break;

                case GlobeClueType.LineDetail:
                    Globe_ClueBase = LineDetaillModel.Get_Globe(Constant.Globe_Clue_List, Constant.Globe_List, Constant.Detail_List);    //获取
                    break;

                case GlobeClueType.NotAll:
                    Globe_ClueBase = NotAllModel.Get_Globe(Constant.Globe_Clue_List, Constant.Globe_List);    //获取
                    break;

                default:
                    break;
                }
                jsm = JsonModel.GetJsonModel(0, "successed", Globe_ClueBase);
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return(jsm);
        }
Beispiel #21
0
        public static PolyLineModel Polyline2Model(Autodesk.AutoCAD.DatabaseServices.Polyline polyLine)
        {
            PolyLineModel polylineModel = new PolyLineModel();

            polylineModel.individualName   = "";
            polylineModel.individualFactor = "";
            polylineModel.individualCode   = "";
            polylineModel.individualStage  = "";

            // 增加个体编码、个体要素、个体名称
            System.Data.DataTable tb = Method.AutoGenerateNumMethod.GetAllPolylineNumsEx(polyLine);
            if (tb.Rows != null && tb.Rows.Count > 0)
            {
                foreach (System.Data.DataRow row in tb.Rows)
                {
                    if ((string)row["多段线id"] == polyLine.Id.Handle.Value.ToString())
                    {
                        polylineModel.individualName   = (string)row["个体名称"];
                        polylineModel.individualFactor = (string)row["个体要素"];
                        polylineModel.individualCode   = (string)row["个体编码"];
                        polylineModel.individualStage  = (string)row["个体阶段"];
                    }
                }
            }

            polylineModel.Area     = polyLine.Area;
            polylineModel.Closed   = polyLine.Closed;
            polylineModel.Color    = polyLine.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(polyLine.LayerId) : System.Drawing.ColorTranslator.ToHtml(polyLine.Color.ColorValue);
            polylineModel.Vertices = new System.Collections.ArrayList();
            int vn = polyLine.NumberOfVertices;  //lwp已知的多段线

            //if(polylineModel.Closed)
            //{
            //    for (int i = 0; i < vn; i++)
            //    {
            //        Point2d pt = polyLine.GetPoint2dAt(i);

            //        PointF ptf = new PointF((float)pt.X, (float)pt.Y);

            //        polylineModel.Vertices.Add(ptf);
            //    }
            //}
            //else
            //{


            for (int i = 0; i < vn; i++)
            {
                Point2d     pt = polyLine.GetPoint2dAt(i);
                SegmentType st = polyLine.GetSegmentType(i);
                if (st == SegmentType.Arc)
                {
                    ArcModel      arc = new ArcModel();
                    CircularArc2d cir = polyLine.GetArcSegment2dAt(i);
                    //  arc.Center = new System.Drawing.PointF((float)cir.Center.X,(float)cir.Center.Y);
                    arc.Center     = Point2d2Pointf(cir.Center);
                    arc.Radius     = cir.Radius;
                    arc.Startangel = cir.StartAngle;
                    arc.EndAngel   = cir.EndAngle;
                    //  arc.StartPoint = new System.Drawing.PointF((float)cir.StartPoint.X, (float)cir.StartPoint.Y);
                    if (cir.HasStartPoint)
                    {
                        arc.StartPoint = Point2d2Pointf(cir.StartPoint);
                    }
                    //  arc.EndPoint = new System.Drawing.PointF((float)cir.EndPoint.X, (float)cir.EndPoint.Y);
                    if (cir.HasEndPoint)
                    {
                        arc.EndPoint = Point2d2Pointf(cir.EndPoint);
                    }


                    MyPoint spt    = new MyPoint(arc.StartPoint.X, arc.StartPoint.Y);
                    MyPoint ept    = new MyPoint(arc.EndPoint.X, arc.EndPoint.Y);
                    MyPoint center = new MyPoint(arc.Center.X, arc.Center.Y);
                    arc.Color = polylineModel.Color;
                    // arc.pointList = MethodCommand.GetRoationPoint(spt, ept, center, arc.Startangel,arc.EndAngel,cir.IsClockWise);
                    arc.pointList = MethodCommand.GetArcPointsByPoint2d(cir.GetSamplePoints(20));
                    //arc.pointList = MethodCommand.GetArcPoints(arc.Center,arc.Startangel,arc.EndAngel,arc.Radius);
                    //  arc.pointList.Insert(0, arc.StartPoint);
                    //   arc.pointList.Add(arc.EndPoint);
                    polylineModel.Vertices.Add(arc);
                }
                else if (st == SegmentType.Line)
                {
                    LineModel     line   = new LineModel();
                    LineSegment2d lineSe = polyLine.GetLineSegment2dAt(i);
                    if (lineSe.HasStartPoint)
                    {
                        line.StartPoint = Point2d2Pointf(lineSe.StartPoint);
                    }
                    if (lineSe.HasEndPoint)
                    {
                        line.EndPoint = Point2d2Pointf(lineSe.EndPoint);
                    }
                    if (line.StartPoint.X == line.EndPoint.X && line.StartPoint.Y == line.EndPoint.Y)
                    {
                        line.Angle  = 0;
                        line.Length = 0;
                    }
                    else if (line.StartPoint.X == line.EndPoint.X)
                    {
                        line.Angle = 90;
                    }
                    line.Color = polylineModel.Color;
                    polylineModel.Vertices.Add(line);
                }
            }
            //}
            polylineModel.isDashed = GetLayerLineTypeByIDEx(polyLine);
            return(polylineModel);
        }
Beispiel #22
0
        public string NextQuestion(string userId, string msg)
        {
            var reply = "";

            using (var db = new LineModel())
            {
                var current_question = db.QuestionProcess.Where(x => x.UserId == userId).SingleOrDefault();
                int movie_next_order = current_question.M_Order + 1;

                if (!msg.ToLower().Contains("取消"))
                {
                    switch (current_question.M_Order)
                    {
                    case 1:
                        if (msg == "威秀" || msg == "國賓")
                        {
                            current_question.M_Order = movie_next_order;
                            current_question.Answer += msg;
                            reply = db.MovieQuestion.Where(x => x.Id == movie_next_order).SingleOrDefault().M_Question + "," + movie_next_order + "," + MovieKeys[msg];
                        }
                        else
                        {
                            reply = "請點選下方之選項!,1";
                            current_question.ErrorCount += 1;
                        }

                        break;

                    case 2:
                        switch (current_question.Answer)
                        {
                        case "威秀":
                            if (!vsMovieDict.ContainsKey(msg))
                            {
                                reply = "請選擇當前有的選項!,2,VS";
                                current_question.ErrorCount += 1;
                            }
                            else
                            {
                                current_question.M_Order = movie_next_order;
                                current_question.Answer += "," + msg;
                                reply = db.MovieQuestion.Where(x => x.Id == movie_next_order).SingleOrDefault().M_Question + "," + movie_next_order + ",VS";
                            }
                            break;

                        case "國賓":
                            if (msg == "新莊" || msg == "林口")
                            {
                                msg = msg + "國賓";
                            }
                            if (atMovieDict.ContainsKey(msg))
                            {
                                current_question.M_Order = movie_next_order;
                                current_question.Answer += "," + msg;
                                reply = db.MovieQuestion.Where(x => x.Id == movie_next_order).SingleOrDefault().M_Question + "," + movie_next_order + ",AT";
                            }
                            else
                            {
                                reply = "請選擇當前有的選項!,2,AT";
                                current_question.ErrorCount += 1;
                            }
                            break;
                        }

                        break;

                    case 3:
                        if (msg.Length < 2)
                        {
                            return("重新輸入一次。請輸入長度至少二字以上查詢電影!或輸入'取消'結束對話。,-1");
                        }
                        var movie_str = "";
                        answerArr = current_question.Answer.Split(',');

                        switch (answerArr[0])
                        {
                        case "威秀":
                            movie_str = GetVSMovieTime(answerArr[1], msg);
                            break;

                        case "國賓":
                            movie_str = GetATMovieTimeAsync(answerArr[1], msg);
                            break;
                        }

                        if (movie_str != "")
                        {
                            reply += movie_str + ",-1";
                            db.QuestionProcess.Remove(current_question);
                        }
                        else
                        {
                            reply = $"關鍵字'{msg}'查無結果請重新輸入。或輸入'取消'結束對話,-1";
                        }
                        break;

                    default:
                        reply = "ERROR";
                        break;
                    }
                    if (current_question.ErrorCount > 3)
                    {
                        reply = "錯誤次數過多,請重新呼叫一次,-1";
                        db.QuestionProcess.Remove(current_question);
                    }
                }
                else
                {
                    reply = "break!,-1";
                    db.QuestionProcess.Remove(current_question);
                }
                db.SaveChanges();
            }
            return(reply);
        }
Beispiel #23
0
        public static LineModel Line2Model(Line line, AttributeModel atModel)
        {
            LineModel dbModel = new LineModel();

            dbModel.StartPoint = Point3d2Pointf(line.StartPoint);

            dbModel.EndPoint = Point3d2Pointf(line.EndPoint);

            dbModel.Angle = line.Angle;

            dbModel.Length = line.Length;
            dbModel.Color  = line.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(line.LayerId) : System.Drawing.ColorTranslator.ToHtml(line.Color.ColorValue);
            foreach (AttributeItemModel item in atModel.attributeItems)
            {
                string attValue = "";

                switch (item.AtItemType)
                {
                case AttributeItemType.Area:

                    break;

                case AttributeItemType.TxtHeight:

                    break;

                case AttributeItemType.Color:
                    attValue = dbModel.Color;
                    break;

                case AttributeItemType.Content:

                    break;

                case AttributeItemType.LayerName:
                    attValue = line.Layer;
                    break;

                case AttributeItemType.LineScale:
                    attValue = line.LinetypeScale.ToString();
                    break;

                case AttributeItemType.LineType:
                    attValue = GetLayerLineTypeByID(line);
                    break;

                case AttributeItemType.Overallwidth:

                    break;

                case AttributeItemType.TotalArea:

                    break;
                }
                if (!string.IsNullOrEmpty(attValue))
                {
                    item.AtValue = attValue;
                    dbModel.attItemList.Add(item);
                }
            }
            return(dbModel);
        }
Beispiel #24
0
        private void bwLoadData_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            string version = AssemblyHelper.Version();

            miRequestList.Visibility = Visibility.Collapsed;
            if (section.SectionId == "F")
            {
                this.Title = string.Format("Assembly Incentives - {0}", version);
                miAssemblyReportIncentives.IsEnabled = true;
            }
            if (section.SectionId == "E")
            {
                this.Title = string.Format("Sewing Incentives - {0}", version);
            }
            if (section.SectionId == "B" || section.SectionId == "C")
            {
                this.Title = string.Format("Cut-Prep Incentives - {0}", version);
            }
            if (section.SectionId == "G")
            {
                this.Title = string.Format("Outsole Incentives - {0}", version);
            }
            if (section.SectionId == "IE")
            {
                miRequestList.Visibility = Visibility.Visible;
            }
            int countColumn = gridLine.ColumnDefinitions.Count();
            int countRow    = countRow = lineList.Count / countColumn;

            if (lineList.Count % countColumn != 0)
            {
                countRow = lineList.Count / countColumn + 1;
            }
            gridLine.RowDefinitions.Clear();
            for (int i = 1; i <= countRow; i++)
            {
                RowDefinition rd = new RowDefinition
                {
                    Height = new GridLength(1, GridUnitType.Star),
                };
                gridLine.RowDefinitions.Add(rd);
            }

            for (int i = 0; i <= lineList.Count() - 1; i++)
            {
                LineModel line    = lineList[i];
                Button    btnLine = new Button();
                Grid.SetColumn(btnLine, i % countColumn);
                Grid.SetRow(btnLine, i / countColumn);
                btnLine.Margin     = new Thickness(3, 1, 3, 1);
                btnLine.Content    = String.Format("LINE {0}", line.Name);
                btnLine.Tag        = line;
                btnLine.ToolTip    = String.Format("Log-in to LINE {0}", line.Name);
                btnLine.Background = Brushes.RoyalBlue;
                btnLine.Foreground = Brushes.White;
                btnLine.FontWeight = FontWeights.Bold;
                btnLine.Click     += new RoutedEventHandler(btnLine_Click);
                gridLine.Children.Add(btnLine);
            }

            foreach (WorkerLoginModel workerLogin in workerLoginList)
            {
                PersonalModel personal = personalList.Where(p => p.CardId == workerLogin.CardId || p.WorkerId == workerLogin.WorkerId).FirstOrDefault();
                if (personal != null)
                {
                    WorkerLoginViewModel workerLoginView = new WorkerLoginViewModel
                    {
                        CardId   = personal.CardId,
                        WorkerId = personal.WorkerId,
                        Name     = personal.Name,
                        Line     = personal.Department,
                        LineWork = workerLogin.LineId,
                        Position = personal.Position,
                    };
                    workerLoginViewList.Add(workerLoginView);
                }
            }
            dgWorkerLogin.ItemsSource = workerLoginViewList;
            txtCardId.IsEnabled       = true;
            this.Cursor = null;
        }
Beispiel #25
0
        public static PolyLineModel Polyline2Model(Autodesk.AutoCAD.DatabaseServices.Polyline polyLine, AttributeModel atModel)
        {
            PolyLineModel polylineModel = new PolyLineModel();

            polylineModel.individualName   = "";
            polylineModel.individualFactor = "";
            polylineModel.individualCode   = "";
            polylineModel.individualStage  = "";

            // 增加个体编码、个体要素、个体名称
            System.Data.DataTable tb = Method.AutoGenerateNumMethod.GetAllPolylineNumsEx(polyLine);
            if (tb.Rows != null && tb.Rows.Count > 0)
            {
                foreach (System.Data.DataRow row in tb.Rows)
                {
                    if ((string)row["多段线id"] == polyLine.Id.Handle.Value.ToString())
                    {
                        polylineModel.individualName   = (string)row["个体名称"];
                        polylineModel.individualFactor = (string)row["个体要素"];
                        polylineModel.individualCode   = (string)row["个体编码"];
                        polylineModel.individualStage  = (string)row["个体阶段"];
                    }
                }
            }
            polylineModel.Area     = polyLine.Area;
            polylineModel.Closed   = polyLine.Closed;
            polylineModel.Color    = polyLine.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(polyLine.LayerId) : System.Drawing.ColorTranslator.ToHtml(polyLine.Color.ColorValue);
            polylineModel.Vertices = new System.Collections.ArrayList();
            int vn = polyLine.NumberOfVertices;  //lwp已知的多段线

            for (int i = 0; i < vn; i++)
            {
                Point2d     pt = polyLine.GetPoint2dAt(i);
                SegmentType st = polyLine.GetSegmentType(i);
                if (st == SegmentType.Arc)
                {
                    ArcModel      arc = new ArcModel();
                    CircularArc2d cir = polyLine.GetArcSegment2dAt(i);
                    //  arc.Center = new System.Drawing.PointF((float)cir.Center.X,(float)cir.Center.Y);
                    arc.Center     = Point2d2Pointf(cir.Center);
                    arc.Radius     = cir.Radius;
                    arc.Startangel = cir.StartAngle;
                    arc.EndAngel   = cir.EndAngle;
                    //  arc.StartPoint = new System.Drawing.PointF((float)cir.StartPoint.X, (float)cir.StartPoint.Y);
                    if (cir.HasStartPoint)
                    {
                        arc.StartPoint = Point2d2Pointf(cir.StartPoint);
                    }
                    //  arc.EndPoint = new System.Drawing.PointF((float)cir.EndPoint.X, (float)cir.EndPoint.Y);
                    if (cir.HasEndPoint)
                    {
                        arc.EndPoint = Point2d2Pointf(cir.EndPoint);
                    }


                    MyPoint spt    = new MyPoint(arc.StartPoint.X, arc.StartPoint.Y);
                    MyPoint ept    = new MyPoint(arc.EndPoint.X, arc.EndPoint.Y);
                    MyPoint center = new MyPoint(arc.Center.X, arc.Center.Y);
                    arc.Color = polylineModel.Color;
                    // arc.pointList = MethodCommand.GetRoationPoint(spt, ept, center, arc.Startangel,arc.EndAngel,cir.IsClockWise);
                    arc.pointList = MethodCommand.GetArcPointsByPoint2d(cir.GetSamplePoints(20));
                    //arc.pointList = MethodCommand.GetArcPoints(arc.Center,arc.Startangel,arc.EndAngel,arc.Radius);
                    //  arc.pointList.Insert(0, arc.StartPoint);
                    //   arc.pointList.Add(arc.EndPoint);
                    foreach (AttributeItemModel item in atModel.attributeItems)
                    {
                        string attValue = "";

                        switch (item.AtItemType)
                        {
                        case AttributeItemType.Area:
                            attValue = polyLine.Area.ToString();
                            break;

                        case AttributeItemType.TxtHeight:

                            break;

                        case AttributeItemType.Color:
                            attValue = polylineModel.Color;
                            break;

                        case AttributeItemType.Content:

                            break;

                        case AttributeItemType.LayerName:
                            attValue = polyLine.Layer;
                            break;

                        case AttributeItemType.LineScale:
                            attValue = polyLine.LinetypeScale.ToString();
                            break;

                        case AttributeItemType.LineType:
                            attValue = GetLayerLineTypeByID(polyLine);
                            break;

                        case AttributeItemType.Overallwidth:
                            attValue = polyLine.ConstantWidth.ToString();
                            break;

                        case AttributeItemType.TotalArea:

                            break;
                        }
                        if (!string.IsNullOrEmpty(attValue))
                        {
                            item.AtValue = attValue;
                            arc.attItemList.Add(item);
                        }
                    }
                    polylineModel.Vertices.Add(arc);
                }
                else if (st == SegmentType.Line)
                {
                    LineModel     line   = new LineModel();
                    LineSegment2d lineSe = polyLine.GetLineSegment2dAt(i);
                    if (lineSe.HasStartPoint)
                    {
                        line.StartPoint = Point2d2Pointf(lineSe.StartPoint);
                    }
                    if (lineSe.HasEndPoint)
                    {
                        line.EndPoint = Point2d2Pointf(lineSe.EndPoint);
                    }
                    if (line.StartPoint.X == line.EndPoint.X && line.StartPoint.Y == line.EndPoint.Y)
                    {
                        line.Angle  = 0;
                        line.Length = 0;
                    }
                    else if (line.StartPoint.X == line.EndPoint.X)
                    {
                        line.Angle = 90;
                    }
                    line.Color = polylineModel.Color;
                    foreach (AttributeItemModel item in atModel.attributeItems)
                    {
                        string attValue = "";

                        switch (item.AtItemType)
                        {
                        case AttributeItemType.Area:
                            attValue = polyLine.Area.ToString();
                            break;

                        case AttributeItemType.TxtHeight:

                            break;

                        case AttributeItemType.Color:
                            attValue = polylineModel.Color;
                            break;

                        case AttributeItemType.Content:

                            break;

                        case AttributeItemType.LayerName:
                            attValue = polyLine.Layer;
                            break;

                        case AttributeItemType.LineScale:
                            attValue = polyLine.LinetypeScale.ToString();
                            break;

                        case AttributeItemType.LineType:
                            attValue = GetLayerLineTypeByID(polyLine);
                            break;

                        case AttributeItemType.Overallwidth:
                            attValue = polyLine.ConstantWidth.ToString();
                            break;

                        case AttributeItemType.TotalArea:

                            break;
                        }

                        item.AtValue = attValue;
                        line.attItemList.Add(item);
                    }
                    polylineModel.Vertices.Add(line);
                }
            }

            return(polylineModel);
        }
Beispiel #26
0
 internal void Initialize(LineModel model, int index)
 {
     Model     = model;
     PropModel = model as PropertyModel;
     ValidateStackPanel(index);
 }
Beispiel #27
0
        public override void Run()
        {
            var hullAlg = new GrahamScanAlgorithm();

            // 30, 30
            // -20, 50
            // -30, -20
            // 10, -60
            // 30, -30

            //var list = new List<Vector>();

            //list.Add(new Vector { X = 30, Y = 30 });
            //list.Add(new Vector { X = -20, Y = 50 });
            //list.Add(new Vector { X = -30, Y = -20 });
            //list.Add(new Vector { X = 10, Y = -60 });
            //list.Add(new Vector { X = 30, Y = -30 });

            hullAlg.SetInputPoints(InputPoints);

            hullAlg.Run();

            //Console.WriteLine("poly: " + hullAlg.Hull);

            hull = new List <Vector>();

            foreach (var line in hullAlg.Hull.Lines)
            {
                hull.Add(new Vector {
                    X = line.StartPoint.X, Y = line.StartPoint.Y
                });
            }
            //hull.Add(new Vector { X = hullAlg.Hull.Lines[0].StartPoint.X, Y = hullAlg.Hull.Lines[0].StartPoint.Y });

            //hull.Reverse();

            Result = FindSmallestBoundingBox();

            var layer = History.CreateAndAddNewLayer("Final Result");

            //  (-20 0 ) ,(14.3396 -9.81132 ), (0 -60 ) ,(-34.3396 -50.1887 )

            Result.Corners[0].X = -20;
            Result.Corners[0].Y = 0;

            Result.Corners[1].X = 14.3396;
            Result.Corners[1].Y = -9.81132;

            Result.Corners[2].X = 0;
            Result.Corners[2].Y = -60;

            Result.Corners[3].X = -34.3396;
            Result.Corners[3].Y = -50.1887;

            // 0 to 2
            // 2 to

            for (int i = 0; i < 4; i++)
            {
                LineModel line = new LineModel
                {
                    StartPoint = new Vector {
                        X = Result.Corners[i].X, Y = Result.Corners[i].Y
                    },
                    EndPoint = new Vector {
                        X = Result.Corners[(i + 1) % 4].X, Y = Result.Corners[(i + 1) % 4].Y
                    }
                };

                layer.AddCommand(new AddNonIndexedLineCommand
                {
                    StartX = line.StartPoint.X,
                    StartY = line.StartPoint.Y,
                    EndX   = line.EndPoint.X,
                    EndY   = line.EndPoint.Y
                });
            }
        }
Beispiel #28
0
 public void SaveLine(LineModel line)
 {
     _cacheStoreHelper.Remove("line");
     _cacheStoreHelper.Add("line", line);
 }
Beispiel #29
0
        public void Refresh(LineModel lineModel)
        {
            _emitEvent = false;
            _lineModel = lineModel;
            _titleInputField.inputField.text = lineModel.DisplayName;
            _layerSlider.slider.value        = lineModel.Layer;

            _emissionSwitch.toggle.isOn               = lineModel.IsEmissionEnabled;
            _brushEmissionSlider.slider.value         = lineModel.EmissionIntensity;
            _brushEmissionColorButton.backgroundColor = lineModel.EmissionColor;

            _audioPanel.SetActive(lineModel.Shape != Shape.Phyllotaxis);
            _phyllotaxisPanel.SetActive(lineModel.Shape == Shape.Phyllotaxis);

            _emissionReactSwitch.toggle.isOn             = lineModel.EmissionProperty.IsEmissionReactOnAudio;
            _emissionThresholdSlider.slider.value        = (lineModel.EmissionProperty.EmissionThreshold);
            _emissionBandBufferSlider.slider.value       = (lineModel.EmissionProperty.EmissionBandBuffer);
            _emissionFrequencyDropdown.currentlySelected = (int)lineModel.EmissionProperty.EmissionFrequencyType;

            _scaleReactSwitch.toggle.isOn       = lineModel.ScaleProperty.IsScaleReactOnAudio;
            _scaleMultiplierSlider.slider.value = (lineModel.ScaleProperty.ScaleMultiplier);
            _scaleBandBufferSlider.slider.value = (lineModel.ScaleProperty.ScaleBandBuffer);

            _brushEmissionSlider.gameObject.SetActive(lineModel.IsEmissionEnabled);
            _emissionThresholdSlider.gameObject.SetActive(lineModel.EmissionProperty.IsEmissionReactOnAudio);
            _emissionBandBufferSlider.gameObject.SetActive(lineModel.EmissionProperty.IsEmissionReactOnAudio);
            _emissionFrequencyDropdown.gameObject.SetActive(lineModel.EmissionProperty.IsEmissionReactOnAudio);

            _scaleMultiplierSlider.gameObject.SetActive(lineModel.ScaleProperty.IsScaleReactOnAudio);
            _scaleBandBufferSlider.gameObject.SetActive(lineModel.ScaleProperty.IsScaleReactOnAudio);
            _scaleThresholdSlider.gameObject.SetActive(lineModel.ScaleProperty.IsScaleReactOnAudio);
            _scaleFrequencyDropdown.gameObject.SetActive(lineModel.ScaleProperty.IsScaleReactOnAudio);

            _kochReactSwitch.toggle.isOn = lineModel.KochLineProperty.IsKochEnabled;
            _kochReactSwitch.gameObject.SetActive(lineModel.Shape != Shape.Line);

            _startGenerationList.transform.parent.parent.gameObject.SetActive(lineModel.Shape != Shape.Line && lineModel.KochLineProperty.IsKochEnabled);
            _audioBandLayoutGroup.transform.parent.parent.gameObject.SetActive(lineModel.Shape != Shape.Line && lineModel.KochLineProperty.IsKochEnabled);

            _trailSwitch.toggle.isOn = _lineModel.KochTrailProperty.IsTrailEnabled;
            _trailSwitch.gameObject.SetActive(lineModel.Shape != Shape.Line && lineModel.KochLineProperty.IsKochEnabled);

            _trailsMinMaxParent.gameObject.SetActive(lineModel.Shape != Shape.Line && lineModel.KochLineProperty.IsKochEnabled && lineModel.KochTrailProperty.IsTrailEnabled);
            _trailMinSpeedSlider.slider.value = (lineModel.KochTrailProperty.TrailSpeedMinMax.x);
            _trailMaxSpeedSlider.slider.value = (lineModel.KochTrailProperty.TrailSpeedMinMax.y);

            _trailMinTimeSlider.slider.value = (lineModel.KochTrailProperty.TrailTimeMinMax.x);
            _trailMaxTimeSlider.slider.value = (lineModel.KochTrailProperty.TrailTimeMinMax.y);

            _trailMinWidthSlider.slider.value = (lineModel.KochTrailProperty.TrailWidthMinMax.x);
            _trailMaxWidthSlider.slider.value = (lineModel.KochTrailProperty.TrailWidthMinMax.y);

            _degreeSlider.slider.value       = lineModel.PhyllotaxisProperty.Degree;
            _scaleSlider.slider.value        = lineModel.PhyllotaxisProperty.Scale;
            _numberStartSlider.slider.value  = lineModel.PhyllotaxisProperty.NumberStart;
            _stepSizeSlider.slider.value     = lineModel.PhyllotaxisProperty.StepSize;
            _maxIterationSlider.slider.value = lineModel.PhyllotaxisProperty.MaxIterations;

            _useLerpingCheckbox.toggle.isOn          = lineModel.PhyllotaxisProperty.UseLerping;
            _lerpFrequencyDropdown.currentlySelected = (int)lineModel.PhyllotaxisProperty.LerpFrequencyType;
            _lerpBandSlider.slider.value             = lineModel.PhyllotaxisProperty.LerpAudioBand;
            _speedMinSlider.slider.value             = lineModel.PhyllotaxisProperty.SpeedMinMax.x;
            _speedMaxSlider.slider.value             = lineModel.PhyllotaxisProperty.SpeedMinMax.y;
            _repeatCheckbox.toggle.isOn = lineModel.PhyllotaxisProperty.Repeat;
            _invertCheckbox.toggle.isOn = lineModel.PhyllotaxisProperty.Invert;

            _useScaleCheckbox.toggle.isOn = lineModel.PhyllotaxisProperty.UseScaling;
            _scalePhylloFrequencyDropdown.currentlySelected = (int)lineModel.PhyllotaxisProperty.ScaleFrequencyType;
            _scaleBandSlider.slider.value      = lineModel.PhyllotaxisProperty.ScaleAudioBand;
            _scaleMinSlider.slider.value       = lineModel.PhyllotaxisProperty.ScaleMinMax.x;
            _scaleMaxSlider.slider.value       = lineModel.PhyllotaxisProperty.ScaleMinMax.y;
            _useScaleCurveCheckbox.toggle.isOn = lineModel.PhyllotaxisProperty.UseScaleCurve;
            _scaleSpeedSlider.slider.value     = lineModel.PhyllotaxisProperty.InterpolationSpeed;

            _audioBands.Clear();
            int audioBandSliderToGenerate = (int)lineModel.Shape + 2;

            foreach (Transform child in _audioBandLayoutGroup.transform)
            {
                Destroy(child.gameObject);
            }

            if (lineModel.Shape != Shape.Phyllotaxis)
            {
                for (int i = 0; i < audioBandSliderToGenerate; i++)
                {
                    MaterialSlider slider = Instantiate(_audioBandSlider, _audioBandLayoutGroup.transform, false);
                    slider.leftContentTransform.GetComponentInChildren <Text>().text = i.ToString();
                    slider.slider.value = (lineModel.KochLineProperty.KochAudioBand[i]);
                    slider.slider.onValueChanged.AddListener(OnAudioBandValueChanged);
                    _audioBands.Add(slider);
                }
            }

            RefreshKochStartGeneration();
            _emitEvent = true;
            UpdateGradient(lineModel.Gradient);
            LayoutRebuilder.ForceRebuildLayoutImmediate(_verticalLayoutGroup.GetComponent <RectTransform>());
        }
Beispiel #30
0
 private void OnBrushGradientRequested(LineModel lineModel)
 {
     UpdateGradientSignal.Dispatch(lineModel);
 }
Beispiel #31
0
        /// <summary>
        /// 返回结果,直接写入数据库(alarm,alarm_log,line)
        /// </summary>
        /// <param name="id">线路Id</param>
        /// <param name="pingState"></param>
        public void WriteAlarmToDB(int id, PingState pingState)
        {
            lock (_lock)
            {
                try
                {
                    if (!_catch.ContainsKey(id))
                    {
                        _catch.Add(id, new LineAlarmCache()
                        {
                            Alarm = null, Count = 0
                        });
                    }

                    if (!pingState.State)
                    {
                        _catch[id].Count++;
                        if (_catch[id].Alarm == null)
                        {
                            LineModel line = new LineBusiness().GetItem(id);
                            if (_catch[id].Count >= line.AlarmMax)
                            {
                                _catch[id].Alarm = new AlarmModel()
                                {
                                    AlarmCount = 1,
                                    Confirm    = false,
                                    FirstTime  = pingState.CollectTime,
                                    IP         = line.LineIP,
                                    LineId     = line.Id,
                                    LineName   = line.Name,
                                    OrganId    = line.OrganizationId,
                                    OrganName  = line.OrganizationName,
                                    State      = AlarmStateType.OnAlarm,
                                    LastTime   = pingState.CollectTime,
                                    Type       = AlarmType.LineNotConnected
                                };
                                //状态改为 正在告警
                                MonitorADOProvider.GetInstance().InsertAlarm(_catch[id].Alarm);
                                SendMessage?.Invoke(_catch[id].Alarm, line.SMSTelphone);
                            }
                        }
                        else
                        {
                            if (_catch[id].Alarm.Id == 0)
                            {
                                _catch[id].Alarm = MonitorADOProvider.GetInstance().GetLastestAlarm(id, AlarmType.LineNotConnected);
                            }
                            //更新次数和最后时间
                            MonitorADOProvider.GetInstance().UpdateAlarm(_catch[id].Alarm.Id, pingState.CollectTime);
                        }
                    }
                    else
                    {
                        if (_catch[id].Alarm != null)
                        {
                            if (_catch[id].Alarm.Id == 0)
                            {
                                _catch[id].Alarm = MonitorADOProvider.GetInstance().GetLastestAlarm(id, AlarmType.LineNotConnected);
                            }
                            LineModel line = MonitorADOProvider.GetInstance().GetLineModel(id);
                            MonitorADOProvider.GetInstance().RecoverAlarm(_catch[id].Alarm.Id, DateTime.Now, AlarmStateType.Recover);
                            SendMessage?.Invoke(_catch[id].Alarm, line.SMSTelphone);
                        }
                    }



                    //var alarm = _catch[id].Provider.GetLastestAlarm(id, AlarmType.LineNotConnected);
                    //if (!pingState.State)
                    //{
                    //    _catch[id].Count++;

                    //    //根据告警策略 更新 告警状态
                    //    if (alarm == null)
                    //    {
                    //        LineModel line = new LineBusiness().GetItem(id);
                    //        //肯定是有alarm的
                    //        if (_catch[id].Count >= line.AlarmMax)
                    //        {
                    //            alarm = new AlarmModel()
                    //            {
                    //                AlarmCount = 1,
                    //                Confirm = false,
                    //                FirstTime = pingState.CollectTime,
                    //                IP = line.LineIP,
                    //                LineId = line.Id,
                    //                LineName = line.Name,
                    //                OrganId = line.OrganizationId,
                    //                OrganName = line.OrganizationName,
                    //                State = AlarmStateType.OnAlarm,
                    //                LastTime = pingState.CollectTime,
                    //                Type = AlarmType.LineNotConnected
                    //            };
                    //            //状态改为 正在告警
                    //            _catch[id].Provider.InsertSync(alarm);
                    //            SendMessage?.Invoke(alarm, line.SMSTelphone);
                    //        }
                    //    }
                    //    else
                    //    {
                    //        //更新次数和最后时间
                    //        string condition = "AND Id = @Id";
                    //        string field = "AlarmCount=@AlarmCount,LastTime=@LastTime";
                    //        _catch[id].Provider.UpdateSync(condition, field, new { Id = alarm.Id, AlarmCount = alarm.AlarmCount + 1, LastTime = pingState.CollectTime });
                    //    }
                    //}
                    //else
                    //{
                    //    if (alarm != null)
                    //    {
                    //        LineModel line = new LineBusiness().GetItem(id);
                    //        alarm.RecoverDate = pingState.CollectTime;
                    //        alarm.State = AlarmStateType.Recover;
                    //        //alarm.AlarmCount = _catch[id].Count;
                    //        _catch[id].Provider.AddRecoverDate(alarm);
                    //        SendMessage?.Invoke(alarm, line.SMSTelphone);
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                }
            }
        }