コード例 #1
0
        /// <summary>
        /// установка текста рекомендации
        /// </summary>
        private void setRecommendation()
        {
            try
            {
                scintillaRecommendations.ReadOnly = false;
                scintillaRecommendations.Text     = "";
                Dictionary <string, Color> textCollection = RangeTerrain.GetRecommendation(range, pointCoordinates, Vars.ETOPOdatabase);
                int i = 9, start = 0;
                foreach (string text in textCollection.Keys)
                {
                    scintillaRecommendations.Text += text + "\n";

                    Indicator indic = scintillaRecommendations.Indicators[i++];
                    indic.Style     = IndicatorStyle.TextFore;
                    indic.ForeColor = textCollection[text];
                    indic.Alpha     = 100;
                    scintillaRecommendations.IndicatorCurrent = indic.Index;
                    scintillaRecommendations.IndicatorFillRange(start, text.Length);
                    start += text.Length + 1;
                }
            }
            catch (WindEnergyException ex)
            {
                Indicator indic = scintillaRecommendations.Indicators[16];
                indic.Style     = IndicatorStyle.TextFore;
                indic.ForeColor = Color.Red;
                indic.Alpha     = 100;
                scintillaRecommendations.IndicatorCurrent = indic.Index;
                scintillaRecommendations.Text             = ex.Message;
                scintillaRecommendations.IndicatorFillRange(0, ex.Message.Length);
            }
            finally
            {
                scintillaRecommendations.ReadOnly = true;
            }
        }
コード例 #2
0
        private void buttonCalculate_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            Action <int> action = new Action <int>((percent) =>
            {
                try
                {
                    if (this.InvokeRequired)
                    {
                        _ = Invoke(new Action(() => { progressBar1.Value = percent; }));
                    }
                    else
                    {
                        progressBar1.Value = percent;
                    }
                }
                catch (Exception) { }
            });

            Action <RawRange, FlugerMeteostationInfo> actionAfter = new Action <RawRange, FlugerMeteostationInfo>((rawRange, fluger_MS) =>
            {
                _ = this.Invoke(new Action(() =>
                {
                    string text = fluger_MS != null ? $"\r\nпо данным МС {fluger_MS.Name} ({fluger_MS.Position}) с учетом изменения классов открытости площадок" : "";
                    _           = MessageBox.Show(this, $"Скорости ветра пересчитаны в точку ВЭС ({pointCoordinates.ToString(3)}){((!string.IsNullOrWhiteSpace(text)) ? text : "")}", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    rawRange.Name = $"Ряд в точке {pointCoordinates.ToString(3)}";
                    if (rawRange == null)
                    {
                        DialogResult = DialogResult.Cancel;
                    }
                    else
                    {
                        DialogResult = DialogResult.OK;
                        Result       = rawRange;
                    }
                    Cursor = Cursors.Arrow;
                    Result = rawRange;
                    Close();
                }));
            });

            try
            {
                if (range.Position.IsEmpty)
                {
                    FormSelectMapPointDialog fsp = new FormSelectMapPointDialog("Выберите координаты ряда " + range.Name, PointLatLng.Empty, Vars.Options.CacheFolder, Resources.rp5_marker, Vars.Options.MapProvider);
                    if (fsp.ShowDialog(this) == DialogResult.OK)
                    {
                        range.Position = fsp.Result;
                    }
                    else
                    {
                        return;
                    }
                }

                RangeTerrain.ProcessRange(range, new TerrainParameters()
                {
                    MSClasses                = msClasses,
                    PointClasses             = pointClasses,
                    TerrainType              = terrainType,
                    PointCoordinates         = pointCoordinates,
                    FlugerMeteostation       = flugerMeteostation,
                    AtmosphereStratification = stratification,
                    MicroclimateCoefficient  = microclimateCoeff,
                    MesoclimateCoefficient   = mesoclimateCoeff,
                }, action, actionAfter);;
            }
            catch (WebException exc)
            {
                Cursor       = Cursors.Arrow;
                _            = MessageBox.Show(this, exc.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.Cancel;
            }
            catch (WindEnergyException wex)
            {
                Cursor       = Cursors.Arrow;
                _            = MessageBox.Show(this, wex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.Cancel;
            }
            catch (ApplicationException exc)
            {
                Cursor       = Cursors.Arrow;
                _            = MessageBox.Show(this, exc.Message + "\r\nПопробуйте уменьшить длину ряда", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.Cancel;
            }
            catch (Exception ex)
            {
                Cursor       = Cursors.Arrow;
                _            = MessageBox.Show(this, "Произошла ошибка:\r\n" + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.Cancel;
            }
        }