コード例 #1
0
        public void Can_repeat()
        {
            //arrange
            var history = new HistoryBuffer <string>();

            string currentItem = null, previousItem = null;

            history.HistoryRepeated += delegate(object sender, HistoryEventArgs <string> args)
            {
                args.TryGetCurrentItem(out currentItem);
                args.TryGetPreviousItem(out previousItem);
            };

            //act
            history.RememberNew("first item");
            history.RememberNew("second item");
            history.Undo();
            history.Repeat();

            //assert
            currentItem.Should().Be("second item");
            previousItem.Should().Be("first item");

            history.CurrentItem.Should().Be("second item");
            history.Count.Should().Be(2);
        }
コード例 #2
0
ファイル: Macros.cs プロジェクト: BdGL3/CXPortal
 public Macro (string name)
 {
     Name = name;
     Buffer = new HistoryBuffer();
     PseudoColor = new HistoryPseudoColor();
     Histogram = new HistoryHistogram();
 }
コード例 #3
0
        public void Can_overflow_limited_history()
        {
            //arrange
            var history = new HistoryBuffer <string>(maxSize: 2);

            string currentItem = null, previousItem = null;

            history.HistoryOverflowed += delegate(object sender, HistoryEventArgs <string> args)
            {
                args.TryGetCurrentItem(out currentItem);
                args.TryGetPreviousItem(out previousItem);
            };

            //act
            history.RememberNew("first item");
            history.RememberNew("second item");
            history.RememberNew("third item");

            //assert
            currentItem.Should().Be("third item");
            previousItem.Should().Be("second item");

            history.GetAll().ToArray().Should().BeEquivalentTo(new[]
            {
                "second item", "third item"
            });
        }
コード例 #4
0
        public void Can_forget_current_item()
        {
            //arrange
            var history = new HistoryBuffer <string>();

            string forgottenItem = null;

            history.CurrentItemForgotten += delegate(object sender, HistoryEventArgs <string> args)
            {
                args.TryGetPreviousItem(out forgottenItem);
            };

            //act
            history.RememberNew("new item");
            history.ForgetCurrent();

            //assert
            forgottenItem.Should().Be("new item");

            Action getCurrentItem = () =>
            {
                var currentItem = history.CurrentItem;
            };

            getCurrentItem.ShouldThrow <HistoryIsEmptyException>();

            history.Count.Should().Be(0);
        }
コード例 #5
0
ファイル: Macros.cs プロジェクト: marzlia/CXPortal
 public Macro(string name)
 {
     Name        = name;
     Buffer      = new HistoryBuffer();
     PseudoColor = new HistoryPseudoColor();
     Histogram   = new HistoryHistogram();
 }
コード例 #6
0
        private void m_ToolBarItem_Click(Object sender, RoutedEventArgs e)
        {
            ApplyFilter(true);

            HistoryBuffer buffer = new HistoryBuffer();

            buffer.name = m_Name;
            m_History.AddStep(buffer);
        }
コード例 #7
0
        public void Should_remove_obsolete_items_after_adding_new_one()
        {
            //arrange
            var history = new HistoryBuffer <string>();

            //act
            history.RememberNew("first item");
            history.RememberNew("second item");
            history.Undo();
            history.RememberNew("third item");

            //assert
            history.CurrentItem.Should().Be("third item");
            history.Count.Should().Be(2);
        }
コード例 #8
0
        public void Can_clear_history()
        {
            //arrange
            var history = new HistoryBuffer <string>(maxSize: 2);

            //act
            history.RememberNew("first item");
            history.RememberNew("second item");
            history.RememberNew("third item");

            history.Clear();

            //assert
            history.Count.Should().Be(0);
            history.GetAll().ToArray().Should().BeEmpty();
        }
コード例 #9
0
        public void Can_remember_new_item()
        {
            //arrange
            var history = new HistoryBuffer <string>();

            string rememberedItem = null;

            history.NewItemRemembered += delegate(object sender, HistoryEventArgs <string> args)
            {
                args.TryGetCurrentItem(out rememberedItem);
            };

            //act
            history.RememberNew("new item");

            //assert
            rememberedItem.Should().Be("new item");
            history.CurrentItem.Should().Be("new item");
            history.Count.Should().Be(1);
        }
コード例 #10
0
        public InMemoryPersistenceProvider(ILoggerFactory loggerFactory)
        {
            _valueBuffer = new HistoryBuffer <string, Value>
            {
                DefaultMaxHistoryEntries  = 200,
                DefaultMaxHistoryLivetime = TimeSpan.Zero
            };

            _deviceInfos   = new Dictionary <DeviceId, DeviceInfo>();
            _messageBuffer = new MessageBuffer();
            _jobBuffer     = new JobBuffer();
            Logger         = loggerFactory.CreateLogger <InMemoryPersistenceProvider>();


            // FIXME Persistence

            var devices = "devices";
            var dirname = Path.Combine(Directory.GetCurrentDirectory(), devices);

            if (Directory.Exists(dirname))
            {
                foreach (var fullFileName in Directory.GetFiles(dirname))
                {
                    var lines = File.ReadAllLines(fullFileName);

                    if (lines != null && lines.Length > 0)
                    {
                        var filename = Path.GetFileName(fullFileName);

                        var jsonString = string.Join("", lines);
                        var deviceInfo = JsonConvert.DeserializeObject <DeviceInfo>(jsonString, new JsonSerializerSettings
                        {
                            NullValueHandling = NullValueHandling.Ignore
                        });

                        _deviceInfos.Add(new DeviceId(filename), deviceInfo);
                    }
                }
            }
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: Tymolc/drh-visual-odometry
		static void Main(string[] args)
		{
			try
			{



				HistoryBuffer<int> history = new HistoryBuffer<int>(7);
				history.PrintContent("Empty -------");
				history.Add(1);
				history.Add(2);
				history.Add(3);
				history.PrintContent("3 in ------");
				history.Add(4);
				history.Add(5);
				history.Add(6);
				history.Add(7);
				history.PrintContent("Should be full ------");
				history.Add(8);
				history.Add(9);
				history.PrintContent("2 recycled ------");


				//IntrinsicCameraParameters intrinsicCameraParameters = new IntrinsicCameraParameters();
				//// We initialize the intrinsic matrix such that the two focal lengths have a ratio of 1.0
				//intrinsicCameraParameters.IntrinsicMatrix[0, 0] = 1.0;
				//intrinsicCameraParameters.IntrinsicMatrix[1, 1] = 1.0;

				//intrinsicCameraParameters.IntrinsicMatrix.Save("IntrinsixMatrix.xml");

			}
			catch (Exception ex)
			{
				Console.WriteLine(ex);
			}
			finally
			{
				Console.ReadLine();
			}
		}
コード例 #12
0
ファイル: XRayView.xaml.cs プロジェクト: marzlia/CXPortal
        public void Setup(ViewObject content, History history, SysConfiguration sysConfig)
        {
            if (!IsSetup)
            {
                m_ViewObject = content;

                m_History = history;
                m_History.CurrentHistoryChangedEvent += new CurrentHistoryChanged(ApplyHistory);

                if (m_ViewObject.HighEnergy != null)
                {
                    m_SourceObject = m_ViewObject.HighEnergy;
                    HEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/HEOn.png", UriKind.Relative));
                    LEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/LEOff.png", UriKind.Relative));
                }
                else if (m_ViewObject.LowEnergy != null)
                {
                    m_SourceObject = m_ViewObject.LowEnergy;
                    HEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/HEOff.png", UriKind.Relative));
                    LEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/LEOn.png", UriKind.Relative));
                }
                else
                {
                    throw new Exception();
                }

                if (m_ViewObject.LowEnergy == null ||
                    m_ViewObject.HighEnergy == null)
                {
                    XRayDualEnergy_ToolBar.Visibility = Visibility.Collapsed;
                }
                else
                {
                    HistoryDualEnergy dualEnergy = new HistoryDualEnergy();
                    dualEnergy.name = "HighEnergy";
                    m_History.SetFirstStep(dualEnergy);
                }

                if (sysConfig != null)
                {
                    m_sysConfig = sysConfig;
                    CreateUserMacroControls();
                    Macro_Toolbar.Visibility = Visibility.Visible;
                }

                CreateBufferControls();

                CreateFilterControls();

                CreateColorMappingControls();

                MainImage.Source = m_SourceObject.Source;
                MainImage.Height = m_SourceObject.Height;
                MainImage.Width  = m_SourceObject.Width;

                HistoryBuffer buffer = new HistoryBuffer();
                buffer.name = "Original Gray Scale";

                m_History.SetFirstStep(buffer);

                HistoryList.DataContext = m_History.Step;

                IsApplyHistoryFromSetup = true;

                m_History.ApplyStep();

                IsApplyHistoryFromSetup = false;

                IsSetup = true;
            }
        }
コード例 #13
0
ファイル: VoltWorld.cs プロジェクト: slawo/VolatilePhysics
 internal void FreeHistory(HistoryBuffer history)
 {
     this.historyPool.Deallocate(history);
 }
コード例 #14
0
ファイル: Buffer.cs プロジェクト: BdGL3/CXPortal
        private void m_ToolBarItem_Click(Object sender, RoutedEventArgs e)
        {
            ApplyFilter(true);

            HistoryBuffer buffer = new HistoryBuffer();
            buffer.name = m_Name;
            m_History.AddStep(buffer);
        }
コード例 #15
0
ファイル: XRayView.xaml.cs プロジェクト: BdGL3/CXPortal
        public void Setup (ViewObject content, History history, SysConfiguration sysConfig)
        {
            if (!IsSetup)
            {
                m_ViewObject = content;

                m_History = history;
                m_History.CurrentHistoryChangedEvent += new CurrentHistoryChanged(ApplyHistory);

                if (m_ViewObject.HighEnergy != null)
                {
                    m_SourceObject = m_ViewObject.HighEnergy;
                    HEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/HEOn.png", UriKind.Relative));
                    LEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/LEOff.png", UriKind.Relative));
                }
                else if (m_ViewObject.LowEnergy != null)
                {
                    m_SourceObject = m_ViewObject.LowEnergy;
                    HEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/HEOff.png", UriKind.Relative));
                    LEImage.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/LEOn.png", UriKind.Relative));
                }
                else
                {
                    throw new Exception();
                }

                if (m_ViewObject.LowEnergy == null ||
                    m_ViewObject.HighEnergy == null)
                {
                    XRayDualEnergy_ToolBar.Visibility = Visibility.Collapsed;
                }
                else
                {
                    HistoryDualEnergy dualEnergy = new HistoryDualEnergy();
                    dualEnergy.name = "HighEnergy";
                    m_History.SetFirstStep(dualEnergy);
                }

                if (sysConfig != null)
                {
                    m_sysConfig = sysConfig;
                    CreateUserMacroControls();
                    Macro_Toolbar.Visibility = Visibility.Visible;
                }

                CreateBufferControls();

                CreateFilterControls();

                CreateColorMappingControls();

                MainImage.Source = m_SourceObject.Source;
                MainImage.Height = m_SourceObject.Height;
                MainImage.Width = m_SourceObject.Width;
                
                HistoryBuffer buffer = new HistoryBuffer();
                buffer.name = "Original Gray Scale";

                m_History.SetFirstStep(buffer);

                HistoryList.DataContext = m_History.Step;

                IsApplyHistoryFromSetup = true;

                m_History.ApplyStep();

                IsApplyHistoryFromSetup = false;

                IsSetup = true;
            }
        }