Beispiel #1
0
        private TableConfigurator()
        {
            InitializeComponent();
            string fieldValueFormat = JSetting.ReadAppSetting("FieldValueFormat");

            if (!string.IsNullOrEmpty(fieldValueFormat))
            {
                string[] formats = fieldValueFormat.Trim().Split(',');
                if (formats.Length == 3)
                {
                    JTable.NumericFieldValueFormat  = formats[0];
                    JTable.StringFieldValueFormat   = formats[1];
                    JTable.DateTimeFieldValueFormat = formats[2];
                }
            }

            this.tableConfigCtrl1.FileChanged += this.OnFileChanged;
            this.LoadAction = (fileName) =>
            {
                this.tableConfigCtrl1.LoadFile(fileName);
                if (!string.IsNullOrEmpty(this.tableConfigCtrl1.TableSetting.ConnStr))
                {
                    this.ConnStr = this.tableConfigCtrl1.TableSetting.ConnStr;
                    this.ShowInStatus(this.ConnStr);
                }
            };
            this.SaveAction = (fileName) =>
            {
                this.tableConfigCtrl1.SaveFile(fileName, this.Extension);
            };
        }
Beispiel #2
0
        private void InitTree()
        {
            DirectoryInfo dir = new DirectoryInfo(JSetting.Get <String>("CodeSnippet"));

            if (!dir.Exists)
            {
                return;
            }

            if (!imageListOfDirectory.Images.ContainsKey(folderKeyOfImageList))
            {
                imageListOfDirectory.Images.Add(folderKeyOfImageList, FileHelper.GetDirectoryIcon());
            }

            TreeNode rootNode = new TreeNode("我的代码段")
            {
                Name = JSetting.Get <String>("CodeSnippet"), Tag = JSetting.Get <String>("CodeSnippet"), ImageKey = folderKeyOfImageList, SelectedImageKey = folderKeyOfImageList
            };

            tvDirectory.Nodes.Clear();
            tvDirectory.Nodes.Add(rootNode);
            BindTreeNode(rootNode, dir, false);
            rootNode.Expand();
            CreateSharpEditor();
            CreateWebBrower();
            CreateDSOFramer();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Workbench wk = null;

            if (args != null && args.Length > 0)
            {
                wk = new Workbench(args);
            }
            else
            {
                wk = new Workbench();
            }
            try
            {
                bool enableFileLog = JSetting.ReadAppSetting("EnableFileLog").Value <bool>();
                if (enableFileLog)
                {
                    MessageSvc.Default.MessageReceived += MessageReceived;
                }

                MessageSvc.Default.MessageReceived += OutPutWindow.Instance.MessageReceived;

                Application.Run(wk);
            }
            catch (Exception ex)
            {
                JLog.Default.Write(LogMode.Error, ex);
            }
        }
Beispiel #4
0
 private void CubeViewer_Load(object sender, EventArgs e)
 {
     try
     {
         JSetting.SetUseAppSetting("OLAPConnStr", "OLAPConnStr");
         //CubeViewCtrlSetting.DefaultConnStr = ConfigurationManager.AppSettings["OLAPConnStr"];
     }
     catch { }
 }
Beispiel #5
0
        private void Workbench_Load(object sender, EventArgs e)
        {
            m_bSaveLayout       = JSetting.ReadAppSetting <bool>("SaveWindowLayout");
            notifyIcon1.Visible = JSetting.ReadAppSetting <bool>("ShowInNotifyArea");


            this.ShowMessage("addin【{0}】", AddinFileName);

            if (File.Exists(AddinFileName))
            {
                try
                {
                    addinConfig = SerializeHelper.XmlDeserializeFromFile <AddinConfig>(AddinFileName);

                    if (addinConfig != null && addinConfig.Tools != null)
                    {
                        foreach (var item in addinConfig.Tools)
                        {
                            if (!Assemblies.ContainsKey(item.DllFileName))
                            {
                                Assembly assembly = Assembly.Load(item.DllFileName);
                                Assemblies.Add(item.DllFileName, assembly);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.ShowMessage(ex);
                }
            }
            if (!specialFile) //加载上次打开的文件
            {
                string configFile = Path.Combine(Application.StartupPath, "DockPanel.config");
                try
                {
                    if (File.Exists(configFile))
                    {
                        dockPanel.LoadFromXml(configFile, m_deserializeDockContent);
                    }
                }
                catch
                {
                    File.Delete(configFile);
                }
            }
            else   //右键文件名,进行打开
            {
                OpenFileAccordingToFile(rightContextMenuFileName);
            }
            OutPutWin = OutPutWindow.Instance;
            OutPutWin.Show(dockPanel, DockState.DockBottom);

            dockPanel.ShowDocumentIcon = true;

            DynamicMenuGenerate();
        }
Beispiel #6
0
 public JCodeCompiler()
 {
     InitializeComponent();
     JSetting.SetUseAppSetting("JDKPath", "JDKPath");
     //CodeComplierCtrl.JDKPath = ConfigurationManager.AppSettings["JDKPath"];
     this.codeComplierCtrl1.FileChanged = (fileName) => { this.FileName = fileName; };
     this.LoadAction = (fileName) => { this.codeComplierCtrl1.LoadFile(fileName); };
     this.SaveAction = (fileName) => { this.codeComplierCtrl1.SaveFile(fileName, this.Extension); };
 }
Beispiel #7
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
     {
         txtFolder.Text = folderBrowserDialog1.SelectedPath;
         JSetting.Set("CodeSnippet", folderBrowserDialog1.SelectedPath);
         InitTree();
     }
 }
        public static void InitIfNeed()
        {
            if (IsInitilized == false)
            {
                /*
                 * CachePath The location where cache data will be stored on disk.If empty an in-memory cache will be used for some features and a temporary disk cache will be used for others.HTML5 databases such as localStorage will only persist across sessions if a cache path is specified.
                 * Locale The locale string that will be passed to Blink.If empty the default locale of "en-US" will be used.Also configurable using the "lang" command - line switch.Change this to set the Context menu language as well.
                 * LogFile The directory and file name to use for the debug log.If empty, the default name of "debug.log" will be used and the file will be written to the application directory.Also configurable using the "log-file" command - line switch.
                 * LogSeverity The log severity. Only messages of this severity level or higher will be logged.Also configurable using the "log-severity" command - line switch with a value of "verbose", "info", "warning", "error", "error-report" or "disable".
                 *
                 * //CefCommandLineArgs example
                 * // Enable WebRTC
                 * settings.CefCommandLineArgs.Add("enable-media-stream", "1");
                 * //Disable GPU Acceleration
                 * settings.CefCommandLineArgs.Add("disable-gpu", "1");
                 * // Don't use a proxy server, always make direct connections. Overrides any other proxy server flags that are passed.
                 * // Slightly improves Cef initialize time as it won't attempt to resolve a proxy
                 * settings.CefCommandLineArgs.Add("no-proxy-server", "1");
                 * //Chromium Command Line args
                 * //http://peter.sh/experiments/chromium-command-line-switches/
                 */
                var settings = new CefSettings();

                JSetting setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting()
                {
                    Name        = "MainApp.userAgent",
                    Description = "User Agent",
                    ValueType   = typeof(JUserAgent),
                    IsUser      = true
                });
                JUserAgent userAgent = (JUserAgent)FrwConfig.Instance.GetPropertyValue(setting.Name);
                if (userAgent != null)
                {
                    //JUserAgent userAgent = Dm.Instance.Find<JUserAgent>(userAgentId);
                    //if (userAgent == null) throw new Exception("User Agent not found by id = " + userAgentId);
                    settings.UserAgent = userAgent.Data;
                }
                else
                {
                    //    "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Acoo Browser 1.98.744; .NET CLR 3.5.30729)",
                    //    "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko",
                    //    "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)",
                    //    "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"

                    settings.UserAgent = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36";
                }
                //For Windows 7 and above, best to include relevant app.manifest entries as well
                //Cef.EnableHighDPISupport(); - todo test it

                if (!Cef.Initialize(settings))
                {
                    throw new Exception("Unable to Initialize Cef");
                }
                IsInitilized = true;
            }
        }
Beispiel #9
0
 private void MdxExecutor_Load(object sender, EventArgs e)
 {
     this.LoadFile(this.FileName);
     try
     {
         JSetting.SetUseAppSetting("OLAPConnStr", "OLAPConnStr");
         //MdxExecuterCtrlSetting.DefaultConnStr = ConfigurationManager.AppSettings["OLAPConnStr"];
     }
     catch { }
 }
Beispiel #10
0
        private void CodeViewCtrl_Load(object sender, EventArgs e)
        {
            this.ShowToolTips(new ToolTip());

            if (string.IsNullOrEmpty(JSetting.Get <String>("CodeSnippet")))
            {
                return;
            }
            txtFolder.Text = JSetting.Get <String>("CodeSnippet");
            InitTree();
        }
Beispiel #11
0
 static public BaseProxyServer GetDefaulBaseProxyServer()
 {
     if (BaseProxyServerDefault == null)
     {
         JSetting setting = FrwConfig.Instance.GetProperty(DEFAULT_JPROXY_SERVER);
         if (setting != null)
         {
             BaseProxyServerDefault = setting.Value as BaseProxyServer;
         }
     }
     return(BaseProxyServerDefault);
 }
Beispiel #12
0
        void MdxExecutor_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.MdiFormClosing)
            {
                e.Cancel = true;
            }

            bool save = JSetting.ReadAppSetting <bool>("SaveFileWhenExit");

            if (save && (e.CloseReason == CloseReason.ApplicationExitCall || e.CloseReason == CloseReason.UserClosing))
            {
                this.mdxExecuterCtrl1.SaveFile(this.FileName, this.Extension);
            }
        }
Beispiel #13
0
        //Open
        private void subItemOfOpen_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsItem = sender as ToolStripMenuItem;

            Justin.Core.MenuItem data = tsItem.Tag as Justin.Core.MenuItem;
            openFileDialog1.InitialDirectory = JSetting.ReadAppSetting("ConfigFileFolder");//注意这里写路径时要用c:\\而不是c:\
            openFileDialog1.Filter           = Tools.GetFileDialogFilter(data.Extensions);
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.FilterIndex      = 1;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string fileName = openFileDialog1.FileName;
                ActiveContent(data, fileName);
            }
        }
Beispiel #14
0
        private void TableConfigCtrl_Load(object sender, EventArgs e)
        {
            JSetting.SetUseAppSetting("TableConfigFolder", "TableConfigFolder");
            if (this.TableSetting != null)
            {
                BindTableToTree();
            }
            JTable.SqlProcess = (StringBuilder sqlBuilder, JTable table) =>
            {
                string fileName = GetFullFileName(table.TableName, sqlFileExtensions);
                File.AppendAllText(fileName, sqlBuilder.ToString());
            };

            this.ShowToolTips(new ToolTip());
        }
Beispiel #15
0
        private void SaveToFile(List <MdxCodeSnip> list)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            var            form            = this.FindForm();

            saveFileDialog1.InitialDirectory = JSetting.ReadAppSetting("ConfigFileFolder");;
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.Filter           = "xml Files (.xml)|*.xml|All Files (*.*)|*.*";
            saveFileDialog1.FilterIndex      = 1;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string fileName = saveFileDialog1.FileName;
                SerializeHelper.XmlSerializeToFile <List <MdxCodeSnip> >(list, fileName, true);
            }
        }
Beispiel #16
0
        private void MdxExecuterCtrl_Load(object sender, EventArgs e)
        {
            this.cboxConnStrings.Items.Clear();
            foreach (var item in ConfigurationManager.AppSettings.AllKeys)
            {
                if (item.StartsWith("OLAPConnStr", StringComparison.CurrentCultureIgnoreCase))
                {
                    this.cboxConnStrings.Items.Add(ConfigurationManager.AppSettings[item]);
                }
            }
            txtMdx.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("TSQL");
            txtMdx.Encoding = Encoding.GetEncoding("GB2312");

            this.ShowToolTips(new ToolTip());
            if (string.IsNullOrEmpty(cboxConnStrings.Text))
            {
                this.cboxConnStrings.Text = JSetting.Get("OLAPConnStr");
            }
        }
Beispiel #17
0
        private void CubeViewCtrl_Load(object sender, EventArgs e)
        {
            this.ShowToolTips(new ToolTip());
            this.cboxConnStrings.Items.Clear();
            foreach (var item in ConfigurationManager.AppSettings.AllKeys)
            {
                if (item.StartsWith("OLAPConnStr", StringComparison.CurrentCultureIgnoreCase))
                {
                    this.cboxConnStrings.Items.Add(ConfigurationManager.AppSettings[item]);
                }
            }

            if (string.IsNullOrEmpty(cboxConnStrings.Text))
            {
                this.cboxConnStrings.Text = JSetting.Get("OLAPConnStr");
            }
            JSetting.SetUseAppSetting("OLAPConnStr", "OLAPConnStr");
            cboxFilterType.Items.Clear();
            cboxFilterType.Items.AddRange(Enum.GetNames(typeof(FilterType)));
        }
Beispiel #18
0
        private void loadMdxFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            string         folder     = JSetting.ReadAppSetting("ConfigFileFolder");;

            fileDialog.InitialDirectory = folder;
            fileDialog.RestoreDirectory = true;

            fileDialog.Filter = "XML Files (.txt)|*.xml|All Files (*.*)|*.*";
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                List <MdxCodeSnip> list = SerializeHelper.XmlDeserializeFromFile <List <MdxCodeSnip> >(fileDialog.FileName);
                if (list == null)
                {
                    return;
                }
                foreach (var item in list)
                {
                    AddMdxEditorTabPage(item.Name, item.ConnStr, item.Mdx);
                }
            }
        }
Beispiel #19
0
        private void btnBrowerFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            string         folder     = JSetting.ReadAppSetting("ConfigFileFolder");

            if (!string.IsNullOrEmpty(txtFileName.Text))
            {
                var dic = new DirectoryInfo(Path.GetDirectoryName(txtFileName.Text));
                if (dic.Exists)
                {
                    folder = Path.GetDirectoryName(txtFileName.Text);
                }
            }

            fileDialog.InitialDirectory = folder;
            fileDialog.RestoreDirectory = true;

            fileDialog.Filter = "XML Files (.txt)|*.xml|All Files (*.*)|*.*";
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                txtFileName.Text = fileDialog.FileName;
            }
        }
Beispiel #20
0
        //must be call after Dm init
        public static void InitSettings()
        {
            JSetting setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting()
            {
                Name        = "Vpn.Reconnect",
                Description = VpnSelectorLibRes.Reconnect_to_VPN,
                Help        = VpnSelectorLibRes.Reconnect_to_current_VPN_server_when_connection_lost,
                Group       = "VPN",
                Value       = true,
                IsUser      = true
            });

            NetConnUtils.IsReconnect = FrwConfig.Instance.GetPropertyValueAsBool(setting.Name, true);
            setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting()
            {
                Name        = NetConnUtils.DEFAULT_JPROXY_SERVER,
                Description = VpnSelectorLibRes.VPN_server_by_default,
                Group       = "VPN",
                Value       = null,
                ValueType   = BaseProxyServer.CurrentType,
                IsUser      = true
            });
        }
Beispiel #21
0
        private void txtSQLPreview_Load(object sender, EventArgs e)
        {
            txtSQLPreview.BoxPart.ReadOnly = false;
            #region tips

            btnIntelligentExecuteSQL.Tag = string.Format(@"{0}
{1}   
以上两行之内的SQL将一次性执行.
分段SQL开始符:{0}
分段SQL结束符:{1}
", Constants.SQLParagraphStartFlag, Constants.SQLParagraphEndFlag);
            this.ShowToolTips(new ToolTip());

            #endregion

            #region openFileDialog

            openFileDialog.InitialDirectory = JSetting.ReadAppSetting("OuputSQLFileFolder");

            StringBuilder filterBuilder = new StringBuilder();
            //FileInfoAttribute fia = FileType.SQL.GetFileInfoAttribute();
            //filterBuilder.AppendFormat(Constants.OpenFileDialogFilterFormart, fia.DefaultFileExtension, fia.DefaultDisplayName);
            //foreach (string fileExtension in fia.GetAllowFileExtensions(true))
            //{
            //    filterBuilder.AppendFormat(Constants.OpenFileDialogFilterFormart, fileExtension, fileExtension);
            //}
            filterBuilder.AppendFormat(Constants.OpenFileDialogFilterFormart, "sql", "sql文件");
            filterBuilder.AppendFormat(Constants.OpenFileDialogFilterFormart, "*", "所有");
            openFileDialog.Filter = filterBuilder.ToString().TrimEnd('|');

            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;

            #endregion
            txtSQLPreview.AllowDrop = true;
        }
Beispiel #22
0
 public TestDataGenerator()
 {
     InitializeComponent();
     JSetting.SetUseAppSetting("TableConfigFolder", "TableConfigFolder");
 }
Beispiel #23
0
        static void Main()
        {
            AppManager.AjustVideoSetting();
            try
            {
                Form form = null;
                try
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    if (!AppManager.CheckForSingleInstance())
                    {
                        return;
                    }
                    //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en");
                    log = Log.GetLogger();
                    //http://stackoverflow.com/questions/8137070/force-application-close-on-system-shutdown
                    //SystemEvents can help you. The SessionEnding occurs when the user is trying to log off or shut down the system.
                    Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding;
                    //If you don't want to cancel the event, but just react to it appropriately, you should handle the SystemEvents.SessionEnded event instead.
                    Microsoft.Win32.SystemEvents.SessionEnded += SystemEvents_SessionEnded;

                    //create instances of manager classes
                    FrwConfig.Instance  = new FrwSimpleWinCRUDConfig(); //WebAccountConfig();
                    Dm.Instance         = new WebAccountDm();
                    AppManager.Instance = new WebAccountLibAppManager();
                    AppManager.Instance.MainAppFormType       = typeof(WebAccountMainForm);
                    AppManager.Instance.DefaultViewWindowType = typeof(BrowserViewWindow);

                    //force load dlls with entities
                    VpnSelectorLibLoader.Load();
                    WebAccountLibLoader.Load();

                    AppManager.Instance.InitApplication();

                    JSetting setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting()
                    {
                        Name                 = "RunAppInWindowsTray",
                        Description          = VpnSelectorLibRes.Run_application_in_windows_system_tray__next_run_,
                        Value                = true,
                        IsUser               = true,
                        IsAttachedToComputer = false
                    });
                    if (FrwConfig.Instance.GetPropertyValueAsBool(setting.Name, true))
                    {
                        applicationContext = new BaseApplicationContext();
                        applicationContext.DefaultTooltip = VpnSelectorLibRes.VPN_selector;
                        applicationContext.IconFileName   = "bookmark_icon.ico";
                        applicationContext.Load();
                        BaseApplicationContext.NotifyIcon.Icon = VpnSelectorLibRes.vpn_off;
                        applicationContext.ThreadExit         += ApplicationContext_ThreadExit;
                        Application.Run(applicationContext);
                    }
                    else
                    {
                        form              = AppManager.Instance.LoadDocPanelContainersState(true);
                        form.FormClosing += Form_FormClosing;
                        form.FormClosed  += Form_FormClosed;
                    }
                }
                catch (Exception ex)
                {
                    Log.ShowError("Error start app", ex);
                    Application.Exit();
                }
                if (form != null && !form.IsDisposed)
                {
                    Application.ThreadException += Application_ThreadException;
                    Application.Run(form);
                }
            }
            catch (Exception ex)
            {
                Log.ShowError("Error running main app form", ex);
                MessageBox.Show("Unexpected error: " + ex);
                Application.Exit();
            }
        }
Beispiel #24
0
 public CodeSnippetMgr()
 {
     JSetting.SetUseAppSetting("CodeSnippet", "CodeSnippet");
     //CodeSnippetCtrl.CodeSnippetFileDirectory = ConfigurationManager.AppSettings["CodeSnippet"];
     InitializeComponent();
 }
Beispiel #25
0
        public static string GetFullFileName(string tableName, string fileExtension)
        {
            string fullFileName = Path.Combine(JSetting.Get <String>("TableConfigFolder"), string.Format("{0}{1}", tableName, fileExtension));

            return(fullFileName);
        }
Beispiel #26
0
 private void btnDefaultConnStr_Click(object sender, EventArgs e)
 {
     this.cboxConnStrings.Text = JSetting.Get("OLAPConnStr");
 }
Beispiel #27
0
        static void Main()
        {
            MainAppUtils.AjustVideoSetting();
            try
            {
                Form form = null;
                try
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    if (!MainAppUtils.CheckForSingleInstance())
                    {
                        return;
                    }
                    log = Log.GetLogger();
                    //http://stackoverflow.com/questions/8137070/force-application-close-on-system-shutdown
                    //SystemEvents can help you. The SessionEnding occurs when the user is trying to log off or shut down the system.
                    Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding;
                    //If you don't want to cancel the event, but just react to it appropriately, you should handle the SystemEvents.SessionEnded event instead.
                    Microsoft.Win32.SystemEvents.SessionEnded += SystemEvents_SessionEnded;

                    //for testing, remove this lines in real app
                    //var culture = new CultureInfo("en-US");
                    //CultureInfo.DefaultThreadCurrentCulture = culture;
                    //CultureInfo.DefaultThreadCurrentUICulture = culture;

                    //create instances of manager classes
                    FrwConfig.Instance  = new VpnSelectorConfig();
                    AppManager.Instance = new VpnSelectorAppManager();
                    AppManager.Instance.MainAppFormType = typeof(VpnSelectorMainForm);
                    Dm.Instance = new VpnSelectorDm();
                    //force load dlls with entities
                    //...
                    VpnSelectorLibLoader.Load();
                    //BaseProxyServer.CurrentType = typeof(FProxyServer);
                    //BaseProxyProvider.CurrentType = typeof(FProxyProvider);

                    MainAppUtils.InitAppPaths();

                    JSetting setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting()
                    {
                        Name                 = "RunAppInWindowsTray",
                        Description          = VpnSelectorLibRes.Run_application_in_windows_system_tray__next_run_,
                        Value                = true,
                        IsUser               = true,
                        IsAttachedToComputer = false
                    });

                    if (FrwConfig.Instance.GetPropertyValueAsBool(setting.Name, true))
                    {
                        applicationContext = new BaseApplicationContext();
                        applicationContext.DefaultTooltip = VpnSelectorLibRes.VPN_selector;
                        applicationContext.IconFileName   = "icon_vpn_selector.ico";
                        applicationContext.Load();
                        BaseApplicationContext.NotifyIcon.Icon = VpnSelectorLibRes.vpn_off;
                        applicationContext.ThreadExit         += ApplicationContext_ThreadExit;
                        Application.Run(applicationContext);
                    }
                    else
                    {
                        form              = AppManager.Instance.LoadDocPanelContainersState(true);
                        form.FormClosing += Form_FormClosing;
                        form.FormClosed  += Form_FormClosed;
                    }
                }
                catch (Exception ex)
                {
                    Log.ShowError("Error start app", ex);
                    Application.Exit();
                }
                if (form != null && !form.IsDisposed)
                {
                    Application.ThreadException += Application_ThreadException;
                    Application.Run(form);
                }
            }
            catch (Exception ex)
            {
                Log.ShowError("Error start app", ex);
                Application.Exit();
            }
        }
Beispiel #28
0
        static public void MakeContextMenuForBaseProxyServer(List <ToolStripItem> items, BaseProxyServer item)
        {
            ToolStripMenuItem menuItem = new ToolStripMenuItem();

            menuItem.Text = VpnSelectorLibRes.Create_VPN_entry_ + " PPTP " + item.GetConnectionName();
            if (NetConnUtils.IsConnectionEntryExist(item) || item.IsProtocolAvailable(ProxyProtocolTypeEnum.PPTP) == false)
            {
                menuItem.Enabled = false;
            }
            menuItem.Click += (s, em) =>
            {
                try
                {
                    NetConnUtils.CreateConnectionEntry(item, ProxyProtocolTypeEnum.PPTP);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            items.Add(menuItem);

            menuItem      = new ToolStripMenuItem();
            menuItem.Text = VpnSelectorLibRes.Create_VPN_entry_ + " L2TP " + item.GetConnectionName();
            if (NetConnUtils.IsConnectionEntryExist(item) || item.IsProtocolAvailable(ProxyProtocolTypeEnum.L2TP) == false)
            {
                menuItem.Enabled = false;
            }
            menuItem.Click += (s, em) =>
            {
                try
                {
                    NetConnUtils.CreateConnectionEntry(item, ProxyProtocolTypeEnum.L2TP);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            items.Add(menuItem);

            menuItem      = new ToolStripMenuItem();
            menuItem.Text = VpnSelectorLibRes.Connect_to_VPN_server;
            if (NetConnUtils.IsConnected(item))
            {
                menuItem.Enabled = false;
            }
            if (NetConnUtils.IsConnectionEntryExist(item))
            {
                menuItem.Text = menuItem.Text + VpnSelectorLibRes.__created_;
            }
            menuItem.Text   = menuItem.Text + " " + item.GetConnectionName();
            menuItem.Click += (s, em) =>
            {
                try
                {
                    DialogResult res = DialogResult.Cancel;
                    if (NetConnUtils.IsActiveConnectionPresent())
                    {
                        res = MessageBox.Show(VpnSelectorLibRes.Active_VPN_connection_found____
                                              + NetConnUtils.ShowConnectionEntries() + VpnSelectorLibRes.__Press_OK_to_close_it_and_connect_to_selected_VPN_server_, VpnSelectorLibRes.Warning_, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                        if (res == DialogResult.OK)
                        {
                            NetConnUtils.CloseAllActiveConnections(false);
                        }
                    }
                    else
                    {
                        res = DialogResult.OK;
                    }

                    if (res == DialogResult.OK)
                    {
                        bool statusChanged = CreateAndConnectToProxyAsync(item);
                    }
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            items.Add(menuItem);


            menuItem      = new ToolStripMenuItem();
            menuItem.Text = VpnSelectorLibRes.Disonnect_from_VPN_server_ + item.GetConnectionName();
            if (!NetConnUtils.IsConnected(item))
            {
                menuItem.Enabled = false;
            }
            menuItem.Click += (s, em) =>
            {
                try
                {
                    NetConnUtils.CloseConnect(item, true);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            items.Add(menuItem);

            menuItem      = new ToolStripMenuItem();
            menuItem.Text = VpnSelectorLibRes.Set_as_default_VPN_connection_ + item.GetConnectionName();
            if (NetConnUtils.GetDefaulBaseProxyServer() == item)
            {
                menuItem.Enabled = false;
            }
            menuItem.Click += (s, em) =>
            {
                try
                {
                    BaseProxyServerDefault = item;
                    JSetting setting = FrwConfig.Instance.GetProperty(DEFAULT_JPROXY_SERVER);
                    setting.Value = item;
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            items.Add(menuItem);
        }