//Resizing the chart dependend on the new format of the control
        private async Task ResizeChart()
        {
            CommandHelper ch = new CommandHelper();

            await ch.RunBackgroundWorkerWithFlagHelperAsync(() => IsDrawing, async() =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    //Filtering data based on the selection
                    try
                    {
                        drawingBackground.Visibility = Visibility.Visible;
                        chartCanvas.Children.Clear();

                        textCanvas.Children.RemoveRange(1, textCanvas.Children.Count - 1);

                        if (LogDataCollection != null)
                        {
                            bcs.AddSectionChartStyle(LogDataCollection.Count);
                        }
                        else
                        {
                            bcs.AddSectionChartStyle(0);
                        }


                        if (SectionDataCollection != null)
                        {
                            if (SectionDataCollection.Count > 0)
                            {
                                bcs.SetBars(SectionDataCollection);
                                bcs.SetBarsControl();
                                if (IsLegend)
                                {
                                    lg.AddLegend(chartCanvas, SectionDataCollection);
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        drawingBackground.Visibility = Visibility.Hidden;
                    }
                });
            });
        }
        private async Task ResizeChart()
        {
            CommandHelper ch = new CommandHelper();

            await ch.RunBackgroundWorkerWithFlagHelperAsync(() => IsDrawing, async() =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    //Filtering data based on the selection
                    try
                    {
                        chartCanvas.Children.Clear();
                        textCanvas.Children.RemoveRange(1, textCanvas.Children.Count - 1);
                        cs.AddChartStyle();

                        if (DataCollection != null)
                        {
                            if (DataCollection.Count > 0)
                            {
                                cs.SetLinesControl(new BindableCollection <LineSeries>(DataCollection));

                                if (!IsBubbleChart)
                                {
                                    lg.AddLegend(chartCanvas, new BindableCollection <LineSeries>(DataCollection));
                                }
                                else
                                {
                                    lg.AddLegend(chartCanvas, Unit);
                                    lg.AddColorBar(textCanvas, ColorMap);
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                    }
                });
            });
        }
Esempio n. 3
0
        private async Task ResizeChart()
        {
            CommandHelper ch = new CommandHelper();

            await ch.RunBackgroundWorkerWithFlagHelperAsync(() => IsDrawing, async() =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    //Filtering data based on the selection
                    try
                    {
                        drawingBackground.Visibility = Visibility.Visible;

                        chartCanvas.Children.Clear();
                        textCanvas.Children.RemoveRange(1, textCanvas.Children.Count - 1);
                        cs.AddTernaryChartStyle();

                        if (DataCollection != null)
                        {
                            if (DataCollection.Count > 0)
                            {
                                cs.SetLinesControl(new BindableCollection <LineSeries>(DataCollection));

                                lg.AddLegend(chartCanvas, new BindableCollection <LineSeries>(DataCollection));
                            }
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        drawingBackground.Visibility = Visibility.Hidden;
                    }
                });
            });
        }
        //Resizing the chart dependent on the new format of the control
        private async Task ResizeChart()
        {
            CommandHelper ch = new CommandHelper();

            await ch.RunBackgroundWorkerWithFlagHelperAsync(() => IsDrawing, async() =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    //Filtering data based on the selection
                    try
                    {
                        chartCanvas.Children.Clear();

                        textCanvas.Children.RemoveRange(1, textCanvas.Children.Count - 1);

                        bcs.AddChartStyle();

                        if (DataCollection != null)
                        {
                            if (DataCollection.Count > 0)
                            {
                                bcs.SetBoxPlots(DataCollection);
                                bcs.SetBoxPlotControl();
                                lg.AddLegend(chartCanvas, DataCollection);
                            }
                        }
                    }
                    catch
                    {
                        return;
                    }
                    finally
                    {
                    }
                });
            });
        }
        /// <summary>
        /// Attempts to log the user in
        /// </summary>
        /// <param name="parameter">The SecureString passed in from the view for the users password</param>
        /// <returns></returns>
        public async void Login(PasswordBox parameter)
        {
            CommandHelper ch = new CommandHelper();

            await ch.RunBackgroundWorkerWithFlagHelperAsync(() => IsLoginRunning, async() =>
            {
                try
                {
                    //var pwBox = (PasswordBox)parameter;
                    string username = this.Email ?? "";

                    using (var db = new ApirsDatabase())
                    {
                        var paramLoginName = new SqlParameter
                        {
                            ParameterName = "pLoginName",
                            Value         = username,
                            Direction     = ParameterDirection.Input
                        };

                        var paramPass = new SqlParameter
                        {
                            ParameterName = "pPassword",
                            Value         = parameter.Password,
                            Direction     = ParameterDirection.Input
                        };

                        var paramResponse = new SqlParameter
                        {
                            ParameterName = "responseMessage",
                            Size          = 250,
                            SqlDbType     = SqlDbType.NVarChar,
                            Direction     = ParameterDirection.Output
                        };


                        string par = db.Database.SqlQuery <string>("exec dbo.spUserLogin @pLoginName, @pPassword, @responseMessage", paramLoginName, paramPass, paramResponse).First();

                        //Forward the user to the home view or denying the login based on the response of the server
                        switch (par)
                        {
                        case "Invalid login":
                        case "Incorrect password":
                            _events.PublishOnUIThreadAsync(new MessageBoxMessage("Wrong password. Please try it again", "", MessageBoxViewType.Information, MessageBoxViewButton.Ok));
                            break;

                        case "User successfully logged in":
                            //Get the actual user id and set it as a property in the shellview
                            tblPerson result = (from p in db.tblPersons
                                                where p.persUserName == username.ToString()
                                                select p).First();
                            _events.PublishOnUIThreadAsync(new ChangeUserMessage(Convert.ToInt32(result.persIdPk), result.persFullName));
                            //Changing the viewmodel to the homeview
                            _events.PublishOnUIThreadAsync(new ChangeViewModelMessage("HomeView"));
                            break;

                        default:
                            break;
                        }
                    }

                    return;
                }
                catch (Exception e)
                {
                    _events.PublishOnUIThreadAsync(new MessageBoxMessage(UserMessageValueConverter.ConvertBack(1), "", MessageBoxViewType.Error, MessageBoxViewButton.Ok));
                }
            });
        }
        private async Task ResizeChart()
        {
            cts = new CancellationTokenSource();
            var token = cts.Token;

            CommandHelper ch = new CommandHelper();

            await ch.RunBackgroundWorkerWithFlagHelperAsync(() => IsDrawing, async() =>
            {
                //Filtering data based on the selection
                try
                {
                    await this.Dispatcher.InvokeAsync(async() =>
                    {
                        int count = 0;

                        count = chartCanvas.Children.Count;

                        chartCanvas.Children.RemoveRange(0, chartCanvas.Children.Count);

                        cs.SetChartStyle();

                        var dc = new BindableCollection <LineSeries3D>(DataCollection);

                        if (dc != null)
                        {
                            if (dc.Count > 0)
                            {
                                symbols.Clear();
                                ColormapBrush cm = new ColormapBrush(ColorMap);

                                for (int i = 0; i < dc.Count; i++)
                                {
                                    try
                                    {
                                        var symbolCollection = await cs.AddLine3D(dc[i], cm, token).ConfigureAwait(false);
                                        symbols.AddRange(symbolCollection);
                                    }
                                    catch
                                    {
                                    }
                                }

                                foreach (UIElement x in symbols)
                                {
                                    if (!cts.IsCancellationRequested)
                                    {
                                        try
                                        {
                                            await Task.Delay(1);
                                            this.Dispatcher.Invoke(() => chartCanvas.Children.Add(x));
                                        }
                                        catch
                                        {
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        symbols.Clear();
                                        break;
                                    }
                                }

                                this.Dispatcher.Invoke(() =>
                                {
                                    if (IsBubble)
                                    {
                                        lg.AddColorBar(chartCanvas, cm);
                                    }
                                });
                            }
                        }
                    });
                }
                catch
                {
                }
                finally
                {
                }
            });
        }