Esempio n. 1
0
        public MainWindow()
        {
            WindowBlur.SetIsEnabled(this, true);
            InitializeComponent();

            Helper = new FlashWindowHelper(System.Windows.Application.Current);

            Settings = SettingsClass.Create();
            if (Settings.AutoRun)
            {
                if (!IsStartupItem())
                {
                    SetAutorunValue(true, Environment.CurrentDirectory + "\\Updater.exe");
                }
            }
            else
            {
                if (IsStartupItem())
                {
                    SetAutorunValue(false, Environment.CurrentDirectory + "\\Updater.exe");
                }
            }

            if (Environment.GetCommandLineArgs().Length == 1)
            {
                Close();
            }

            Connection = new ConnectionClass(Settings);
            Connection.AcceptMessage += Connection_AcceptMessage;
        }
Esempio n. 2
0
        private void Notify(MessageModel message)
        {
            if (!_mainWindow.IsActive)
            {
                notifier.ShowNotification(message.ToChatName, message.Name, message.Color, message.PhotoPath, GetContent(message));
            }

            FlashWindowHelper.FlashWindow(_mainWindow);
            player.Play();
        }
Esempio n. 3
0
        public MainWindow()
        {
            InitializeComponent();

            Hide();

            UserInfoWindow userInfoWindow = new UserInfoWindow();

            userInfoWindow.Show();
            TextBoxUtilities.SetAlwaysScrollToEnd(OutputTextBox, true);

            _flashHelper = new FlashWindowHelper(Application.Current);
        }
Esempio n. 4
0
        private async void btnMergeFact_Click(object sender, EventArgs e)
        {
            pgbAnalisis.Visible = true;
            pgbAnalisis.Style   = eDotNetBarStyle.Windows7;

            btnMergeFact.Enabled = false;

            await Task.Run(() =>
            {
                try {
                    CheckForIllegalCrossThreadCalls = false;
                    var engineNotas        = new FileHelperEngine <NotasCSV>();
                    NotasCSV[] resultNotas = engineNotas.ReadFile(archFact.rutaNotas);
                    conexion.InsertarRegistrosNotas(resultNotas);


                    var engineBase        = new DelimitedFileEngine <BaseCSV>();
                    engineBase.Encoding   = Encoding.UTF8;
                    BaseCSV[] resultBases = engineBase.ReadFile(archFact.rutaFactBruta);
                    conexion.InsertarRegistrosEnBaseFacturacion(resultBases);


                    notifyIcon1.Visible         = true;
                    notifyIcon1.Icon            = SystemIcons.Information;
                    notifyIcon1.BalloonTipTitle = "MENSAJE DEL SISTEMA";
                    notifyIcon1.BalloonTipText  = "PROCESO COMPLETADO SATISFACTORIAMENTE.";
                    notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
                    notifyIcon1.ShowBalloonTip(1000);
                }
                catch (Exception ex)
                {
                    MessageBoxEx.Show(this, "ERROR AL GENERAR ARCHIVO.\n" + ex.Message, "ERROR DEL SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            });

            FlashWindowHelper.Flash(this);
            //btnImport.Enabled = true;
            pgbAnalisis.Visible = false;
            // MessageBoxEx.Show(this, "PROCESO COMPLETADO SATISFACTORIAMENTE", "MENSAJE DEL SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Information);
            archFact.GenerarFacturacinBruta = true;
            if (!archFact.GenerarFacturacionNeta)
            {
                btnGenerarFactNeta.Enabled = true;
            }
        }
Esempio n. 5
0
        private void PlayNotification()
        {
            Window window = Window.GetWindow(this);

            if (!window.IsActive || !IsVisible)
            {
                IntPtr handle = new WindowInteropHelper(window).Handle;
                FlashWindowHelper.Flash(handle);

                if (File.Exists("Assets/message.wav"))
                {
                    using (SoundPlayer player = new SoundPlayer("Assets/message.wav"))
                    {
                        player.Play();
                    }
                }
            }
        }
        public NotificationWindow(string symbol, string condition)
        {
            InitializeComponent();

            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
            {
                var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
                var transform   = PresentationSource.FromVisual(this).CompositionTarget.TransformFromDevice;
                var corner      = transform.Transform(new Point(workingArea.Right, workingArea.Bottom));

                this.Left = corner.X - this.ActualWidth - 100;
                this.Top  = corner.Y - this.ActualHeight;
            }));

            Title.Text = symbol;
            Body.Text  = condition;

            FlashWindowHelper.FlashWindow(this);
        }
Esempio n. 7
0
        private void StartOrStopFlashTaskBar(bool isFlash)
        {
            Application.Current.Dispatcher.Invoke((Action) delegate
            {
                if (isFlash)
                {
                    //var isTrue = FlashWindowHelper.FlashWindowEx(this, FlashType.FLASHW_TIMERNOFG);
                    //if (isTrue == false)
                    //{
                    //    //如果窗口未激活,那么就停止闪烁,高亮
                    //    FlashWindowHelper.FlashWindowEx(this, FlashType.FLASHW_TIMER);
                    //}

                    FlashWindowHelper.FlashWindowEx(this, FlashType.FLASHW_TIMER);
                }
                else
                {
                    FlashWindowHelper.StopFlashingWindow(this);
                }
            });
        }
Esempio n. 8
0
        /// <summary>
        /// Met à jour les messages
        /// </summary>
        private async void UpdateMessages(System.Windows.Controls.ListView lv)
        {
            using (LobbyService.LobbyServiceClient client = new LobbyService.LobbyServiceClient())
            {
                var lstMessages = await Task.Run(() => client.GetNewMessageFrom(UserSessionSingleton.Instance.UserToken.Value, _receiverName));

                bool newMsg = false;

                if (lstMessages.Count > 0)
                {
                    newMsg = true;
                }

                foreach (LobbyService.UserMessage um in lstMessages)
                {
                    lv.Items.Add(um);
                }

                if (lv.Items.Count > 0)
                {
                    lv.ScrollIntoView(lv.Items[lv.Items.Count - 1]);
                }

                if (newMsg)
                {
                    _mediaPlayer              = new MediaPlayer();
                    _mediaPlayer.MediaFailed += (o, args) =>
                    {
                        MessageBox.Show("Media Failed!!");
                    };
                    _mediaPlayer.Open(new Uri("Sounds/MSN Sound.mp3", UriKind.RelativeOrAbsolute));
                    _mediaPlayer.Play();

                    var helper = new FlashWindowHelper(Application.Current);
                    // Flashes the window and taskbar 5 times and stays solid
                    // colored until user focuses the main window
                    helper.FlashApplicationWindow();
                }
            }
        }
Esempio n. 9
0
        public MainWindowViewModel(IDialogCoordinator dialog, IHubProxy hub, HubConnection connection, Window window)
        {
            Connection               = connection;
            Connection.Reconnected  += ConnectionOnReconnected;
            Connection.StateChanged += ConnectionOnStateChanged;
            Hub                    = hub;
            Dialog                 = dialog;
            AdminViewModel         = new AdminViewModel(Hub, DialogCoordinator.Instance);
            _flashWindowHelper     = new FlashWindowHelper(Application.Current);
            _thisWindow            = window;
            MenuItemConnectCommand = new Command(arg => Show_LoginForm());
            SecurityChooseCommand  = new Command(SecurityChoose);
            SecuritiesCommand      = new Command(arg => GetSecurities());
            OpenWindowCommand      = new Command(OpenWindow);
            ChangePassCommand      = new Command(arg => ChangePass());
            SleepCommand           = new Command(arg => SelfSleep());
            SaveWorkspaceCommand   = new Command(arg => SaveWorkspace());
            LoadWorkspaceCommand   = new Command(arg => LoadWorkspace());
            Status                 = "Status: Disconnected";
            //get watchlists collection and initialize watcher to monitor changes in the watchlists' folder
            GetWatchlists();
            InitializeWatcher();
            SecVm.WatchListsCollection = WatchListsCollection;
            //Subscribing to events
            TXmlConnector.SendNewFormData += XmlConnector_OnSendNewFormData; //general data
            /*TXmlConnector.SendNewStatus += XmlConnector_OnSendNewStatus;*/ //status
            TXmlConnector.SendStatus      += XmlConnector_OnSendNewStatus;
            TXmlConnector.SendNewSecurity += XmlConnector_OnSendNewSecurity; //securities
            TXmlConnector.ConnectorSetCallback();
            TXmlConnector.FormReady = true;

            //Initializing the connector dll
            var path = (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Inside MMA\\logs\\" + ClientInfo.InsideLogin).Replace("\\", "//");

            Directory.CreateDirectory(path);
            foreach (var file in new DirectoryInfo(path).GetFiles())
            {
                file.Delete();
            }
            //loading settings
            WindowDataHandler.GetWindowData();
            Settings.Default.Reload();
            Level2Settings.Default.Reload();
            //path = path.Substring(0, path.LastIndexOf('\\') + 1) + "\0";
            if (TXmlConnector.ConnectorInitialize(path, (short)Settings.Default.LogLevel))
            {
                TXmlConnector.StatusDisconnected.Set();
            }

            //setting the number decimal separator to a point
            var customCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();

            customCulture.NumberFormat.NumberDecimalSeparator = ".";
            CultureInfo.DefaultThreadCurrentCulture           = customCulture;
            Thread.CurrentThread.CurrentCulture = customCulture;

            //subbing for singlar events
            Hub?.On("Sleep", Sleep);
            Hub?.On("Unsleep", Unsleep);
            Hub?.On("SelectWindows", WindowAvailabilityManager.SelectWindows);
            Hub?.On("Disconnect", DisconnectByServer);
            Hub?.On("DisplayMessage", DisplayMessage);
            Hub?.On("CancelOrders", ClientOrdersViewModel.CancelAllOrdersMethod);
            Hub?.On("CancelStoporders", ClientOrdersViewModel.CancelAllStopordersMethod);
            Hub?.On("CloseBalance", ClientsViewModel.CloseBalanceMethod);
            //requesting license exp date
            Hub?.On("License", GetLicense);
            Hub?.Invoke("GetLicense");
            //setting the stoporder manager
            new OrderManager(ClientOrdersViewModel.ClientStoporders, ClientOrdersViewModel.ClientOrders);
            //setting the report manager
            ReportManager.Set();
            ShowPatchnotes();
        }
Esempio n. 10
0
 protected override void OnActivated(EventArgs e)
 {
     FlashWindowHelper.StopFlashingWindow(this);
     base.OnActivated(e);
 }
Esempio n. 11
0
        private void IstemciThreadi(TcpListener sunucu)
        {
            TcpClient istemci = sunucu.AcceptTcpClient();

            ConsoleAddItem(String.Format("A client connected with IP: {0}. Thread ID: {1}. Inserting alert", ((IPEndPoint)istemci.Client.RemoteEndPoint).Address, Thread.CurrentThread.ManagedThreadId));

            string ID         = null;
            string gelen_veri = "";

            byte[] bytesToRead = null;
            int    bytesRead   = 0;

            try
            {
                InsertAlert(((IPEndPoint)istemci.Client.RemoteEndPoint).Address.ToString(), out ID);
                ConsoleAddItem("Alert info has been added to DB!");
            }
            catch (Exception ex)
            {
                ConsoleAddItem("Error while insertion alert: " + ex.Message);
            }

            //enter to an infinite cycle to be able to handle every change in stream
            while (serverRunning)
            {
                try
                {
                    using (NetworkStream yayin = istemci.GetStream())
                    {
                        bytesToRead = new byte[istemci.ReceiveBufferSize];
                        bytesRead   = yayin.Read(bytesToRead, 0, istemci.ReceiveBufferSize);
                        gelen_veri  = Encoding.ASCII.GetString(bytesToRead, 0, bytesRead);
                        ConsoleAddItem("Received : " + Encoding.ASCII.GetString(bytesToRead, 0, bytesRead));
                        if (bytesRead > 0)
                        {
                            ConsoleAddItem(String.Format("{0}: {1}", Thread.CurrentThread.ManagedThreadId, gelen_veri));

                            if (UpdateAlert(gelen_veri, ((IPEndPoint)istemci.Client.RemoteEndPoint).Address.ToString(), ID))
                            {
                                ConsoleAddItem(String.Format("Alert info has been updated to DB successfully!"));
                                RetrieveAlerts(true, null);
                                break;
                            }
                            else
                            {
                                ConsoleAddItem(String.Format("Alert info could NOT be updated!!!"));
                                // TODO: What to do if update fails ?
                            }
                        }
                    }
                }
                // Client Drop
                catch (System.IO.IOException)
                {
                    ConsoleAddItem(String.Format("Connection lost. Thread ID: {0}", Thread.CurrentThread.ManagedThreadId));
                    if (ID != null)
                    {
                        string          connStr = "server=earthpwn.ddns.net;user=anan;database=anan;port=6969;password=anan;SslMode=none"; //global
                        MySqlConnection conn    = new MySqlConnection(connStr);
                        try
                        {
                            conn.Open();
                            ConsoleAddItem("DB Connection established to record client drop.");
                            ActivityUpdate(Activity.ON_ClientDrop, ID, false, conn);
                            RetrieveAlerts(false, conn);
                            // job's done
                            ConsoleAddItem("Client drop has been recorded successfully");
                        }
                        catch (Exception ex)
                        {
                            ConsoleAddItem("Error while changing status to client drop: " + ex.Message);
                        }
                        if (conn.State == System.Data.ConnectionState.Open)
                        {
                            try
                            {
                                conn.Close();
                                ConsoleAddItem("DB Connection Closed.");
                            }
                            catch (Exception ex)
                            {
                                ConsoleAddItem($"{ex.Message} You should've never seen this.");
                            }
                        }
                    }
                    else
                    {
                        ConsoleAddItem("Alert ID is null! Cannot change!");
                    }
                    RetrieveAlerts(true, null);
                    break;
                }
                // Other Exceptions
                catch (Exception ex)
                {
                    ConsoleAddItem(String.Format("Error on Thread ID {0}: " + ex.Message, Thread.CurrentThread.ManagedThreadId));
                    RetrieveAlerts(true, null);
                    break;
                }
            }

            // Play sound
            Assembly    assembly;
            SoundPlayer sp;

            assembly = Assembly.GetExecutingAssembly();
            using (sp = new SoundPlayer(assembly.GetManifestResourceStream("Shiny.alert.wav")))
            {
                sp.Play();
            }

            // Bring the window to the front or Flash yellow in the taskbar; based on the user's selection.
            if (Properties.Settings.Default.BringWindowToTop)
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    if (WindowState == WindowState.Minimized)
                    {
                        WindowState = WindowState.Normal;
                    }

                    Activate();
                    Topmost = true;
                    Topmost = false;
                    Focus();
                }), DispatcherPriority.ContextIdle);
            }
            else
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    var helper = new FlashWindowHelper(Application.Current);

                    // Flashes the window and taskbar 5 times and stays solid
                    // colored until user focuses the main window
                    helper.FlashApplicationWindow();
                }), DispatcherPriority.ContextIdle);
            }

            ConsoleAddItem(String.Format("Aborting #{0}", Thread.CurrentThread.ManagedThreadId));
            Thread.CurrentThread.Abort();
        }