Exemplo n.º 1
0
        private void copyButton_Click(object sender, EventArgs e)
        {
            if (_Source == null)
            {
                return;
            }

            using (var factory = new ImageFactory(false))
            {
                byte[] buf;
                var    format       = MakeImageFormat();
                var    imageFactory = factory.Load(ResizeImage(_Source, factory)).Format(format);
                if (outputFormatPng8.Checked && checkBox2.Checked)
                {
                    var tempPathIn = Path.GetTempFileName() + ".png";
                    _ = imageFactory.Save(tempPathIn);
                    var tempPathOut = Path.GetTempFileName() + ".png";
                    File.Delete(tempPathOut);
                    using (var p = Process.Start(
                               new ProcessStartInfo(@"oxipng-v2.3.0-i686-pc-windows-msvc\oxipng.exe",
                                                    $"-o3 --out=\"{tempPathOut}\" \"{tempPathIn}\"")
                    {
                        RedirectStandardError = true,
                        RedirectStandardOutput = true,
                        UseShellExecute = false,
                        CreateNoWindow = true,
                    }))
                    {
                        p.WaitForExit();
                        Debug.Write(p.StandardOutput.ReadToEnd());
                        if (p.ExitCode != 0)
                        {
                            MessageBox.Show(this, p.StandardError.ReadToEnd(), "oxipng", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    buf = File.ReadAllBytes(tempPathOut);
                    File.Delete(tempPathIn);
                    File.Delete(tempPathOut);
                }
                else
                {
                    using (var stream = new MemoryStream())
                    {
                        _   = imageFactory.Save(stream);
                        buf = stream.GetBuffer();
                    }
                }

                var dataUri = (checkBox3.Checked ? "<img src=\"" : "") +
                              "data:" + format.MimeType + ";base64," + Convert.ToBase64String(buf, Base64FormattingOptions.None) +
                              (checkBox3.Checked ? "\">" : "");

                try
                {
                    Clipboard.Clear();
                    Clipboard.SetText(dataUri);

                    textBox1.Text = $"{dataUri.Length} characters copied.";
                }
                catch (ExternalException ex)
                {
                    MessageBox.Show(this, "Failed to set Clipboard.\n" + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 2
0
        private IntPtr LowLevelKeyboardHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0)
            {
                return(CallNextHookEx(m_hHook, nCode, wParam, lParam));
            }
            else
            {
                var           khs       = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
                KeysConverter Converter = new KeysConverter();
                Console.WriteLine("Hook: Code: {0}, WParam: {1},VirtualKK: {2}, ScaneCode: {3}, Charer: {4}", nCode, wParam, khs.VirtualKeyCode, khs.ScanCode, Converter.ConvertToString(khs.VirtualKeyCode));

                if (wParam.ToInt32() == 257 && khs.VirtualKeyCode == 187)
                {//Отжата клавиша "="
                    try
                    {
                        template.LastUsedTime = DateTime.Now;

                        //InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new System.Globalization.CultureInfo("ru-RU"));
                        raskladka();
                        string[] Data = Clipboard.GetText().Split(new string[] { template.Separator }, StringSplitOptions.None);
                        Clipboard.Clear();
                        SendKeys.SendWait("+{HOME}{BS}");
                        for (int counter = 0; counter < template.Rule.Count; counter++)
                        {
                            if (template.Rule[counter] != "")             //если у нас что то записано в правиле, то мы выполняем действия внутри
                            {
                                if (template.Rule[counter].Contains("_")) //проверяем есть ли у нас в правиле признаки постановки пробела
                                {
                                    string[] datatwo = template.Rule[counter].Split('_');
                                    for (int twocounter = 0; twocounter < datatwo.Length; twocounter++)
                                    {
                                        string element = datatwo[twocounter];
                                        Set_Data(Data, element, " ");
                                    }
                                }
                                else    //если у нас в элементе правила ничего нет то мы пытаемся что-то разобрать. Странно не правда ли?
                                if (!Set_Data(Data, template.Rule[counter], ""))
                                {
                                    break;
                                }
                            }

                            System.Threading.Thread.Sleep(100);
                            SendKeys.SendWait("{TAB}");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "\nОбратитесь к разработчикам.", "Ошибка");
                    }
                }
                else
                {
                    //if (!PressedVKC.Contains(khs.VirtualKeyCode) || (ConvertToInt(Converter.ConvertToString(khs.VirtualKeyCode)) != int.MinValue && wParam.ToInt32() == 260))

                    PressedVKC.Add(khs.VirtualKeyCode);
                }
                return(CallNextHookEx(m_hHook, nCode, wParam, lParam));
            }
        }
Exemplo n.º 3
0
        public static void CopyToClipboard(string htmlFragment, string textFragment, string title, Uri sourceUrl)
        {
            if (title == null)
            {
                title = "From Clipboard";
            }

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            // Builds the CF_HTML header. See format specification here:
            // http: //msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipboard/htmlclipboard.asp

            // The string contains index references to other spots in the string, so we need
            // placeholders so we can compute the offsets. The <<<<<<<_ strings are just
            // placeholders. We'll backpatch them actual values afterwards. The string layout (<<<)
            // also ensures that it can't appear in the body of the html because the < character must
            // be escaped.
            string header = @"Format:HTML Format
                                Version:1.0
                                StartHTML:<<<<<<<1
                                EndHTML:<<<<<<<2
                                StartFragment:<<<<<<<3
                                EndFragment:<<<<<<<4
                                StartSelection:<<<<<<<3
                                EndSelection:<<<<<<<3
                                ";

            string pre = @"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">
                            <HTML><HEAD><TITLE>" + title + @"</TITLE></HEAD><BODY><!--StartFragment-->";

            string post = @"<!--EndFragment--></BODY></HTML>";

            sb.Append(header);
            if (sourceUrl != null)
            {
                sb.AppendFormat("SourceURL:{0}", sourceUrl);
            }
            int startHTML = sb.Length;

            sb.Append(pre);
            int fragmentStart = sb.Length;

            sb.Append(htmlFragment);
            int fragmentEnd = sb.Length;

            sb.Append(post);
            int endHTML = sb.Length;

            // Backpatch offsets
            sb.Replace("<<<<<<<1", To8DigitString(startHTML));
            sb.Replace("<<<<<<<2", To8DigitString(endHTML));
            sb.Replace("<<<<<<<3", To8DigitString(fragmentStart));
            sb.Replace("<<<<<<<4", To8DigitString(fragmentEnd));

            // Finally copy to clipboard.
            string data = sb.ToString();

            Clipboard.Clear();

            DataObject dataObject = new DataObject();

            dataObject.SetData(DataFormats.Html, data);
            dataObject.SetData(DataFormats.Text, textFragment);
            dataObject.SetData(DataFormats.UnicodeText, textFragment);
            Clipboard.SetDataObject(dataObject);
            //Clipboard.SetText(data, TextDataFormat.Html);
        }
Exemplo n.º 4
0
 void Button7_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();
     Clipboard.SetText(label7.Text);
     Notification();
 }
Exemplo n.º 5
0
        public void findMathTypeEquations()
        {
            Word.Shapes objects = docOpen.Shapes;
            foreach (Word.Shape shape in objects)
            {
                Console.WriteLine(shape.TextFrame);
            }

            int OMathsCount = myRange.OMaths.Count;

            Console.WriteLine(OMathsCount);
            Console.WriteLine("Bar max:");

            form.progressBar1.Maximum = OMathsCount;


            try
            {
                String     clipboard_memory = Clipboard.GetText();
                Word.Range endRange         = docOpen.Range(myRange.End - 1, myRange.End - 1);



                if (OMathsCount > 0)
                {
                    string final_eq_file_path_clear = this.inputFileDir + @"\EquationsFile.txt";
                    File.WriteAllText(final_eq_file_path_clear, String.Empty);

                    string temp_file_path = this.inputFileDir + @"\EquationTemporaryFile.txt";
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(temp_file_path))

                    {
                        int  offset = 1;
                        bool empty_eq_fl;
                        bool break_for_fl = false;
                        for (int i = 0; i < OMathsCount && offset <= myRange.OMaths.Count; i++)
                        {
                            empty_eq_fl = true;
                            Thread staThread = new Thread(
                                delegate()
                            {
                                Word.OMath currentEquation = myRange.OMaths[offset];
                                while (empty_eq_fl)
                                {
                                    try
                                    {
                                        currentEquation.Range.Select();

                                        currentEquation.Range.TextRetrievalMode.IncludeHiddenText = true;
                                        currentEquation.Range.TextRetrievalMode.IncludeFieldCodes = true;

                                        currentEquation.Range.Application.Selection.Copy();
                                        empty_eq_fl = false;
                                    }
                                    catch (System.Runtime.InteropServices.COMException ex)
                                    {
                                        if (offset <= myRange.OMaths.Count - 1)
                                        {
                                            offset++;
                                            currentEquation = myRange.OMaths[offset];
                                        }
                                        else
                                        {
                                            break_for_fl = true;
                                            break;
                                        }
                                    }
                                }
                                if (!break_for_fl)
                                {
                                    //currentEquation.Range.Application.Selection.Range.HighlightColorIndex = Word.WdColorIndex.wdYellow;
                                    String tekst     = Clipboard.GetText();
                                    String new_tekst = "$";
                                    /////////////////////////////////////////////////////////////////////////////////////

                                    char[] tokens   = tekst.ToCharArray();
                                    string[] parsed = TranslateTokensToTex(tokens);
                                    for (int p = 0; p < parsed.Length; p++)
                                    {
                                        Console.Write(parsed[p] + "^.^");
                                    }
                                    Console.WriteLine("---------------------------------------------------");
                                    for (int p = 0; p < parsed.Length; p++)
                                    {
                                        parsed[p] = ParseToken(ref parsed, p);
                                    }
                                    for (int p = 0; p < parsed.Length; p++)
                                    {
                                        if (parsed[p] != @"")
                                        {
                                            new_tekst += parsed[p];
                                        }
                                    }
                                    new_tekst += "$";
                                    /////////////////////////////////////////////////////////////////////////////////////
                                    file.WriteLine(tekst);

                                    string final_eq_file_path = this.inputFileDir + @"\EquationsFile.txt";
                                    using (System.IO.StreamWriter file2 = File.AppendText(final_eq_file_path))
                                    {
                                        file2.WriteLine(new_tekst);
                                    }

                                    if (clipboard_memory.CompareTo("") != 0)
                                    {
                                        Clipboard.SetText(clipboard_memory);
                                    }
                                    else
                                    {
                                        Clipboard.Clear();
                                    }

                                    //removing text from start to end

                                    int start = currentEquation.Range.Start;
                                    int end   = currentEquation.Range.End;
                                    currentEquation.Range.Application.Selection.Delete();

                                    if (new_tekst != "$$")
                                    {
                                        currentEquation.Range.InsertBefore(new_tekst);
                                    }
                                }
                            });

                            staThread.SetApartmentState(ApartmentState.STA);
                            staThread.Start();
                            staThread.Join();
                            form.progressBar1.PerformStep();
                            if (break_for_fl)
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No equations found.");
                }

                if (form.checkBox2.Checked == false)
                {
                    docOpen.SaveAs(second_file_path);
                }
                else
                {
                    docOpen.SaveAs();
                }
                docOpen.Close();
                app.Quit();

                string final_message = "Process Completed\n\nFile \"EquationsFile.txt\" containing all converted equations and needed packages.\n";
                if (packages.Count != 0)
                {
                    final_message += "Additional packages required for further use:\n";
                    string final_eq_file_path = this.inputFileDir + @"\EquationsFile.txt";
                    using (System.IO.StreamWriter file2 = File.AppendText(final_eq_file_path))
                    {
                        file2.WriteLine("\n" + @"\usepackage{amsmath}");
                        foreach (string pack in packages)
                        {
                            final_message += pack;
                            final_message += "\n";
                            file2.WriteLine(pack);
                        }
                    }
                }
                MessageBox.Show(final_message);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 6
0
 private void narrativeText_KeyUp(object sender, KeyRoutedEventArgs e)
 {
     Clipboard.Clear();
 }
Exemplo n.º 7
0
        private void Paste_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            XElement root = LoadSerializedDataFromClipBoard();

            if (root == null)
            {
                return;
            }

            // create DesignerItems
            Dictionary <Guid, Guid> mappingOldToNewIDs = new Dictionary <Guid, Guid>();
            List <ISelectable>      newItems           = new List <ISelectable>();
            IEnumerable <XElement>  itemsXML           = root.Elements("DesignerItems").Elements("DesignerItem");

            double offsetX = Double.Parse(root.Attribute("OffsetX").Value, CultureInfo.InvariantCulture);
            double offsetY = Double.Parse(root.Attribute("OffsetY").Value, CultureInfo.InvariantCulture);

            foreach (XElement itemXML in itemsXML)
            {
                Guid oldID = new Guid(itemXML.Element("ID").Value);
                Guid newID = Guid.NewGuid();
                mappingOldToNewIDs.Add(oldID, newID);
                DesignerItem item = DeserializeDesignerItem(itemXML, newID, offsetX, offsetY);
                this.Children.Add(item);
                listDesignerItem.Add(item);
                SetConnectorDecoratorTemplate(item);
                newItems.Add(item);
            }

            // update group hierarchy
            SelectionService.ClearSelection();
            foreach (DesignerItem el in newItems)
            {
                if (el.ParentID != Guid.Empty)
                {
                    el.ParentID = mappingOldToNewIDs[el.ParentID];
                }
            }


            foreach (DesignerItem item in newItems)
            {
                if (item.ParentID == Guid.Empty)
                {
                    SelectionService.AddToSelection(item);
                }
            }

            // create Connections
            IEnumerable <XElement> connectionsXML = root.Elements("Connections").Elements("Connection");

            foreach (XElement connectionXML in connectionsXML)
            {
                Guid oldSourceID = new Guid(connectionXML.Element("SourceID").Value);
                Guid oldSinkID   = new Guid(connectionXML.Element("SinkID").Value);

                if (mappingOldToNewIDs.ContainsKey(oldSourceID) && mappingOldToNewIDs.ContainsKey(oldSinkID))
                {
                    Guid newSourceID = mappingOldToNewIDs[oldSourceID];
                    Guid newSinkID   = mappingOldToNewIDs[oldSinkID];

                    String sourceConnectorName = connectionXML.Element("SourceConnectorName").Value;
                    String sinkConnectorName   = connectionXML.Element("SinkConnectorName").Value;

                    Connector sourceConnector = GetConnector(newSourceID, sourceConnectorName);
                    Connector sinkConnector   = GetConnector(newSinkID, sinkConnectorName);

                    Connection connection = new Connection(sourceConnector, sinkConnector);
                    Canvas.SetZIndex(connection, Int32.Parse(connectionXML.Element("zIndex").Value));
                    this.Children.Add(connection);

                    SelectionService.AddToSelection(connection);
                }
            }

            DesignerCanvas.BringToFront.Execute(null, this);

            // update paste offset
            root.Attribute("OffsetX").Value = (offsetX + 10).ToString();
            root.Attribute("OffsetY").Value = (offsetY + 10).ToString();
            Clipboard.Clear();
            Clipboard.SetData(DataFormats.Xaml, root);
        }
 private void button19_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();
     Clipboard.SetDataObject(nasa + "T" + monstr + ".L3m_MO_RRS_Rrs_667_4km.nc\n");
 }
        private void button1_Click(object sender, EventArgs e)
        {
            download = "";
            year     = Convert.ToInt32(cb_year.Text);
            month    = Convert.ToInt32(cb_month.Text);

            #region monstr建立
            if (year % 4 == 0)
            {
                switch (month)
                {
                case 1:
                    monstr = year.ToString() + "001" + year.ToString() + "031";
                    break;

                case 2:
                    monstr = year.ToString() + "032" + year.ToString() + "060";
                    break;

                case 3:
                    monstr = year.ToString() + "061" + year.ToString() + "091";
                    break;

                case 4:
                    monstr = year.ToString() + "092" + year.ToString() + "121";
                    break;

                case 5:
                    monstr = year.ToString() + "122" + year.ToString() + "152";
                    break;

                case 6:
                    monstr = year.ToString() + "153" + year.ToString() + "182";
                    break;

                case 7:
                    monstr = year.ToString() + "183" + year.ToString() + "213";
                    break;

                case 8:
                    monstr = year.ToString() + "214" + year.ToString() + "244";
                    break;

                case 9:
                    monstr = year.ToString() + "245" + year.ToString() + "274";
                    break;

                case 10:
                    monstr = year.ToString() + "275" + year.ToString() + "305";
                    break;

                case 11:
                    monstr = year.ToString() + "306" + year.ToString() + "335";
                    break;

                case 12:
                    monstr = year.ToString() + "336" + year.ToString() + "366";
                    break;
                }
            }
            else
            {
                switch (month)
                {
                case 1:
                    monstr = year.ToString() + "001" + year.ToString() + "031";
                    break;

                case 2:
                    monstr = year.ToString() + "032" + year.ToString() + "059";
                    break;

                case 3:
                    monstr = year.ToString() + "060" + year.ToString() + "090";
                    break;

                case 4:
                    monstr = year.ToString() + "091" + year.ToString() + "120";
                    break;

                case 5:
                    monstr = year.ToString() + "121" + year.ToString() + "151";
                    break;

                case 6:
                    monstr = year.ToString() + "152" + year.ToString() + "181";
                    break;

                case 7:
                    monstr = year.ToString() + "182" + year.ToString() + "212";
                    break;

                case 8:
                    monstr = year.ToString() + "213" + year.ToString() + "243";
                    break;

                case 9:
                    monstr = year.ToString() + "244" + year.ToString() + "273";
                    break;

                case 10:
                    monstr = year.ToString() + "274" + year.ToString() + "304";
                    break;

                case 11:
                    monstr = year.ToString() + "305" + year.ToString() + "334";
                    break;

                case 12:
                    monstr = year.ToString() + "335" + year.ToString() + "365";
                    break;
                }
            }
            #endregion

            for (int i = 0; i < dataContent.Length; i++)
            {
                dataSite[i] = monstr + "." + dataContent[i];
            }

            for (int i = 0; i < dataContent.Length * 2; i++)
            {
                if (i < dataContent.Length)
                {
                    download = download + nasa + "T" + dataSite[i] + "\n";
                }
                else
                {
                    download = download + nasa + "A" + dataSite[i - dataContent.Length] + "\n";
                }
            }

            richTextBox1.Text = download;

            string codeStr = "";
            codeStr       = "./bnli.sh " + cb_year.Text + " " + cb_month.Text;
            textBox1.Text = codeStr;
            Clipboard.Clear();
            Clipboard.SetDataObject(codeStr + "\n");
            if (nud_month.Value == 12)
            {
                nud_year.Value++;
            }
            nud_month.Value++;
        }
 private void button12_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();
     Clipboard.SetDataObject(nasa + "T" + monstr + ".L3m_MO_SST4_sst4_4km.nc\n");
 }
 private void button13_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();
     Clipboard.SetDataObject(nasa + "T" + monstr + ".L3m_MO_CHL_chlor_a_4km.nc\n");
 }
 private void button6_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();
     Clipboard.SetDataObject(nasa + "A" + monstr + ".L3m_MO_PAR_par_4km.nc\n");
 }
 private void button3_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();                                      //清空剪切板内容
     Clipboard.SetData(DataFormats.Text, richTextBox1.Text); //复制内容到剪切板
     MessageBox.Show("下载地址复制成功!(*^__^*) 嘻嘻……", "信息提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Exemplo n.º 14
0
 private void CopyNameMethod()
 {
     Clipboard.Clear();
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     Clipboard.SetText(array.ToStringArray(true));
 }
Exemplo n.º 15
0
        private void btnExcel_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog sfd  = new SaveFileDialog();
                string         path = @"D:\StockAssistant\Document\InOutReport";
                Directory.CreateDirectory(path);
                sfd.InitialDirectory = path;
                sfd.Filter           = "Excel Documents (*.xls)|*.xls";
                sfd.FileName         = setFileName();

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    tool.historyRecord(text.Excel, text.getExcelString(sfd.FileName), DateTime.Now, MainDashboard.USER_ID);
                    // Copy DataGridView results to clipboard
                    copyAlltoClipboard();
                    Cursor = Cursors.WaitCursor; // change cursor to hourglass type
                    object misValue = System.Reflection.Missing.Value;
                    Microsoft.Office.Interop.Excel.Application xlexcel = new Microsoft.Office.Interop.Excel.Application();
                    xlexcel.PrintCommunication = false;
                    xlexcel.ScreenUpdating     = false;
                    xlexcel.DisplayAlerts      = false; // Without this you will get two confirm overwrite prompts
                    Workbook xlWorkBook = xlexcel.Workbooks.Add(misValue);

                    xlexcel.Calculation = XlCalculation.xlCalculationManual;
                    Worksheet xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);

                    if (string.IsNullOrEmpty(cmbType.Text))
                    {
                        if (!string.IsNullOrEmpty(cmbType.Text))
                        {
                            xlWorkSheet.Name = cmbType.Text;
                        }
                        else
                        {
                            xlWorkSheet.Name = "NAME NOT FOUND";
                        }
                    }
                    else
                    {
                        xlWorkSheet.Name = cmbType.Text;
                    }


                    #region Save data to Sheet

                    string title = cmbType.Text;

                    if (cbDaily.Checked)
                    {
                        title += "_Daily";
                    }
                    else
                    {
                        title += "_Total";
                    }

                    if (cbDO.Checked)
                    {
                        title += "_OutReport";
                    }
                    else
                    {
                        title += "_InOutReport";
                    }

                    xlWorkSheet.PageSetup.CenterHeader = "&\"Calibri,Bold\"&16 (" + dtpStart.Text + "-" + dtpEnd.Text + ")" + title;

                    //Header and Footer setup
                    xlWorkSheet.PageSetup.LeftHeader   = "&\"Calibri,Bold\"&11 " + DateTime.Now.Date.ToString("dd/MM/yyyy");;
                    xlWorkSheet.PageSetup.RightHeader  = "&\"Calibri,Bold\"&11 PG -&P";
                    xlWorkSheet.PageSetup.CenterFooter = "Printed By " + dalUser.getUsername(MainDashboard.USER_ID);

                    //Page setup
                    xlWorkSheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4;

                    if (cbDO.Checked)
                    {
                        xlWorkSheet.PageSetup.Orientation = XlPageOrientation.xlPortrait;
                    }
                    else
                    {
                        xlWorkSheet.PageSetup.Orientation = XlPageOrientation.xlLandscape;
                    }

                    xlWorkSheet.PageSetup.Zoom = false;
                    xlWorkSheet.PageSetup.CenterHorizontally = true;
                    xlWorkSheet.PageSetup.LeftMargin         = 1;
                    xlWorkSheet.PageSetup.RightMargin        = 1;
                    xlWorkSheet.PageSetup.FitToPagesWide     = 1;
                    xlWorkSheet.PageSetup.FitToPagesTall     = false;
                    xlWorkSheet.PageSetup.PrintTitleRows     = "$1:$1";

                    xlexcel.PrintCommunication = true;
                    xlexcel.Calculation        = XlCalculation.xlCalculationAutomatic;
                    // Paste clipboard results to worksheet range
                    xlWorkSheet.Select();
                    Range CR = (Range)xlWorkSheet.Cells[1, 1];
                    CR.Select();
                    xlWorkSheet.PasteSpecial(CR, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true);

                    //content edit
                    Range tRange = xlWorkSheet.UsedRange;
                    tRange.Borders.LineStyle = XlLineStyle.xlContinuous;
                    tRange.Borders.Weight    = XlBorderWeight.xlThin;
                    tRange.Font.Size         = 11;
                    tRange.Font.Name         = "Calibri";
                    tRange.EntireColumn.AutoFit();
                    tRange.EntireRow.AutoFit();
                    tRange.Rows[1].interior.color = Color.FromArgb(237, 237, 237);

                    #endregion

                    //Save the excel file under the captured location from the SaveFileDialog
                    xlWorkBook.SaveAs(sfd.FileName, XlFileFormat.xlWorkbookNormal,
                                      misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                    xlexcel.DisplayAlerts = true;

                    xlWorkBook.Close(true, misValue, misValue);
                    xlexcel.Quit();

                    releaseObject(xlWorkSheet);
                    releaseObject(xlWorkBook);
                    releaseObject(xlexcel);

                    // Clear Clipboard and DataGridView selection
                    Clipboard.Clear();
                    dgvInOutReport.ClearSelection();

                    // Open the newly saved excel file
                    if (File.Exists(sfd.FileName))
                    {
                        System.Diagnostics.Process.Start(sfd.FileName);
                    }
                }

                Cursor = Cursors.Arrow; // change cursor to normal type
            }
            catch (Exception ex)
            {
                tool.saveToTextAndMessageToUser(ex);
            }
        }
Exemplo n.º 16
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (lstTicket == null || lstTicket.Count == 0)
            {
                MessageBox.Show("Please search ticket order first", "Disneyland", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string tempPath = Application.StartupPath + $@"\TicketTemplate\{order.OrderId}";

            Word.Application wapp = new Word.Application();
            wapp.Visible = false;
            if (Directory.Exists(tempPath))
            {
                var files = Directory.GetFiles(tempPath);
                for (int i = 0; i < files.Length; i++)
                {
                    File.Delete(files[i]);
                }
                Directory.Delete(tempPath);
            }
            Directory.CreateDirectory(tempPath);

            lstTicket.ForEach(x =>
            {
                Word.Document ticketDoc = wapp.Documents.Open(Application.StartupPath + @"\ticketTemp.dotm");
                ticketDoc.Bookmarks["date"].Range.Text             = x.InvalidDate.ToString("yyyy-MMdd");
                ticketDoc.Bookmarks["dateType"].Range.Text         = x.TicketOffer.TicketName.Contains("年票") ? "有效" : "入園";
                ticketDoc.Bookmarks["name"].Range.Text             = x.GuestName;
                ticketDoc.Bookmarks["price"].Range.Text            = x.TicketOffer.Price.ToString();
                ticketDoc.Bookmarks["ticketId"].Range.Text         = x.TicketId;
                ticketDoc.Bookmarks["ticketType"].Range.Font.Color = x.TicketOffer.TicketName.Contains("年票") ? Word.WdColor.wdColorRed : Word.WdColor.wdColorBlue;
                ticketDoc.Bookmarks["ticketType"].Range.Text       = x.TicketOffer.TicketName.Contains("年票") ? "年票 Annual Pass" : "一日票 One Day Pass";
                ticketDoc.Bookmarks["type"].Range.Text             = x.TicketOffer.TicketName;

                Bitmap qrCode = QRCode.Generate(CreateCode(x), 100, 100);
                Clipboard.SetImage(qrCode);
                ticketDoc.Bookmarks["image"].Range.Paste();
                Clipboard.Clear();
                ticketDoc.SaveAs2(tempPath + $@"\{x.TicketId}.docx", Word.WdSaveFormat.wdFormatDocumentDefault);
                ticketDoc.Close(false);
            });

            var lstFile = Directory.GetFiles(tempPath);

            Word.Document mainDoc = new Word.Document();
            for (int i = 0; i < lstFile.Length; i++)
            {
                if (i % 5 == 0)
                {
                    mainDoc = wapp.Documents.Add();
                }

                Word.Paragraph paragraph = mainDoc.Paragraphs.Add();
                paragraph.Range.InsertFile(lstFile[i]);
                paragraph.Range.Delete();

                if (i == lstFile.Length - 1 || i % 5 == 4)
                {
                    //mainDoc.SaveAs2(tempPath + $@"\{(int)(i / 5) + 1}.pdf", Word.WdSaveFormat.wdFormatPDF);
                    mainDoc.PrintOut(false);
                    mainDoc.Close(false);
                }
            }


            wapp.Quit(false);
        }
Exemplo n.º 17
0
        private void AdjustmentTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            Clipboard.Clear();
            IAdjustmentViewModel viewModel    = DataContext as IAdjustmentViewModel;
            TextBox          txtInput         = sender as TextBox;
            NumberFormatInfo numberFormat     = NumberFormatInfo.CurrentInfo;
            string           decimalSeparator = numberFormat.CurrencyDecimalSeparator;
            string           groupSeparator   = numberFormat.CurrencyGroupSeparator;

            initialValue = txtInput.Text;

            if (!e.Key.isValidNumberKey() && e.Key != VirtualKey.Back &&
                !e.Key.ToString().Equals(Constants.KeyCode190) && !e.Key.ToString().Equals(Constants.KeyCode188))
            {
                e.Handled = true;
            }
            string strValue = initialValue.Replace(groupSeparator, "");

            string[] digit = initialValue.Split(decimalSeparator.ToCharArray());
            double   result;
            bool     isDouble = double.TryParse(strValue, out result);

            if (isDouble && strValue.Length >= 12 && !strValue.Contains(decimalSeparator) &&
                e.Key != VirtualKey.Decimal && !e.Key.ToString().Equals(Constants.KeyCode188) && !e.Key.ToString().Equals(Constants.KeyCode190))
            {
                AssignValue(initialValue);
                e.Handled = true;
            }
            else if ((isDouble && strValue.Contains(decimalSeparator) && (e.Key == VirtualKey.Decimal ||
                                                                          e.Key.ToString().Equals(Constants.KeyCode188) || e.Key.ToString().Equals(Constants.KeyCode190))) || strValue.Length >= 15)
            {
                AssignValue(initialValue);
                e.Handled = true;
                return;
            }
            else if (e.Key.ToString().Equals(Constants.KeyCode190) &&
                     groupSeparator.Equals(".") && !strValue.Contains("."))
            {
                AssignValue(initialValue);
                Focus(initialValue);
                e.Handled = true;
                return;
            }
            else if (e.Key.ToString() == Constants.KeyCode188 && groupSeparator.Equals(","))
            {
                AssignValue(initialValue);
                Focus(initialValue);
                e.Handled = true;
            }
            else if (!isDouble && (e.Key == VirtualKey.Back || e.Key.ToString().Equals(Constants.KeyCode188) ||
                                   e.Key.ToString().Equals(Constants.KeyCode190)))
            {
                AssignValue(initialValue);
                e.Handled = true;
            }
            else if ("0".Equals(initialValue) && (e.Key == VirtualKey.Number0 || e.Key == VirtualKey.NumberPad0))
            {
                AssignValue(initialValue);
                e.Handled = true;
            }
            else if (digit.Length == 2 && !string.IsNullOrWhiteSpace(digit[1]) && digit[1].Length == 2)
            {
                AssignValue(initialValue);
                e.Handled = true;
            }

            if (!String.IsNullOrWhiteSpace(txtInput.Text) && viewModel.AdjustmentType == AdjustmentType.Percentage)
            {
                try
                {
                    double val = Convert.ToDouble(txtInput.Text + GetNumber(e.Key));
                    e.Handled = val > 100;
                    if (e.Key == VirtualKey.Back || (!e.Key.isValidNumberKey() && !e.Key.ToString().Equals(Constants.KeyCode190) &&
                                                     !e.Key.ToString().Equals(Constants.KeyCode188)) || (digit.Length == 2 && digit[1] != null && digit[1].Length == 2))
                    {
                        e.Handled = true;
                    }
                }
                catch (Exception)
                {
                    AssignValue(string.Empty);
                    e.Handled = true;
                }
            }
        }
        private void export_Click(object sender, EventArgs e)
        {
            productsGV.MultiSelect = true;
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = "Excel Documents (*.xls)|*.xls";
            sfd.FileName = "Products_" + DateTime.Now.ToString().Replace('/', '_').Replace(':', '_') + ".xls";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                copyAlltoClipboard();

                object misValue = System.Reflection.Missing.Value;
                Microsoft.Office.Interop.Excel.Application xlexcel = new Microsoft.Office.Interop.Excel.Application();

                xlexcel.DisplayAlerts = false;
                Workbook  xlWorkBook  = xlexcel.Workbooks.Add(misValue);
                Worksheet xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);

                Range rng = xlWorkSheet.get_Range("D:D").Cells;
                rng.NumberFormat = "@";

                Range CR = (Range)xlWorkSheet.Cells[2, 1];
                CR.Select();

                xlWorkSheet.PasteSpecial(CR, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true);

                Range delRng = xlWorkSheet.get_Range("A:A").Cells;
                delRng.Delete(Type.Missing);
                xlWorkSheet.get_Range("A1").Select();
                xlWorkSheet.Cells[1, 1]  = "ID";
                xlWorkSheet.Cells[1, 2]  = "Name";
                xlWorkSheet.Cells[1, 3]  = "Description";
                xlWorkSheet.Cells[1, 4]  = "Category";
                xlWorkSheet.Cells[1, 5]  = "Supplier";
                xlWorkSheet.Cells[1, 6]  = "Store";
                xlWorkSheet.Cells[1, 7]  = "Buying Price";
                xlWorkSheet.Cells[1, 8]  = "Selling Price";
                xlWorkSheet.Cells[1, 9]  = "In Stock";
                xlWorkSheet.Cells[1, 10] = "Min Stock";


                xlWorkSheet.Columns.AutoFit();
                xlWorkBook.SaveAs(sfd.FileName, XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                xlexcel.DisplayAlerts = true;

                rng = xlWorkSheet.get_Range("K:K").Cells;
                rng.Delete();
                xlWorkBook.Close(true, misValue, misValue);
                xlexcel.Quit();

                releaseObject(xlWorkSheet);
                releaseObject(xlWorkBook);
                releaseObject(xlexcel);

                Clipboard.Clear();
                productsGV.ClearSelection();



                if (File.Exists(sfd.FileName))
                {
                    System.Diagnostics.Process.Start(sfd.FileName);
                }
            }
            productsGV.MultiSelect = false;
        }
Exemplo n.º 19
0
        public static async Task Export(Deck deck)
        {
            if (deck == null)
            {
                return;
            }
            var currentClipboard = "";
            var altScreenCapture = Config.Instance.AlternativeScreenCapture;

            try
            {
                Logger.WriteLine("Exporting " + deck.GetDeckInfo(), "DeckExporter");
                if (Config.Instance.ExportPasteClipboard && Clipboard.ContainsText())
                {
                    currentClipboard = Clipboard.GetText();
                }

                var info = new ExportingInfo();
                LogDebugInfo(info);

                var inForeground = await ExportingHelper.EnsureHearthstoneInForeground(info.HsHandle);

                if (!inForeground)
                {
                    return;
                }
                Logger.WriteLine($"Waiting for {Config.Instance.ExportStartDelay} seconds before starting the export process", "DeckExporter");
                await Task.Delay(Config.Instance.ExportStartDelay * 1000);

                if (!altScreenCapture)
                {
                    Core.Overlay.ForceHide(true);
                }

                await ClearDeck(info);
                await SetDeckName(deck, info);
                await ClearFilters(info);

                var lostFocus = await CreateDeck(deck, info);

                if (lostFocus)
                {
                    return;
                }
                await ClearSearchBox(info.HsHandle, info.SearchBoxPos);

                if (Config.Instance.ExportPasteClipboard)
                {
                    Clipboard.Clear();
                }
                Logger.WriteLine("Success exporting deck.", "DeckExporter");
            }
            catch (Exception e)
            {
                Logger.WriteLine("Error exporting deck: " + e, "DeckExporter");
            }
            finally
            {
                if (!altScreenCapture)
                {
                    Core.Overlay.ForceHide(false);
                }
                if (Config.Instance.ExportPasteClipboard && currentClipboard != "")
                {
                    Clipboard.SetText(currentClipboard);
                }
            }
        }
 private void copyBackToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();
     Clipboard.SetText("Back");
     notifyIcon1.ShowBalloonTip(1);
 }
Exemplo n.º 21
0
 private void copyInfoButton_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();
     Clipboard.SetText(richTextBox1.Text);
 }
Exemplo n.º 22
0
 private void MailTBox_Click(object sender, EventArgs e)
 {
     Clipboard.Clear( );
     Clipboard.SetText("*****@*****.**");
 }
Exemplo n.º 23
0
 private void Button1_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();
     Clipboard.SetText(label2.Text + "\n" + label3.Text + "\n" + label4.Text + "\n" + label5.Text + "\n" + label6.Text + "\n" + label7.Text);
     Notification();
 }
Exemplo n.º 24
0
 private void TelephoneTBox_Click(object sender, EventArgs e)
 {
     Clipboard.Clear( );
     Clipboard.SetText("(095)3428673");
 }
Exemplo n.º 25
0
        public static void ClearPrimary()
        {
            Clipboard clipboard = Clipboard.Get(CopyOperation.PRIMARYCLIPBOARD_ATOM);

            clipboard.Clear();
        }
Exemplo n.º 26
0
 private void copyAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Clipboard.Clear();
     Clipboard.SetText(textBox1.Text);
 }
Exemplo n.º 27
0
 public HtmlFragment()
 {
     htmlClipBuilder = new StringBuilder();
     textClipBuilder = new StringBuilder();
     Clipboard.Clear();
 }
Exemplo n.º 28
0
        PasteResult IClipboardItem.Paste(IDocument document)
        {
            IDiagram diagram = (IDiagram)document;

            if (diagram == null)
            {
                return(null);
            }
            bool success = false;

            currentOffset += BaseOffset;
            //Size offset = new Size(
            //    (int)((diagram.Offset.X + currentOffset) / diagram.Zoom),
            //    (int)((diagram.Offset.Y + currentOffset) / diagram.Zoom));

            foreach (Shape shape in shapes)
            {
                Shape pasted = shape.Paste(diagram, new Size(currentOffset, currentOffset));
                pastedShapes[shape] = pasted;
                success            |= (pasted != null);
            }
            foreach (var shape in shapes)
            {
                if (shape.ParentShape == null)
                {
                    continue;
                }

                if (!pastedShapes.ContainsKey(shape.ParentShape) ||
                    !pastedShapes.ContainsKey(shape))
                {
                    continue;
                }

                var parentShape = (ShapeContainer)pastedShapes[shape.ParentShape];
                var childShape  = pastedShapes[shape];
                parentShape.AttachShapes(new List <Shape> {
                    childShape
                });
            }
            foreach (var connection in connections)
            {
                Shape first  = GetShape(connection.Relationship.First);
                Shape second = GetShape(connection.Relationship.Second);

                if (first != null && pastedShapes[first] != null &&
                    second != null && pastedShapes[second] != null)
                {
                    var pasted = connection.Paste(
                        diagram, new Size(currentOffset, currentOffset), pastedShapes[first], pastedShapes[second]);
                    pastedConnections[connection] = pasted;
                    success |= (pasted != null);
                }
            }

            if (success)
            {
                Clipboard.Clear();
            }

            return(new PasteResult(pastedConnections, pastedShapes));
        }
Exemplo n.º 29
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            string FileName = @"C:\temp\temp.xls";

            // Copy DataGridView results to clipboard
            dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
            dataGridView1.SelectAll();

            DataObject dataObj = dataGridView1.GetClipboardContent();

            if (dataObj != null)
            {
                Clipboard.SetDataObject(dataObj);
            }

            object misValue = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Excel.Application xlexcel = new Microsoft.Office.Interop.Excel.Application();

            xlexcel.DisplayAlerts = false; // Without this you will get two confirm overwrite prompts
            Microsoft.Office.Interop.Excel.Workbook  xlWorkBook  = xlexcel.Workbooks.Add(misValue);
            Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            // Format column D as text before pasting results, this was required for my data
            //Microsoft.Office.Interop.Excel.Range rng = xlWorkSheet.get_Range("D:D").Cells;
            //rng.NumberFormat = "@";

            // Paste clipboard results to worksheet range
            Microsoft.Office.Interop.Excel.Range CR = (Microsoft.Office.Interop.Excel.Range)xlWorkSheet.Cells[1, 1];
            CR.Select();
            xlWorkSheet.PasteSpecial(CR, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true);

            // For some reason column A is always blank in the worksheet. ¯\_(ツ)_/¯
            // Delete blank column A and select cell A1
            //Microsoft.Office.Interop.Excel.Range delRng = xlWorkSheet.get_Range("A:A").Cells;
            //delRng.Delete(Type.Missing);
            xlWorkSheet.get_Range("A1").Select();

            Microsoft.Office.Interop.Excel.Worksheet ws    = xlexcel.ActiveWorkbook.Worksheets[1];
            Microsoft.Office.Interop.Excel.Range     range = ws.UsedRange;
            //ws.Columns.ClearFormats();
            //ws.Rows.ClearFormats();
            //range.EntireColumn.AutoFit();
            //range.EntireRow.AutoFit();
            xlWorkSheet.Range["A1:D1"].Interior.Color = System.Drawing.Color.LightSkyBlue;
            ws.Columns.AutoFit();
            ws.Rows.AutoFit();
            range.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
            range.Borders.Color     = ColorTranslator.ToOle(Color.Black);

            // Save the excel file under the captured location from the SaveFileDialog
            xlWorkBook.SaveAs(FileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            xlexcel.DisplayAlerts = true;
            xlWorkBook.Close(true, misValue, misValue);
            xlexcel.Quit();

            //releaseObject(xlWorkSheet);
            //releaseObject(xlWorkBook);
            //releaseObject(xlexcel);

            // Clear Clipboard and DataGridView selection
            Clipboard.Clear();
            dataGridView1.ClearSelection();

            // Open the newly saved excel file
            if (File.Exists(FileName))
            {
                System.Diagnostics.Process.Start(FileName);
            }

            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbooks   workbooks;
            Microsoft.Office.Interop.Excel.Workbook    excelBook;

            //app = null;
            //app = new Excel.Application(); // create a new instance
            excelApp.DisplayAlerts = false; //turn off annoying alerts that make me want to cryyyy
            uint processID = 0;

            workbooks = excelApp.Workbooks;
            excelBook = workbooks.Add(FileName);
            Microsoft.Office.Interop.Excel.Sheets    sheets     = excelBook.Worksheets;
            Microsoft.Office.Interop.Excel.Worksheet excelSheet = (Microsoft.Office.Interop.Excel.Worksheet)(sheets[1]);

            //Range.Rows.AutoFit();
            //Range.Columns.AutoFit();
        }
Exemplo n.º 30
0
        private void CopyToUCI()
        {
            StringBuilder sbf = new StringBuilder();
            string        txt = "";
            //write the name of the calculator to the string buffer
            //xyang  sbf.append(" *** " + this.calculatorType + " ***\n");

            ArrayList labels = new ArrayList();

            if (Calc.CurrentType == FTableCalculator.ChannelType.TRAPEZOIDAL) //"TRAPEZOIDAL")
            {
                string sChTypeName = "*** Channel Type: Trapezoidal";
                txt = ((FTableCalcTrape)Calc).inpChannelMaxDepth.ToString();
                string sChDepth = "*** Channel Depth: " + txt;
                txt = ((FTableCalcTrape)Calc).inpChannelTopWidth.ToString();
                string sChWidth = "*** Channel Width: " + txt;
                txt = ((FTableCalcTrape)Calc).inpChannelSideSlope.ToString();
                string sChSideSlope = "*** Channel Side Slope: " + txt;
                txt = ((FTableCalcTrape)Calc).inpChannelLength.ToString();
                string sChLength = "*** Channel Length: " + txt;

                ///*txt = plotdata.trapPanel.lblChannelMannigsValue.getText();
                //sbf.Append(" *** " + txt + "      ");
                //outvalue = plotdata.value[4];
                //sbf.Append(outvalue + "***\n");*/

                ///* txt = plotdata.trapPanel.lblChannelAvgSlope.getText();
                // sbf.Append(" *** " + txt + "      ");
                //outvalue = plotdata.value[5];
                // sbf.Append(outvalue + "***\n");*/

                txt = ((FTableCalcTrape)Calc).inpHeightIncrement.ToString();
                string sChHInc = "*** Height Increment: " + txt;
                labels.Add(sChTypeName);  labels.Add(sChLength); labels.Add(sChWidth); labels.Add(sChDepth); labels.Add(sChSideSlope); labels.Add(sChHInc);
            }
            else if (Calc.CurrentType == FTableCalculator.ChannelType.PARABOLIC) //this.calculatorType == "PARABOLIC")
            {
                string sChTypeName = "*** Channel Type: Parabolic";
                txt = ((FTableCalcEllipse)Calc).inpChannelLength.ToString();
                string sChLength = "*** Channel Length: " + txt;
                txt = ((FTableCalcEllipse)Calc).inpChannelWidth.ToString();
                string sChWidth = "*** Channel Width: " + txt;
                txt = ((FTableCalcEllipse)Calc).inpChannelDepth.ToString();
                string sChDepth = "*** Channel Depth: " + txt;
                txt = ((FTableCalcEllipse)Calc).inpChannelSlope.ToString();
                string sChSlope = "*** Channel Slope: " + txt;
                txt = ((FTableCalcEllipse)Calc).inpHeightIncrement.ToString();
                string sChHInc = "*** Height Increment: " + txt;

                /*txt = plotdata.parabolicPanel.lblChannelMannigsValue.getText();
                 * //sbf.Append(" *** " + txt + "      ");
                 * //outvalue = plotdata.value[3];
                 * //sbf.Append(outvalue + "***\n"); */
                labels.Add(sChTypeName); labels.Add(sChLength); labels.Add(sChWidth); labels.Add(sChDepth); labels.Add(sChSlope); labels.Add(sChHInc);
            }
            else if (Calc.CurrentType == FTableCalculator.ChannelType.CIRCULAR) //this.calculatorType == "CIRCULAR")
            {
                string sChTypeName = "*** Channel Type: Circular";
                txt = ((FTableCalcCircle)Calc).inpChannelLength.ToString();   //plotdata.circPanel.lblChannelLength.getText();//xyang
                string sChLength = "*** Channel Length: " + txt;
                txt = ((FTableCalcCircle)Calc).inpChannelDiameter.ToString(); //plotdata.circPanel.lblChannelDiameter.getText();//xyang
                string sChDiam = "*** Channel Diameter: " + txt;

                /*txt = plotdata.circPanel.lblChannelMannigsValue.getText();//xyang
                 * sbf.Append(" *** " + txt + "      ");
                 * outvalue = plotdata.value[2];
                 * sbf.Append(outvalue + "***\n");*/
                //txt = ((FTableCalcCircle)Calc).ChannelManningsValue.ToString();
                //string sManningsN = "*** Channel Manning's N: " + txt;

                txt = ((FTableCalcCircle)Calc).inpChannelSlope.ToString();    //plotdata.circPanel.lblChannelAvgSlope.getText();//xyang
                string sChSlope = "*** Average Channel Slope: " + txt;
                txt = ((FTableCalcCircle)Calc).inpHeightIncrement.ToString(); //plotdata.circPanel.lblIncrement.getText();//xyang
                string sChHInc = "*** Height Increment: " + txt;

                labels.Add(sChTypeName); labels.Add(sChLength); labels.Add(sChDiam); labels.Add(sChSlope); labels.Add(sChHInc);
            }
            else if (Calc.CurrentType == FTableCalculator.ChannelType.RECTANGULAR)  //this.calculatorType == "RECTANGULAR")
            {
                string sChTypeName = "*** Channel Type: Rectangular";
                txt = ((FTableCalcRectangular)Calc).inpChannelLength.ToString();
                string sChLength = "*** Channel Length: " + txt;
                txt = ((FTableCalcRectangular)Calc).inpChannelTopWidth.ToString();
                string sChWidth = "*** Channel Width: " + txt;
                txt = ((FTableCalcRectangular)Calc).inpChannelMaxDepth.ToString();
                string sChDepth = "*** Channel Depth: " + txt;
                txt = ((FTableCalcRectangular)Calc).inpChannelSlope.ToString();
                string sChSlope = "*** Channel Slope: " + txt;
                txt = ((FTableCalcRectangular)Calc).inpHeightIncrement.ToString();
                string sChHInc = "*** Height Increment: " + txt;

                /*txt = plotdata.parabolicPanel.lblChannelMannigsValue.getText();
                 * //sbf.Append(" *** " + txt + "      ");
                 * //outvalue = plotdata.value[3];
                 * //sbf.Append(outvalue + "***\n"); */

                labels.Add(sChTypeName); labels.Add(sChLength); labels.Add(sChWidth); labels.Add(sChDepth); labels.Add(sChSlope); labels.Add(sChHInc);
            }
            else if (Calc.CurrentType == FTableCalculator.ChannelType.TRIANGULAR) //this.calculatorType == "TRIANGULAR")
            {
                string sChTypeName = "*** Channel Type: Triangular";
                txt = ((FTableCalcTri)Calc).inpChannelLength.ToString();
                string sChLength = "*** Channel Length: " + txt;
                txt = ((FTableCalcTri)Calc).inpChannelTopWidth.ToString();
                string sChWidth = "*** Channel Width: " + txt;
                txt = ((FTableCalcTri)Calc).inpChannelMaxDepth.ToString();
                string sChDepth = "*** Channel Depth: " + txt;
                txt = ((FTableCalcTri)Calc).inpChannelSlope.ToString();
                string sChSlope = "*** Channel Slope: " + txt;
                txt = ((FTableCalcTri)Calc).inpHeightIncrement.ToString();
                string sChHInc = "*** Height Increment: " + txt;

                /*txt = plotdata.parabolicPanel.lblChannelMannigsValue.getText();
                 * //sbf.Append(" *** " + txt + "      ");
                 * //outvalue = plotdata.value[3];
                 * //sbf.Append(outvalue + "***\n"); */
                labels.Add(sChTypeName); labels.Add(sChLength); labels.Add(sChWidth); labels.Add(sChDepth); labels.Add(sChSlope); labels.Add(sChHInc);
            }
            else if (Calc.CurrentType == FTableCalculator.ChannelType.NATURAL)
            {
                string sChTypeName = "*** Channel Type: Natural";
                txt = ((FTableCalcNatural)Calc).inpChannelLength.ToString();
                string sChLength = "*** Channel Length: " + txt;
                txt = ((FTableCalcNatural)Calc).inpChannelSlope.ToString();
                string sChSlope = "*** Channel Slope: " + txt;
                txt = ((FTableCalcNatural)Calc).inpHeightIncrement.ToString();
                string sChHInc = "*** Height Increment: " + txt;

                labels.Add(sChTypeName); labels.Add(sChLength); labels.Add(sChSlope); labels.Add(sChHInc);
            }
            else if (Calc.CurrentType == FTableCalculator.ChannelType.NATURALFP)
            {
                string sChTypeName = "*** Channel Type: Natural w/ FP";
                txt = ((FTableCalcNaturalFP)Calc).inpChannelLength.ToString();
                string sChLength = "*** Channel Length: " + txt;
                txt = ((FTableCalcNaturalFP)Calc).inpChannelSlope.ToString();
                string sChSlope = "*** Channel Slope: " + txt;
                txt = ((FTableCalcNaturalFP)Calc).inpHeightIncrement.ToString();
                string sChHInc = "*** Height Increment: " + txt;

                labels.Add(sChTypeName); labels.Add(sChLength); labels.Add(sChSlope); labels.Add(sChHInc);
            }

            SortedList <int, object> lblLens = new SortedList <int, object>();
            int strLen = 0;

            foreach (string lstr in labels)
            {
                strLen = lstr.Length;
                if (!lblLens.Keys.Contains(strLen))
                {
                    lblLens.Add(strLen, null);
                }
            }
            int maxLblLength = lblLens.Keys[lblLens.Count - 1];

            foreach (string lstr in labels)
            {
                sbf.AppendLine(lstr.PadRight(maxLblLength) + " ***");
            }

            sbf.AppendLine("  FTABLE    999");
            //sbf.Append("  999's are placeholders for user provided ID 1-3 digits in length***");
            //sbf.Append("\n");

            sbf.AppendLine(" rows cols                               ***");
            //the following section requires me to do a calculation to correctly right justify the rows and cols figures.

            int    ftableFieldWidth = 10;
            string ftableNumFormat  = "{0:0.00}";
            int    numrows          = FTableSource.Rows;
            int    numcols          = FTableSource.Columns;

            //determine if need to use extended FTable width 15
            double lsmallestVal = double.MaxValue;

            for (int i = 0; i < numrows; i++)
            {
                if (i == 0)
                {
                    continue;
                }
                for (int j = 0; j < numcols; j++)
                {
                    double newValue = 0;
                    if (double.TryParse(FTableSource.get_CellValue(i, j).ToString(), out newValue))
                    {
                        if (!double.IsNaN(newValue))
                        {
                            if (newValue > 0 && lsmallestVal > newValue)
                            {
                                lsmallestVal = newValue;
                            }
                        }
                    }
                }
            }
            txt = string.Format(ftableNumFormat, (object)lsmallestVal);
            double lsmallValTest = double.Parse(txt);

            if (chkExtendedFormat.Checked) //lsmallValTest - 0 < 0.000001
            {
                ftableFieldWidth = 15;
                ftableNumFormat  = "{0:0.000000}";
            }
            string lzeroStr = ftableNumFormat.Substring(ftableNumFormat.IndexOf(":") + 1).TrimEnd(new char[] { '}' });

            sbf.AppendLine(numrows.ToString().PadLeft(5) + numcols.ToString().PadLeft(5));
            for (int i = 0; i < numcols; i++)
            {
                string colName = FTableSource.get_CellValue(0, i);
                if (colName.IndexOf("(") >= 0)
                {
                    colName = colName.Substring(0, colName.IndexOf("(")).Trim();
                }
                sbf.Append(colName.PadLeft(ftableFieldWidth));
            }
            sbf.AppendLine(" ***");
            for (int i = 0; i < numrows; i++)
            {
                //ToDo: later see if need to only do selected cells
                if (i == 0)
                {
                    continue;
                }
                for (int j = 0; j < numcols; j++)
                {
                    //jTable1.getValueAt(rowsselected[i],colsselected[j]);
                    double newValue = 0;
                    if (double.TryParse(FTableSource.get_CellValue(i, j).ToString(), out newValue))
                    {
                        if (!double.IsNaN(newValue))
                        {
                            if (newValue > 0 && newValue < 0.000001)
                            {
                                txt = String.Format(System.Globalization.CultureInfo.InvariantCulture, clsGlobals.NumberFormatSci, newValue);
                            }
                            else
                            {
                                txt = String.Format(ftableNumFormat, (object)newValue);
                            }
                        }
                        else
                        {
                            txt = lzeroStr;
                        }
                    }
                    else
                    {
                        txt = lzeroStr;
                    }

                    //txt = FTableSource.get_CellValue(i, j).ToString();
                    sbf.Append(txt.PadLeft(ftableFieldWidth));
                    //if (j<numcols-1) sbf.Append("\t");
                }
                sbf.AppendLine("");
            }
            sbf.AppendLine("  END FTABLE999");

            Clipboard.Clear();
            Clipboard.SetText(sbf.ToString(), TextDataFormat.Text);
            if (clsGlobals.pFTable == null)
            {
                System.Windows.Forms.MessageBox.Show("FTable contents are ready to be pasted into a UCI", "Copy To UCI");
            }
            else
            {
                clsGlobals.pFTable.Ncols = numcols;
                clsGlobals.pFTable.Nrows = numrows - 1;

                if (ftableFieldWidth == 15)
                {
                    clsGlobals.pFTable.ExtendedFlag = true;
                }
                else
                {
                    clsGlobals.pFTable.ExtendedFlag = false;
                }

                clsGlobals.pFTable.Comment = "";
                for (int j = 0; j < numcols; j++)
                {
                    string s = FTableSource.get_CellValue(0, j).ToString();
                    clsGlobals.pFTable.Comment = clsGlobals.pFTable.Comment + s.PadLeft(ftableFieldWidth);
                }
                clsGlobals.pFTable.Comment = clsGlobals.pFTable.Comment + " ***";

                for (int i = 0; i < numrows; i++)
                {
                    if (i == 0)
                    {
                        continue;
                    }
                    for (int j = 0; j < numcols; j++)
                    {
                        double newValue = 0.00;
                        double.TryParse(FTableSource.get_CellValue(i, j).ToString(), out newValue);
                        if (double.IsNaN(newValue))
                        {
                            newValue = 0.00;
                        }

                        if (j == 0)
                        {
                            clsGlobals.pFTable.set_Depth(i, newValue);
                        }
                        if (j == 1)
                        {
                            clsGlobals.pFTable.set_Area(i, newValue);
                        }
                        if (j == 2)
                        {
                            clsGlobals.pFTable.set_Volume(i, newValue);
                        }
                        if (j == 3)
                        {
                            clsGlobals.pFTable.set_Outflow1(i, newValue);
                        }
                        if (j == 4)
                        {
                            clsGlobals.pFTable.set_Outflow2(i, newValue);
                        }
                        if (j == 5)
                        {
                            clsGlobals.pFTable.set_Outflow3(i, newValue);
                        }
                        if (j == 6)
                        {
                            clsGlobals.pFTable.set_Outflow4(i, newValue);
                        }
                        if (j == 7)
                        {
                            clsGlobals.pFTable.set_Outflow5(i, newValue);
                        }
                    }
                }

                System.Windows.Forms.MessageBox.Show("FTable contents have been copied to the UCI", "Copy To UCI");
            }
        }