private void SmartPartClosingEventHandler(object sender, WorkspaceCancelEventArgs e)
        {
            // SCC has detected the user wants to close a control ...
            object o1 = e.SmartPart;

            if (o1 is IDialogView)
            {
                IDialogView OmsControl = o1 as DialogView;
                if (OmsControl.IsOKToClose())
                {
                    // backend has already confirmed it is OK to close, go on and close ...
                    e.Cancel = false;
                }
                else
                {
                    // do not close the control yet, backend has to confirm it is OK first
                    e.Cancel = true;
                    object o2 = OmsControl.TrimControl;
                    if (o2 is inUC)
                    {
                        inUC TrimControl = o2 as inUC;
                        TrimControl.requestClose();
                    }
                }
            }
        }
        public void Execute()
        {
            IMessagePrinter printer = uiFactory.CreateMessagePrinter();
            List <String>   args    = new List <string>();

            args.Add("Number");
            args.Add("Error");

            IDialogView   dialog  = uiFactory.CreateDialogView();
            List <string> results = dialog.ShowSelectionDialog(args);
            double        number  = 0;
            double        error   = 0;

            if (!double.TryParse(results.ElementAt(0), out number))
            {
                printer.Print("First input is not a number");
            }
            if (!double.TryParse(results.ElementAt(1), out error))
            {
                printer.Print("Second input is not a number");
            }
            ITaylorExpansion exp    = new ArctgExpansion(error, number);
            Result           result = exp.Calculate();

            printer.Print("Answer " + result.Answer);
        }
        public OpenFileDialogViewModel(
            IDialogView <OpenFileDialogResult> view,
            IClipboardService clipboard,
            IFileIconProvider fileIconProvider,
            IMessageDialogService messageDialogService,
            bool allowMultipleSelection,
            IEnumerable <FileDialogFilter> filters)
        {
            _view = view;

            Filters        = filters.Select(FileDialogFilterViewModel.New).ToImmutableArray();
            SelectedFilter = Filters.FirstOrDefault();

            _fileName = String.Empty;

            var filter = this.WhenAnyValue(vm => vm.SelectedFilter).Select(vm => vm?.Filter).Select(Filter.FileDialog.Matches);

            FileExplorer = new FileExplorerViewModel(clipboard, fileIconProvider, messageDialogService, allowMultipleSelection, filter);

            OpenCommand   = ReactiveCommand.Create(Open);
            CancelCommand = ReactiveCommand.Create(Cancel);

            FileExplorer.FileOpened.Subscribe(_ => Open());
            FileExplorer.FileExplorerFolder.WhenAnyValue(vm => vm.SelectedItem).Subscribe(SelectedItemChanged);
        }
        public void ShowMenu()
        {
            IDialogView dialogView = uiFactory.CreateDialogView();

            dialogView.ShowMessage("MENU");
            IMenuView     menuView  = uiFactory.CreateMenuView();
            List <string> menuItems = commands.Keys.ToList();

            menuItems.Add("Exit");

            while (true)
            {
                string result       = menuView.ShowMenu(menuItems);
                int    parsedResult = -1;
                if (int.TryParse(result, out parsedResult))
                {
                    if (parsedResult <= commands.Count)
                    {
                        commandProcessor.Execute(commands.Values.ToList().ElementAt(parsedResult - 1));
                    }
                    else if (parsedResult == commands.Count + 1)
                    {
                        dialogView.ShowMessage("Exiting");
                        return;
                    }
                    else
                    {
                        dialogView.ShowMessage("No such menu item");
                    }
                }
            }
        }
Exemple #5
0
        bool IPresenter.Open(IUserDefinedSearch search)
        {
            IFiltersList tempList  = search.Filters.Clone();
            bool         confirmed = false;

            using (dialogView = view.CreateDialog(this))
                using (var filtersManagerPresenter = filtersManagerFactory(tempList, dialogView))
                {
                    dialogView.SetData(new DialogData()
                    {
                        Name = search.Name
                    });
                    confirm = () =>
                    {
                        string name = dialogView.GetData().Name;
                        if (string.IsNullOrWhiteSpace(name))
                        {
                            alerts.ShowPopup(
                                alertsCaption,
                                "Bad filter name.",
                                AlertFlags.Ok
                                );
                            return(false);
                        }
                        if (name != search.Name && userDefinedSearches.ContainsItem(name))
                        {
                            alerts.ShowPopup(
                                alertsCaption,
                                string.Format("Name '{0}' is already used by another filter. Enter another name.", name),
                                AlertFlags.Ok
                                );
                            return(false);
                        }
                        if (tempList.Items.Count == 0)
                        {
                            alerts.ShowPopup(
                                alertsCaption,
                                "Can not save: filter must have at least one rule.",
                                AlertFlags.Ok
                                );
                            return(false);
                        }
                        confirmed = true;
                        return(confirmed);
                    };
                    dialogView.OpenModal();
                    confirm = null;
                    if (confirmed)
                    {
                        search.Name    = dialogView.GetData().Name;
                        search.Filters = tempList;
                    }
                    else
                    {
                        tempList.Dispose();
                    }
                }
            dialogView = null;
            return(confirmed);
        }
Exemple #6
0
 public IDialogView CreateNew()
 {
     if (dialog == null)
     {
         dialog = new DialogImpl();
     }
     return(dialog);
 }
 void IPresenter.ShowTheDialog(string selectedPageName)
 {
     if (dialog == null)
     {
         dialog = view.CreateDialog(this);
     }
     UpdateList(selectedPageName);
     dialog.ShowModal();
 }
 public MessageBoxViewModel(string title, IDialogView view, IView contentView)
 {
     View = view;
     View.Model = this;
     ContentView = contentView;
     Title = title;
     CloseWindowCommand = new DelegateCommand(Close);
     MoveWindowCommand = new DelegateCommand(() => { View.DragMove(); });
 }
Exemple #9
0
        /// <summary>
        /// Remove the <see cref="KeyValuePair{Thing, IDialogView}"/> from the open floating dialog list
        /// </summary>
        /// <param name="view">The closing <see cref="IDialogView"/></param>
        public void ClosingFloatingWindow(IDialogView view)
        {
            var kvp = this.FloatingThingDialog.SingleOrDefault(x => x.Value == view);

            if (!kvp.Equals(new KeyValuePair <Thing, IDialogView>()))
            {
                this.FloatingThingDialog.Remove(kvp.Key);
            }
        }
 void IPresenter.Open()
 {
     using (currentDialog = view.CreateDialog(this))
     {
         UpdateViewItems();
         UpdateControls();
         currentDialog.OpenModal();
     }
     currentDialog = null;
 }
        IUserDefinedSearch IPresenter.Open()
        {
            using (currentDialog = view.CreateDialog(this))
            {
                UpdateViewItems();
                UpdateControls();
                currentDialog.OpenModal();
            }
            var tmp = currentDialogResult;

            currentDialog       = null;
            currentDialogResult = null;
            return(tmp);
        }
Exemple #12
0
        internal ContentDialogViewModel(
            IDialogView <DialogResult> view,
            string title,
            object content,
            IReadOnlyList <DialogResult> dialogResults)
        {
            _view = view;

            Title   = title;
            Content = content;

            DialogResults = dialogResults;

            CloseCommand = ReactiveCommand.Create <DialogResult>(_view.Close);
        }
Exemple #13
0
        public async Task <T> Show <T>(string viewName, T context)
            where T : Confirmation
        {
            IDialogView view = unityContainer.Resolve <IDialogView>(viewName);

            var viewModel = view.DataContext as ConfirmationViewModel <T>;

            viewModel?.Initialize(context);

            DialogHost.CloseDialogCommand.Execute(null, null);

            await DialogHost.Show(view);

            return(context);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageBoxViewModel"/> class.        
 /// </summary>
 /// <remarks>This is a private constructor, use the static method Show to create MessageBox instances.</remarks>
 /// <param name="title">The title.</param>
 /// <param name="message">The message.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="imageSource">The image source.</param>
 /// <param name="isErrorAlert">if set to <c>true</c> [is error alert].</param>
 public MessageBoxViewModel(string title, string message, System.Windows.MessageBoxButton buttons, string imageSource, IDialogView view)
 {
     View = view;
     View.Model = this;
     Title = title;
     Message = message;
     Buttons = buttons;
     if (imageSource != null)
         ImageSource = imageSource;
     else
         ResetErrorImage();
     ResultButtonPressedCommand = new DelegateCommand<string>(OnResultButtonPressed);
     CloseWindowCommand = new DelegateCommand(Close);
     MoveWindowCommand = new DelegateCommand(() => { View.DragMove(); });
 }
        public void Setup()
        {
            this.dialogView            = new TestDialog();
            this.floatingView          = new TestFloatingDialog();
            this.dialogViewModel       = new TestDialogViewModel();
            this.nameMetaData          = new Mock <INameMetaData>();
            this.nameViewModelMetaData = new Mock <INameMetaData>();
            this.nameViewModelMetaData.Setup(x => x.Name).Returns("view-model");
            this.session = new Mock <ISession>();

            this.viewList = new List <Lazy <IDialogView, INameMetaData> >();
            this.viewList.Add(new Lazy <IDialogView, INameMetaData>(() => this.dialogView, this.nameMetaData.Object));
            this.viewList.Add(new Lazy <IDialogView, INameMetaData>(() => this.floatingView, this.nameMetaData.Object));

            this.viewModelList = new List <Lazy <IDialogViewModel, INameMetaData> >();
            this.viewModelList.Add(new Lazy <IDialogViewModel, INameMetaData>(() => this.dialogViewModel, this.nameViewModelMetaData.Object));
        }
Exemple #16
0
        public DialogFormPresenter(
            IDialogFormView dialogFormView,
            IService <Task> taskService,
            IService <Employee> employeeService,
            IService <AssignedTask> assignedTaskService,
            ISystemInformationService systemInformationService,
            IValidateAssignment validateAssignment,
            IMenuCommand[] commands)
        {
            this.dialogFormView = dialogFormView;

            this.taskDialogView = dialogFormView.TaskDialogView;
            this.taskDialogView.SetTitle(MenuOption.Tasks.GetAttribute <MenuOptionAttribute>().Name);

            this.employeeDialogView = dialogFormView.EmployeeDialogView;
            this.employeeDialogView.SetTitle(MenuOption.Employees.GetAttribute <MenuOptionAttribute>().Name);

            this.assignedTaskDialogView = dialogFormView.AssignedTaskDialogView;
            this.assignedTaskDialogView.SetTitle(MenuOption.AssignedTasks.GetAttribute <MenuOptionAttribute>().Name);

            this.taskDialogView.OnCancelButtonClick += OnCancelButtonClick;
            this.taskDialogView.OnSaveButtonClick   += TaskDialogView_OnSaveButtonClick;

            this.employeeDialogView.OnCancelButtonClick += OnCancelButtonClick;;
            this.employeeDialogView.OnSaveButtonClick   += EmployeeDialogView_OnSaveButtonClick;;

            this.assignedTaskDialogView.OnCancelButtonClick += OnCancelButtonClick;;
            this.assignedTaskDialogView.OnSaveButtonClick   += AssignedTaskDialogView_OnSaveButtonClick;;

            this.taskService         = taskService;
            this.employeeService     = employeeService;
            this.assignedTaskService = assignedTaskService;

            this.assignedTaskDialogView.LoadEmployees(employeeService.Get(e => !e.IsDeleted));
            this.assignedTaskDialogView.LoadTasks(taskService.Get(t => !t.IsDeleted));

            this.validateAssignment = validateAssignment;

            this.commands = commands;

            if (!systemInformationService.IsHighContrastColourScheme)
            {
                dialogFormView.BackColor = Color.White;
            }
        }
        public SaveFileDialogViewModel(
            IDialogView <SaveFileDialogResult> view,
            IClipboardService clipboard,
            IFileIconProvider fileIconProvider,
            IMessageDialogService messageDialogService)
        {
            _view = view;
            _messageDialogService = messageDialogService;

            FileExplorer = new FileExplorerViewModel(clipboard, fileIconProvider, messageDialogService, allowMultipleSelection: false);

            SaveCommand   = ReactiveCommand.Create(SaveAsync);
            CancelCommand = ReactiveCommand.Create(Cancel);

            FileExplorer.FileOpened.Subscribe(async file => await SaveAsync());

            FileExplorer.FileExplorerFolder.WhenAnyValue(vm => vm.SelectedItem).Subscribe(SelectedItemChanged);
        }
Exemple #18
0
 public void BeforeEach()
 {
     model      = Substitute.For <IPostprocessorTags>();
     view       = Substitute.For <IView>();
     dialogView = Substitute.For <IDialogView>();
     alerts     = Substitute.For <IAlertPopup>();
     view.When(v => v.SetViewModel(Arg.Any <IViewModel>())).Do(x => viewModel = x.Arg <IViewModel>());
     view.CreateDialog(Arg.Do <IDialogViewModel>(x => dialogViewModel         = x), Arg.Any <IEnumerable <string> >(), Arg.Any <string>()).Returns(dialogView);
     changeNotification = Substitute.For <IChangeNotification>();
     model.AvailableTags.Returns(ImmutableHashSet.Create(new[] { "foo", "bar", "item-1", "item-2", "abd", "abc" }));
     model.TagsPredicate.Returns(TagsPredicate.Parse("bar OR item-1 AND NOT abc"));
     presenter = new TagsListPresenter(
         model,
         view,
         changeNotification,
         alerts
         );
 }
Exemple #19
0
        public void Execute()
        {
            IMessagePrinter printer = uiFactory.CreateMessagePrinter();
            List <String>   args    = new List <string>();

            args.Add("Error");
            args.Add("Number");
            args.Add("Power");
            IDialogView   dialog        = uiFactory.CreateDialogView();
            List <string> results       = dialog.ShowSelectionDialog(args);
            double        number        = 0;
            double        error         = 0;
            double        power         = 0;
            bool          parsingfailed = false;

            if (!double.TryParse(results.ElementAt(0), out error))
            {
                parsingfailed = true;
                printer.Print("First input is not a number");
            }
            if (!double.TryParse(results.ElementAt(1), out number))
            {
                parsingfailed = true;
                printer.Print("Second input is not a number");
            }
            if (!double.TryParse(results.ElementAt(1), out power))
            {
                parsingfailed = true;
                printer.Print("Third input is not a number");
            }
            if (!parsingfailed)
            {
                ITaylorExpansion exp    = new Power(error, number, power);
                Result           result = exp.Calculate();
                if (result.Exist)
                {
                    printer.Print("Answer " + result.Answer);
                }
                else
                {
                    printer.Print("Answer does not exist");
                }
            }
        }
Exemple #20
0
 public LoadAssignedTasksCommand(
     IMainFormView mainFormView,
     IDialogFormView dialogFormView,
     IDialogView <AssignedTask> assignedTaskDialogView,
     IService <Task> taskService,
     IService <Employee> employeeService,
     IService <AssignedTask> assignedTaskService)
 {
     this.mainFormView           = mainFormView;
     this.dialogFormView         = dialogFormView;
     this.assignedTaskDialogView = assignedTaskDialogView;
     this.taskService            = taskService;
     this.employeeService        = employeeService;
     this.assignedTaskService    = assignedTaskService;
     Icon        = Properties.Resources.icons8_planner_48;
     ToolTip     = MenuOption.AssignedTasks.GetAttribute <MenuOptionAttribute>().Name;
     ShortcutKey = Keys.Alt | Keys.A;
     IsEnabled   = true;
 }
    void IActivatable.Activate(GameObject target)
    {
        // Get the dialog component of the listener, so we can use it's NpcRecord
        player = target.GetComponent <Character>();

        // Get the npc greeting, as if there is no greeting, the Npc can't be talked to.
        var greeting = DialogRecord.GetDialogInfo(DialogType.Greeting, Npc, player);

        if (greeting == null)
        {
            return;
        }

        // Check if the listener knows the current topic, otherwise it will not be available
        // This could be done within the same loop as getting the dialog topic
        topics = DialogRecord.GetDialog(Npc, player);

        var knownTopics = new List <DialogRecord>();

        foreach (var topic in topics)
        {
            // Only show topics that the player knows
            if (player.Journal.Topics.ContainsKey(topic.name))
            {
                knownTopics.Add(topic);
            }
        }

        // Display services
        var services = GetComponents <CharacterService>();

        // Load the dialog and instantiate
        dialogView = DialogView.Create(this, record.FullName, knownTopics, services, Npc.GetDisposition(player));

        // Process the greeting after getting topics, or there will be no topics to check against
        DisplayInfo(null, greeting);

        // Set this last, so it isn't true the first time the player talks to an Npc.
        GetComponent <Character>().HasTalkedToPlayer = true;
    }
 public void AddChildProgram(IDialogView childProgram)
 {
     childPrograms.Add(childProgram);
 }
        private void Accept(IDialogView dialogView)
        {
            RemoveItem();

            dialogView.Close();
        }
 private void Cancel(IDialogView dialogView)
 {
     dialogView.Close();
 }
        private void OpenTrimWindowHandler(object sender, dvEventArgs e)
        {
            // backend has created a new UserControl, show it as a new tab or new window or  ...
            inUC        TrimControl = e.Content;
            IDialogView OmsControl  = WorkItem.SmartParts.AddNew <DialogView>();

            OmsControl.Id = programStartSequence++;

            //Save the containing module for the OmsControl to use when it is closing. [Dashboard compliance]
            object containingModule = null;

            if (inUCContainingModuleDic.ContainsKey((inUC)sender))
            {
                containingModule = inUCContainingModuleDic[(inUC)sender];
                inUCContainingModuleDic.Remove((inUC)sender);
            }

            //System.Diagnostics.Debug.WriteLine("Opening new trim Dialog: " + OmsControl.Id);
            OmsControl.Show(TrimControl);
            SmartPartInfo spInfo = null;

            switch (e.Type)
            {
            case dvWinType.Main:
                ShellInteractionService.Show(OmsControl);
                OpenTabs.Add(OmsControl);
                break;

            case dvWinType.Modal:
                // currently not used!
                break;

            case dvWinType.Float:
                // currently not used!
                break;
            }

            TrimControl.evCloseWin += (s, args) =>
            {
                // backend confirms it is OK to close a program
                OmsControl.OKToClose();
                //System.Diagnostics.Debug.WriteLine("About to close Dialog " + OmsControl.Id);

                if (OmsControl.ParentProgram != null)
                {
                    IDialogView parent = OmsControl.ParentProgram;
                    parent.RemoveChildProgram(OmsControl);
                    OmsControl.ParentProgram = null;
                }

                switch (e.Type)
                {
                case dvWinType.Main:

                    //Check containing module and use it´s ShellInteractionService to close the OmsControl. [Dashboard compliance]
                    if (containingModule != null)
                    {
                        if (containingModule.GetType().GetProperty("ShellInteractionService") != null)
                        {
                            ((IShellInteractionService)containingModule.GetType().GetProperty("ShellInteractionService").GetValue(containingModule, null)).Close(OmsControl);
                        }
                    }
                    else
                    {
                        ShellInteractionService.Close(OmsControl);
                    }

                    WorkItem.SmartParts.Remove(OmsControl);
                    OpenTabs.Remove(OmsControl);
                    if (OpenTabs.Count == 0 && isWindowCloseRequested)
                    {
                        // user has requested to close the window and no open programs remain
                        Application.Current.MainWindow.Close();
                    }
                    break;

                case dvWinType.Modal:
                    // currently not used
                    break;

                case dvWinType.Float:
                    // currently not used
                    break;
                }
            };

            TrimControl.evTitleWin += (s, args) =>
            {
                // set title and description (as tooltip on tab)
                string   programInfo      = (string)((FrameworkElement)TrimControl).Tag;
                char[]   c                = { ' ' };
                string[] programInfoSplit = programInfo.Split(c);
                string   title            = programInfoSplit[0];
                int      titleLength      = title.Length;
                if (OmsControl.ParentProgram != null)
                {
                    string parentTitle = OmsControl.ParentProgram.ProgramName;
                    title = parentTitle + " > " + title;
                }
                OmsControl.ProgramName = title;
                string description = null;
                if (programInfo.Length > titleLength)
                {
                    description = programInfo.Substring(titleLength + 1).Trim();
                    OmsControl.ProgramDescription = description;
                }

                if (startParametersDictionary.ContainsKey(title))
                {
                    string startParams = startParametersDictionary[title];
                    OmsControl.StartParameters = startParams;
                    startParametersDictionary.Remove(title);
                }

                //System.Diagnostics.Debug.WriteLine("Setting title on Dialog " + OmsControl.Id + " to " + title);

                switch (e.Type)
                {
                case dvWinType.Main:
                    spInfo             = new SmartPartInfo();
                    spInfo.Title       = title;
                    spInfo.Description = description;
                    ShellInteractionService.Show(OmsControl, spInfo);

                    break;

                case dvWinType.Float:
                    // currently not used
                    break;
                }
            };

            if (workbenchParentView != null)
            {
                // backend is about to start a new sub program to a workbench
                workbenchParentView.AddChildProgram(OmsControl);
                OmsControl.ParentProgram = workbenchParentView;
                workbenchParentView      = null;
            }

            TrimControl.evSendString += (s, args) =>
            {
                // event received when starting and stopping workbench programs
                // or when the actions menu is to be updated
                string receivedStr = (string)((FrameworkElement)TrimControl).Tag;
                receivedStr = System.Web.HttpUtility.HtmlDecode(receivedStr);
                if (receivedStr.StartsWith("startProgram"))
                {
                    OmsControl.IsWorkbenchParent = true;
                    workbenchParentView          = OmsControl;
                    dvStart TrimStartClient = new dvStart();
                    TrimStartClient.evCreate += new EventHandler <dvEventArgs>(InitializeWorkbenchWindowHandler);
                    try
                    {
                        string startWorkbenchProgXML = createStartWorkbenchProgramXml(receivedStr);
                        TrimStartClient.newWindow(startWorkbenchProgXML);
                    }
                    catch (SecurityTokenExpiredException ex)
                    { }
                }
                else if (receivedStr.StartsWith("stopProgram"))
                {
                    foreach (IDialogView childProgram in OmsControl.GetChildPrograms())
                    {
                        object childObject = childProgram.TrimControl;
                        if (childObject is inUC)
                        {
                            inUC childControl = childObject as inUC;
                            childControl.requestClose();
                        }
                    }
                }
                else if (receivedStr.StartsWith("actions:"))
                {
                    OmsControl.ShowActions(receivedStr.Substring(8));
                }
                else if (receivedStr.StartsWith("savesearch:"))
                {
                    OmsControl.SaveSeach(receivedStr.Substring(11));
                }
                else if (receivedStr.StartsWith("savedashboard:"))
                {
                    OmsControl.SaveInDashboard(receivedStr.Substring(14));
                }
            };
        }
 public void RemoveChildProgram(IDialogView childProgram)
 {
     childPrograms.Remove(childProgram);
 }