Ejemplo n.º 1
0
 public string ToLine()
 {
     return("D1"
            + $"{Field1.ToFixedString(10)}"
            + $"{Field2.ToFixedString(10)}"
            + $"{Field3.ToFixedString(10)}"
            + $"{Field4.ToFixedString(10)}"
            + $"{Field5.ToFixedStringRight(10, '0')}"
            + "");
 }
        protected override void Execute(CodeActivityContext context)
        {
            //Channel Details
            var writeKey = Write_API_Key.Get(context);

            //Field Values
            var f1 = Field1.Get(context) != null ? "&field1=" + Field1.Get(context) : "";
            var f2 = Field2.Get(context) != null ? "&field2=" + Field2.Get(context) : "";
            var f3 = Field3.Get(context) != null ? "&field3=" + Field3.Get(context) : "";
            var f4 = Field4.Get(context) != null ? "&field4=" + Field4.Get(context) : "";
            var f5 = Field5.Get(context) != null ? "&field5=" + Field5.Get(context) : "";
            var f6 = Field6.Get(context) != null ? "&field6=" + Field6.Get(context) : "";
            var f7 = Field7.Get(context) != null ? "&field7=" + Field7.Get(context) : "";
            var f8 = Field8.Get(context) != null ? "&field8=" + Field8.Get(context) : "";

            var chosenFormat = Format.GetHashCode() == 0 ? "" : "." + Format.ToString();

            //Optional Parameters
            var lat        = Lat.Get(context) == 0 ? "" : "&lat=" + Lat.Get(context).ToString();
            var lon        = Long.Get(context) == 0 ? "" : "&long=" + Long.Get(context).ToString();
            var elevation  = Elevation.Get(context) == 0 ? "" : "&elevation=" + Elevation.Get(context).ToString();
            var status     = Status.Get(context) == null ? "" : "&status=" + Status.Get(context);
            var twitter    = Twitter.Get(context) == null ? "" : "&twitter=" + Twitter.Get(context);
            var tweet      = Tweet.Get(context) == null ? "" : "&tweet=" + Tweet.Get(context);
            var created_at = Created_at.Get(context) == null ? "" : "&created_at=" + Created_at.Get(context);


            //Http Request URL
            string URL = "https://api.thingspeak.com/update" + chosenFormat + "?api_key=" + writeKey;

            URL = URL + f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + lat + lon + elevation + status + twitter + tweet + created_at;

            //Creating GET Http Request
            WebRequest   wrGETURL  = WebRequest.Create(URL);
            Stream       objStream = wrGETURL.GetResponse().GetResponseStream();
            StreamReader objReader = new StreamReader(objStream);

            //Capturing the response
            string sLine        = "";
            string httpResponse = "";

            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null)
                {
                    httpResponse = httpResponse + sLine + "\n";
                }
            }
            objStream.Close();
            //objReader.Close();
            Response.Set(context, httpResponse);
        }
Ejemplo n.º 3
0
        private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            bool isNumPadNumeric = (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9);
            bool isNumeric       = (e.Key >= Key.D0 && e.Key <= Key.D9);

            Key[] keysToFilter = { Key.Delete, Key.Back, Key.Left, Key.Right, Key.Tab };
            if (!isNumeric && !isNumPadNumeric && !keysToFilter.Contains(e.Key))
            {
                e.Handled = true;
                return;
            }

            if ((e.Key == Key.Right && (sender as TextBox).CaretIndex == (sender as TextBox).Text.Length))
            {
                if (sender == Field1)
                {
                    Field2.Focus();
                }
                else if (sender == Field2)
                {
                    Field3.Focus();
                }
                else if (sender == Field3)
                {
                    Field4.Focus();
                }

                e.Handled = true;
            }
            else if (e.Key == Key.Left && (sender as TextBox).CaretIndex == 0)
            {
                if (sender == Field4)
                {
                    Field3.Focus();
                }
                else if (sender == Field3)
                {
                    Field2.Focus();
                }
                else if (sender == Field2)
                {
                    Field1.Focus();
                }

                e.Handled = true;
            }
            else if (e.Key == Key.OemMinus)
            {
                e.Handled = true;
            }
        }
Ejemplo n.º 4
0
                public override int GetHashCode()
                {
                    int hash = 1;

                    if (Field3.Length != 0)
                    {
                        hash ^= Field3.GetHashCode();
                    }
                    if (field4_ != null)
                    {
                        hash ^= Field4.GetHashCode();
                    }
                    if (_unknownFields != null)
                    {
                        hash ^= _unknownFields.GetHashCode();
                    }
                    return(hash);
                }
Ejemplo n.º 5
0
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            var tbx = sender as TextBox;

            byte value = 0;

            if (!string.IsNullOrEmpty(tbx.Text) && !Byte.TryParse(tbx.Text, out value))
            {
                tbx.Text = "255";

                if (sender == Field1)
                {
                    Field2.Focus();
                }
                else if (sender == Field2)
                {
                    Field3.Focus();
                }
                else if (sender == Field3)
                {
                    Field4.Focus();
                }
            }
            else if (tbx.Text.Length == 3)
            {
                if (sender == Field1)
                {
                    Field2.Focus();
                }
                else if (sender == Field2)
                {
                    Field3.Focus();
                }
                else if (sender == Field3)
                {
                    Field4.Focus();
                }
            }

            SetValue(ValueProperty, string.Format("{0}.{1}.{2}.{3}", Field1.Text, Field2.Text, Field3.Text, Field4.Text));
        }
Ejemplo n.º 6
0
        public void SetFromClone(GameState clone)
        {
            VictoryPoints         = clone.VictoryPoints;
            Money                 = clone.Money;
            NumberOfRounds        = clone.NumberOfRounds;
            ResidualMoney         = clone.ResidualMoney;
            RemainingBonusActions = clone.RemainingBonusActions;
            Round                 = clone.Round;

            Hand.SetFromClone(clone.Hand, Entities);

            VineDeck.SetFromClone(clone.VineDeck, Entities);
            OrderDeck.SetFromClone(clone.OrderDeck, Entities);
            AutomaDeck.SetFromClone(clone.AutomaDeck, Entities);
            SummerVisitorDeck.SetFromClone(clone.SummerVisitorDeck, Entities);
            WinterVisitorDeck.SetFromClone(clone.WinterVisitorDeck, Entities);

            Yoke.SetFromClone(clone.Yoke, Entities);
            Trellis.SetFromClone(clone.Trellis, Entities);
            Cottage.SetFromClone(clone.Cottage, Entities);
            Windmill.SetFromClone(clone.Windmill, Entities);
            Irigation.SetFromClone(clone.Irigation, Entities);
            LargeCellar.SetFromClone(clone.LargeCellar, Entities);
            TastingRoom.SetFromClone(clone.TastingRoom, Entities);
            MediumCellar.SetFromClone(clone.MediumCellar, Entities);

            Field1.SetFromClone(clone.Field1, Entities);
            Field2.SetFromClone(clone.Field2, Entities);
            Field3.SetFromClone(clone.Field3, Entities);

            Grande.SetFromClone(clone.Grande, Entities);
            NeutralWorker.SetFromClone(clone.NeutralWorker, Entities);

            for (var i = 0; i < 5; i++)
            {
                _workers[i].SetFromClone(clone.Workers.ElementAt(i), Entities);
            }

            for (int i = 0; i < 9; i++)
            {
                _redGrapes[i].SetFromClone(clone._redGrapes[i], Entities);
            }

            for (int i = 0; i < 9; i++)
            {
                _whiteGrapes[i].SetFromClone(clone._whiteGrapes[i], Entities);
            }

            for (int i = 0; i < 9; i++)
            {
                _redWines[i].SetFromClone(clone._redWines[i], Entities);
            }

            for (int i = 0; i < 9; i++)
            {
                _whiteWines[i].SetFromClone(clone._whiteWines[i], Entities);
            }
            for (int i = 0; i < 6; i++)
            {
                _blushWines[i].SetFromClone(clone._blushWines[i], Entities);
            }
            for (int i = 0; i < 3; i++)
            {
                _sparklingWines[i].SetFromClone(clone._sparklingWines[i], Entities);
            }
        }
Ejemplo n.º 7
0
        public GameState Clone()
        {
            var gameState = new GameState();

            gameState.VictoryPoints         = VictoryPoints;
            gameState.Money                 = Money;
            gameState.NumberOfRounds        = NumberOfRounds;
            gameState.ResidualMoney         = ResidualMoney;
            gameState.RemainingBonusActions = RemainingBonusActions;
            gameState.Round                 = Round;

            gameState.Hand = Hand.Clone() as Hand;

            gameState.VineDeck          = VineDeck.Clone();
            gameState.OrderDeck         = OrderDeck.Clone();
            gameState.AutomaDeck        = AutomaDeck.Clone();
            gameState.SummerVisitorDeck = SummerVisitorDeck.Clone();
            gameState.WinterVisitorDeck = WinterVisitorDeck.Clone();

            gameState.Yoke         = Yoke.Clone() as Yoke;
            gameState.Trellis      = Trellis.Clone() as Trellis;
            gameState.Cottage      = Cottage.Clone() as Cottage;
            gameState.Windmill     = Windmill.Clone() as Windmill;
            gameState.Irigation    = Irigation.Clone() as Irigation;
            gameState.LargeCellar  = LargeCellar.Clone() as LargeCellar;
            gameState.TastingRoom  = TastingRoom.Clone() as TastingRoom;
            gameState.MediumCellar = MediumCellar.Clone() as MediumCellar;

            gameState.Field1 = Field1.Clone() as Field;
            gameState.Field2 = Field2.Clone() as Field;
            gameState.Field3 = Field3.Clone() as Field;

            gameState.Grande        = Grande.Clone() as Grande;
            gameState.NeutralWorker = NeutralWorker.Clone() as Worker;

            gameState._workers = new List <Worker>();
            for (var i = 0; i < 5; i++)
            {
                gameState._workers.Add(_workers[i].Clone() as Worker);
            }

            gameState._redGrapes = new List <Grape>();
            foreach (var redGrape in _redGrapes)
            {
                gameState._redGrapes.Add(redGrape.Clone() as Grape);
            }

            gameState._whiteGrapes = new List <Grape>();
            foreach (var whiteGrape in _whiteGrapes)
            {
                gameState._whiteGrapes.Add(whiteGrape.Clone() as Grape);
            }

            gameState._redWines = new List <Wine>();
            foreach (var redWine in _redWines)
            {
                gameState._redWines.Add(redWine.Clone() as Wine);
            }

            gameState._whiteWines = new List <Wine>();
            foreach (var whiteWine in _whiteWines)
            {
                gameState._whiteWines.Add(whiteWine.Clone() as Wine);
            }

            gameState._blushWines = new List <Wine>();
            foreach (var blushWine in _blushWines)
            {
                gameState._blushWines.Add(blushWine.Clone() as Wine);
            }

            gameState._sparklingWines = new List <Wine>();
            foreach (var sparklingWine in _sparklingWines)
            {
                gameState._sparklingWines.Add(sparklingWine.Clone() as Wine);
            }

            return(gameState);
        }
Ejemplo n.º 8
0
        void ReleaseDesignerOutlets()
        {
            if (Field0 != null)
            {
                Field0.Dispose();
                Field0 = null;
            }

            if (Field1 != null)
            {
                Field1.Dispose();
                Field1 = null;
            }

            if (Field2 != null)
            {
                Field2.Dispose();
                Field2 = null;
            }

            if (Field3 != null)
            {
                Field3.Dispose();
                Field3 = null;
            }

            if (Field4 != null)
            {
                Field4.Dispose();
                Field4 = null;
            }

            if (Label0 != null)
            {
                Label0.Dispose();
                Label0 = null;
            }

            if (Label1 != null)
            {
                Label1.Dispose();
                Label1 = null;
            }

            if (Label2 != null)
            {
                Label2.Dispose();
                Label2 = null;
            }

            if (Label3 != null)
            {
                Label3.Dispose();
                Label3 = null;
            }

            if (Label4 != null)
            {
                Label4.Dispose();
                Label4 = null;
            }
        }
Ejemplo n.º 9
0
        public override string ToString()
        {
            string content = "当前状态 : " + FaultTitle + "\r\n太阳能电压 : " + Field1.ToString("0.00") + " V\r\n超容电压 : " + Field2.ToString("0.00") + " V\r\n超容电流 : " + Field3.ToString("0.00") + " A\r\n功率 : " + Field4.ToString("0.00") + " W\r\n温度 : " + Field5.ToString("0.00") + " ℃";

            if (Field6 > 100)
            {
                content += "\r\n更新时间 : " + CreateTime;
            }
            else
            {
                content += "\r\n超容余量 : " + Field6.ToString("0.00") + " %\r\n更新时间 : " + CreateTime;
            }
            return(content);
        }
Ejemplo n.º 10
0
        public string ToOldString()
        {
            string content = "当前状态 : " + FaultTitle + "\r\n太阳能电压 : " + Field1.ToString("0.00") + " V\r\n超容电压 : " + Field2.ToString("0.00") + " V\r\n超容电流 : " + Field3.ToString("0.00") + " A\r\n功率 : " + Field4.ToString("0.00") + " W\r\n温度 : " + Field5.ToString("0.00") + " ℃";

            content += "\r\n更新时间 : " + CreateTime;

            return(content);
        }