Esempio n. 1
0
        private void LocalVariablesSource_OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (Favorites == null && RecentlyUsed == null)
            {
                return;
            }
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Reset:
                var variables = LocalVariablesSource.ToSet();
                if (Favorites != null)
                {
                    Favorites.RemoveAll(data => data.Key == FormulaEditorKey.LocalVariable && !variables.Contains(data.LocalVariable));
                }
                if (RecentlyUsed != null)
                {
                    RecentlyUsed.RemoveAll(data => data.Key == FormulaEditorKey.LocalVariable && !variables.Contains(data.LocalVariable));
                }
                break;

            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Replace:
                var deletedVariables = e.OldItems.Cast <LocalVariable>().ToSet();
                if (Favorites != null)
                {
                    Favorites.RemoveAll(data => data.Key == FormulaEditorKey.LocalVariable && deletedVariables.Contains(data.LocalVariable));
                }
                if (RecentlyUsed != null)
                {
                    RecentlyUsed.RemoveAll(data => data.Key == FormulaEditorKey.LocalVariable && deletedVariables.Contains(data.LocalVariable));
                }
                break;
            }
        }
Esempio n. 2
0
        public void ChangedEvent()
        {
            int changedCount = 0;

            var recent = new RecentlyUsed();

            recent.Changed += (o, i) => { changedCount++; };

            recent.Push(@"C:\test1.txt");
            Assert.Equal(1, changedCount);

            recent.Push(@"C:\test2.txt");
            Assert.Equal(2, changedCount);

            recent.Remove(@"C:\test2.txt");
            Assert.Equal(3, changedCount);

            recent.Remove(@"C:\test2.txt");
            Assert.Equal(3, changedCount);

            recent.Clear();
            Assert.Equal(4, changedCount);

            recent.Clear();
            Assert.Equal(4, changedCount);
        }
Esempio n. 3
0
        public void InvalidFileName()
        {
            var recent = new RecentlyUsed(null);

            recent.Push(@"\\\");

            Assert.Equal(0, recent.Count);
        }
Esempio n. 4
0
 public void AddRecentlyUsed(string file)
 {
     RecentlyUsed.RemoveAll(f => f.Equals(file, StringComparison.CurrentCultureIgnoreCase));
     RecentlyUsed.Insert(0, file);
     if (RecentlyUsed.Count > 10)
     {
         RecentlyUsed = RecentlyUsed.Take(10).ToList();
     }
 }
Esempio n. 5
0
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));
            Hash.ToStream(output);
            Packs.ToStream(output);
            Sets.ToStream(output);
            Documents.ToStream(output);

            ShowStickersTab.NullableToStream(output);
            RecentlyUsed.NullableToStream(output);
            Date.NullableToStream(output);
        }
Esempio n. 6
0
        public void DuplicateEntry()
        {
            var recent = new RecentlyUsed(null);

            recent.Push(@"C:\test1.txt");
            recent.Push(@"C:\test2.txt");
            recent.Push(@"C:\test1.txt");

            Assert.Equal(2, recent.Count);
            Assert.Equal(@"C:\test1.txt", recent[0].FileName);
            Assert.Equal(@"C:\test2.txt", recent[1].FileName);
        }
Esempio n. 7
0
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));
            Hash.ToStream(output);
            Packs.ToStream(output);
            Sets.ToStream(output);
            Documents.ToStream(output);

            IsDefaultSetVisible.NullableToStream(output);
            RecentlyUsed.NullableToStream(output);
            Date.NullableToStream(output);
        }
Esempio n. 8
0
        public void LimitCount()
        {
            var recent = new RecentlyUsed(null, 2);

            recent.Push(@"C:\test1.txt");
            recent.Push(@"C:\test2.txt");
            recent.Push(@"C:\test3.txt");
            recent.Push(@"C:\test4.txt");

            Assert.Equal(2, recent.Count);
            Assert.Equal(@"C:\test4.txt", recent[0].FileName);
            Assert.Equal(@"C:\test3.txt", recent[1].FileName);
        }
Esempio n. 9
0
        public void FileExists()
        {
            var recent = new RecentlyUsed(null);

            var fileName = Path.GetTempFileName();

            try {
                recent.Push(fileName);
                Assert.True(recent[0].FileExists);
            } finally {
                File.Delete(fileName);
            }
            Assert.False(recent[0].FileExists);
        }
Esempio n. 10
0
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));
            HashValue.ToStream(output);
            Packs.ToStream(output);

            Sets.ToStream(output);
            Documents.ToStream(output);
            ShowStickersTab.NullableToStream(output);
            RecentlyUsed.NullableToStream(output);
            Date.NullableToStream(output);
            CustomFlags.ToStream(output);
            ToStream(output, RecentStickers, CustomFlags, (int)AllStickersCustomFlags.RecentStickers);
            ToStream(output, FavedStickers, CustomFlags, (int)AllStickersCustomFlags.FavedStickers);
            ToStream(output, _showStickersByEmoji, CustomFlags, (int)AllStickersCustomFlags.ShowStickersByEmoji);
        }
Esempio n. 11
0
        internal static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");

            Medo.Application.UnhandledCatch.ThreadException += new EventHandler <ThreadExceptionEventArgs>(UnhandledCatch_ThreadException);
            Medo.Application.UnhandledCatch.Attach();


            var recentLegacy = new RecentFiles();

            if (recentLegacy.Count > 0)
            {
                var fileList = new List <string>();
                foreach (var item in recentLegacy.Items)
                {
                    fileList.Add(item.FileName);
                }
                Recent = new RecentlyUsed(fileList);
                Config.Write("RecentFile", Recent.FileNames);
                recentLegacy.Clear();
            }
            else
            {
                Recent = new RecentlyUsed(Config.Read("RecentFile"));
            }
            Recent.Changed += (o, i) => {
                Config.Write("RecentFile", Recent.FileNames);
            };

            if (!Config.IsAssumedInstalled)
            {
                Medo.Windows.Forms.State.ReadState += delegate(object sender, Medo.Windows.Forms.StateReadEventArgs e) {
                    e.Value = Config.Read("State!" + e.Name.Replace("Bimil.", ""), e.DefaultValue);
                };
                Medo.Windows.Forms.State.WriteState += delegate(object sender, Medo.Windows.Forms.StateWriteEventArgs e) {
                    Config.Write("State!" + e.Name.Replace("Bimil.", ""), e.Value);
                };
            }

            App.MainForm = new MainForm();
            Application.Run(App.MainForm);

            SetupMutex.Close();
        }
Esempio n. 12
0
        public void Basic()
        {
            var recent = new RecentlyUsed();

            recent.Push(@"C:\test1.txt");
            recent.Push(@"C:\test2.txt");
            recent.Push(@"C:\test3.txt");
            recent.Push(@"C:\test4.txt");

            Assert.Equal(4, recent.Count);
            Assert.Equal(@"C:\test4.txt", recent[0].FileName);
            Assert.Equal(@"C:\test3.txt", recent[1].FileName);
            Assert.Equal(@"C:\test2.txt", recent[2].FileName);
            Assert.Equal(@"C:\test1.txt", recent[3].FileName);

            Assert.StartsWith(@"test4", recent[0].Title);
            Assert.StartsWith(@"test3", recent[1].Title);
            Assert.StartsWith(@"test2", recent[2].Title);
            Assert.StartsWith(@"test1", recent[3].Title);
        }