Changeset 2290


Ignore:
Timestamp:
Jan 5, 2011, 6:49:17 PM (11 years ago)
Author:
sauer
Message:

Wizard:

  • added functionality to click through the first categories (not fully configured yet)
Location:
trunk/CrypPlugins/Wizard
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/Wizard/Config/wizard.config.analysis.xml

    r2284 r2290  
    77  <!-- This is the step's headline. It should be a short, but precise instruction of what the user is supposed to do. -->
    88  <headline lang="en" >Choose between classic or modern encryption to analyse</headline>
     9
     10  <!-- This is the description's headline. -->
     11  <desc lang="en" >Description</desc>
    912
    1013  <!-- Classic Encryption Category -->
  • trunk/CrypPlugins/Wizard/Config/wizard.config.enDe.xml

    r2288 r2290  
    77  <!-- This is the step's headline. It should be a short, but precise instruction of what the user is supposed to do. -->
    88  <headline lang="en" >Choose between classic or modern encryption/decryption</headline>
     9
     10  <!-- This is the description's headline. -->
     11  <desc lang="en" >Description</desc>
    912
    1013  <!-- Classic Encryption/Decryption Category -->
  • trunk/CrypPlugins/Wizard/Config/wizard.config.indiv.xml

    r2284 r2290  
    77  <!-- This is the step's headline. It should be a short, but precise instruction of what the user is supposed to do. -->
    88  <headline lang="en" >Choose between individual procedures</headline>
     9
     10  <!-- This is the description's headline. -->
     11  <desc lang="en" >Description</desc>
    912
    1013  <!-- Hash Functions Category -->
  • trunk/CrypPlugins/Wizard/Config/wizard.config.modernEnDe.xml

    r2288 r2290  
    77  <!-- This is the step's headline. It should be a short, but precise instruction of what the user is supposed to do. -->
    88  <headline lang="en" >Choose between symmetric or asymmetric encryption/decryption</headline>
     9
     10  <!-- This is the description's headline. -->
     11  <desc lang="en" >Description</desc>
    912
    1013  <!-- Symmetric Encryption/Decryption Category -->
  • trunk/CrypPlugins/Wizard/Config/wizard.config.start.xml

    r2284 r2290  
    77  <!-- This is the step's headline. It should be a short, but precise instruction of what the user is supposed to do. -->
    88  <headline lang="en" >Choose your task</headline>
     9
     10  <!-- This is the description's headline. -->
     11  <desc lang="en" >Description</desc>
    912 
    1013  <!-- Encryption/Decryption Category -->
  • trunk/CrypPlugins/Wizard/WizardControl.xaml

    r2216 r2290  
    1212            <RowDefinition Height="Auto" />
    1313        </Grid.RowDefinitions>
    14         <Label Content="Choose your task" HorizontalAlignment="Center" Name="taskHeader" VerticalAlignment="Top" FontSize="18" />
     14        <Label HorizontalAlignment="Center" Name="taskHeader" VerticalAlignment="Top" FontSize="18" />
    1515        <ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Grid.Row="1">
    1616            <Grid HorizontalAlignment="Stretch" Name="grid1" VerticalAlignment="Stretch" >
     
    1919                <ColumnDefinition />
    2020            </Grid.ColumnDefinitions>
    21                 <StackPanel Name="stackPanel1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="15">
    22                     <RadioButton HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" IsChecked="True">
    23                         <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Orientation="Horizontal" >
    24                             <Image Source="wizard.png" Stretch="Fill" Width="30" Height="30"/>
    25                             <Label Content="Test" Height="28" />
    26                         </StackPanel>
    27                     </RadioButton>
    28                 </StackPanel>
    29                 <StackPanel HorizontalAlignment="Stretch" Name="descStackPanel" VerticalAlignment="Stretch" Grid.Column="1">
    30                     <Label Name="descHeader" Content="Description" HorizontalAlignment="Center"/>
    31                     <TextBlock Name="description" TextWrapping="Wrap" Margin="15">
    32                         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    33                     </TextBlock>
    34                 </StackPanel>
     21                <StackPanel Name="radioButtonStackPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="15" />
     22                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1">
     23                    <Grid.RowDefinitions>
     24                        <RowDefinition Height="Auto" />
     25                        <RowDefinition Height="Auto" />
     26                    </Grid.RowDefinitions>
     27                    <Grid.ColumnDefinitions>
     28                        <ColumnDefinition />
     29                    </Grid.ColumnDefinitions>
     30                    <Label Name="descHeader" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
     31                    <TextBlock Name="description" TextWrapping="Wrap" Margin="10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" TextAlignment="Left" Grid.Row="1" />
     32                </Grid>
    3533            </Grid>
    3634        </ScrollViewer>
    3735        <StackPanel Grid.RowSpan="2" Height="Auto" HorizontalAlignment="Right" Name="buttonStackPanel" VerticalAlignment="Bottom" Margin="2" Grid.Row="2" Orientation="Horizontal" >
    38             <Button Content="Back" Height="23" Name="backButton" Width="75" Margin="1"/>
    39             <Button Content="Next" Height="23" Name="nextButton" Width="75" Margin="1" IsDefault="True" />
    40             <Button Content="Cancel" Height="23" Name="cancelButton" Width="75" Margin="1"/>
     36            <Button Content="Back" Height="23" Name="backButton" Width="75" Margin="1" Click="backButton_Click"/>
     37            <Button Content="Next" Height="23" Name="nextButton" Width="75" Margin="1" IsDefault="True" Click="nextButton_Click"/>
     38            <Button Content="Abort" Height="23" Name="abortButton" Width="75" Margin="1" Click="abortButton_Click"/>
    4139        </StackPanel>
    4240    </Grid>
  • trunk/CrypPlugins/Wizard/WizardControl.xaml.cs

    r2288 r2290  
    1515using System.IO;
    1616using System.Reflection;
     17using System.Windows.Threading;
     18using System.Threading;
    1719
    1820namespace Wizard
     
    2426    {
    2527
    26         private string culture = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
    2728        private const string configXMLPath = "Wizard.Config.wizard.config.start.xml";
    2829        private const string defaultLang = "en";
     
    4445            }
    4546            InitializeComponent();
     47            SetupPage(wizardConfigXML);
    4648        }
    4749
     
    9294        }
    9395
    94         private void GetCategoryList()
    95         {
    96 
     96        private void SetupPage(XElement element)
     97        {
     98            XElement parent = element.Parent;
     99            if (parent == null)
     100            {
     101                backButton.IsEnabled = false;
     102                abortButton.IsEnabled = false;
     103            }
     104            else
     105            {
     106                backButton.IsEnabled = true;
     107                abortButton.IsEnabled = true;
     108            }
     109
     110            nextButton.IsEnabled = false;
     111
     112            string currentLang = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
     113
     114            //set headline
     115            XElement headline = FindElementInElement(element, "headline");
     116            if (headline != null)
     117                taskHeader.Content = headline.Value;
     118
     119            //set description label
     120            XElement desc = FindElementInElement(element, "desc");
     121            if (desc != null)
     122                descHeader.Content = desc.Value;
     123
     124            //generate radio buttons
     125            IEnumerable<XElement> categories = element.Elements("category");
     126            IEnumerable<XElement> items = element.Elements("item");
     127
     128            if (items.Any())
     129                categories.Union(items);
     130
     131            if (categories.Any())
     132            {
     133                foreach (XElement ele in categories)
     134                {
     135                    Label l = new Label();
     136                    l.Height = 30;
     137                    XElement label = FindElementInElement(ele, "name");
     138                    if (label != null)
     139                        l.Content = label.Value;
     140
     141                    //Image i = new Image(); TODO
     142
     143                    StackPanel sp = new StackPanel();
     144                    sp.VerticalAlignment = VerticalAlignment.Stretch;
     145                    sp.HorizontalAlignment = HorizontalAlignment.Stretch;
     146                    sp.Orientation = Orientation.Horizontal;
     147                    //add image
     148                    sp.Children.Add(l);
     149
     150                    RadioButton rb = new RadioButton();
     151                    rb.HorizontalAlignment = HorizontalAlignment.Stretch;
     152                    rb.HorizontalContentAlignment = HorizontalAlignment.Left;
     153                    rb.Checked += rb_Checked;
     154                    rb.Content = sp;
     155                    rb.Tag = ele;
     156
     157                    radioButtonStackPanel.Children.Add(rb);
     158                }
     159            }
     160
     161        }
     162
     163        void rb_Checked(object sender, RoutedEventArgs e)
     164        {
     165            RadioButton b = (RadioButton)sender;
     166            XElement ele = (XElement)b.Tag;
     167            XElement desc = FindElementInElement(ele, "description");
     168            if (desc != null)
     169                description.Text = desc.Value;
     170            nextButton.IsEnabled = true;
     171        }
     172
     173        //finds elements according to the current language
     174        private XElement FindElementInElement(XElement element, string xname)
     175        {
     176            string currentLang = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
     177            XElement foundElement = null;
     178
     179            IEnumerable<XElement> descriptions = element.Elements(xname);
     180            if (descriptions.Any())
     181            {
     182                var description = from descln in descriptions where descln.Attribute("lang").Value == currentLang select descln;
     183                if (!description.Any())
     184                {
     185                    description = from descln in descriptions where descln.Attribute("lang").Value == defaultLang select descln;
     186                    if (description.Any())
     187                        foundElement = description.First();
     188                }
     189                else
     190                    foundElement = description.First();
     191            }
     192
     193            return foundElement;
     194        }
     195
     196        private void nextButton_Click(object sender, RoutedEventArgs e)
     197        {
     198            UIElement[] uiea = new UIElement[radioButtonStackPanel.Children.Count];
     199            radioButtonStackPanel.Children.CopyTo(uiea, 0);
     200            foreach (UIElement uie in uiea)
     201            {
     202                RadioButton b = (RadioButton)uie;
     203                if (b.IsChecked != null && (bool)b.IsChecked)
     204                {
     205                    radioButtonStackPanel.Children.Clear();
     206                    description.Text = "";
     207                    SetupPage((XElement)b.Tag);
     208                    break;
     209                }
     210            }
     211        }
     212
     213        private void backButton_Click(object sender, RoutedEventArgs e)
     214        {
     215            UIElement[] uiea = new UIElement[radioButtonStackPanel.Children.Count];
     216            radioButtonStackPanel.Children.CopyTo(uiea, 0);
     217            if (uiea.Length > 0)
     218            {
     219                RadioButton b = (RadioButton)uiea[0];
     220                XElement ele = (XElement)b.Tag;
     221                radioButtonStackPanel.Children.Clear();
     222                description.Text = "";
     223                XElement grandParent = ele.Parent.Parent;
     224                if (grandParent != null)
     225                    SetupPage(grandParent);
     226                else
     227                    SetupPage(wizardConfigXML);
     228            }
     229        }
     230
     231        private void abortButton_Click(object sender, RoutedEventArgs e)
     232        {
     233            radioButtonStackPanel.Children.Clear();
     234            description.Text = "";
     235            SetupPage(wizardConfigXML);
    97236        }
    98237
Note: See TracChangeset for help on using the changeset viewer.