Exemple #1
0
        public void ShowFormattingDialog()
        {
            var foldChangeRows = _bindingListSource.OfType <RowItem>()
                                 .Select(rowItem => rowItem.Value)
                                 .OfType <FoldChangeBindingSource.FoldChangeRow>()
                                 .ToArray();

            var backup = GroupComparisonDef.ColorRows.Select(r => (MatchRgbHexColor)r.Clone()).ToArray();
            // This list will later be used as a BindingList, so we have to create a mutable clone
            var copy = GroupComparisonDef.ColorRows.Select(r => (MatchRgbHexColor)r.Clone()).ToList();

            using (var form = new VolcanoPlotFormattingDlg(this, copy, foldChangeRows,
                                                           rows =>
            {
                EditGroupComparisonDlg.ChangeGroupComparisonDef(false, GroupComparisonModel, GroupComparisonDef.ChangeColorRows(rows));
                UpdateGraph();
            }))
            {
                if (form.ShowDialog(FormEx.GetParentForm(this)) == DialogResult.OK)
                {
                    EditGroupComparisonDlg.ChangeGroupComparisonDef(true, GroupComparisonModel, GroupComparisonDef);
                }
                else
                {
                    EditGroupComparisonDlg.ChangeGroupComparisonDef(false, GroupComparisonModel, GroupComparisonDef.ChangeColorRows(backup));
                }

                UpdateGraph();
            }
        }
Exemple #2
0
        private void OpenWithForm_Load(object sender, EventArgs e)
        {
            FormEx.Dockable(this);

            BackColor = Main.Colors.BaseDark;

            Icon = Resources.PortableApps_blue;

            Lang.SetControlLang(this);
            Text = Lang.GetText(Name);

            Main.SetFont(this);
            Main.SetFont(appMenu);

            var notifyBox = new NotifyBox {
                Opacity = .8d
            };

            notifyBox.Show(Lang.GetText(nameof(en_US.FileSystemAccessMsg)), Main.Title, NotifyBox.NotifyBoxStartPosition.Center);
            Main.CheckCmdLineApp();
            notifyBox.Close();
            if (WinApi.NativeHelper.GetForegroundWindow() != Handle)
            {
                WinApi.NativeHelper.SetForegroundWindow(Handle);
            }

            AppsBox_Update(false);
        }
Exemple #3
0
        public bool Open(string skypPath, IEnumerable <Server> servers, FormEx parentWindow = null)
        {
            try
            {
                var skyp = SkypFile.Create(skypPath, servers);

                using (var longWaitDlg = new LongWaitDlg
                {
                    Text = Resources.SkypSupport_Open_Downloading_Skyline_Document_Archive,
                })
                {
                    longWaitDlg.PerformWork(parentWindow ?? _skyline, 1000, progressMonitor => Download(skyp, progressMonitor, parentWindow));
                    if (longWaitDlg.IsCanceled)
                    {
                        return(false);
                    }
                }
                return(_skyline.OpenSharedFile(skyp.DownloadPath));
            }
            catch (Exception e)
            {
                var message = TextUtil.LineSeparate(Resources.SkypSupport_Open_Failure_opening_skyp_file_, e.Message);
                MessageDlg.ShowWithException(parentWindow ?? _skyline, message, e);
                return(false);
            }
        }
Exemple #4
0
 public void ShowProperties()
 {
     using (var dlg = new VolcanoPlotPropertiesDlg())
     {
         dlg.ShowDialog(FormEx.GetParentForm(this));
     }
 }
        void EnableFormEvents()
        {
            _form = CoreUtil.GetParent<FormEx>(this);

            if(_form != null)
            {
                CoreUtil.AdjustImages(this, ref _dpiOld, _form.DpiNew);
            }
        }
Exemple #6
0
 private void toolStripProperties_Click(object sender, EventArgs e)
 {
     using (var dlgProperties = new AreaCVToolbarProperties(_graphSummary))
     {
         if (dlgProperties.ShowDialog(FormEx.GetParentForm(this)) == DialogResult.OK)
         {
             _graphSummary.UpdateUI();
         }
     }
 }
 protected void TextBox_GotFocus(object sender, EventArgs e)
 {
     if (StatementCompletionForm != null && !StatementCompletionForm.Visible)
     {
         StatementCompletionForm.Show(FormEx.GetParentForm(TextBox));
         StatementCompletionForm.ResizeToIdealSize(ScreenRect);
     }
     else
     {
         DoStatementCompletion();
     }
 }
Exemple #8
0
 private static void SystemEventsOnDisplaySettingsChanged(object sender, EventArgs eventArgs)
 {
     foreach (Form form in FormUtil.OpenForms)
     {
         Rectangle rcForm = form.Bounds;
         var       screen = Screen.FromControl(form);
         if (!rcForm.IntersectsWith(screen.WorkingArea))
         {
             FormEx.ForceOnScreen(form);
         }
     }
 }
Exemple #9
0
 //marked public for testing purposes
 public void pbProperties_Click(object sender, EventArgs e)
 {
     using (var dlgProperties = new DetectionToolbarProperties(_graphSummary))
     {
         _timer.Stop();
         if (dlgProperties.ShowDialog(FormEx.GetParentForm(this)) == DialogResult.OK)
         {
             UpdateUI();
             _timer.Start();
         }
     }
 }
Exemple #10
0
        private void Download(SkypFile skyp, IProgressMonitor progressMonitor, FormEx parentWindow = null)
        {
            var progressStatus =
                new ProgressStatus(string.Format(Resources.SkypSupport_Download_Downloading__0_, skyp.SkylineDocUri));

            progressMonitor.UpdateProgress(progressStatus);

            if (DownloadClient == null)
            {
                DownloadClient = new WebDownloadClient(progressMonitor, progressStatus);
            }

            DownloadClient.Download(skyp.SkylineDocUri, skyp.DownloadPath, skyp.Server?.Username, skyp.Server?.Password);

            if (progressMonitor.IsCanceled || DownloadClient.IsError)
            {
                FileEx.SafeDelete(skyp.DownloadPath, true);
            }
            if (DownloadClient.IsError)
            {
                var message =
                    string.Format(
                        Resources
                        .SkypSupport_Download_There_was_an_error_downloading_the_Skyline_document_specified_in_the_skyp_file___0__,
                        skyp.SkylineDocUri);

                if (DownloadClient.Error != null)
                {
                    var exceptionMsg = DownloadClient.Error.Message;
                    message = TextUtil.LineSeparate(message, exceptionMsg);

                    if (exceptionMsg.Contains(ERROR401))
                    {
                        message = TextUtil.LineSeparate(message,
                                                        string.Format(
                                                            Resources
                                                            .SkypSupport_Download_You_may_have_to_add__0__as_a_Panorama_server_from_the_Tools___Options_menu_in_Skyline_,
                                                            skyp.SkylineDocUri.Host));
                    }
                    else if (exceptionMsg.Contains(ERROR403))
                    {
                        message = TextUtil.LineSeparate(message,
                                                        string.Format(
                                                            Resources.SkypSupport_Download_You_do_not_have_permissions_to_download_this_file_from__0__,
                                                            skyp.SkylineDocUri.Host));
                    }
                }

                throw new Exception(message, DownloadClient.Error);
            }
        }
        private void OpenWithForm_Load(object sender, EventArgs e)
        {
            var notifyBox = NotifyBoxEx.Show(Language.GetText(nameof(en_US.FileSystemAccessMsg)), Resources.GlobalTitle, NotifyBoxStartPosition.Center, 0u, false);

            Arguments.DefineAppName();
            notifyBox.Close();

            if (WinApi.NativeHelper.GetForegroundWindow() != Handle)
            {
                WinApi.NativeHelper.SetForegroundWindow(Handle);
            }

            FormEx.Dockable(this);
            AppsBoxUpdate(false);
        }
Exemple #12
0
        public PdnBaseForm()
        {
            UI.InitScaling(this);

            this.SuspendLayout();
            InitializeComponent();

            this.formEx = new PaintDotNet.SystemLayer.FormEx(this, new RealParentWndProcDelegate(this.RealWndProc));
            this.Controls.Add(this.formEx);
            this.formEx.Visible = false;
            DecideOpacitySetting();
            this.ResumeLayout(false);

            this.formEx.ProcessCmdKeyRelay += OnProcessCmdKeyRelay;
        }
Exemple #13
0
        public PdnBaseForm()
        {
            UI.InitScaling(this);

            this.SuspendLayout();
            InitializeComponent();

            this.formEx = new PaintDotNet.SystemLayer.FormEx(this, new RealParentWndProcDelegate(this.RealWndProc));
            this.Controls.Add(this.formEx);
            this.formEx.Visible = false;
            DecideOpacitySetting();
            this.ResumeLayout(false);

            this.formEx.ProcessCmdKeyRelay += OnProcessCmdKeyRelay;
        }
Exemple #14
0
        private void AboutForm_Load(object sender, EventArgs e)
        {
            FormEx.Dockable(this);

            Icon = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.HelpShield, Main.SystemResourcePath);

            Lang.SetControlLang(this);
            Text = Lang.GetText(Name);

            Main.SetFont(this);

            AddFileInfoLabels();

            logoPanel.BackColor = Main.Colors.Base;

            updateBtnPanel.Width = TextRenderer.MeasureText(updateBtn.Text, updateBtn.Font).Width + 32;
            updateBtn.Image      = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Network, Main.SystemResourcePath)?.ToBitmap();
            updateBtn.ForeColor  = Main.Colors.ButtonText;
            updateBtn.BackColor  = Main.Colors.Button;
            updateBtn.FlatAppearance.MouseDownBackColor = Main.Colors.Button;
            updateBtn.FlatAppearance.MouseOverBackColor = Main.Colors.ButtonHover;

            _progressCircle = new ProgressCircle
            {
                Anchor        = updateBtnPanel.Anchor,
                BackColor     = Color.Transparent,
                ForeColor     = mainPanel.BackColor,
                InnerRadius   = 7,
                Location      = new Point(updateBtnPanel.Right + 3, updateBtnPanel.Top + 1),
                OuterRadius   = 9,
                RotationSpeed = 80,
                Size          = new Size(updateBtnPanel.Height, updateBtnPanel.Height),
                Thickness     = 3,
                Visible       = false
            };
            mainPanel.Controls.Add(_progressCircle);

            aboutInfoLabel.ActiveLinkColor = Main.Colors.Base;
            aboutInfoLabel.BorderStyle     = BorderStyle.None;
            aboutInfoLabel.Text            = string.Format(Lang.GetText(aboutInfoLabel), "Si13n7 Developments", Lang.GetText(aboutInfoLabel.Name + "LinkLabel1"), Lang.GetText(aboutInfoLabel.Name + "LinkLabel2"));
            aboutInfoLabel.Links.Clear();
            aboutInfoLabel.LinkText("Si13n7 Developments", "http://www.si13n7.com");
            aboutInfoLabel.LinkText(Lang.GetText(aboutInfoLabel.Name + "LinkLabel1"), "http://paypal.si13n7.com");
            aboutInfoLabel.LinkText(Lang.GetText(aboutInfoLabel.Name + "LinkLabel2"), "https://support.si13n7.com");

            copyrightLabel.Text = string.Format(copyrightLabel.Text, DateTime.Now.Year);
        }
Exemple #15
0
        public PdnBaseForm()
        {
            this.originalPriority         = Thread.CurrentThread.Priority;
            Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;

            UI.InitScaling(this);

            this.SuspendLayout();
            InitializeComponent();

            this.formEx = new PixelDotNet.SystemLayer.FormEx(this, new RealParentWndProcDelegate(this.RealWndProc));
            this.Controls.Add(this.formEx);
            this.formEx.Visible = false;
            DecideOpacitySetting();
            this.ResumeLayout(false);

            this.formEx.ProcessCmdKeyRelay += OnProcessCmdKeyRelay;
        }
Exemple #16
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            highlightInstalledCheck.Checked = Settings.Window.HighlightInstalled;
            showLargeImagesCheck.Checked    = Settings.Window.LargeImages;
            showGroupsCheck.Checked         = Settings.Window.ShowGroups;
            showColorsCheck.Checked         = Settings.Window.ShowGroupColors;

            group1ColorPanel.BackColor  = Settings.Window.Colors.GroupColor1;
            group2ColorPanel.BackColor  = Settings.Window.Colors.GroupColor2;
            group3ColorPanel.BackColor  = Settings.Window.Colors.GroupColor3;
            group4ColorPanel.BackColor  = Settings.Window.Colors.GroupColor4;
            group5ColorPanel.BackColor  = Settings.Window.Colors.GroupColor5;
            group6ColorPanel.BackColor  = Settings.Window.Colors.GroupColor6;
            group7ColorPanel.BackColor  = Settings.Window.Colors.GroupColor7;
            group8ColorPanel.BackColor  = Settings.Window.Colors.GroupColor8;
            group9ColorPanel.BackColor  = Settings.Window.Colors.GroupColor9;
            group11ColorPanel.BackColor = Settings.Window.Colors.GroupColor11;
            group12ColorPanel.BackColor = Settings.Window.Colors.GroupColor12;

            FormEx.Dockable(this);
            WinApi.NativeHelper.MoveWindowToVisibleScreenArea(Handle);
        }
Exemple #17
0
        /// <summary> 用户信息
        /// </summary>
        private void tSMenuItem_UserInfo_Click(object sender, EventArgs e)
        {
            HXCServerWinForm.UCForm.Personnel.UCPersonnelView ucform = new UCForm.Personnel.UCPersonnelView();
            ucform.Dock           = DockStyle.Fill; ucform.windowStatus = HXCServerWinForm.UCForm.WindowStatus.View;
            ucform.pnlOpt.Visible = false;
            ucform.id             = GlobalStaticObj_Server.Instance.UserID;
            FormEx frm = new FormEx();

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.Text          = "用户信息-查看";
            frm.MaximizeBox   = false;
            frm.MinimizeBox   = false;
            frm.ShowInTaskbar = false;
            if (frm.Controls.ContainsKey("pnlContainer"))
            {
                Control col = frm.Controls["pnlContainer"];
                frm.Size    = ucform.Size;
                frm.Height += 30;
                frm.Width  += 30;
                col.Controls.Add(ucform);
                frm.ShowDialog();
            }
        }
Exemple #18
0
        private bool AddServerAndOpen(string skypPath, String message, FormEx parentWindow)
        {
            using (var alertDlg = new AlertDlg(message, MessageBoxButtons.OKCancel))
            {
                alertDlg.ShowDialog(parentWindow ?? _skyline);
                if (alertDlg.DialogResult == DialogResult.OK)
                {
                    using (var dlg = new ToolOptionsUI(_skyline.Document.Settings))
                    {
                        // Let the user add a Panorama server.
                        dlg.NavigateToTab(ToolOptionsUI.TABS.Panorama);
                        dlg.ShowDialog(alertDlg);
                        if (dlg.DialogResult != DialogResult.OK)
                        {
                            return(false);
                        }
                    }
                    return(Open(skypPath, Settings.Default.ServerList /*get the updated server list*/, parentWindow));
                }

                return(false);
            }
        }
Exemple #19
0
        public ArrayList QuerySystemSP_Output(ArrayList ParameterArrayList, ArrayList ValueArrayList, ArrayList TypeArrayList, ArrayList OutputParameterArrayList, ArrayList OutputTypeArrayList, string SPName)
        {
            SqlConnection conn;
            SqlCommand    cmd;
            SqlParameter  myPar;
            SqlDataReader drData;
            SqlDbType     ParType = SqlDbType.VarChar;
            ArrayList     alData  = new ArrayList();

            m_bQuerySystemSPErr = false;

            try
            {
                cmd             = new SqlCommand();
                conn            = DBConn();
                cmd.Connection  = conn;
                cmd.CommandText = SPName;
                cmd.CommandType = CommandType.StoredProcedure;

                for (int i = 0; i <= ParameterArrayList.Count - 1; i++)
                {
                    switch (Convert.ToString(TypeArrayList[i]).ToLower())
                    {
                    case "myvarchar":
                        ParType = myVarChar;
                        break;

                    case "myint":
                        ParType = myInt;
                        break;

                    case "mydatetime":
                        ParType = myDateTime;
                        break;

                    case "myfloat":
                        ParType = myFloat;
                        break;

                    case "mybit":
                        ParType = myBit;
                        break;

                    case "mybinary":
                        ParType = myBinary;
                        break;

                    case "mydecimal":
                        ParType = myDecimal;
                        break;

                    case "mytext":
                        ParType = myText;
                        break;
                    }

                    myPar = cmd.CreateParameter();
                    myPar.ParameterName = Convert.ToString(ParameterArrayList[i]);
                    myPar.Direction     = ParameterDirection.Input;
                    myPar.SqlDbType     = ParType;
                    myPar.Value         = ValueArrayList[i];
                    cmd.Parameters.Add(myPar);
                }

                for (int i = 0; i <= OutputParameterArrayList.Count - 1; i++)
                {
                    switch (Convert.ToString(OutputTypeArrayList[i]).ToLower())
                    {
                    case "myvarchar":
                        ParType = myVarChar;
                        break;

                    case "myint":
                        ParType = myInt;
                        break;

                    case "mydatetime":
                        ParType = myDateTime;
                        break;

                    case "myfloat":
                        ParType = myFloat;
                        break;

                    case "mybit":
                        ParType = myBit;
                        break;

                    case "mybinary":
                        ParType = myBinary;
                        break;

                    case "mydecimal":
                        ParType = myDecimal;
                        break;

                    case "mytext":
                        ParType = myText;
                        break;
                    }

                    myPar = cmd.CreateParameter();
                    myPar.ParameterName = (string)OutputParameterArrayList[i];
                    myPar.Direction     = ParameterDirection.Output;
                    myPar.SqlDbType     = ParType;
                    if (ParType == myVarChar)
                    {
                        myPar.Size = OutputParameterSize(myPar.ParameterName, SPName);
                    }
                    cmd.Parameters.Add(myPar);
                }

                conn.Open();
                drData = cmd.ExecuteReader(CommandBehavior.Default);
                for (int i = 0; i <= cmd.Parameters.Count - 1; i++)
                {
                    if (cmd.Parameters[i].Direction == ParameterDirection.Output)
                    {
                        alData.Add(cmd.Parameters[i].Value);
                    }
                }

                cmd.Dispose();
                conn.Close();
                conn.Dispose();
            }
            catch (SqlException SqlEx)
            {
                m_bQuerySystemSPErr = true;
                m_sExceptionMessage = SqlEx.ToString();
            }
            catch (FormatException FormEx)
            {
                m_bQuerySystemSPErr = true;
                m_sExceptionMessage = FormEx.ToString();
            }
            catch (Exception ex)
            {
                m_bQuerySystemSPErr = true;
                m_sExceptionMessage = ex.ToString();
            }

            return(alData);
        }
Exemple #20
0
        public static void Main(string[] args = null)
        {
            if (String.IsNullOrEmpty(Settings.Default.InstallationId)) // Each instance to have GUID
            {
                Settings.Default.InstallationId = Guid.NewGuid().ToString();
            }

            // don't allow 64-bit Skyline to run in a 32-bit process
            if (Install.Is64Bit && !Environment.Is64BitProcess)
            {
                string installUrl   = Install.Url;
                string installLabel = (installUrl == string.Empty) ? string.Empty : string.Format(Resources.Program_Main_Install_32_bit__0__, Name);
                AlertLinkDlg.Show(null,
                                  string.Format(Resources.Program_Main_You_are_attempting_to_run_a_64_bit_version_of__0__on_a_32_bit_OS_Please_install_the_32_bit_version, Name),
                                  installLabel,
                                  installUrl);
                return;
            }

            CommonFormEx.TestMode      = FunctionalTest;
            CommonFormEx.Offscreen     = SkylineOffscreen;
            CommonFormEx.ShowFormNames = FormEx.ShowFormNames = ShowFormNames;

            // For testing and debugging Skyline command-line interface
            if (args != null && args.Length > 0)
            {
                if (!CommandLineRunner.HasCommandPrefix(args[0]))
                {
                    TextWriter textWriter;
                    if (Debugger.IsAttached)
                    {
                        textWriter = new DebugWriter();
                    }
                    else
                    {
                        AttachConsole(-1);
                        textWriter = Console.Out;
                        Console.WriteLine();
                        Console.WriteLine();
                    }
                    var writer = new CommandStatusWriter(textWriter);
                    if (args[0].Equals("--ui", StringComparison.InvariantCultureIgnoreCase)) // Not L10N
                    {
                        // ReSharper disable once ObjectCreationAsStatement
                        new CommandLineUI(args, writer);
                    }
                    else
                    {
                        CommandLineRunner.RunCommand(args, writer);
                    }
                }
                else
                {
                    // For testing SkylineRunner without installation
                    CommandLineRunner clr = new CommandLineRunner();
                    clr.Start(args[0]);
                }

                return;
            }
            // The way Skyline command-line interface is run for an installation
            else if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null &&
                     AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null &&
                     AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Length > 0 &&
                     CommandLineRunner.HasCommandPrefix(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0])) // Not L10N
            {
                CommandLineRunner clr = new CommandLineRunner();
                clr.Start(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]);

                // HACK: until the "invalid string binding" error is resolved, this will prevent an error dialog at exit
                Process.GetCurrentProcess().Kill();
                return;
            }

            try
            {
                Init();
                if (!string.IsNullOrEmpty(Settings.Default.DisplayLanguage))
                {
                    try
                    {
                        LocalizationHelper.CurrentUICulture =
                            CultureInfo.GetCultureInfo(Settings.Default.DisplayLanguage);
                    }
                    catch (CultureNotFoundException)
                    {
                    }
                }
                LocalizationHelper.InitThread(Thread.CurrentThread);

                // Make sure the user has agreed to the current license version
                // or one more recent.
                int licenseVersion = Settings.Default.LicenseVersionAccepted;
                if (licenseVersion < LICENSE_VERSION_CURRENT && !NoSaveSettings)
                {
                    // If the user has never used the application before, then
                    // they must have agreed to the current license agreement during
                    // installation.  Otherwise, make sure they agree to the new
                    // license agreement.
                    if (Install.Type == Install.InstallType.release &&
                        (licenseVersion != 0 || !Settings.Default.MainWindowSize.IsEmpty))
                    {
                        using (var dlg = new UpgradeDlg(licenseVersion))
                        {
                            if (dlg.ShowDialog() == DialogResult.Cancel)
                            {
                                return;
                            }
                        }
                    }

                    try
                    {
                        // Make sure the user never sees this again for this license version
                        Settings.Default.LicenseVersionAccepted = LICENSE_VERSION_CURRENT;
                        Settings.Default.Save();
                    }
// ReSharper disable EmptyGeneralCatchClause
                    catch (Exception)
// ReSharper restore EmptyGeneralCatchClause
                    {
                        // Just try to update the license version next time.
                    }
                }

                try
                {
                    // If this is a new installation copy over installed external tools from previous installation location.
                    var toolsDirectory = ToolDescriptionHelpers.GetToolsDirectory();
                    if (!Directory.Exists(toolsDirectory))
                    {
                        using (var longWaitDlg = new LongWaitDlg
                        {
                            Text = Name,
                            Message = Resources.Program_Main_Copying_external_tools_from_a_previous_installation,
                            ProgressValue = 0
                        })
                        {
                            longWaitDlg.PerformWork(null, 1000 * 3, broker => CopyOldTools(toolsDirectory, broker));
                        }
                    }
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch
                {
                }

                // Force live reports (though tests may reset this)
                //Settings.Default.EnableLiveReports = true;

                if (ReportShutdownDlg.HadUnexpectedShutdown())
                {
                    using (var reportShutdownDlg = new ReportShutdownDlg())
                    {
                        reportShutdownDlg.ShowDialog();
                    }
                }
                SystemEvents.DisplaySettingsChanged += SystemEventsOnDisplaySettingsChanged;
                // Careful, a throw out of the SkylineWindow constructor without this
                // catch causes Skyline just to appear to silently never start.  Makes for
                // some difficult debugging.
                try
                {
                    var activationArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments;
                    if ((activationArgs != null &&
                         activationArgs.ActivationData != null &&
                         activationArgs.ActivationData.Length != 0) ||
                        !Settings.Default.ShowStartupForm)
                    {
                        MainWindow = new SkylineWindow(args);
                    }
                    else
                    {
                        StartWindow = new StartPage();
                        try
                        {
                            if (StartWindow.ShowDialog() != DialogResult.OK)
                            {
                                Application.Exit();
                                return;
                            }

                            MainWindow = StartWindow.MainWindow;
                        }
                        finally
                        {
                            StartWindow.Dispose();
                            StartWindow = null;
                        }
                    }
                }
                catch (Exception x)
                {
                    ReportExceptionUI(x, new StackTrace(1, true));
                }

                ConcurrencyVisualizer.StartEvents(MainWindow);

                // Position window offscreen for stress testing.
                if (SkylineOffscreen)
                {
                    FormEx.SetOffscreen(MainWindow);
                }

                ActionUtil.RunAsync(() =>
                {
                    try {
                        SendAnalyticsHit();
                    } catch (Exception ex) {
                        Trace.TraceWarning("Exception sending analytics hit {0}", ex);  // Not L10N
                    }
                });
                MainToolServiceName = Guid.NewGuid().ToString();
                Application.Run(MainWindow);
                StopToolService();
            }
            catch (Exception x)
            {
                // Send unhandled exceptions to the console.
                Console.WriteLine(x.Message);
                Console.Write(x.StackTrace);
            }

            MainWindow = null;
        }
Exemple #21
0
        public bool OpenFile(string path, FormEx parentWindow = null)
        {
            // Remove any extraneous temporary chromatogram spill files.
            var spillDirectory = Path.Combine(Path.GetDirectoryName(path) ?? "", "xic");    // Not L10N
            if (Directory.Exists(spillDirectory))
                DirectoryEx.SafeDelete(spillDirectory);

            Exception exception = null;
            SrmDocument document = null;

            try
            {
                using (var longWaitDlg = new LongWaitDlg(this)
                {
                    Text = Resources.SkylineWindow_OpenFile_Loading___,
                    Message = Path.GetFileName(path),
                    ProgressValue = 0
                })
                {
                    longWaitDlg.PerformWork(parentWindow ?? this, 500, progressMonitor =>
                    {
                        using (var reader = new StreamReaderWithProgress(path, progressMonitor))
                        {
                            XmlSerializer ser = new XmlSerializer(typeof (SrmDocument));
                            document = (SrmDocument) ser.Deserialize(reader);
                        }
                    });

                    if (longWaitDlg.IsCanceled)
                        document = null;
                }
            }
            catch (Exception x)
            {
                exception = x;
            }

            if (exception == null)
            {
                if (document == null)
                    return false;

                try
                {
                    document = ConnectDocument(parentWindow ?? this, document, path);
                    if (document == null || !CheckResults(document, path))
                        return false;

                    // Make sure settings lists contain correct values for
                    // this document.
                    document.Settings.UpdateLists(path);
                }
                catch (Exception x)
                {
                    exception = x;
                }
            }

            if (exception == null)
            {
                try
                {
                    using (new SequenceTreeForm.LockDoc(_sequenceTreeForm))
                    {
                        // Switch over to the opened document
                        SwitchDocument(document, path);
                    }
                    // Locking the sequenceTree can throw off the node count status
                    UpdateNodeCountStatus();
                }
                catch (Exception x)
                {
                    exception = x;
                }
            }

            if (exception != null)
            {
                new MessageBoxHelper(parentWindow ?? this).ShowXmlParsingError(
                    string.Format(Resources.SkylineWindow_OpenFile_Failure_opening__0__, path), path, exception);
                return false;
            }

            if (SequenceTree != null && SequenceTree.Nodes.Count > 0 && !SequenceTree.RestoredFromPersistentString)
                SequenceTree.SelectedNode = SequenceTree.Nodes[0];

            return true;
        }
Exemple #22
0
 public virtual void SuccessPay(FormEx parent, PrintType printType)
 {
 }
 /// <summary> 用户信息
 /// </summary>
 private void tSMenuItem_UserInfo_Click(object sender, EventArgs e)
 {
     try
     {
         HXCServerWinForm.UCForm.Personnel.UCPersonnelView ucform = new UCForm.Personnel.UCPersonnelView();
         ucform.Dock = DockStyle.Fill; ucform.windowStatus = HXCServerWinForm.UCForm.WindowStatus.View;
         ucform.pnlOpt.Visible = false;
         ucform.id = GlobalStaticObj_Server.Instance.UserID;
         ucform.accCode = GlobalStaticObj_Server.CommAccCode;
         FormEx frm = new FormEx();
         frm.StartPosition = FormStartPosition.CenterScreen;
         frm.Text = "用户信息-查看";
         frm.MaximizeBox = false;
         frm.MinimizeBox = false;
         frm.ShowInTaskbar = false;
         if (frm.Controls.ContainsKey("pnlContainer"))
         {
             Control col = frm.Controls["pnlContainer"];
             frm.Size = ucform.Size;
             frm.Height += 30;
             frm.Width += 30;
             col.Controls.Add(ucform);
             frm.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         GlobalStaticObj_Server.GlobalLogService.WriteLog("MainForm", ex);
         MessageBoxEx.ShowWarning("程序异常");
     }
 }
 private void SettingsForm_Load(object sender, EventArgs e)
 {
     LoadSettings();
     FormEx.Dockable(this);
     WinApi.NativeHelper.MoveWindowToVisibleScreenArea(Handle);
 }
Exemple #25
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            FormEx.Dockable(this);

            Lang.SetControlLang(this);

            // Check internet connection
            if (!(_ipv4 = NetEx.InternetIsAvailable()) && !(_ipv6 = NetEx.InternetIsAvailable(true)))
            {
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Get update infos from GitHub if enabled
            if (Ini.Read("Settings", "UpdateChannel", 0) > 0)
            {
                if (!_ipv4 && _ipv6)
                {
                    Environment.ExitCode = 1;
                    Application.Exit();
                    return;
                }
                try
                {
                    var path = PathEx.AltCombine(Resources.GitRawProfileUri, Resources.GitSnapshotsPath, "Last.ini");
                    if (!NetEx.FileIsAvailable(path, 60000))
                    {
                        throw new PathNotFoundException(path);
                    }
                    var data = NetEx.Transfer.DownloadString(path);
                    if (string.IsNullOrWhiteSpace(data))
                    {
                        throw new ArgumentNullException(nameof(data));
                    }
                    _lastStamp = Ini.ReadOnly("Info", "LastStamp", data);
                    if (string.IsNullOrWhiteSpace(_lastStamp))
                    {
                        throw new ArgumentNullException(_lastStamp);
                    }
                    path = PathEx.AltCombine(Resources.GitRawProfileUri, Resources.GitSnapshotsPath, $"{_lastStamp}.ini");
                    if (!NetEx.FileIsAvailable(path, 60000))
                    {
                        throw new PathNotFoundException(path);
                    }
                    data = NetEx.Transfer.DownloadString(path);
                    if (string.IsNullOrWhiteSpace(data))
                    {
                        throw new ArgumentNullException(nameof(data));
                    }
                    _hashInfo = data;
                }
                catch (Exception ex)
                {
                    Log.Write(ex);
                }
            }

            // Get update infos if not already set
            if (string.IsNullOrWhiteSpace(_hashInfo))
            {
                // Get available download mirrors
                var dnsInfo = string.Empty;
                for (var i = 0; i < 3; i++)
                {
                    if (!_ipv4 && _ipv6)
                    {
                        dnsInfo = Resources.IPv6DNS;
                        break;
                    }
                    try
                    {
                        var path = PathEx.AltCombine(Resources.GitRawProfileUri, Resources.GitDnsPath);
                        if (!NetEx.FileIsAvailable(path, 60000))
                        {
                            throw new PathNotFoundException(path);
                        }
                        var data = NetEx.Transfer.DownloadString(path);
                        if (string.IsNullOrWhiteSpace(data))
                        {
                            throw new ArgumentNullException(nameof(data));
                        }
                        dnsInfo = data;
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                    }
                    if (string.IsNullOrWhiteSpace(dnsInfo) && i < 2)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }
                    break;
                }
                if (!string.IsNullOrWhiteSpace(dnsInfo))
                {
                    foreach (var section in Ini.GetSections(dnsInfo))
                    {
                        var addr = Ini.Read(section, _ipv4 ? "addr" : "ipv6", dnsInfo);
                        if (string.IsNullOrEmpty(addr))
                        {
                            continue;
                        }
                        var domain = Ini.Read(section, "domain", dnsInfo);
                        if (string.IsNullOrEmpty(domain))
                        {
                            continue;
                        }
                        var ssl = Ini.ReadOnly(section, "ssl", false, dnsInfo);
                        domain = PathEx.AltCombine(ssl ? "https:" : "http:", domain);
                        if (!DownloadMirrors.ContainsEx(domain))
                        {
                            DownloadMirrors.Add(domain);
                        }
                    }
                }
                if (DownloadMirrors.Count == 0)
                {
                    Environment.ExitCode = 1;
                    Application.Exit();
                    return;
                }

                // Get file hashes
                foreach (var mirror in DownloadMirrors)
                {
                    try
                    {
                        var path = PathEx.AltCombine(mirror, Resources.ReleasePath, "Last.ini");
                        if (!NetEx.FileIsAvailable(path, 60000))
                        {
                            throw new PathNotFoundException(path);
                        }
                        var data = NetEx.Transfer.DownloadString(path);
                        if (string.IsNullOrWhiteSpace(data))
                        {
                            throw new ArgumentNullException(nameof(data));
                        }
                        _lastFinalStamp = Ini.ReadOnly("Info", "LastStamp", data);
                        if (string.IsNullOrWhiteSpace(_lastFinalStamp))
                        {
                            throw new ArgumentNullException(nameof(_lastFinalStamp));
                        }
                        path = PathEx.AltCombine(mirror, Resources.ReleasePath, $"{_lastFinalStamp}.ini");
                        if (!NetEx.FileIsAvailable(path, 60000))
                        {
                            throw new PathNotFoundException(path);
                        }
                        data = NetEx.Transfer.DownloadString(path);
                        if (string.IsNullOrWhiteSpace(data))
                        {
                            throw new ArgumentNullException(nameof(data));
                        }
                        _hashInfo = data;
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                    }
                    if (!string.IsNullOrWhiteSpace(_hashInfo))
                    {
                        break;
                    }
                }
            }
            if (string.IsNullOrWhiteSpace(_hashInfo))
            {
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Compare hashes
            var updateAvailable = false;

            try
            {
                foreach (var key in Ini.GetKeys("SHA256", _hashInfo))
                {
                    var file = Path.Combine(HomeDir, $"{key}.exe");
                    if (!File.Exists(file))
                    {
                        file = PathEx.Combine(PathEx.LocalDir, $"{key}.exe");
                    }
                    if (Ini.Read("SHA256", key, _hashInfo).EqualsEx(Crypto.EncryptFileToSha256(file)))
                    {
                        continue;
                    }
                    updateAvailable = true;
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Install updates
            if (updateAvailable)
            {
                if (MessageBox.Show(Lang.GetText(nameof(en_US.UpdateAvailableMsg)), Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    // Update changelog
                    if (DownloadMirrors.Count > 0)
                    {
                        var changes = string.Empty;
                        foreach (var mirror in DownloadMirrors)
                        {
                            var path = PathEx.AltCombine(mirror, Resources.ReleasePath, "ChangeLog.txt");
                            if (string.IsNullOrWhiteSpace(path))
                            {
                                continue;
                            }
                            if (!NetEx.FileIsAvailable(path, 60000))
                            {
                                continue;
                            }
                            changes = NetEx.Transfer.DownloadString(path);
                            if (!string.IsNullOrWhiteSpace(changes))
                            {
                                break;
                            }
                        }
                        if (!string.IsNullOrWhiteSpace(changes))
                        {
                            changeLog.Font = new Font("Consolas", 8.25f);
                            changeLog.Text = TextEx.FormatNewLine(changes);
                            var colorMap = new Dictionary <Color, string[]>
                            {
                                {
                                    Color.PaleGreen, new[]
                                    {
                                        " PORTABLE APPS SUITE",
                                        " UPDATED:",
                                        " CHANGES:"
                                    }
                                },
                                {
                                    Color.SkyBlue, new[]
                                    {
                                        " Global:",
                                        " Apps Launcher:",
                                        " Apps Downloader:",
                                        " Apps Suite Updater:"
                                    }
                                },
                                {
                                    Color.Khaki, new[]
                                    {
                                        "Version History:"
                                    }
                                },
                                {
                                    Color.Plum, new[]
                                    {
                                        "{", "}",
                                        "(", ")",
                                        "|",
                                        ".",
                                        "-"
                                    }
                                },
                                {
                                    Color.Tomato, new[]
                                    {
                                        " * "
                                    }
                                },
                                {
                                    Color.Black, new[]
                                    {
                                        new string('_', 84)
                                    }
                                }
                            };
                            foreach (var line in changeLog.Text.Split('\n'))
                            {
                                if (line.Length < 1 || !DateTime.TryParseExact(line.Trim(' ', ':'), "d MMMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime _))
                                {
                                    continue;
                                }
                                changeLog.MarkText(line, Color.Khaki);
                            }
                            foreach (var color in colorMap)
                            {
                                foreach (var s in color.Value)
                                {
                                    changeLog.MarkText(s, color.Key);
                                }
                            }
                        }
                    }
                    else
                    {
                        changeLog.Dock     = DockStyle.None;
                        changeLog.Size     = new Size(changeLogPanel.Width, TextRenderer.MeasureText(changeLog.Text, changeLog.Font).Height);
                        changeLog.Location = new Point(0, changeLogPanel.Height / 2 - changeLog.Height - 16);
                        changeLog.SelectAll();
                        changeLog.SelectionAlignment = HorizontalAlignment.Center;
                        changeLog.DeselectAll();
                    }
                    ShowInTaskbar = true;
                    return;
                }
            }

            // Exit the application if no updates were found
            Environment.ExitCode = 2;
            Application.Exit();
        }
 private void LangSelectionForm_Load(object sender, EventArgs e)
 {
     FormEx.Dockable(this);
     Lang.SetControlLang(this);
     Text = _name;
 }
Exemple #27
0
        private void OnProcessCmdKeyRelay(object sender, FormEx.ProcessCmdKeyEventArgs e)
        {
            bool handled = e.Handled;

            if (!handled)
            {
                handled = ProcessCmdKeyData(e.KeyData);
                e.Handled = handled;
            }
        }
Exemple #28
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            FormEx.Dockable(this);

            if (Main.ScreenDpi > 96)
            {
                Font = SystemFonts.CaptionFont;
            }

            Icon = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.SystemControl, Main.SystemResourcePath);

            foreach (TabPage tab in tabCtrl.TabPages)
            {
                tab.BackColor = Main.Colors.BaseDark;
            }

            locationBtn.BackgroundImage = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Directory, Main.SystemResourcePath)?.ToBitmap();
            fileTypesMenu.EnableAnimation();
            fileTypesMenu.SetFixedSingle();
            associateBtn.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap();
            try
            {
                restoreFileTypesBtn.Image = new Bitmap(28, 16);
                using (var g = Graphics.FromImage(restoreFileTypesBtn.Image))
                {
                    g.DrawImage(ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath).ToBitmap(), 0, 0);
                    g.DrawImage(ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Undo, Main.SystemResourcePath).ToBitmap(), 12, 0);
                }
            }
            catch
            {
                restoreFileTypesBtn.Image      = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap();
                restoreFileTypesBtn.ImageAlign = ContentAlignment.MiddleLeft;
                restoreFileTypesBtn.Text       = @"<=";
                if (restoreFileTypesBtn.Image != null)
                {
                    restoreFileTypesBtn.TextAlign = ContentAlignment.MiddleRight;
                }
            }

            previewBg.BackgroundImage       = Main.BackgroundImage.Redraw((int)Math.Round(Main.BackgroundImage.Width * .65f) + 1, (int)Math.Round(Main.BackgroundImage.Height * .65f) + 1);
            previewBg.BackgroundImageLayout = Main.BackgroundImageLayout;
            previewLogoBox.BackgroundImage  = Resources.PortableApps_Logo_gray.Redraw(previewLogoBox.Height, previewLogoBox.Height);
            var exeIco = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.ExeFile, Main.SystemResourcePath);

            if (exeIco != null)
            {
                previewImgList.Images.Add(exeIco.ToBitmap());
                previewImgList.Images.Add(exeIco.ToBitmap());
            }

            foreach (var btn in new[] { saveBtn, exitBtn })
            {
                btn.BackColor = Main.Colors.Button;
                btn.ForeColor = Main.Colors.ButtonText;
                btn.FlatAppearance.MouseDownBackColor = Main.Colors.Button;
                btn.FlatAppearance.MouseOverBackColor = Main.Colors.ButtonHover;
            }
            var strAppNames = Main.AppsInfo.Select(x => x.LongName).ToArray();
            var objAppNames = new object[strAppNames.Length];

            Array.Copy(strAppNames, objAppNames, objAppNames.Length);
            appsBox.Items.AddRange(objAppNames);

            appsBox.SelectedItem = _selectedItem;
            if (appsBox.SelectedIndex < 0)
            {
                appsBox.SelectedIndex = 0;
            }

            fileTypes.MaxLength  = short.MaxValue;
            addToShellBtn.Image  = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap();
            rmFromShellBtn.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap();

            LoadSettings();
        }
Exemple #29
0
 public void Dispose()
 {
     _owner = null;
 }
Exemple #30
0
 //用户信息
 private void tSMenuItem_UserInfo_Click(object sender, EventArgs e)
 {
     UCPersonnelView ucform = new UCPersonnelView();
     ucform.Dock = DockStyle.Fill; ucform.windowStatus = WindowStatus.View;
     ucform.pnlOpt.Visible = false;
     ucform.id = GlobalStaticObj.UserID;
     FormEx frm = new FormEx();
     frm.StartPosition = FormStartPosition.CenterScreen;
     frm.Text = "用户信息-查看";
     frm.MaximizeBox = false;
     frm.MinimizeBox = false;
     frm.ShowInTaskbar = false;
     if (frm.Controls.ContainsKey("pnlContainer"))
     {
         Control col = frm.Controls["pnlContainer"];
         frm.Size = ucform.Size;
         frm.Height += 30;
         col.Controls.Add(ucform);
         frm.ShowDialog();
     }
 }
Exemple #31
0
 public virtual void BadPay(FormEx parent)
 {
 }
Exemple #32
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // Check internet connection
            if (!Network.InternetIsAvailable)
            {
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Get update infos from GitHub if enabled
            if (Settings.UpdateChannel == Settings.UpdateChannelOptions.Beta)
            {
                if (!NetEx.IPv4IsAvalaible && NetEx.IPv6IsAvalaible)
                {
                    Environment.ExitCode = 1;
                    Application.Exit();
                    return;
                }
                SetUpdateInfo(false, CorePaths.RepoSnapshotsUrl);
            }

            // Get update infos if not already set
            if (string.IsNullOrWhiteSpace(HashInfo))
            {
                DownloadMirrors.AddRange(new[]
                {
                    "https://port-a.de",
                    "https://p-able.de",

                    // Backup
                    "https://dl.si13n7.de/Port-Able",
                    "https://dl.si13n7.com/Port-Able",

                    // Reserved
                    "http://dl-0.de/Port-Able",
                    "http://dl-1.de/Port-Able",
                    "http://dl-2.de/Port-Able",
                    "http://dl-3.de/Port-Able",
                    "http://dl-4.de/Port-Able",
                    "http://dl-5.de/Port-Able"
                });
                if (!DownloadMirrors.Any())
                {
                    Environment.ExitCode = 1;
                    Application.Exit();
                    return;
                }
                SetUpdateInfo(true, DownloadMirrors.ToArray());
            }
            if (string.IsNullOrWhiteSpace(HashInfo))
            {
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Compare hashes
            var updateAvailable = false;

            try
            {
                foreach (var key in Ini.GetKeys("SHA256", HashInfo))
                {
                    var file = PathEx.Combine(PathEx.LocalDir, $"{key}.exe");
                    if (!File.Exists(file))
                    {
                        file = Path.Combine(CorePaths.HomeDir, $"{key}.exe");
                    }
                    if (Ini.Read("SHA256", key, HashInfo).EqualsEx(file.EncryptFile(ChecksumAlgorithm.Sha256)))
                    {
                        continue;
                    }
                    updateAvailable = true;
                    break;
                }
            }
            catch (Exception ex) when(ex.IsCaught())
            {
                Log.Write(ex);
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Install updates
            if (updateAvailable)
            {
                if (string.IsNullOrEmpty(CorePaths.FileArchiver))
                {
                    if (MessageBox.Show(Language.GetText(nameof(en_US.RequirementsErrorMsg)), Text, MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                    {
                        Process.Start(CorePaths.RepoReleasesUrl);
                    }
                    Environment.ExitCode = 1;
                    Environment.Exit(Environment.ExitCode);
                }
                if (MessageBox.Show(Language.GetText(nameof(en_US.UpdateAvailableMsg)), Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    SetChangeLog(DownloadMirrors.ToArray());
                    ShowInTaskbar = true;
                    FormEx.Dockable(this);
                    return;
                }
                DirectoryEx.TryDelete(CachePaths.UpdateDir);
            }

            // Exit the application if no updates were found
            Environment.ExitCode = 2;
            Application.Exit();
        }
Exemple #33
0
 public SystemButtonManager(FormEx owner)
 {
     this._owner = owner;
     isShowCloseButton = owner.ShowCloseButton;
     IniSystemButtons();
 }