Exemplo n.º 1
0
 internal void Update()
 {
     if (_nextUpdate == null)
     {
         _nextUpdate = Dispatcher.BeginInvoke((Action)UpdateImpl, System.Windows.Threading.DispatcherPriority.Loaded);
     }
 }
Exemplo n.º 2
0
        private void AsyncApresentarDados(object cliente)
        {
            string _cliente = new mMascaras().Remove((string)cliente);

            FlowDocument flow = new FlowDocument();

            new System.Threading.Thread(() =>
            {
                System.Windows.Threading.DispatcherOperation op =
                    FlowDoc.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,
                                                   new Action(delegate() {
                    switch (_cliente.Length)
                    {
                    case 11:
                        FlowDoc = FlowPF(_cliente);
                        break;

                    case 14:
                        FlowDoc = FlowPJ(_cliente);
                        break;
                    }
                }));

                op.Completed += (o, args) =>
                {
                    //BlackBox = Visibility.Collapsed;
                    //MainBox = Visibility.Collapsed;
                    //PrintBox = Visibility.Visible;
                    //StartProgress = false;
                };
            }).Start();
        }
        private void OBackgroundWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            MainRibbonWindow oMainRibbonWindow = new MainRibbonWindow();

            System.Threading.Thread oThread = new System.Threading.Thread(new System.Threading.ThreadStart(delegate()
            {
                System.Windows.Threading.DispatcherOperation oDispatcherOperation =
                    oMainRibbonWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                                             new System.Action(delegate()
                {
                    DAL.UnitOfWork oUnitOfWork = new DAL.UnitOfWork();

                    Utility.CurrentUser = oUnitOfWork.UserRepository
                                          .GetById(Utility.CurrentUser.Id);

                    oMainRibbonWindow.Show();

                    oMainRibbonWindow.WindowState = System.Windows.WindowState.Maximized;

                    this.Hide();
                }));
            }));

            oThread.SetApartmentState(System.Threading.ApartmentState.STA);

            oThread.Start();
        }
Exemplo n.º 4
0
        /// <summary>
        /// CIPCの状態を送信する
        /// </summary>
        public void Tcp_Send()
        {
            try
            {
                List <TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client>     clientlist     = new List <TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client>();
                List <TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection> connectionlist = new List <TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection>();
                if (this.RHS.List_RemoteHost.Count > 0)
                {
                    foreach (var count in this.RHS.List_RemoteHost)
                    {
                        TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client.Mode mode;
                        if (count.Connection_Mode == ConnectionState.Sender)
                        {
                            mode = TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Sender;
                        }
                        else if (count.Connection_Mode == ConnectionState.Receiver)
                        {
                            mode = TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Receiver;
                        }
                        else
                        {
                            mode = TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Default;
                        }

                        clientlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client(count.ID, count.Name, int.Parse(count.remotePort), count.remoteIP, count.Fps, mode));
                    }
                }
                if (this.DCS.List_dataconnection.Count > 0)
                {
                    foreach (var count in this.DCS.List_dataconnection)
                    {
                        connectionlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection(count.SENDER.ID, count.RECEIVER.ID));
                    }
                }


                bool IsSyncConnect = false;
                System.Windows.Threading.DispatcherOperation DO = this.mainwindow.Dispatcher.BeginInvoke(new Action(() =>
                {
                    IsSyncConnect = this.mainwindow.CheckBox_IsSyncReceived.IsChecked == true ? true : false;
                }));
                DO.Wait();

                TerminalConnectionSettings.ServerProtocols.ReportInfo reportinfo = new TerminalConnectionSettings.ServerProtocols.ReportInfo(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo(clientlist, connectionlist, IsSyncConnect));

                this.send.stringData = reportinfo.Data;
                this.networkstream.Write(this.send.encodedbytes, 0, this.send.encodedbytes.Length);
                this.debugwindow.DebugLog = "[TerminalConnection]送信:" + this.send.stringData;
            }
            catch (Exception ex)
            {
                this.debugwindow.DebugLog = "[" + this + "]" + ex.Message;
            }
        }
Exemplo n.º 5
0
 private void DoRaiseCollectionChanged(NotifyCollectionChangedEventHandler handler, NotifyCollectionChangedEventArgs ev)
 {
     //var lastOp = _lastOp;
     //while (true) {
     _lastOp?.Wait();
     //if (object.ReferenceEquals(System.Threading.Interlocked.CompareExchange(ref _lastOp, null, lastOp), lastOp)) {
     _lastOp = System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.DataBind, handler, this, ev);
     return;
     //}
     //lastOp = _lastOp;
     //}
 }
Exemplo n.º 6
0
 void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     System.Windows.Threading.DispatcherOperation
     dispatcherOp1 = LayoutRoot.Dispatcher.BeginInvoke(
         System.Windows.Threading.DispatcherPriority.Normal,
         new Action(
             delegate()
     {
         testsInProgress       = false;
         StartTestsBtn.Content = "Start Tests";
     }
             ));
 }
Exemplo n.º 7
0
        private void OnWindowOpenedClosed(object sender, AutomationEventArgs args)
        {
            // Ignore if different process.
            var element = sender as AutomationElement;

            if (element == null || element.Current.ProcessId != currentProcessId)
            {
                return;
            }

            // Since we're scheduling to the main thread which should be the only window creating thread, this should be thread safe.
            // (if not, it wouldn't be too tragic - as long as we don't spam the scheduler with more updates than necessary we're fine)
            if (scheduledUpdateControllerOperation == null || scheduledUpdateControllerOperation.Status == System.Windows.Threading.DispatcherOperationStatus.Completed)
            {
                scheduledUpdateControllerOperation = Application.Current.Dispatcher.InvokeAsync(UpdateTitleBarControllerList);
            }
        }
Exemplo n.º 8
0
        private static void PrintOnConsole(string message, object color)
        {
            DateTime TimeStamp = DateTime.Now;

            message       = $"[{TimeStamp.ToLongTimeString()}] {message}\n";
            LastOperation = _Instance.Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Background,
                new Action(() => {
                TextRange msg = new TextRange(_Instance.Console.Document.ContentEnd, _Instance.Console.Document.ContentEnd)
                {
                    Text = message
                };
                msg.ApplyPropertyValue(TextElement.ForegroundProperty, color);
                ScrollToEnd();
            })
                );
        }
Exemplo n.º 9
0
        private async void FlowAtendimentoAsync(string protocolo)
        {
            FlowDocument flow = new FlowDocument();

            await Task.Run(() =>
            {
                System.Windows.Threading.DispatcherOperation op =
                    FlowDoc.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,
                                                   new Action(delegate() {
                    FlowDoc = FlowAtendimento(protocolo);
                }));

                op.Completed += (o, args) =>
                {
                    //BlackBox = Visibility.Collapsed;
                    //MainBox = Visibility.Collapsed;
                    //PrintBox = Visibility.Visible;
                    //StartProgress = false;
                };
            });
        }
Exemplo n.º 10
0
        /// <summary>
        /// Load Event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ReportsBusinessObject objVersion = new ReportsBusinessObject();

            if (String.IsNullOrEmpty(oCommonUtilities.CreateInstance().GetConnectionString()))
            {
                MessageBox.ShowBox("MessageID1", BMC_Icon.Error);
                App.Current.Shutdown();
            }


            string sVersion, sName, sCopyRight, sDescription, sCompanyName, sProductName, sProductVersion;

            objVersion.GetVersion_SiteName(out sVersion, out sName);
            objVersion.GetSplashDetails(out sCopyRight, out sDescription, out sCompanyName, out sProductName, out sProductVersion);
            txtVersion.Text     = sVersion;
            CopyRight.Text      = "© " + DateTime.Now.Year + " Bally Technologies Inc. All Rights Reserved";
            CompanyName.Text    = "Company Name : " + sCompanyName;
            ProductName.Text    = "Product Name : " + sProductName;
            ProductVersion.Text = "Product Version : " + sProductVersion;

            //Start a new thread for the Pre - Requisite Checks.
            if (thread == null)
            {
                thread = new System.Threading.Thread(
                    new System.Threading.ThreadStart(
                        delegate()
                {
                    System.Windows.Threading.DispatcherOperation
                    dispatcherOp = txtStatus.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(
                            UpdateStatus
                            ));
                }
                        ));

                thread.Start();
            }
        }
Exemplo n.º 11
0
        private void AsyncFlowDoc()
        {
            BlackBox      = Visibility.Visible;
            StartProgress = true;

            new System.Threading.Thread(() =>
            {
                System.Windows.Threading.DispatcherOperation op =
                    FlowDoc.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,
                                                   new Action(delegate() {
                    FlowDoc = PreviewInTable(ListarAgenda);
                }));

                op.Completed += (o, args) =>
                {
                    BlackBox      = Visibility.Collapsed;
                    MainBox       = Visibility.Collapsed;
                    PrintBox      = Visibility.Visible;
                    StartProgress = false;
                };
            }).Start();
        }
Exemplo n.º 12
0
        private void AsyncFlowDoc(string evento)
        {
            try
            {
                BlackBox      = Visibility.Visible;
                StartProgress = true;
                new System.Threading.Thread(() =>
                {
                    if (IsName)
                    {
                        ListaInscritos = mdata.Inscritos(evento);
                    }

                    if (IsInscricao)
                    {
                        ListaInscritos = mdata.InscritosI(evento);
                    }

                    System.Windows.Threading.DispatcherOperation op =
                        FlowDoc.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,
                                                       new Action(delegate() {
                        FlowDoc  = PreviewInTable(ListaInscritos);
                        ViewGrid = Visibility.Collapsed;
                        ViewFlow = Visibility.Visible;
                    }));

                    op.Completed += (o, args) =>
                    {
                        BlackBox      = Visibility.Collapsed;
                        StartProgress = false;
                    };
                }).Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Sim.Alerta!");
            }
        }
Exemplo n.º 13
0
        void reportGenerator_ResultsChange(object sender, ReportGenerator.ResultsChangedEventArgs results)
        {
            //Updating Charts
            var plotData = results.CurrentResults;

            if (plotData != null && plotData.Tests.Count > 0)
            {
                //Preparing Grid
                System.Windows.Threading.DispatcherOperation
                dispatcherOp = ChartsGrid.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(
                        delegate()
                {
                    if (plotData.Tests.Count != ChartsGrid.RowDefinitions.Count)
                    {
                        //Removing charts
                        ChartsGrid.Children.Clear();
                        ChartsGrid.RowDefinitions.Clear();
                        //Adding components
                        var plot1 = new OxyPlot.Wpf.Plot()
                        {
                            Height = 500
                        };
                        plot1.Name = "chart0_0";
                        plot1.SetValue(Grid.RowProperty, 0);
                        plot1.SetValue(Grid.ColumnProperty, 0);
                        plot1.BorderBrush       = new SolidColorBrush(Colors.Black);
                        plot1.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                        var split = new GridSplitter()
                        {
                            Width = 4
                        };
                        var plot2 = new OxyPlot.Wpf.Plot()
                        {
                            Height = 500
                        };
                        plot2.Name = "chart0_1";
                        plot2.SetValue(Grid.RowProperty, 0);
                        plot2.SetValue(Grid.ColumnProperty, 1);
                        plot2.BorderBrush       = new SolidColorBrush(Colors.Black);
                        plot2.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                        ChartsGrid.Children.Add(plot1);
                        ChartsGrid.Children.Add(split);
                        ChartsGrid.Children.Add(plot2);
                        ChartsGrid.Height = 700;
                        ChartsGrid.RowDefinitions.Add(new RowDefinition()
                        {
                        });
                        if (plotData.Tests.Count > 1)
                        {
                            for (int i = 1; i < plotData.Tests.Count; i++)
                            {
                                var plot3 = new OxyPlot.Wpf.Plot()
                                {
                                    Height = 500
                                };
                                plot3.Name = String.Format("chart{0}_0", i);
                                plot3.SetValue(Grid.RowProperty, i);
                                plot3.SetValue(Grid.ColumnProperty, 0);
                                plot3.BorderBrush       = new SolidColorBrush(Colors.Black);
                                plot3.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                var split1 = new GridSplitter()
                                {
                                    Width = 4
                                };
                                split1.SetValue(Grid.RowProperty, i);
                                var plot4 = new OxyPlot.Wpf.Plot()
                                {
                                    Height = 500
                                };
                                plot4.Name = String.Format("chart{0}_1", i);
                                plot4.SetValue(Grid.RowProperty, i);
                                plot4.SetValue(Grid.ColumnProperty, 1);
                                plot4.BorderBrush       = new SolidColorBrush(Colors.Black);
                                plot4.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                ChartsGrid.Children.Add(plot3);
                                ChartsGrid.Children.Add(split1);
                                ChartsGrid.Children.Add(plot4);
                                ChartsGrid.RowDefinitions.Add(new RowDefinition()
                                {
                                });
                            }
                            ChartsGrid.Height = plotData.Tests.Count * 500 + plotData.Tests.Count * 4;
                        }
                        ChartsGrid.UpdateLayout();
                    }
                }));
                //For all Tests in Tests Data
                for (int testIndex = 0; testIndex < plotData.Tests.Count; testIndex++)
                {
                    var test = plotData.Tests[testIndex];
                    //Creating Model for Time
                    var tmp = new PlotModel("Duration", "using OxyPlot and NPerf");
                    if (isLogarithmic)
                    {
                        tmp.Axes.Add(new LogarithmicAxis(AxisPosition.Right, "Logarithmic"));
                    }
                    tmp.Title = "Duration (" + test.Name + ")";
                    int typeIndex      = 0;
                    int testIndexInner = testIndex;

                    var runTotal = test.Runs[0];
                    var series   =
                        (from PerfResult trun in runTotal.Results
                         select new LineSeries(trun.TestedType)
                    {
                        MarkerType = MarkerType.Circle
                    }).Cast <Series>().ToList();

                    foreach (var run in test.Runs)
                    {
                        typeIndex = 0;
                        foreach (var trun in run.Results)
                        {
                            if (typeIndex < run.Results.Count)
                            {
                                //Series name: run.Results[index].testedtype
                                // Value -> run.Results[index]
                                (series[typeIndex] as LineSeries).Points.Add(new DataPoint(run.Value,
                                                                                           run.Results[typeIndex].
                                                                                           Duration));
                            }
                            typeIndex++;
                        }
                    }
                    tmp.Series = new System.Collections.ObjectModel.Collection <Series>(series);

                    //Creating model for Memory
                    var tmp1 = new PlotModel("Memory", "using OxyPlot and NPerf");
                    if (isLogarithmic)
                    {
                        tmp1.Axes.Add(new LogarithmicAxis(AxisPosition.Right, "Logarithmic"));
                    }
                    typeIndex  = 0;
                    tmp1.Title = "Memory (" + test.Name + ")";
                    var runTotal1 = test.Runs[0];
                    var series1   =
                        (from PerfResult trun in runTotal1.Results
                         select new LineSeries(trun.TestedType)
                    {
                        MarkerType = MarkerType.Circle
                    }).Cast <Series>().ToList();
                    foreach (var run in test.Runs)
                    {
                        typeIndex = 0;
                        foreach (var trun in run.Results)
                        {
                            if (typeIndex < run.Results.Count)
                            {
                                //Series name: run.Results[index].testedtype
                                // Value -> run.Results[index]
                                (series1[typeIndex] as LineSeries).Points.Add(new DataPoint(run.Value,
                                                                                            run.Results[typeIndex].
                                                                                            MemoryUsageMb));
                            }
                            typeIndex++;
                        }
                    }
                    tmp1.Series = new System.Collections.ObjectModel.Collection <Series>(series1);

                    System.Windows.Threading.DispatcherOperation
                    dispatcherOp1 = ChartsGrid.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(
                            delegate()
                    {
                        //Setting models
                        foreach (var el in ChartsGrid.Children)
                        {
                            if (el is OxyPlot.Wpf.Plot &&
                                (el as OxyPlot.Wpf.Plot).Name.Equals(String.Format("chart{0}_0",
                                                                                   testIndexInner)))
                            {
                                (el as OxyPlot.Wpf.Plot).Model = tmp;
                                break;
                            }
                        }
                        foreach (var el in ChartsGrid.Children)
                        {
                            if (el is OxyPlot.Wpf.Plot &&
                                (el as OxyPlot.Wpf.Plot).Name.Equals(String.Format("chart{0}_1",
                                                                                   testIndexInner)))
                            {
                                (el as OxyPlot.Wpf.Plot).Model = tmp1;
                                break;
                            }
                        }
                        ChartsGrid.UpdateLayout();
                    }
                            ));
                }
            }
        }
Exemplo n.º 14
0
        void worker_DoWork(Object sender, DoWorkEventArgs e)
        {
            int       currentFileCount = 0;
            int       currentCodeCount;
            updateLog updateLogDelegate = new updateLog(updateLogMethod);

            System.Windows.Threading.DispatcherOperation updateLogBox = txtLog.Dispatcher.BeginInvoke(updateLogDelegate, System.Windows.Threading.DispatcherPriority.Normal, "Reading files");
            foreach (Files file in sourceFiles)
            {
                currentCodeCount = 0;
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }

                if (isWhitelisted(file.extension.ToUpper()))
                {
                    if (!turbo)
                    {
                        Thread.Sleep(50);
                    }

                    currentFileCount++;
                    System.Windows.Threading.DispatcherOperation updateProgressText = tbxLoc.Dispatcher.BeginInvoke(new progressTextUpdater(progressTextUpdateMethod), System.Windows.Threading.DispatcherPriority.Normal, file.fullname);
                    System.Windows.Threading.DispatcherOperation updateProgressBar  = progress.Dispatcher.BeginInvoke(new progressBarUpdater(progressBarUpdateMethod), System.Windows.Threading.DispatcherPriority.Normal, currentFileCount);

                    try
                    {
                        using (TextReader reader = new StreamReader(file.fullname))
                        {
                            while (reader.ReadLine() != null)
                            {
                                currentCodeCount++;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        updateLogBox = txtLog.Dispatcher.BeginInvoke(updateLogDelegate, System.Windows.Threading.DispatcherPriority.Normal, "Exception: " + ex.Message);
                    }

                    loc += currentCodeCount;

                    if (CodeBreakup.ContainsKey(file.extension.ToLower()))
                    {
                        CodeBreakup[file.extension.ToLower()] += currentCodeCount;
                    }
                    else
                    {
                        CodeBreakup.Add(file.extension.ToLower(), currentCodeCount);
                    }

                    System.Windows.Threading.DispatcherOperation updateLocCounter = progress.Dispatcher.BeginInvoke(new updateLOCCounter(LocCounterUpdateMethod), System.Windows.Threading.DispatcherPriority.Normal);
                }
                else
                {
                    currentFileCount++;
                    updateLogBox = txtLog.Dispatcher.BeginInvoke(updateLogDelegate, System.Windows.Threading.DispatcherPriority.Normal, "Skipping file: " + file.fullname);
                }
            }
        }