Exemplo n.º 1
0
        // Event when another instance of clippy was started and sent file name to open
        private void MessageRecievedHandler(string content)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(new ServerMessageInvoker(MessageRecievedHandler), content);
                return;
            }

            if (string.IsNullOrEmpty(content))
            {
                return;
            }

            content = StaticHelper.Base64Decode(content);
            if (content.ToUpper() == ":BRINGTOFRONT:")
            {
                BringToFront();
                return;
            }

            if (!content.ToLower().EndsWith("." + ClipDataManager.Instance.FileExtension))
            {
                return;
            }

            if (ClipDataManager.Instance.Items.Count > 0)
            {
                MessageBoxResult result = MessageBox.Show(
                    $"The list is not empty. Do you want to load a new list from the file '{content}' and dismiss this one?",
                    $"{Title}: Confirm Loading",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question);

                if (result == MessageBoxResult.No)
                {
                    return;
                }
            }

            ClipDataManager.Instance.LoadList(content);
        }