예제 #1
0
        protected override void OnStart(string[] args)
        {
            try
            {
                iniSetting = new IniFileHelper(Path.Combine(appCachePath, "setting.ini"));

                //读取服务和应用程序通讯管道设置
                string channelName = iniSetting.IniReadValue("General", "ChannelName");
                if (string.IsNullOrEmpty(channelName))
                {
                    channelName = "SkyViewerChannel";
                    iniSetting.IniWriteValue("General", "ChannelName", channelName);
                }

                string strChannelPort = iniSetting.IniReadValue("General", "ChannelPort");
                int    channelPort;
                bool   isvalidPort = int.TryParse(strChannelPort, out channelPort);
                if (isvalidPort == false || channelPort == 0)
                {
                    channelPort = 6530;
                    iniSetting.IniWriteValue("General", "ChannelPort", channelPort.ToString());
                }
                channelUri = string.Format("tcp://localhost:{0}/ShareObject", channelPort);

                TcpServerChannel channel = new TcpServerChannel(channelName, channelPort);
                ChannelServices.RegisterChannel(channel, false);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(ShareObject), "ShareObject", WellKnownObjectMode.Singleton);

                exeName = iniSetting.IniReadValue("General", "AppName");
                if (string.IsNullOrEmpty(exeName))
                {
                    exeName = "SkyViewer.exe";
                }

                wkSocketSercerUrl = iniSetting.IniReadValue("Service", "WebSocket");
                if (string.IsNullOrEmpty(wkSocketSercerUrl))
                {
                    LogManager.WiteLog("未设置服务器WebSocket地址");
                }

                ConnectWebSocketServer();

                LogManager.WiteLog("服务启动成功!");
            }
            catch (Exception ex)
            {
                LogManager.WiteLog("服务启动发送错误" + ex.Message + " " + ex.StackTrace);
            }
        }
예제 #2
0
 private void TabItem_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (sender is TabItem item)
     {
         IniFileHelper.IniWriteValue(CustomUtils.UserLayoutSection, CustomUtils.LastWorkTab, item.Header.ToString());
     }
 }
예제 #3
0
        /// <summary>
        /// 设置样式
        /// </summary>
        /// <param name="SkinName"></param>
        public static void SetKin(string SkinName)
        {
            string        cfgINI = AppDomain.CurrentDomain.BaseDirectory + INI_CFG;
            IniFileHelper ini    = new IniFileHelper(cfgINI);

            ini.IniWriteValue("Skin", "Skin", SkinName);
        }
예제 #4
0
        /// <summary>
        /// 保存登录信息
        /// </summary>
        private void SaveLoginInfo()
        {
            string        cfgINI = AppDomain.CurrentDomain.BaseDirectory + LocalConfiguration.INI_CFG;
            IniFileHelper ini    = new IniFileHelper(cfgINI);

            ini.IniWriteValue("Login", "Account", Account);
            if (UserChecked)
            {
                ini.IniWriteValue("Login", "Password", CEncoder.Encode(Password));
                ini.IniWriteValue("Login", "SaveInfo", "Y");
            }
            else
            {
                ini.IniWriteValue("Login", "Password", string.Empty);
                ini.IniWriteValue("Login", "SaveInfo", "N");
            }
        }
예제 #5
0
        private void ViewTabControl_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selectedItem = ViewTabControl.SelectedItem as TabItem;

            if (!string.IsNullOrEmpty(selectedItem?.Name))
            {
                IniFileHelper.IniWriteValue(UserOperationSection, CustomUtils.LastViewKey, selectedItem.Name);
            }
        }
        /// <summary>
        /// 点击按钮,确认/取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void ConfirSaveProjectPathHandler(object sender, DialogClosingEventArgs eventArgs)
        {
            if ("False".Equals(eventArgs.Parameter.ToString()))
            {
                return;
            }
            // cancel the close
            eventArgs.Cancel();

            var    FileTextBox = eventArgs.Parameter as System.Windows.Controls.TextBox;
            String FullPath    = FileTextBox.Text;

            if (string.IsNullOrEmpty(FullPath))
            {
                MessageBox.Show("请选择文件", "提示");
                return;
            }

            try
            {
                string        cfgINI = AppDomain.CurrentDomain.BaseDirectory + LocalConfiguration.INI_CFG;
                IniFileHelper ini    = new IniFileHelper(cfgINI);
                ini.IniWriteValue("Project", "FilePath", FullPath);

                // 显示加载1s
                eventArgs.Session.UpdateContent(new SampleProgressDialog());
                Task.Delay(TimeSpan.FromSeconds(0.3))
                .ContinueWith((t, _) => eventArgs.Session.Close(false), null,
                              TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().updateShow(ex, eventArgs.Session);
                return;
            }
        }
 private void BackToWordViewButton_OnClick(object sender, RoutedEventArgs e)
 {
     IniFileHelper.IniWriteValue(CustomUtils.UserLayoutSection, CustomUtils.LastViewKey, nameof(SearchWordView));
     ShowWordView();
 }
 private void ShowTranslationViewButton_OnClick(object sender, RoutedEventArgs e)
 {
     IniFileHelper.IniWriteValue(CustomUtils.UserLayoutSection, CustomUtils.LastViewKey, nameof(TranslationView));
     ShowTranslationView();
 }
예제 #9
0
 public static void SetUserSetting(UserSetting userSetting)
 {
     IniFileHelper.IniWriteValue(UserSetting, ProjectKey, userSetting.ProjectName);
     IniFileHelper.IniWriteValue(UserSetting, AccountKey, userSetting.Account);
     IniFileHelper.IniWriteValue(UserSetting, PasswordKey, userSetting.Password);
 }