Exemple #1
0
        private void select_text(string txt)
        {
            try
            {
                int indx = rtbData.Find(txt);
                //if (hash_index[cmb_step.SelectedIndex] != null)
                if (indx != -1)
                {
                    //rtbData.SelectedText = cmb_step.Text;
                    //rtbData.Select((int)hash_index[cmb_step.SelectedIndex], cmb_step.Text.Length);
                    rtbData.Select(indx, txt.Length);
                    rtbData.ScrollToCaret();
                    //rtbData.SelectionBackColor = Color.Red;
                    rtbData.SelectionBackColor = Color.YellowGreen;

                    //rtbData.SelectionLength = cmb_step.Text.Length;

                    Lines.Remove(cmb_step.Items[0].ToString());
                    if (Lines.Contains(txt))
                    {
                        Lines.Remove(txt);
                    }
                    Lines.Add(txt);
                    Show_Next_Previous_Text();
                }
            }
            catch (Exception ex) { }
        }
Exemple #2
0
        public void RestoreLines()
        {
            _elements.RemoveAll(x => Lines.Contains(x));

            foreach (var component in Components)
            {
                foreach (var input in component.Input)
                {
                    _elements.Add(new Line(
                                      _elements.FirstOrDefault(x => x is IMoveableElement && x.Name == input) as IMoveableElement,
                                      component
                                      ));
                }
            }

            foreach (var output in Outputs)
            {
                _elements.Add(new Line(
                                  _elements.FirstOrDefault(x => x is IMoveableElement && x.Name == output.Input) as IMoveableElement,
                                  output
                                  ));
            }

            foreach (var line in Lines)
            {
                line.connection = new Tuple <IMoveableElement, IMoveableElement>(
                    _elements.FirstOrDefault(x => x is IMoveableElement && x.Name == line.connectionName.Item1) as IMoveableElement,
                    _elements.FirstOrDefault(x => x is IMoveableElement && x.Name == line.connectionName.Item2) as IMoveableElement
                    );
            }
        }
Exemple #3
0
 public OcrLine AddLine(OcrLine line)
 {
     if (!Lines.Contains(line))
     {
         Lines.Add(line);
     }
     return(line);
 }
Exemple #4
0
        public Station AddLine(string lineName)
        {
            if (string.IsNullOrEmpty(lineName))
            {
                return(this);
            }

            if (!Lines.Contains(lineName))
            {
                Lines.Add(lineName);
            }

            return(this);
        }
Exemple #5
0
        void AtiveEditor_EditValueChanged(object sender, EventArgs e)
        {
            t CurrentLine = GridView.GetSelected <t>();

            //Verifica se o registro á o último se for
            //adicina a lista
            switch (CurrentLine.StateRecord)
            {
            case eState.eAdd:
            {
                var line = Lines.IndexOf(CurrentLine);

                if (line < 0)
                {
                    //var nextID = Lines.Count == 0 ? 1 : Lines.Max(p => p.KeyFields[0].GetInt32()) + 1;
                    //CurrentLine.KeyFields[0].Value = nextID;

                    if (OnAddList != null)
                    {
                        var args = new GridViewEditableEventArgs()
                        {
                            item = CurrentLine
                        };
                        OnAddList(this, args);
                        if (args.Cancel)
                        {
                            return;
                        }
                    }

                    if (!Lines.Contains(CurrentLine))
                    {
                        Lines.Add(CurrentLine);
                    }
                }
            }
            break;

            case eState.eDatabase:
                CurrentLine.StateRecord = eState.eUpdate;
                break;
            }

            if (OnChangeList != null)
            {
                OnChangeList(this, new EventArgs());
            }
        }
Exemple #6
0
        public void Redraw(Models.Game.Path path)
        {
            App.Current.Dispatcher.Invoke((Action) delegate
            {
                if (path.ToDelete)
                {
                    var str = _strokeById[path.ID];
                    Lines.Remove(str);
                    _strokeById.Remove(path.ID);

                    return;
                }

                if (path.Coordinates.Count == 0)
                {
                    return;
                }

                var points = new StylusPointCollection();

                foreach (var coordinate in path.Coordinates)
                {
                    points.Add(new StylusPoint(coordinate.X, coordinate.Y));
                }


                if (!_strokeById.ContainsKey(path.ID))
                {
                    _strokeById.Add(path.ID, new Stroke(points));
                    _strokeById[path.ID].DrawingAttributes.Width     = path.Size;
                    _strokeById[path.ID].DrawingAttributes.StylusTip = path.DrawingShape == Models.Game.Cap.Round ? StylusTip.Ellipse : StylusTip.Rectangle;
                    _strokeById[path.ID].DrawingAttributes.Height    = path.Size;
                    _strokeById[path.ID].DrawingAttributes.Color     = (Color)ColorConverter.ConvertFromString(path.Color);
                }
                else
                {
                    _strokeById[path.ID].StylusPoints.Add(points);
                }

                var tempStroke = _strokeById[path.ID];
                if (!Lines.Contains(tempStroke))
                {
                    Lines.Add(tempStroke);
                }
            });
        }
 public bool Contains(string item) => Lines.Contains(item);
Exemple #8
0
 public bool CheckSolution(byte line)
 {
     return(Lines.Contains(line));
 }
Exemple #9
0
        private void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            int counter = 0;

            StringBuilder sb = new StringBuilder();

            bool[] isReadTextString = new bool[DigitNumber];

            StreamReader LoadedWordFile = new StreamReader(tbxSelectedFile.Text); // 치환파일의 내용을 파일에 담음
            string       BufferWords;

            sb.AppendLine("");      // 다음줄로 이동 코드
            bool isContinue = true; // 문장이 계속 되는 한 계속 반복하게


            string[]      strarray = tbxMain.Text.Split(Environment.NewLine.ToCharArray());
            List <string> strList  = new List <string>();

            foreach (var item in strarray)
            {
                if (!string.IsNullOrWhiteSpace(item))
                {
                    strList.Add(item);
                }
            }

            //do
            //{
            while ((BufferWords = LoadedWordFile.ReadLine()) != null)
            {
                //tbxOutput.Text += BufferWords;
                int BoolEndWord = string.Compare(EndWord, BufferWords);     // 읽어들인 문장과 엔드워드가 같으면 0을 반환. 다르면 앞쪽 글자가 우선일 경우 0이하, 뒷쪽 글자가 우선일 경우 0보다 큰 수 반환
                if (BoolEndWord != 0)
                {
                    words[counter]   = BufferWords;
                    tbxMonitor.Text += words[counter];    // 테스트 코드
                    tbxMonitor.Text += sb.ToString();     // 다음줄로 이동 실행
                    counter++;
                }
                else
                {
                    break;
                }
            }

            foreach (var Lines in strList)
            {
                int BoolProgramOver = string.Compare(ProgramOver, words[0].ToString()); // 읽어들인 문장과 엔드워드가 같으면 0을 반환. 다르면 앞쪽 글자가 우선일 경우 0이하, 뒷쪽 글자가 우선일 경우 0보다 큰 수 반환
                if (BoolProgramOver == 0)
                {                                                                       // 프로그램 종료
                    tbxMonitor.Text = "프로그램 종료";                                        // 테스트 코드
                    counter         = 0;
                    continue;
                }
                else if (BoolProgramOver != 0)
                {
                    tbxMonitor.Text += "첫 번째";                                                           // 테스트 코드

                    for (int i_isReadTextString = 0; i_isReadTextString < counter; i_isReadTextString++) // ReadTextString_의 길이 만큼 반복할 수 있음
                    {                                                                                    // 해당 문자열이 있는지 없는지의 여부를 배열에 할당하여 불값으로 전달. 상수값을 전달
                        isReadTextString[i_isReadTextString] = Lines.Contains(ReadTextString_[i_isReadTextString]);
                        //tbxOutput.Text += ReadTextString_[i_isReadTextString];// 테스트 코드
                    }


                    tbxOutput.Text += Lines.Replace("#0", words[0])
                                      .Replace("#1", words[1])
                                      .Replace("#2", words[2])
                                      .Replace("#3", words[3])
                                      .Replace("#4", words[4])
                                      .Replace("#5", words[5])
                                      .Replace("#6", words[6])
                                      .Replace("#7", words[7])
                                      .Replace("#8", words[8])
                                      .Replace("#9", words[9])
                                      .Replace("#10", words[10])
                                      .Replace("#11", words[11]);
                    tbxOutput.Text += Environment.NewLine;
                }
            }


            for (int i = 0; i < counter; i++)
            {                                                                // 프로그램 단어의 끝 단어가 나오지 않으면 계속 반복하게 설정.
                int BoolProgramOver = string.Compare(ProgramOver, words[i]); // 읽어들인 문장과 엔드워드가 같으면 0을 반환. 다르면 앞쪽 글자가 우선일 경우 0이하, 뒷쪽 글자가 우선일 경우 0보다 큰 수 반환
                if (BoolProgramOver != 0)
                {
                    isContinue = true;
                }
                else
                {
                    isContinue = false;
                }
            }

            //} while (isContinue);



            //LoadedWordFile.Close();
        }
Exemple #10
0
        public override void Tokenize(ObstacleCollection obstacles)
        {
            var polygons     = SplitPolygon(Lines, obstacles);
            var blocks       = Polygon.GetAssociatedBlocks(polygons, Map, Layer).ToList();
            var polygonEdges = new List <LineSegment>();

            foreach (var polygon in polygons)
            {
                for (int i = 0, j = polygon.Count - 1; i < polygon.Count; j = i++)
                {
                    polygonEdges.Add(GetLine(polygon[i], polygon[j], false, Lines));
                }
            }
            var intersectionLines = polygonEdges.GroupBy(x => x).Where(group => group.Count() > 1).Select(group => group.Key).ToList(); //finds duplicated items

            var blockLines = new Dictionary <Block, List <LineSegment> >();                                                             //create a dictionary of block which intersection line they belong to. Because if the intersection line does not match,
                                                                                                                                        //all intersecting lines of that block must be set invalid. Otherwise they engine would not not create a separate polygon.
            var mismatchBlocks = new List <Block>();

            foreach (var intersectionLine in intersectionLines)
            {
                Block       blockX;
                Block       blockY;
                Orientation orientation;
                GetNeighborBlocks(intersectionLine, blocks, out blockX, out blockY, out orientation);
                if (BlocksMatch(blockX, blockY, orientation))
                {
                    Lines.Remove(intersectionLine);
                }
                else
                {
                    if (blockX != null & !mismatchBlocks.Contains(blockX))
                    {
                        mismatchBlocks.Add(blockX);
                    }
                    if (blockY != null & !mismatchBlocks.Contains(blockY))
                    {
                        mismatchBlocks.Add(blockY);
                    }
                }
                AddBlockLines(blockLines, blockX, intersectionLine);
                AddBlockLines(blockLines, blockY, intersectionLine);
            }
            foreach (var mismatchBlock in mismatchBlocks)
            {
                //Restore all lines of the mismatched blocks
                List <LineSegment> blockLineSegments;
                if (!blockLines.TryGetValue(mismatchBlock, out blockLineSegments))
                {
                    continue;
                }
                foreach (var blockSegment in blockLineSegments.Where(blockSegment => !Lines.Contains(blockSegment)))
                {
                    Lines.Add(blockSegment);
                }
            }

            polygons.Clear();
            polygons = SplitPolygon(Lines, obstacles);
            foreach (var polygon in polygons)
            {
                var simplePolygon = SimplifyTools.CollinearSimplify(polygon);
                AddSlopeObstacle(simplePolygon, VerticesEx.IsRectangle(simplePolygon), obstacles, Layer);
            }
        }
Exemple #11
0
        internal void HandleMovement(GameMoveMessageRequest request, Socket sender)
        {
            CheckIfSomeonewon();
            if (CurrentUser.ClientSocket != sender)
            {
                return;
            }

            var line = new Tuple <Point, Point>(request.From, request.To);

            if (Lines.Contains(line))
            {
                Server.Instance.SendMessage(new GameSendMessageResponse("Server:", "Invalid move"), new NetworkStream(sender));
                return;
            }

            Lines.Add(line);
            var  startingPoint = new Point(0, 0);
            bool addedNew      = false;

            for (int i = 0; i < GameSize * GameSize; i++)
            {
                if (Squares.FirstOrDefault(s => s.Id == i) != null)
                {
                    if (startingPoint.Y == GameSize - 1)
                    {
                        startingPoint.X++;
                        startingPoint.Y = 0;
                    }
                    else
                    {
                        startingPoint.Y++;
                    }
                    continue;
                }
                var lines = 0;
                if (Lines.Contains(new Tuple <Point, Point>(startingPoint, new Point(startingPoint.X, startingPoint.Y + 1))))
                {
                    lines++;
                }

                if (Lines.Contains(new Tuple <Point, Point>(startingPoint, new Point(startingPoint.X + 1, startingPoint.Y))))
                {
                    lines++;
                }

                if (Lines.Contains(new Tuple <Point, Point>(new Point(startingPoint.X + 1, startingPoint.Y), new Point(startingPoint.X + 1, startingPoint.Y + 1))))
                {
                    lines++;
                }

                if (Lines.Contains(new Tuple <Point, Point>(new Point(startingPoint.X, startingPoint.Y + 1), new Point(startingPoint.X + 1, startingPoint.Y + 1))))
                {
                    lines++;
                }

                if (lines == 4)
                {
                    Squares.Add(new Square(Server.Instance.Users[sender].Name, i));
                    addedNew = true;
                }

                if (startingPoint.Y == GameSize - 1)
                {
                    startingPoint.X++;
                    startingPoint.Y = 0;
                }
                else
                {
                    startingPoint.Y++;
                }
            }
            if (addedNew)
            {
                CurrentUser = _currentUser;
            }
            else
            {
                CurrentUser = CurrentUser == Player1 ? Player2 : Player1;
            }

            var response = new GameMoveMessageResponse(Lines, Squares);

            Server.Instance.SendMessage(response, Player1.ClientStream);
            Server.Instance.SendMessage(response, Player2.ClientStream);
            CheckIfSomeonewon();
        }