示例#1
0
        public static SnippetSelection GetSnippetSelection(Bitmap bitmap)
        {
            var selection = new SnippetSelection();

            for (int y = 0; y < bitmap.Size.Height; y++)
            {
                bool firstX = true;
                for (int x = 0; x < bitmap.Size.Width; x++)
                {
                    Color pixel = bitmap.GetPixel(x, y);
                    if (pixel.Equals(yellowColor))
                    {
                        if (selection.Start.Y == -1)
                        {
                            selection.Start.Y = y;
                        }
                        if (selection.Start.Y == y && x > selection.Start.X)
                        {
                            selection.Start.X = x;
                        }
                        if (firstX)
                        {
                            firstX          = false;
                            selection.End.X = x;
                        }
                        selection.End.Y = y;
                    }
                }
            }
            return(selection);
        }
示例#2
0
        public static Snippet CalculatePageSelection(Snippet snippet, SnippetSelection selection)
        {
            snippet.StartLine = selection.Start.Y < 80 ? 1 : (int)Math.Round(((decimal)selection.Start.Y - 66) / 40, 0) + 1;
            snippet.EndLine   = selection.End.Y < 120 ? 1 : (int)Math.Round(((decimal)selection.End.Y - 66) / 40, 0);

            snippet.StartPoint = 49 + ((selection.Start.X - 450) * 950 / 338) + 5;
            snippet.EndPoint   = 49 + ((selection.End.X - 450) * 950 / 338);

            return(snippet);
        }
        public override void KeyDown(KeyEventArgs args, KeyStateInfo keyStateInfo)
        {
            if (args.Handled)
            {
                return;
            }

            //open snippets selection window
            if (keyStateInfo.Equals(Session.Current.Settings.SnippetSelectionKeyStateInfo))
            {
                SnippetSelectionVM viewModel        = new SnippetSelectionVM(Session.Current.SnippetManager);
                SnippetSelection   snippetSelection = new SnippetSelection();
                snippetSelection.ViewModel = viewModel;
                if (snippetSelection.ShowDialog() == true)
                {
                    if (snippetSelection.ViewModel.Selected != null)
                    {
                        RunSnippet(snippetSelection.ViewModel.Selected);
                    }
                }
                args.Handled = true;
                return;
            }

            //check snippet hot keys
            foreach (Snippet snippet in Session.Current.Settings.Snippets)
            {
                if (!String.IsNullOrWhiteSpace(snippet.HotKey))
                {
                    KeyStateInfo snippetKeyStateInfo = new KeyStateInfo(snippet.HotKey);
                    if (keyStateInfo.Equals(snippetKeyStateInfo))
                    {
                        RunSnippet(snippet);
                        args.Handled = true;
                        return;
                    }
                }
            }
        }