コード例 #1
0
        public DateTimeWindow()
        {
            InitializeComponent();
            this.HideIcon();

            foreach (string cultureName in MainViewModel.Instance.LoadedCultureNames)
            {
                CultureInfo ci = new CultureInfo(cultureName);
                CulturesList.Items.Add(new ValueViewModel<string>(ci.DisplayName, cultureName));
            }

            timerDc = DelayedCall.Create(UpdateView, 1000);
        }
コード例 #2
0
ファイル: DelayedCall.cs プロジェクト: modulexcite/FieldLog
        /// <summary>
        /// Creates and starts a new asynchronous <see cref="DelayedCall"/> instance. The callback
        /// function will be invoked on a ThreadPool thread.
        /// </summary>
        /// <param name="cb">The callback function.</param>
        /// <param name="milliseconds">Time to callback invocation in milliseconds.</param>
        /// <returns>The created <see cref="DelayedCall"/> instance that can be used for later controlling of the invocation process.</returns>
        public static DelayedCall StartAsync(Callback cb, int milliseconds)
        {
            DelayedCall dc = CreateAsync(cb, milliseconds);

            if (milliseconds > 0)
            {
                dc.Start();
            }
            else if (milliseconds == 0)
            {
                dc.FireNow();
            }
            return(dc);
        }
コード例 #3
0
        public EasyForm()
        {
            renderPageDc = DelayedCall.Create(RenderPdfPage, 200);

            InitializeComponent();

            FillCertificatesList();
            ValidateUIState();

            string[] args = Environment.GetCommandLineArgs();
            if (args.Length > 1)
            {
                InputFileText.Text = args[1];
                ValidateInputFile();
            }
        }
コード例 #4
0
        public MainWindow()
        {
            Instance = this;

            InitializeComponent();

            Width = 1000;
            Height = 500;
            SettingsHelper.BindWindowState(this, App.Settings.MainWindowState);

            logItemsScrollPixelDc = DelayedCall.Create(() => { logItemsHostPanel.ScrollToPixel = true; }, 600);
            updateScrollmapDc = DelayedCall.Create(UpdateScrollmap, 100);

            App.Settings.OnPropertyChanged(s => s.ShowWarningsErrorsInScrollBar, () => InvalidateScrollmap(false));
            App.Settings.OnPropertyChanged(s => s.ShowSelectionInScrollBar, () => InvalidateScrollmap(false));
        }
コード例 #5
0
        public MainViewModel()
        {
            Instance = this;

            TextKeys = new Dictionary<string, TextKeyViewModel>();
            LoadedCultureNames = new HashSet<string>();
            DeletedCultureNames = new HashSet<string>();
            RootTextKey = new TextKeyViewModel(null, false, null, this);
            ProblemKeys = new ObservableHashSet<TextKeyViewModel>();

            searchDc = DelayedCall.Create(UpdateSearch, 250);
            SearchText = "";   // Change value once to set the clear button visibility
            ClearViewHistory();
            UpdateTitle();

            FontScale = App.Settings.View.FontScale;

            App.Settings.View.OnPropertyChanged(s => s.ShowSuggestions, UpdateSuggestionsLayout);
            App.Settings.View.OnPropertyChanged(s => s.SuggestionsHorizontalLayout, UpdateSuggestionsLayout);
            UpdateSuggestionsLayout();
        }
コード例 #6
0
        public void AnimateStatusText(string newText)
        {
            int durationMs = 300;
            TimeSpan duration = TimeSpan.FromMilliseconds(durationMs);
            double offset = Math.Max(15, StatusText.ActualHeight);

            // Prepare animation
            if (statusTextAnimationDc != null)
            {
                statusTextAnimationDc.Fire();
            }
            StatusTextShadow.Text = newText;

            // Animate both text blocks
            AnimationHelper.AnimateEaseOut(StatusTextTranslateTransform, TranslateTransform.YProperty, 0, -offset, duration);
            AnimationHelper.AnimateEaseOut(StatusText, TextBlock.OpacityProperty, 1, 0, duration);
            AnimationHelper.AnimateEaseOut(StatusTextShadowTranslateTransform, TranslateTransform.YProperty, offset, 0, duration);
            AnimationHelper.AnimateEaseOut(StatusTextShadow, TextBlock.OpacityProperty, 0, 1, duration);

            // Finish up animation
            statusTextAnimationDc = DelayedCall.Start(StatusTextAnimationFinished, durationMs);
        }
コード例 #7
0
        private void StatusTextAnimationFinished()
        {
            StatusText.Text = StatusTextShadow.Text;

            StatusTextShadowTranslateTransform.Y = -StatusTextTranslateTransform.Y;
            StatusTextShadow.Opacity = 0;
            StatusTextTranslateTransform.Y = 0;
            StatusText.Opacity = 1;

            statusTextAnimationDc = null;
        }
コード例 #8
0
ファイル: DelayedCall.cs プロジェクト: modulexcite/FieldLog
 /// <summary>
 /// Unregisters a <see cref="DelayedCall"/> instance from the static list.
 /// </summary>
 /// <param name="dc">The <see cref="DelayedCall"/> instance to unregister.</param>
 protected static void Unregister(DelayedCall dc)
 {
     lock (instances)
     {
         // Free a reference on this object to allow the Garbage Collector to dispose it
         // if no other reference is kept to it
         instances.Remove(dc);
     }
 }
コード例 #9
0
ファイル: DelayedCall.cs プロジェクト: modulexcite/FieldLog
 /// <summary>
 /// Registers a <see cref="DelayedCall"/> instance in the static list.
 /// </summary>
 /// <param name="dc">The <see cref="DelayedCall"/> instance to register.</param>
 protected static void Register(DelayedCall dc)
 {
     lock (instances)
     {
         // Keep a reference on this object to prevent it from being caught by the Garbage Collector
         if (!instances.Contains(dc))
             instances.Add(dc);
     }
 }
コード例 #10
0
ファイル: DelayedCall.cs プロジェクト: modulexcite/FieldLog
        /// <summary>
        /// Prepares a <see cref="DelayedCall"/> instance.
        /// </summary>
        /// <param name="dc">The <see cref="DelayedCall"/> instance to prepare.</param>
        /// <param name="milliseconds">Time to callback invocation in milliseconds.</param>
        /// <param name="async">true to call the function asynchronously; false to call it in the current synchronisation context.</param>
        protected static void PrepareDCObject(DelayedCall dc, int milliseconds, bool async)
        {
            if (milliseconds < 0)
                throw new ArgumentOutOfRangeException("milliseconds", "The new timeout must be 0 or greater.");

            // Get the current synchronization context if required, with dummy fallback
            dc.context = null;
            if (!async)
            {
                dc.context = SynchronizationContext.Current;
                if (dc.context == null)
                    throw new InvalidOperationException("Cannot delay calls synchronously on a non-UI thread. Use the *Async methods instead.");
            }
            if (dc.context == null) dc.context = new SynchronizationContext();   // Run asynchronously silently

            dc.timer = new System.Timers.Timer();
            if (milliseconds > 0) dc.timer.Interval = milliseconds;
            dc.timer.AutoReset = false;
            dc.timer.Elapsed += dc.Timer_Elapsed;

            Register(dc);
        }
コード例 #11
0
ファイル: DelayedCall.cs プロジェクト: modulexcite/FieldLog
 /// <summary>
 /// Creates a new asynchronous <see cref="DelayedCall"/> instance. The callback function
 /// will be invoked on a ThreadPool thread.
 /// </summary>
 /// <param name="cb">The callback function.</param>
 /// <param name="milliseconds">Time to callback invocation in milliseconds.</param>
 /// <returns>The created <see cref="DelayedCall"/> instance that can be used for later controlling of the invocation process.</returns>
 public static DelayedCall CreateAsync(Callback cb, int milliseconds)
 {
     DelayedCall dc = new DelayedCall();
     PrepareDCObject(dc, milliseconds, true);
     dc.callback = cb;
     return dc;
 }
コード例 #12
0
ファイル: MouseFilter.cs プロジェクト: modulexcite/FieldLog
 private void InitializeComponent()
 {
     hideCursorTimer = DelayedCall.Create(HideCursor, 2000);
     if (!DesignMode)
     {
         Application.AddMessageFilter(this);
     }
 }
コード例 #13
0
 /// <summary>
 /// Validates all text keys and updates the suggestions later.
 /// </summary>
 public void ValidateTextKeysDelayed()
 {
     if (validateDc == null)
     {
         validateDc = DelayedCall.Start(ValidateTextKeys, 500);
     }
     else
     {
         validateDc.Reset();
     }
 }