Example #1
0
 // Simple method with Assert (send text, verify data and click)
 public void SignInWithAssert(String userName, String password, String database)
 {
     Field1.SendKeys(userName);
     Field2.SendKeys(password);
     Assert.AreEqual(DropDown.Text, database);
     Button.Click();
 }
Example #2
0
 // Simple method (send text and click)
 public void SignIn(String userName, String password, String database)
 {
     Field1.SendKeys(userName);
     Field2.SendKeys(password);
     DropDown.SendKeys(database);
     Button.Click();
 }
Example #3
0
 //Update Photo in DB
 private void insertPicture()
 {
     if (fileName != "")
     {
         //code from http://stackoverflow.com/questions/779211/programmatically-managing-microsoft-access-attachment-typed-field-with-net
         DBEngine  dbe = new DBEngine();
         Database  db  = dbe.OpenDatabase("PineSpringsPottery.accdb", false, false, "");
         Recordset rs  = db.OpenRecordset("SELECT * FROM PATTERN WHERE PATTERN.PatternNo = " + currentPattern.patternNo, RecordsetTypeEnum.dbOpenDynaset, 0, LockTypeEnum.dbOptimistic);
         rs.MoveFirst();
         rs.Edit();
         Recordset2 rs2 = (Recordset2)rs.Fields["PatternPicture"].Value;
         //delete previous pics
         if (rs2.RecordCount != 0)
         {
             rs2.Delete();
         }
         //if not just deleting previous, add new
         if (fileName != "delete")
         {
             rs2.AddNew();
             Field2 f2 = (Field2)rs2.Fields["FileData"];
             f2.LoadFromFile(fileName);
             rs2._30_Update();
         }
         rs2.Close();
         rs._30_Update();
         rs.Close();
     }
 }
        private void buttonInit_Click(object sender, EventArgs e)
        {
            // make bitmap
            Size size = pictureBox1.ClientSize;

            // init field
            //try
            //{
            this.field = new Field2(GlobalConfig.NrThings);
            //}
            //catch ( Exception ex )
            //{
            //	MessageBox.Show( this, ex.Message );
            //	return;
            //}

            // draw field
            RepaintField();
            //UpdateSlider();

            // debug
            DebugPrintLine("size=" + pictureBox1.ClientSize);
            DebugPrintLine("Nr of things: " + this.field.things.Count);

            // set status
            SetStatus("initialized");
            SetStatus2("initialized");
        }
Example #5
0
 public void AddListViewItems()
 {
     try
     {
         Recordset recordset = daoDB.OpenRecordset(selDataTable.TableName);
         if (recordset.RecordCount > 0)
         {
             foreach (Field field in recordset.Fields)
             {
                 Field2 field2 = field as Field2;
                 if (field2.Expression != string.Empty && !calculatedFields.Contains(field.Name))
                 {
                     if (paramIdMap.ContainsKey(field.Name))
                     {
                         string       paramName = paramIdMap[field.Name];
                         ListViewItem item      = new ListViewItem(paramName);
                         item.Name = field.Name;
                         listViewFields.Items.Add(item);
                     }
                     else
                     {
                         ListViewItem item = new ListViewItem(field.Name);
                         item.Name = field.Name;
                         listViewFields.Items.Add(item);
                     }
                 }
             }
         }
         recordset.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to collect calculated fields.\n" + ex.Message, "DeleteCalculated Error:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
 public string ToLine()
 {
     return("H1"
            + $"{Field1.ToFixedString(10)}"
            + $"{Field2.ToFixedString(10)}"
            + $"{Field3.ToFixedString(10)}"
            + "");
 }
Example #7
0
 //Simple method with ExpectedConditions (send text, wait for element and click)
 public void SignInWithEC(String userName, String password, String database)
 {
     Field1.SendKeys(userName);
     this._wait.Until(ExpectedConditions.ElementToBeClickable(Field2));
     Field2.SendKeys(password);
     DropDown.SendKeys(database);
     Button.Click();
 }
 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);
        }
Example #10
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;
            }
        }
        private List <string> ExportFilesFromRecordset(Recordset2 rstAttach)
        {
            var result = new List <string>();

            while (!rstAttach.EOF)
            {
                var    fileName = $"{tempFolder}\\{rstAttach.Fields["FileName"].Value}";
                Field2 fld      = (Field2)rstAttach.Fields["FileData"];
                fld.SaveToFile(fileName);
                result.Add(fileName);
                rstAttach.MoveNext();
            }

            return(result);
        }
        /// <summary>
        /// Update species fact fields with latest red list values.
        /// </summary>
        protected override void SetReadListValues()
        {
            if (AllowAutomaticUpdate)
            {
                Factor factor;

                if (RedListCalculator.IsEvaluationStatusSet)
                {
                    factor = FactorManager.GetFactor((Int32)FactorId.RedListCategoryAutomatic);
                    foreach (FactorFieldEnumValue enumValue in factor.FactorDataType.Fields[0].FactorFieldEnum.Values)
                    {
                        if (enumValue.KeyInt == ((Int32)Category))
                        {
                            Field1.SetValueAutomatic(enumValue);
                            break;
                        }
                    }
                    Field2.SetValueAutomatic(RedListCalculator.IsGraded);
                    if (RedListCalculator.IsGraded &&
                        ((Category == RedListCategory.CR) ||
                         (Category == RedListCategory.EN) ||
                         (Category == RedListCategory.VU) ||
                         (Category == RedListCategory.NT) ||
                         (Category == RedListCategory.LC)) &&
                        !(((RedListCalculator.CategoryProbableNoGrading == RedListCategory.NT) ||
                           (RedListCalculator.CategoryProbableNoGrading == RedListCategory.LC)) &&
                          (RedListCalculator.CategoryProbableGraded == RedListCategory.LC) &&
                          (Category == RedListCategory.NT) &&
                          RedListCalculator.IsConservationDependent))
                    {
                        Field4.SetValueAutomatic(Category.ToString() + "°");
                    }
                    else
                    {
                        Field4.SetValueAutomatic(Category.ToString());
                    }
                }
                else
                {
                    // Reset values to nothing.
                    Field1.SetValueAutomatic(null);
                    Field2.SetValueAutomatic(null);
                    Field4.SetValueAutomatic(null);
                }
            }
        }
Example #13
0
 private bool ValidateExpression(TableDef tableDef, string expression)
 {
     try
     {
         Field2 field2 = tableDef.CreateField("temp", DataTypeEnum.dbText) as Field2;
         field2.Expression      = expression;
         field2.AllowZeroLength = true;
         tableDef.Fields.Append(field2);
     }
     catch (Exception ex)
     {
         MessageBox.Show("The expression you entered contains invalid syntax.\n" + ex.Message, "Expression Builder Error:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return(false);
     }
     tableDef.Fields.Delete("temp");
     return(true);
 }
Example #14
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));
        }
    private void Form1_Load(object sender, EventArgs e)
    {
        DBEngine  dbe    = new DBEngine();
        Database  db     = dbe.OpenDatabase(@"C:\Users\Public\AttachmentsDB.accdb");
        Recordset rsMain = db.OpenRecordset(
            "select solution from tab2 where id = 1",
            RecordsetTypeEnum.dbOpenSnapshot);
        Recordset2 rsAttach  = rsMain.Fields["solution"].Value;
        Field2     fldAttach = (Field2)rsAttach.Fields["FileData"];

        tempFileName = System.IO.Path.GetTempPath() + "\\" + rsAttach.Fields["FileName"].Value;
        try
        {
            System.IO.File.Delete(tempFileName);
        }
        catch { }
        fldAttach.SaveToFile(tempFileName);
        rsAttach.Close();
        rsMain.Close();
        db.Close();
        img = Image.FromFile(tempFileName);
        pictureBox1.Image = img;
    }
Example #16
0
 public override string ToString()
 {
     return(Field1.ToLower() + Field2.ToString() + Field3.ToString());
 }
Example #17
0
            public override int GetHashCode()
            {
                int result = string.IsNullOrEmpty(Field1) ? 0 : Field1.GetHashCode() + Field2.GetHashCode();

                return(result);
            }
        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);
        }
Example #19
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);
        }
        static void Main(string[] args)
        {
            //'C:\Users\niraj\Documents\Civictrack\XML_Reader\XML_Reader\bin\Debug\EdmontonManning.xml
            //XmlDataDocument xmldoc = new XmlDataDocument();
            //XmlNodeList xmlnode;
            //int i = 0;
            //string str = null;
            //FileStream fs = new FileStream("EdmontonManning.xml", FileMode.Open, FileAccess.Read);
            //xmldoc.Load(fs);
            //xmlnode = xmldoc.GetElement;sByTagName("Table1");
            //for (i = 0; i <= xmlnode.Count - 1; i++)
            //{
            //    xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
            //    str = xmlnode[i].ChildNodes.Item(0).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(1).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(2).InnerText.Trim();

            //    Console.WriteLine(str);
            //    Console.ReadLine();

            //}

            var       dbe     = new DBEngine();
            Database  db      = dbe.OpenDatabase(@"ACCESDATA_BASE_PDF");
            Recordset rstMain = db.OpenRecordset(
                "SELECT Document FROM Table1 WHERE ID=1017",
                RecordsetTypeEnum.dbOpenSnapshot);
            Recordset2 rstAttach = rstMain.Fields["Document"].Value;
            Field2     fld       = (Field2)rstAttach.Fields["FileData"];

            fld.SaveToFile(@"filename_full_path.pdf");
            //while ((!"Document1.pdf".Equals(rstAttach.Fields["FileName"].Value)) && (!rstAttach.EOF))
            //{
            //    rstAttach.MoveNext();
            //}
            //if (rstAttach.EOF)
            //{
            //    Console.WriteLine("Not found.");
            //}
            //else
            //{
            //    Field2 fld = (Field2)rstAttach.Fields["FileData"];
            //    fld.SaveToFile(@"C:\Users\Gord\Desktop\FromSaveToFile.pdf");
            //}
            db.Close();


            //XmlDocument docu = new XmlDocument();
            //docu.Load("Test.xml");
            //XmlNodeList nodeList = docu.GetElementsByTagName("FileData");
            //string filedata = string.Empty;
            //foreach (XmlNode node in nodeList)
            //{
            //    filedata = node.InnerText;


            //    byte[] binaryData = Encoding.UTF8.GetBytes(filedata);
            //    //File.WriteAllBytes(@"C:\textxml.pdf", binaryData);


            //    BinaryWriter writer = new BinaryWriter(File.Open(@"C:\Users\niraj\Documents\Civictrack\textxml1.pdf", FileMode.Create));
            //    writer.Write(filedata);
            //    //string s = Encoding.UTF8.GetString(binaryData);

            //    Console.WriteLine(filedata);
            //    break;
            //}
            Console.ReadLine();
        }
Example #21
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);
        }
Example #22
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;
            }
        }
        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);
            }
        }
        public static Bitmap Draw(this Field2 field, Size display)
        {
            if (display.Width <= 0 || display.Height <= 0)
            {
                return(null);
            }

            Bitmap bitmap = new Bitmap(display.Width, display.Height);

            Graphics g = Graphics.FromImage(bitmap);

            CoordinatesConverter conv = new CoordinatesConverter(display, field.Viewport);

            // draw border
            int width  = display.Width;
            int height = display.Height;

            g.DrawLine(Pens.Aqua, 0, 0, width - 1, 0);
            g.DrawLine(Pens.Aqua, width - 1, 0, width - 1, height - 1);
            g.DrawLine(Pens.Aqua, width - 1, height - 1, 0, height - 1);
            g.DrawLine(Pens.Aqua, 0, height - 1, 0, 0);


            // paint all things

            foreach (Thing2 t in field.things)
            {
                // Draw a disc with center at its location, and radius its size, and color its color
                PointF p1 = new PointF();
                PointF p2 = new PointF();
                float  w, h;

                p1.X = (float)(t.location.x - t.size);
                p1.Y = (float)(t.location.y - t.size);

                w = (float)(t.size * 2);
                h = (float)(t.size * 2);

                PointF p1s = conv.ConvertPoint(p1);
                float  ws  = conv.ConvertDistanceHorizontal(w);
                float  hs  = conv.ConvertDistanceVertical(h);

                Brush b = new SolidBrush(t.color);

                g.FillEllipse(b, p1s.X, p1s.Y, ws, hs);

                // draw gravity vector
                if (t.forceNet != null)
                {
                    p1 = new PointF();
                    p2 = new PointF();

                    p1 = conv.ConvertPoint((float)t.location.x, (float)t.location.y);
                    p2 = conv.ConvertPoint(t.location.x + t.forceNet.i, t.location.y + t.forceNet.j);

                    g.DrawLine(Pens.White, p1, p2);
                }

                // draw gravity component vectors
                if (t.forceComponents != null)
                {
                    foreach (Vector2d v in t.forceComponents)
                    {
                        p1 = new PointF();
                        p2 = new PointF();

                        p1 = conv.ConvertPoint((float)t.location.x, (float)t.location.y);
                        p2 = conv.ConvertPoint(t.location.x + v.i, t.location.y + v.j);

                        g.DrawLine(Pens.Aquamarine, p1, p2);
                    }
                }

                //// draw velocity vector
                //if ( a.velocity != null )
                //{
                //	x = (float)(a.location.x);
                //	y = (float)(a.location.y);
                //	g.DrawLine( Pens.Yellow, x, y, x + (float)a.velocity.i, y + (float)a.velocity.j );
                //}
            }


            // paint all rezinochki

            foreach (Rezinochka r in field.rezinochki)
            {
                PointF p1 = new PointF();
                PointF p2 = new PointF();

                p1.X = (float)(r.a.location.x);
                p1.X = (float)(r.a.location.y);

                p2.X = (float)(r.b.location.x);
                p2.X = (float)(r.b.location.y);

                PointF p1s = conv.ConvertPoint(p1);
                PointF p2s = conv.ConvertPoint(p2);

                SolidBrush brush = new SolidBrush(r.color);

                PointF[] points = new PointF[]
                {
                    new PointF(p1s.X + 2, p1s.Y + 2),
                    new PointF(p1s.X - 2, p1s.Y - 2),
                    new PointF(p2s.X + 2, p2s.Y + 2),
                    new PointF(p2s.X - 2, p2s.Y - 2)
                };

                g.FillPolygon(brush, points);
            }


            return(bitmap);
        }
Example #25
0
        private void CreateField(bool exist, TableDef tableDef, string strExpression)
        {
            try
            {
                if (exist)
                {
                    string paramId = fieldDictionary[selField].ParamId;
                    tableDef.Fields.Delete(paramId);

                    if (calType == CalculationType.String)
                    {
                        Field2 field2 = tableDef.CreateField(paramId, DataTypeEnum.dbText) as Field2;
                        field2.Expression      = strExpression;
                        field2.AllowZeroLength = true;
                        tableDef.Fields.Append(field2);
                    }
                    else if (calType == CalculationType.Math)
                    {
                        Field2 field2 = tableDef.CreateField(paramId, DataTypeEnum.dbDouble) as Field2;
                        field2.Expression = strExpression;
                        tableDef.Fields.Append(field2);

                        if (setDecimal)
                        {
                            Property property = field2.CreateProperty("DecimalPlaces", DataTypeEnum.dbByte, decimalPlace);
                            field2.Properties.Append(property);

                            property = field2.CreateProperty("Format", DataTypeEnum.dbText, "Fixed");
                            field2.Properties.Append(property);

                            field2.Properties.Refresh();
                        }
                    }
                }
                else// not exist in the database
                {
                    if (calType == CalculationType.String)
                    {
                        Field2 field2 = tableDef.CreateField(selField, DataTypeEnum.dbText) as Field2;
                        field2.Expression      = strExpression;
                        field2.AllowZeroLength = true;
                        tableDef.Fields.Append(field2);
                    }
                    else if (calType == CalculationType.Math)
                    {
                        Field2 field2 = tableDef.CreateField(selField, DataTypeEnum.dbDouble) as Field2;
                        if (roundUp)
                        {
                            string oldExpression = strExpression;
                            strExpression = string.Format("IIf({0}>Int({0}),Int({0})+1,Int({0}))", oldExpression);
                        }
                        else if (roundDown)
                        {
                            strExpression = "Int(" + strExpression + ")";
                        }
                        field2.Expression = strExpression;
                        tableDef.Fields.Append(field2);

                        if (setDecimal)
                        {
                            Property property = field2.CreateProperty("DecimalPlaces", DataTypeEnum.dbByte, decimalPlace);
                            field2.Properties.Append(property);

                            property = field2.CreateProperty("Format", DataTypeEnum.dbText, "Fixed");
                            field2.Properties.Append(property);

                            field2.Properties.Refresh();
                        }
                    }

                    DataColumn column = new DataColumn();
                    column.DataType   = System.Type.GetType(strDataType);
                    column.ColumnName = selField;
                    selDataTable.Columns.Add(column);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to create a calculated field.\n" + ex.Message, "Expression Builder Error:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }