void ReleaseDesignerOutlets() { if (LeftImageView != null) { LeftImageView.Dispose(); LeftImageView = null; } if (LeftImageViewWidthConstraint != null) { LeftImageViewWidthConstraint.Dispose(); LeftImageViewWidthConstraint = null; } if (LeftLabel != null) { LeftLabel.Dispose(); LeftLabel = null; } if (NotificaionView != null) { NotificaionView.Dispose(); NotificaionView = null; } }
private double[] GetNeededSizes() { double _neededHeight = 0; double _neededWidth = 0; SizeRequest LeftLabelRequest = LeftLabel.Measure(double.PositiveInfinity, double.PositiveInfinity, MeasureFlags.IncludeMargins); SizeRequest RightLabelRequest = RightLabel.Measure(double.PositiveInfinity, double.PositiveInfinity, MeasureFlags.IncludeMargins); _neededWidth += LeftLabelRequest.Request.Width + 24; _neededHeight = Math.Max(_neededHeight, LeftLabelRequest.Request.Height); _neededWidth += RightLabelRequest.Request.Width + 24; _neededHeight = Math.Max(_neededHeight, RightLabelRequest.Request.Height) + 8; return(new double[] { _neededWidth, _neededHeight }); }
public Panel CreateLeftTextBubble(string text, string userName) { RichTextBox Body = new RichTextBox() { Name = DateTime.Now.ToString("HHmmssfff"), Size = new Size(278, 81), Location = new Point(20, 10), BorderStyle = BorderStyle.None, ScrollBars = RichTextBoxScrollBars.None, WordWrap = true, ReadOnly = true, BackColor = Color.White, ForeColor = Color.Black, Font = new Font("Tahoma", 12, FontStyle.Regular), Text = text }; LeftLabel Info = new LeftLabel() { BackColor = Color.Transparent, Location = new Point(195, 98), ForeColor = Theme.GetForeColor(), Anchor = AnchorStyles.Bottom, Text = DateTime.Now.ToString("HH:mm") }; Panel BodyPanel = new Panel() { Name = "TextBox" + Body.Name, Size = new Size(839, 485), //Margin = new Padding(70, 0, 0, 0), BackColor = Theme.GetBackColor() }; Body.ContentsResized += (sender, e) => Body_ContentsResized(sender, e, Body, BodyPanel); BodyPanel.Controls.Add(Body); BodyPanel.Controls.Add(Info); return(BodyPanel); }
private void Update() { if (!IsChartInitialized) { return; } Func <double, string> defFormatter = x => x.ToString(CultureInfo.InvariantCulture); var completed = (Value - From) / (To - From); var t = 0d; if (double.IsNaN(completed) || double.IsInfinity(completed)) { completed = 0; } completed = completed > 1 ? 1 : (completed < 0 ? 0 : completed); var angle = Uses360Mode ? 360 : 180; if (!_isCallBack && Uses360Mode) { Grid.SetRow(Min, 0); Grid.SetRow(Max, 0); Grid.SetRow(LeftLabel, 1); Grid.SetRow(RightLabel, 1); //LeftLabel.UpdateLayout(); //RightLabel.UpdateLayout(); GridLeft.Children.Remove(GridLeftBoarder); GridLeftBoarder = new Border { BorderThickness = new Thickness(1, 0, 0, 0), BorderBrush = _titleColor }; GridLeft.Children.Add(GridLeftBoarder); Grid.SetRow(GridLeftBoarder, 1); GridRight.Children.Remove(GridRightBoarder); Panel.SetZIndex(GridLeftBoarder, 1); Canvas.SetLeft(GridLeftBoarder, ActualWidth / 2); _isCallBack = true; } if (!Uses360Mode) { LeftLabel.Text = (LabelFormatter ?? defFormatter)(From); RightLabel.Text = (LabelFormatter ?? defFormatter)(To); LeftLabel.UpdateLayout(); RightLabel.UpdateLayout(); //LeftLabel.Visibility = LabelsVisibility; GridLeft.Visibility = LabelsVisibility; //RightLabel.Visibility = LabelsVisibility; GridRight.Visibility = LabelsVisibility; t = LeftLabel.ActualHeight; if (Icon != null) { Icon.Visibility = Visibility.Hidden; } } else { LeftLabel.Text = (LabelFormatter ?? defFormatter)(From); RightLabel.Text = (LabelFormatter ?? defFormatter)(To); LeftLabel.UpdateLayout(); RightLabel.UpdateLayout(); GridLeft.Visibility = LabelsVisibility; GridRight.Visibility = LabelsVisibility; //LeftLabel.Visibility = Visibility.Hidden; //RightLabel.Visibility = Visibility.Hidden; // t = GridLeft.ActualHeight; if (Icon != null) { Icon.Visibility = Visibility.Visible; } } double r, top; if (Uses360Mode) { //r = ActualWidth > ActualHeight ? ActualHeight : ActualWidth; //r = r / 2 - t; //r / 2 - 2 * t; r = ActualWidth > ActualHeight ? ActualHeight / 2 - t : ActualWidth / 2; top = ActualHeight / 2; } else { r = ActualWidth; if (ActualWidth > ActualHeight * 2) { r = ActualHeight * 2; } else { t = 0; } //r = r / 2 - 2 * t; r = r / 2; top = ActualHeight / 2 + r / 2; } if (r < 0) { r = 1; } PieBack.Radius = r; PieBack.InnerRadius = InnerRadius ?? r * .8; PieBack.RotationAngle = 270; PieBack.WedgeAngle = angle; Pie.Radius = PieBack.Radius * 0.96; Pie.InnerRadius = PieBack.InnerRadius * 1.06; Pie.RotationAngle = PieBack.RotationAngle; Canvas.SetLeft(PieBack, ActualWidth / 2); Canvas.SetTop(PieBack, top); Canvas.SetLeft(Pie, ActualWidth / 2); Canvas.SetTop(Pie, top); //Canvas.SetTop(LeftLabel, top); //Canvas.SetTop(RightLabel, top); //Canvas.SetRight(LeftLabel, ActualWidth / 2 + ( r + PieBack.InnerRadius ) / 2 - LeftLabel.ActualWidth / 2); //Canvas.SetRight(RightLabel, ActualWidth / 2 - ( r + PieBack.InnerRadius ) / 2 - RightLabel.ActualWidth / 2); MeasureTextBlock.FontSize = HighFontSize ?? Pie.InnerRadius * .4; if (Uses360Mode) { MeasureTextBlock.FontSize = Pie.InnerRadius * .6; } MeasureTextBlock.Text = (LabelFormatter ?? defFormatter)(Value); if (FontColor != null) { MeasureTextBlock.Foreground = FontColor; } MeasureTextBlock.UpdateLayout(); double ratio = Uses360Mode ? .3 : .4; MeasureTextBlockUnit.Text = (Uses360Mode ? "" : " ") + GaugeUnit; MeasureTextBlockUnit.FontSize = MeasureTextBlock.FontSize * ratio; MeasureTextBlockUnit.UpdateLayout(); Title.Text = GaugeTitle; Title.FontSize = MeasureTextBlock.FontSize * ratio; Title.UpdateLayout(); //LeftLabel.FontSize = MeasureTextBlock.FontSize * ratio; //RightLabel.FontSize = MeasureTextBlock.FontSize * ratio; //LeftLabel.UpdateLayout(); //RightLabel.UpdateLayout(); if (Uses360Mode) { double top360 = top - r - GridLeft.ActualHeight; //top - Gridleft.ActualHeight + ( r + PieBack.InnerRadius ) / 2; Canvas.SetTop(GridLeft, top360); Canvas.SetTop(GridRight, top360); Canvas.SetLeft(GridRight, (ActualWidth / 2) - GridRight.ActualWidth); Canvas.SetLeft(GridLeft, ActualWidth / 2); if (IconSource != null) { if (Icon == null) { Icon = new Image { Source = IconSource }; Icon.UpdateLayout(); Canvas.Children.Add(Icon); } Icon.Width = Icon.Height = Pie.InnerRadius * .5; Canvas.SetTop(Icon, top - PieBack.InnerRadius * 0.9); Canvas.SetLeft(Icon, (ActualWidth - Icon.Width) / 2); Icon.UpdateLayout(); } } else { LeftLabel.FontSize = Min.FontSize = MeasureTextBlock.FontSize * ratio * 0.6; Min.UpdateLayout(); LeftLabel.UpdateLayout(); Canvas.SetTop(GridLeft, top - GridLeft.ActualHeight); Canvas.SetLeft(GridLeft, ActualWidth / 2 - PieBack.InnerRadius); RightLabel.FontSize = Max.FontSize = MeasureTextBlock.FontSize * ratio * 0.6; Max.UpdateLayout(); RightLabel.UpdateLayout(); Canvas.SetTop(GridRight, top - GridRight.ActualHeight); Canvas.SetLeft(GridRight, ActualWidth / 2 + PieBack.InnerRadius - GridRight.ActualWidth); } GridLeft.UpdateLayout(); GridRight.UpdateLayout(); //August Lee if (Uses360Mode) { Canvas.SetTop(MeasureTextBlock, top - MeasureTextBlock.ActualHeight * .5); Canvas.SetLeft(MeasureTextBlock, ActualWidth / 2 - MeasureTextBlock.ActualWidth / 2); Canvas.SetTop(MeasureTextBlockUnit, top + (MeasureTextBlock.ActualHeight) * .5); Canvas.SetLeft(MeasureTextBlockUnit, ActualWidth / 2 - MeasureTextBlockUnit.ActualWidth / 2); Canvas.SetTop(Title, top + Title.ActualHeight + MeasureTextBlock.ActualHeight / 2); Canvas.SetLeft(Title, ActualWidth / 2 - Title.ActualWidth / 2); } else { Canvas.SetTop(MeasureTextBlock, top - (MeasureTextBlock.ActualHeight * 1.5)); Canvas.SetLeft(MeasureTextBlock, ActualWidth / 2 - MeasureTextBlock.ActualWidth / 2 - MeasureTextBlockUnit.ActualWidth / 2); Canvas.SetTop(MeasureTextBlockUnit, top - (MeasureTextBlock.ActualHeight * 0.5 + MeasureTextBlockUnit.ActualHeight * 1.2)); Canvas.SetLeft(MeasureTextBlockUnit, ActualWidth / 2 + MeasureTextBlock.ActualWidth / 2 - MeasureTextBlockUnit.ActualWidth / 2); Canvas.SetTop(Title, top - Title.ActualHeight); Canvas.SetLeft(Title, ActualWidth / 2 - Title.ActualWidth / 2); } var interpolatedColor = new Color { R = LinearInterpolation(FromColor.R, ToColor.R), G = LinearInterpolation(FromColor.G, ToColor.G), B = LinearInterpolation(FromColor.B, ToColor.B), A = LinearInterpolation(FromColor.A, ToColor.A) }; if (IsNew) { Pie.Fill = new SolidColorBrush(FromColor); Pie.WedgeAngle = 0; } if (DisableAnimations) { Pie.WedgeAngle = completed * angle; } else { Pie.BeginAnimation(PieSlice.WedgeAngleProperty, new DoubleAnimation(completed * angle, AnimationsSpeed)); } if (GaugeActiveFill == null) { ((SolidColorBrush)Pie.Fill).BeginAnimation(SolidColorBrush.ColorProperty, new ColorAnimation(interpolatedColor, AnimationsSpeed)); } else { Pie.Fill = GaugeActiveFill; } IsNew = false; }
private void Update() { if (!IsChartInitialized) { return; } Func <double, string> defFormatter = x => x.ToString(CultureInfo.InvariantCulture); var completed = (Value - From) / (To - From); var t = 0d; if (double.IsNaN(completed) || double.IsInfinity(completed)) { completed = 0; } completed = completed > 1 ? 1 : (completed < 0 ? 0 : completed); var angle = Uses360Mode ? 360 : 180; if (!Uses360Mode) { LeftLabel.Text = (LabelFormatter ?? defFormatter)(From); RightLabel.Text = (LabelFormatter ?? defFormatter)(To); LeftLabel.UpdateLayout(); RightLabel.UpdateLayout(); LeftLabel.Visibility = LabelsVisibility; RightLabel.Visibility = LabelsVisibility; t = LeftLabel.ActualHeight; } else { LeftLabel.Visibility = Visibility.Hidden; RightLabel.Visibility = Visibility.Hidden; } double r, top; if (Uses360Mode) { r = ActualWidth > ActualHeight ? ActualHeight : ActualWidth; r = r / 2 - 2 * t; top = ActualHeight / 2; } else { r = ActualWidth; if (ActualWidth > ActualHeight * 2) { r = ActualHeight * 2; } else { t = 0; } r = r / 2 - 2 * t; top = ActualHeight / 2 + r / 2; } if (r < 0) { r = 1; } PieBack.Radius = r; PieBack.InnerRadius = InnerRadius ?? r * .6; PieBack.RotationAngle = 270; PieBack.WedgeAngle = angle; Pie.Radius = PieBack.Radius; Pie.InnerRadius = PieBack.InnerRadius; Pie.RotationAngle = PieBack.RotationAngle; Canvas.SetLeft(PieBack, ActualWidth / 2); Canvas.SetTop(PieBack, top); Canvas.SetLeft(Pie, ActualWidth / 2); Canvas.SetTop(Pie, top); Canvas.SetTop(LeftLabel, top); Canvas.SetTop(RightLabel, top); Canvas.SetRight(LeftLabel, ActualWidth / 2 + (r + PieBack.InnerRadius) / 2 - LeftLabel.ActualWidth / 2); Canvas.SetRight(RightLabel, ActualWidth / 2 - (r + PieBack.InnerRadius) / 2 - RightLabel.ActualWidth / 2); MeasureTextBlock.FontSize = HighFontSize ?? Pie.InnerRadius * .4; MeasureTextBlock.Text = (LabelFormatter ?? defFormatter)(Value); MeasureTextBlock.UpdateLayout(); Canvas.SetTop(MeasureTextBlock, top - MeasureTextBlock.ActualHeight * (Uses360Mode ? .5 : 1)); Canvas.SetLeft(MeasureTextBlock, ActualWidth / 2 - MeasureTextBlock.ActualWidth / 2); var interpolatedColor = new Color { R = LinearInterpolation(FromColor.R, ToColor.R), G = LinearInterpolation(FromColor.G, ToColor.G), B = LinearInterpolation(FromColor.B, ToColor.B), A = LinearInterpolation(FromColor.A, ToColor.A) }; if (IsNew) { Pie.Fill = new SolidColorBrush(FromColor); Pie.WedgeAngle = 0; } if (DisableAnimations) { Pie.WedgeAngle = completed * angle; } else { Pie.BeginAnimation(PieSlice.WedgeAngleProperty, new DoubleAnimation(completed * angle, AnimationsSpeed)); } if (GaugeActiveFill == null) { ((SolidColorBrush)Pie.Fill).BeginAnimation(SolidColorBrush.ColorProperty, new ColorAnimation(interpolatedColor, AnimationsSpeed)); } else { Pie.Fill = GaugeActiveFill; } IsNew = false; }
private void Update() { if (!IsChartInitialized) { return; } var ms = new Size(double.PositiveInfinity, double.PositiveInfinity); Measure(ms); Canvas.Width = Width; Canvas.Height = Height; Func <double, string> defFormatter = x => x.ToString(CultureInfo.InvariantCulture); var completed = (Value - From) / (To - From); var t = 0d; if (double.IsNaN(completed) || double.IsInfinity(completed)) { completed = 0; } completed = completed > 1 ? 1 : (completed < 0 ? 0 : completed); var angle = Uses360Mode ? 360 : 180; if (!Uses360Mode) { LeftLabel.Text = (LabelFormatter ?? defFormatter)(From); RightLabel.Text = (LabelFormatter ?? defFormatter)(To); LeftLabel.Visibility = LabelsVisibility; RightLabel.Visibility = LabelsVisibility; t = LeftLabel.ActualHeight; } else { LeftLabel.Visibility = Visibility.Collapsed; RightLabel.Visibility = Visibility.Collapsed; } double r, top; if (Uses360Mode) { r = ActualWidth > ActualHeight ? ActualHeight: ActualWidth; r = r / 2 - 2 * t; top = ActualHeight / 2; } else { r = ActualWidth; if (ActualWidth > ActualHeight * 2) { r = ActualHeight * 2; } else { t = 0; } r = r / 2 - 2 * t; top = ActualHeight / 2 + r / 2; } if (r < 0) { r = 1; } PieBack.Height = Canvas.ActualHeight; PieBack.Width = Canvas.ActualWidth; Pie.Height = Canvas.ActualHeight; Pie.Width = Canvas.ActualWidth; PieBack.Radius = r; PieBack.InnerRadius = double.IsNaN(InnerRadius) ? r * .6 : InnerRadius; PieBack.RotationAngle = 270; PieBack.WedgeAngle = angle; Pie.Radius = PieBack.Radius; Pie.InnerRadius = PieBack.InnerRadius; Pie.RotationAngle = PieBack.RotationAngle; Pie.YOffset = top - ActualHeight / 2; PieBack.YOffset = top - ActualHeight / 2; Canvas.SetTop(LeftLabel, top); Canvas.SetTop(RightLabel, top); LeftLabel.Measure(ms); RightLabel.Measure(ms); Canvas.SetLeft(LeftLabel, Canvas.ActualWidth * .5 - (Pie.InnerRadius + (Pie.Radius - Pie.InnerRadius) * .5 + LeftLabel.DesiredSize.Width * .5)); Canvas.SetLeft(RightLabel, Canvas.ActualWidth * .5 + (Pie.InnerRadius + (Pie.Radius - Pie.InnerRadius) * .5 - RightLabel.DesiredSize.Width * .5)); MeasureTextBlock.FontSize = double.IsNaN(HighFontSize) ? Pie.InnerRadius * .4 : HighFontSize; MeasureTextBlock.Text = (LabelFormatter ?? defFormatter)(Value); MeasureTextBlock.Measure(ms); Canvas.SetTop(MeasureTextBlock, top - MeasureTextBlock.DesiredSize.Height * (Uses360Mode ? .5 : 1)); Canvas.SetLeft(MeasureTextBlock, ActualWidth / 2 - MeasureTextBlock.DesiredSize.Width / 2); var interpolatedColor = new Color { R = LinearInterpolation(FromColor.R, ToColor.R), G = LinearInterpolation(FromColor.G, ToColor.G), B = LinearInterpolation(FromColor.B, ToColor.B), A = LinearInterpolation(FromColor.A, ToColor.A) }; if (IsNew) { Pie.Fill = new SolidColorBrush(FromColor); Pie.WedgeAngle = 0; } Pie.BeginDoubleAnimation(nameof(PieSlice.WedgeAngle), completed * angle, AnimationsSpeed); if (GaugeActiveFill == null) { ((SolidColorBrush)Pie.Fill).BeginColorAnimation(nameof(SolidColorBrush.Color), interpolatedColor, AnimationsSpeed); } else { Pie.Fill = GaugeActiveFill; } IsNew = false; }
public Panel CreateLeftAudioBubble(string text, string userName) { Panel BodyPanel = new Panel() { Size = new Size(839, 130),//Original 729, 168 Margin = new Padding(0, 0, 0, 0), AutoSizeMode = AutoSizeMode.GrowAndShrink, BackColor = Theme.GetBackColor() }; RoundPanel AudioPanel = new RoundPanel() { Name = AudioFile, BackColor = Color.White, Size = new Size(253, 81), Location = new Point(20, 15) }; AudioPanel.Region = System.Drawing.Region.FromHrgn(GDI.CreateRoundRectRgn(0, 0, AudioPanel.Width, AudioPanel.Height, 20, 20)); LeftLabel Info = new LeftLabel() { BackColor = Color.Transparent, Location = new Point(195, 98), ForeColor = Theme.GetForeColor(), Anchor = AnchorStyles.Bottom, Text = DateTime.Now.ToString("HH:mm") }; Label TimeInfo = new Label() { BackColor = Color.Transparent, Location = new Point(166, 53), ForeColor = Color.Black, Text = string.Empty }; RoundButton ButtonPic = new RoundButton() { Size = new Size(64, 62), Location = new Point(8, 10), FlatStyle = FlatStyle.Flat, BackColor = Theme.GetForeColor(), BackgroundImage = Properties.Resources.play2, BackgroundImageLayout = ImageLayout.Stretch, }; ButtonPic.FlatAppearance.BorderSize = 0; TrackBar ElapsedBar = new TrackBar() { Size = new Size(169, 45), Location = new Point(75, 31), TickStyle = TickStyle.None }; ButtonPic.Click += (sender, e) => Chat.ButtonPic_Click(sender, e, ButtonPic, AudioPanel.Name, ElapsedBar); FileStream ms = File.OpenRead(AudioFile); var rdr = new WaveFileReader(ms); var ts = new TimeSpan(); ts = rdr.TotalTime; ElapsedBar.Maximum = (int)ts.TotalSeconds * 100; string time = rdr.TotalTime.ToString(); time = time.Remove(time.LastIndexOf('.'), 8); TimeInfo.Text = time; ms.Dispose(); rdr.Dispose(); AudioPanel.Controls.Add(TimeInfo); AudioPanel.Controls.Add(ButtonPic); AudioPanel.Controls.Add(ElapsedBar); BodyPanel.Controls.Add(Info); BodyPanel.Controls.Add(AudioPanel); return(BodyPanel); }