/* * Move the textBlock after the moving of the circle */ /**********************************************************************************************//** * Move text block in circle. * * \author Ilan Hindy * \date 29/09/2016 * * \param presentationElement The presentation element. * **************************************************************************************************/ private void MoveTextBlockInCircle(PresentationElement presentationElement) { Ellipse circle = (Ellipse)presentationElement.controls[PresentationElement.ControlKeys.Circle]; TextBlock textBlock = (TextBlock)presentationElement.controls[PresentationElement.ControlKeys.TextBlock]; double top = circle.Margin.Top; double left = circle.Margin.Left; double textBlockTop = top + circle.Height / 2 - textBlock.Height / 2 + 2; double textBlockLeft = left + circle.Width / 2 - textBlock.Width / 2 + 2; textBlock.Margin = new Thickness(textBlockLeft, textBlockTop, 0, 0); }
/* * Set the textBlock dimentions */ /**********************************************************************************************//** * Sets text block dimentions. * * \author Ilan Hindy * \date 29/09/2016 * * \param presentationElement The presentation element. * **************************************************************************************************/ private void SetTextBlockDimentions(PresentationElement presentationElement) { Ellipse circle = (Ellipse)presentationElement.controls[PresentationElement.ControlKeys.Circle]; TextBlock textBlock = (TextBlock)presentationElement.controls[PresentationElement.ControlKeys.TextBlock]; Double a = circle.Width / 2; Double b = circle.Height / 2; Double PI = 3.1415926; textBlock.Width = 2 * a * Math.Cos(45 * PI / 180) - 4; textBlock.Height = 2 * b * Math.Sin(45 * PI / 180) - 4; }
/* * Constructor */ /**********************************************************************************************//** * Constructor. * * \author Ilan Hindy * \date 29/09/2016 * * \param canvas The canvas. * \param process The process. * \param mainWindow The main window. * **************************************************************************************************/ public ProcessPresentation(Canvas canvas, BaseProcess process, MainWindow mainWindow) : base(mainWindow, canvas) { Ellipse circle; PresentationElement presentationElement = new PresentationElement(); presentationElement.controls.Add(PresentationElement.ControlKeys.Circle, circle = CreateCircle(process)); presentationElement.controls.Add(PresentationElement.ControlKeys.TextBlock, CreateTextBlock(process)); presentationElement.controls.Add(PresentationElement.ControlKeys.BreakpointLabel, CreateInvisibleLabel()); presentationElement.status = MainWindow.SelectedStatus.Selected; presentationElement.blinkingStoryBoard = CreateBlinkingStoryBoard(circle); SetTextBlockDimentions(presentationElement); MoveTextBlockInCircle(presentationElement); presentationElements.Add(process, presentationElement); SetBlinkingForAllProcesses(); }
/* * Add a channel to a presentation that contains one channel */ /**********************************************************************************************//** * Adds a channel to 'positionChannel'. * * \author Ilan Hindy * \date 29/09/2016 * * \param channel The channel. * \param positionChannel (Optional) True to position channel. * **************************************************************************************************/ public void AddChannel(BaseChannel channel, bool positionChannel = true) { PresentationElement presentationElement = new PresentationElement(); presentationElement.status = MainWindow.SelectedStatus.NotSelected; presentationElement.controls.Add(PresentationElement.ControlKeys.ArrowHead, CreatePolygon()); //presentationElement.controls.Add(PresentationElement.ControlKeys.MessageQ, CreateInvisibleLabel()); presentationElement.controls.Add(PresentationElement.ControlKeys.MessagesGridView, CreateMessagesGridView(channel.ea[bc.eak.SourceProcess])); presentationElement.controls.Add(PresentationElement.ControlKeys.Label, CreatePresentationLabel(channel)); ((StackPanel)additionalControls[AdditionalControlKeys.LabelsPanel]).Children.Add(presentationElement.controls[PresentationElement.ControlKeys.Label]); presentationElements.Add(channel, presentationElement); if (positionChannel) { PositionChannel(); } }
/**********************************************************************************************//** * Updates the presentation shape parameters described by process. * * \author Ilan Hindy * \date 16/01/2017 * * \param process The process. **************************************************************************************************/ private void UpdatePresentationShapeParameters(BaseProcess process, bool moveChannels = true) { PresentationElement presentationElement = presentationElements[process]; ((Ellipse)presentationElement.controls[PresentationElement.ControlKeys.Circle]).Width = process.pp[bp.ppk.FrameWidth]; ((Ellipse)presentationElement.controls[PresentationElement.ControlKeys.Circle]).Height = process.pp[bp.ppk.FrameHeight]; ((Ellipse)presentationElement.controls[PresentationElement.ControlKeys.Circle]).Margin = new Thickness(process.pp[bp.ppk.FrameLeft], process.pp[bp.ppk.FrameTop], 0, 0); ((Ellipse)presentationElement.controls[PresentationElement.ControlKeys.Circle]).Fill = new SolidColorBrush(CreateColorFromEnum(process.pp[bp.ppk.Background])); ((Ellipse)presentationElement.controls[PresentationElement.ControlKeys.Circle]).StrokeThickness = process.pp[bp.ppk.FrameLineWidth]; ((TextBlock)presentationElement.controls[PresentationElement.ControlKeys.TextBlock]).Text = process.pp[bp.ppk.Text]; ((TextBlock)presentationElement.controls[PresentationElement.ControlKeys.TextBlock]).Background = new SolidColorBrush(CreateColorFromEnum(process.pp[bp.ppk.Background])); ((TextBlock)presentationElement.controls[PresentationElement.ControlKeys.TextBlock]).Foreground = new SolidColorBrush(CreateColorFromEnum(process.pp[bp.ppk.Foreground])); SetTextBlockDimentions(presentationElement); MoveTextBlockInCircle(presentationElement); if (moveChannels) { MoveChannels(process); } SetBlinkingForAllProcesses(); }
/**********************************************************************************************//** * Event handler. Called by Circle for mouse enter events. * * \author Ilan Hindy * \date 29/09/2016 * * \param sender Source of the event. * \param e Mouse event information. * **************************************************************************************************/ /**********************************************************************************************//** * Updates the debug data dock pannel. * * \author Ilan Hindy * \date 29/09/2016 * * \param mouseLocation The mouse location. * \param process The process. * \param presentationElement The presentation element. * \param remove true to remove. * **************************************************************************************************/ private void UpdateDebugDataDockPannel(Point mouseLocation, BaseProcess process, PresentationElement presentationElement, bool remove) { Ellipse circle = (Ellipse)presentationElement.controls[PresentationElement.ControlKeys.Circle]; double circleCenretX = circle.Margin.Left + circle.Width / 2; double circleCenterY = circle.Margin.Top + circle.Height / 2; presentationElement.debugWindow = new ElementDebugWindow(new List <NetworkElement>() { process }); presentationElement.debugWindow.Show(); }