Example #1
0
        public RulePointContext(RulePoint rulePoint, RulePointContext parentContext, RuleConfigContext ruleConfigContext)
            : base(rulePoint.Name, parentContext, ruleConfigContext)
        {
            if (rulePoint == null)
            {
                throw new ArgumentNullException("rulePoint");   // NOXLATE
            }

            _displayName = rulePoint.DisplayName;
            UpdateDisplayTexts();

            _signature = rulePoint.Signature;

            if (_signature != null)
            {
                DeleteContentOperation = new OperationContext(
                    Properties.Resources.DeleteRulePointDisplayName,
                    new RelayCommand(obj => DeleteContent()));
                CreateContentOperation = new OperationContext(
                    Properties.Resources.CreateRuleContentDisplayName,
                    new RelayCommand(obj => CreateContent()));
                CreateNamedRuleOperation = new OperationContext(
                    Properties.Resources.CreateNewSubruleDisplayName,
                    new RelayCommand(obj => CreateNewNamedRule(Properties.Resources.DefaultNewSubruleName)));
                CopyOperation = new OperationContext(
                    Properties.Resources.CopyRulePointDisplayName,
                    new RelayCommand(obj => CopyToClipboard(), obj => HasContent));
                PasteNamedRuleOperation = new OperationContext(
                    Properties.Resources.PasteNamedRuleDisplayName,
                    new RelayCommand(obj => PasteAsNamedRule(), obj => CanPasteNamedRule()));
            }
        }
 private RuleConfigDialog()
 {
     InitializeComponent();
     this.ShowInTaskbar = false;
     _ruleConfigContext = new RuleConfigContext();
     _ruleConfigContext.PropertyChanged += new PropertyChangedEventHandler(RuleConfigContext_PropertyChanged);
     this.DataContext = _ruleConfigContext;
 }
 public NamedRuleContext(string name, RulePointContext parentContext, RuleConfigContext ruleConfigContext)
     : base(name, parentContext, ruleConfigContext)
 {
     DeleteOperation = new OperationContext(
         Properties.Resources.DeleteNamedRuleDisplayName,
         new RelayCommand(obj => Delete()));
     CopyOperation = new OperationContext(
         Properties.Resources.CopyNamedRuleDisplayName,
         new RelayCommand(obj => CopyToClipboard()));
     CutOperation = new OperationContext(
         Properties.Resources.CutNamedRuleDisplayName,
         new RelayCommand(obj => Cut()));
     UpdateDisplayTexts();
 }
Example #4
0
        public RuleBaseContext(string name, RulePointContext parentContext, RuleConfigContext ruleConfigContext)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name"); // NOXLATE
            }
            if (ruleConfigContext == null)
            {
                throw new ArgumentNullException("ruleConfigContext"); // NOXLATE
            }

            _name              = name;
            _parentContext     = parentContext;
            _ruleConfigContext = ruleConfigContext;
        }
        private void RuleConfigContext_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            RuleConfigContext context = sender as RuleConfigContext;

            Debug.Assert(context != null);

            if (e.PropertyName == "EditingRule") // NOXLATE
            {
                RuleBaseContext editingRule = context.EditingRule;
                if (editingRule == null)
                {
                    DetachDesigner();

                    if (context.SelectedRule != null && context.SelectedRule is RulePointContext)
                    {
                        RulePointContext rpc = context.SelectedRule as RulePointContext;
                        mDesignerViewContent.Content = rpc.CreateContentOperation;
                    }
                    else
                    {
                        mDesignerViewContent.Content = "TODO: show help doc here."; // NOXLATE
                    }
                }
                else
                {
                    RuleAppExtension.RuleDesignerManagerInst.UpdateDesignerAttributes();
                    _workflowDesigner      = new WorkflowDesigner();
                    _workflowDesigner.Text = context.EditingRule.Text;
                    _workflowDesigner.Load();
                    RuleEditingContext editingContext         = context.EditingRule.GetEditingContext();
                    ServiceManager     editingContextServices = _workflowDesigner.Context.Services;
                    editingContextServices.Publish <RuleEditingContextService>(new RuleEditingContextService(editingContext));
                    editingContextServices.Publish <ActivityTranslator>(RuleAppExtension.ActivityTranslatorInst);
                    editingContextServices.Publish <ActivityFactory>(RuleAppExtension.ActivityFactoryInst);
                    _workflowDesigner.ModelChanged += new EventHandler(WorkflowDesigner_ModelChanged);
                    if (_ruleDesigner == null)
                    {
                        _ruleDesigner = new InternalDesigner();
                    }
                    _ruleDesigner.SetDesigner(_workflowDesigner);
                    mDesignerViewContent.Content = _ruleDesigner;
                    //mRulesTreeView.Focus();
                }
            }
        }
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            // If users accept (e.g. click on 'OK' button) and the rules have been changed, save rules.
            if (this.DialogResult == true && _ruleConfigContext.IsDirty)
            {
                _ruleConfigContext.CommitWorkingSet();
            }
            // If users cancelled the dialog and the rules have been changed, ask users if they want to save changes.
            else if (_ruleConfigContext.IsDirty)
            {
                MessageBoxResult result = MessageBox.Show(
                    Properties.Resources.PreClosingPrompt,
                    Properties.Resources.Warning,
                    MessageBoxButton.YesNoCancel,
                    MessageBoxImage.Warning);
                if (result == MessageBoxResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
                else
                {
                    if (result == MessageBoxResult.Yes)
                    {
                        _ruleConfigContext.CommitWorkingSet();
                    }
                }
            }

            DetachDesigner();
            DataContext        = null;
            _ruleConfigContext = null;
            _instance          = null;

            GC.Collect();
        }
        const string IllegalChars = "'"; // NOXLATE


        public NamedRuleContext(NamedRule namedRule, RulePointContext parentContext, RuleConfigContext ruleConfigContext)
            : this(namedRule.Name, parentContext, ruleConfigContext)
        {
        }