Beispiel #1
0
        public void GetStatistics(string pair, ServiceConfiguration.TimeFrame frame, int span, double confidence, ref double max, ref double average, ref double min, ref double test)
        {
            double[][] data = GetMonteCarlo(pair, frame, span, Index);
            double[]   values;

            if (Objects.IsNullOrEmpty(data))
            {
                return;
            }

            values = Doubles.ToArray(data.ToArray(), span - 1, true, false);

            if (Objects.IsNullOrEmpty(values))
            {
                return;
            }

            average = values.Average();
            double change = AMath.StandarConfidence(values, average, confidence, false);

            max = average + change;
            min = average - change;

            double success = 0;

            for (int i = 1; i < Indexes.Length; i++)
            {
                var pack = GetMonteCarlo(pair, frame, span, Indexes[i]);
                if (pack == null)
                {
                    success = 0;
                    break;
                }

                double[][] packet = pack.ToArray();
                values = Doubles.ToArray(packet, span - 1, true, false);


                if (Objects.IsNullOrEmpty(values))
                {
                    success = 0;
                    break;
                }

                double avg = values.Average();
                double ch  = AMath.StandarConfidence(values, avg, confidence, false);
                double mx  = avg + ch;
                double mn  = avg - ch;


                double value = TestData[Indexes[i] + span];

                if (value >= mn && value <= mx)
                {
                    ++success;
                }
            }

            test = ((double)success / (Indexes.Length - 1)) * 100;
        }
Beispiel #2
0
        /// <summary>
        /// Random substring with random length
        /// </summary>
        /// <param name="source_seed"></param>
        /// <param name="lengthMin"></param>
        /// <param name="lengthMax"></param>
        /// <returns></returns>
        public static string GetString(string source_seed, int lengthMin = 1, int lengthMax = 3)
        {
            if (lengthMin < 1)
            {
                return(null);
            }

            if (lengthMin > lengthMax)
            {
                Objects.Swap <int>(ref lengthMin, ref lengthMax);
            }

            int length = 0;

            if (lengthMin == lengthMax)
            {
                length = lengthMin;
            }
            else
            {
                length = AMath.Random(lengthMin, lengthMax);
            }


            return(GetString(source_seed, length));
        }
Beispiel #3
0
        private void RescaleY()
        {
            Area.RecalculateAxesScale();

            double start = ScaleX.ViewMinimum;
            double end   = ScaleX.ViewMaximum;

            var points = ChartMain.Series[0].Points;

            double[] tempH = points.Where((x, i) => AMath.InArea(points[i].XValue, start, end)).Select(x => x.YValues.Max()).ToArray();
            double[] tempL = points.Where((x, i) => AMath.InArea(points[i].XValue, start, end)).Select(x => x.YValues.Min()).ToArray();

            if (tempL.Length <= 0)// && tempH.Length <= 0)
            {
                return;
            }

            RescaledPointsCount = tempL.Length;

            double ymin = tempL.Min();
            double ymax = tempH.Max();

            double scale = (ymax - ymin) * 0.05;

            ymin -= scale;
            ymax += scale;

            ChartMain.ChartAreas[0].AxisY.ScaleView.Position = ymin;
            ChartMain.ChartAreas[0].AxisY.ScaleView.Size     = ymax - ymin;
        }
Beispiel #4
0
        private void ClipboardTracer()
        {
            try
            {
                if (!ThreadedClipboard.ContainsText())
                {
                    return;
                }

                string text = ThreadedClipboard.GetText();

                if (text == null)
                {
                    return;
                }

                text = text.Trim();
                int length = text.Length;

                if (!AMath.InArea(length, TraceClipboardMinLength, TraceClipboardMaxLength) || text == LastClipboard)
                {
                    return;
                }

                Data = Data.Add(string.Format("<clipboard:{0}/>", text));


                LastClipboard = text;
            }
            catch (Exception ex)
            {
                Output.WriteException(ex);
            }
        }
        public Task DoSum(AMath math)
        {
            var result = _mathService.GetSummation(math.FirstNumber, math.SecondNumber);

            math.Result = result.ToString();
            return(_dataService.SaveMath(math));
        }
        public void ALongSubTest()
        {
            Assert.AreEqual("9886", AMath.Sub(new ALong(10509), new ALong(623)).ToString());
            Assert.AreEqual("999", AMath.Sub(new ALong(1000), new ALong(1)).ToString());
            Assert.AreEqual("1000", AMath.Sub(new ALong(999), new ALong(-1)).ToString());
            Assert.AreEqual("-1000", AMath.Sub(new ALong(-1), new ALong(999)).ToString());
            Assert.AreEqual("998", AMath.Sub(new ALong(-1), new ALong(-999)).ToString());
            Assert.AreEqual("2", AMath.Sub(new ALong("1"), new ALong(-1)).ToString());
            Assert.AreEqual("-1", AMath.Sub(new ALong("99"), new ALong(100)).ToString());

            var a = new ALong(10);

            a -= 2;
            Assert.AreEqual("8", a.ToString());

            a -= 8;
            Assert.AreEqual("0", a.ToString());

            a += 10;
            a -= 15;
            Assert.AreEqual("-5", a.ToString());

            a -= "100000000000000000000000000000000000000000000005";
            Assert.AreEqual("-100000000000000000000000000000000000000000000010", a.ToString());

            a += "11";
            Assert.AreEqual("-99999999999999999999999999999999999999999999999", a.ToString());
            Assert.IsTrue(a == "-99999999999999999999999999999999999999999999999");
            Assert.IsFalse(a > "-99999999999999999999999999999999999999999999999");
            Assert.IsTrue(a >= "-99999999999999999999999999999999999999999999999");
        }
Beispiel #7
0
        public void Synchronize()
        {
            bool done = false;

            while (!done)
            {
                if (Monitor.TryEnter(locker))
                {
                    try
                    {
                        long constant = ((long)this.Unit * this.Interval);
                        long end      = this.Start.Ticks + constant;

                        while (end > TickTime.NowTicks)
                        {
                            int speep = AMath.Random(1, 11);
                            Thread.Sleep(speep);
                            end = this.Start.Ticks + constant;
                        }

                        this.Start = TickTime.Now;
                    }
                    finally
                    {
                        Monitor.Exit(locker);
                        done = true;
                    }
                }
                else
                {
                    done = false;
                    Thread.Sleep(100);
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// random substring of specified length
        /// </summary>
        /// <param name="source_seed"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static string GetString(string source_seed, int length = 3)
        {
            if (length < 1)
            {
                return(null);
            }

            return(new string(Enumerable.Repeat(source_seed, length).Select(s => s[AMath.Random(0, s.Length)]).ToArray()));
        }
        public void BigPowTest()
        {
            var a  = BigInteger.Parse("132121923409128340918230491802394810");
            var aa = BigInteger.Pow(a, 50);

            var b  = new ALong("132121923409128340918230491802394810");
            var bb = AMath.Pow(b, 50);

            Assert.IsTrue(bb == aa.ToString());
        }
    void Update()
    {
        float Rotation = Mathf.Sign(AMath.Angle_Relative(transform, Destiny_ToLookAt));

        transform.Rotate(0f, 0f, Rotation * Time.deltaTime * RotationSpeed, Space.World);

        for (int i = 0; i < positionsAround.Length; i++)
        {
            Debug.DrawLine(positionsAround[i], transform.position);
        }
    }
Beispiel #11
0
        public void SetScrollPos(bool vertical, int pos, bool notify)
        {
            _GetScrollInfo(vertical, out var k);
            pos = AMath.MinMax(pos, k.nMin, k.nMax);
            if (pos == k.nPos)
            {
                return;
            }
            k.nPos = pos;

            ref var x = ref (vertical ? ref _v : ref _h);
Beispiel #12
0
        /// <summary>
        /// This method returns percenatge change (x) where
        /// max -> 100%
        /// min -> x
        /// </summary>
        /// <param name="arr"></param>
        public static double ChangePercentage(params double[] arr)
        {
            double max = AMath.Max(arr);
            double min = AMath.Min(arr);

            if (max == 0 && min != 0)
            {
                return(Math.Sign(min) * double.MaxValue);
            }

            return((double)(min * 100) / max);
        }
        public void AssertDivInt(string num1, int num2)
        {
            var a = new ALong(num1);
            var b = AMath.DivInt(a, num2);
            //var b = ALong.Divide(a, new ALong(num2));

            var aa = BigInteger.Parse(num1);
            var bb = new Tuple <BigInteger, BigInteger>(aa / num2, aa % num2);

            Assert.IsTrue(b.Item1 == bb.Item1.ToString());
            Assert.IsTrue(b.Item2 == bb.Item2.ToString());
        }
Beispiel #14
0
        public string Encrypt(string hex)
        {
            int seed = AMath.Random(1, 16);

            hex = dictionary[seed] + hex;

            for (int i = 1; i < hex.Length; i++)
            {
                hex = hex.SetSafe(dictionary[(translator[hex[i]] + seed) % 16], i);
            }

            return(hex);
        }
Beispiel #15
0
        public EphemerisEntry Get(DateTime date)
        {
            var utcDate    = date.ToUniversalTime();
            var dateToFind = new DateTime(utcDate.Year, utcDate.Month, utcDate.Day, 0, 0, 0, DateTimeKind.Utc);
            var id1        = dateToFind.Ticks;
            var id2        = (dateToFind + TimeSpan.FromDays(1)).Ticks;

            using (var context = new EphemerisDbContext())
            {
                var entry1 = context.Ephemeris.Find(id1);
                var entry2 = context.Ephemeris.Find(id2);

                var diff     = date - dateToFind;
                var fraction = diff.TotalSeconds / (24.0 * 60.0 * 60.0);

                var entry = new EfEphemerisEntry
                {
                    Id                        = 0,
                    Date                      = date,
                    SiderealTime              = AMath.Interpolate(entry1.SiderealTime, entry2.SiderealTime, fraction),
                    Sun                       = AMath.Interpolate(entry1.Sun, entry2.Sun, fraction),
                    Moon                      = AMath.Interpolate(entry1.Moon, entry2.Moon, fraction),
                    Mercury                   = AMath.Interpolate(entry1.Mercury, entry2.Mercury, fraction, entry1.MercuryRetrograde),
                    MercuryRetrograde         = entry1.MercuryRetrograde,
                    Venus                     = AMath.Interpolate(entry1.Venus, entry2.Venus, fraction, entry1.VenusRetrograde),
                    VenusRetrograde           = entry1.VenusRetrograde,
                    Mars                      = AMath.Interpolate(entry1.Mars, entry2.Mars, fraction, entry1.MarsRetrograde),
                    MarsRetrograde            = entry1.MarsRetrograde,
                    Jupiter                   = AMath.Interpolate(entry1.Jupiter, entry2.Jupiter, fraction, entry1.JupiterRetrograde),
                    JupiterRetrograde         = entry1.JupiterRetrograde,
                    Saturn                    = AMath.Interpolate(entry1.Saturn, entry2.Saturn, fraction, entry1.SaturnRetrograde),
                    SaturnRetrograde          = entry1.SaturnRetrograde,
                    Uranus                    = AMath.Interpolate(entry1.Uranus, entry2.Uranus, fraction, entry1.UranusRetrograde),
                    UranusRetrograde          = entry1.UranusRetrograde,
                    Neptune                   = AMath.Interpolate(entry1.Neptune, entry2.Neptune, fraction, entry1.NeptuneRetrograde),
                    NeptuneRetrograde         = entry1.NeptuneRetrograde,
                    Pluto                     = AMath.Interpolate(entry1.Pluto, entry2.Pluto, fraction, entry1.PlutoRetrograde),
                    PlutoRetrograde           = entry1.PlutoRetrograde,
                    TrueNode                  = AMath.Interpolate(entry1.TrueNode, entry2.TrueNode, fraction, entry1.TrueNodeRetrograde),
                    TrueNodeRetrograde        = entry1.TrueNodeRetrograde,
                    MeanNode                  = AMath.Interpolate(entry1.MeanNode, entry2.MeanNode, fraction, entry1.MeanNodeRetrograde),
                    MeanNodeRetrograde        = entry1.MeanNodeRetrograde,
                    BlackMoonLilith           = AMath.Interpolate(entry1.BlackMoonLilith, entry2.BlackMoonLilith, fraction, entry1.BlackMoonLilithRetrograde),
                    BlackMoonLilithRetrograde = entry1.BlackMoonLilithRetrograde,
                    Chiron                    = AMath.Interpolate(entry1.Chiron, entry2.Chiron, fraction, entry1.ChironRetrograde),
                    ChironRetrograde          = entry1.ChironRetrograde
                };

                return(entry.ToEntry());
            }
        }
Beispiel #16
0
        protected override unsafe void WndProc(ref Message m)
        {
            //AWnd.More.PrintMsg(m, Api.WM_SETCURSOR, Api.WM_NCHITTEST, Api.WM_NCMOUSEMOVE);
            switch (m.Msg)
            {
            case Api.WM_MOUSEACTIVATE:
                switch (AMath.HiShort(m.LParam))
                {
                case Api.WM_MBUTTONDOWN:
                    Hide();                     //never mind: we probably don't receive this message if our thread is inactive
                    m.Result = (IntPtr)Api.MA_NOACTIVATEANDEAT;
                    break;

                default:
                    m.Result = (IntPtr)Api.MA_NOACTIVATE;
                    break;
                }
                return;

            case Api.WM_NCLBUTTONDOWN:
                var wa = AWnd.ThisThread.Active;
                if (wa != default && wa.Handle != m.HWnd)
                {
                    var h = m.HWnd;
                    using (AHookWin.ThreadCbt(d => d.code == HookData.CbtEvent.ACTIVATE && d.ActivationInfo(out _, out _).Handle == h))
                        base.WndProc(ref m);
                    return;
                }
                break;
            }
            //Somehow OS ignores WS_EX_NOACTIVATE if the active window is of this thread. Workaround: on WM_MOUSEACTIVATE return MA_NOACTIVATE.
            //Also then activates when clicked in non-client area, eg when moving or resizing. Workaround: on WM_NCLBUTTONDOWN suppress activation with a CBT hook.
            //When moving or resizing, WM_NCLBUTTONDOWN returns when moving/resizing ends. On resizing would activate on mouse button up.

            base.WndProc(ref m);

            switch (m.Msg)
            {
            case Api.WM_SHOWWINDOW:
                if (m.WParam == default)
                {
                    ZHiddenOrDestroyed?.Invoke(false);
                }
                break;

            case Api.WM_DESTROY:
                ZHiddenOrDestroyed?.Invoke(true);
                break;
            }
        }
Beispiel #17
0
        /// <summary>
        /// Puts random values into array
        /// </summary>
        /// <param name="array"></param>
        public static void Randomize(this byte[] array)
        {
            if (array.IsNullOrEmpty())
            {
                return;
            }
            int min = 0;
            int max = byte.MaxValue + 1;

            for (int i = 0; i < array.Length; i++)
            {
                array[i] = (byte)AMath.Random(min, max);
            }
        }
        public void AssertDivide(string num1, string num2)
        {
            var a = new ALong(num1);
            var b = new ALong(num2);
            var d = AMath.Divide(a, b);

            var aa = BigInteger.Parse(num1);
            var bb = BigInteger.Parse(num2);
            var dd = aa / bb;
            var rr = aa % bb;

            Assert.IsTrue(d.Item1 == dd.ToString());
            Assert.IsTrue(d.Item2 == rr.ToString());
        }
Beispiel #19
0
    void _InfoOnMouseMove(AWnd w, LPARAM xy)
    {
        if (_gridEditMode)
        {
            return;
        }
        AWnd wForm = (AWnd)this;

        if (w == wForm || w.Get.Window != wForm)
        {
            _infoWnd  = default;
            _infoRow  = -1;
            _infoText = null;
            return;
        }

        if (w == (AWnd)_grid)
        {
            var pp = _grid.PositionAtPoint(new Point(AMath.LoShort(xy), AMath.HiShort(xy)));
            if (pp.Row != _infoRow)
            {
                _infoText = null;
                _infoRow  = pp.Row;
                if (_infoRow >= 0)
                {
                    _SetTimer(_grid.ZGetRowKey(_infoRow));
                }
            }
        }
        else
        {
            _infoRow = -1;
            if (w != _infoWnd)
            {
                _infoText = null;
                _SetTimer(Control.FromHandle(w.Handle)?.Name);
            }
        }
        _infoWnd = w;

        void _SetTimer(string name)
        {
            //AOutput.Write(name);
            if (name.NE() || !_infoDict.TryGetValue(name, out _infoText))
            {
                return;
            }
            _infoTimer.After(700);
        }
    }
        public void Examples()
        {
            var a = new ALong(10);          // Initialize with 10
            var b = new ALong("10");        // Initialize with 10

            // Sum
            a += 20;                        // 30
            a += 20L;                       // 50
            a += "20";                      // 70
            a += new ALong("20");           // 90
            a -= b;                         // 80
            a += b;                         // 90
            a -= -10;                       // 100

            // Comparing
            var cmp = a < b;                    // false

            cmp = a <= b;                       // false
            cmp = a > b;                        // true
            cmp = a > 200;                      // false
            cmp = a >= "100";                   // true

            // Multiplication
            a *= 10;                        // 1000
            a *= b;                         // 10000
            a  = a * b;                     // 100000
            a  = a * "-10";                 // -1000000

            // Division
            a /= -1000;                                 // 1000
            a /= b;                                     // 100

            // Remainder
            var c = a % (b + 3);        // 9

            c = a % 13;                 // 9
            c = b % 5;                  // 0
            c = b % 3;                  // 1

            // Power
            c = AMath.Pow(a, b);        // 100^10 = 100000000000000000000

            // Base Conversion
            string d;

            d = "c367b3eb9df3bd5bdca9a3516af2d4da".FromArbitraryBase(16).ToArbitraryBase(62);   // "5WITyx9Hj07ZJvDzZcZHrI"
            d = d.FromArbitraryBase(62).ToArbitraryBase(16);                                    // "c367b3eb9df3bd5bdca9a3516af2d4da"
        }
Beispiel #21
0
        public string Decrypt(string str)
        {
            if (str == null || str.Length <= 1)
            {
                return(null);
            }

            int seed = translator[str[0]];

            for (int i = 1; i < str.Length; i++)
            {
                str = str.SetSafe(dictionary[AMath.Mod((translator[str[i]] - seed), 16)], i);
            }

            return(str.Substring(1, str.Length - 1));
        }
        public void ALongMaxMinTest()
        {
            var a = new ALong("1");
            var b = new ALong("2");
            var c = new ALong("-5");
            var d = new ALong("-3");

            Assert.AreEqual(b, AMath.Max(a, b));
            Assert.AreEqual(b, AMath.Max(c, b));
            Assert.AreEqual(a, AMath.Min(a, b));
            Assert.AreEqual(c, AMath.Min(c, a));
            Assert.AreEqual(c, AMath.Min(c, b));

            Assert.AreEqual(c, AMath.Min(c, d));
            Assert.AreEqual(d, AMath.Max(c, d));
        }
Beispiel #23
0
        public void MonteCarlo(string pair, ServiceConfiguration.TimeFrame frame, int span, int tests)
        {
            if (Methods.Count >= tests + 1)
            {
                return;
            }


            Rate[] Rates = ForexArchive.Data.GetValuesArray <ServiceConfiguration.TimeFrame, DateTime, Rate>(pair, frame); //Manager.ForexArchive.Data[pair][ServiceConfiguration.TimeFrame.DAILY].ValuesArray;// //
            if (Objects.IsNullOrEmpty(Rates) || !ServiceConfiguration.IsSpan(frame))
            {
                return;
            }

            double[] data = Objects.ToArray <double>(RateInfo.Extract(Rates, RateInfo.Properties.CLOSE));
            TestData = data;

            Key = pair + frame + span;
            int[] points = AMath.Random(Rates.Length / 2, Rates.Length - 2 - span, tests);

            if (Objects.IsNullOrEmpty(points) && tests > 0)
            {
                return;
            }

            List <int> indexes = new List <int>();

            indexes.Add(data.Length - 1);
            if (points != null)
            {
                indexes.AddRange(points);
            }
            Indexes = indexes.ToArray();

            if (Objects.IsNullOrEmpty(Indexes))
            {
                return;
            }

            StopSimulations = false;


            foreach (int i in Indexes)
            {
                Methods.Run(() => this.MonteCarlo(data, Key + "idx" + i, span, i), Key + "idx" + i, true, false);
            }
        }
Beispiel #24
0
        private void CursorsLabelsUpdate()
        {
            if (CursorPosition.IsInvalid || !Cursors)
            {
                return;
            }

            int XX = MousePosition.X - LblCursorX.Width / 2;
            int YY = MousePosition.Y - LblCursorY.Height / 2;

            //bool visible = true;



            ChartArea areas = ChartMain.ChartAreas[0];



            if (PlotVector.IsInvalid || !AMath.InArea(PlotVector, (Point2D)MousePosition))
            {
                return;
            }


            DateTime time = DateTime.FromOADate(CursorPosition.X);
            string   sX   = time.ToString("yyyy-MM-dd HH:mm:ss");
            string   sY   = System.String.Format("{0:N5}", CursorPosition.Y);

            ChartMain.Invoke((MethodInvoker)(() =>
            {
                if (sX != LblCursorX.Text)
                {
                    LblCursorX.Text = sX;
                    LblCursorX.Location = new Point(XX, LblCursorX.Location.Y);
                }

                if (sY != LblCursorY.Text)
                {
                    LblCursorY.Text = sY;
                    LblCursorY.Location = new Point(LblCursorY.Location.X, YY);
                }


                ChartMain.Update();
            }));
        }
Beispiel #25
0
        public static string NewString()
        {
            try
            {
                TickTime start  = TickTime.Now;
                string   time   = TickTime.NowTicks.ToString("X");
                string   random = AMath.Random(1, 1000000).ToString("X");
                string   span   = start.Span().ToString("X");

                return(string.Format("{0}{1}{2}", time, random, span));
            }
            catch (Exception ex)
            {
                ex.ToOutput();
                return(null);
            }
        }
Beispiel #26
0
        public Task SaveMath(AMath math)
        {
            return Task.Run(() =>
            {
                using (var entities = new MathDbEntities())
                using (var entitiesTransaction = entities.Database.BeginTransaction())
                {
                    try
                    {
                        var dbUser = entities.tbl_user.SingleOrDefault(x => x.name.ToLower() == math.User.UserName.Trim().ToLower());

                        var newUser = new tbl_user
                        {
                            name = math.User.UserName
                        };
                        var newMath = new tbl_math
                        {
                            number_1 = math.FirstNumber,
                            number_2 = math.SecondNumber,
                            summation = math.Result,
                            created_on = DateTime.Now
                        };

                        if (dbUser != null)
                        {
                            newMath.created_by = dbUser.id;
                            entities.tbl_math.Add(newMath);
                        }
                        else
                        {
                            newUser.tbl_math.Add(newMath);
                            entities.tbl_user.Add(newUser);
                        }

                        entities.SaveChanges();
                        entitiesTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        entitiesTransaction.Rollback();
                        throw new Exception(ex.ToString());
                    }
                }
            });
        }
Beispiel #27
0
        //private YouTubeService YTService;

        public static string RandomVideo(int exceptions_countout = 3, string base_url = "www.youtube.com/watch?v=")
        {
            if (exceptions_countout < 0)
            {
                return(null);
            }

            YouTubeService YTService = new YouTubeService(new BaseClientService.Initializer()
            {
                ApiKey          = "AIzaSyBpscnC6P4cL7S6_W_3zxQX3NHeU5v6ypA",
                ApplicationName = "Asmodat"
            });
            SearchListResponse YTSearchResponse;

            // YTService.a

            var YTSearchRequest = YTService.Search.List("snippet");

            YTSearchRequest.Q          = "v=" + Randomizer.GetString(Randomizer.Seed_NumbersLowerUpperCaseLetters, 3, 4);
            YTSearchRequest.MaxResults = AMath.Random(25, 50);

            try
            {
                YTSearchResponse = YTSearchRequest.Execute();
            }
            catch
            {
                return(RandomVideo(--exceptions_countout, base_url));
            }

            int count = 0;

            if (YTSearchResponse == null || YTSearchResponse.Items == null || (count = YTSearchResponse.Items.Count) <= 0)
            {
                return(null);
            }

            int select = AMath.Random(0, count);

            return(base_url + YTSearchResponse.Items[select].Id.VideoId);
        }
Beispiel #28
0
        public NativeFont_(string name, int height, FontStyle style = default, bool calculateHeightOnScreen = false)
        {
            using var dcs = new ScreenDC_(0);
            int h2 = -AMath.MulDiv(height, Api.GetDeviceCaps(dcs, 90), 72);             //LOGPIXELSY=90

            Handle = Api.CreateFont(h2,
                                    cWeight: style.Has(FontStyle.Bold) ? 700 : 0, //FW_BOLD
                                    bItalic: style.Has(FontStyle.Italic) ? 1 : 0,
                                    bUnderline: style.Has(FontStyle.Underline) ? 1 : 0,
                                    bStrikeOut: style.Has(FontStyle.Strikeout) ? 1 : 0,
                                    iCharSet: 1,
                                    pszFaceName: name);
            if (calculateHeightOnScreen)
            {
                using var dcMem = new CompatibleDC_(dcs);
                var of = Api.SelectObject(dcMem, Handle);
                Api.GetTextExtentPoint32(dcMem, "A", 1, out var z);
                HeightOnScreen = z.height;
                Api.SelectObject(dcMem, of);
            }
        }
Beispiel #29
0
        /// <summary>
        /// Colours textbox RGB depending on value
        /// </summary>
        /// <param name="Tbx"></param>
        /// <param name="value"></param>
        /// <param name="exception"></param>
        /// <param name="decimals"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="punctuation"></param>
        public static void ColourDouble(ref TextBox Tbx, double value, string exception, int decimals, double min, double max, char punctuation, double precision = 0)
        {
            Tbx.Text = Doubles.ToString(value, exception, decimals, min, max, punctuation);

            if (Tbx.Text == exception)
            {
                Tbx.ForeColor = Color.Black;
            }
            else if (AMath.Equ(value, 0, precision))
            {
                Tbx.ForeColor = Color.DarkBlue;
            }
            else if (value < 0)
            {
                Tbx.ForeColor = Color.DarkRed;
            }
            else if (value > 0)
            {
                Tbx.ForeColor = Color.DarkGreen;
            }
        }
Beispiel #30
0
            public bool Detect(POINT pt)
            {
                //get normal x y. In pt can be outside screen when cursor moved fast and was stopped by a screen edge. Tested: never for click/wheel events.
                //AOutput.Write(pt, AMouse.XY);
                //var r = AScreen.Of(pt).Bounds; //problem with empty corners between 2 unaligned screens: when mouse tries to quickly diagonally cut such a corner, may activate a wrong trigger
                var r = AScreen.Of(AMouse.XY).Bounds;                 //smaller problem: AMouse.XY gets previous coordinates

                _xmin = r.left; _ymin = r.top; _xmax = r.right - 1; _ymax = r.bottom - 1;
                _x    = AMath.MinMax(pt.x, _xmin, _xmax);
                _y    = AMath.MinMax(pt.y, _ymin, _ymax);
                //AOutput.Write(pt, _x, _y, r);

                result    = default;
                result.pt = (_x, _y);

                _Detect();
                _prev.xx = _x; _prev.yy = _y;

#if DEBUG
                //AOutput.Write(++_prev.debug, edgeEvent, moveEvent, (_x, _y));
#endif
                return(result.edgeEvent != 0 || result.moveEvent != 0);
            }