Changeset 8653


Ignore:
Timestamp:
Feb 21, 2020, 4:29:38 PM (2 years ago)
Author:
Sven Rech
Message:

Primes tutorial: "Amount of primes" page: Show info texts as "normal" selectable text.

Location:
trunk/CrypPlugins/Primes/Primes/WpfControls/PrimesDistribution/Graph
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/Primes/Primes/WpfControls/PrimesDistribution/Graph/GraphControl.xaml

    r8648 r8653  
    5353                            <Image Cursor="Hand" Source="../../../Resources/icons/help.png" Width="16" Height="16" Grid.Row="0" Grid.Column="4" Name="btnHelpPiGauss" HorizontalAlignment="Left" MouseLeftButtonDown="btnHelpFunctionTypeClick" />
    5454                            <DockPanel Grid.Row="0" Grid.Column="5" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="10,0,0,0" Name="dpGauss">
    55                                 <DockPanel.ContextMenu>
    56                                     <ContextMenu Opened="ctxMenu_Opened" Closed="ctxMenu_Closed" Name="ctxMenuDpGauss">
    57                                         <MenuItem Header="{x:Static lang:Distribution.graph_contextmenucopy}" Name="miCopyGauss" Click="miCopy_Click" />
    58                                     </ContextMenu>
    59                                 </DockPanel.ContextMenu>
    60                                 <comps:SelectableTextBlock x:Name="lblCalcInfoPiGauss" Visibility="Collapsed" MouseEnter="lblInfo_MouseEnter" MouseLeave="lblInfo_MouseLeave" Text="{x:Static lang:Distribution.graph_gausscountinfo}"></comps:SelectableTextBlock>
    61                                 <comps:SelectableTextBlock x:Name="tbInfoGaußPrimeTheorem" Margin="3,0,0,0" MouseEnter="lblInfo_MouseEnter" MouseLeave="lblInfo_MouseLeave" />
     55                                <comps:SelectableTextBlock x:Name="lblCalcInfoPiGaussTextBlock" Visibility="Collapsed">
     56                                    <Run x:Name="lblCalcInfoPiGauss" Text="{x:Static lang:Distribution.graph_gausscountinfo}" />
     57                                    <Run x:Name="tbInfoGaußPrimeTheorem" />
     58                                </comps:SelectableTextBlock>
    6259                            </DockPanel>
    6360                            <Line X1="0" X2="10" Y1="0" Y2="0" Stroke="Green" StrokeThickness="3" Grid.Row="1" VerticalAlignment="Center" />
     
    6764                            <Image Cursor="Hand" Source="../../../Resources/icons/help.png" Width="16" Height="16" Name="btnHelpLiN" Grid.Row="1" Grid.Column="4" HorizontalAlignment="Left" MouseLeftButtonDown="btnHelpFunctionTypeClick" />
    6865                            <DockPanel Grid.Row="1" Grid.Column="5" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="10,0,0,0" Name="dpLin">
    69                                 <DockPanel.ContextMenu>
    70                                     <ContextMenu Opened="ctxMenu_Opened" Closed="ctxMenu_Closed" Name="ctxMenuDpLin">
    71                                         <MenuItem Header="{x:Static lang:Distribution.graph_contextmenucopy}" Name="miCopyLin" Click="miCopy_Click" />
    72                                     </ContextMenu>
    73                                 </DockPanel.ContextMenu>
    74                                 <comps:SelectableTextBlock x:Name="lblCalcInfoLiN" Visibility="Collapsed" Text="{x:Static lang:Distribution.graph_lincountinfo}" MouseEnter="lblInfo_MouseEnter" MouseLeave="lblInfo_MouseLeave">
    75 
     66                                <comps:SelectableTextBlock x:Name="lblCalcInfoLiNTextBlock" Visibility="Collapsed">
     67                                    <Run x:Name="lblCalcInfoLiN" Text="{x:Static lang:Distribution.graph_lincountinfo}" />
     68                                    <Run x:Name="tbInfoLin" />
    7669                                </comps:SelectableTextBlock>
    77                                 <comps:SelectableTextBlock x:Name="tbInfoLin" Margin="3,0,0,0" MouseEnter="lblInfo_MouseEnter" MouseLeave="lblInfo_MouseLeave" />
    7870                            </DockPanel>
    7971                            <Line X1="0" X2="10" Y1="0" Y2="0" Stroke="Red" StrokeThickness="3" Grid.Row="2" VerticalAlignment="Center" />
     
    8375                            <Image Cursor="Hand" Source="../../../Resources/icons/help.png" Width="16" Height="16" Grid.Row="2" Grid.Column="4" Name="btnHelpPiX" HorizontalAlignment="Left" VerticalAlignment="Center" MouseLeftButtonDown="btnHelpFunctionTypeClick" />
    8476                            <DockPanel Grid.Row="2" Grid.Column="5" VerticalAlignment="Center" Margin="10,0,0,0" Name="dpPiX">
    85                                 <DockPanel.ContextMenu>
    86                                     <ContextMenu Opened="ctxMenu_Opened" Closed="ctxMenu_Closed" Name="ctxMenuDpPiX">
    87                                         <MenuItem Header="{x:Static lang:Distribution.graph_contextmenucopy}" Name="miCopyPix" Click="miCopy_Click" />
    88                                     </ContextMenu>
    89                                 </DockPanel.ContextMenu>
    90                                 <comps:SelectableTextBlock x:Name="lblCalcInfoPiX" Visibility="Collapsed" Margin="0,0,0,0" MouseEnter="lblInfo_MouseEnter" MouseLeave="lblInfo_MouseLeave" Text="{x:Static lang:Distribution.graph_pincountinfo}"></comps:SelectableTextBlock>
    91                                 <comps:SelectableTextBlock x:Name="tbInfoPiX" Margin="3,0,0,0" MouseEnter="lblInfo_MouseEnter" MouseLeave="lblInfo_MouseLeave" />
     77                                <comps:SelectableTextBlock x:Name="lblCalcInfoPiXTextBlock" Visibility="Collapsed" Margin="0,0,0,0">
     78                                    <Run x:Name="lblCalcInfoPiX" Text="{x:Static lang:Distribution.graph_pincountinfo}" />
     79                                    <Run x:Name="tbInfoPiX" />
     80                                </comps:SelectableTextBlock>
    9281                            </DockPanel>
    9382                        </Grid>
  • trunk/CrypPlugins/Primes/Primes/WpfControls/PrimesDistribution/Graph/GraphControl.xaml.cs

    r8606 r8653  
    2929using Primes.WpfControls.Threads;
    3030using System.Threading.Tasks;
     31using System.Windows.Documents;
    3132
    3233namespace Primes.WpfControls.PrimesDistribution.Graph
     
    163164        }
    164165
    165         void SetInfo(TextBlock tb, object value)
     166        void SetInfo(Run tb, object value)
    166167        {
    167168            if (value != null)
     
    209210            cgraph.CancelFunction(m_FunctionPix);
    210211            ircCountPrimes.UnLockControls();
    211             ControlHandler.SetPropertyValue(lblCalcInfoPiX, "Visibility", Visibility.Collapsed);
    212             ControlHandler.SetPropertyValue(lblCalcInfoPiGauss, "Visibility", Visibility.Collapsed);
    213             ControlHandler.SetPropertyValue(lblCalcInfoLiN, "Visibility", Visibility.Collapsed);
    214             ControlHandler.SetPropertyValue(tbInfoLin, "Visibility", Visibility.Collapsed);
    215             ControlHandler.SetPropertyValue(tbInfoPiX, "Visibility", Visibility.Collapsed);
    216             ControlHandler.SetPropertyValue(tbInfoGaußPrimeTheorem, "Visibility", Visibility.Collapsed);
     212            ControlHandler.SetPropertyValue(lblCalcInfoPiXTextBlock, "Visibility", Visibility.Collapsed);
     213            ControlHandler.SetPropertyValue(lblCalcInfoPiGaussTextBlock, "Visibility", Visibility.Collapsed);
     214            ControlHandler.SetPropertyValue(lblCalcInfoLiNTextBlock, "Visibility", Visibility.Collapsed);
    217215
    218216            //EnabledButton(btnExec);
     
    311309            }
    312310
    313             ControlHandler.SetPropertyValue(lblCalcInfoPiX, "Visibility", Visibility.Visible);
    314             ControlHandler.SetPropertyValue(lblCalcInfoPiGauss, "Visibility", Visibility.Visible);
    315             ControlHandler.SetPropertyValue(lblCalcInfoLiN, "Visibility", Visibility.Visible);
    316             ControlHandler.SetPropertyValue(tbInfoLin, "Visibility", Visibility.Visible);
    317             ControlHandler.SetPropertyValue(tbInfoPiX, "Visibility", Visibility.Visible);
    318             ControlHandler.SetPropertyValue(tbInfoGaußPrimeTheorem, "Visibility", Visibility.Visible);
     311            ControlHandler.SetPropertyValue(lblCalcInfoPiXTextBlock, "Visibility", Visibility.Visible);
     312            ControlHandler.SetPropertyValue(lblCalcInfoPiGaussTextBlock, "Visibility", Visibility.Visible);
     313            ControlHandler.SetPropertyValue(lblCalcInfoLiNTextBlock, "Visibility", Visibility.Visible);
    319314            lblCalcInfoLiN.Text = Primes.Resources.lang.WpfControls.Distribution.Distribution.graph_lincountinfoCalculating;
    320315            lblCalcInfoPiGauss.Text = Primes.Resources.lang.WpfControls.Distribution.Distribution.graph_gausscountinfoCalculating;
    321316            lblCalcInfoPiX.Text = Primes.Resources.lang.WpfControls.Distribution.Distribution.graph_pincountinfoCalculating;
     317            tbInfoLin.Text = "";
     318            tbInfoGaußPrimeTheorem.Text = "";
     319            tbInfoPiX.Text = "";
    322320            //}
    323321        }
     
    860858        #endregion
    861859
    862         private void MarkTextblock(TextBlock tb1, TextBlock tb2, DockPanel dp)
    863         {
    864             if (tb1.Visibility == Visibility.Visible && tb2.Visibility == Visibility.Visible)
    865             {
    866                 dp.Background = Brushes.Blue;
    867                 tb1.Foreground = tb2.Foreground = Brushes.White;
    868             }
    869         }
    870 
    871         private void UnMarkTextblock(TextBlock tb1, TextBlock tb2, DockPanel dp)
    872         {
    873             dp.Background = Brushes.Transparent;
    874             tb1.Foreground = tb2.Foreground = Brushes.Black;
    875         }
    876 
    877         private void CopyInfo(TextBlock tb1, TextBlock tb2)
    878         {
    879             Clipboard.SetText(tb1.Text + " " + tb2.Text);
    880         }
    881 
    882         private void lblInfo_MouseEnter(object sender, MouseEventArgs e)
    883         {
    884             if (sender == lblCalcInfoLiN || sender == tbInfoLin)
    885                 MarkTextblock(lblCalcInfoLiN, tbInfoLin, dpLin);
    886             else if (sender == lblCalcInfoPiGauss || sender == tbInfoGaußPrimeTheorem)
    887                 MarkTextblock(lblCalcInfoPiGauss, tbInfoGaußPrimeTheorem, dpGauss);
    888             else if (sender == lblCalcInfoPiX || sender == tbInfoPiX)
    889                 MarkTextblock(lblCalcInfoPiX, tbInfoPiX, dpPiX);
    890         }
    891 
    892         private void lblInfo_MouseLeave(object sender, MouseEventArgs e)
    893         {
    894             if (sender == lblCalcInfoLiN || sender == tbInfoLin)
    895                 UnMarkTextblock(lblCalcInfoLiN, tbInfoLin, dpLin);
    896             else if (sender == lblCalcInfoPiGauss || sender == tbInfoGaußPrimeTheorem)
    897                 UnMarkTextblock(lblCalcInfoPiGauss, tbInfoGaußPrimeTheorem, dpGauss);
    898             else if (sender == lblCalcInfoPiX || sender == tbInfoPiX)
    899                 UnMarkTextblock(lblCalcInfoPiX, tbInfoPiX, dpPiX);
    900         }
    901 
    902         private void ctxMenu_Opened(object sender, RoutedEventArgs e)
    903         {
    904             if (sender == ctxMenuDpLin)
    905                 MarkTextblock(lblCalcInfoLiN, tbInfoLin, dpLin);
    906             else if (sender == ctxMenuDpGauss)
    907                 MarkTextblock(lblCalcInfoPiGauss, tbInfoGaußPrimeTheorem, dpGauss);
    908             else if (sender == ctxMenuDpPiX)
    909                 MarkTextblock(lblCalcInfoPiX, tbInfoPiX, dpPiX);
    910         }
    911 
    912         private void ctxMenu_Closed(object sender, RoutedEventArgs e)
    913         {
    914             if (sender == ctxMenuDpLin)
    915                 UnMarkTextblock(lblCalcInfoLiN, tbInfoLin, dpLin);
    916             else if (sender == ctxMenuDpGauss)
    917                 UnMarkTextblock(lblCalcInfoPiGauss, tbInfoGaußPrimeTheorem, dpGauss);
    918             else if (sender == ctxMenuDpPiX)
    919                 UnMarkTextblock(lblCalcInfoPiX, tbInfoPiX, dpPiX);
    920         }
    921 
    922         private void miCopy_Click(object sender, RoutedEventArgs e)
    923         {
    924             if (sender == miCopyLin)
    925             {
    926                 CopyInfo(lblCalcInfoLiN, tbInfoLin);
    927             }
    928             else if (sender == miCopyPix)
    929             {
    930                 CopyInfo(lblCalcInfoPiX, tbInfoPiX);
    931             }
    932             else if (sender == miCopyGauss)
    933             {
    934                 CopyInfo(lblCalcInfoPiGauss, tbInfoGaußPrimeTheorem);
    935             }
    936         }
    937860
    938861        #region IPrimeUserControl Members
Note: See TracChangeset for help on using the changeset viewer.