/* * SetSelected - define the colors of the channels * If the status of the channel is DoNotShow the status will not be change by selecting * or deselecting of the channel * In order that a channel will be released from DoNotShow status one of the processes * has to be repositioned * In the PositionChannel there is a condition that if the processes are not detached * from one another they will get the status of DoNotShow. * If the reposition detach the processes the status will be change to NotSelected or Selected * According to whether the channel is selected in the main window * After this condition the controls will be colored in the following way: * The poligon of the channel will be colored according to the status * If one of the channels are in DoNotShow status the line and label will be colored according to * DoNotShow status * Else if one of the channels are in Selected status the line and the label will be colored * according to Selected color * Else (Both channels are NotSelected) the line and the label will be colored according to * NotSelected color */ /**********************************************************************************************//** * Sets a selected. * * \author Ilan Hindy * \date 29/09/2016 * * \param networkElement The network element. * \param selectedStatus The selected status. * **************************************************************************************************/ public override void SetSelected(NetworkElement networkElement, MainWindow.SelectedStatus selectedStatus) { if (presentationElements[networkElement].status == MainWindow.SelectedStatus.DoNotShow) { selectedStatus = MainWindow.SelectedStatus.DoNotShow; } else { presentationElements[networkElement].status = selectedStatus; } // Set the Arrow Head ((Polygon)presentationElements[networkElement].controls[PresentationElement.ControlKeys.ArrowHead]).Fill = selectedColors[(int)selectedStatus]; // Set the Labels SetLabelColors((BaseChannel)networkElement, selectedStatus); if (presentationElements.Values.Any(pe => pe.status == MainWindow.SelectedStatus.DoNotShow)) { ((Line)additionalControls[AdditionalControlKeys.Line]).Stroke = selectedColors[(int)MainWindow.SelectedStatus.DoNotShow]; SetBorderColors(selectedColors[(int)MainWindow.SelectedStatus.DoNotShow]); } else if (presentationElements.Values.Any(pe => pe.status == MainWindow.SelectedStatus.Selected)) { ((Line)additionalControls[AdditionalControlKeys.Line]).Stroke = selectedColors[(int)MainWindow.SelectedStatus.Selected]; SetBorderColors(selectedColors[(int)MainWindow.SelectedStatus.Selected]); } else //None of the channels is selected { ((Line)additionalControls[AdditionalControlKeys.Line]).Stroke = selectedColors[(int)MainWindow.SelectedStatus.NotSelected]; SetBorderColors(selectedColors[(int)MainWindow.SelectedStatus.NotSelected]); } }
/* * Set network element status * The method determin the satus of the channel * If the circles of the processes are one on top of the other * The status of all the controls will be DoNotShow * If the circles are not one on top of the other the status is determined according * The whether the channel is selected or not in the MainWindow * After the status was determined the SetSelected method is called to * apply the status on the controls */ /**********************************************************************************************//** * Sets channels statuses. * * \author Ilan Hindy * \date 29/09/2016 * * \param desieredStatus The desiered status. * **************************************************************************************************/ private void SetChannelsStatuses(MainWindow.SelectedStatus desieredStatus) { //It is not possible to modify a collection while in foreeach therefor the //Dictionary is copied to a temp one foreach (var presentationElementEntry in presentationElements) { if (desieredStatus == MainWindow.SelectedStatus.DoNotShow) { presentationElementEntry.Value.status = MainWindow.SelectedStatus.DoNotShow; } else { if (presentationElementEntry.Key == mainWindow.SelectedChannel) { presentationElementEntry.Value.status = MainWindow.SelectedStatus.Selected; } else { presentationElementEntry.Value.status = MainWindow.SelectedStatus.NotSelected; } } SetSelected(presentationElementEntry.Key, presentationElementEntry.Value.status); } }
/* * Sete label colors * The method coms to solve the following problem: * If the label should not be shown the background has to be Transperant * Else the background has to be white (Becouse the label is set on the line) */ /**********************************************************************************************//** * Sets label colors. * * \author Ilan Hindy * \date 29/09/2016 * * \param channel The brush. * * \param status The status. **************************************************************************************************/ private void SetLabelColors(BaseChannel channel, MainWindow.SelectedStatus status) { Label label = (Label)presentationElements[channel].controls[PresentationElement.ControlKeys.Label]; if (status == MainWindow.SelectedStatus.DoNotShow) { label.BorderBrush = Brushes.Transparent; label.Background = Brushes.Transparent; label.Foreground = Brushes.Transparent; } else { UpdateLabel(channel, label); } }
/* * Set the sircle status and colors according to if it was selectted or not */ /**********************************************************************************************//** * Sets a selected. * * \author Ilan Hindy * \date 29/09/2016 * * \param networkElement The network element. * \param selectedStatus The selected status. * **************************************************************************************************/ public override void SetSelected(NetworkElement networkElement, MainWindow.SelectedStatus selectedStatus) { presentationElements[networkElement].status = selectedStatus; ((Ellipse)presentationElements[networkElement].controls[PresentationElement.ControlKeys.Circle]).Stroke = selectedColors[(int)selectedStatus]; }
/* * Set the status of the network element and paint the presentation accordinally */ /**********************************************************************************************//** * Sets a selected. * * \author Ilan Hindy * \date 29/09/2016 * * \param element The element. * \param status The status. * **************************************************************************************************/ public virtual void SetSelected(NetworkElement element, MainWindow.SelectedStatus status) { }