// TODO: Use an interface for view
        public TestCentricPresenter(IMainView view, ITestModel model, CommandLineOptions options)
        {
            _view    = view;
            _model   = model;
            _options = options;

            _settings    = _model.Settings;
            _recentFiles = _model.RecentFiles;

            _agentSelectionController = new AgentSelectionController(_model, _view);

            _view.Font = _settings.Gui.Font;
            _view.ResultTabs.SelectedIndex = _settings.Gui.SelectedTab;

            SetTreeDisplayFormat(_settings.Gui.TestTree.DisplayFormat);

            UpdateViewCommands();
            _view.StopRunMenuCommand.Visible   = true;
            _view.StopRunButton.Visible        = true;
            _view.ForceStopMenuCommand.Visible = false;
            _view.ForceStopButton.Visible      = false;
            _view.RunSummaryButton.Visible     = false;

            foreach (string format in _model.ResultFormats)
            {
                if (format != "cases" && format != "user")
                {
                    _resultFormats.Add(format);
                }
            }

            WireUpEvents();
        }
Esempio n. 2
0
            public TAStudioSettings()
            {
                RecentTas                   = new RecentFiles(8);
                AutoPause                   = true;
                FollowCursor                = true;
                ScrollSpeed                 = 6;
                FollowCursorAlwaysScroll    = false;
                FollowCursorScrollMethod    = "near";
                BranchCellHoverInterval     = 1;
                SeekingCutoffInterval       = 2;
                AutosaveInterval            = 120000;
                AutosaveAsBk2               = false;
                AutosaveAsBackupFile        = false;
                BackupPerFileSave           = false;
                SingleClickAxisEdit         = false;
                OldControlSchemeForBranches = false;
                LoadBranchOnDoubleClick     = true;
                CopyIncludesFrameNo         = false;

                // default to taseditor fashion
                DenoteStatesWithIcons    = false;
                DenoteStatesWithBGColor  = true;
                DenoteMarkersWithIcons   = false;
                DenoteMarkersWithBGColor = true;

                Palette = TAStudioPalette.Default;
            }
 public void SetUp()
 {
     menu    = new MenuItem();
     files   = new FakeRecentFiles();
     handler = new RecentFileMenuHandler(menu, files);
     handler.CheckFilesExist = false;
 }
Esempio n. 4
0
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (UI.Handler != null && UI.Handler.HasUnsavedChanges)
            {
                if (UI.Handler.IsConnected)
                {
                    // Handle undeployed changes to connected model:
                    var res = MessageBox.Show("You have made changes to the currently connected model, which have not yet been saved. Are you sure you want to quit?", "Unsaved changes in the model", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (res == DialogResult.Cancel)
                    {
                        e.Cancel = true;
                    }
                }
                else
                {
                    // Handle unsaved changes to file:
                    var res = MessageBox.Show("You have made changes to the currently loaded Model.bim file, which have not yet been saved. Are you sure you want to quit?", "Unsaved changes in the model", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (res == DialogResult.Cancel)
                    {
                        e.Cancel = true;
                    }
                }
            }

            RecentFiles.Save();
        }
Esempio n. 5
0
        public void OpenInternal(string filename, bool newWindow)
        {
            MessageBoxService.SetOwner(Application.Current.MainWindow);

            if (newWindow)
            {
                Process.Start(Process.GetCurrentProcess().MainModule.FileName, filename);
                return;
            }

            CloseCommand.Execute(null);
            try {
                PEFile   = new PEFile(_stm = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), false);
                PEHeader = PEFile.Header;
                if (PEHeader == null)
                {
                    throw new InvalidOperationException("No PE header detected.");
                }
                FileName = Path.GetFileName(filename);
                PathName = filename;
                RaisePropertyChanged(nameof(Title));
                MapFile();

                BuildTree();
                RecentFiles.Remove(PathName);
                RecentFiles.Insert(0, PathName);
                if (RecentFiles.Count > 10)
                {
                    RecentFiles.RemoveAt(RecentFiles.Count - 1);
                }
            }
            catch (Exception ex) {
                MessageBoxService.ShowMessage($"Error: {ex.Message}", Constants.AppName);
            }
        }
		public void SetUp()
		{
			menu = new MenuItem();
			files = new FakeRecentFiles();
			handler = new RecentFileMenuHandler( menu, files );
            handler.CheckFilesExist = false;
        }
Esempio n. 7
0
        public void AddRecentFile(string recentFile)
        {
            if (!File.Exists(recentFile))
            {
                return;
            }

            int index = RecentFiles.IndexOf(recentFile);

            if (index < 0)
            {
                if (RecentFiles.Count < MaxRecentFileCount)
                {
                    RecentFiles.Add(string.Empty);
                }

                for (int i = RecentFiles.Count - 2; i >= 0; i--)
                {
                    RecentFiles[i + 1] = RecentFiles[i];
                }
                RecentFiles[0] = recentFile;
            }
            else if (index > 0)
            {
                string temp = RecentFiles[index];
                for (int i = index; i > 0; i--)
                {
                    RecentFiles[i] = RecentFiles[i - 1];
                }
                RecentFiles[0] = temp;
            }
        }
        public void ClearRecentFiles()
        {
            RecentFiles.Clear();

            Save();
            Updated?.Invoke(this, EventArgs.Empty);
        }
        public void AddFile(RecentFile fileToAdd)
        {
            if (fileToAdd is null)
            {
                return;
            }

            //if it already exists, remove it (will be added on top later)
            for (var i = 0; i < RecentFiles.Count; i++)
            {
                if (string.Equals(RecentFiles[i].Path, fileToAdd.Path, StringComparison.OrdinalIgnoreCase))
                {
                    RecentFiles.RemoveAt(i);
                    break;
                }
            }

            //add to top
            RecentFiles.Insert(0, fileToAdd);

            EnsureMaxiumItemCount();

            Save();

            Updated?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 10
0
        // TODO: Use an interface for view
        public TestCentricPresenter(IMainView view, ITestModel model, CommandLineOptions options)
        {
            _view    = view;
            _model   = model;
            _options = options;

            _settings    = _model.Settings;
            _recentFiles = _model.RecentFiles;
            _runtimeSelectionController = new RuntimeSelectionController(_view.RuntimeMenu, _model);

            _view.Font = _settings.Gui.Font;
            _view.ResultTabs.SelectedIndex = _settings.Gui.SelectedTab;

            UpdateViewCommands();

            foreach (string format in _model.ResultFormats)
            {
                if (format != "cases" && format != "user")
                {
                    _resultFormats.Add(format);
                }
            }

            WireUpEvents();
        }
 private void EnsureMaxiumItemCount()
 {
     while (RecentFiles.Count > MaximumItemCount)
     {
         RecentFiles.RemoveAt(RecentFiles.Count - 1);
     }
 }
        public void File_SaveAs_ToFolder()
        {
            using (var fbd = new CommonOpenFileDialog()
            {
                IsFolderPicker = true
            })
            {
                var res = fbd.ShowDialog();
                if (res == CommonFileDialogResult.Ok && !string.IsNullOrWhiteSpace(fbd.FileName))
                {
                    UI.StatusLabel.Text = "Saving...";
                    Handler.Save(fbd.FileName, SaveFormat.TabularEditorFolder, Preferences.Current.GetSerializeOptions(true));

                    RecentFiles.Add(fbd.FileName);
                    UI.FormMain.PopulateRecentFilesList();

                    // If working with a file, change the current file pointer:
                    if (Handler.SourceType != ModelSourceType.Database)
                    {
                        File_SaveMode = ModelSourceType.Folder;
                        File_Current  = fbd.FileName;
                    }

                    UpdateUIText();
                }
            }
        }
            /// <summary>
            /// Writes the type to XML.
            /// </summary>
            /// <param name="property">The property to serialize.</param>
            /// <param name="writer">The XML writer.</param>
            internal static void WriteType(object property, XmlTextWriter writer)
            {
                RecentFiles recentFiles = (RecentFiles)property;

                writer.WriteAttributeString(SeralizeAsAttribute, SeralizeAs.RecentFiles.ToString());
                writer.WriteValue(recentFiles);
            }
Esempio n. 14
0
        public void File_SaveAs()
        {
            ExpressionEditor_AcceptEdit();

            var res = UI.SaveBimDialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                using (new Hourglass())
                {
                    UI.StatusLabel.Text = "Saving...";
                    Handler.Save(UI.SaveBimDialog.FileName, SaveFormat.ModelSchemaOnly, Preferences.Current.GetSerializeOptions(false));

                    RecentFiles.Add(UI.SaveBimDialog.FileName);
                    UI.FormMain.PopulateRecentFilesList();

                    // If not connected to a database, change the current working file:
                    if (Handler.SourceType != ModelSourceType.Database)
                    {
                        File_Current  = UI.SaveBimDialog.FileName;
                        File_SaveMode = ModelSourceType.File;
                    }

                    UpdateUIText();
                }
            }
        }
Esempio n. 15
0
 private void InitializeRecentFiles()
 {
     if (Settings.Default.recentFiles != null)
     {
         RecentFiles.AddRange(Settings.Default.recentFiles.Cast <string>());
     }
 }
Esempio n. 16
0
 public TAStudioSettings()
 {
     RecentTas    = new RecentFiles(8);
     DrawInput    = true;
     AutoPause    = true;
     FollowCursor = true;
 }
Esempio n. 17
0
        private void SaveRecentFile(string fileName)
        {
            // Clear the recent files list
            // and add this file to the top.
            RecentFiles.Clear();
            RecentFiles.Add(fileName);

            var i = 0;

            while (i < 2 &&
                   Settings.Default.recentFiles != null &&
                   Settings.Default.recentFiles.Count > i)
            {
                var recentPath = Settings.Default.recentFiles[i];

                // Only add the path if it isn't already
                // in the list.
                if (!RecentFiles.Contains(recentPath))
                {
                    RecentFiles.Add(Settings.Default.recentFiles[i]);
                }

                i++;
            }

            var sc = new StringCollection();

            sc.AddRange(RecentFiles.ToArray());
            Settings.Default.recentFiles = sc;
            Settings.Default.Save();
        }
Esempio n. 18
0
        public void Init(HashTableSettings gSettings, Ribbon mainRibbon)
        {
            ribbon = mainRibbon;

            devSettings = (bool)gSettings["DeveloperMode"];

            appDir         = Application.StartupPath + "\\";
            globalSettings = gSettings;

            // load recent files
            if (File.Exists(appDir + "recentFiles.xml"))
            {
                recentFiles = RecentFiles.LoadFromFile(appDir + "recentFiles.xml");
                recentFiles.ClearDeadEntires();
            }
            else
            {
                recentFiles = new RecentFiles();
            }

            RebuildRecentFilesMenu();

            baseDir = /*(string)gSettings["Base.Path"];*/ Path.GetFullPath(ConfigurationManager.AppSettings[(devSettings ? "dev@" : "") + "Base.Path.Relative"].Replace("%STARTUP%", Application.StartupPath));
            if (!Directory.Exists(baseDir))
            {
                throw new ApplicationException("Base directory does not exist! : " + baseDir);
            }

            cdi = ICommonDeviceInterface.NewInterface((byte)globalSettings["CDI.Adapter"], baseDir);
            cdi.ResourceLoader.RegisterContentLoader(new LayerContentLoader());
            cdi.ResourceLoader.RegisterContentLoader(new BooScriptContentLoader());

            ShowHideGroups(false);
        }
        protected override void Run()
        {
            if (!Taskbar.TaskbarManager.IsPlatformSupported)
            {
                return;
            }

            bool areFileExtensionsRegistered = this.Initialize();

            if (!areFileExtensionsRegistered)
            {
                return;
            }

            this.updateTimer           = new Timer(1000);
            this.updateTimer.Elapsed  += this.OnUpdateTimerEllapsed;
            this.updateTimer.AutoReset = false;

            this.recentFiles          = DesktopService.RecentFiles;
            this.recentFiles.Changed += this.OnRecentFilesChanged;

            try {
                UpdateJumpList();
            } catch (Exception ex) {
                MonoDevelop.Core.LoggingService.LogError("Could not update jumplists", ex);
            }
        }
		public void SetUp()
		{
			menu = new MenuItem();
			files = new FakeRecentFiles();
			handler = new RecentFileMenuHandler( menu, files );
            handler.ShowMissingFiles = true;
        }
Esempio n. 21
0
        private void OnClick_DeleteRecentFile(object sender, RoutedEventArgs e)
        {
            var listToRemove = new List <RecentFileWrapper>(RecentFiles);

            foreach (var wrapper in listToRemove)
            {
                if (wrapper.IsChecked)
                {
                    int index = RecentFiles.IndexOf(wrapper);
                    foreach (var uri in m_Session.RecentFiles)
                    {
                        if (uri.ToString() == wrapper.Uri.ToString())
                        {
                            int index_ = m_Session.RecentFiles.IndexOf(uri);
                            //DebugFix.Assert(index == index_);
                            index = index_;
                            break;
                        }
                    }
                    m_Session.RecentFiles.RemoveAt(index);
                    RecentFiles.Remove(wrapper);
                }
            }
            m_Session.SaveRecentFiles();
        }
Esempio n. 22
0
        public TestModel(ITestEngine testEngine, string applicationPrefix = null)
        {
            TestEngine       = testEngine;
            _settingsService = new SettingsService(true);
            _events          = new TestEventDispatcher(this);
            _assemblyWatcher = new AssemblyWatcher();

            _settingsService.LoadSettings();
            Settings    = new UserSettings(_settingsService, applicationPrefix);
            RecentFiles = new RecentFiles(_settingsService, applicationPrefix);

            Services = new TestServices(testEngine);

            foreach (var node in Services.ExtensionService.GetExtensionNodes(PROJECT_LOADER_EXTENSION_PATH))
            {
                if (node.TypeName == NUNIT_PROJECT_LOADER)
                {
                    NUnitProjectSupport = true;
                }
                else if (node.TypeName == VISUAL_STUDIO_PROJECT_LOADER)
                {
                    VisualStudioSupport = true;
                }
            }
        }
Esempio n. 23
0
            public TAStudioSettings()
            {
                RecentTas                   = new RecentFiles(8);
                DrawInput                   = true;
                AutoPause                   = true;
                FollowCursor                = true;
                ScrollSpeed                 = 6;
                FollowCursorAlwaysScroll    = false;
                FollowCursorScrollMethod    = "near";
                BranchCellHoverInterval     = 1;
                SeekingCutoffInterval       = 2;
                AutoRestoreOnMouseUpOnly    = false;
                AutosaveInterval            = 120000;
                AutosaveAsBk2               = false;
                AutosaveAsBackupFile        = false;
                BackupPerFileSave           = false;
                SingleClickFloatEdit        = false;
                OldControlSchemeForBranches = false;
                LoadBranchOnDoubleClick     = true;

                // default to taseditor fashion
                DenoteStatesWithIcons    = false;
                DenoteStatesWithBGColor  = true;
                DenoteMarkersWithIcons   = false;
                DenoteMarkersWithBGColor = true;
            }
Esempio n. 24
0
 public void SetUp()
 {
     menu    = new MenuItem();
     files   = new FakeRecentFiles();
     handler = new RecentFileMenuHandler(menu, files);
     handler.ShowMissingFiles = true;
 }
Esempio n. 25
0
        private void OpenFile(FileInfo file)
        {
            _schedulerProvider.Background.Schedule(() =>
            {
                try
                {
                    _logger.Info($"Attempting to open '{file.FullName}'");

                    RecentFiles.Add(file);

                    //1. resolve TailViewModel
                    var factory   = _objectProvider.Get <TailViewModelFactory>();
                    var viewModel = factory.Create(file);

                    //2. Display it
                    var newItem = new ViewContainer(new FileHeader(file), viewModel);

                    _windowsController.Register(newItem);

                    _logger.Info($"Objects for '{file.FullName}' has been created.");
                    //do the work on the ui thread
                    _schedulerProvider.MainThread.Schedule(() =>
                    {
                        Views.Add(newItem);
                        _logger.Info($"Opened '{file.FullName}'");
                        Selected = newItem;
                    });
                }
                catch (Exception ex)
                {
                    //TODO: Create a failed to load view
                    _logger.Error(ex, $"There was a problem opening '{file.FullName}'");
                }
            });
        }
Esempio n. 26
0
        public static void HandleLoadError(this RecentFiles recent, string path, string encodedPath = null)
        {
            GlobalWin.Sound.StopSound();
            if (recent.Frozen)
            {
                var result = MessageBox.Show("Could not open " + path, "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // ensure topmost, not to have to minimize everything to see and use our modal window, if it somehow got covered
                var result = MessageBox.Show(new Form()
                {
                    TopMost = true
                }, "Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (result == DialogResult.Yes)
                {
                    if (encodedPath != null)
                    {
                        recent.Remove(encodedPath);
                    }
                    else
                    {
                        recent.Remove(path);
                    }
                }
            }

            GlobalWin.Sound.StartSound();
        }
Esempio n. 27
0
        /// <summary>
        /// Sets the recently opened map and tilesets in the menu strip.
        /// </summary>
        public void ChangedRecentFiles()
        {
            RecentFiles.GetPaths(out List <string> maps, out List <string> tilesets);

            AddRecentPaths(recentlyOpenedMapsToolStripMenuItem, maps, OnMapLoad);
            AddRecentPaths(recentlyOpenedTilesetsToolStripMenuItem, tilesets, OnTilesetLoad);
        }
Esempio n. 28
0
        public ClickAndQueryForm()
        {
            InitializeComponent();
            new SelfRegisteringWatch(new ControlPreferences.FormWatch(this));
            new SelfRegisteringWatch(new ControlPreferences.SplitContainerWatch(_splitContainer));
            _recentFiles = new RecentFiles(_fileToolStripMenuItem, _recentFilesSeparator, RecentFileClickedHandler);


            //
            // Bind our commands to their menus
            new DelegateCommand(delegate { NewDocument(); }).Bind(_newToolStripMenuItem);
            new DelegateCommand(delegate { OpenFile(); }).Bind(_openToolStripMenuItem);
            new DelegateCommand(delegate { Save(); }).Bind(_saveToolStripMenuItem);
            new DelegateCommand(delegate { SaveAs(); }).Bind(_saveAsToolStripMenuItem);
            new DelegateCommand(delegate { Close(); }).Bind(_exitToolStripMenuItem);
            new DelegateCommand(delegate { CopyToClipboard(); }).Bind(_copyToolStripMenuItem);
            new DelegateCommand(delegate { ShowOptionsForm(); }).Bind(_optionsToolStripMenuItem);
            new DelegateCommand(delegate { ShowAboutForm(); }).Bind(_aboutToolStripMenuItem);
            new DelegateCommand(delegate { _resultsControl.CancelQuery(); }, delegate { return(_resultsControl.IsQueryExecuting); }).Bind(_cancelToolStripMenuItem);
            new DelegateCommand(delegate { _resultsControl.SizeColumnsToFit(); }).Bind(_sizeColumnsToFitToolStripMenuItem);
            new DelegateCommand(delegate { ExecuteQuery(); }, delegate { return(_document != null && _document.Query.Length > 0); }).Bind(_executeToolStripMenuItem);
            new DelegateCommand(delegate { ShowConnectionDetailsForm(); }).Bind(_connectionDetailsToolStripMenuItem);


            ToolStripCommandHelper.BindToolStripItems(_menuStrip, _toolbarStrip);

            UpdateCaption();
        }
Esempio n. 29
0
        public void LoadTests(IList <string> files)
        {
            if (IsPackageLoaded)
            {
                UnloadTests();
            }

            _files   = files;
            _package = MakeTestPackage(files);

            Runner = _testEngine.GetRunner(_package);

            Tests = new TestNode(Runner.Explore(TestFilter.Empty));

            _resultIndex.Clear();

            if (TestLoaded != null)
            {
                TestLoaded(new TestNodeEventArgs(TestAction.TestLoaded, Tests));
            }

            foreach (var subPackage in _package.SubPackages)
            {
                RecentFiles.SetMostRecent(subPackage.FullName);
            }
        }
Esempio n. 30
0
        private void PopulateRecentFilesMethod(IEnumerable <SavedFileInfo> recentFiles)
        {
            RecentFiles.Clear();

            if (recentFiles != null)
            {
                foreach (var file in recentFiles)
                {
                    var fileInfo = new FileInfo(file.FilePath);
                    var menuItem = new MenuItem {
                        Header = fileInfo.FullName, Tag = file.FilePath
                    };
                    menuItem.Click += OnRecentFileClick;
                    RecentFiles.Add(menuItem);
                }
            }

            RecentFiles.Add(new Separator());
            var clearListMenuItem = new MenuItem {
                Header = "Clear Recent File List"
            };

            clearListMenuItem.Click += (sender, args) => ClearRecentFiles();
            RecentFiles.Add(clearListMenuItem);

            RaisePropertyChanged("RecentFiles");
        }
Esempio n. 31
0
 void LoadSettings()
 {
     if (Settings.Default.RecentFiles != null)
     {
         RecentFiles.AddRange(Settings.Default.RecentFiles.Cast <string>());
     }
 }
Esempio n. 32
0
        public void Check()
        {
            string[] ar = RecentFiles.FileNames;

            for (int i = 0; i < ar.Length; i++)
            {
                try
                {
                    if (!new System.IO.FileInfo(ar[i]).Exists)
                    {
                        ar[i] = "";
                    }
                }
                catch (Exception)
                {
                    ar[i] = "";
                }
            }

            var v1 = ar.Where((s) => !s.Equals("")).Select((s, index) => new { s, index });
            var v2 = v1.Distinct();
            var v3 = v2.OrderBy((index) => index);
            var v4 = v3.Take(Count);

            RecentFiles.Clear();
            v2.Take(20).ForEach((v) => RecentFiles.Add(v.s));

            LastOpenFile = CheckFileName(LastOpenFile);
            LastOpenDir  = CheckDirectory(LastOpenDir);
        }
Esempio n. 33
0
		public NUnitForm( GuiOptions guiOptions ) : base("NUnit")
		{
			InitializeComponent();

			this.guiOptions = guiOptions;
			this.recentFilesService = Services.RecentFiles;
			this.userSettings = Services.UserSettings;

            this.presenter = new NUnitPresenter(this, TestLoader);
		}
Esempio n. 34
0
        public NUnitForm( CommandLineOptions commandLineOptions )
        {
            InitializeComponent();

            this.commandLineOptions = commandLineOptions;
            this.recentFilesService = Services.RecentFiles;
            this.userSettings = Services.UserSettings;
        }
        public NUnitArxNetForm(GuiOptions guiOptions)
        {
            InitializeComponent();

            this.guiOptions = guiOptions;
            this.recentFilesService = Services.RecentFiles;
            this.userSettings = Services.UserSettings;
        }
Esempio n. 36
0
 public RecentFileMenuHandler( MenuItem menu, RecentFiles recentFiles )
 {
     this.menu = menu;
     this.recentFiles = recentFiles;
 }
        public NUnitFormArxNet( GuiOptions guiOptions )
            : base("NUnit")
        {
            InitializeComponent();

            this.guiOptions = guiOptions;
            this.recentFilesService = ServicesArxNet.RecentFiles;
            this.userSettings = ServicesArxNet.UserSettings;

            this.presenter = new NUnitPresenterArxNet(this, TestLoader);

            //����ǰһCAD��ĵ�
            //prevActiveDocument = CADApplication.DocumentManager.MdiActiveDocument;
            //CADApplication.DocumentManager.MdiActiveDocument.Window.h
        }