Example #1
0
        public Finder(
            TextField searchField,
            ISearchLens <T> searchLens,
            ISearchResultProcessor <T> processor,
            ISearchResultDisplayer <T, V> displayer,
            int visibleResults   = 10,
            int indexOfSelection = 0
            )
        {
            _searchLens        = searchLens;
            _processor         = processor;
            _displayer         = displayer;
            _resultData        = new List <T>();
            _selectionPosition = new SelectionPosition(this);
            NumVisibleResults  = visibleResults;
            if (indexOfSelection >= NumVisibleResults)
            {
                throw new ArgumentException("The index of the selection must be less than the number of results.");
            }
            IndexOfSelection = indexOfSelection;

            searchField.RegisterCallback <KeyDownEvent>(HandleSearchFieldInputs);
            searchField.OnValueChanged(e => UpdateSearch(e.newValue));

            _resultDisplay = new ReuseSelectionList <V>(
                _displayer.MakeElement,
                (e, i) => _displayer.ApplyData(_currentSearchTerm, e, _resultData, i),
                new DataSource(_resultData),
                NumVisibleResults,
                IndexOfSelection
                );
            _resultDisplay.Container.CheapDisable();
            _resultDisplay.Prewarm();
            EditorApplication.update += Update;
        }
 public void MoveUp()
 {
     if (bHasSavedData)
     {
         if (currentPosition == SelectionPosition.Nothing)
         {
             currentPosition = SelectionPosition.GoOn;
             goOnB.GetComponent <Button>().Select();
         }
         else if (currentPosition == SelectionPosition.End)
         {
             currentPosition = SelectionPosition.New;
             newB.GetComponent <Button>().Select();
         }
         else if (currentPosition == SelectionPosition.New)
         {
             currentPosition = SelectionPosition.GoOn;
             goOnB.GetComponent <Button>().Select();
         }
     }
     else
     {
         if (currentPosition == SelectionPosition.Nothing)
         {
             currentPosition = SelectionPosition.Start;
             startB.GetComponent <Button>().Select();
         }
         else if (currentPosition == SelectionPosition.End)
         {
             currentPosition = SelectionPosition.Start;
             startB.GetComponent <Button>().Select();
         }
     }
 }
Example #3
0
        public void DrawTriangle(Point corner, double width, double height,
                                 SelectionPosition position)
        {
            double x1, y1, x2, y2, x3, y3;

            x1 = corner.X;
            y1 = corner.Y;

            switch (position)
            {
            case SelectionPosition.Top:
                x2 = x1 + width / 2;
                y2 = y1 + height;
                x3 = x1 - width / 2;
                y3 = y1 + height;
                break;

            case SelectionPosition.Bottom:
            default:
                x2 = x1 + width / 2;
                y2 = y1 - height;
                x3 = x1 - width / 2;
                y3 = y1 - height;
                break;
            }

            SetColor(StrokeColor);
            CContext.MoveTo(x1, y1);
            CContext.LineTo(x2, y2);
            CContext.LineTo(x3, y3);
            CContext.ClosePath();
            StrokeAndFill();
        }
Example #4
0
 public void ChangeSelection(SelectionPosition position)
 {
     SourceEditor.Select(
         position == SelectionPosition.BodyStart ? 0
         : position == SelectionPosition.BodyEnd ? SourceEditor.TextLength
         : 0,
         0);
 }
    public void NewGame()
    {
        startB.transform.localScale = Vector3.zero;
        goOnB.transform.localScale  = Vector3.zero;
        newB.transform.localScale   = Vector3.zero;
        endB.transform.localScale   = Vector3.zero;
        newT.transform.localScale   = new Vector3(0.5f, 0.5f, 1f);
        yesB.transform.localScale   = new Vector3(0.5f, 0.5f, 1f);
        noB.transform.localScale    = new Vector3(0.5f, 0.5f, 1f);

        currentPosition = SelectionPosition.ToBeNew;
    }
 public void MoveRight()
 {
     if (currentPosition == SelectionPosition.YesNew)
     {
         currentPosition = SelectionPosition.ToBeNew;
         newB.GetComponent <Button>().Select();
     }
     else if (currentPosition == SelectionPosition.ToBeNew)
     {
         currentPosition = SelectionPosition.NoNew;
         noB.GetComponent <Button>().Select();
     }
 }
    void Start()
    {
        if (PlayerPrefs.GetInt("Saved") > 0)
        {
            bHasSavedData = true;

            startB.transform.localScale = Vector3.zero;
            goOnB.transform.localScale  = new Vector3(0.5f, 0.5f, 1f);
            newB.transform.localScale   = new Vector3(0.5f, 0.5f, 1f);
        }

        currentPosition = SelectionPosition.Nothing;

        StartCoroutine(InitialDelayedSelection());
    }
        public SelectionConfiguration(float tolerance, float resolution, SelectionPosition selectionType)
        {
            if ((tolerance < 0f) || (tolerance > 1f))
                throw new ArgumentOutOfRangeException(nameof(tolerance), tolerance, "Should be a percentage");

            if ((resolution < 0f) || (resolution > 1f))
                throw new ArgumentOutOfRangeException(nameof(resolution), resolution, "Should be a percentage");

            this.Tolerance = tolerance;
            this.SelectionType = selectionType;

            this.ResolutionX = (int) Math.Round(1f/resolution + 1f, 0);
            this.ResolutionY = (int) Math.Round(1f/resolution + 1f, 0);
            this.MaxSurface = this.ResolutionX*this.ResolutionY;
            this.MinSurface = this.Tolerance*this.MaxSurface;
        }
        private void Init(SelectionPosition selectionType, float tolerance)
        {
            this.Tolerance = tolerance;
            this.SelectionType = selectionType;

            // Automatic resolution            
            var factor = this.Tolerance/10;
            while (!Math.Floor(factor).NearlyEquals(factor))
                factor = factor*10f;

            // Members
            this.ResolutionX = (int) Math.Round(factor*10 + 1f, 0);
            this.ResolutionY = (int) Math.Round(factor*10 + 1f, 0);
            this.MaxSurface = this.ResolutionX*this.ResolutionY;
            this.MinSurface = this.Tolerance*this.MaxSurface;
        }
    public void NewGameNo()
    {
        newT.transform.localScale = Vector3.zero;
        yesB.transform.localScale = Vector3.zero;
        noB.transform.localScale  = Vector3.zero;

        if (PlayerPrefs.GetInt("Saved") > 0)
        {
            goOnB.transform.localScale = new Vector3(0.5f, 0.5f, 1f);
            newB.transform.localScale  = new Vector3(0.5f, 0.5f, 1f);
        }
        else
        {
            startB.transform.localScale = new Vector3(0.5f, 0.5f, 1f);
        }

        endB.transform.localScale = new Vector3(0.5f, 0.5f, 1f);

        currentPosition = SelectionPosition.New;
        newB.GetComponent <Button>().Select();
    }
 public void ChangeSelection(SelectionPosition position)
 {
     SourceEditor.Select(
         position == SelectionPosition.BodyStart ? 0
         : position == SelectionPosition.BodyEnd ? SourceEditor.TextLength
         : 0,
         0);
 }
 /// <summary>
 ///     Define CircularConfiguration with automatic resolution based on tolerance
 /// </summary>
 /// <param name="selectionType"></param>
 public SelectionConfiguration(SelectionPosition selectionType)
 {
     this.Init(selectionType, 1f);
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:PA.TileList.Selection.SelectionConfiguration" /> class.
 /// </summary>
 /// <param name="selectionType">Selection type.</param>
 /// <param name="tolerance">Surface of "on profile items", in %, to be inside to be considered "inside profile"  </param>
 public SelectionConfiguration(SelectionPosition selectionType, float tolerance)
 {
     if ((tolerance < 0f) || (tolerance > 1f))
         throw new ArgumentOutOfRangeException(nameof(tolerance), tolerance, "Must be a percentage");
     this.Init(selectionType, tolerance);
 }
Example #14
0
        public void Move(Selection sel, Point p, Point start)
        {
            double diffX;

            // Apply dragging restrictions
            if (DraggingMode == NodeDraggingMode.None)
            {
                return;
            }
            switch (sel.Position)
            {
            case SelectionPosition.Left:
            case SelectionPosition.Right:
                if (DraggingMode == NodeDraggingMode.Segment)
                {
                    return;
                }
                break;

            case SelectionPosition.All:
                if (DraggingMode == NodeDraggingMode.Borders)
                {
                    return;
                }
                break;
            }

            Time newTime = Utils.PosToTime(p, SecondsPerPixel);

            diffX = p.X - start.X;

            if (p.X < 0)
            {
                p.X = 0;
            }
            else if (newTime > MaxTime)
            {
                p.X = Utils.TimeToPos(MaxTime, SecondsPerPixel);
            }
            newTime = Utils.PosToTime(p, SecondsPerPixel);

            if (TimeNode is StatEvent)
            {
                TimeNode.EventTime = newTime;
                return;
            }

            switch (sel.Position)
            {
            case SelectionPosition.Left:
                if (newTime.MSeconds + MAX_TIME_SPAN > TimeNode.Stop.MSeconds)
                {
                    TimeNode.Start.MSeconds = TimeNode.Stop.MSeconds - MAX_TIME_SPAN;
                }
                else
                {
                    TimeNode.Start = newTime;
                }
                break;

            case SelectionPosition.Right:
                if (newTime.MSeconds - MAX_TIME_SPAN < TimeNode.Start.MSeconds)
                {
                    TimeNode.Stop.MSeconds = TimeNode.Start.MSeconds + MAX_TIME_SPAN;
                }
                else
                {
                    TimeNode.Stop = newTime;
                }
                break;

            case SelectionPosition.All:
                Time tstart, tstop;
                Time diff = Utils.PosToTime(new Point(diffX, p.Y), SecondsPerPixel);

                if (StrictClipping)
                {
                    tstart = TimeNode.Start;
                    tstop  = TimeNode.Stop;
                }
                else
                {
                    tstart = TimeNode.Stop;
                    tstop  = TimeNode.Start;
                }
                if ((tstart + diff) >= new Time(0) && (tstop + diff) < MaxTime)
                {
                    TimeNode.Start += diff;
                    TimeNode.Stop  += diff;
                }
                break;
            }
            movingPos = sel.Position;
        }
Example #15
0
 public void ChangeSelection(SelectionPosition position)
 {
     sourceControl.ChangeSelection(position);
 }
Example #16
0
        protected override void StartMove(Selection sel)
        {
            Drawable          drawable = null;
            SelectionPosition pos = SelectionPosition.BottomRight;
            bool resize = true, copycolor = true, sele = true;

            if (Tool == DrawTool.Selection)
            {
                if (Selections.Count == 0 && currentZoom != 1)
                {
                    widget.SetCursorForTool(DrawTool.Move);
                    inZooming = true;
                }
                return;
            }

            if (sel != null)
            {
                ClearSelection();
            }

            switch (Tool)
            {
            case DrawTool.Line:
                drawable = new Line(MoveStart, new Point(MoveStart.X + 1, MoveStart.Y + 1),
                                    LineType, LineStyle);
                drawable.FillColor = Color;
                pos = SelectionPosition.LineStop;
                break;

            case DrawTool.Cross:
                drawable = new Cross(MoveStart, new Point(MoveStart.X + 1, MoveStart.Y + 1),
                                     LineStyle);
                break;

            case DrawTool.Ellipse:
                drawable = new Ellipse(MoveStart, 2, 2);
                break;

            case DrawTool.Rectangle:
                drawable = new Rectangle(MoveStart, 2, 2);
                break;

            case DrawTool.CircleArea:
                drawable             = new Ellipse(MoveStart, 2, 2);
                drawable.FillColor   = Color.Copy();
                drawable.FillColor.A = byte.MaxValue / 2;
                break;

            case DrawTool.RectangleArea:
                drawable             = new Rectangle(MoveStart, 2, 2);
                drawable.FillColor   = Color.Copy();
                drawable.FillColor.A = byte.MaxValue / 2;
                break;

            case DrawTool.Counter:
                drawable           = new Counter(MoveStart, 3 * LineWidth, 0);
                drawable.FillColor = Color.Copy();
                (drawable as Counter).TextColor = Color.Grey2;
                resize = false;
                break;

            case DrawTool.Text:
            case DrawTool.Player:
            {
                int  width, heigth;
                Text text = new Text(MoveStart, 1, 1, "");
                if (ConfigureObjectEvent != null)
                {
                    ConfigureObjectEvent(text, Tool);
                }
                if (text.Value == null)
                {
                    return;
                }
                Config.DrawingToolkit.MeasureText(text.Value, out width, out heigth,
                                                  Config.Style.Font, FontSize, FontWeight.Normal);
                text.Update(new Point(MoveStart.X - width / 2, MoveStart.Y - heigth / 2),
                            width, heigth);
                text.TextColor = TextColor.Copy();
                text.FillColor = text.StrokeColor = TextBackgroundColor.Copy();
                text.TextSize  = FontSize;
                resize         = copycolor = sele = false;
                drawable       = text;
                break;
            }

            case DrawTool.Pen:
            case DrawTool.Eraser:
                handdrawing = true;
                break;

            case DrawTool.Zoom:
            {
                double newZoom = currentZoom;

                if (modifier == ButtonModifier.Shift)
                {
                    newZoom -= 0.1;
                }
                else
                {
                    newZoom += 0.1;
                }
                newZoom = Math.Max(newZoom, MinZoom);
                newZoom = Math.Min(newZoom, MaxZoom);
                Zoom(newZoom, MoveStart);
                break;
            }
            }

            if (drawable != null)
            {
                if (copycolor)
                {
                    drawable.StrokeColor = Color.Copy();
                }
                drawable.LineWidth = LineWidth;
                drawable.Style     = LineStyle;
                var selo = Add(drawable);
                drawing.Drawables.Add(drawable);
                if (Tool == DrawTool.Counter)
                {
                    UpdateCounters();
                }
                if (sele)
                {
                    if (resize)
                    {
                        UpdateSelection(new Selection(selo, pos, 5));
                    }
                    else
                    {
                        UpdateSelection(new Selection(selo, SelectionPosition.All, 5));
                    }
                    inObjectCreation = true;
                }
                widget.ReDraw();
            }
        }
Example #17
0
        /// <summary>
        /// Move the TimeNodeObject with a given selection sel
        /// from point start to point p.
        /// </summary>
        /// <param name="sel">Selection.</param>
        /// <param name="p">Target point.</param>
        /// <param name="start">Start point.</param>
        public virtual void Move(Selection sel, Point p, Point start)
        {
            Time   newTime;
            double diffX, posX;

            // Apply dragging restrictions
            if (DraggingMode == NodeDraggingMode.None)
            {
                return;
            }
            switch (sel.Position)
            {
            case SelectionPosition.Left:
            case SelectionPosition.Right:
                if (DraggingMode == NodeDraggingMode.Segment)
                {
                    return;
                }
                break;

            case SelectionPosition.All:
                if (DraggingMode == NodeDraggingMode.Borders)
                {
                    return;
                }
                break;
            }

            newTime = Utils.PosToTime(p, SecondsPerPixel);
            diffX   = p.X - start.X;
            p       = p.Copy();

            if (p.X < 0)
            {
                p.X = 0;
            }
            else if (newTime > MaxTime)
            {
                p.X = Utils.TimeToPos(MaxTime, SecondsPerPixel);
            }
            p.X    += ScrollX;
            newTime = Utils.PosToTime(p, SecondsPerPixel);

            switch (sel.Position)
            {
            case SelectionPosition.Left:
                if (ClippingMode == NodeClippingMode.EventTime && !(newTime <= TimeNode.EventTime &&
                                                                    TimeNode.EventTime <= TimeNode.Stop))
                {
                    break;
                }
                if (newTime.MSeconds + MAX_TIME_SPAN > TimeNode.Stop.MSeconds)
                {
                    TimeNode.Start.MSeconds = TimeNode.Stop.MSeconds - MAX_TIME_SPAN;
                }
                else
                {
                    TimeNode.Start = newTime;
                }
                break;

            case SelectionPosition.Right:
                if (ClippingMode == NodeClippingMode.EventTime && !(TimeNode.Start <= TimeNode.EventTime &&
                                                                    TimeNode.EventTime <= newTime))
                {
                    break;
                }
                if (newTime.MSeconds - MAX_TIME_SPAN < TimeNode.Start.MSeconds)
                {
                    TimeNode.Stop.MSeconds = TimeNode.Start.MSeconds + MAX_TIME_SPAN;
                }
                else
                {
                    TimeNode.Stop = newTime;
                }
                break;

            case SelectionPosition.All:
                Time tstart, tstop;
                Time diff = Utils.PosToTime(new Point(diffX, p.Y), SecondsPerPixel);
                bool ok   = false;

                tstart = TimeNode.Start;
                tstop  = TimeNode.Stop;

                switch (ClippingMode)
                {
                case NodeClippingMode.None:
                    ok = true;
                    break;

                case NodeClippingMode.NoStrict:
                    ok = ((tstop + diff) >= new Time(0) && (tstart + diff) < MaxTime);
                    break;

                case NodeClippingMode.LeftStrict:
                    ok = ((tstart + diff) >= new Time(0) && (tstart + diff) < MaxTime);
                    break;

                case NodeClippingMode.RightStrict:
                    ok = (tstop + diff) >= new Time(0) && ((tstop + diff) < MaxTime);
                    break;

                case NodeClippingMode.Strict:
                    ok = ((tstart + diff) >= new Time(0) && (tstop + diff) < MaxTime);
                    break;

                case NodeClippingMode.EventTime:
                    ok = ((tstart + diff) <= TimeNode.EventTime && (tstop + diff) >= TimeNode.EventTime) &&
                         (tstop + diff) - (tstart + diff) >= new Time(MAX_TIME_SPAN);
                    break;
                }

                if (ok)
                {
                    TimeNode.Start += diff;
                    TimeNode.Stop  += diff;
                }
                break;
            }
            movingPos = sel.Position;
        }
 public void ChangeSelection(SelectionPosition position)
 {
     _currentEditor.ChangeSelection(position);
 }
Example #19
0
 public void ChangeSelection(SelectionPosition position)
 {
     contentEditor.ChangeSelection(position);
 }
Example #20
0
        public void Move(Selection sel, Point p, Point start)
        {
            double diffX;

            // Apply dragging restrictions
            if (DraggingMode == NodeDraggingMode.None)
                return;
            switch (sel.Position) {
            case SelectionPosition.Left:
            case SelectionPosition.Right:
                if (DraggingMode == NodeDraggingMode.Segment)
                    return;
                break;
            case SelectionPosition.All:
                if (DraggingMode == NodeDraggingMode.Borders)
                    return;
                break;
            }

            Time newTime = Utils.PosToTime (p, SecondsPerPixel);
            diffX = p.X - start.X;

            if (p.X < 0) {
                p.X = 0;
            } else if (newTime > MaxTime) {
                p.X = Utils.TimeToPos (MaxTime, SecondsPerPixel);
            }
            newTime = Utils.PosToTime (p, SecondsPerPixel);

            if (TimeNode is StatEvent) {
                TimeNode.EventTime = newTime;
                return;
            }

            switch (sel.Position) {
            case SelectionPosition.Left:
                if (newTime.MSeconds + MAX_TIME_SPAN > TimeNode.Stop.MSeconds) {
                    TimeNode.Start.MSeconds = TimeNode.Stop.MSeconds - MAX_TIME_SPAN;
                } else {
                    TimeNode.Start = newTime;
                }
                break;
            case SelectionPosition.Right:
                if (newTime.MSeconds - MAX_TIME_SPAN < TimeNode.Start.MSeconds) {
                    TimeNode.Stop.MSeconds = TimeNode.Start.MSeconds + MAX_TIME_SPAN;
                } else {
                    TimeNode.Stop = newTime;
                }
                break;
            case SelectionPosition.All:
                Time tstart, tstop;
                Time diff = Utils.PosToTime (new Point (diffX, p.Y), SecondsPerPixel);

                if (StrictClipping) {
                    tstart = TimeNode.Start;
                    tstop = TimeNode.Stop;
                } else {
                    tstart = TimeNode.Stop;
                    tstop = TimeNode.Start;
                }
                if ((tstart + diff) >= new Time (0) && (tstop + diff) < MaxTime) {
                    TimeNode.Start += diff;
                    TimeNode.Stop += diff;
                }
                break;
            }
            movingPos = sel.Position;
        }
        public void ChangeSelection(SelectionPosition position)
        {
            MarkupPointer location;
            switch (position)
            {
                case SelectionPosition.BodyStart:
                    location = MarkupServices.CreateMarkupPointer(PostBodyElement,
                                                                  _ELEMENT_ADJACENCY.ELEM_ADJ_AfterBegin);
                    break;
                case SelectionPosition.BodyEnd:
                    location = MarkupServices.CreateMarkupPointer(PostBodyElement,
                                                                  _ELEMENT_ADJACENCY.ELEM_ADJ_BeforeEnd);
                    break;
                default:
                    throw new ArgumentException("Unknown position value");
            }

            IHTMLCaret caret;
            ((IDisplayServices)HTMLDocument).GetCaret(out caret);
            IDisplayPointer displayPointer;
            ((IDisplayServices)HTMLDocument).CreateDisplayPointer(out displayPointer);
            displayPointer.MoveToMarkupPointer((IMarkupPointer)location.PointerRaw, null);
            caret.MoveCaretToPointerEx(displayPointer, 1, 1, _CARET_DIRECTION.CARET_DIRECTION_INDETERMINATE);
        }
Example #22
0
 public Selection(IMovableObject drawable, SelectionPosition selpos, double accuracy=0)
 {
     Drawable = drawable;
     Position = selpos;
     Accuracy = accuracy;
 }
 public void ChangeSelection(SelectionPosition position)
 {
     contentEditor.ChangeSelection(position);
 }
Example #24
0
 public void Move(SelectionPosition s, Point dst, Point start)
 {
     Move(new Selection(null, s, 0), dst, start);
 }
 public void ChangeSelection(SelectionPosition position)
 {
     sourceControl.ChangeSelection(position);
 }
Example #26
0
 public Selection(IMovableObject drawable, SelectionPosition selpos, double accuracy = 0)
 {
     Drawable = drawable;
     Position = selpos;
     Accuracy = accuracy;
 }