Ejemplo n.º 1
0
        void OnEditModeChanged()
        {
            if (EditMode)
            {
                if (EditControl != null)
                {
                    EditControl.Show();
                    EditControl.Focus();
                }
            }
            else
            {
                if (EditControl != null && EditControl.Visible)
                {
                    EditControl.Hide();
                }

                EditingObject = null;

                if (this.CanFocus)
                {
                    this.Focus();
                }
            }
        }
Ejemplo n.º 2
0
        Rectangle GetObjectRect(ITextObject tobj)
        {
            if (tobj == null)
            {
                throw new ArgumentNullException();
            }

            Rectangle rect = PaintHelper.Zoom(tobj.Bounds, Zoom);

            if (HorizontalScroll.Enabled)
            {
                rect.X -= HorizontalScroll.Value;
            }

            if (VerticalScroll.Enabled)
            {
                rect.Y -= VerticalScroll.Value;
            }

            //rect.X += Margin.Left;
            //rect.Y += Margin.Top;

            rect.X += TranslatePoint.X;
            rect.Y += TranslatePoint.Y;

            return(rect);
        }
Ejemplo n.º 3
0
        Rectangle GetObjectRect(ITextObject tobj)
        {
            if (tobj == null)
            {
                throw new ArgumentNullException();
            }

            Rectangle rect;

            if (tobj is Topic)
            {
                rect = PaintHelper.Zoom(((Topic)tobj).GlobalTextBounds, Zoom);
            }
            else
            {
                rect = PaintHelper.Zoom(tobj.Bounds, Zoom);
            }

            if (HorizontalScroll.Enabled)
            {
                rect.X -= HorizontalScroll.Value;
            }

            if (VerticalScroll.Enabled)
            {
                rect.Y -= VerticalScroll.Value;
            }

            rect.X += TranslatePoint.X;
            rect.Y += TranslatePoint.Y;

            return(rect);
        }
 protected override void OnMouseEvent(MouseClickArgs arg){
     if (null != m_text)
         m_text.Delete();
     m_text = DrwText.Create(
         arg.point, string.Format("user mouse {0} click at bar {1} on data stream {2}",
         arg.buttons, arg.bar_number, arg.data_number));
 }
Ejemplo n.º 5
0
        public bool contains(ITextObject text)
        {
            try {
                var extractedTexts = extractionStrategy.extract(text);
                foreach (var t in extractedTexts)
                {
                    if (t.Contains(findTarget))
                    {
                        return(true);
                    }
                }

                return(false);
            }
            catch (Exception e) {
                if (e.Message.Contains("PatternMatchingExtraction.cutText"))
                {
                    return(false);
                }
                else
                {
                    throw e;
                }
            }
        }
Ejemplo n.º 6
0
        public IEnumerable <ExtractionResult> extract(ITextObject text)
        {
            IEnumerable <ExtractionResult> originExtractionResults = performExtractionBlock(text);
            IEnumerable <ExtractionResult> results = performTransformationBlock(originExtractionResults);

            return(results);
        }
Ejemplo n.º 7
0
        protected override void CalcBar()
        {
            if ((Bars.CurrentBar % 5 == 0) && current < Bars.CurrentBar)
            {
                //*
                if (this.CurrentPosition.Side == EMarketPositionSide.Flat)
                {
                    BUY.Send("BUY", 1);
                    current = Bars.CurrentBar;
                }
                else
                {
                    BUY_C.Send("SELL");
                    current = Bars.CurrentBar;
                }
                //*/

                //*
                ++iii;
                current = Bars.CurrentBar;
                ITextObject cObject = this.DrwText.Create(new ChartPoint(Bars.Low[0]), iii.ToString());
                cObject.HStyle = ETextStyleH.Center;

                cObject        = this.DrwText.Create(new ChartPoint(BarsOfData(2).Low[0]), iii.ToString(), 2);
                cObject.HStyle = ETextStyleH.Center;
                //*/
            }

            cText.Text = DateTime.Now.ToString();
        }
Ejemplo n.º 8
0
 /// <summary>
 ///   指出目前的物件是否等於另一個具有相同型別的物件。
 /// </summary>
 /// <param name="other">要與這個物件相互比較的物件。</param>
 /// <returns>如果目前的物件等於 other 參數,則為 true,否則為 false。</returns>
 public bool Equals(ITextObject other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this.ID == other.ID);
 }
 protected override void StartCalc(){
     m_textid = DrwText.Create(new ChartPoint(Bars.Time[0], Bars.Close[0]), "CurrentState");
     m_textid.HStyle = ETextStyleH.Left;
     m_textid.VStyle = ETextStyleV.Below;
     m_sync_state = "MP is synchronized!";
     m_diff_state = string.Format("MP syncronization.\nWait {0} seconds", TimeOutMS*0.001);
     m_mp_diff = false;
     m_mp_corrected = false;
 }
 protected override void OnMouseEvent(MouseClickArgs arg)
 {
     if (null != m_text)
     {
         m_text.Delete();
     }
     m_text = DrwText.Create(
         arg.point, string.Format("user mouse {0} click at bar {1} on data stream {2}",
                                  arg.buttons, arg.bar_number, arg.data_number));
 }
 protected override void StartCalc()
 {
     m_textid        = DrwText.Create(new ChartPoint(Bars.Time[0], Bars.Close[0]), "CurrentState");
     m_textid.HStyle = ETextStyleH.Left;
     m_textid.VStyle = ETextStyleV.Below;
     m_sync_state    = "MP is synchronized!";
     m_diff_state    = string.Format("MP syncronization.\nWait {0} seconds", TimeOutMS * 0.001);
     m_mp_diff       = false;
     m_mp_corrected  = false;
 }
Ejemplo n.º 12
0
 private IEnumerable <ExtractionResult> performExtractionBlock(ITextObject text)
 {
     foreach (var extractionBlock in extractionBlocks)
     {
         var id     = extractionBlock.order;
         var name   = extractionBlock.name;
         var result = extractionBlock.extract(text);
         yield return(new ExtractionResult(id, name, result));
     }
 }
 protected override void CalcBar(){
     if (!Bars.LastBarOnChart) return;
     if (m_text_obj == null)
     {
         m_text_obj = DrwText.Create(new ChartPoint(Bars.Time[0], Bars.Close[0]), texttoplot);
     }
     else{
         this.Text_Float(m_text_obj, textbarsback, textpricepercent);
     }
 }
 protected override void StartCalc(){
     m_textid = DrwText.Create(new ChartPoint(Bars.Time[0], Bars.Close[0]), "CurrentState");
     m_sync_state = "MP is synchronized!";
     m_diff_state = "MP syncronization. Wait " + (TimeOut_ms*.001) + " seconds.";
     m_correction_state = "MP correction order sent. Wait " + (Latency_ms*0.001) + " seconds.";
     m_mp_diff = false;
     m_mp_diff_time_start = 0;
     m_mp_corrected = false;
     m_mp_corrected_time_start = 0;
     m_place_correction_marketorder = false;
 }
 protected override void StartCalc()
 {
     m_textid                       = DrwText.Create(new ChartPoint(Bars.Time[0], Bars.Close[0]), "CurrentState");
     m_sync_state                   = "MP is synchronized!";
     m_diff_state                   = "MP syncronization. Wait " + (TimeOut_ms * .001) + " seconds.";
     m_correction_state             = "MP correction order sent. Wait " + (Latency_ms * 0.001) + " seconds.";
     m_mp_diff                      = false;
     m_mp_diff_time_start           = 0;
     m_mp_corrected                 = false;
     m_mp_corrected_time_start      = 0;
     m_place_correction_marketorder = false;
 }
Ejemplo n.º 16
0
        protected override void Create()
        {
            BUY    = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.UserSpecified, EOrderAction.Buy));
            SELL   = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.UserSpecified, EOrderAction.SellShort));
            BUY_C  = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, EOrderAction.Sell, OrderExit.FromAll));
            SELL_C = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, EOrderAction.BuyToCover, OrderExit.FromAll));

            cText         = this.DrwText.Create(new ChartPoint(1, 50), "1234", true);
            cText.Size    = 13;
            cText.Color   = Color.Yellow;
            cText.BGColor = Color.Red;
            cText.SetFont(System.Drawing.FontStyle.Bold, true);
        }
Ejemplo n.º 17
0
 protected override void CalcBar()
 {
     if (!Bars.LastBarOnChart)
     {
         return;
     }
     if (m_text_obj == null)
     {
         m_text_obj = DrwText.Create(new ChartPoint(Bars.Time[0], Bars.Close[0]), texttoplot);
     }
     else
     {
         this.Text_Float(m_text_obj, textbarsback, textpricepercent);
     }
 }
Ejemplo n.º 18
0
        public bool check(ITextObject text)
        {
            lengthValidation(containsCheckBlocks, expectedResults);
            var lstExpectedResults = expectedResults.ToList();

            foreach (var checkBlock in containsCheckBlocks.Select((v, i) => new { value = v, index = i }))
            {
                if (checkBlock.value.contains(text) != lstExpectedResults[checkBlock.index])
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 19
0
        public virtual void EditObject(ITextObject tobj)
        {
            if (EditMode)
            {
                EndEdit(false);
            }

            if (tobj == null || ReadOnly)
            {
                return;
            }

            if (EditControl == null)
            {
                EditControl = CreateEditControl();
            }
            if (EditControl == null)
            {
                return;
            }
            if (EditControl.Parent != this)
            {
                this.Controls.Add(EditControl);
            }
            EditControl.BringToFront();

            EditingObject    = tobj;
            EditControl.Text = tobj.Text;
            ResetEditControlBounds(tobj);

            Font font;

            if (tobj.Font != null)
            {
                font = tobj.Font;
            }
            else
            {
                font = ChartBox.Font;
            }
            if (Zoom != 1.0f)
            {
                font = new Font(font.FontFamily, font.Size * Zoom, font.Style);
            }
            EditControl.Font = font;

            EditMode = true;
        }
        public List <string> extract(ITextObject textObject)
        {
            string cuttedText = cutText(textObject.text());
            string pattern    = patternWithLookAround();

            MatchCollection match;

            try {
                match = Regex.Matches(cuttedText, pattern);
            }
            catch (Exception e) {
                throw new InvalidOperationException("PatternMatchingExtraction.cutText: text matching failed\r\n" + e.Message);
            }

            return(matchToStringList(match).ToList());
        }
Ejemplo n.º 21
0
        private StringCollection Script(ITextObject obj, SmoScriptingContext ctx)
        {
            var output = new StringCollection();

            if (ctx.ScriptDatabaseContext)
            {
                AddDatabaseContext(output, ctx);
                AddBatchSeparator(output, ctx);
            }

            AddAnsiNulls(output, ctx);
            AddBatchSeparator(output, ctx);
            AddQuotedIdentifier(output, ctx);
            AddBatchSeparator(output, ctx);
            AddHeader(output, obj);
            AddBody(output, obj);

            return(output);
        }
 protected override void CalcBar(){
     if (m_criteria(0))
     {
         var m_count = m_criteria.CountIF(length);
         if (PublicFunctions.DoubleGreaterEquals(m_count, occur)){
             Plot1.Set(0, Bars.High[0]);
             Alerts.Alert();
             if (showtext){
                 m_textid = DrwText.Create(new ChartPoint(Bars.Time[0], Bars.High[0]), m_count.ToString());
                 m_textid.HStyle = ETextStyleH.Center;
                 m_textid.VStyle = ETextStyleV.Above;
                 m_textid.Color = textcolor;
             }
         }
     }
     else{
         Plot1.Reset();
     }
 }
Ejemplo n.º 23
0
        private void ResetEditControlBounds(ITextObject tobj)
        {
            Rectangle rect = GetObjectRect(tobj);

            rect.X += ChartBox.Left;
            rect.Y += ChartBox.Top;

            int minH = tobj.Font != null ? tobj.Font.Height : ChartBox.Font.Height;

            if (rect.Height < minH)
            {
                rect.Height = minH;
            }

            rect.Width--;
            rect.Height--;
            rect.Inflate(GeneralRender.OutBoxSpace + 2, GeneralRender.OutBoxSpace + 2);
            EditControl.Bounds = rect;
        }
Ejemplo n.º 24
0
 protected override void CalcBar()
 {
     if (m_criteria(0))
     {
         var m_count = m_criteria.CountIF(length);
         if (PublicFunctions.DoubleGreaterEquals(m_count, occur))
         {
             Plot1.Set(0, Bars.High[0]);
             Alerts.Alert();
             if (showtext)
             {
                 m_textid        = DrwText.Create(new ChartPoint(Bars.Time[0], Bars.High[0]), m_count.ToString());
                 m_textid.HStyle = ETextStyleH.Center;
                 m_textid.VStyle = ETextStyleV.Above;
                 m_textid.Color  = textcolor;
             }
         }
     }
     else
     {
         Plot1.Reset();
     }
 }
Ejemplo n.º 25
0
 public ChangeTextCommand(ITextObject tobj, string newText)
 {
     TheObject = tobj;
     NewText   = newText;
 }
Ejemplo n.º 26
0
 public List <string> extract(ITextObject textObject)
 {
     return(extractionStrategy.extract(textObject));
 }
Ejemplo n.º 27
0
        public void Update(GameTime gameTime)
        {
            if (CurrentTextObject == null)
            {
                CurrentTextObject = TxtReader.NextTxtObject();
            }

            if (Dialogue != null)
            {
                EndOfLine = Dialogue.Complete();
            }

            switch (CurrentTextObject.GetType().Name)
            {
            case "Background":
                Background = (Background)CurrentTextObject;
                PriorCharacterAnimation = null;
                CurrentTextObject       = TxtReader.NextTxtObject();
                break;

            case "CharacterAnimation":
                CharacterAnimation CurrentAnimation = (CharacterAnimation)CurrentTextObject;
                DefaultAnimation  = CurrentAnimation;
                CurrentTextObject = TxtReader.NextTxtObject();
                break;

            case "LineOfDialogue":
                Dialogue = (LineOfDialogue)CurrentTextObject;
                if (DefaultAnimation != null)
                {
                    Dialogue.SetSecondAnimation(DefaultAnimation, DESATURATION_PERCENT);
                }

                if (PreviousButtonState == ButtonState.Pressed && Mouse.GetState().LeftButton == ButtonState.Released && EndOfLine)
                {
                    CharacterAnimation CurrentCharacter = Dialogue.CharacterAnimation;
                    CurrentTextObject = TxtReader.NextTxtObject();
                    EndOfLine         = false;

                    CharacterAnimation NextCharacter = null;

                    if (CurrentTextObject != null)
                    {
                        NextCharacter = CurrentCharacterAnimation();
                    }

                    if (CurrentCharacter != null && NextCharacter != null &&
                        !NextCharacter.CharacterName.Equals(CurrentCharacter.CharacterName))
                    {
                        PriorCharacterAnimation = CurrentCharacter;
                        DefaultAnimation        = null;
                    }
                }
                break;

            default:
                CurrentTextObject = TxtReader.NextTxtObject();
                break;
            }

            TextEnd = TxtReader.IsEmpty();
            if (!TextEnd)
            {
                CurrentTextObject.Update(gameTime);
                PreviousButtonState = Mouse.GetState().LeftButton;
            }
        }
Ejemplo n.º 28
0
        public ITextObject NextTxtObject()
        {
            String      CurrentString = Text.Dequeue();
            char        FirstChar     = CurrentString[FIRST_INDEX];
            ITextObject TextObject    = null;

            if (Text.Count > 0)
            {
                switch (FirstChar)
                {
                case BACKGROUND:
                    return(new Background(Content, CurrentString.Substring(SECOND_INDEX)));

                case AUDIO:
                    return(new Audio(Content, CurrentString.Substring(SECOND_INDEX)));

                case CHARACTER:
                    return(new CharacterAnimation(Content, CurrentString.Substring(SECOND_INDEX), null));

                /**
                 * case CHOICE:
                 *
                 *  List<String[]> ChoiceKeys = new List<String[]>();
                 *  while (FirstChar == CHOICE)
                 *  {
                 *      ChoiceKeys.Add(CurrentString.Substring(SECOND_INDEX).Split(SPLIT));
                 *      TextIndex++;
                 *      CurrentString = Text[TextIndex];
                 *      FirstChar = CurrentString[FIRST_INDEX];
                 *  }
                 *
                 *  List<String[]> ChoiceValues = new List<String[]>();
                 *
                 *  for (int i = 1; i < ChoiceKeys.Count; i++)
                 *  {
                 *      int LastIndex = Array.IndexOf(Text, JUMP + ChoiceKeys[i][FIRST_INDEX]);
                 *      String[] ChoiceText = new ArraySegment<String>(Text, TextIndex, LastIndex - TextIndex).ToArray();
                 *      ChoiceValues.Add(ChoiceText);
                 *      TextIndex = LastIndex + 1;
                 *  }
                 *
                 *  ChoiceValues.Add(new ArraySegment<String>(Text, TextIndex, Text.Length - TextIndex).ToArray());
                 *
                 *  Dictionary<String[], String[]> ChoiceDictionary = new Dictionary<string[], string[]>();
                 *
                 *  for (int i = 0; i < ChoiceKeys.Count; i++)
                 *  {
                 *      ChoiceDictionary.Add(ChoiceKeys[i], ChoiceValues[i]);
                 *  }
                 *
                 *  return new ChoiceDialogue(ChoiceDictionary);
                 *
                 * case JUMP:
                 *  return TextObject;
                 **/

                case ADD:
                    char     SecondChar       = CurrentString[SECOND_INDEX];
                    String[] CharacterChanges = CurrentString.Substring(CHANGE_INDEX).Split(SPLIT);

                    foreach (String Change in CharacterChanges)
                    {
                        switch (SecondChar)
                        {
                        case FLAG:
                            MainCharacter.EventFlags.Add(Change);
                            break;

                        case RELATIONSHIP:
                            String[] Relationship = Change.Split(ADDSPLIT);
                            String   Character    = Relationship[FIRST_INDEX];
                            int      Heart        = MainCharacter.Relationships.GetValueOrDefault(Character, 0);

                            if (Heart == 0)
                            {
                                MainCharacter.Relationships.Add(Character, Int32.Parse(Relationship[SECOND_INDEX]));
                            }
                            else
                            {
                                MainCharacter.Relationships[Character] = Heart + Int32.Parse(Relationship[SECOND_INDEX]);
                            }
                            break;

                        case STAT:
                            String[] Stat      = Change.Split(ADDSPLIT);
                            String   StatPoint = Stat[FIRST_INDEX];
                            int      Level     = MainCharacter.Stats.GetValueOrDefault(StatPoint, 0);

                            if (Level == 0)
                            {
                                MainCharacter.Stats.Add(StatPoint, Int32.Parse(Stat[SECOND_INDEX]));
                            }
                            else
                            {
                                MainCharacter.Stats[StatPoint] = Level + Int32.Parse(Stat[SECOND_INDEX]);
                            }

                            break;

                        case NOTEBOOK:
                            MainCharacter.Journal.Add(Change);
                            break;
                        }
                    }
                    return(NextTxtObject());

                default:
                    int CharacterIndex = CurrentString.IndexOf(CHARACTER);
                    int AnimationIndex = CurrentString.IndexOf(ANIMATION);
                    int SoundIndex     = CurrentString.IndexOf(AUDIO);

                    String Dialogue = CurrentString;
                    String Sound    = null;

                    if (CharacterIndex != -1)
                    {
                        Dialogue = CurrentString.Substring(FIRST_INDEX, CharacterIndex);
                        String CharacterName = CurrentString.Substring(CharacterIndex + 1, AnimationIndex - CharacterIndex - 2);
                        String Animation     = CurrentString.Substring(AnimationIndex + 1);

                        if (SoundIndex != -1)
                        {
                            Animation = CurrentString.Substring(AnimationIndex + 1, SoundIndex - AnimationIndex - 2);
                            Sound     = CurrentString.Substring(SoundIndex + 1);
                        }

                        return(new LineOfDialogue(Content, Dialogue, Sound, new CharacterAnimation(Content, CharacterName, Animation)));
                    }
                    else if (SoundIndex != -1)
                    {
                        Dialogue = CurrentString.Substring(FIRST_INDEX, SoundIndex);
                        Sound    = CurrentString.Substring(SoundIndex + 1);
                    }

                    return(new LineOfDialogue(Content, Dialogue, Sound, null));
                }
            }

            return(TextObject);
        }
Ejemplo n.º 29
0
        public void ChangeObjectText(ITextObject tobj, string newText)
        {
            ChangeTextCommand command = new ChangeTextCommand(tobj, newText);

            ExecuteCommand(command);
        }
Ejemplo n.º 30
0
		/// <summary>
		///   指出目前的物件是否等於另一個具有相同型別的物件。
		/// </summary>
		/// <param name="other">要與這個物件相互比較的物件。</param>
		/// <returns>如果目前的物件等於 other 參數,則為 true,否則為 false。</returns>
		public bool Equals(ITextObject other) {
			if (other == null) {
				return false;
			}
			return this.ID == other.ID;
		}
Ejemplo n.º 31
0
 private void AddBody(StringCollection output, ITextObject obj)
 {
     output.Add(obj.TextBody);
 }
Ejemplo n.º 32
0
 public void setUp()
 {
     testTextObject_ = Substitute.For <ITextObject>();
     testTextObject_.text().Returns("one: star two: cow  three: dog four: QuestionMark"
                                    + "하나- 별, 둘- 소, 셋- 개, 넷- 물음표");
 }
Ejemplo n.º 33
0
 private void AddHeader(StringCollection output, ITextObject obj)
 {
     output.Add(obj.ScriptHeader(true));
 }