Ejemplo n.º 1
0
        private void FilterApplyClick(object sender)
        {
            MyAnimations.AnimateOpacity(LabelWriteOutput, 0, 1.00, 300);
            MyAnimations.AnimateOpacity(ImageProcessingInfo, 1.0, 0, 300);

            if (Image3.Opacity > 0)
            {
                MyAnimations.AnimateOpacity(Image3, 1.0, 0, 300);
            }

            var filterBox = (FilterEdit)sender;

            _lastFilterType = filterBox.TypeOfFilter;

            var filterColors = new[]
            {
                Color.FromArgb(150, 244, 164, 96),
                Color.FromArgb(150, 164, 244, 96),
                Color.FromArgb(150, 244, 96, 164),
                Color.FromArgb(150, 96, 164, 244)
            };

            if (FiltersGraph.SelectedFilter != -1)
            {
                FiltersGraph.EditFilterDef(FiltersGraph.SelectedFilter, filterBox.TypeOfFilter,
                                           filterBox.FrequencyOne, filterBox.FrequencyTwo,
                                           filterColors[FiltersGraph.SelectedFilter]);
            }
            else
            {
                FiltersGraph.AddFilterDef(filterBox.TypeOfFilter,
                                          filterBox.FrequencyOne, filterBox.FrequencyTwo,
                                          filterColors[FiltersGraph.GetFiltersCount()]);
            }
        }
Ejemplo n.º 2
0
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            DeleteFilter.Visibility = EditMode ? Visibility.Visible : Visibility.Hidden;

            MyAnimations.AnimateProcessingWindowLoad(BackGrid, SurfGrid, ActualHeight);

            edit_panel1.Opacity = 0.0;
            edit_panel1.FlowBox(0, false);
            edit_panel1.Value      = Knob.FormatValue(knobCutOff.Value);
            edit_panel1.Active     = knobCutOff;
            edit_panel1.OnChange  += edit_panel_OnChange;
            edit_panel1.OnFlowing += edit_panel_OnFlowing;
            edit_panel1.textBox1.Focus();

            edit_panel2.Opacity = 0.0;
            edit_panel2.FlowBox(0, false);
            edit_panel2.Value      = Knob.FormatValue(knobLowFreq.Value);
            edit_panel2.Active     = knobLowFreq;
            edit_panel2.OnChange  += edit_panel_OnChange;
            edit_panel2.OnFlowing += edit_panel_OnFlowing;
            edit_panel2.textBox1.Focus();

            //graph1.GraphPen = new Pen(new SolidColorBrush(Color.FromArgb(100, 0xa5, 0x2a, 0x2a)), 7);
            Graph1.GraphPen = new Pen(new SolidColorBrush(Color.FromArgb(25, 117, 152, 45)), 7);
            Graph1.AxisPen  = new Pen(new SolidColorBrush(Color.FromArgb(200, 50, 50, 50)), 3);
        }
Ejemplo n.º 3
0
        void TextBox1KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (OnChange != null)
                {
                    OnChange(this, Active, Value);
                }
            }

            if (e.Key == Key.Tab)
            {
                var next = _flowedTo;

                if (Opacity < 1.0)
                {
                    MyAnimations.AnimateOpacity(this, 0, 1, 100);
                }
                else
                {
                    next = _flowedTo + 1;
                    if (next >= _span)
                    {
                        next = 0;
                    }
                }

                FlowBox(next);
            }
        }
Ejemplo n.º 4
0
        private void KnobMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (CutPanel.Visibility == Visibility.Visible)
            {
                if (edit_panel1.Opacity < 1.0)
                {
                    MyAnimations.AnimateOpacity(edit_panel1, 0, 1, 100);
                }

                if (sender.Equals(knobCutOff))
                {
                    edit_panel1.FlowBox(0);
                }
            }
            else
            {
                if (edit_panel2.Opacity < 1.0)
                {
                    MyAnimations.AnimateOpacity(edit_panel2, 0, 1, 100);
                }

                if (sender.Equals(knobLowFreq))
                {
                    edit_panel2.FlowBox(0);
                }
                if (sender.Equals(knobHiFreq))
                {
                    edit_panel2.FlowBox(1);
                }
            }
        }
Ejemplo n.º 5
0
        private void CloseAnimation()
        {
            Topmost = true;

            MyAnimations.AnimateOpacity(SurfGrid, Opacity, 0, 150);
            MyAnimations.AnimateRenderScale(this, 1, 0.0001, ActualWidth / 2, ActualHeight / 2, 300,
                                            (sender, args) => Close(), ScaleTransform.ScaleYProperty);
        }
Ejemplo n.º 6
0
        protected override void OnMouseLeave(MouseEventArgs e)
        {
            base.OnMouseLeave(e);

            if (_enterCatched)
            {
                MyAnimations.AnimateOpacity(this, 1.0, 0.4, 200);
            }
        }
Ejemplo n.º 7
0
 private void AnimateText(string text)
 {
     MyAnimations.AnimateRenderTranslation(TextLine, TranslateTransform.XProperty,
                                           0, (_increased ? -1 : 1) * TextLine.ActualWidth, 200, 0,
                                           (s, args) =>
     {
         TextLine.Text = text;
         DoFlyin();
     });
 }
Ejemplo n.º 8
0
        protected override void OnMouseEnter(MouseEventArgs e)
        {
            base.OnMouseEnter(e);

            _enterCatched = true;
            if (Opacity < 1.0)
            {
                MyAnimations.AnimateOpacity(this, Opacity, 1.0, 200);
            }
        }
Ejemplo n.º 9
0
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            base.OnMouseUp(e);

            MyAnimations.AnimateRenderScale(this, 0.98, 1, ActualWidth / 2, ActualHeight / 2, 100);

            if (OnClick != null)
            {
                OnClick(this);
            }
        }
Ejemplo n.º 10
0
        private void FilterTypeChanged(object sender, int selected)
        {
            // Change graph
            Graph.DlgExpression[] graphTable =
            {
                MyGraphLowPass,  MyGraphHighPass,
                MyGraphBandPass, MyGraphBandStop
            };

            MyAnimations.AnimateOpacity(Graph1, 1, 0, 200, 0,
                                        (s, args) =>
            {
                Graph1.Expression =
                    graphTable[selected];
                MyAnimations.AnimateOpacity(Graph1, 0, 1, 200);
            });

            // Change controls
            if (selected >= 2)
            {
                if (BandPanel.Visibility == Visibility.Hidden)
                {
                    MyAnimations.AnimateOpacity(CutPanel, 1, 0, 200, 0,
                                                (s, args) =>
                    {
                        CutPanel.Visibility  = Visibility.Hidden;
                        BandPanel.Visibility = Visibility.Visible;
                        MyAnimations.AnimateOpacity(BandPanel, 0, 1, 200);
                    });

                    edit_panel2.textBox1.Focus();
                }
            }
            else
            {
                if (CutPanel.Visibility == Visibility.Hidden)
                {
                    MyAnimations.AnimateOpacity(BandPanel, 1, 0, 200, 0,
                                                (s, args) =>
                    {
                        CutPanel.Visibility  = Visibility.Visible;
                        BandPanel.Visibility = Visibility.Hidden;
                        MyAnimations.AnimateOpacity(CutPanel, 0, 1, 200);
                    });

                    edit_panel1.textBox1.Focus();
                }
            }
        }
Ejemplo n.º 11
0
 private void GridMouseLeave1(object sender, MouseEventArgs e)
 {
     try
     {
         var element = (UIElement)sender;
         if (element.Opacity < 0.001)
         {
             return;
         }
         MyAnimations.AnimateOpacity(element, element.Opacity, 0.7, 100);
         //element.Opacity = 0.7;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 12
0
        public void OnRight(object sender, MouseButtonEventArgs e)
        {
            if (_items != null)
            {
                if (SelectedItem < _items.Count - 1)
                {
                    SelectedItem++;
                }
                else
                {
                    SelectedItem = 0;
                }

                var polygon = (Polygon)sender;
                MyAnimations.AnimateRenderScale(polygon, 1, 0.9,
                                                polygon.ActualWidth / 2, polygon.ActualHeight / 2, 200, null, null, true);
            }
        }
Ejemplo n.º 13
0
        private void WriteOutputMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (Grid3.Opacity < 1.0)
            {
                return;
            }

            var grid = (Grid)sender;

            MyAnimations.AnimateRenderScale(grid, 1.0, 0.98,
                                            grid.ActualWidth / 2, grid.ActualHeight / 2, 100, (s, t) => Dispatcher.InvokeAsync(() =>
            {
                if (ImageProcessingInfo.Opacity < 1.0)
                {
                    var fileName = "";
                    if (SaveFileDialog(ref fileName) == false)
                    {
                        return;
                    }

                    _targetFile = fileName;

                    Grid1.IsEnabled = false;
                    Grid2.IsEnabled = false;

                    MyAnimations.AnimateOpacity(LabelWriteOutput, 1.0, 0, 300);
                    MyAnimations.AnimateOpacity(ImageProcessingInfo, 0, 1.0, 300);

                    if (Image3.Opacity > 0)
                    {
                        MyAnimations.AnimateOpacity(Image3, 1.0, 0, 300);
                    }

                    LabelProcessingPersent.Content = "Processing: 0%";

                    StartProcessing();
                }
                else
                {
                    CloseRunningProcess();
                }
            }), null, true);
        }
Ejemplo n.º 14
0
 private void GridMouseEnter1(object sender, MouseEventArgs e)
 {
     try
     {
         var element = (UIElement)sender;
         if (element.IsEnabled)
         {
             if (element.Opacity < 0.001)
             {
                 return;
             }
             MyAnimations.AnimateOpacity(element, element.Opacity, 1.0, 100);
             //element.Opacity = 1.0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 15
0
        void RunningProcessExited(object sender, EventArgs e)
        {
            Dispatcher.Invoke(() =>
            {
                Grid1.IsEnabled = true;
                Grid2.IsEnabled = true;

                if (File.Exists(_targetFile))
                {
                    try
                    {
                        var runtimeWrap = new RuntimeWrap();

                        var fileInfo = new Dictionary <string, string>();
                        var response = runtimeWrap.GetFileResponse(_targetFile, ref fileInfo);

                        var responseConvert =
                            response.Select(
                                tuple => new PointF((float)tuple.Item1, (float)Math.Log(tuple.Item2)))
                            .ToArray();

                        ResultGraph.SetPoints(0, responseConvert, Colors.DarkSalmon, "Result");

                        var points = SourceGraph.GetPoints(0);
                        ResultGraph.SetPoints(1, (PointF[])points.Item1.Clone(), points.Item2, "Source");
                    }
                    catch
                    {
                        Dispatcher.InvokeAsync(() => MyAnimations.AnimateOpacity(TargetInfoError, 0, 1.0, 300));
                    }
                }

                if (TargetInfoError.Opacity > 0)
                {
                    MyAnimations.AnimateOpacity(TargetInfoError, 1.0, 0, 300);
                }

                MyAnimations.AnimateOpacity(ImageProcessingInfo, 1.0, 0, 300);
                MyAnimations.AnimateOpacity(Image3, 0, 1.0, 300);
            });
        }
Ejemplo n.º 16
0
 private void DoFlyin()
 {
     MyAnimations.AnimateRenderTranslation(TextLine, TranslateTransform.XProperty,
                                           (_increased ? 1 : -1) * TextLine.ActualWidth, 0, 200);
 }
Ejemplo n.º 17
0
        private void SelectSourceMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (Grid1.IsEnabled == false)
            {
                return;
            }

            var grid = (Grid)sender;

            MyAnimations.AnimateRenderScale(grid, 1.0, 0.98,
                                            grid.ActualWidth / 2, grid.ActualHeight / 2, 100, (o, args) =>
            {
                var fileName = "";
                if (OpenFileDialog(ref fileName) == false)
                {
                    return;
                }

                _sourceFile = fileName;

                var runtimeWrap = new RuntimeWrap();

                try
                {
                    var fileInfo = new Dictionary <string, string>();
                    var response = runtimeWrap.GetFileResponse(fileName, ref fileInfo);

                    var fileFreq    = long.Parse(fileInfo["samplerate"]);
                    var fileSamples = long.Parse(fileInfo["samples_per_channel"]);
                    var duration    = fileSamples * 8 / fileFreq;

                    DurationLabel.Content = "File duration: " + TimeSpan.FromSeconds(duration).ToString();

                    var responseConvert =
                        response.Select(
                            tuple => new PointF((float)tuple.Item1, (float)Math.Log(tuple.Item2)))
                        .ToArray();

                    SourceGraph.SetPoints(0, responseConvert, Colors.LightSteelBlue, "Source");

                    if (Grid2.Opacity < 1.0)
                    {
                        Dispatcher.InvokeAsync(() =>
                        {
                            MyAnimations.AnimateRenderTranslation(Grid2, TranslateTransform.YProperty,
                                                                  -Grid1.ActualHeight - 20, 0, 300, 50);
                            MyAnimations.AnimateOpacity(Grid2, 0, 0.7, 100, 50);
                            MyAnimations.AnimateOpacity(LabelSelectDsdiff, 1.0, 0.0, 300);
                            MyAnimations.AnimateOpacity(Image1, 0.0, 1.0, 300);

                            if (LabelLoadError.Opacity > 0)
                            {
                                MyAnimations.AnimateOpacity(LabelLoadError, 1.0, 0, 300);
                            }
                        });
                    }

                    if (LabelWriteOutput.Opacity < 1.0)
                    {
                        Dispatcher.InvokeAsync(() =>
                        {
                            MyAnimations.AnimateOpacity(LabelWriteOutput, 0, 1.0, 300);
                            MyAnimations.AnimateOpacity(ImageProcessingInfo, 1.0, 0, 300);
                        });
                    }

                    if (FiltersGraph.GetFiltersCount() > 0)
                    {
                        Dispatcher.InvokeAsync(() =>
                        {
                            if (Image3.Opacity > 0)
                            {
                                MyAnimations.AnimateOpacity(Image3, 1.0, 0, 300);
                            }

                            if (Grid3.Opacity < 1.0)
                            {
                                MyAnimations.AnimateOpacity(Grid3, 0, 1.0, 300);
                            }
                        });
                    }
                }
                catch (Exception ex)
                {
                    Dispatcher.InvokeAsync(() =>
                    {
                        LabelLoadError.Content = "Unable to open file: " + ex.Message;

                        MyAnimations.AnimateOpacity(LabelLoadError, 0, 1.0, 300);

                        if (LabelSelectDsdiff.Opacity < 1.0)
                        {
                            MyAnimations.AnimateOpacity(LabelSelectDsdiff, 0, 1.0, 300);
                        }

                        if (Grid2.Opacity > 0)
                        {
                            MyAnimations.AnimateOpacity(Grid2, 1.0, 0, 300);
                        }

                        if (Grid3.Opacity > 0)
                        {
                            MyAnimations.AnimateOpacity(Grid3, 1.0, 0, 300);
                        }

                        if (Image1.Opacity > 0)
                        {
                            MyAnimations.AnimateOpacity(Image1, 1.0, 0, 300);
                        }
                    });
                }
            }, null, true);
        }
Ejemplo n.º 18
0
        private void AddProcessingMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (Grid2.Opacity < 1.0)
            {
                return;
            }
            if (Grid2.IsEnabled == false)
            {
                return;
            }

            var grid = (Grid)sender;

            if (Image2.Opacity < 1.0 && Grid2.Opacity > 0)
            {
                Image2.IsEnabled = true;

                MyAnimations.AnimateRenderScale(grid, 1.0, 0.98,
                                                grid.ActualWidth / 2, grid.ActualHeight / 2, 100, null, null, true);

                MyAnimations.AnimateRenderTranslation(Grid3, TranslateTransform.YProperty,
                                                      -Grid1.ActualHeight - 20, 0, 300, 50);
                MyAnimations.AnimateOpacity(Grid3, 0, 0.7, 100, 50);

                MyAnimations.AnimateOpacity(LabelAddProcessing, 1.0, 0.0, 300);
                MyAnimations.AnimateOpacity(Image2, 0.0, 1.0, 300);
            }
            else
            {
                if (Image2.IsEnabled && (FiltersGraph.GetFiltersCount() < 4 ||
                                         FiltersGraph.SelectedFilter != -1))
                {
                    Image2.IsEnabled = false;

                    var edit = new FilterEdit
                    {
                        ApplyClick  = FilterApplyClick,
                        DeleteClick = FilterDeleteClick
                    };

                    if (FiltersGraph.SelectedFilter != -1)
                    {
                        var filter = FiltersGraph.GetFilterDef(FiltersGraph.SelectedFilter);
                        edit.TypeOfFilter = filter.Item1;
                        edit.FrequencyOne = filter.Item2;
                        edit.FrequencyTwo = filter.Item3;
                        edit.EditMode     = true;
                    }
                    else
                    {
                        edit.TypeOfFilter = _lastFilterType;
                        edit.FrequencyOne = FiltersGraph.MouseFrequency;
                        edit.FrequencyTwo = edit.FrequencyOne + 50;
                        edit.EditMode     = false;
                    }

                    edit.Closed += (o, args) => Image2.IsEnabled = true;
                    MyUtils.ShowCommonDialog(edit, edit.BackGrid, ActualWidth, ActualHeight);
                }
            }
        }
Ejemplo n.º 19
0
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            base.OnMouseDown(e);

            MyAnimations.AnimateRenderScale(this, 1, 0.98, ActualWidth / 2, ActualHeight / 2, 100);
        }
Ejemplo n.º 20
0
 private void Maximize()
 {
     MyAnimations.AnimateOpacity(this, 0.1, 1, 300);
     MyAnimations.AnimateRenderScale(this, 0.1, 1, ActualWidth / 2, ActualHeight / 2, 300);
 }