/// <summary>
 /// Captures the current cursor position.
 /// </summary>
 internal void CaptureCursorPosition()
 {
     if (TextDocument != null && TextDocument.Selection != null)
     {
         TrackedCursorPosition = new CursorPosition(TextDocument.Selection);
     }
 }
示例#2
0
        public void NextPlayerMove()
        {
            var cursorPosition = new CursorPosition {
                x = 0, y = 0
            };

            _board[cursorPosition.y][cursorPosition.x] = _board[cursorPosition.y][cursorPosition.x] | CellState.Selected;
            while (true)
            {
                Redraw();
                var key = Console.ReadKey();
                _board[cursorPosition.y][cursorPosition.x] =
                    _board[cursorPosition.y][cursorPosition.x] ^ CellState.Selected;
                switch (key.Key)
                {
                case ConsoleKey.LeftArrow:
                    cursorPosition.x = Mod(--cursorPosition.x, _size);
                    break;

                case ConsoleKey.RightArrow:
                    cursorPosition.x = Mod(++cursorPosition.x, _size);
                    break;

                case ConsoleKey.UpArrow:
                    cursorPosition.y = Mod(--cursorPosition.y, _size);
                    break;

                case ConsoleKey.DownArrow:
                    cursorPosition.y = Mod(++cursorPosition.y, _size);
                    break;

                case ConsoleKey.Enter:
                    if (_board[cursorPosition.y][cursorPosition.x].HasFlag(CellState.X) ||
                        _board[cursorPosition.y][cursorPosition.x].HasFlag(CellState.O))
                    {
                        Console.WriteLine("Illegal move");
                        Console.ReadKey();
                        break;
                    }

                    _board[cursorPosition.y][cursorPosition.x] = CellState.X;
                    return;
                }

                _board[cursorPosition.y][cursorPosition.x] =
                    _board[cursorPosition.y][cursorPosition.x] | CellState.Selected;
            }
            int Mod(int x, int m)
            {
                return((x % m + m) % m);
            }
        }
示例#3
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = base.GetHashCode();
         hash = hash * 37 + (GameTime != null ? GameTime.GetHashCode() : 0);
         hash = hash * 37 + (MouseState != null ? MouseState.GetHashCode() : 0);
         hash = hash * 37 + (TouchState != null ? TouchState.GetHashCode() : 0);
         hash = hash * 37 + (CursorPosition != null ? CursorPosition.GetHashCode() : 0);
         hash = hash * 37 + (ObjectPool != null ? ObjectPool.GetHashCode() : 0);
         return(hash);
     }
 }
        public static CursorPosition ParseSetCursorMessage(string message)
        {
            CursorPosition result = new CursorPosition();

            List <string> tokens = GetMessageTokens(message);

            if (tokens.Count != 4)
            {
                Logging.Logging.LogError("Invalid message: " + message);
                Logging.Logging.LogError("Invalid token count for 'move cursor' message. Expected 4, but got " + tokens.Count.ToString());
                return(result);
            }

            if (tokens[0] != s_moveCursorPrefix)
            {
                Logging.Logging.LogError("Invalid message: " + message);
                Logging.Logging.LogError("Invalid message type. Expected '" + s_moveCursorPrefix + "' but got '" + tokens[0] + "'");
                return(result);
            }

            result.FilePath = tokens[1];

            int lineNumber = 0;

            if (int.TryParse(tokens[2], out lineNumber))
            {
                result.LineNumber = lineNumber;
            }
            else
            {
                Logging.Logging.LogError("Invalid message: " + message);
                Logging.Logging.LogError("Failed to parse line number");
                return(result);
            }

            int columnNumber = 0;

            if (int.TryParse(tokens[3], out columnNumber))
            {
                result.ColumnNumber = columnNumber;
            }
            else
            {
                Logging.Logging.LogError("Invalid message: " + message);
                Logging.Logging.LogError("Failed to parse column number");
                return(result);
            }

            result.Valid = true;
            return(result);
        }
示例#5
0
    private string LexTag()
    {
        bool           isClose  = htmlString[currentPosition.Index + 1] == '/';
        CursorPosition startPos = CopyPosition(currentPosition);

        FeedPosition(currentPosition, htmlString, isClose ? 2 : 1);
        string type    = (isClose) ? "tag-end" : "tag-start";
        string content = (isClose) ? "/>" : "<";

        tokens.Add(new Token(type, content, startPos, CopyPosition(currentPosition)));
        string tagName = LexTagName();

        LexTagAttributes();
        return(tagName);
    }
        private static void TestCursorPosition(string text, CursorPosition position)
        {
            var reader = new CharReader(new StringReader(text));

            for (int i = 0; i < text.Length; i++)
            {
                reader.MoveNext();
            }

            string msg = $"'{text.Replace("\r", "\\r").Replace("\n", "\\n")}': current ";

            Assert.AreEqual(position.Row, reader.CurrentRow, msg + "row");
            Assert.AreEqual(position.Column, reader.CurrentColumn, msg + "column");
            Assert.AreEqual(text.Length, reader.CurrentIndex, msg + "index");
        }
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            IEnumerable <PropertyEditor> textEdits = GetTextEdits();

            foreach (var textEdit in textEdits)
            {
                CursorPosition cursorPosition = ((IModelPropertyEditorCursorPosition)textEdit.Model).CursorPosition;
                var            edit           = ((TextEdit)textEdit.Control);
                edit.GotFocus += (sender, args) => {
                    var length = cursorPosition == SystemModule.CursorPosition.End ? (edit.EditValue + "").Length : 0;
                    edit.Select(length, length);
                };
            }
        }
        public static void MoveOrResizeWindow(this Window window, MouseButtonEventArgs e)
        {
            CursorPosition pos = window.GetCursorPosition();

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (pos == CursorPosition.Body)
                {
                    window.DragMove();
                }
                else
                {
                    ResizeWindow(window, pos);
                }
            }
        }
示例#9
0
        //
        // Private methods
        //
        #region Private methods

        // Move cursor
        private void MoveCursor(int cDeltaPixel)
        {
            // If mouse is outside screen, move it to the center
            // In case of multiple screens are used, the mouse will be moved to the center of the main screen
            // This has never been a problem to me, but you can modify the code to support multiple screens
            if (!CursorHelper.CheckRelativePosition(cDeltaPixel, cDeltaPixel))
            {
                var res_info          = DesktopHelper.GetResolution();
                var center_screen_pos = new CursorPosition(res_info.Width / 2, res_info.Height / 2);
                CursorHelper.SetPositionAbsolute(center_screen_pos);
            }
            else
            {
                CursorHelper.SetPositionRelative(cDeltaPixel, cDeltaPixel);
            }
        }
示例#10
0
        /// <summary>
        /// Display results of scan
        /// </summary>
        public static void ScanProgress(int scanned, int found, int total, TimeSpan curTime, string range, string curAddr = "---.---.---.---")
        {
            // Check if cursor position is already set
            if (progBarPos.Left != 0)
            {
                // Store original cursor position
                CursorPosition originalPos = new CursorPosition(Console.CursorLeft, Console.CursorTop);
                Console.CursorVisible = false;

                // Update labels
                curAddrPos.SetToPosition();
                Console.WriteLine(new String(' ', 20));
                scanInfoPos.SetToPosition();
                Console.WriteLine(SCAN_HOSTS_TXT, scanned, found);
                scanTimePos.SetToPosition();
                Console.Write("{0:hh\\:mm\\:ss}", curTime);
                curAddrPos.SetToPosition();
                Console.Write(curAddr);
                progBarPos.SetToPosition();
                double s            = scanned;
                double tot          = total;
                double blockPercent = (s / tot) * 30;
                Console.WriteLine(new String('=', Convert.ToInt32(blockPercent)) + ">");
                perComplPos.SetToPosition();
                Console.WriteLine("{0}%", Math.Round((s / tot) * 100, 0));

                // Reset to original cursor position
                Console.SetCursorPosition(originalPos.Left, originalPos.Top);
            }
            else
            {
                // Setup labels
                Console.WriteLine(SCAN_RANGE_TXT, range);
                Console.Write(SCAN_CUR_ADDR_TXT);
                curAddrPos = new CursorPosition(Console.CursorLeft, Console.CursorTop);
                Console.WriteLine(curAddr);
                scanInfoPos = new CursorPosition(Console.CursorLeft, Console.CursorTop);
                Console.WriteLine();
                Console.Write(" ");
                scanTimePos = new CursorPosition(Console.CursorLeft, Console.CursorTop);
                Console.Write("00:00:00 [");
                progBarPos = new CursorPosition(Console.CursorLeft, Console.CursorTop);
                Console.Write("                               ] ");
                perComplPos = new CursorPosition(Console.CursorLeft, Console.CursorTop);
                Console.WriteLine();
            }
        }
示例#11
0
    private void LexComment()
    {
        CursorPosition startPos = CopyPosition(currentPosition);

        FeedPosition(currentPosition, htmlString, 4); //<!---
        int contentEnd = htmlString.IndexOf("-->", currentPosition.Index);
        int commentEnd = contentEnd + 3;              //-->

        if (contentEnd == -1)
        {
            contentEnd = commentEnd = htmlString.Length;
        }
        string content = htmlString.Substring(currentPosition.Index, contentEnd - currentPosition.Index);

        FeedPosition(currentPosition, htmlString, commentEnd - currentPosition.Index);
        tokens.Add(new Token("comment", content, startPos, CopyPosition(currentPosition)));
    }
示例#12
0
    private void LexText()
    {
        int textEnd = FindTextEnd(htmlString, currentPosition.Index);

        if (textEnd != currentPosition.Index)
        {
            textEnd = (textEnd == -1) ? htmlString.Length : textEnd;
            CursorPosition startPos = CopyPosition(currentPosition);
            currentPosition.Index += (currentPosition.Index + 1 >= htmlString.Length) ? 0 : 1;
            string content = htmlString.Substring(currentPosition.Index, textEnd - currentPosition.Index).Trim();
            FeedPosition(currentPosition, htmlString, textEnd - currentPosition.Index);
            if (content != "")
            {
                tokens.Add(new Token("text", content, startPos, CopyPosition(currentPosition)));
            }
        }
    }
        public static void ResizeWindow(Window window, CursorPosition pos)
        {
            IntPtr handle;

            if (_winHandles.ContainsKey(window))
            {
                handle = _winHandles[window];
            }
            else
            {
                HwndSource hs = (HwndSource)PresentationSource.FromVisual(window);
                _winHandles.Add(window, handle = hs.Handle);
            }

            Native.SendMessage(handle, Native.WM_SYSCOMMAND,
                               (IntPtr)(61440 + pos), IntPtr.Zero);
        }
        public static CursorPosition GetCursorPosition(this Window window)
        {
            var            pt  = Mouse.GetPosition(window);
            var            x   = pt.X;
            var            y   = pt.Y;
            CursorPosition pos = CursorPosition.Body;

            int THRESHOLD = 5;

            if (x < THRESHOLD && y < THRESHOLD)
            {
                pos = CursorPosition.TopLeft;
            }
            else if (x < THRESHOLD && y > window.Height - THRESHOLD)
            {
                pos = CursorPosition.TopRight;
            }

            else if (x < THRESHOLD && y > window.Height - THRESHOLD)
            {
                pos = CursorPosition.BottomLeft;
            }
            else if (x > window.Width - THRESHOLD && y > window.Height - THRESHOLD)
            {
                pos = CursorPosition.BottomRight;
            }

            else if (x < THRESHOLD)
            {
                pos = CursorPosition.Left;
            }
            else if (y < THRESHOLD)
            {
                pos = CursorPosition.Top;
            }
            else if (x > window.Width - THRESHOLD)
            {
                pos = CursorPosition.Right;
            }
            else if (y > window.Height - THRESHOLD)
            {
                pos = CursorPosition.Bottom;
            }

            return(pos);
        }
示例#15
0
 public void Loaded()
 {
     Data.UpdateProductTree(tvNavigator, DisplayIndex);
     UpdateChart();
     InitTrendsList();
     fileSystemWatcher1.Path = Data.HistoryFolder;
     _minutes            = Data.Session.ReadInteger("TrendShowed" + DisplayIndex, "TimeRange", 20);
     tsbNextTime.Enabled = false;
     foreach (var dropitem in tsbTimeSelect.DropDownItems.Cast <ToolStripDropDownItem>()
              .Where(dropitem => dropitem.Tag != null &&
                     (string)dropitem.Tag == _minutes.ToString("0")))
     {
         tsbTimeSelect.Text = dropitem.Text;
         break;
     }
     _offset = Data.Session.ReadInteger("TrendShowed" + DisplayIndex, "TimeOffset", 0);
     if (_offset > 0)
     {
         tsbNextTime.Enabled = true;
     }
     _cursorPosition = Data.Session.ReadDateTime("TrendShowed" + DisplayIndex, "TimePosition", DateTime.MinValue);
     if (_cursorPosition == DateTime.MinValue)
     {
         ClearDateCursor();
     }
     else
     {
         tslCursorPositionDate.Text = @"Позиция курсора: " + CursorPosition.ToString("dd.MM.yy HH:mm.ss.fff");
     }
     _zoomminutes = Data.Session.ReadInteger("TrendShowed" + DisplayIndex, "TimeZoom", _minutes);
     if (_zoomminutes < _minutes && _cursorPosition > DateTime.MinValue)
     {
         tsbNoZoom.Enabled = true;
         var dateHighRange = CursorPosition.AddMinutes(_zoomminutes);
         var dateLowRange  = CursorPosition.AddMinutes(-_zoomminutes);
         UpdateChart(dateLowRange, dateHighRange);
         FillCursorsData(CursorPosition);
         tsbZoomIn.Enabled  = true;
         tsbZoomOut.Enabled = true;
     }
     else
     {
         UpdateChart();
     }
 }
示例#16
0
        public void apply()
        {
            MyConsole.displayMain($"\n\n Applying {name} ----------------------------------: ");
            MyConsole.displayMain($"\n\n-----iteration : 0");


            // Starting timer to mesure completion time
            timer.start();
            // generate initial solution using greedy randomized construction
            initialSolution = buildSolution();
            // At the beginning, the best is the initial solution
            bestSolution = initialSolution;

            if (initialSolution != null)
            {
                CursorPosition cp = new CursorPosition();
                fitnessCurve.Add(model.fitness(initialSolution), 0);

                for (int i = 1; i < model.getNumOfIterations(); i++)
                {
                    // for display ------------------------------------------------------------------------------------------
                    MyConsole.restCursorPosition(cp);
                    MyConsole.displayMain($"\n\n-----------------------------iteration : {i + 1}/{model.getNumOfIterations()}");
                    MyConsole.display($"-----------------------------constructing solution");
                    // -------------------------------------------------------------------------------------------------------

                    solution = buildSolution();
                    solution = localSearch(solution);
                    // If fitness is improved
                    updateBestSolution(i);
                }

                timer.stop(excelFile);


                MyConsole.displayMain($"\n best solution reached : {model.fitness(bestSolution)}");
                exportFitnessToExcel();
                //saveInitialSolution();
                //saveBestSolution();
            }
            else
            {
                MyConsole.displayError("ERROR : Couldn't find Initial solution. Program breaks ");
            }
        }
示例#17
0
    private void FeedPosition(CursorPosition position, string str, int len)
    {
        int start = position.Index;
        int end   = position.Index = start + len;

        for (int i = start; i < end; i++)
        {
            if (str[i] == '\n')
            {
                position.Line++;
                position.Column = 0;
            }
            else
            {
                position.Column++;
            }
        }
    }
示例#18
0
        // Move mouse
        public void MoveMouse()
        {
            // Get current position
            var curr_pos = CursorHelper.GetCurrentPosition();

            // Move cursor only if position is not changed, in order to not disturb if the user is working
            if (curr_pos == mLastCursorPos)
            {
                // Get pixel movement depending on the direction
                int mov_pixel_rel = (mMovingDir == eMovingDirections.BACKWARD) ? (-1 * mMovingPixel) : mMovingPixel;
                // Move cursor
                MoveCursor(mov_pixel_rel);
                // Update moving direction
                UpdateMovingDir();
            }

            // Reset last cursor position
            mLastCursorPos = CursorHelper.GetCurrentPosition();
        }
示例#19
0
        private void tsbZoomIn_Click(object sender, EventArgs e)
        {
            var dateLowRange  = DateTime.FromOADate(chartTrends.ChartAreas[0].AxisX.Minimum);
            var dateHighRange = DateTime.FromOADate(chartTrends.ChartAreas[0].AxisX.Maximum);

            if (CursorPosition <= dateLowRange || CursorPosition >= dateHighRange)
            {
                return;
            }
            if (Zoomminutes <= 1)
            {
                return;
            }
            Zoomminutes  -= Zoomminutes / 2;
            dateHighRange = CursorPosition.AddMinutes(Zoomminutes);
            dateLowRange  = CursorPosition.AddMinutes(-Zoomminutes);
            UpdateChart(dateLowRange, dateHighRange);
            tsbNoZoom.Enabled = true;
        }
示例#20
0
        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            CursorPosition pos = this.GetCursorPosition();

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (pos == CursorPosition.Body)
                {
                    this.DragMove();
                    SnapWindowToEdge();
                }
                else
                {
                    WindowTools.ResizeWindow(this, pos);
                }
            }


            //this.MoveOrResizeWindow(e);
        }
示例#21
0
        private static string GetFilename(CursorPosition cursorPosition, bool mustExist = true)
        {
            bool   valid    = false;
            string fileName = "";

            while (!valid)
            {
                valid = (fileName = Console.ReadLine()?.Replace("\"", string.Empty)) != null;

                if (!valid | !File.Exists(fileName) & mustExist)
                {
                    Prettier.ShowMessage($"Die Datei {fileName} existiert nicht oder kann nicht gelesen werden!", Prettier.MessageKind.Error, cursorPosition);
                    Prettier.ClearLine(cursorPosition);
                    valid = false;
                }
            }

            Prettier.ClearMessage();
            return(fileName);
        }
示例#22
0
    private void LexTagAttributes()
    {
        int           index, attrStart = index = currentPosition.Index;
        char          quote = '\0';
        List <string> words = new List <string>();

        while (index < htmlString.Length)
        {
            char c = htmlString[index];
            if (quote != '\0')
            {
                quote = (c == quote) ? '\0' : quote;
            }
            else if (c == '/' || c == '>')
            {
                if (index != attrStart)
                {
                    words.Add(htmlString.Substring(attrStart, index - attrStart));
                }
                break;
            }
            else if (Char.IsWhiteSpace(c))
            {
                if (index != attrStart)
                {
                    words.Add(htmlString.Substring(attrStart, index - attrStart));
                }
                attrStart = index + 1;
            }
            else if (c == '\'' || c == '"')
            {
                quote = c;
            }
            index++;
        }

        CursorPosition startPos = CopyPosition(currentPosition);

        FeedPosition(currentPosition, htmlString, index - currentPosition.Index);
        LexTagAttributeWords(words, startPos);
    }
示例#23
0
        private static void BulkValidate()
        {
            Console.Clear();
            Prettier.Banner("Massenvalidierung", "IBAN- Validierung", foreGroundColor: ConsoleColor.Blue, padding: 10);
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("Bitte geben Sie den Namen der zu validierenden Datei an: ");
            CursorPosition cursorPosition = new CursorPosition(Console.CursorLeft, Console.CursorTop);
            string         fileName       = GetFilename(cursorPosition);

            long[]   composition = GetComposition(fileName);
            string[] result      = new string[composition[1]];

            using (StreamReader reader = new StreamReader(fileName))
            {
                string line;
                int    counter = 0;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] iban = new string[4];
                    if (composition[0] == 1)
                    {
                        continue;
                    }
                    iban[0] = line.Substring(0, 2);
                    iban[1] = line.Substring(2, 2);
                    iban[2] = line.Substring(4, 8);
                    iban[3] = line.Substring(12, 10);

                    int checksum = int.Parse(iban[1]);
                    if (!ValidateIban(ref iban, checksum))
                    {
                        result[counter] = line;
                        counter++;
                    }
                }
            }


            WriteInvalidIbans(result);
        }
示例#24
0
        private static void BulkConvert()
        {
            Console.Clear();
            Prettier.Banner("Massenkonvertierung", "Klassische Kontodaten zu IBAN", ConsoleColor.Blue, 10);
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("Bitte geben Sie den Namen der zu konvertierenden Datei an: ");
            CursorPosition cursorPosition = new CursorPosition(Console.CursorLeft, Console.CursorTop);
            string         fileName       = GetFilename(cursorPosition);

            if (DebugEnabled)
            {
                LogHelper.Log("BulkConvert | Chosen filename (full path): " + Path.GetFullPath(fileName));
            }

            string[] bankdata    = ConvertBankData(fileName);
            string   outFileName = WriteConvertedData(bankdata);

            Prettier.ShowMessage($"Die Daten wurden in der Datei {outFileName} gespeichert. Mit [ENTER] zum Menü...", Prettier.MessageKind.Success);
            Console.ReadLine();
        }
示例#25
0
        void Update()
        {
            LBMPressedFlag = Input.GetMouseButtonDown(0) && !IsUIObject();
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit[] hits = Physics.RaycastAll(ray, 100.0f);

            for (int i = 0; i < hits.Length; i++)
            {
                if (i == 0)
                {
                    CursorPosition?.Invoke(GetPosition(hits[i]));
                }

                Selected = SelectObject(hits[i]);
            }

            if (LBMPressedFlag)
            {
                LBMPressed?.Invoke();
            }
        }
示例#26
0
        private static void Generate()
        {
            Console.Clear();
            Prettier.Banner("IBAN generieren", foreGroundColor: ConsoleColor.Blue, padding: 10);
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.White;

            Console.Write("Bitte geben Sie eine Kontonummer ein: ");
            CursorPosition cursorPosition = new CursorPosition(Console.CursorLeft, Console.CursorTop);
            string         accountNumber  = GetBankData(cursorPosition, 'k');

            if (DebugEnabled)
            {
                LogHelper.Log("Generate | Account number entered: " + accountNumber);
            }

            Console.Write("Bitte die BLZ eingeben: ");
            cursorPosition.UpdatePosition(Console.CursorLeft, Console.CursorTop);
            string bankNumber = GetBankData(cursorPosition, 'b');

            if (DebugEnabled)
            {
                LogHelper.Log("Generate | Bank number entered: " + bankNumber);
            }

            string[] iban = GenerateIban(bankNumber, accountNumber);

            Console.Clear();
            string result = string.Concat(iban);

            if (DebugEnabled)
            {
                LogHelper.Log("Generate | Generated IBAN: " + result);
            }

            Prettier.Banner($"Ihre IBAN lautet {FormatIban(ref result)}", padding: 20, centerVertical: true);
            Prettier.ShowMessage("Mit [ENTER] gelangen Sie zurück zum Menü", Prettier.MessageKind.Success);
            Console.ReadLine();
        }
示例#27
0
 private void LexTagAttributeWords(List <string> words, CursorPosition startPos)
 {
     bool[] alreadyUsed = new bool[words.Count];
     for (int i = 0; i < words.Count; i++)
     {
         if (!alreadyUsed[i])
         {
             if (!words[i].Contains('=') && words.ElementAtOrDefault(i + 1) != null && !alreadyUsed[i + 1] && words[i + 1] == "=")
             {
                 if (words.ElementAtOrDefault(i + 2) != null && !alreadyUsed[i + 2])
                 {
                     tokens.Add(new Token("attribute", words[i] + "=" + words[i + 2], startPos, CopyPosition(currentPosition)));
                     alreadyUsed[i] = alreadyUsed[i + 1] = alreadyUsed[i + 2] = true;
                 }
             }
             else
             {
                 tokens.Add(new Token("attribute", words[i], startPos, CopyPosition(currentPosition)));
             }
         }
     }
 }
示例#28
0
            public void Focus(CursorPosition position)
            {
                Focus();

                switch (position)
                {
                case CursorPosition.Start:
                    SelectionStart  = 0;
                    SelectionLength = 0;
                    break;

                case CursorPosition.End:
                    SelectionStart  = TextLength;
                    SelectionLength = 0;
                    break;

                case CursorPosition.SelectAll:
                    SelectionStart  = 0;
                    SelectionLength = TextLength;
                    break;
                }
            }
示例#29
0
        /// <summary>
        /// Displays and updates results of an ICMP flood
        /// </summary>
        /// <param name="results"></param>
        public static void FloodProgress(PingResults results, string target)
        {
            // Check if labels have already been drawn
            if (sentPos.Left > 0)
            {
                // Store original cursor position
                CursorPosition originalPos = new CursorPosition(Console.CursorLeft, Console.CursorTop);
                Console.CursorVisible = false;

                // Update labels
                Console.SetCursorPosition(sentPos.Left, sentPos.Top);
                Console.Write(results.Sent);
                Console.SetCursorPosition(ppsPos.Left, ppsPos.Top);
                Console.Write("          "); // Blank first
                Console.SetCursorPosition(ppsPos.Left, ppsPos.Top);
                Console.Write(results.Sent - sentPings);

                // Reset to original cursor position
                Console.SetCursorPosition(originalPos.Left, originalPos.Top);
                Console.CursorVisible = true;
            }
            else
            {
                // Draw labels
                Console.WriteLine(FLOOD_INTO_TXT, target);
                Console.Write(FLOOD_SEND_TXT);
                sentPos.Left = Console.CursorLeft;
                sentPos.Top  = Console.CursorTop;
                Console.WriteLine("0");
                Console.Write(FLOOD_PPS_TXT);
                ppsPos.Left = Console.CursorLeft;
                ppsPos.Top  = Console.CursorTop;
                Console.WriteLine();
                Console.WriteLine(FLOOD_EXIT_TXT);
            }

            sentPings = results.Sent;
        }
 private void KinectCursor_CursorMoved(object sender, CursorPosition e)
 {
     this.inputSimulator.Mouse.MoveMouseTo(e.X, e.Y);
 }
示例#31
0
        void InternalSelect(
            CursorPosition InCursorPos,
            Int32 InStart,
            Int32 InLength)
        {
            if (InStart < 0)
                InStart = 0;

            if (InLength < 0)
                InLength = 0;

            if (InStart >= LineItems.Count)
                InStart = LineItems.Count - 1;

            if (InStart + InLength >= LineItems.Count)
                InLength = LineItems.Count - InStart;

            m_SelectionStart = InStart;
            m_SelectionEnd = InStart + InLength;

            if (InCursorPos == CursorPosition.Start)
                m_CursorPosition = SelectionStart;
            else
                m_CursorPosition = SelectionEnd;
        }
        public override bool HandleKeyPress(KeyInput e)
        {
            if (IsDisabled() || e.Event == KeyInputEvent.Up)
            {
                return(false);
            }

            // Only take input if we are focused
            if (!HasKeyboardFocus)
            {
                return(false);
            }

            var isOSX = Platform.CurrentPlatform == PlatformType.OSX;

            switch (e.Key)
            {
            case Keycode.RETURN:
            case Keycode.KP_ENTER:
                if (OnEnterKey())
                {
                    return(true);
                }
                break;

            case Keycode.TAB:
                if (OnTabKey())
                {
                    return(true);
                }
                break;

            case Keycode.ESCAPE:
                ClearSelection();
                if (OnEscKey())
                {
                    return(true);
                }
                break;

            case Keycode.LALT:
                if (OnAltKey())
                {
                    return(true);
                }
                break;

            case Keycode.LEFT:
                ResetBlinkCycle();
                if (CursorPosition > 0)
                {
                    var cachedCurrentCursorPos = CursorPosition;

                    if ((!isOSX && e.Modifiers.HasModifier(Modifiers.Ctrl)) || (isOSX && e.Modifiers.HasModifier(Modifiers.Alt)))
                    {
                        CursorPosition = GetPrevWhitespaceIndex();
                    }
                    else if (isOSX && e.Modifiers.HasModifier(Modifiers.Meta))
                    {
                        CursorPosition = 0;
                    }
                    else
                    {
                        CursorPosition--;
                    }

                    if (e.Modifiers.HasModifier(Modifiers.Shift))
                    {
                        HandleSelectionUpdate(cachedCurrentCursorPos, CursorPosition);
                    }
                    else
                    {
                        ClearSelection();
                    }
                }

                break;

            case Keycode.RIGHT:
                ResetBlinkCycle();
                if (CursorPosition <= Text.Length - 1)
                {
                    var cachedCurrentCursorPos = CursorPosition;

                    if ((!isOSX && e.Modifiers.HasModifier(Modifiers.Ctrl)) || (isOSX && e.Modifiers.HasModifier(Modifiers.Alt)))
                    {
                        CursorPosition = GetNextWhitespaceIndex();
                    }
                    else if (isOSX && e.Modifiers.HasModifier(Modifiers.Meta))
                    {
                        CursorPosition = Text.Length;
                    }
                    else
                    {
                        CursorPosition++;
                    }

                    if (e.Modifiers.HasModifier(Modifiers.Shift))
                    {
                        HandleSelectionUpdate(cachedCurrentCursorPos, CursorPosition);
                    }
                    else
                    {
                        ClearSelection();
                    }
                }

                break;

            case Keycode.HOME:
                ResetBlinkCycle();
                if (e.Modifiers.HasModifier(Modifiers.Shift))
                {
                    HandleSelectionUpdate(CursorPosition, 0);
                }
                else
                {
                    ClearSelection();
                }

                CursorPosition = 0;
                break;

            case Keycode.END:
                ResetBlinkCycle();

                if (e.Modifiers.HasModifier(Modifiers.Shift))
                {
                    HandleSelectionUpdate(CursorPosition, Text.Length);
                }
                else
                {
                    ClearSelection();
                }

                CursorPosition = Text.Length;
                break;

            case Keycode.D:
                if (e.Modifiers.HasModifier(Modifiers.Ctrl) && CursorPosition < Text.Length)
                {
                    // Write directly to the Text backing field to avoid unnecessary validation
                    text           = text.Remove(CursorPosition, 1);
                    CursorPosition = CursorPosition.Clamp(0, text.Length);

                    OnTextEdited();
                }

                break;

            case Keycode.K:
                // ctrl+k is equivalent to cmd+delete on osx (but also works on osx)
                ResetBlinkCycle();
                if (e.Modifiers.HasModifier(Modifiers.Ctrl) && CursorPosition < Text.Length)
                {
                    // Write directly to the Text backing field to avoid unnecessary validation
                    text           = text.Remove(CursorPosition);
                    CursorPosition = CursorPosition.Clamp(0, text.Length);

                    OnTextEdited();
                }

                break;

            case Keycode.U:
                // ctrl+u is equivalent to cmd+backspace on osx
                ResetBlinkCycle();
                if (!isOSX && e.Modifiers.HasModifier(Modifiers.Ctrl) && CursorPosition > 0)
                {
                    // Write directly to the Text backing field to avoid unnecessary validation
                    text           = text.Substring(CursorPosition);
                    CursorPosition = 0;
                    ClearSelection();
                    OnTextEdited();
                }

                break;

            case Keycode.X:
                ResetBlinkCycle();
                if (((!isOSX && e.Modifiers.HasModifier(Modifiers.Ctrl)) || (isOSX && e.Modifiers.HasModifier(Modifiers.Meta))) &&
                    !string.IsNullOrEmpty(Text) && selectionStartIndex != -1)
                {
                    var lowestIndex  = selectionStartIndex < selectionEndIndex ? selectionStartIndex : selectionEndIndex;
                    var highestIndex = selectionStartIndex < selectionEndIndex ? selectionEndIndex : selectionStartIndex;
                    Game.Renderer.SetClipboardText(Text.Substring(lowestIndex, highestIndex - lowestIndex));

                    RemoveSelectedText();
                    OnTextEdited();
                }

                break;

            case Keycode.C:
                ResetBlinkCycle();
                if (((!isOSX && e.Modifiers.HasModifier(Modifiers.Ctrl)) || (isOSX && e.Modifiers.HasModifier(Modifiers.Meta))) &&
                    !string.IsNullOrEmpty(Text) && selectionStartIndex != -1)
                {
                    var lowestIndex  = selectionStartIndex < selectionEndIndex ? selectionStartIndex : selectionEndIndex;
                    var highestIndex = selectionStartIndex < selectionEndIndex ? selectionEndIndex : selectionStartIndex;
                    Game.Renderer.SetClipboardText(Text.Substring(lowestIndex, highestIndex - lowestIndex));
                }

                break;

            case Keycode.DELETE:
                // cmd+delete is equivalent to ctrl+k on non-osx
                ResetBlinkCycle();
                if (selectionStartIndex != -1)
                {
                    RemoveSelectedText();
                }
                else if (CursorPosition < Text.Length)
                {
                    // Write directly to the Text backing field to avoid unnecessary validation
                    if ((!isOSX && e.Modifiers.HasModifier(Modifiers.Ctrl)) || (isOSX && e.Modifiers.HasModifier(Modifiers.Alt)))
                    {
                        text = text.Substring(0, CursorPosition) + text.Substring(GetNextWhitespaceIndex());
                    }
                    else if (isOSX && e.Modifiers.HasModifier(Modifiers.Meta))
                    {
                        text = text.Remove(CursorPosition);
                    }
                    else
                    {
                        text = text.Remove(CursorPosition, 1);
                    }

                    CursorPosition = CursorPosition.Clamp(0, text.Length);
                    OnTextEdited();
                }

                break;

            case Keycode.BACKSPACE:
                // cmd+backspace is equivalent to ctrl+u on non-osx
                ResetBlinkCycle();
                if (selectionStartIndex != -1)
                {
                    RemoveSelectedText();
                }
                else if (CursorPosition > 0)
                {
                    // Write directly to the Text backing field to avoid unnecessary validation
                    if ((!isOSX && e.Modifiers.HasModifier(Modifiers.Ctrl)) || (isOSX && e.Modifiers.HasModifier(Modifiers.Alt)))
                    {
                        var prevWhitespace = GetPrevWhitespaceIndex();
                        text           = text.Substring(0, prevWhitespace) + text.Substring(CursorPosition);
                        CursorPosition = prevWhitespace;
                    }
                    else if (isOSX && e.Modifiers.HasModifier(Modifiers.Meta))
                    {
                        text           = text.Substring(CursorPosition);
                        CursorPosition = 0;
                    }
                    else
                    {
                        CursorPosition--;
                        text = text.Remove(CursorPosition, 1);
                    }

                    OnTextEdited();
                }

                break;

            case Keycode.V:
                ResetBlinkCycle();

                if (selectionStartIndex != -1)
                {
                    RemoveSelectedText();
                }

                if ((!isOSX && e.Modifiers.HasModifier(Modifiers.Ctrl)) || (isOSX && e.Modifiers.HasModifier(Modifiers.Meta)))
                {
                    var clipboardText = Game.Renderer.GetClipboardText();

                    // Take only the first line of the clipboard contents
                    var nl = clipboardText.IndexOf('\n');
                    if (nl > 0)
                    {
                        clipboardText = clipboardText.Substring(0, nl);
                    }

                    clipboardText = clipboardText.Trim();
                    if (clipboardText.Length > 0)
                    {
                        HandleTextInput(clipboardText);
                    }
                }

                break;

            case Keycode.A:
                // Ctrl+A as Select-All, or Cmd+A on OSX
                if ((!isOSX && e.Modifiers.HasModifier(Modifiers.Ctrl)) || (isOSX && e.Modifiers.HasModifier(Modifiers.Meta)))
                {
                    ClearSelection();
                    HandleSelectionUpdate(0, Text.Length);
                }

                break;

            default:
                break;
            }

            return(true);
        }
示例#33
0
	// Use this for initialization
	public override void Start()
	{
		base.Start();
		for (int c = 0; c < Cursors.Count; ++c)
		{
			var cursorPos = new CursorPosition();
			cursorPositions.Add(cursorPos);
			SetCursorPosition(c, cursorPos);
		}
		cornerAnchors.Clear();
		for(int r=0; r<4; ++r)
		{
			RectTransform localTransform = this.transform as RectTransform;
			GameObject cornerObj = GameObjectFactory.Instance.SpawnUI("UI/CornerAnchor", localTransform.parent);
			cornerObj.name = "CornerAnchor "+r;
			cornerObj.transform.SetParent(localTransform);
			CornerAnchor cornerAnchor = cornerObj.GetComponent<CornerAnchor>();
			cornerAnchors.Add(cornerAnchor);

			RectTransform tr = cornerAnchor.transform as RectTransform;
			tr.anchoredPosition = GetCornerPos(r);
			int padding = 20;

			tr = cornerAnchors[r].cursor.transform as RectTransform;
			tr.anchoredPosition = new Vector2(34,-30);
			tr = cornerAnchors[r].cursorText.transform as RectTransform;
			tr.anchoredPosition = new Vector2(31,padding+5);
			tr = cornerAnchors[r].btnAlphaText.transform as RectTransform;
			tr.anchoredPosition = new Vector2(5,0);
			tr = cornerAnchors[r].btnBravoText.transform as RectTransform;
			tr.anchoredPosition = new Vector2(66,0);

			Vector2 offsetMin = Vector2.zero;
			offsetMin.y -= padding;
			tr = cornerAnchors[r].brickAlpha0Text.transform as RectTransform;
			tr.anchoredPosition = offsetMin;
			offsetMin.y -= padding;
			tr = cornerAnchors[r].brickAlpha1Text.transform as RectTransform;
			tr.anchoredPosition = offsetMin;
			offsetMin.y -= padding;
			tr = cornerAnchors[r].brickAlpha2Text.transform as RectTransform;
			tr.anchoredPosition = offsetMin;
			offsetMin.y -= padding;
			tr = cornerAnchors[r].brickAlpha3Text.transform as RectTransform;
			tr.anchoredPosition = offsetMin;
			offsetMin.y -= padding;

			offsetMin = Vector2.zero;
			offsetMin.x += 75;
			offsetMin.y -= padding;
			tr = cornerAnchors[r].brickBravo0Text.transform as RectTransform;
			tr.anchoredPosition = offsetMin;
			offsetMin.y -= padding;
			tr = cornerAnchors[r].brickBravo1Text.transform as RectTransform;
			tr.anchoredPosition = offsetMin;
			offsetMin.y -= padding;
			tr = cornerAnchors[r].brickBravo2Text.transform as RectTransform;
			tr.anchoredPosition = offsetMin;
			offsetMin.y -= padding;
			tr = cornerAnchors[r].brickBravo3Text.transform as RectTransform;
			tr.anchoredPosition = offsetMin;
			offsetMin.y -= padding;

			
		}

		Transform actionBricksTransform = GameObject.Find("ActionBricks").transform;
		int i = 0;
		int j = -1;

		foreach (string k in ActionBricksDictionary.Dictionary.Keys)
		{
			actionMethods.Add(ActionBricksDictionary.Dictionary[k].method);
			if (i % MaxI == 0)
			{
				i = 0;
				j++;
			}

			var cube = Instantiate(ActionBrick);
			cube.SetParent(actionBricksTransform);
			cube.localPosition = new Vector3((i - MaxI / 2) * BrickSize, -j * BrickSize + BrickSize, 0);
			cube.Find("BrickText").GetComponent<Text>().text = ActionBricksDictionary.Dictionary[k].name;

			var sprite = Resources.Load<Sprite>(ActionBricksDictionary.Dictionary[k].image);
			cube.Find("BrickBg").GetComponent<Image>().sprite = sprite;
			actions.Add(cube);
			i++;

			maxJ = j;
		}
	}
示例#34
0
 public static string SetBufferPosition(CursorPosition position)
 {
     return SetCursorPosition(position.Row, position.Column);
 }
示例#35
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (_mouseDown == CursorPosition.NONE)
     {
         Parent.Capture = true;
         _mouseStart = new Point(e.X, e.Y);
         _mouseDown = GetCursorPosition(e.X, e.Y);
         Invalidate();
     }
 }
示例#36
0
	private void SetCursorPosition(int idx, CursorPosition cp)
	{
		this.Cursors[idx].localPosition = new Vector3((cp.i - MaxI / 2) * BrickSize, -cp.j * BrickSize + BrickSize, 0);
	}
示例#37
0
    public static void ResizeWindow(Window window, CursorPosition pos) {
      IntPtr handle;
      
      if( _winHandles.ContainsKey(window) ) 
        handle = _winHandles[window];
      else {
        HwndSource hs = (HwndSource)PresentationSource.FromVisual(window);
        _winHandles.Add(window, handle = hs.Handle);
      }

      Native.SendMessage(handle, Native.WM_SYSCOMMAND,
          (IntPtr)( 61440 + pos ), IntPtr.Zero);
    }
示例#38
0
 protected void OnParentMouseUp(object sender, MouseEventArgs e)
 {
     if (_mouseDown != CursorPosition.NONE)
     {
         Control.SetBounds(Left + BorderWidth - OffSet.X, Top + BorderWidth - OffSet.Y, Width - BorderWidth * 2, Height - BorderWidth * 2);
         Parent.Capture = false;
         _mouseDown = CursorPosition.NONE;
         Parent.Refresh();
     }
 }
示例#39
0
        public static void RopSeekRowFractionalResponse(bool isZeroNumerator, bool isSmallDenominator, CursorPosition cursorPosition)
        {
            // When numerator field is 0, the cursor position is begin
            if (isZeroNumerator)
            {
                Condition.IsTrue(cursorPosition == CursorPosition.BEGIN);
                ModelHelper.CaptureRequirement(514, @"[In Processing RopSeekRowFractional] If the Numerator field is set to 0, the cursor MUST move to the beginning of the table.");
            }

            // When numerator field is greater than denominator, the cursor position is end
            if (isSmallDenominator)
            {
                Condition.IsTrue(cursorPosition == CursorPosition.END);
                ModelHelper.CaptureRequirement(515, @"[In Processing RopSeekRowFractional] If the Numerator field value is greater than or equal to the Denominator field, the cursor MUST move to the end of the table.");
            }
        }
 private void KinectCursor_LeftMouseUp(object sender, CursorPosition e)
 {
     this.inputSimulator.Mouse.LeftButtonUp();
 }
示例#41
0
 private void SetCursor(CursorPosition position)
 {
     this._parent.Messenger.Raise(new TextBoxSetCaretMessage(
                                      position.Index < 0 ? InputText.Length : position.Index, position.SelectionLength));
 }
示例#42
0
 private void SetCursor(CursorPosition position)
 {
     this._parent.Messenger.Raise(new TextBoxSetCaretMessage(
         position.Index < 0 ? InputText.Length : position.Index, position.SelectionLength));
 }
示例#43
0
        public static void RopQueryPositionResponse(CursorPosition cursorPosition, bool isRowCount)
        {
            // Cursor is current position and  total number of rows in response.
            Condition.IsTrue(isRowCount && (cursorPosition == CursorPosition.BEGIN
                    || cursorPosition == CursorPosition.CURRENT
                    || cursorPosition == CursorPosition.END));
            ModelHelper.CaptureRequirement(491, @"[In Processing RopQueryPosition] The RopQueryPosition ROP ([MS-OXCROPS] section 2.2.5.7) MUST send the current position of the cursor and the total number of rows in the table in the response.");

            // The server MUST invalidate all current bookmarks of the table and MUST move the cursor position to the beginning of the table.
            if (bookmarkCreated && restrictFlags.ContainsValue(true))
            {
                // After ROPSetColumns ROP, restrict, it need to use ROPQueryRows ROP to verify whether the columns, restrict set in the previous calls works. So this requirement is verified here.
                Condition.IsTrue(!validBookmark && (cursorPosition == CursorPosition.BEGIN)); 
                ModelHelper.CaptureRequirement(453, "[In Processing RopRestrict] When this ROP is sent, the server MUST invalidate all current bookmarks of the table and MUST move the cursor position to the beginning of the table.");
            }
        }
示例#44
0
        /// <summary>
        /// Will update the whole selection and sets SelectionStart to "InStart",
        /// SelectionLength to "InLength" and the cursor to either SelectionStart
        /// or SelectionEnd, depending on the value set for "InCursorPos".
        /// </summary>
        /// <param name="InCursorPos"></param>
        /// <param name="InStart"></param>
        /// <param name="InLength"></param>
        void Select(
            CursorPosition InCursorPos,
            Int32 InStart,
            Int32 InLength)
        {
            InternalSelect(InCursorPos, InStart, InLength);

            UpdateSelection();

            if (OnSelectionChanged != null)
                OnSelectionChanged(this);
        }
		protected CursorPositionToken(CursorPosition position) {
			this.position = position;
		}