Пример #1
0
        internal static void ImportOptions(Form1 form)
        {
            OpenFileDialog       openFileDialog       = form.openFileDialog;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;

            openFileDialog.InitialDirectory = ConstantUtil.ApplicationExecutionPath();
            openFileDialog.Multiselect      = false;
            openFileDialog.Filter           = String.Format("{0} (*.{1})|*.{1}", LanguageUtil.GetCurrentLanguageString("ExportFileDescription", className), ConstantUtil.exportFileExtension); //DtPad export files (*.dpe)|*.dpe
            openFileDialog.FileName         = String.Format("*.{0}", ConstantUtil.exportFileExtension);

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            ZipFile toImportFile = null;

            try
            {
                toImportFile = new ZipFile(openFileDialog.FileName);

                if (toImportFile.ZipFileComment != AssemblyUtil.AssemblyVersion)
                {
                    if (WindowManager.ShowQuestionBox(form, LanguageUtil.GetCurrentLanguageString("WarningImport", className)) == DialogResult.No)
                    {
                        return;
                    }
                }
            }
            finally
            {
                if (toImportFile != null)
                {
                    toImportFile.Close();
                }
            }

            toolStripProgressBar.Value   = 0;
            toolStripProgressBar.Visible = true;

            FastZip importFile = new FastZip();

            toolStripProgressBar.PerformStep();

            importFile.ExtractZip(openFileDialog.FileName, ConstantUtil.ApplicationExecutionPath(), FastZip.Overwrite.Always, null, String.Empty, String.Empty, true);

            toolStripProgressBar.PerformStep();

            //String importStatus = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("ImportStatusLabel1", className), openFileDialog.FileName, LanguageUtil.GetCurrentLanguageString("ImportStatusLabel2", className));
            String importStatus = String.Format(LanguageUtil.GetCurrentLanguageString("ImportStatusLabel", className), openFileDialog.FileName);

            toolStripProgressBar.PerformStep();
            toolStripProgressBar.PerformStep();

            toolStripStatusLabel.Text = importStatus;
            WindowManager.ShowInfoBox(form, importStatus + "!");

            toolStripProgressBar.Visible = false;
        }
Пример #2
0
        static public void RealmChecks(ref TextBox textbox, ref ToolStripProgressBar ProgressBar)
        {
            if (!Directory.Exists((string)Settings.Global.Properties["POLPath"] + @"\realm"))
            {
                textbox.AppendText("* Fail: Realms have not been generated." + Environment.NewLine);
            }
            else
            {
                string[] tmp = FileSystemUtil.GetAllFileNames((string)Settings.Global.Properties["POLPath"] + @"\realm", "*.*");
                if (tmp.Length > 1)
                {
                    textbox.AppendText("* Pass: Realm folder detected." + Environment.NewLine);
                }
                else
                {
                    textbox.AppendText("* Fail: Realm folder is empty." + Environment.NewLine);
                }
            }
            ProgressBar.PerformStep();

            foreach (string s in PL_UOConvert.GetConfigFileNames())
            {
                if (File.Exists((string)Settings.Global.Properties["POLPath"] + @"\" + s))
                {
                    textbox.AppendText("* Pass: Found config file '" + s + "'." + Environment.NewLine);
                }
                else
                {
                    textbox.AppendText("* Fail: Config file '" + s + "' not found." + Environment.NewLine);
                }
                ProgressBar.PerformStep();
            }
        }
Пример #3
0
 /// <summary>
 /// This can be used to update the progress bar with a new value
 /// </summary>
 /// <remarks>This version updates the progress by the step
 /// value.</remarks>
 /// <overloads>There are four overloads for this method</overloads>
 public static void UpdateProgress()
 {
     if (progressBar != null)
     {
         progressBar.PerformStep();
     }
 }
Пример #4
0
        internal static void ExportOptions(Form1 form)
        {
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;

            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog
            {
                Description  = LanguageUtil.GetCurrentLanguageString("folderBrowserDialogDescription", className),
                RootFolder   = Environment.SpecialFolder.ProgramFiles,
                SelectedPath = FileUtil.GetInitialFolder(form)
            };

            if (folderBrowserDialog.ShowDialog(form) != DialogResult.OK)
            {
                return;
            }

            toolStripProgressBar.Value   = 0;
            toolStripProgressBar.Visible = true;

            String zipFileName = String.Format("{0}_{1}_{2}.{3}", ConstantUtil.exportOptionsFileName, AssemblyUtil.AssemblyVersion.Replace(".", String.Empty), DateTimeUtil.GetTodayDateAsString("yyyyMMdd"), ConstantUtil.exportFileExtension);

            toolStripProgressBar.PerformStep();

            FastZip exportFile = new FastZip();

            exportFile.CreateZip(Path.Combine(folderBrowserDialog.SelectedPath, zipFileName), ConstantUtil.ApplicationExecutionPath(), true,
                                 @"DtPad\.exe\.config|DtPad\.exe\.ex|DtPad\.exe\.fv|DtPad\.exe\.no|DtPad\.exe\.rf|DtPad\.exe\.rp|DtPad\.exe\.rs|DtPad\.exe\.sf|DtPad\.exe\.sh|DtPad\.exe\.tm|DtPad\.exe\.to|DtPad\.exe\.ru");

            toolStripProgressBar.PerformStep();

            ZipFile exportedFile = null;

            try
            {
                exportedFile = new ZipFile(Path.Combine(folderBrowserDialog.SelectedPath, zipFileName));
                exportedFile.BeginUpdate();
                exportedFile.SetComment("DtPad - " + AssemblyUtil.AssemblyVersion);
                exportedFile.CommitUpdate();
            }
            finally
            {
                if (exportedFile != null)
                {
                    exportedFile.Close();
                }
            }

            toolStripProgressBar.PerformStep();

            String exportStatus = String.Format(LanguageUtil.GetCurrentLanguageString("ExportStatusLabel", className), zipFileName);

            toolStripProgressBar.PerformStep();

            toolStripStatusLabel.Text = exportStatus;
            WindowManager.ShowInfoBox(form, exportStatus + "!");

            toolStripProgressBar.Visible = false;
        }
Пример #5
0
        internal static void MergeTab(Form1 form, String[] selectedTabNames, bool indicateMerge, String markSeparation)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;

            bool linesDisabled   = false;
            int  previousMaximum = toolStripProgressBar.Maximum;
            int  previousStep    = toolStripProgressBar.Step;

            toolStripProgressBar.Maximum = selectedTabNames.Length + 1;
            toolStripProgressBar.Step    = 1;
            toolStripProgressBar.Value   = 0;
            toolStripProgressBar.Visible = true;

            if (indicateMerge)
            {
                ConfigUtil.UpdateParameter("MergeTabSeparation", markSeparation.Replace(ConstantUtil.newLine, "\\r\\n"));
            }

            XtraTabPage       firstTab    = GetXtraTabPageFromName(pagesTabControl, selectedTabNames[0]);
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(firstTab);

            for (int i = 1; i < selectedTabNames.Length; i++)
            {
                String textPostMerge;
                if (indicateMerge)
                {
                    textPostMerge = pageTextBox.Text + ConstantUtil.newLine + markSeparation + ConstantUtil.newLine + ProgramUtil.GetPageTextBox(GetXtraTabPageFromName(pagesTabControl, selectedTabNames[i])).Text;
                }
                else
                {
                    textPostMerge = pageTextBox.Text + ConstantUtil.newLine + ProgramUtil.GetPageTextBox(GetXtraTabPageFromName(pagesTabControl, selectedTabNames[i])).Text;
                }

                if (linesDisabled != true)
                {
                    linesDisabled = WindowManager.CheckLineNumbersForTextLenght(form, textPostMerge, true);
                }
                pageTextBox.Text = textPostMerge;

                pagesTabControl.TabPages.Remove(GetXtraTabPageFromName(pagesTabControl, selectedTabNames[i]));
                toolStripProgressBar.PerformStep();
            }

            toolStripStatusLabel.Text = String.Format("{0} {1}", selectedTabNames.Length, LanguageUtil.GetCurrentLanguageString("TabMerged", className));
            toolStripProgressBar.PerformStep();
            toolStripProgressBar.Visible = false;
            toolStripProgressBar.Maximum = previousMaximum;
            toolStripProgressBar.Step    = previousStep;

            pagesTabControl.SelectedTabPage = firstTab;

            if (linesDisabled)
            {
                WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("LineNumbersDisabled", className));
            }
        }
        public void start()
        {
            CurrentPortCount.Minimum = portList.start;
            CurrentPortCount.Maximum = portList.stop;
            new Task(() => {
                Parallel.For(portList.start, portList.stop, (i) => {
                    try
                    {
                        Connect(host, i, tcpTimeout);
                    }
                    catch
                    {
                        f.BeginInvoke((Action)(() =>
                        {
                            view.Rows.Add(i, "Close", "");
                            CurrentPortCount.PerformStep();
                        }));
                        if (this.CurrentPortCount.Value >= this.CurrentPortCount.Maximum - 1)
                        {
                            f.BeginInvoke((Action)(() =>
                            {
                                button1.Enabled = true;
                                CurrentPortCount.Value = CurrentPortCount.Minimum;
                            }));
                        }
                        return;
                    }
                    int Data1    = i;
                    string Data2 = "Open";
                    string Data3 = string.Empty;
                    try
                    {
                        Data3 = BannerGrab(host, i, tcpTimeout);
                    }
                    catch (Exception ex)
                    {
                        Data3 = "Could not retrieve the Banner ::Original Error = " + ex.Message;
                    }

                    f.BeginInvoke((Action)(() =>
                    {
                        view.Rows.Add(Data1, Data2, Data3);
                        CurrentPortCount.PerformStep();
                    }));

                    if (this.CurrentPortCount.Value >= this.CurrentPortCount.Maximum - 1)
                    {
                        f.BeginInvoke((Action)(() =>
                        {
                            button1.Enabled = true;
                            CurrentPortCount.Value = CurrentPortCount.Minimum;
                        }));
                    }
                });
            }).Start();
        }
Пример #7
0
        internal static bool OpenFileFromDropbox(Form1 form1, Form form, String fileName, String directoryName)
        {
            XtraTabControl       pagesTabControl      = form1.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form1.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form1.toolStripProgressBar;

            try
            {
                Application.DoEvents();
                toolStripProgressBar.Value   = 0;
                toolStripProgressBar.Visible = true;
                toolStripProgressBar.PerformStep();

                bool   fileExists;
                String content = DropboxManager.GetFileFromDropbox(DropboxManager.GetDirectory(form1, directoryName), fileName, out fileExists);
                toolStripProgressBar.PerformStep();

                if (!fileExists)
                {
                    WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("openingFileNotExists", className), fileName, directoryName));
                    return(false);
                }
                if (String.IsNullOrEmpty(content))
                {
                    WindowManager.ShowInfoBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("openingFileEmpty", className), fileName));
                    return(false);
                }
                toolStripProgressBar.PerformStep();

                form1.LastDropboxFolder = directoryName;
                if (!String.IsNullOrEmpty(ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text))
                {
                    form1.TabIdentity = TabManager.AddNewPage(form1, form1.TabIdentity);
                }
                ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text = content;
                toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), fileName, LanguageUtil.GetCurrentLanguageString("OpenedFromDropbox", className));
                toolStripProgressBar.PerformStep();
            }
            catch (Exception exception)
            {
                WindowManager.ShowErrorBox(form, exception.Message, exception);
                return(false);
            }
            finally
            {
                toolStripProgressBar.Visible = false;
            }

            return(true);
        }
Пример #8
0
        public void gammaCorrection()
        {
            if (imageOpened)
            {
                //Константы, фигурирующие в формуле!
                float  C = 1, f0 = 0, Gamma = gamma; //0.5f;
                Bitmap BitmapImage = new Bitmap(pictureBox.Image);
                setProgressOptions(BitmapImage.Width);

                for (int i = 0; i < BitmapImage.Width; i++)
                {
                    for (int j = 0; j < BitmapImage.Height; j++)
                    {
                        //Вычисляем старое значение яркости (x) и новое по формуле С * (x +f0)^Gamma.
                        int OldBrightness = getPixelBrightness(BitmapImage.GetPixel(i, j)),
                            NewBrightness = (int)(C * Math.Pow((OldBrightness + f0), Gamma));
                        //Устанавливаем новое значение яркости
                        BitmapImage.SetPixel(i, j, setPixelBrightness(BitmapImage.GetPixel(i, j),
                                                                      OldBrightness,
                                                                      NewBrightness));
                    }
                    toolStripProgressBar.PerformStep();
                }
                pictureBox.Image = BitmapImage;
                chartUpdate(chartSecond);
                statusLabel.Text = "Гамма-коррекция";
            }
        }
Пример #9
0
        public void BehaviorPerformStep()
        {
            ToolStripProgressBar tsi = new ToolStripProgressBar();

            tsi.PerformStep();
            Assert.AreEqual(10, tsi.Value, "B1");
        }
Пример #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Member Step
        /// </summary>
        /// <param name="nStepAmt">nStepAmt</param>
        /// ------------------------------------------------------------------------------------
        public void Step(int nStepAmt)
        {
            if (m_progressBar == null)
            {
                return;
            }

            if (m_control.InvokeRequired)
            {
                m_control.BeginInvoke(new SetIntInvoke(Step), nStepAmt);
            }
            else
            {
                if (nStepAmt == 0)
                {
                    m_progressBar.PerformStep();
                }
                else
                {
                    if (m_progressBar.Value + nStepAmt > m_progressBar.Maximum)
                    {
                        m_progressBar.Value = m_progressBar.Minimum +
                                              (m_progressBar.Value + nStepAmt - m_progressBar.Maximum);
                    }
                    else
                    {
                        m_progressBar.Value += nStepAmt;
                    }
                }
            }
        }
Пример #11
0
        private void ProgressBarPerformStep(ToolStripProgressBar pb)
        {
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (statusStrip1.InvokeRequired)
            {
                ProgressBarPerformStepCallback d = new ProgressBarPerformStepCallback(ProgressBarPerformStep);
                statusStrip1.BeginInvoke(d, new object[] { pb });
            }
            else
            {
                if (pb.Value == pb.Maximum)
                {
                    ProgressBarFillTimes++;
                }

                if (ProgressBarFillTimes == 100)
                {
                    pb.Value             = pb.Minimum;
                    ProgressBarFillTimes = 0;
                }
                pb.PerformStep();
            }
        }
Пример #12
0
        static public void ScriptChecks(ref TextBox textbox, ref ToolStripProgressBar ProgressBar)
        {
            string[] src = FileSystemUtil.GetAllFileNames((string)Settings.Global.Properties["POLPath"], "*.src");
            string[] ecl = FileSystemUtil.GetAllFileNames((string)Settings.Global.Properties["POLPath"], "*.ecl");
            string[] asp = FileSystemUtil.GetAllFileNames((string)Settings.Global.Properties["POLPath"], "*.asp");

            ScriptCount.Add("ECL", ecl.Length);
            ScriptCount.Add("SRC", src.Length);
            ScriptCount.Add("ASP", asp.Length);

            if (ecl.Length < src.Length)
            {
                textbox.AppendText("* Warning: Not all scripts are compiled." + Environment.NewLine);
            }
            else if (ecl.Length > src.Length)
            {
                textbox.AppendText("* Warning: There are more ecl files than src files." + Environment.NewLine);
            }
            else
            {
                textbox.AppendText("* Pass: All scripts are compiled." + Environment.NewLine);
            }
            textbox.AppendText("Found " + src.Length.ToString() + " .src files and " + ecl.Length.ToString() + " .ecl files." + Environment.NewLine);
            ProgressBar.PerformStep();
        }
        public static void StartBusy(String status)
        {
            if (String.IsNullOrWhiteSpace(InitialStatus))
            {
                InitialStatus = status;
            }

            SetStatusLabel(status);
            if (Cursor.Current == Cursors.WaitCursor)
            {
                return;
            }

            Cursor.Current          = Cursors.WaitCursor;
            StatusProgressBar.Value = 0;
            StatusProgressBar.Step  = 10;
            StatusProgressBar.PerformStep();
        }
Пример #14
0
        internal static bool SaveFileOnDropbox(Form1 form1, Form form, String fileName, String directoryName)
        {
            XtraTabControl       pagesTabControl      = form1.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form1.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form1.toolStripProgressBar;

            ICloudDirectoryEntry directory = DropboxManager.GetDirectory(form1, directoryName);

            try
            {
                Application.DoEvents();
                toolStripProgressBar.Value   = 0;
                toolStripProgressBar.Visible = true;
                toolStripProgressBar.PerformStep();

                if (DropboxManager.ExistsChildOnDropbox(directory, fileName))
                {
                    if (WindowManager.ShowQuestionBox(form, LanguageUtil.GetCurrentLanguageString("OverwriteFileOnDropbox", className)) != DialogResult.Yes)
                    {
                        return(false);
                    }
                }

                //Encoding fileEncoding = TabUtil.GetTabTextEncoding(pagesTabControl.SelectedTabPage);
                toolStripProgressBar.PerformStep();

                DropboxManager.SaveFileOnDropbox(form1, directory, fileName, ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text); //, fileEncoding);
                toolStripProgressBar.PerformStep();

                form1.LastDropboxFolder   = directoryName;
                toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), Path.GetFileName(fileName), LanguageUtil.GetCurrentLanguageString("SavedOnDropbox", className));
                toolStripProgressBar.PerformStep();

                toolStripProgressBar.Visible = false;
            }
            catch (Exception exception)
            {
                toolStripProgressBar.Visible = false;
                WindowManager.ShowErrorBox(form, exception.Message, exception);
                return(false);
            }

            return(true);
        }
Пример #15
0
 //method to update the progressbar
 public static void UpdateProgressBar(int value)
 {
     //defensive programming
     //we should only allow appropriate values
     if (MainProgressBar != null && value >= 1 && value <= 100)
     {
         MainProgressBar.Value = value;
         MainProgressBar.PerformStep();
     }
 }
Пример #16
0
 public void PackedFileLoaded(PackedFile packedFile)
 {
     currentCount++;
     if (currentCount % 10 <= 0)
     {
         label.Text = string.Format("Opening {0} ({1} of {2} files loaded)", file, currentCount, count);
         progress.PerformStep();
         Application.DoEvents();
     }
 }
Пример #17
0
        internal static void AppendFileContent(Form1 form)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;
            CustomRichTextBox    pageTextBox          = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
            OpenFileDialog       openFileDialog       = form.openFileDialog;

            try
            {
                openFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form);
                SetFileDialogFilter(openFileDialog);

                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    toolStripProgressBar.Visible = false;
                    return;
                }
                toolStripProgressBar.Value   = 0;
                toolStripProgressBar.Visible = true;
                toolStripProgressBar.PerformStep();

                ConfigUtil.UpdateParameter("LastUserFolder", Path.GetDirectoryName(openFileDialog.FileName));
                toolStripProgressBar.PerformStep();

                String fileContents = FileUtil.ReadToEndWithEncoding(openFileDialog.FileName);
                toolStripProgressBar.PerformStep();

                pageTextBox.AppendText(fileContents);
                TextManager.RefreshUndoRedoExternal(form);

                toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), Path.GetFileName(openFileDialog.FileName), LanguageUtil.GetCurrentLanguageString("Appended", className));
                toolStripProgressBar.PerformStep();
                toolStripProgressBar.Visible = false;
            }
            catch (Exception exception)
            {
                toolStripProgressBar.Visible = false;
                WindowManager.ShowErrorBox(form, exception.Message, exception);
            }
        }
Пример #18
0
 private void UpdateProgressBar()
 {
     try
     {
         if (progressBar != null)
         {
             progressBar.Control.Invoke((Action)(() => { progressBar.PerformStep(); }));
         }
     }
     catch (Exception)
     {
     }
 }
        private void generarExpedientesPDFsToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            var carpeta = new FolderBrowserDialog
            {
                Description         = "Carpeta de Salida",
                ShowNewFolderButton = true,
            };

            if (carpeta.ShowDialog() == DialogResult.OK)
            {
                Cursor = System.Windows.Forms.Cursors.WaitCursor;

                parametros = "|V2=" + ((Clases.clsNodoTiny)nodoActual.Tag).idNodo + "|";
                validar    = "10";
                Datos      = Acceso.ivkProcedimiento("sp_Datos_Expedientes", validar, parametros, Clases.vGlobales.conexion, null);

                if (Datos.bOk)
                {
                    // Iniciar el Proceso de Generación de PDF's
                    PBGeneral.Style   = ProgressBarStyle.Continuous;
                    PBGeneral.Minimum = 1;
                    PBGeneral.Maximum = Datos.ds.Tables[0].Rows.Count;
                    PBGeneral.Value   = 1;
                    PBGeneral.Step    = 1;

                    PBGeneral.Visible = true;

                    foreach (DataRow r in Datos.ds.Tables[0].Rows)
                    {
                        //parametros = "|V2=" + r[0].ToString() +"|";
                        //validar = "42";
                        //Datos2 = Acceso.ivkProcedimiento("sp_Datos_Documentos", validar, parametros, Clases.vGlobales.conexion, null);

                        if (!File.Exists(carpeta.SelectedPath + "\\" + r[1].ToString() + ".pdf"))
                        {
                            Clases.clsPDFExport pdfExport = new Clases.clsPDFExport();
                            pdfExport.Exportar(carpeta.SelectedPath + "\\" + r[1].ToString() + ".pdf", r[0].ToString());
                        }

                        PBGeneral.PerformStep();
                        Application.DoEvents();
                    }

                    PBGeneral.Visible = false;
                    PBGeneral.Style   = ProgressBarStyle.Marquee;
                }

                ShowNotify("Generación de PDF", "Termino el proceso de generación de PDF's", ToolTipIcon.Info, 2000);
                Cursor = Cursors.Default;
            }
        }
Пример #20
0
        /// <summary>
        /// Create archives based on specifications passed and internal state
        /// </summary>
        void Create(string zipFileName, ArrayList fileSpecs, ref ToolStripProgressBar ProgressBar)
        {
            if (Path.GetExtension(zipFileName).Length == 0)
            {
                zipFileName = Path.ChangeExtension(zipFileName, ".zip");
            }

            try
            {
                using (ZipFile zf = ZipFile.Create(zipFileName))
                {
                    zf.BeginUpdate();

                    activeZipFile_ = zf;

                    foreach (string spec in fileSpecs)
                    {
                        // This can fail with wildcards in spec...
                        string path     = Path.GetDirectoryName(Path.GetFullPath(spec));
                        string fileSpec = Path.GetFileName(spec);

                        zf.NameTransform = new ZipNameTransform(Settings.Global.Properties["POLPath"]);

                        FileSystemScanner scanner = new FileSystemScanner(fileSpec);
                        scanner.ProcessFile = new ProcessFileHandler(ProcessFile);
                        scanner.Scan(path, false);
                        ProgressBar.PerformStep();
                    }
                    zf.CommitUpdate();
                    ProgressBar.PerformStep();
                }
            }
            catch (Exception ex)
            {
                ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                tmp.ShowDialog();
            }
        }
Пример #21
0
        /// <summary>
        /// The CreateCards method.
        /// Creates card buttons.
        /// </summary>
        /// <param name="pnlTable">The panel on the calling form the card buttons will be added to.</param>
        /// <param name="ShowProgress">The progress bar on the calling form.</param>
        /// <param name="Booster">Pack of cards.</param>
        private void CreateCards(Panel pnlTable, ToolStripProgressBar ShowProgress, Button LastButton, Pack Booster, ToolStripLabel DraftStatus)
        {
            for (int card = 1; card <= 15; card++)
            {
                ShowProgress.PerformStep();     //Show the progress

                #region Card Property Setup
                //The cards are buttons on the panel. Set the button properties to match the card properties.
                CardProperties CardProps = new CardProperties();
                Button         btnCard   = new Button();
                btnCard.Name      = card.ToString();
                btnCard.Width     = CardProps.CardWidth;
                btnCard.Height    = CardProps.CardHeight;
                btnCard.Click    += Card_Click;
                btnCard.Text      = card.ToString();
                btnCard.BackColor = Color.Black;
                btnCard.Image     = CardArt();
                #endregion

                #region Set Card Position
                if (card == 1)
                {
                    btnCard.Left = pnlTable.Left;
                    btnCard.Top  = pnlTable.Top;
                }
                else
                {
                    btnCard.Left = LastButton.Right + 5;

                    if (btnCard.Left > (pnlTable.Right - 5))
                    {
                        btnCard.Left = pnlTable.Left;
                        btnCard.Top  = LastButton.Bottom + 5;
                    }
                    else
                    {
                        btnCard.Top = LastButton.Top;
                    }
                }
                #endregion

                #region Add Card
                pnlTable.Controls.Add(btnCard); //Add the button to the panel.
                LastButton = btnCard;           //Set the last button so we know where to begin on the next one.
                Booster.Cards.Add(btnCard);     //Add the card to the opened booster.
                #endregion
            }
        }
Пример #22
0
        private void btnAssign_Click(object sender, EventArgs e)
        {
            using (new WaitCursor(this, false))
            {
                var newTarget    = (IAnalysis)(tvTarget.SelectedNode.Tag);
                var checkedItems = m_currentBrowseView.CheckedItems;
                var src          = (IAnalysis)tvSource.SelectedNode.Tag;
                if (checkedItems.Count > 0)
                {
                    m_toolStripProgressBar.Minimum = 0;
                    m_toolStripProgressBar.Maximum = checkedItems.Count;
                    m_toolStripProgressBar.Step    = 1;
                    m_toolStripProgressBar.Value   = 0;
                }

                UndoableUnitOfWorkHelper.Do(MEStrings.ksUndoAssignAnalyses, MEStrings.ksRedoAssignAnalyses, m_specialSda.GetActionHandler(), () =>
                {
                    var concSda        = ConcSda;
                    var originalValues = new Dictionary <int, IParaFragment>();
                    foreach (var originalHvo in concSda.VecProp(src.Hvo, m_currentSourceFakeFlid))
                    {
                        originalValues.Add(originalHvo, concSda.OccurrenceFromHvo(originalHvo));
                    }
                    foreach (var fakeHvo in checkedItems)
                    {
                        originalValues.Remove(fakeHvo);
                        var analysisOccurrence = concSda.OccurrenceFromHvo(fakeHvo);
                        ((AnalysisOccurrence)analysisOccurrence).Analysis = newTarget;
                        m_specialSda.SetInt(fakeHvo, XMLViewsDataCache.ktagItemSelected, 0);
                        m_toolStripProgressBar.PerformStep();
                    }
                    // Make sure the correct updated occurrences will be computed when needed in Refresh of the
                    // occurrences pane and anywhere else.
                    concSda.UpdateExactAnalysisOccurrences(src);
                    var clerk    = m_recordClerks[newTarget.ClassID];
                    var clerkSda = (ConcDecorator)((DomainDataByFlidDecoratorBase)clerk.VirtualListPublisher).BaseSda;
                    clerkSda.UpdateExactAnalysisOccurrences(newTarget);
                });

                CheckAssignBtnEnabling();
                m_toolStripProgressBar.Value = 0;
                SetRecordStatus();
            }
        }
Пример #23
0
 private void btnAssign_Click(object sender, System.EventArgs e)
 {
     using (new SIL.FieldWorks.Common.Utils.WaitCursor(this, false))
     {
         int        newTargetHvo = (int)(tvTarget.SelectedNode.Tag);
         List <int> checkedItems = m_currentBrowseView.CheckedItems;
         int        virtFlid     = m_currentBrowseView.Clerk.VirtualFlid;
         int        srcHvo       = (int)tvSource.SelectedNode.Tag;
         if (checkedItems.Count > 0)
         {
             m_toolStripProgressBar.Minimum = 0;
             m_toolStripProgressBar.Maximum = checkedItems.Count;
             m_toolStripProgressBar.Step    = 1;
             m_toolStripProgressBar.Value   = 0;
         }
         foreach (int annHvo in checkedItems)
         {
             ICmBaseAnnotation ann = null;
             if (m_cache.IsDummyObject(annHvo))
             {
                 ann = ConvertDummyToReal(srcHvo, virtFlid, annHvo) as ICmBaseAnnotation;
                 Debug.Assert(ann != null);
             }
             else
             {
                 ann = CmBaseAnnotation.CreateFromDBObject(m_cache, annHvo);
             }
             ann.InstanceOfRAHvo = newTargetHvo;
             m_cache.SetIntProperty(ann.Hvo, XmlBrowseViewVc.ktagItemSelected, 0);
             m_toolStripProgressBar.PerformStep();
         }
         // After these changes, we need to refresh the display.  PropChanged() redraws the
         // list, but incorrect (and inconsistent) items are then displayed.  See LT-8703.
         // Refreshing the clerk reloads the list and then redraws it.
         m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, srcHvo, virtFlid, 0, 0,
                             checkedItems.Count);
         m_currentBrowseView.Clerk.OnRefresh(null);
         CheckAssignBtnEnabling();
         m_toolStripProgressBar.Value = 0;
         SetRecordStatus();
     }
 }
Пример #24
0
        private void ErrorMailProgressTimer_Tick(object sender, EventArgs e)
        {
            if (mComplete == false)
            {
                ErrorToolStripProgressBar.PerformStep();
                if (ErrorToolStripProgressBar.Value >= ErrorToolStripProgressBar.Maximum)
                {
                    ErrorToolStripProgressBar.Value = 0;
                }
            }
            else
            {
                ErrorToolStripStatusLabel.Text    = "";
                ErrorToolStripProgressBar.Value   = ErrorToolStripProgressBar.Minimum;
                ErrorToolStripStatusLabel.Visible = false;
                ErrorToolStripProgressBar.Visible = false;

                ErrorMailProgressTimer.Stop();
                ErrorMailProgressTimer.Enabled = false;
            }
        }
Пример #25
0
 private void progress()
 {
     pb.PerformStep();
     pb.Invalidate();
 }
Пример #26
0
        private void PopulateExcelRow(Excel.Worksheet Ws, ref int row, ref int lastDataSourceRow, ref int lastTableRow, ComparisonObject comparisonObject, ToolStripProgressBar progBar)
        {
            progBar.PerformStep();
            row += 1;

            // Close out groups if necessary
            if (comparisonObject.ComparisonObjectType == ComparisonObjectType.DataSource || comparisonObject.ComparisonObjectType == ComparisonObjectType.Table || comparisonObject.ComparisonObjectType == ComparisonObjectType.Perspective || comparisonObject.ComparisonObjectType == ComparisonObjectType.Culture || comparisonObject.ComparisonObjectType == ComparisonObjectType.Role || comparisonObject.ComparisonObjectType == ComparisonObjectType.Expression || comparisonObject.ComparisonObjectType == ComparisonObjectType.Action) //treat perspectives/cultures/roles/expressions like datasources for purpose of grouping
            {
                // do we need to close a table group?
                if (lastTableRow + 1 < row && lastTableRow != -1)
                {
                    Ws.Application.Rows[Convert.ToString(lastTableRow + 1) + ":" + Convert.ToString(row - 1)].Select();
                    Ws.Application.Selection.Rows.Group();
                }
                lastTableRow = row;
            }

            //Type column
            switch (comparisonObject.ComparisonObjectType)
            {
            case ComparisonObjectType.Model:
                Ws.Cells[row, 1].Value = "Model";
                break;

            case ComparisonObjectType.DataSource:
                Ws.Cells[row, 1].Value = "Data Source";
                break;

            case ComparisonObjectType.Table:
                Ws.Cells[row, 1].Value = "Table";
                break;

            case ComparisonObjectType.Relationship:
                Ws.Cells[row, 1].Value = "Relationship";
                Ws.Cells[row, 1].InsertIndent(3);
                Ws.Cells[row, 2].InsertIndent(3);
                Ws.Cells[row, 5].InsertIndent(3);
                break;

            case ComparisonObjectType.Measure:
                Ws.Cells[row, 1].Value = "Measure";
                Ws.Cells[row, 1].InsertIndent(3);
                Ws.Cells[row, 2].InsertIndent(3);
                Ws.Cells[row, 5].InsertIndent(3);
                break;

            case ComparisonObjectType.Kpi:
                Ws.Cells[row, 1].Value = "KPI";
                Ws.Cells[row, 1].InsertIndent(3);
                Ws.Cells[row, 2].InsertIndent(3);
                Ws.Cells[row, 5].InsertIndent(3);
                break;

            case ComparisonObjectType.CalculationItem:
                Ws.Cells[row, 1].Value = "Calculation Item";
                Ws.Cells[row, 1].InsertIndent(3);
                Ws.Cells[row, 2].InsertIndent(3);
                Ws.Cells[row, 5].InsertIndent(3);
                break;

            case ComparisonObjectType.Perspective:
                Ws.Cells[row, 1].Value = "Perspective";
                break;

            case ComparisonObjectType.Culture:
                Ws.Cells[row, 1].Value = "Culture";
                break;

            case ComparisonObjectType.Role:
                Ws.Cells[row, 1].Value = "Role";
                break;

            case ComparisonObjectType.Expression:
                Ws.Cells[row, 1].Value = "Expression";
                break;

            case ComparisonObjectType.Action:
                Ws.Cells[row, 1].Value = "Action";
                break;

            default:
                Ws.Cells[row, 1].Value = comparisonObject.ComparisonObjectType.ToString();
                break;
            }

            //Source Obj Name column
            if (comparisonObject.SourceObjectName != null && comparisonObject.SourceObjectName != "")
            {
                Ws.Cells[row, 2].Value = comparisonObject.SourceObjectName;
                if (comparisonObject.SourceObjectDefinition != null && comparisonObject.SourceObjectDefinition != "")
                {
                    Ws.Cells[row, 3].Value = comparisonObject.SourceObjectDefinition;
                }
            }
            else
            {
                Ws.Cells[row, 2].Interior.Pattern             = Excel.Constants.xlSolid;
                Ws.Cells[row, 2].Interior.PatternColorIndex   = Excel.Constants.xlAutomatic;
                Ws.Cells[row, 2].Interior.ThemeColor          = Excel.XlThemeColor.xlThemeColorDark1;
                Ws.Cells[row, 2].Interior.TintAndShade        = -0.149998474074526;
                Ws.Cells[row, 2].Interior.PatternTintAndShade = 0;

                Ws.Cells[row, 3].Interior.Pattern             = Excel.Constants.xlSolid;
                Ws.Cells[row, 3].Interior.PatternColorIndex   = Excel.Constants.xlAutomatic;
                Ws.Cells[row, 3].Interior.ThemeColor          = Excel.XlThemeColor.xlThemeColorDark1;
                Ws.Cells[row, 3].Interior.TintAndShade        = -0.149998474074526;
                Ws.Cells[row, 3].Interior.PatternTintAndShade = 0;
            }

            //status
            switch (comparisonObject.Status)
            {
            case ComparisonObjectStatus.SameDefinition:
                Ws.Cells[row, 4].Value = "Same Definition";
                break;

            case ComparisonObjectStatus.DifferentDefinitions:
                Ws.Cells[row, 4].Value = "Different Definitions";
                break;

            case ComparisonObjectStatus.MissingInTarget:
                Ws.Cells[row, 4].Value = "Missing in Target";
                break;

            case ComparisonObjectStatus.MissingInSource:
                Ws.Cells[row, 4].Value = "Missing in Source";
                break;

            default:
                Ws.Cells[row, 4].Value = comparisonObject.Status.ToString();
                break;
            }

            //Target Obj Name column
            if (comparisonObject.TargetObjectName != null && comparisonObject.TargetObjectName != "")
            {
                Ws.Cells[row, 5].Value = comparisonObject.TargetObjectName;
                if (comparisonObject.TargetObjectDefinition != null && comparisonObject.TargetObjectDefinition != "")
                {
                    Ws.Cells[row, 6].Value = comparisonObject.TargetObjectDefinition;
                }
            }
            else
            {
                Ws.Cells[row, 5].Interior.Pattern             = Excel.Constants.xlSolid;
                Ws.Cells[row, 5].Interior.PatternColorIndex   = Excel.Constants.xlAutomatic;
                Ws.Cells[row, 5].Interior.ThemeColor          = Excel.XlThemeColor.xlThemeColorDark1;
                Ws.Cells[row, 5].Interior.TintAndShade        = -0.149998474074526;
                Ws.Cells[row, 5].Interior.PatternTintAndShade = 0;

                Ws.Cells[row, 6].Interior.Pattern             = Excel.Constants.xlSolid;
                Ws.Cells[row, 6].Interior.PatternColorIndex   = Excel.Constants.xlAutomatic;
                Ws.Cells[row, 6].Interior.ThemeColor          = Excel.XlThemeColor.xlThemeColorDark1;
                Ws.Cells[row, 6].Interior.TintAndShade        = -0.149998474074526;
                Ws.Cells[row, 6].Interior.PatternTintAndShade = 0;
            }

            // Insert blank in last cell so defintion doesn't overlap
            Ws.Cells[row, 7].Value = " ";

            foreach (ComparisonObject childComparisonObject in comparisonObject.ChildComparisonObjects)
            {
                PopulateExcelRow(Ws, ref row, ref lastDataSourceRow, ref lastTableRow, childComparisonObject, progBar);
            }
        }
Пример #27
0
        internal static bool SaveAsPdf(Form1 form)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            CustomRichTextBox    pageTextBox          = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
            SaveFileDialog       saveFileDialog       = form.saveFileDialog;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;

            if (String.IsNullOrEmpty(pageTextBox.Text))
            {
                WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("NoTextForPDF", className));
                return(false);
            }

            try
            {
                saveFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form);
                saveFileDialog.Filter           = LanguageUtil.GetCurrentLanguageString("PDFFile", className); //"PDF document (*.pdf)|*.pdf";
                saveFileDialog.FilterIndex      = 0;

                String filenameTabPage = ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage);
                if (String.IsNullOrEmpty(filenameTabPage))
                {
                    saveFileDialog.FileName = "*.pdf";
                }
                else if (filenameTabPage.Contains("."))
                {
                    saveFileDialog.FileName = filenameTabPage.Substring(0, filenameTabPage.LastIndexOf('.')) + ".pdf";
                }
                else
                {
                    saveFileDialog.FileName = filenameTabPage + ".pdf";
                }

                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                {
                    toolStripProgressBar.Visible = false;
                    return(false);
                }

                Application.DoEvents();
                toolStripProgressBar.Value   = 0;
                toolStripProgressBar.Visible = true;

                String fileName = saveFileDialog.FileName;
                toolStripProgressBar.PerformStep();

                ConfigUtil.UpdateParameter("LastUserFolder", Path.GetDirectoryName(fileName));
                FileInfo fileInfo = new FileInfo(fileName);
                if (fileInfo.IsReadOnly && fileInfo.Exists)
                {
                    toolStripProgressBar.Visible = false;
                    WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("SavingReadonly", className));
                    return(SaveAsPdf(form));
                }

                toolStripProgressBar.PerformStep();
                String fileTitle = fileName.Substring(0, fileName.LastIndexOf(".pdf"));

                //Document document = new Document();
                //FileStream fileStream = File.Create(fileName);
                //PdfWriter.GetInstance(document, fileStream);

                //document.Open();
                //document.AddTitle(fileTitle);
                //document.AddCreationDate();
                //document.AddCreator("DtPad " + AssemblyUtil.AssemblyVersion);
                //document.Add(new Paragraph(pageTextBox.Text));

                //if (document.IsOpen())
                //{
                //    document.CloseDocument();
                //}
                //fileStream.Dispose();
                PdfUtil.SaveText(fileName, fileTitle, pageTextBox.Text);

                toolStripProgressBar.PerformStep();
                toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), Path.GetFileName(fileName), LanguageUtil.GetCurrentLanguageString("Saved", className));

                toolStripProgressBar.PerformStep();
                toolStripProgressBar.Visible = false;

                OtherManager.StartProcess(form, fileName);
                saveFileDialog.FileName = "*.txt";
                return(true);
            }
            catch (Exception exception)
            {
                toolStripProgressBar.Visible = false;
                saveFileDialog.FileName      = "*.txt";
                WindowManager.ShowErrorBox(form, exception.Message, exception);
                return(false);
            }
        }
Пример #28
0
        internal static int OpenFile(Form1 form, int tabIdentity, String[] specificFileNames, bool showMessages, bool saveNewRecentFile, out List <String> errors)
        {
            CustomXtraTabControl pagesTabControl      = form.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;
            OpenFileDialog       openFileDialog       = form.openFileDialog;

            bool isWindowsHostsFile = false;
            int  localTabIdentity   = tabIdentity;

            errors = new List <String>();

            openFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form);
            openFileDialog.Multiselect      = true;
            SetFileDialogFilter(openFileDialog);

            TrayManager.RestoreFormIfIsInTray(form);

            try
            {
                String[] fileNames;

                if (specificFileNames == null || specificFileNames.Length <= 0)
                {
                    if (openFileDialog.ShowDialog() != DialogResult.OK)
                    {
                        return(tabIdentity);
                    }

                    fileNames = openFileDialog.FileNames;
                }
                else
                {
                    fileNames = specificFileNames;
                }

                //Verify if file is a DtPad session
                if (fileNames.Length == 1 && fileNames[0].EndsWith(".dps"))
                {
                    SessionManager.OpenSession(form, fileNames[0]);
                    return(form.TabIdentity);
                }

                Application.DoEvents();
                toolStripProgressBar.Value = 0;

                foreach (String fileName in fileNames)
                {
                    //Verify if file is Windows hosts file
                    if (fileName.Contains(@"drivers\etc\hosts"))
                    {
                        if (!SystemUtil.IsUserAdministrator())
                        {
                            WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("UserNotAdmin", className));
                        }

                        isWindowsHostsFile = true;
                    }

                    if (!showMessages)
                    {
                        if (!File.Exists(fileName))
                        {
                            errors.Add(String.Format(LanguageUtil.GetCurrentLanguageString("NoMessageFileNotExists", className), fileName));
                            continue;
                        }
                        if (FileUtil.IsFileInUse(fileName))
                        {
                            errors.Add(String.Format(LanguageUtil.GetCurrentLanguageString("NoMessageFileInUse", className), fileName));
                            continue;
                        }
                        if (FileUtil.IsFileTooLargeForDtPad(fileName))
                        {
                            errors.Add(String.Format(LanguageUtil.GetCurrentLanguageString("NoMessageFileTooHeavy", className), fileName));
                            continue;
                        }
                    }
                    else if (!File.Exists(fileName))
                    {
                        WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileNotExisting", className), fileName));
                        continue;
                    }
                    else if (FileUtil.IsFileInUse(fileName))
                    {
                        WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileInUse", className), fileName));
                        continue;
                    }
                    if (FileUtil.IsFileTooLargeForDtPad(fileName))
                    {
                        WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileTooHeavy", className), fileName));
                        continue;
                    }

                    //Cycle and check if the file is already open, in which case I select its tab and continue with the next one
                    XtraTabPage tabPage;
                    if (FileUtil.IsFileAlreadyOpen(form, fileName, out tabPage))
                    {
                        pagesTabControl.SelectedTabPage = tabPage;
                        toolStripProgressBar.PerformStep();
                        toolStripProgressBar.PerformStep();
                        toolStripProgressBar.PerformStep();
                        toolStripProgressBar.PerformStep();
                        toolStripProgressBar.Visible = false;
                        continue;
                    }

                    //Verify if file is an archive
                    try
                    {
                        ZipFile file = null;
                        bool    isZipFile;

                        try
                        {
                            file      = new ZipFile(fileName);
                            isZipFile = file.TestArchive(false, TestStrategy.FindFirstError, form.Zip_Errors);
                        }
                        finally
                        {
                            if (file != null)
                            {
                                file.Close();
                            }
                        }

                        if (isZipFile)
                        {
                            WindowManager.ShowZipExtract(form, fileName);
                            continue;
                        }
                    }
                    catch (ZipException)
                    {
                    }

                    toolStripProgressBar.Visible = true;
                    toolStripProgressBar.PerformStep();

                    String   fileContents;
                    Encoding fileEncoding;
                    bool     anonymousFile = false;

                    //Verify if file is a PDF
                    if (fileName.EndsWith(".pdf"))
                    {
                        bool success;
                        fileContents = PdfUtil.ExtractText(fileName, out success);

                        if (!success)
                        {
                            WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("InvalidPdf", className));
                            return(tabIdentity);
                        }

                        fileEncoding  = EncodingUtil.GetDefaultEncoding();
                        anonymousFile = true;
                    }
                    else
                    {
                        fileContents = FileUtil.ReadToEndWithEncoding(fileName, out fileEncoding);
                    }

                    bool favouriteFile = FavouriteManager.IsFileFavourite(fileName);
                    if (!favouriteFile && saveNewRecentFile)
                    {
                        ConfigUtil.UpdateParameter("LastUserFolder", Path.GetDirectoryName(fileName));
                        FileListManager.SetNewRecentFile(form, fileName);
                    }
                    toolStripProgressBar.PerformStep();

                    CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
                    if (!String.IsNullOrEmpty(pageTextBox.Text) || !String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage)))
                    {
                        localTabIdentity = TabManager.AddNewPage(form, localTabIdentity);
                    }
                    toolStripProgressBar.PerformStep();

                    //Row number check
                    WindowManager.CheckLineNumbersForTextLenght(form, fileContents);

                    FileInfo fileInfo = new FileInfo(fileName);

                    pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);

                    //Verify if file is a tweet file
                    if (fileName.EndsWith(".tweet") && !ColumnRulerManager.IsPanelOpen(form))
                    {
                        ColumnRulerManager.TogglePanel(form);
                    }

                    pageTextBox.Text           = fileContents.Replace(Environment.NewLine, ConstantUtil.newLine);
                    pageTextBox.CustomOriginal = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text.GetHashCode().ToString();
                    pageTextBox.CustomEncoding = fileEncoding.CodePage.ToString();

                    if (!anonymousFile)
                    {
                        String fileNameWithoutPath = Path.GetFileName(fileName);

                        pageTextBox.CustomModified = false;
                        ProgramUtil.SetFilenameTabPage(pagesTabControl.SelectedTabPage, fileName);
                        pagesTabControl.SelectedTabPage.ImageIndex   = fileInfo.IsReadOnly ? 2 : 0;
                        pagesTabControl.SelectedTabPage.Text         = fileNameWithoutPath;
                        pagesTabControl.SelectedTabPage.Tooltip      = fileName;
                        pagesTabControl.SelectedTabPage.TooltipTitle = fileNameWithoutPath;
                        form.Text = String.Format("DtPad - {0}", fileNameWithoutPath);
                        TabManager.ToggleTabFileTools(form, true);
                    }
                    else
                    {
                        pageTextBox.CustomModified = true;
                    }

                    toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), Path.GetFileName(fileName), LanguageUtil.GetCurrentLanguageString("Opened", className));
                    toolStripProgressBar.PerformStep();

                    tabIdentity = localTabIdentity;

                    if (!String.IsNullOrEmpty(fileInfo.Extension) && ConfigUtil.GetStringParameter("AutoFormatFiles").Contains(fileInfo.Extension))
                    {
                        FormatManager.FormatXml(form);
                    }

                    if (ConfigUtil.GetBoolParameter("AutoOpenHostsConfigurator") && isWindowsHostsFile)
                    {
                        pagesTabControl.SelectedTabPage.Appearance.Header.ForeColor = ConfigUtil.GetColorParameter("ColorHostsConfigurator");
                        CustomFilesManager.OpenHostsSectionPanel(form);
                        isWindowsHostsFile = false;
                    }
                }
            }
            catch (Exception exception)
            {
                TabManager.ToggleTabFileTools(form, false);

                toolStripProgressBar.Visible = false;
                toolStripProgressBar.Value   = 0;

                if (showMessages)
                {
                    WindowManager.ShowErrorBox(form, exception.Message, exception);
                }
            }
            finally
            {
                toolStripProgressBar.Visible = false;
                toolStripProgressBar.Value   = 0;
            }

            return(tabIdentity);
        }
Пример #29
0
        private static bool SaveFile(bool saveNewRecentFile, Form1 form, bool forceSaveAs, bool forceBackup, bool savingAll = false)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;
            SaveFileDialog       saveFileDialog       = form.saveFileDialog;

            try
            {
                String fileName;

                if (String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage)) || forceSaveAs)
                {
                    saveFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form);
                    SetFileDialogFilter(saveFileDialog);

                    TabsUpdate(pagesTabControl, savingAll, UpdatePhase.End);   //Useful to save all execution
                    DialogResult saveNewResult = saveFileDialog.ShowDialog();
                    TabsUpdate(pagesTabControl, savingAll, UpdatePhase.Begin); //Useful to save all execution

                    if (saveNewResult != DialogResult.OK)
                    {
                        toolStripProgressBar.Visible = false;
                        return(false);
                    }

                    fileName = saveFileDialog.FileName;
                }
                else
                {
                    fileName = ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage);
                }

                //Check that fileName is not already opened into another tab
                foreach (XtraTabPage tabPage in pagesTabControl.TabPages)
                {
                    if (tabPage == pagesTabControl.SelectedTabPage || ProgramUtil.GetFilenameTabPage(tabPage) != fileName)
                    {
                        continue;
                    }

                    pagesTabControl.SelectedTabPage = tabPage;

                    TabsUpdate(pagesTabControl, savingAll, UpdatePhase.End);   //Useful to save all execution
                    WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("FileAlreadyOpen", className));
                    TabsUpdate(pagesTabControl, savingAll, UpdatePhase.Begin); //Useful to save all execution

                    return(false);
                }

                bool favouriteFile = FavouriteManager.IsFileFavourite(fileName);

                Application.DoEvents();
                toolStripProgressBar.Value   = 0;
                toolStripProgressBar.Visible = true;

                toolStripProgressBar.PerformStep();

                if (!favouriteFile)
                {
                    ConfigUtil.UpdateParameter("LastUserFolder", Path.GetDirectoryName(fileName));
                }

                FileInfo fileInfo = new FileInfo(fileName);
                if (fileInfo.IsReadOnly && fileInfo.Exists)
                {
                    toolStripProgressBar.Visible = false;

                    TabsUpdate(pagesTabControl, savingAll, UpdatePhase.End);   //Useful to save all execution
                    WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("SavingReadonly", className));
                    TabsUpdate(pagesTabControl, savingAll, UpdatePhase.Begin); //Useful to save all execution

                    return(SaveFile(form, true));
                }

                bool backupConfigActive = ConfigUtil.GetBoolParameter("BackupEnabled");
                if ((!String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage)) && !forceSaveAs) && (forceBackup || backupConfigActive))
                {
                    TabsUpdate(pagesTabControl, savingAll, UpdatePhase.End);   //Useful to save all execution
                    bool saved = BackupFileOnSaving(form, fileName);
                    TabsUpdate(pagesTabControl, savingAll, UpdatePhase.Begin); //Useful to save all execution

                    if (saved == false)
                    {
                        toolStripProgressBar.Visible = false;
                        return(false);
                    }
                }

                toolStripProgressBar.PerformStep();
                if (SaveFileCoreWithEncoding(form, fileName, savingAll) == false)
                {
                    toolStripProgressBar.Visible = false;
                    return(false);
                }

                if (!favouriteFile && saveNewRecentFile)
                {
                    FileListManager.SetNewRecentFile(form, fileName);
                }

                if (CustomFilesManager.IsHostsSectionPanelOpen(form))
                {
                    CustomFilesManager.GetSections(form, false);
                }
                toolStripProgressBar.PerformStep();

                CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);

                ProgramUtil.SetFilenameTabPage(pagesTabControl.SelectedTabPage, fileName);
                pagesTabControl.SelectedTabPage.ImageIndex = 0;
                pagesTabControl.SelectedTabPage.Text       = Path.GetFileName(fileName);
                pageTextBox.CustomModified = false;
                pageTextBox.CustomOriginal = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text.GetHashCode().ToString();
                form.Text = String.Format("DtPad - {0}", Path.GetFileName(fileName));
                toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), Path.GetFileName(fileName), LanguageUtil.GetCurrentLanguageString("Saved", className));
                TabManager.ToggleTabFileTools(form, true);

                toolStripProgressBar.PerformStep();
                toolStripProgressBar.Visible = false;
            }
            catch (Exception exception)
            {
                TabManager.ToggleTabFileTools(form, false);
                toolStripProgressBar.Visible = false;

                TabsUpdate(pagesTabControl, savingAll, UpdatePhase.End);   //Useful to save all execution
                WindowManager.ShowErrorBox(form, exception.Message, exception);
                TabsUpdate(pagesTabControl, savingAll, UpdatePhase.Begin); //Useful to save all execution

                return(false);
            }

            return(true);
        }
Пример #30
0
        public bool MapMassToArea()
        {
            bool mapped = false;

            try
            {
                List <Element> areas = settings.SelectedElements;

                if (areas.Count > 0)
                {
                    foreach (Element element in areas)
                    {
                        progressBar.PerformStep();
                        Area area = element as Area;
                        if (area.Area == 0)
                        {
                            continue;
                        }
#if RELEASE2015 || RELEASE2016 || RELEASE2017
                        if (null == area.LookupParameter("Plot Code"))
                        {
                            MessageBox.Show("Cannot find a parameter named Plot Code in Area elements\n Please add required parameters in both Area and Mass to calculate FAR."
                                            , "Missing Parameter: Plot Code", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            break;
                        }
                        string plotCode = area.LookupParameter("Plot Code").AsString();
#else
                        if (null == area.get_Parameter("Plot Code"))
                        {
                            MessageBox.Show("Cannot find a parameter named Plot Code in Area elements\n Please add required parameters in both Area and Mass to calculate FAR."
                                            , "Missing Parameter: Plot Code", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            break;
                        }
                        string plotCode = area.get_Parameter("Plot Code").AsString();
#endif

                        if (plotCode == null || plotCode == "0")
                        {
                            continue;
                        }

                        minXYZ = new XYZ();
                        maxXYZ = new XYZ();

                        IList <CurveLoop> profiles  = CreateProfiles(area);
                        Solid             extrusion = null;
                        if (profiles.Count > 0)
                        {
                            try
                            {
                                extrusion = GeometryCreationUtilities.CreateExtrusionGeometry(profiles, XYZ.BasisZ, 100);
                            }
                            catch { extrusion = null; return(false); }
                        }

                        if (null != extrusion && !areaDictionary.ContainsKey(area.Id.IntegerValue))
                        {
                            AreaProperties ap = new AreaProperties(area);
                            ap.SolidArea    = extrusion;
                            ap.BaseFace     = GetBottomFace(extrusion);
                            ap.MassIDs      = FindMass(ap);
                            ap.FAR          = CalculateFAR(ap);
                            ap.FARParameter = ap.FAR;
                            areaDictionary.Add(ap.AreaId, ap);
                        }
                    }
                }
                mapped = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to map between areas and mass object to write plot codes.\n" + ex.Message, "FARCalcuator:MapMassToArea", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(mapped);
        }