Exemplo n.º 1
0
        public AdvancedMenuModel(
            IAdvancedMenuManager advancedMenuManager,
            IAppearanceManager appearanceManager,
            IBranchManager branchManager,
            IHelpManager helpManager,
            AbstractDialogModel model)
        {
            IsEnabled = true;
            _advancedMenuManager = advancedMenuManager;
            _appearanceManager = appearanceManager;
            _branchManager = branchManager;
            _helpManager = helpManager;
            _model = model;
            _dialogInstance = new AdvancedMenuWindow { DataContext = this };
            BuildGroupsList();
            _width = 500;
            _height = 550;
            Cursor = Cursors.Arrow;
            Title = _advancedMenuManager.DefaultTitle;
            Description = _advancedMenuManager.DefaultDescription;
            _timer = new DispatcherTimer
                {
                    Interval = new TimeSpan(0, 0, 0, 0, 500),
                    IsEnabled = false,
                };

            _timer.Tick += TimerTickHandler;
        }
Exemplo n.º 2
0
 public ReturnStoredResultModel(ISettingsManager manager, AbstractDialogModel model, string key)
     : base(model)
 {
     _manager = manager;
     _model = model;
     _resultKey = key;
 }
Exemplo n.º 3
0
 internal void SetBackButtonText(AbstractDialogModel model, string value)
 {
     model.BackModel.Text = value;
 }
Exemplo n.º 4
0
        private void SetButtonText(AbstractDialogModel model, string key, string value)
        {
            var methodName = string.Format("set{0}text", key.ToLowerInvariant());
            var methodInfo = GetType()
                .GetMethod(methodName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic);

            if (methodInfo == null)
                throw new Exception(string.Format("Could not find setter method for {0}", key));

            if (!ReflectionUtilities.IsMethodAllowedFromXml(methodInfo))
                throw new Exception(string.Format("Method {0} not callable from xml", key));

            methodInfo.Invoke(this, new object[] {model, value });
        }
Exemplo n.º 5
0
 internal void SetAdvancedButtonText(AbstractDialogModel model, string value)
 {
     model.AdvancedModel.Text = value;
 }
Exemplo n.º 6
0
        public static AbstractCommandModel FromButtonWrapper(AbstractDialogModel dialog, AbstractButton wrapper)
        {
            var result = MapButtonWrapperToModel(dialog, wrapper);
            if (result == null)
            {
                Log.WarnFormat("Cannot instatiate model for wrapper of type {0}", wrapper.GetType().Name);
                return null;
            }

            result.Enabled = wrapper.Enabled;
            result.Text = wrapper.Text;
            result.Visibility = wrapper.Visible ? Visibility.Visible : Visibility.Collapsed;
            result.Target = wrapper.Target;
            result.IsDefaultButton = wrapper.IsDefaultButton;
            result.IsCancelButton = wrapper.IsCancelButton;
            return result;
        }
Exemplo n.º 7
0
 internal void SetNextButtonText(AbstractDialogModel model, string value)
 {
     model.NextModel.Text = value;
 }
Exemplo n.º 8
0
        public void ShowHelpTopic(string value, AbstractDialogModel model)
        {
            try
            {
                var resolvedValue = value.Resolve(_settingsManager, true);
                UploadTopicReportingEntry(resolvedValue);

                var topics =
                    _helpTopics.FindAll(e => e.Identifier.Equals(
                        resolvedValue,
                        StringComparison.InvariantCultureIgnoreCase));

                if (!topics.Any())
                    throw new Exception("topic does not exist");

                var topic = topics.FirstOrDefault(e => e.IsValid);
                if (topic == null)
                    throw new Exception("topic exists, but not valid entries found");

                if (model == null)
                    _model.ShowUri(ResolveUri(topic.Url));
                else
                    _model.ShowUri(ResolveUri(topic.Url), model.Left, model.Top);

            }
            catch (Exception e)
            {
                Log.WarnFormat("An issue occurred while attempting to open the help topic {0}: {1}", value, e.Message);
            }
        }
Exemplo n.º 9
0
 protected AbstractCommandModel(AbstractDialogModel model)
     : base(model)
 {
     PropertyChanged += PropertyChangedHandler;
 }
Exemplo n.º 10
0
 internal void SetHelpButtonText(AbstractDialogModel model, string value)
 {
     model.HelpModel.Text = value;
 }
Exemplo n.º 11
0
 public DisabledCommandModel(AbstractDialogModel model)
     : base(model)
 {
 }
Exemplo n.º 12
0
 public ReturnResultModel(AbstractDialogModel model, AbstractTaskResult result)
     : base(model)
 {
     _result = result;
 }
Exemplo n.º 13
0
 public CancelButtonModel(AbstractDialogModel model)
     : base(model)
 {
 }
Exemplo n.º 14
0
        public void ShowAdvancedMenu(AbstractDialogModel model, string group)
        {
            try
            {

                if (model == null)
                    return;

                var left = model.DialogInstance.Left;
                var top = model.DialogInstance.Top;

                model.EnableDisableAllControls(false);
                var advancedMenuModel = new AdvancedMenuModel(this,
                    _appearanceManager,
                    _branchManager,
                    _helpManager,
                    model);
                advancedMenuModel.ShowDialog(
                    left,
                    top,
                    group.Resolve(_settingsManager, true));

                if (advancedMenuModel.Result != null)
                {
                    if (advancedMenuModel.Result is RestartComputerResult ||
                        advancedMenuModel.Result is SilentRestartComputerResult ||
                        advancedMenuModel.Result is ExitUtilityResult)
                    {
                        model.Result = advancedMenuModel.Result;
                        model.SuppressCloseQuestion = true;
                        model.DialogInstance.Close();
                    }
                }
            }
            finally
            {
                if (model != null)
                    model.EnableDisableAllControls(true);

            }
        }
Exemplo n.º 15
0
 public OpenTopicModel(AbstractDialogModel model, string topic, IHelpManager helpManager)
     : base(model)
 {
     _topic = topic;
     _helpManager = helpManager;
 }
Exemplo n.º 16
0
 public BannerPageModel(AbstractDialogModel dialogModel)
     : base(dialogModel)
 {
 }
Exemplo n.º 17
0
 public ModifySettingsModel(AbstractDialogModel model, ISettingsManager manager, SettingsLink wrapper)
     : base(model)
 {
     _manager = manager;
     _wrapper = wrapper;
 }
Exemplo n.º 18
0
 public DoNothingCommandModel(AbstractDialogModel model)
     : base(model)
 {
 }
Exemplo n.º 19
0
 public InvisibleCommandModel(AbstractDialogModel model)
     : base(model)
 {
 }
Exemplo n.º 20
0
 public OpenAdvancedButtonModel(AbstractDialogModel model, IAdvancedMenuManager advancedMenuManager, string group)
     : base(model)
 {
     _advancedMenuManager = advancedMenuManager;
     _group = group;
 }
Exemplo n.º 21
0
 public OpenLinkModel(AbstractDialogModel model, AbstractLink link)
     : base(model)
 {
     _link = link;
 }
Exemplo n.º 22
0
        private static AbstractCommandModel MapButtonWrapperToModel(AbstractDialogModel dialog, AbstractButton wrapper)
        {
            var kernal = Application.Current.CurrentKernel();
            var modelParameter = new ConstructorArgument("model", dialog);

            if (wrapper is ResultButton)
                return kernal.Get<ReturnResultModel>(
                    new IParameter[]
                        {
                            modelParameter,
                            new ConstructorArgument("result", (wrapper as ResultButton).TaskResult)
                        });

            if (wrapper is UrlButton)
            {
                var link = kernal.Get<UrlLink>();
                link.Target = (wrapper as UrlButton).Value;
                return kernal.Get<OpenLinkModel>(
                    new IParameter[]
                        {
                            modelParameter,
                            new ConstructorArgument("link", link)
                        }
                    );
            }

            if (wrapper is SettingsButton)
            {
                var link = kernal.Get<SettingsLink>();
                link.Target = (wrapper as SettingsButton).Key;
                link.Value = "true";
                return kernal.Get<ModifySettingsModel>(
                    new IParameter[]
                        {
                            modelParameter,
                            new ConstructorArgument("wrapper", link)
                        }
                    );
            }

            if (wrapper is TopicButton)
            {
                var value = (wrapper as TopicButton).Value;
                return kernal.Get<OpenTopicModel>(
                   new IParameter[]
                        {
                            modelParameter,
                            new ConstructorArgument("topic",value)
                        }
                   );
            }

            if (wrapper is StoredResultButton)
            {
                return kernal.Get<ReturnStoredResultModel>(
                    new IParameter[]
                        {
                            modelParameter,
                            new ConstructorArgument("key",(wrapper as StoredResultButton).Key)
                        });
            }

            if (wrapper is OpenAdvancedMenuButton)
            {
                var group = (wrapper as OpenAdvancedMenuButton).Group;
                return kernal.Get<OpenAdvancedButtonModel>(
                    new IParameter[]
                        {
                            modelParameter,
                            new ConstructorArgument("group", group)
                        });

            }

            if (wrapper is DisabledButton)
                return kernal.Get<DisabledCommandModel>(modelParameter);

            if (wrapper is CancelButton)
                return kernal.Get<CancelButtonModel>(modelParameter);

            if (wrapper is DoNothingButton)
                return kernal.Get<DoNothingCommandModel>(modelParameter);

            return null;
        }