Ejemplo n.º 1
0
        public ArchiveWindow()
        {
            InitializeComponent();

            _glowFadeOutAnimation = new ColorAnimation(Colors.WindowActiveGlow, Colors.WindowInactiveGlow, new Duration(new TimeSpan(0, 0, 0, 0, 150)));
            _glowFadeInAnimation  = new ColorAnimation(Colors.WindowInactiveGlow, Colors.WindowActiveGlow, new Duration(new TimeSpan(0, 0, 0, 0, 150)));

            var borderActivateAnimation   = new ColorAnimation(Colors.WindowInactiveBorder, Colors.WindowActiveBorder, new Duration(new TimeSpan(0, 0, 0, 0, 150)));
            var borderDeactivateAnimation = new ColorAnimation(Colors.WindowActiveBorder, Colors.WindowInactiveBorder, new Duration(new TimeSpan(0, 0, 0, 0, 150)));

            _borderActivateStoryboard   = new Storyboard();
            _borderDeactivateStoryboard = new Storyboard();

            Storyboard.SetTarget(borderActivateAnimation, WindowBorder);
            Storyboard.SetTargetProperty(borderActivateAnimation, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)"));
            _borderActivateStoryboard.Children.Add(borderActivateAnimation);

            Storyboard.SetTarget(borderDeactivateAnimation, WindowBorder);
            Storyboard.SetTargetProperty(borderDeactivateAnimation, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)"));
            _borderDeactivateStoryboard.Children.Add(borderDeactivateAnimation);

            Title = LocaleSelector.GetLocaleString("ArchiveWindow_Title");

            LoadAllArchives();
        }
        public ParametersPage()
        {
            BindingContext = this;
            LocalFilePath  = FileSystem.Current.LocalStorage.Path;
            InitializeComponent();
            Title = AppResources.ParametersPage_Title;



            Locales.Add(new LocaleSelector()
            {
                Code = "en",
                Name = "English"
            });
            Locales.Add(new LocaleSelector()
            {
                Code = "ru",
                Name = "Русский"
            });
            localizationpicker.ItemsSource = Locales;

            //текущая локаль
            LocaleSelector locale = Locales.Find(x => x.Code == Settings.CurrentLocalization);

            if (locale is LocaleSelector)
            {
                localizationpicker.SelectedItem = locale;
            }
        }
Ejemplo n.º 3
0
        protected void ValidateUniqueName(object source, ServerValidateEventArgs args)
        {
            try
            {
                using (var connection = new SqlConnection(DB.GetDBConn()))
                    using (var command = new SqlCommand())
                    {
                        command.Connection  = connection;
                        command.CommandText = @"
					select count(*) 
					from SalesPrompt
					cross apply dbo.ParseMlLocales(SalesPrompt.Name) as ML
					where 
						(@id is null or SalesPromptID != @id)
						and Deleted = 0
						and (ML.Locale is NULL or ML.Locale = @locale) 
						and ML.Value = @name"                        ;
                        command.Parameters.AddWithValue("@id", (object)SalesPromptId ?? DBNull.Value);
                        command.Parameters.AddWithValue("@locale", LocaleSelector.GetSelectedLocale().Name);
                        command.Parameters.AddWithValue("@name", args.Value);

                        connection.Open();
                        args.IsValid = (int)command.ExecuteScalar() == 0;
                    }
            }
            catch (Exception exception)
            {
                ctlAlertMessage.PushAlertMessage(String.Format("Could not validate:<br />{0}", exception.ToString()), AlertMessage.AlertType.Error);
            }
        }
Ejemplo n.º 4
0
        void LoadSalesPrompt()
        {
            if (SalesPromptId == null)
            {
                return;
            }

            try
            {
                using (var connection = new SqlConnection(DB.GetDBConn()))
                    using (var command = new SqlCommand())
                    {
                        command.Connection  = connection;
                        command.CommandText = "select dbo.GetMlValue(Name, @locale) [Name] from SalesPrompt with(nolock) where SalesPromptID = @id";
                        command.Parameters.AddWithValue("@id", SalesPromptId);
                        command.Parameters.AddWithValue("@locale", LocaleSelector.GetSelectedLocale().Name);

                        connection.Open();
                        using (var reader = command.ExecuteReader())
                            if (reader.Read())
                            {
                                NameTextBox.Text = reader.Field("Name");
                            }
                            else
                            {
                                ctlAlertMessage.PushAlertMessage(String.Format("No Sales Prompt with ID {0} exists", SalesPromptId), AlertMessage.AlertType.Error);
                            }
                    }
            }
            catch (Exception exception)
            {
                ctlAlertMessage.PushAlertMessage(String.Format("Could not load:<br />{0}", exception.ToString()), AlertMessage.AlertType.Error);
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Form.DefaultButton = btnUpdate.UniqueID;

            SelectedLocale = LocaleSelector
                             .GetSelectedLocale()
                             .Name;

            if (!IsPostBack)
            {
                StoreId = Store.GetDefaultStore().StoreID;
                BindStores();
            }
            else
            {
                int storeId;
                if (!int.TryParse(StoreSelector.SelectedValue, out storeId))
                {
                    return;
                }

                StoreId = storeId;
            }

            if (!Page.IsPostBack)
            {
                LoadPageContent(SelectedLocale, StoreId);
            }
        }
Ejemplo n.º 6
0
 private void ServerDisconnectionCleanup()
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         DisableChatRelatedControls();
         StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_ServerClosedConnection");
     });
 }
Ejemplo n.º 7
0
 public void DisconnectFromStranger()
 {
     if (_connection.IsStrangerConnected)
     {
         _connection.DisconnectStranger();
     }
     Application.Current.Dispatcher.Invoke(() => StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_ConnectedToServer"));
 }
Ejemplo n.º 8
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (SaveForm(RecordId))
     {
         var localeQueryString = LocaleSelector.HasMultipleLocales() ? String.Format("&locale.selection={0}", Locale) : String.Empty;
         Response.Redirect(String.Format("orderoption.aspx?optionid={0}{1}", RecordId, localeQueryString));
     }
 }
        private void ClearArchiveButton_Click(object sender, RoutedEventArgs e)
        {
            var choice = ChoiceWindow.Show(LocaleSelector.GetLocaleString("ChoiceWindow_ArchiveEraseWarning"));

            if (choice)
            {
                App.ArchiveManager.EraseArchives();
            }
        }
        private void ClearStatisticsButton_Click(object sender, RoutedEventArgs e)
        {
            var choice = ChoiceWindow.Show(LocaleSelector.GetLocaleString("ChoiceWindow_StatisticsEraseWarning"));

            if (choice)
            {
                App.StatsManager.ClearStats();
            }
        }
Ejemplo n.º 11
0
 private void Connection_StrangerChatstateChanged(object sender, ChatstateEventArgs e)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         StatusTextBlock.Text = e.ChatState == ChatState.Writing
             ? LocaleSelector.GetLocaleString("StatusIndicator_StrangerTyping")
             : LocaleSelector.GetLocaleString("StatusIndicator_StrangerIdle");
     });
 }
        private void LanguageSelectComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems?[0] == null)
            {
                return;
            }

            SettingsSelector.SetConfigurationValue("Language", e.AddedItems[0] as string);
            LocaleSelector.SetLocaleIdentifier(e.AddedItems[0] as string);
        }
Ejemplo n.º 13
0
 private void Connection_MessageReceived(object sender, MessageEventArgs e)
 {
     if (e.Message.Type == MessageType.Chat)
     {
         Application.Current.Dispatcher.Invoke(() => MessageLog.AddMessage(e.Message, true));
         Application.Current.Dispatcher.Invoke(() => StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_StrangerIdle"));
     }
     else if (e.Message.Type == MessageType.Topic)
     {
         Application.Current.Dispatcher.Invoke(() => MessageLog.AddTopic(e.Message));
     }
 }
        private void PaintOutgoingMessage()
        {
            SenderTextBlock.Text = LocaleSelector.GetLocaleString("MessageControl_Sender_You");

            MainGrid.Background  = Colors.OutgoingMessageBackgroundBrush;
            MainGrid.BorderBrush = Colors.OutgoingMessageBorderBrush;

            if (SettingsSelector.GetConfigurationValue <bool>("Appearance_MessageMargins"))
            {
                Margin = new Thickness(20, 0, 0, 0);
            }
        }
Ejemplo n.º 15
0
 public PresenceControl(bool started) : this()
 {
     if (started)
     {
         PresenceTextBlock.Text = LocaleSelector.GetLocaleString("PresenceControl_ConversationStarted");
         PresenceTextBlock.HorizontalAlignment = HorizontalAlignment.Left;
     }
     else
     {
         PresenceTextBlock.Text = LocaleSelector.GetLocaleString("PresenceControl_ConversationEnded");
         PresenceTextBlock.HorizontalAlignment = HorizontalAlignment.Right;
     }
 }
        private void localizationpicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            var picker        = (Picker)sender;
            int selectedIndex = picker.SelectedIndex;

            if (selectedIndex >= 0)
            {
                LocaleSelector selected             = (LocaleSelector)picker.SelectedItem;
                System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(selected.Code);
                Settings.CurrentLocalization = selected.Code;
                Resx.AppResources.Culture    = ci;                 // set the RESX for resource localization
                DependencyService.Get <ILocalize>().SetLocale(ci); // set the Thread for locale-aware methods
            }
        }
Ejemplo n.º 17
0
        void LoadNewsItem()
        {
            if (RecordId == 0)
            {
                Title = HeaderText.Text = AppLogic.GetString("admin.editnews.AddingNews", ThisCustomer.LocaleSetting);
                txtDate.SelectedDate = DateTime.Now.AddMonths(1);
            }
            else
            {
                Title = HeaderText.Text = AppLogic.GetString("admin.editnews.EditingNews", ThisCustomer.LocaleSetting);

                using (var connection = new SqlConnection(DB.GetDBConn()))
                    using (var command = new SqlCommand())
                    {
                        command.Connection  = connection;
                        command.CommandText = "SELECT * FROM News WITH (NOLOCK) WHERE NewsID = @NewsID";
                        command.Parameters.AddRange(new[]
                        {
                            new SqlParameter("@NewsID", RecordId.ToString())
                        });

                        connection.Open();
                        using (var reader = command.ExecuteReader())
                            if (reader.Read())
                            {
                                var selectedLocale = LocaleSelector.GetSelectedLocale().Name;

                                litNewsId.Text   = reader.FieldInt("NewsID").ToString();
                                txtHeadline.Text = reader.FieldByLocale("Headline", selectedLocale);

                                if (UseHtmlEditor)
                                {
                                    radCopy.Content = reader.FieldByLocale("NewsCopy", selectedLocale);
                                }
                                else
                                {
                                    txtCopy.Text = reader.FieldByLocale("NewsCopy", selectedLocale);
                                }

                                txtDate.SelectedDate = reader.FieldDateTime("ExpiresOn");
                                cbxPublished.Checked = reader.FieldBool("Published");
                            }
                    }
            }

            StoresMapping.ObjectID = RecordId;
            StoresMapping.DataBind();
            divStoreMapping.Visible = StoresMapping.StoreCount > 1;
        }
Ejemplo n.º 18
0
        private void Connection_StrangerFound(object sender, StrangerFoundEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                ChatBox.IsEnabled = true;
                ChatBox.Focus();

                MessageLog.AddPresence(true, e.StrangerInfo.FlaggedAsUnpleasant);
                StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_StrangerIdle");

                Toolbar.FlagStrangerButton.IsEnabled           = true;
                Toolbar.DisconnectFromStrangerButton.IsEnabled = true;
                Toolbar.RequestRandomTopicButton.IsEnabled     = true;
            });
        }
Ejemplo n.º 19
0
 private void SettingsSelector_SettingsChanged(object sender, EventArgs e)
 {
     if (SettingsSelector.GetConfigurationValue <bool>("Appearance_UppercaseMenuHeaders"))
     {
         MainMenuButton.Label    = LocaleSelector.GetLocaleString("Menu_File").ToUpper();
         OptionsMenuButton.Label = LocaleSelector.GetLocaleString("Menu_Options").ToUpper();
         ViewMenuButton.Label    = LocaleSelector.GetLocaleString("Menu_View").ToUpper();
     }
     else
     {
         MainMenuButton.Label    = LocaleSelector.GetLocaleString("Menu_File");
         OptionsMenuButton.Label = LocaleSelector.GetLocaleString("Menu_Options");
         ViewMenuButton.Label    = LocaleSelector.GetLocaleString("Menu_View");
     }
 }
Ejemplo n.º 20
0
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var selector = new LocaleSelector();

            selector.Activate();
            selector.ShowDialog(null);
            if (selector.DialogResult != DialogResult.OK)
            {
                return;
            }

            CultureInfo.CurrentCulture                = selector.TargetCulture;
            CultureInfo.CurrentUICulture              = selector.TargetCulture;
            CultureInfo.DefaultThreadCurrentCulture   = selector.TargetCulture;
            CultureInfo.DefaultThreadCurrentUICulture = selector.TargetCulture;

            var rnd = new Random();

            WaitRollDice.Rnd  = rnd;
            ItemContainer.Rnd = rnd;
            var view = new MainGameForm();
            // Construct the initial game data structures
            var presenter  = new Presenter(view);
            var board      = new GameBoard();
            var bank       = new Bank();
            var playerList = new List <Player>
            {
                new Player(PlayerColor.Blue),
                new Player(PlayerColor.Orange),
                new Player(PlayerColor.Red),
                new Player(PlayerColor.White)
            };


            var gameModel = new GameModel(board, bank, playerList, presenter);
            var manager   = new TurnManager(gameModel);

            presenter.RegisterTurnManager(manager);
            board.InitializeView(presenter);

            var t = new Thread(presenter.MainLoop);

            t.Start();
            Application.Run(view);
        }
Ejemplo n.º 21
0
        private void Connection_ConversationEnded(object sender, ConversationEndedEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                if (!e.DisconnectInfo.IsReminder)
                {
                    MessageLog.AddPresence(false);
                }

                ChatBox.Clear();
                ChatBox.IsEnabled = false;

                StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_ConnectedToServer");

                Toolbar.DisconnectFromStrangerButton.IsEnabled = false;
                Toolbar.SearchForStrangerButton.IsEnabled      = true;
                Toolbar.FlagStrangerButton.IsEnabled           = false;
                Toolbar.RequestRandomTopicButton.IsEnabled     = false;
            });
        }
Ejemplo n.º 22
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var systemVersion = Environment.OSVersion.Version;

            if (systemVersion.Major < 6)
            {
                MessageBox.Show("Incompatible system version, must be at least Windows Vista", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            DirectoryGuard.DirectoriesSanityCheck();
            if (!HasWriteAccessToFolder(AppDomain.CurrentDomain.BaseDirectory))
            {
                AlertWindow.Show(LocaleSelector.GetLocaleString("AlertWindow_NoWriteAccess"));
                CanWriteToCurrentFolder = false;
            }
            else
            {
                CanWriteToCurrentFolder = true;
            }
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            WindowFlashHelper = new WindowFlashHelper(this);

            Connection = new Connection
            {
                SendUserAgent = SettingsSelector.GetConfigurationValue <bool>("Behavior_SendUserAgent")
            };
            StatsManager   = new StatsManager(Connection);
            ArchiveManager = new ArchiveManager();

            LocaleSelector.SetLocaleIdentifier(
                SettingsSelector.GetConfigurationValue <string>("Language")
                );

            ColorSchemeLoader = new ColorSchemeLoader();

            ColorSchemeLoader.LoadColorSchemes();
            ColorSchemeLoader.ApplyColors();

            base.OnStartup(e);
        }
Ejemplo n.º 23
0
        void SaveNewsItem()
        {
            var editing        = RecordId != 0;
            var selectedLocale = LocaleSelector.GetSelectedLocale().Name;
            var expirationDate = txtDate.SelectedDate ?? System.DateTime.Now.AddMonths(1);
            var headline       = editing
                                ? AppLogic.FormLocaleXml("Headline", txtHeadline.Text.Trim(), selectedLocale, "News", RecordId)
                                : AppLogic.FormLocaleXml(txtHeadline.Text.Trim(), selectedLocale);

            var copyContent = UseHtmlEditor
                                ? radCopy.Content
                                : txtCopy.Text;

            var copy = editing
                                ? AppLogic.FormLocaleXml("NewsCopy", copyContent, selectedLocale, "News", RecordId)
                                : AppLogic.FormLocaleXml(copyContent, selectedLocale);

            var parameters = new[]
            {
                new SqlParameter("@newsId", RecordId),
                new SqlParameter("@headline", headline),
                new SqlParameter("@copy", copy),
                new SqlParameter("@expirationDate", expirationDate),
                new SqlParameter("@published", cbxPublished.Checked)
            };

            var query = editing
                                ? "UPDATE News SET Headline = @headline, NewsCopy = @copy, Published = @published, ExpiresOn = @expirationDate WHERE NewsID = @newsID"
                                : "INSERT News (Headline, NewsCopy, Published, ExpiresOn) VALUES (@headline, @copy, @published, @expirationDate); select cast(SCOPE_IDENTITY() as int) N;";

            var identity = DB.GetSqlN(query, parameters);

            if (!editing)
            {
                RecordId = identity;
            }

            StoresMapping.ObjectID = RecordId;
            StoresMapping.Save();
        }
Ejemplo n.º 24
0
        public AboutWindow()
        {
            InitializeComponent();

            Title = LocaleSelector.GetLocaleString("AboutWindow_Title");

            var assemblyName = Assembly.GetExecutingAssembly().GetName();

            VersionNumberTextBlock.Text = string.Format(
                VersionNumberTextBlock.Text,
                assemblyName.Version.Major,
                assemblyName.Version.Minor,
                assemblyName.Version.Build,
                assemblyName.Version.Revision
                );

            _fadeOutAnimation = new DoubleAnimation(1, 0, new Duration(new TimeSpan(0, 0, 0, 0, 150)));
            _fadeInAnimation  = new DoubleAnimation(0, 1, new Duration(new TimeSpan(0, 0, 0, 0, 150)));

            _glowFadeOutAnimation = new ColorAnimation(Colors.WindowActiveGlow, Colors.WindowInactiveGlow, new Duration(new TimeSpan(0, 0, 0, 0, 150)));
            _glowFadeInAnimation  = new ColorAnimation(Colors.WindowInactiveGlow, Colors.WindowActiveGlow, new Duration(new TimeSpan(0, 0, 0, 0, 150)));

            var borderActivateAnimation   = new ColorAnimation(Colors.WindowInactiveBorder, Colors.WindowActiveBorder, new Duration(new TimeSpan(0, 0, 0, 0, 150)));
            var borderDeactivateAnimation = new ColorAnimation(Colors.WindowActiveBorder, Colors.WindowInactiveBorder, new Duration(new TimeSpan(0, 0, 0, 0, 150)));

            _borderActivateStoryboard   = new Storyboard();
            _borderDeactivateStoryboard = new Storyboard();

            Storyboard.SetTarget(borderActivateAnimation, WindowBorder);
            Storyboard.SetTargetProperty(borderActivateAnimation, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)"));
            _borderActivateStoryboard.Children.Add(borderActivateAnimation);

            Storyboard.SetTarget(borderDeactivateAnimation, WindowBorder);
            Storyboard.SetTargetProperty(borderDeactivateAnimation, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)"));
            _borderDeactivateStoryboard.Children.Add(borderDeactivateAnimation);

            _heightUpAnimation            = new DoubleAnimation(160, 370, new Duration(new TimeSpan(0, 0, 0, 0, 500)));
            _heightUpAnimation.Completed += heightUpAnimation_Completed;
        }
        private void SettingsWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            foreach (var s in LocaleSelector.GetAvailableLocaleIdentifiers())
            {
                LanguageSelectComboBox.Items.Add(s);
                LanguageSelectComboBox.SelectedItem = LocaleSelector.GetCurrentLocaleIdentifier();
            }

            foreach (var s in App.ColorSchemeLoader.ColorSchemes.Keys)
            {
                ColorSchemeComboBox.Items.Add(s);
                ColorSchemeComboBox.SelectedItem = SettingsSelector.GetConfigurationValue <string>("ColorScheme");
            }

            SendSexQueryCheckBox.IsChecked                = SettingsSelector.GetConfigurationValue <bool>("Behavior_SendSexQueryOnStart");
            StartupWithSystemCheckBox.IsChecked           = SettingsSelector.GetConfigurationValue <bool>("Behavior_StartupWithSystem");
            SendUserAgentCheckBox.IsChecked               = SettingsSelector.GetConfigurationValue <bool>("Behavior_SendUserAgent");
            SendChatstateCheckBox.IsChecked               = SettingsSelector.GetConfigurationValue <bool>("Behavior_SendChatstate");
            ToggleCopyViewOnDoubleClickCheckBox.IsChecked = SettingsSelector.GetConfigurationValue <bool>("Behavior_CopyViewOnLogDoubleClick");
            UpperCaseMenuHeaderCheckBox.IsChecked         = SettingsSelector.GetConfigurationValue <bool>("Appearance_UppercaseMenuHeaders");
            MessageMarginsCheckBox.IsChecked              = SettingsSelector.GetConfigurationValue <bool>("Appearance_MessageMargins");

            VoivodeshipSelectComboBox.SelectedIndex = SettingsSelector.GetConfigurationValue <int>("Voivodeship");
        }
Ejemplo n.º 26
0
        int?SaveSalesPrompt()
        {
            try
            {
                var salesPromptName = SalesPromptId.HasValue
                                        ? AppLogic.FormLocaleXml("Name", NameTextBox.Text.Trim(), LocaleSelector.GetSelectedLocale().Name, "SalesPrompt", SalesPromptId.Value)
                                        : AppLogic.FormLocaleXml(NameTextBox.Text.Trim(), LocaleSelector.GetSelectedLocale().Name);

                using (var connection = new SqlConnection(DB.GetDBConn()))
                    using (var command = new SqlCommand())
                    {
                        command.Connection  = connection;
                        command.CommandText = SalesPromptId.HasValue
                                                ? "update SalesPrompt set Name = @name where SalesPromptID = @id"
                                                : "insert SalesPrompt (Name) values (@name); select cast(scope_identity() as int);";
                        command.Parameters.AddWithValue("@id", (object)SalesPromptId ?? DBNull.Value);
                        command.Parameters.AddWithValue("@name", salesPromptName);

                        connection.Open();
                        var newId = (int?)command.ExecuteScalar();
                        ctlAlertMessage.PushAlertMessage("Sales prompt saved", AlertMessage.AlertType.Success);

                        return(newId);
                    }
            }
            catch (Exception exception)
            {
                ctlAlertMessage.PushAlertMessage(String.Format("Could not save:<br />{0}", exception.ToString()), AlertMessage.AlertType.Error);
                return(null);
            }
        }
Ejemplo n.º 27
0
        void LoadTopic()
        {
            var locale = LocaleSelector
                         .GetSelectedLocale()
                         .Name;

            if (TopicId == null)
            {
                //creating Topic
                txtTopicName.Text
                                = txtTopicTitle.Text
                                = ltSEKeywords.Text
                                = ltSETitle.Text
                                = ltSEDescription.Text
                                = txtPassword.Text
                                = txtDspOrdr.Text
                                = String.Empty;

                radDescription.Content          = String.Empty;
                txtDescriptionNoHtmlEditor.Text = String.Empty;

                radDescription.Visible             = UseHtmlEditor;
                txtDescriptionNoHtmlEditor.Visible = !UseHtmlEditor;

                rbDisclaimer.SelectedIndex
                      = rbPublish.SelectedIndex
                      = 0;

                chkIsFrequent.Checked = true;

                storeMapperWrapper.Visible = TopicFilteringEnabled && Store.StoreCount > 1;
            }
            else
            {
                using (var connection = new SqlConnection(DB.GetDBConn()))
                {
                    connection.Open();

                    var sql = "select * from Topic with(nolock) where TopicID = @topicId";

                    using (var reader = DB.GetRS(sql, new[] { new SqlParameter("topicId", (object)TopicId) }, connection))
                    {
                        if (!reader.Read())
                        {
                            AlertMessageDisplay.PushAlertMessage(AppLogic.GetString("admin.common.UnableToRetrieveData", ThisCustomer.LocaleSetting), AlertMessage.AlertType.Error);
                            return;
                        }

                        txtTopicName.Text  = DB.RSFieldByLocale(reader, "Name", locale);
                        txtTopicTitle.Text = DB.RSFieldByLocale(reader, "Title", locale);

                        if (UseHtmlEditor)
                        {
                            radDescription.Content = DB.RSFieldByLocale(reader, "Description", locale);
                        }
                        else
                        {
                            txtDescriptionNoHtmlEditor.Visible = true;
                            txtDescriptionNoHtmlEditor.Text    = DB.RSFieldByLocale(reader, "Description", locale);
                            radDescription.Visible             = false;
                        }

                        ltSETitle.Text       = DB.RSFieldByLocale(reader, "SETitle", locale);
                        ltSEKeywords.Text    = DB.RSFieldByLocale(reader, "SEKeywords", locale);
                        ltSEDescription.Text = DB.RSFieldByLocale(reader, "SEDescription", locale);

                        txtPassword.Text = DB.RSField(reader, "Password");

                        txtDspOrdr.Text = DB.RSFieldInt(reader, "DisplayOrder").ToString();

                        rbDisclaimer.SelectedIndex = DB.RSFieldBool(reader, "RequiresDisclaimer")
                                                        ? 1
                                                        : 0;

                        rbPublish.SelectedIndex = DB.RSFieldBool(reader, "ShowInSiteMap")
                                                        ? 1
                                                        : 0;

                        PopulateCopyToStoreDropdown(DB.RSFieldByLocale(reader, "Name", locale));

                        chkPublished.Checked  = DB.RSFieldBool(reader, "Published");
                        chkIsFrequent.Checked = DB.RSFieldBool(reader, "IsFrequent");

                        TopicStoreMapper.SelectedStoreID = DB.RSFieldInt(reader, "StoreId");
                    }
                }
            }
        }
Ejemplo n.º 28
0
        bool SaveTopic()
        {
            var locale = LocaleSelector
                         .GetSelectedLocale()
                         .Name;

            Page.Validate();
            if (!Page.IsValid)
            {
                return(false);
            }

            var selectedStoreId = GetSelectedStoreId();
            var existingTopicId = FindTopicId(txtTopicName.Text, selectedStoreId);

            if (existingTopicId.HasValue && existingTopicId != TopicId)
            {
                AlertMessageDisplay.PushAlertMessage(String.Format("A topic with this name already exists in Store ID {0}", selectedStoreId), AlertMessage.AlertType.Error);
                return(false);
            }

            var name            = txtTopicName.Text;
            var title           = AppLogic.FormLocaleXml("Title", txtTopicTitle.Text, locale, "topic", Convert.ToInt32(TopicId));
            var descriptionText = UseHtmlEditor
                                ? radDescription.Content
                                : txtDescriptionNoHtmlEditor.Text;
            var description        = AppLogic.FormLocaleXml("Description", descriptionText, locale, "topic", Convert.ToInt32(TopicId));
            var seKeywords         = AppLogic.FormLocaleXml("SEKeywords", ltSEKeywords.Text, locale, "topic", Convert.ToInt32(TopicId));
            var seDescription      = AppLogic.FormLocaleXml("SEDescription", ltSEDescription.Text, locale, "topic", Convert.ToInt32(TopicId));
            var seTitle            = AppLogic.FormLocaleXml("SETitle", ltSETitle.Text, locale, "topic", Convert.ToInt32(TopicId));
            var displayOrder       = Localization.ParseUSInt(txtDspOrdr.Text);
            var published          = chkPublished.Checked;
            var isFrequent         = chkIsFrequent.Checked;
            var password           = txtPassword.Text;
            var requiresDisclaimer = rbDisclaimer.SelectedValue == "1";
            var showInSiteMap      = rbPublish.SelectedValue == "1";
            var storeId            = GetSelectedStoreId();

            try
            {
                if (TopicId == null)
                {
                    var newTopicId = TopicManager.CreateTopic(
                        name: name,
                        displayOrder: displayOrder,
                        published: published,
                        title: title,
                        isFrequent: isFrequent,
                        description: description,
                        password: password,
                        requiresDisclaimer: requiresDisclaimer,
                        showInSiteMap: showInSiteMap,
                        seTitle: seTitle,
                        seKeywords: seKeywords,
                        seDescription: seDescription,
                        storeId: storeId);

                    AlertMessageDisplay.PushAlertMessage(AppLogic.GetString("admin.topic.addedstatus", ThisCustomer.LocaleSetting), AlertMessage.AlertType.Success);

                    Response.Redirect(String.Format("topic.aspx?topicId={0}", newTopicId));
                    return(true);
                }
                else
                {
                    TopicManager.UpdateTopic(
                        topicId: TopicId.Value,
                        name: name,
                        displayOrder: displayOrder,
                        published: published,
                        title: title,
                        isFrequent: isFrequent,
                        description: description,
                        password: password,
                        requiresDisclaimer: requiresDisclaimer,
                        showInSiteMap: showInSiteMap,
                        seTitle: seTitle,
                        seKeywords: seKeywords,
                        seDescription: seDescription,
                        storeId: storeId);

                    AlertMessageDisplay.PushAlertMessage(AppLogic.GetString("admin.topic.updatedstatus", ThisCustomer.LocaleSetting), AlertMessage.AlertType.Success);

                    LoadTopic();
                    return(true);
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
                throw;
            }
            catch (Exception ex)
            {
                AlertMessageDisplay.PushAlertMessage(ex.Message, AlertMessage.AlertType.Error);
                return(false);
            }
        }
Ejemplo n.º 29
0
 private void Connection_ConnectionAccepted(object sender, ConnectionAcceptedEventArgs e)
 {
     Application.Current.Dispatcher.Invoke(() => StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_ConnectedToServer"));
 }