private void MenuItem_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (e.Source is MenuItem)
     {
         FrameworkElement node = (FrameworkElement)e.Source;
         string           path = "";
         // collect selected object reflection path
         while (node != null && !(node is Popup))
         {
             path = node.Tag.ToString() + "," + path;
             node = (FrameworkElement)node.Parent;
         }
         OverrideRule newRule = OverrideRule.Create(CurrentLib, path.TrimEnd(','));
         if (newRule != null)
         {
             AllOverrides.Add(newRule);
             lbxOverrideRules.SelectedItem = newRule;
             AllOverrides.ToList().Pack(ioPathRuleOverrides);
         }
     }
     if (sender is ContextMenu)
     {
         (sender as ContextMenu).IsOpen = false;
     }
 }
 private void btnOverridesResetRule_Click(object sender, RoutedEventArgs e)
 {
     if (lbxOverrideRules.SelectedItem != null)
     {
         OverrideRule rule = (OverrideRule)lbxOverrideRules.SelectedItem;
         lbxOverrideRules.SelectedIndex = -1;
         lbxOverrideRules.SelectedItem  = rule;
     }
 }
 private void btnOverridesSaveRule_Click(object sender, RoutedEventArgs e)
 {
     if (lbxOverrideRules.SelectedItem != null)
     {
         OverrideRule rule = (OverrideRule)lbxOverrideRules.SelectedItem;
         rule.jsonValue = tbxOverridesEditor.Text;
         rule.notes     = tbxOverrideEditorNotes.Text;
         AllOverrides.ToList().Pack(ioPathRuleOverrides);
     }
 }
 private void lbxOverrideRules_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (lbxOverrideRules.SelectedItem != null)
     {
         OverrideRule rule = (OverrideRule)lbxOverrideRules.SelectedItem;
         try // neccessary evil so that rules can exist, but don't have to always be functional. This will handle testing of partial exports or potential legacy situations.
         {
             ejoHelpEntity obj = OverrideRule.findeOverrideTargetObject(CurrentLib, rule.fullSelectedPath).source;
             if (obj != null)
             {
                 wbApplyOverrides.Navigate(urlHelpers.getHelpURL(obj.guid));
             }
         }
         catch (Exception)
         {
             MessageBox.Show("The selected OverrideRule references a path to an object that doesn't exist\n\n" + rule.fullSelectedPath, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
Beispiel #5
0
        /// Step 5 has a partial class that encapsulates most of this OverrideRule process and is located in: /StepBehaviors/Step5.ApplyOverrides.cs
        /// The actuall OverrideRule Class is defined in: /InterfaceUtilities/InterfaceObjects.cs
        private void btnExportFinalAbstraction_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog()
            {
                Filter           = "json files | *.json",
                DefaultExt       = "json",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer),
                FileName         = "webHelpAbstraction.json",
                OverwritePrompt  = true,
                Title            = "Export Help Abstraction"
            };

            if (dlg.ShowDialog() == true)
            {
                List <string> Errors = new List <string>();
                for (int i = 0; i < AllOverrides.Count; i++)
                {
                    try // neccessary evil so that rules can exist, but don't have to always be functional. This will handle testing of partial exports or potential legacy situations.
                    {
                        OverrideRule.findeOverrideTargetObject(CurrentLib, AllOverrides[i].fullSelectedPath).source.ApplyRule(AllOverrides[i]);
                    }
                    catch (Exception)
                    {
                        Errors.Add("Error@Index: " + i.ToString().PadLeft(3, '0') + " ON: " + AllOverrides[i].id + "[" + AllOverrides[i].targetProperty + "]");
                    }
                }
                CurrentLib.Pack(dlg.FileName);
                CurrentLib = ioPathHelpAbstraction.UnPack <WebObjectLibrary>();
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Extraction Completed: " + (Errors.Count == 0 ? "without errors" : "with override json errors!"));
                sb.AppendLine("");
                sb.AppendLine("Note that unless you've specifically overwritten the internal (pre-override) version, then this dialog will not show show the exported version");
                sb.AppendLine("");
                sb.AppendLine("");
                foreach (string err in Errors)
                {
                    sb.Append(err);
                }
                MessageBox.Show(sb.ToString(), "Information", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }