// Update is called once per frame
    void Update()
    {
        // Check which context is activated


        // Play the animation according to which context is activated, also according to the car's relative distance to context indicator.

        for (int i = 0; i < this.ContextIndicators.Length; i++)
        {
            ContextScript ctxScript = this.ContextIndicators[i].GetComponent <ContextScript>();
            if (ctxScript.isActivated == true)
            {
                if (ctxScript.ID == 1)
                {
                    GetComponent <Animator>().Play("HumanoidWalk");
                    if (this.transform.position.z > 22.5f)
                    {
                        transform.position = originalPos;
                    }
                }
                else
                {
                    GetComponent <Animator>().Play("HumanoidIdle");
                    transform.position = new Vector3(2f, 2.004f, 24.92f);
                }
            }
        }
    }
示例#2
0
        object FindOrCreateReportersSnapshot(Reporter reporterActivated)
        {
            Strategy strategy = this.ChartFormManager.Executor.Strategy;

            if (strategy == null)
            {
                string msg = "STRATEGY_MUST_NOT_BE_NULL ChartFormManager.Executor.Strategy";
                Debugger.Break();
            }
            ContextScript ctx = strategy.ScriptContextCurrent;

            if (ctx == null)
            {
                string msg = "CONTEXT_MUST_NOT_BE_NULL ChartFormManager.Executor.Strategy.ScriptContextCurrent";
                Debugger.Break();
            }
            Dictionary <string, object> snapshots = ctx.ReportersSnapshots;

            if (snapshots == null)
            {
                string msg = "REPORTERS_SNAPSHOTS_MUST_NOT_BE_NULL ChartFormManager.Executor.Strategy.ScriptContextCurrent.ReporterSnapshots";
                Debugger.Break();
            }
            return(ctx.FindOrCreateReportersSnapshot(reporterActivated));
        }
示例#3
0
        void mnitlbPositionSizeDollarsConstantEachTrade_UserTyped(object sender, LabeledTextBoxUserTypedArgs e)
        {
            try {
                string userTyped = e.StringUserTyped;
                double userTypedDouble;
                bool   validInteger = Double.TryParse(userTyped, out userTypedDouble);
                if (validInteger == false)
                {
                    e.HighlightTextWithRed = true;
                    return;
                }
                if (userTypedDouble <= 0)
                {
                    e.HighlightTextWithRed = true;
                    return;
                }

                ContextScript context = this.ChartFormManager.Strategy.ScriptContextCurrent;
                context.PositionSize = new PositionSize(PositionSizeMode.DollarsConstantForEachTrade, userTypedDouble);

                this.selectOneDeselectResetOthers(this.DdbBacktest.DropDownItems, sender, this.GroupPositionSizeLabeledTextboxes);

                this.ChartFormManager.PopulateSelectorsFromCurrentChartOrScriptContextLoadBarsSaveBacktestIfStrategy("mnitlbPositionSizeDollarsEachTradeConstant_UserTyped");
            } catch (Exception ex) {
                Assembler.PopupException("mnitlbPositionSizeDollarsEachTradeConstant_UserTyped()", ex);
            }
        }
        void mniltbScriptContextRenameTo_UserTyped(object sender, LabeledTextBoxUserTypedArgs e)
        {
            string        scriptContextNewName  = e.StringUserTyped;
            ContextScript scriptContextToRename = this.ScriptContextFromMniTag(sender);

            this.Strategy.ScriptContextRename(scriptContextToRename, scriptContextNewName);
            this.RaiseOnScriptContextRenamed(scriptContextNewName);
            this.ctxParameterBags_Opening(this, null);
        }
        void mniltbScriptContextDuplicateTo_UserTyped(object sender, LabeledTextBoxUserTypedArgs e)
        {
            string        dupeScriptContextName    = e.StringUserTyped;
            ContextScript scriptContextToDuplicate = this.ScriptContextFromMniTag(sender);

            this.Strategy.ScriptContextAdd(dupeScriptContextName, scriptContextToDuplicate);
            this.RaiseOnScriptContextDuplicated(dupeScriptContextName);
            this.ctxParameterBags_Opening(this, null);
        }
示例#6
0
        public void PropagateContextChartOrScriptToLTB(ContextChart ctxChart, Bitmap streamingProviderIcon = null)
        {
            if (base.InvokeRequired)
            {
                base.BeginInvoke((MethodInvoker) delegate { this.PropagateContextChartOrScriptToLTB(ctxChart, streamingProviderIcon); });
                return;
            }

            if (streamingProviderIcon != null)
            {
                this.btnStreaming.Image = streamingProviderIcon;
            }
            // from btnStreaming_Click(); not related but visualises the last clicked state
            if (this.btnStreaming.Checked)
            {
                this.mniBacktestOnSelectorsChange.Enabled = false;
                this.mniBacktestNow.Enabled = false;
                this.btnAutoSubmit.Enabled  = true;
            }
            else
            {
                this.mniBacktestOnSelectorsChange.Enabled = true;
                this.mniBacktestNow.Enabled = true;
                this.btnAutoSubmit.Enabled  = false;
            }

            if (ctxChart.ShowRangeBar)
            {
                this.ChartControl.RangeBarCollapsed = false;
                this.mniShowBarRange.Checked        = true;
            }
            else
            {
                this.ChartControl.RangeBarCollapsed = true;
                this.mniShowBarRange.Checked        = false;
            }

            this.btnStreaming.Checked = ctxChart.ChartStreaming;
            ContextScript ctxScript = ctxChart as ContextScript;

            if (ctxScript == null)
            {
                return;
            }

            this.mniBacktestOnRestart.Checked         = ctxScript.BacktestOnRestart;
            this.mniBacktestOnSelectorsChange.Checked = ctxScript.BacktestOnSelectorsChange;
            this.btnAutoSubmit.Checked = ctxScript.ChartAutoSubmitting;
            this.PropagateContextScriptToLTB(ctxScript);
        }
        ContextScript ScriptContextFromMniTag(object sender)
        {
            var mniOpening             = sender as ToolStripItem;
            ContextMenuStrip mniParent = mniOpening.Owner as ContextMenuStrip;                          // found in debugger
            ContextScript    ctxToLoad = mniParent.Tag as ContextScript;

            if (ctxToLoad == null)
            {
                string msg = "mniOpening[" + mniOpening.Name + "].Tag[" + mniOpening.Tag + "] is not a ScriptContext";
                Assembler.PopupException(msg);
                return(null);
            }
            return(ctxToLoad);
        }
        void mniScriptContextLoad_Click(object sender, EventArgs e)
        {
            ContextScript scriptContextToLoad = this.ScriptContextFromMniTag(sender);

            if (this.Strategy.ScriptContextCurrent == scriptContextToLoad)
            {
                string msg = "won't RaiseOnScriptContextLoad(scriptContextToLoad.Name[" + scriptContextToLoad.Name + "])"
                             + ": GUI should disable the option to (re)load the same (current) ScriptContextCurrent.Name[" + this.Strategy.ScriptContextCurrent.Name + "]";
                Assembler.PopupException(msg);
                return;
            }
            this.RaiseOnScriptContextLoadRequested(scriptContextToLoad.Name);
            this.ctxParameterBags_Opening(this, null);
        }
    public void ActivateContext(int id)
    {
        print("instance ID");
        print(id);

        Context ctx = new Context();

        for (int i = 0; i < this.ContextIndicators.Length; i++)
        {
            //print(this.ContextIndicators[i].GetComponent<ContextScript>().ID);
            if (this.ContextIndicators[i].GetComponent <ContextScript>().ID == id)
            {
                ContextScript ctxScript = this.ContextIndicators[i].GetComponent <ContextScript>();
                ctx.name = ctxScript.textMesh.text;
                ctx.id   = id;

                if (TangibleModeEnabled == false)
                {
                    ctxScript.isActivated = true;
                }

                ctx.active = ctxScript.isActivated;
                //print("context");
                //print(ctx.name);
                //print(ctx.id);
                //print(ctx.active);

                string contextJson = JsonUtility.ToJson(ctx);
                //print(contextJson);

                UDPReceive udp = GameObject.FindWithTag("UDPReceive").GetComponent <UDPReceive>();
                udp.writeSocket(contextJson);
            }
            else
            {
                if (TangibleModeEnabled == false)
                {
                    this.ContextIndicators[i].GetComponent <ContextScript>().isActivated = false; // remove the activation in all other context
                }
            }
        }
    }
        ContextScript ScriptContextFromLabeledTextBoxTag(object sender)
        {
            // rightClick => [Default] => Duplicate To => onKeyPress()
            // TextBox <= LabeledTextBox[DuplicateTo] <= ParentControlHost.Owner[Default] <= Tag[ScriptContext"DEFAULT"]
//			TextBox txt = sender as TextBox;
//			LabeledTextBox lblTxt = txt.Parent as LabeledTextBox;
//			ToolStripControlHost mniOpening = lblTxt.ParentToolStripControlHost;

            MenuItemLabeledTextBox mniltbScriptContextRenameTo = sender as MenuItemLabeledTextBox;
            ContextMenuStrip       mniParent = mniltbScriptContextRenameTo.Owner as ContextMenuStrip;                   // found in debugger
            ContextScript          ctxToLoad = mniParent.Tag as ContextScript;

            if (ctxToLoad == null)
            {
                string msg = "mniltb[" + mniltbScriptContextRenameTo.Name + "].Tag[" + mniltbScriptContextRenameTo.Tag + "] is not a ScriptContext";
                Assembler.PopupException(msg);
                return(null);
            }
            return(ctxToLoad);
        }
        void mniScriptContextDelete_Click(object sender, EventArgs e)
        {
            string msig = "mniParameterBagDelete_Click() ";

            if (this.Strategy == null)
            {
                string msg = "you should keep your rightClickMenu disabled if current chart has no strategy";
                Assembler.PopupException(msig + msg);
                return;
            }
            ContextScript scriptContextToDelete = this.ScriptContextFromMniTag(sender);

            if (scriptContextToDelete == null)
            {
                return;
            }
            this.Strategy.ScriptContextDelete(scriptContextToDelete.Name);
            this.RaiseOnScriptContextDeleted(scriptContextToDelete.Name);
            this.ctxParameterBags_Opening(this, null);
        }
示例#12
0
    // Update is called once per frame
    void Update()
    {
        // Check which context is activated


        // Play the animation according to which context is activated, also according to the car's relative distance to context indicator.

        for (int i = 0; i < this.ContextIndicators.Length; i++)
        {
            ContextScript ctxScript = this.ContextIndicators[i].GetComponent <ContextScript>();
            if (ctxScript.isActivated == true)
            {
                if (ctxScript.ID == 1)
                {
                    GetComponent <Animator>().Play("Shared_CarGiveWay");
                }
                else if (ctxScript.ID == 2)
                {
                    GetComponent <Animator>().Play("Shared_CarStart");
                }
                else if (ctxScript.ID == 3)
                {
                    GetComponent <Animator>().Play("Shared_CarTurnLeft");
                }
                else if (ctxScript.ID == 4)
                {
                    GetComponent <Animator>().Play("Shared_CarWaiting");
                }
                //else
                //{
                //    GetComponent<Animator>().Play("CarDefault");
                //}
                // We commented this to avoid freezing the car if we put car in other context
            }
        }
    }
示例#13
0
        public void PropagateContextScriptToLTB(ContextScript ctxScript)
        {
            if (ctxScript.ScaleInterval.Scale == BarScale.Unknown)
            {
                string msg = "TODO: figure out why deserialized / userSelected strategyClicked[" + this.ChartFormManager.Executor.Strategy
                             + "].ScriptContextCurrent.ScaleInterval[" + ctxScript.ScaleInterval + "] has BarScale.Unknown #4";
                Assembler.PopupException(msg);
            }
            else
            {
                MenuItemLabeledTextBox mnitlbForScale = null;
                switch (ctxScript.ScaleInterval.Scale)
                {
                case BarScale.Minute:           mnitlbForScale = this.mnitlbMinutes; break;

                case BarScale.Hour:                     mnitlbForScale = this.mnitlbDaily; break;

                case BarScale.Daily:            mnitlbForScale = this.mnitlbHourly; break;

                case BarScale.Weekly:           mnitlbForScale = this.mnitlbWeekly; break;

                case BarScale.Monthly:          mnitlbForScale = this.mnitlbMonthly; break;

                //case BarScale.Quarterly		mnitlbForScale = this.mnitlbQuarterly; break;
                case BarScale.Yearly:           mnitlbForScale = this.mnitlbYearly; break;

                default:
                    string msg = "SCALE_UNHANDLED_NO_TEXTBOX_TO_POPULATE " + ctxScript.ScaleInterval.Scale;
                    Assembler.PopupException(msg);
                    break;
                }

                if (mnitlbForScale != null)
                {
                    mnitlbForScale.InputFieldValue = ctxScript.ScaleInterval.Interval.ToString();
                    mnitlbForScale.BackColor       = Color.Gainsboro;
                }
            }

            this.mniShowBarRange.Checked = ctxScript.ShowRangeBar;
            switch (ctxScript.DataRange.Range)
            {
            case BarRange.AllData:
                this.mnitlbShowLastBars.InputFieldValue = "";
                this.mnitlbShowLastBars.BackColor       = Color.White;
                break;

            case BarRange.DateRange:
                this.ChartControl.RangeBar.ValueMin     = ctxScript.DataRange.StartDate;
                this.ChartControl.RangeBar.ValueMax     = ctxScript.DataRange.EndDate;
                this.mnitlbShowLastBars.InputFieldValue = "";
                this.mnitlbShowLastBars.BackColor       = Color.White;
                break;

            case BarRange.RecentBars:
                this.mnitlbShowLastBars.InputFieldValue = ctxScript.DataRange.RecentBars.ToString();
                this.mnitlbShowLastBars.BackColor       = Color.Gainsboro;
                //this.mniShowBarRange.Checked = false;
                break;

            default:
                string msg = "DATE_RANGE_UNHANDLED_RECENT_TIMEUNITS_NYI " + ctxScript.DataRange;
                Assembler.PopupException(msg);
                break;
            }
            this.ChartControl.RangeBarCollapsed = !this.mniShowBarRange.Checked;

            switch (ctxScript.PositionSize.Mode)
            {
            case PositionSizeMode.SharesConstantEachTrade:
                this.mnitlbPositionSizeSharesConstantEachTrade.InputFieldValue = ctxScript.PositionSize.SharesConstantEachTrade.ToString();
                this.mnitlbPositionSizeSharesConstantEachTrade.BackColor       = Color.Gainsboro;
                this.mnitlbPositionSizeDollarsEachTradeConstant.BackColor      = Color.White;
                break;

            case PositionSizeMode.DollarsConstantForEachTrade:
                this.mnitlbPositionSizeDollarsEachTradeConstant.InputFieldValue = ctxScript.PositionSize.DollarsConstantEachTrade.ToString();
                this.mnitlbPositionSizeDollarsEachTradeConstant.BackColor       = Color.Gainsboro;
                this.mnitlbPositionSizeSharesConstantEachTrade.BackColor        = Color.White;
                break;

            default:
                string msg = "POSITION_SIZE_UNHANDLED_NYI " + ctxScript.PositionSize.Mode;
                Assembler.PopupException(msg);
                break;
            }

            DataSourcesForm.Instance.DataSourcesTreeControl.SelectSymbol(ctxScript.DataSourceName, ctxScript.Symbol);
            StrategiesForm.Instance.StrategiesTreeControl.SelectStrategy(this.ChartFormManager.Executor.Strategy);
            this.PropagateSelectorsDisabledIfStreamingForCurrentChart();
        }