Beispiel #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);
            }
        }
        private void InitViewByOperationConfig()
        {
            var lastView = IniFileHelper.IniReadValue(UserOperationSection, CustomUtils.LastViewKey);
            var tabItems = ViewTabControl.Items.Cast <TabItem>();

            ViewTabControl.SelectedItem = tabItems.FirstOrDefault(i => i.Name == lastView);
        }
Beispiel #3
0
        /// <summary>
        /// 读取本地配置信息
        /// </summary>
        public void ReadConfigInfo()
        {
            string cfgINI = AppDomain.CurrentDomain.BaseDirectory + LocalConfiguration.INI_CFG;

            if (File.Exists(cfgINI))
            {
                IniFileHelper ini = new IniFileHelper(cfgINI);
                Account     = ini.IniReadValue("Login", "Account");
                Password    = CEncoder.Decode(ini.IniReadValue("Login", "Password"));
                UserChecked = ini.IniReadValue("Login", "SaveInfo") == "Y";
                SkinName    = ini.IniReadValue("Skin", "Skin");
                //UpdateIP = ini.IniReadValue("OAUS", "UpdateIP");
                //UpdatePort = ini.IniReadValue("OAUS", "UpdatePort");
            }
            UpdateIP   = ConfigUtil.GetValue("ServerIP");
            UpdatePort = ConfigUtil.GetValue("ServerPort");
        }
        /// <summary>
        /// 读取本地配置信息
        /// </summary>
        public void ReadConfigInfo()
        {
            string cfgINI = AppDomain.CurrentDomain.BaseDirectory + LocalConfiguration.INI_CFG;

            if (System.IO.File.Exists(cfgINI))
            {
                IniFileHelper ini = new IniFileHelper(cfgINI);
                UpdateIP = ini.IniReadValue("OAUS", "UpdateIP");
            }
        }
        private void InitViewByOperationConfig()
        {
            var appConfig = IniFileHelper.IniReadValue(CustomUtils.UserLayoutSection, CustomUtils.LastViewKey);

            if (appConfig == nameof(SearchWordView))
            {
                ShowWordView();
            }
            else if (appConfig == nameof(TranslationView))
            {
                ShowTranslationView();
            }
        }
Beispiel #6
0
        public static UserSetting GetUserSetting()
        {
            var projectKey  = IniFileHelper.IniReadValue(UserSetting, ProjectKey);
            var accountKey  = IniFileHelper.IniReadValue(UserSetting, AccountKey);
            var passwordKey = IniFileHelper.IniReadValue(UserSetting, PasswordKey);

            return(new UserSetting()
            {
                ProjectName = projectKey,
                Account = accountKey,
                Password = passwordKey
            });
        }
Beispiel #7
0
        private void InitViewByOperationConfig()
        {
            //设置上次选中的单词tab
            var itemHeaderName = IniFileHelper.IniReadValue(CustomUtils.UserLayoutSection, CustomUtils.LastWorkTab);
            var itemCollection = TheTabControl.Items;

            foreach (var tabItemObject in itemCollection)
            {
                if (tabItemObject is TabItem tabItem && tabItem.Header.ToString().Equals(itemHeaderName))
                {
                    tabItem.IsSelected = true;
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// 获取本地样式参数
        /// </summary>
        /// <returns></returns>
        public static string GetSkin()
        {
            string cfgINI = AppDomain.CurrentDomain.BaseDirectory + INI_CFG;

            if (File.Exists(cfgINI))
            {
                IniFileHelper ini      = new IniFileHelper(cfgINI);
                string        SkinName = ini.IniReadValue("Skin", "Skin");
                return(SkinName);
            }
            else
            {
                return(string.Empty);
            }
        }
Beispiel #9
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            LogManager.WiteLog("启动浏览器窗口");

            browser.LifeSpanHandler = new OpenPageSelf();

            WindowHelper.SetForegroundWindowX(new WindowInteropHelper(this).Handle);

            setting          = new ClientSetting();
            setting.HomeUrl  = this.browser.Address;
            setting.Location = new ClientLocation()
            {
                X      = this.Left,
                Y      = this.Top,
                Width  = this.Width,
                Height = this.Height
            };

            iniSetting = new IniFileHelper(Path.Combine(appCachePath, "setting.ini"));
            string channelPort     = iniSetting.IniReadValue("General", "ChannelPort");
            string shareChannelUri = string.Format("tcp://localhost:{0}/ShareObject", channelPort);

            receiveMessageThread = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    ShareObject remoteObject = (ShareObject)Activator.GetObject(typeof(ShareObject), shareChannelUri);
                    if (remoteObject != null)
                    {
                        HandleMessage(remoteObject);
                    }

                    Thread.Sleep(2000);
                }
            }));
            receiveMessageThread.Start();
        }