Example #1
0
        private void RibbonButton_Click_2(object sender, RoutedEventArgs e)
        {
            if (this._currentWorkplace == null)
            {
                MessageBox.Show("Осциллограмма не загружена");
                return;
            }
            OpenFileDialog _openFileDialog = new OpenFileDialog();

            _openFileDialog.Filter = "Файл com-trade|*.cfg";
            bool?res = _openFileDialog.ShowDialog(this);

            if (res.GetValueOrDefault())
            {
                try
                {
                    var hdr    = File.ReadAllLines(Path.ChangeExtension(App.BasePath, "hdr"));
                    int lenght = hdr.Length;
                    this._encodding = Convert.ToInt32(hdr[lenght - 1]);
                    ComTrade file = ComTrade.Load(_openFileDialog.FileName, this._encodding);
                    if (this._currentWorkplace.Data.IsEqual(file))
                    {
                        ComTrade newComtrade = this._currentWorkplace.Data.Add(file);
                        this.Data = newComtrade;
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    this._encodding = 0;
                    ComTrade file = ComTrade.Load(_openFileDialog.FileName, this._encodding);
                    if (this._currentWorkplace.Data.IsEqual(file))
                    {
                        ComTrade newComtrade = this._currentWorkplace.Data.Add(file);
                        this.Data = newComtrade;
                    }
                }

                catch (Exception)
                {
                    MessageBox.Show("Ошибка. Файл не может быть загружен");
                }
            }
        }
Example #2
0
        private void RibbonButton_Click_1(object sender, RoutedEventArgs e)
        {
            if (this._currentWorkplace == null)
            {
                MessageBox.Show("Осциллограмма не загружена");
                return;
            }
            CutForm cutForm = new CutForm();

            cutForm.Marker1 = this.CurrentWorkplace.MarkersBar.Markers.Marker1;
            cutForm.Marker2 = this.CurrentWorkplace.MarkersBar.Markers.Marker2;
            cutForm.Min     = 0;
            cutForm.Max     = this._currentWorkplace.Data.Cfg.Size;
            if (cutForm.ShowDialog().Value)
            {
                ComTrade a = this.CurrentWorkplace.Data.Copy(cutForm.OscName, cutForm.Start, cutForm.End);
                this.Data = a;
            }
        }
Example #3
0
        public MainWindow()
        {
            this.InitializeComponent();

            new LayoutAnchorablePaneVisibleBinding(this.VectorCheckBox, this.VectorPanel);
            new LayoutAnchorablePaneVisibleBinding(this.PieCheckBox, this.PiePanel);
            new LayoutAnchorablePaneVisibleBinding(this.FreqCharCheckBox, this.FrequencyPanel);

            var bind = new CommandBinding(ApplicationCommands.Open);

            bind.Executed += this.OpenMenuItem_Click;
            this.CommandBindings.Add(bind);
            bind           = new CommandBinding(ApplicationCommands.Close);
            bind.Executed += (sender, args) => this.Close();
            this.CommandBindings.Add(bind);
            bind           = new CommandBinding(ApplicationCommands.SaveAs);
            bind.Executed += this.SaveAsMenuItem_Click;
            this.CommandBindings.Add(bind);

            this.VectorChart.MoveMarker += this.ChartOnMoveMarker;
            this.PieChart.MoveMarker    += this.ChartOnMoveMarker;
            try
            {
                this._hdr = File.ReadAllLines(Path.ChangeExtension(App.BasePath, "hdr"));
                string ttl    = this._hdr[0];
                int    lenght = this._hdr.Length;
                if (!int.TryParse(this._hdr[lenght - 1], out this._encodding) || this._encodding != 1251)
                {
                    this._encodding = 0;
                }
                Title = ttl;
            }
            catch (Exception)
            {
                this._encodding = 0;
            }
            this.Data = ComTrade.Load(App.BasePath, this._encodding);
        }
Example #4
0
        private void OpenMenuItem_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog _openFileDialog = new OpenFileDialog();

            _openFileDialog.InitialDirectory = this._openInitialDirectory;
            _openFileDialog.Filter           = "Файл com-trade|*.cfg";
            bool?res = _openFileDialog.ShowDialog(this);

            if (res.GetValueOrDefault())
            {
                this._openInitialDirectory = Path.GetDirectoryName(_openFileDialog.FileName);

                try
                {
                    ComTrade file = ComTrade.Load(_openFileDialog.FileName, this._encodding);
                    this.Data = file;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ошибка. Файл не может быть загружен");
                }
            }
        }