Exemple #1
0
        private void txtDeviceNum_Validating(object sender, CancelEventArgs e)
        {
            if (eventTiggerOptions != null && deviceNumChanged)
            {
                if (RangeUtils.StrToRange(txtDeviceNum.Text, true, true, out resultRange))
                {
                    // update the list of trigger device nums
                    eventTiggerOptions.DeviceNums.Clear();

                    foreach (int val in resultRange)
                    {
                        eventTiggerOptions.DeviceNums.Add(val);
                    }

                    txtDeviceNum.ForeColor = Color.FromKnownColor(KnownColor.WindowText);

                    OnEventTriggerOptionsChanged();
                }
                else
                {
                    // show a message
                    txtDeviceNum.ForeColor = Color.Red;
                    ScadaUiUtils.ShowError(LibPhrases.RangeNotValid);
                }
            }
        }
Exemple #2
0
        /// <summary>
        ///     Interseccion entre los recubrimientos.
        /// </summary>
        /// <param name="rec">Rectangulo.</param>
        public BoundingBox3d Intersect(BoundingBox3d rec)
        {
            double rxMin, rxMax;

            RangeUtils.Intersect(this.XMin, this.XMax, rec.XMin, rec.XMax, out rxMin, out rxMax);
            if (RangeUtils.IsEmpty(rxMin, rxMax))
            {
                return(Empty);
            }

            double ryMin, ryMax;

            RangeUtils.Intersect(this.YMin, this.YMax, rec.YMin, rec.YMax, out ryMin, out ryMax);
            if (RangeUtils.IsEmpty(ryMin, ryMax))
            {
                return(Empty);
            }

            double rzMin, rzMax;

            RangeUtils.Intersect(this.ZMin, this.ZMax, rec.ZMin, rec.ZMax, out rzMin, out rzMax);
            if (RangeUtils.IsEmpty(rzMin, rzMax))
            {
                return(Empty);
            }

            return(new BoundingBox3d(rxMin, rxMax, ryMin, ryMax, rzMin, rzMax));
        }
Exemple #3
0
 /// <summary>
 /// Loads the settings from the XML node.
 /// </summary>
 public override void LoadFromXml(XmlNode xmlNode)
 {
     base.LoadFromXml(xmlNode);
     RestartServer = xmlNode.GetChildAsBool("RestartServer");
     RestartComm   = xmlNode.GetChildAsBool("RestartComm");
     SetObjNums(RangeUtils.StrToRange(xmlNode.GetChildAsString("ObjNums"), true, true));
 }
Exemple #4
0
        internal IEnumerable <Fingerprint> CreateOriginalFingerprintsFromFrames(IEnumerable <Frame> frames, FingerprintConfiguration configuration)
        {
            var fingerprints = new ConcurrentBag <Fingerprint>();
            var images       = frames.ToList();

            if (!images.Any())
            {
                return(Enumerable.Empty <Fingerprint>());
            }

            var length = images.First().Length;

            Parallel.ForEach(images, () => new ushort[length], (frame, loop, cachedIndexes) =>
            {
                float[] rowCols = configuration.OriginalPointSaveTransform != null ? frame.GetImageRowColsCopy() : frame.ImageRowCols;
                waveletDecomposition.DecomposeImageInPlace(rowCols, frame.Rows, frame.Cols, configuration.HaarWaveletNorm);
                RangeUtils.PopulateIndexes(length, cachedIndexes);
                var image = fingerprintDescriptor.ExtractTopWavelets(rowCols, configuration.TopWavelets, cachedIndexes);
                if (!image.IsSilence())
                {
                    fingerprints.Add(new Fingerprint(image, frame.StartsAt, frame.SequenceNumber));
                }

                return(cachedIndexes);
            },
                             cachedIndexes => { });

            return(fingerprints.ToList());
        }
Exemple #5
0
 /// <summary>
 /// Saves the settings into the XML node.
 /// </summary>
 public override void SaveToXml(XmlElement xmlElem)
 {
     base.SaveToXml(xmlElem);
     xmlElem.AppendElem("RestartServer", RestartServer);
     xmlElem.AppendElem("RestartComm", RestartComm);
     xmlElem.AppendElem("ObjNums", RangeUtils.RangeToStr(ObjNums));
 }
Exemple #6
0
        /// <summary>
        /// Edits Range or Adds Range.
        /// </summary>
        public static bool EditRange(ICollection <int> range)
        {
            if (range == null)
            {
                throw new ArgumentNullException(nameof(range));
            }

            FrmRangeEdit frmRange = new FrmRangeEdit();

            frmRange.txtRange.Text = RangeUtils.RangeToStr(range);

            if (frmRange.ShowDialog() == DialogResult.OK)
            {
                range.Clear();

                foreach (int val in frmRange.resultRange)
                {
                    range.Add(val);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
        private static void wordCompletionTimer_Tick(object sender, EventArgs e)
        {
            s_wordCompletionTimer.Enabled = false;
            s_nTimerTickCount++;
            if (s_nTimerTickCount > 3)
            {
                LogHelper.Debug("Failed to change the word content in 10 tries");
                return;
            }

            if (s_nTimerTickCount % 2 == 0)
            {
                s_distractionForm.Visible = true;
                //s_distractionForm.Focus();
                s_distractionForm.Visible = false;
                s_windowListenerInstance.Focus();
            }

            Range r = RangeUtils.GetWordBeforeCursor(Globals.ThisAddIn.Application.Selection);

            if (RangeUtils.IsRangeEmpty(r))
            {
                LogHelper.Debug(String.Format("wordCompletionTimer_Tick : Range is Empty at ({0})th try.", s_nTimerTickCount));
                s_wordCompletionTimer.Enabled = true;
            }
            else
            {
                s_rangeToBeChanged = r;
                RangeBeforeCuresorRecognized();
            }
        }
Exemple #8
0
        private void btnEditCnlNum_Click(object sender, EventArgs e)
        {
            if (triggerOptions != null)
            {
                if (FrmRangeEdit.EditRange(triggerOptions.CnlNums))
                {
                    txtCnlNum.Text      = RangeUtils.RangeToStr(triggerOptions.CnlNums);
                    txtCnlNum.ForeColor = Color.FromKnownColor(KnownColor.WindowText);

                    if (txtCnlNum.Text == "")
                    {
                        chkSingleQuery.Checked = false;
                        chkSingleQuery.Enabled = false;
                    }
                    else
                    {
                        chkSingleQuery.Enabled = true;
                    }

                    OnTriggerOptionsChanged();
                }
            }

            txtCnlNum.Select();
            txtCnlNum.DeselectAll();
        }
Exemple #9
0
 private bool EpsilonEquals(double xmin, double xmax,
                            double ymin, double ymax,
                            double epsilon)
 {
     return(RangeUtils.EpsilonEquals(this.XMin, this.XMax, xmin, xmax, epsilon) &&
            RangeUtils.EpsilonEquals(this.YMin, this.YMax, ymin, ymax, epsilon));
 }
Exemple #10
0
    public void UpdateRange()
    {
        HexCoord c = HexagonUtils.Pos2Coord(curPosition);
        var      r = RangeUtils.GetRangeClient(c, range);

        r.Add(c);
        indicator.SetRange(r);
    }
Exemple #11
0
 void IView.ScrollStateHistoryItemIntoView(int itemIndex)
 {
     if (stateHistoryDataSource.data.Count == 0)
     {
         return;
     }
     stateHistoryView.ScrollRowToVisible(RangeUtils.PutInRange(0, stateHistoryDataSource.data.Count - 1, itemIndex));
 }
Exemple #12
0
        /// <summary>
        /// Amplia el recubrimiento para que contenga al rectangulo indicado.
        /// </summary>
        /// <param name="rec">Rectangulo.</param>
        public BoundingBox1d Union(BoundingBox1d rec)
        {
            double rxMin, rxMax;

            RangeUtils.Union(this.XMin, this.XMax, rec.XMin, rec.XMax, out rxMin, out rxMax);

            return(new BoundingBox1d(rxMin, rxMax));
        }
Exemple #13
0
        /// <summary>
        /// Amplia el recubrimiento para que contenga al punto indicado.
        /// </summary>
        /// <param name="point">Punto.</param>
        public BoundingBox1d Union(double point)
        {
            double rxMin, rxMax;

            RangeUtils.Union(this.XMin, this.XMax, point, out rxMin, out rxMax);

            return(new BoundingBox1d(rxMin, rxMax));
        }
Exemple #14
0
        /// <summary> 将从Pycharm中复制到word中的代码进行格式化</summary>
        /// <param name="wdApp"></param>
        public static void FormatCodeFromIDE(Application wdApp)
        {
            Document doc = wdApp.ActiveDocument;

            Selection sel = wdApp.Selection;
            Range     rg  = sel.Range;

            if (rg != null)
            {
                try
                {
                    wdApp.ScreenUpdating = false;


                    // 1. change the font size
                    rg.Font.Size = 12;
                    rg.Font.Name = "Times New Roman";

                    // 2. change the shadow color to none
                    var     format = rg.ParagraphFormat;
                    Shading shade  = format.Shading;
                    shade.Texture = WdTextureIndex.wdTextureNone;
                    shade.ForegroundPatternColor = WdColor.wdColorAutomatic;
                    shade.BackgroundPatternColor = WdColor.wdColorAutomatic;

                    // 3. clear all tabs
                    format.TabStops.ClearAll();

                    // 4. unBold the range
                    rg.Font.Bold = 0;

                    foreach (Table tb in rg.Tables)
                    {
                        // 5. change  the talbe style
                        tb.set_Style("zengfy表格-代码");

                        foreach (Row row in tb.Rows)
                        {
                            // 6. change the indent if the code is in a table
                            var rowFormat = row.Range.ParagraphFormat;
                            rowFormat.SpaceBeforeAuto = 0;
                            rowFormat.SpaceAfterAuto  = 0;
                            rowFormat.FirstLineIndent = wdApp.CentimetersToPoints(0);
                        }
                    }

                    // 7. replace the charactors
                    RangeUtils.ReplaceCharactors(rg, "^l", "^p");

                    //
                    rg.HighlightColorIndex = WdColorIndex.wdNoHighlight;
                }
                finally
                {
                    wdApp.ScreenUpdating = true;
                }
            }
        }
Exemple #15
0
 public IEnumerable <IndexedMessage> Forward(int begin, int end)
 {
     begin = RangeUtils.PutInRange(0, size, begin);
     end   = RangeUtils.PutInRange(0, size, end);
     for (int i = begin; i < end; ++i)
     {
         yield return(new IndexedMessage(i, data[i]));
     }
 }
Exemple #16
0
        private void RunTest(IEnumerable <float[]> pool, FingerprintDescriptor descriptor)
        {
            const int TopWavelets = 200;

            foreach (var floats in pool)
            {
                descriptor.ExtractTopWavelets(floats, TopWavelets, RangeUtils.GetRange(floats.Length));
            }
        }
Exemple #17
0
 IEnumerable <IndexedMessage> IMessagesCollection.Reverse(int begin, int end)
 {
     begin = RangeUtils.PutInRange(-1, messages.Count - 1, begin);
     end   = RangeUtils.PutInRange(0, messages.Count, end);
     for (int i = begin; i > end; --i)
     {
         yield return(new IndexedMessage(i, messages[i]));
     }
 }
Exemple #18
0
 static void Validate(ref Appearance appearance)
 {
     appearance.Coloring = (Appearance.ColoringMode)RangeUtils.PutInRange(
         (int)Appearance.ColoringMode.Minimum, (int)Appearance.ColoringMode.Maximum, (int)appearance.Coloring);
     appearance.FontSize = (Appearance.LogFontSize)RangeUtils.PutInRange(
         (int)Appearance.LogFontSize.Minimum, (int)Appearance.LogFontSize.Maximum, (int)appearance.FontSize);
     appearance.ColoringBrightness = (PaletteBrightness)RangeUtils.PutInRange(
         (int)PaletteBrightness.Minimum, (int)PaletteBrightness.Maximum, (int)appearance.ColoringBrightness);
 }
Exemple #19
0
 public IEnumerable <IndexedMessage> Reverse(int begin, int end)
 {
     begin = RangeUtils.PutInRange(-1, size - 1, begin);
     end   = RangeUtils.PutInRange(-1, size - 1, end);
     for (int i = begin; i > end; --i)
     {
         yield return(new IndexedMessage(i, data[i]));
     }
 }
Exemple #20
0
        private void ReadText()
        {
            m_text = (m_range == null) ? null : m_range.Text;

            if (m_text == null || String.IsNullOrEmpty(RangeUtils.TrimRangeText(m_text)))
            {
                m_isInvalid = true;
            }
            m_isTextRead = true;
        }
Exemple #21
0
 void UpdateExpandedState()
 {
     view.UpdateExpandedState(
         isExpandable: IsResultsListExpandable(),
         isExpanded: isSearchesListExpanded,
         preferredListHeightInRows: RangeUtils.PutInRange(3, 8, searchManager.Results.Count()),
         expandButtonHint: "Show previous search results list",
         unexpandButtonHint: "Hide previous search results list"
         );
 }
Exemple #22
0
    public override void OnEnter()
    {
        base.OnEnter();

        var vision       = TowerManager.Instance.GetHexagonsInVision(CurrentPlayer);
        var allAttackers = TowerManager.Instance.GetTowersOfType(CurrentPlayer, TowerType.AttackTower);

        var allTowers = TowerManager.Instance.GetAllTowers();

        foreach (var a in allAttackers)
        {
            if (a.state != TowerInfo.BuildingState.Working)
            {
                continue;
            }

            int targetNumbers = 0;

            var range = RangeUtils.GetRangeOfTower(a, vision);

            int m = RangeUtils.maxTargetCount(a.range);

            float addedDamage = 0.5f / (m * m - m);

            foreach (var t in allTowers)
            {
                if (t.playerSlotId == CurrentPlayer.SlotId)
                {
                    continue;
                }

                if (range.Contains(t.coord)) //Auto attack towers
                {
                    targetNumbers++;
                }
            }

            float currentDamage = 1.0f / targetNumbers + addedDamage;

            foreach (var t in allTowers)
            {
                if (t.playerSlotId == CurrentPlayer.SlotId)
                {
                    continue;
                }

                //Play attack animation

                if (range.Contains(t.coord)) //Auto attack towers
                {
                    t.healthGP -= currentDamage;
                }
            }
        }
    }
Exemple #23
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (RangeUtils.StrToRange(txtRange.Text, true, true, out resultRange))
     {
         DialogResult = DialogResult.OK;
     }
     else
     {
         ScadaUiUtils.ShowError(LibPhrases.RangeNotValid);
     }
 }
Exemple #24
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string) && value is ICollection <int> collection)
     {
         return(RangeUtils.RangeToStr(collection));
     }
     else
     {
         return(base.ConvertTo(context, culture, value, destinationType));
     }
 }
 bool TryUpdateSelectedSuggestion(int?delta = null)
 {
     if (!suggestionsListVisible)
     {
         return(false);
     }
     if (suggestions.IsEmpty)
     {
         return(false);
     }
     if (delta == null)
     {
         selectedSuggestion = FindBestSuggestion(
             suggestions
             .Select((s, i) => new KeyValuePair <int, string>(i, s.IsSelectable ? s.data.Value.DisplayString : null))
             .Where(x => x.Value != null),
             text
             );
     }
     else if (Math.Abs(delta.Value) == 1)
     {
         for (;;)
         {
             selectedSuggestion = (selectedSuggestion + delta.Value + suggestions.Length) % suggestions.Length;
             if (suggestions[selectedSuggestion].IsSelectable)
             {
                 break;
             }
         }
     }
     else
     {
         Func <int, bool> trySet = val =>
         {
             val = RangeUtils.PutInRange(0, suggestions.Length - 1, val);
             if (!suggestions[val].IsSelectable)
             {
                 return(false);
             }
             selectedSuggestion = val;
             return(true);
         };
         for (int i = 0; ; ++i)
         {
             if (trySet(selectedSuggestion + delta.Value + i) || trySet(selectedSuggestion + delta.Value - i))
             {
                 break;
             }
         }
     }
     changeNotification.Post();
     return(true);
 }
Exemple #26
0
        /// <summary>
        /// Interseccion entre los recubrimientos.
        /// </summary>
        /// <param name="rec">Rectangulo.</param>
        public BoundingBox1d Intersect(BoundingBox1d rec)
        {
            double rxMin, rxMax;

            RangeUtils.Intersect(this.XMin, this.XMax, rec.XMin, rec.XMax, out rxMin, out rxMax);
            if (RangeUtils.IsEmpty(rxMin, rxMax))
            {
                return(Empty);
            }

            return(new BoundingBox1d(rxMin, rxMax));
        }
Exemple #27
0
        /// <summary>
        /// Amplia el recubrimiento para que contenga al punto indicado.
        /// </summary>
        /// <param name="point">Punto.</param>
        public BoundingBox2d Union(Point2d point)
        {
            double rxMin, rxMax;

            RangeUtils.Union(this.XMin, this.XMax, point.X, out rxMin, out rxMax);

            double ryMin, ryMax;

            RangeUtils.Union(this.YMin, this.YMax, point.Y, out ryMin, out ryMax);

            return(new BoundingBox2d(rxMin, rxMax, ryMin, ryMax));
        }
Exemple #28
0
        /// <summary>
        /// Loads the options from the XML node.
        /// </summary>
        public virtual void LoadFromXml(XmlElement xmlElem)
        {
            if (xmlElem == null)
            {
                throw new ArgumentNullException(nameof(xmlElem));
            }

            Active = xmlElem.GetAttrAsBool("active", true);
            Name   = xmlElem.GetAttrAsString("name");
            CnlNums.AddRange(RangeUtils.StrToRange(xmlElem.GetChildAsString("CnlNums"), true, true));
            DeviceNums.AddRange(RangeUtils.StrToRange(xmlElem.GetChildAsString("DeviceNums"), true, true));
            Query = xmlElem.GetChildAsString("Query");
        }
Exemple #29
0
        private void btnSelectObj_Click(object sender, EventArgs e)
        {
            // show a dialog to select objects
            FrmObjSelect frmObjSelect = new FrmObjSelect(configBase)
            {
                ObjNums = RangeUtils.StrToRange(txtObjFilter.Text, true, false, false)
            };

            if (frmObjSelect.ShowDialog() == DialogResult.OK)
            {
                txtObjFilter.Text = RangeUtils.RangeToStr(frmObjSelect.ObjNums);
            }
        }
Exemple #30
0
        /// <summary>
        /// Saves the options into the XML node.
        /// </summary>
        public virtual void SaveToXml(XmlElement xmlElem)
        {
            if (xmlElem == null)
            {
                throw new ArgumentNullException(nameof(xmlElem));
            }

            xmlElem.SetAttribute("active", Active);
            xmlElem.SetAttribute("name", Name);
            xmlElem.SetAttribute("type", TriggerType);
            xmlElem.AppendElem("CnlNums", RangeUtils.RangeToStr(CnlNums));
            xmlElem.AppendElem("DeviceNums", RangeUtils.RangeToStr(DeviceNums));
            xmlElem.AppendElem("Query", Query);
        }