Пример #1
0
        public void DoActivities()
        {
            Init();
            try
            {
#if !DEBUG
                if (string.IsNullOrEmpty(Password))
                {
                    GetCredentials();
                }

                Password = new System.Net.NetworkCredential(string.Empty,
                                                            (SecureString)CurrentConfig["Password"]).Password;
#else
                CurrentConfig["User"] = "******";
                Password = "******";
#endif
                if (Methods.OpenWS(EmulatorURL, SessionId, CurrentConfig["User"].ToString(), Password, out int Id) == true)
                {
                    Base();
                }
                else
                {
                }

                Console.WriteLine("Fin");
                FlashWindow.FlashWindowEx(Process.GetCurrentProcess().MainWindowHandle);
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Methods.LogProceso("ERROR_2: " + ex.Message);
            }
        }
Пример #2
0
        public void Drag_Enter(DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop) ||
                e.Data.GetDataPresent("HTML Format") ||
                e.Data.GetDataPresent(DataFormats.Text) ||
                e.Data.GetDataPresent("UniformResourceLocator")
                )
            {
                e.Effect = DragDropEffects.Copy;

                try
                {
                    Point      _p = Cursor.Position;
                    Win32Point _wp;
                    _wp.x = _p.X;
                    _wp.y = _p.Y;
                    IDropTargetHelper _dropHelper = (IDropTargetHelper) new DragDropHelper();
                    _dropHelper.DragEnter(IntPtr.Zero, (System.Runtime.InteropServices.ComTypes.IDataObject)e.Data, ref _wp, (int)e.Effect);
                }
                catch
                {
                }
            }
            else
            {
                e.Effect = DragDropEffects.None; // Unknown data, ignore it
            }

            FlashWindow.Start(Main.Current);
        }
Пример #3
0
        public void IncomingMessage(Message msg, string person, DateTime date)
        {
            FlashWindow.Flash(this.MdiParent, 1);

            if (msg.Delay != null)
            {
                string   datetime = msg.Delay.GetAttribute("stamp");
                DateTime dt       = new DateTime();
                DateTime.TryParse(datetime, out dt);
                if (dtTemp == null || dtTemp.CompareTo(DateTime.MinValue) == 0)
                {
                    dtTemp = dt;
                    rtfChat.SelectionColor     = Color.Black;
                    rtfChat.SelectionAlignment = HorizontalAlignment.Center;
                    rtfChat.SelectionFont      = new System.Drawing.Font(rtfChat.Font, FontStyle.Bold);
                    rtfChat.AppendText(dt.ToLongDateString().ToString());
                    rtfChat.AppendText("\r\n");
                }
                else
                {
                    if (dtTemp.Date.CompareTo(dt.Date) != 0)
                    {
                        dtTemp = dt;
                        rtfChat.SelectionColor     = Color.Black;
                        rtfChat.SelectionAlignment = HorizontalAlignment.Center;
                        rtfChat.SelectionFont      = new System.Drawing.Font(rtfChat.Font, FontStyle.Bold);
                        rtfChat.AppendText(dt.ToLongDateString().ToString());
                        rtfChat.AppendText("\r\n");
                    }
                }
            }
            else if (dtTemp == null || dtTemp.CompareTo(DateTime.MinValue) == 0)
            {
                dtTemp = DateTime.Now;
                rtfChat.SelectionColor     = Color.Black;
                rtfChat.SelectionAlignment = HorizontalAlignment.Center;
                rtfChat.SelectionFont      = new System.Drawing.Font(rtfChat.Font, FontStyle.Bold);
                rtfChat.AppendText(dtTemp.ToLongDateString().ToString());
                rtfChat.AppendText("\r\n");
            }
            else if (dtTemp.Date.CompareTo(date.Date) < 0)
            {
                dtTemp = date;
                rtfChat.SelectionColor     = Color.Black;
                rtfChat.SelectionAlignment = HorizontalAlignment.Center;
                rtfChat.SelectionFont      = new System.Drawing.Font(rtfChat.Font, FontStyle.Bold);
                rtfChat.AppendText(dtTemp.ToLongDateString().ToString());
                rtfChat.AppendText("\r\n");
            }

            rtfChat.SelectionAlignment = HorizontalAlignment.Left;
            rtfChat.SelectionFont      = new System.Drawing.Font(rtfChat.Font, FontStyle.Regular);
            rtfChat.SelectionColor     = Color.Red;
            rtfChat.AppendText(_nickname + " said: ");
            rtfChat.SelectionColor = Color.Black;
            rtfChat.AppendText(msg.Body);
            rtfChat.AppendText("\r\n");

            SaveHistory(person, msg.Body, date, _nickname);
        }
Пример #4
0
 /// <summary>
 /// Điều khiển nháy icon
 /// </summary>
 void Flash()
 {
     if (!_focus)
     {
         FlashWindow.Start(this);
     }
 }
Пример #5
0
        private void notifyIcon1_Click(object sender, EventArgs e)
        {
            Console.Out.WriteLine("system trey icon clicked");

            if (notifyIcon1.Icon.Size == Properties.Resources.icons8_survey_48_notif.Size)
            {
                /*
                 * if (Form1.staticMcq != null) {
                 *  Console.Out.WriteLine("staticMcq is being used");
                 *  notifyIcon1.Icon = Properties.Resources.icons8_survey_48;
                 *  Form1.staticMcq.Show();
                 * } else if (Form1.staticSubjective != null) {
                 *  Console.Out.WriteLine("staticSubjective is being used");
                 *  notifyIcon1.Icon = Properties.Resources.icons8_survey_48;
                 *  Form1.staticSubjective.Show();
                 * }
                 */
                Console.Out.WriteLine("staticQuestionView is being used");
                Form1.notifyIcon1.Icon = Properties.Resources.icons8_survey_48;
                Form1.staticQuestionView.Show();

                staticDummy.WindowState = FormWindowState.Minimized;
                FlashWindow.Stop(staticDummy);
                staticDummy.Hide();
            }
        }
Пример #6
0
 private void UpdatesAvailable(object sender, EventArgs eventArgs)
 {
     UI.SetVisible(UpdatePB);
     UI.SetVisible(UpdatesLabel);
     FlashWindow.Flash(this, 10);
     UI.SetLabelText(CheckUpdatesText, "Ściągnij nowe pliki i uruchom grę");
 }
Пример #7
0
        private void frmServer_Activated(object sender, EventArgs e)
        {
            //BackColor = Color.ForestGreen;
            txtMessage.Focus();

            _focus = true;
            FlashWindow.Stop(this);
        }
Пример #8
0
        public void Drag_Leave()
        {
            FlashWindow.Stop(Main.Current);

            IDropTargetHelper _dropHelper = (IDropTargetHelper) new DragDropHelper();

            _dropHelper.DragLeave();
        }
Пример #9
0
 private void AddLineHandler(ChatWindow cw, string user, string message)
 {
     cw.AddLine(user, message);
     if (!cw.Focused)
     {
         FlashWindow.Flash(cw);
     }
 }
Пример #10
0
        private void frmClient_Activated(object sender, EventArgs e)
        {
            BackColor = Color.DarkOrange;
            txtMessage.Focus();

            _focus = true;
            FlashWindow.Stop(this);
        }
Пример #11
0
        public void ShowChatHandler(string user, string message)
        {
            ChatWindow temp = new ChatWindow(user, message);

            Chats.Add(temp);
            temp.Show();
            FlashWindow.Flash(temp);
        }
Пример #12
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            messagePanel.Height = new GridLength(SettingsProvider.Current.Settings.GeneralSettings.MessagePanelHeight, GridUnitType.Pixel);
            flash = new FlashWindow(this);

            OnParticipantsChanged();
            eventQueue.Open();
        }
Пример #13
0
 // Token: 0x060000C3 RID: 195 RVA: 0x0000531C File Offset: 0x0000351C
 public static IntPtr GetWindowHandle()
 {
     if (!FlashWindow.IsCurrentWindowValid())
     {
         FlashWindow.UpdateCurrentWindow();
     }
     return(FlashWindow.myWindow);
 }
Пример #14
0
 private void StartFlashWindow()
 {
     if (_flashWindowStarted)
     {
         return;
     }
     FlashWindow.Start(Handle);
     _flashWindowStarted = true;
 }
Пример #15
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (_customization.ApplyCustomization)
            {
                Title = _customization.PrintJobWindowCaption;
            }

            FlashWindow.Flash(this, 3);
        }
Пример #16
0
 // Token: 0x060000C9 RID: 201 RVA: 0x00005424 File Offset: 0x00003624
 public static bool Stop(IntPtr formHandle)
 {
     if (FlashWindow.Win2000OrLater)
     {
         FlashWindow.FLASHWINFO flashwinfo = FlashWindow.Create_FLASHWINFO(formHandle, 0u, uint.MaxValue, 0u);
         return(FlashWindow.FlashWindowEx(ref flashwinfo));
     }
     return(false);
 }
Пример #17
0
 // Token: 0x060000C6 RID: 198 RVA: 0x000053A0 File Offset: 0x000035A0
 public static bool Flash(IntPtr formHandle, uint count)
 {
     if (FlashWindow.Win2000OrLater)
     {
         FlashWindow.FLASHWINFO flashwinfo = FlashWindow.Create_FLASHWINFO(formHandle, 3u, count, 0u);
         return(FlashWindow.FlashWindowEx(ref flashwinfo));
     }
     return(false);
 }
Пример #18
0
 private void ShowNotification(string title)
 {
     _context.Post(o =>
     {
         FlashWindow.Flash(this.ParentForm);
         SpeakIt(title);
         MessageBox.Show(this.ParentForm, title, "Нотификация - vpg-toaster", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }, null);
 }
Пример #19
0
 private void StopFlashWindow()
 {
     if (!_flashWindowStarted)
     {
         return;
     }
     FlashWindow.Stop(Handle);
     _flashWindowStarted = false;
 }
Пример #20
0
    // Token: 0x060000C7 RID: 199 RVA: 0x000053C8 File Offset: 0x000035C8
    public static bool Flash()
    {
        IntPtr windowHandle = FlashWindow.GetWindowHandle();

        Debug.LogFormat("FlashWindow.Flash({0})", new object[]
        {
            windowHandle
        });
        return(FlashWindow.Flash(windowHandle));
    }
Пример #21
0
    // Token: 0x060000C2 RID: 194 RVA: 0x000052DC File Offset: 0x000034DC
    private static bool IsCurrentWindowValid()
    {
        IntPtr value;

        FlashWindow.GetWindowThreadProcessId(FlashWindow.myWindow, out value);
        if (value != FlashWindow.myProcessId)
        {
            FlashWindow.myWindow = IntPtr.Zero;
        }
        return(FlashWindow.myWindow != IntPtr.Zero);
    }
Пример #22
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            TranslationHelper.Instance.TranslatorInstance.Translate(this);

            if (Properties.Customization.ApplyCustomization.Equals("true", StringComparison.OrdinalIgnoreCase))
            {
                Title = Properties.Customization.PrintJobWindowCaption;
            }

            FlashWindow.Flash(this, 3);
        }
Пример #23
0
        protected static bool FlashWindowEx()
        {
            FlashWindow fw = new FlashWindow();

            fw.cbSize    = Convert.ToUInt32(Marshal.SizeOf(fw));
            fw.hwnd      = JAO.Window.Handle;
            fw.dwFlags   = 0xF;
            fw.uCount    = 1;
            fw.dwTimeout = 0;
            return(FlashWindowEx(ref fw));
        }
Пример #24
0
        public static bool FlashWindowEx(Form form, FlashWindow flags)
        {
            FLASHWINFO fInfo = new FLASHWINFO();

            fInfo.cbSize    = Convert.ToUInt32(Marshal.SizeOf(fInfo));
            fInfo.hwnd      = form.Handle;
            fInfo.dwFlags   = (uint)flags;
            fInfo.uCount    = UInt32.MaxValue;
            fInfo.dwTimeout = 0;

            return(FlashWindowEx(ref fInfo));
        }
Пример #25
0
        private static FLASHWINFO CreateFlashInfoStruct(IntPtr handle, FlashWindow flags, uint count, uint timeout)
        {
            FLASHWINFO fi = new FLASHWINFO();

            fi.cbSize    = Convert.ToUInt32(Marshal.SizeOf(fi));
            fi.hwnd      = handle;
            fi.dwFlags   = (uint)flags;
            fi.uCount    = count;
            fi.dwTimeout = timeout;

            return(fi);
        }
Пример #26
0
 /// <summary>
 /// Display a notification to the user, while flashing the window in the taskbar if it is not focused.
 /// </summary>
 /// <param name="title">The title for the notification.</param>
 /// <param name="message">The message body for the notification.</param>
 /// <param name="icon">The icon for the notification.</param>
 private void DisplayNotification(string title, string message, BalloonIcon icon)
 {
     //Use a background thread to show a notification.
     Task.Run(() => TaskbarIcon.ShowBalloonTip(title, message, icon));
     //If the window is minimised, make sure it is visible in the taskbar.
     if (WindowState == WindowState.Minimized)
     {
         ShowInTaskbar = true;
     }
     //Flash this window until it receives focus.
     FlashWindow.Flash(this);
 }
Пример #27
0
    // Token: 0x060000C0 RID: 192 RVA: 0x00005294 File Offset: 0x00003494
    private static bool GetWindowEnum(IntPtr hWnd, IntPtr lParam)
    {
        IntPtr value;

        FlashWindow.GetWindowThreadProcessId(hWnd, out value);
        if (value == FlashWindow.myProcessId)
        {
            FlashWindow.myWindow = hWnd;
            return(false);
        }
        return(true);
    }
Пример #28
0
 public static void CallCreateFlash(Form form)
 {
     if (form.InvokeRequired)
     {
         CallCreateFlashCallback d = new CallCreateFlashCallback(CallCreateFlash);
         form.Invoke(d, new object[] { form });
     }
     else
     {
         FlashWindow.Flash(form);
     }
 }
Пример #29
0
        public void PopulateDraftPicker(string message)
        {
            var booster = message.Split('|').Skip(1).Select(CardInfo.FromString).ToList();

            PrintLine("Received booster with " + booster.Count + (booster.Count == 1 ? " card." : " cards."));
            draftPicker.Populate(booster);
            Invoke(new MethodInvoker(delegate
            {
                if (ActiveForm != this)
                {
                    FlashWindow.Flash(this);
                }
            }));
        }
Пример #30
0
        private void FlashWhileMinimized()
        {
            Invoke(new Action(() => FlashWindow.Start(this)));

            var minimized = true;

            while (minimized)
            {
                Thread.Sleep(100);
                Invoke(new Action(() => minimized = WindowState == FormWindowState.Minimized));
            }

            Invoke(new Action(() => FlashWindow.Stop(this)));
        }
Пример #31
0
        public void InputBDZFile(string filename, bool create)
        {
            Excel.Application ex = new Excel.Application();
            Excel.Workbook workBook = ex.Workbooks.Open(filename, Type.Missing, Type.Missing,
                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            ex.Visible = false;
            FlashWindow frmLoad = new FlashWindow();
            frmLoad.Show();

            try
            {
                ArrayList alldata = new ArrayList();
                bool right = true;
                frmLoad.RefleshStatus("共有" + ex.Worksheets.Count.ToString() + "张工作表。");
                for (int n = 1; n <= ex.Worksheets.Count; n++)
                {
                    Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[n];
                    int c = xSheet1.Columns.Count;
                    int r = xSheet1.Rows.Count;
                    ArrayList jwlist = new ArrayList();
                    ArrayList mclist = new ArrayList();
                    ArrayList dylist = new ArrayList();
                    int int_jd = 0;
                    int int_wd = 0;
                    int int_dy = 0;
                    int int_mc = 0;
                    string kv = "";
                    string s = "";

                    for (int j = 1; j < xSheet1.Columns.Count; j++)
                    {
                        frmLoad.RefleshStatus("正在导入第" + n.ToString() + "张工作表,第" + j.ToString() + "行记录。");
                        if (((Excel.Range)xSheet1.Cells[1, j]).Value2 == null)
                        {
                            break;
                        }
                        Excel.Range range1 = (Excel.Range)xSheet1.Cells[1, j];
                        if (range1.Value2.ToString().Contains("经度"))
                        {
                            int_jd = j;
                        }
                        if (range1.Value2.ToString().Contains("纬度"))
                        {
                            int_wd = j;
                        }
                        if (range1.Value2.ToString().Contains("电压"))
                        {
                            int_dy = j;
                        }
                        if (range1.Value2.ToString().Contains("名称"))
                        {
                            int_mc = j;
                        }
                    }
                    if (int_jd == 0 || int_wd == 0)
                    {
                        MessageBox.Show("第" + n.ToString() + "张工作表中不包含经纬度信息,请核对。");
                        right = false;
                        break;
                    }
                    if (int_dy == 0)
                    {
                        MessageBox.Show("第" + n.ToString() + "张工作表中不包含电压信息,请核对。");
                        right = false;
                        break;
                    }
                    if (int_mc == 0)
                    {
                        MessageBox.Show("第" + n.ToString() + "张工作表中不包含变电站名称信息,请核对。");
                        right = false;
                        break;
                    }
                    //   fInfo.Info = "正在导入第" + n.ToString() + "张工作表......";
                    //line_name = xSheet1.Name;
                    for (int i = 2; i < xSheet1.Rows.Count; i++)
                    {
                        if (((Excel.Range)xSheet1.Cells[i, 1]).Value2 == null)
                        {
                            goto LabReadEnd;
                        }
                        Excel.Range range_J = (Excel.Range)xSheet1.Cells[i, int_jd];
                        Excel.Range range_W = (Excel.Range)xSheet1.Cells[i, int_wd];
                        Excel.Range range_mc = (Excel.Range)xSheet1.Cells[i, int_mc];
                        Excel.Range range_kv = (Excel.Range)xSheet1.Cells[i, int_dy];
                        if (range_J.Value2 == null || range_W.Value2 == null)
                        {
                            MessageBox.Show("第" + n.ToString() + "张工作表中第" + i.ToString() + "行经纬度数据格式错误,请核对。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            right = false;
                            break;
                        }
                        if (range_mc.Value2 == null)
                        {
                            MessageBox.Show("第" + n.ToString() + "张工作表中第" + i.ToString() + "行名称数据格式错误,请核对。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            right = false;
                            break;
                        }
                        if (range_kv.Value2 == null)
                        {
                            MessageBox.Show("第" + n.ToString() + "张工作表中第" + i.ToString() + "行电压数据格式错误,请核对。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            right = false;
                            break;
                        }
                        if (range_kv.Value2.ToString() != "500" && range_kv.Value2.ToString() != "220" && range_kv.Value2.ToString() != "110" && range_kv.Value2.ToString() != "35")
                        {
                            MessageBox.Show("第" + n.ToString() + "张工作表中第" + i.ToString() + "行中电压在图元中不存在,请核对。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            right = false;
                            break;
                        }

                        else
                        {
                            bool ck_r = true;
                            //gt = gt + range_gt.Value2.ToString() + ",";
                            s = s + range_J.Value2.ToString() + "," + range_W.Value2.ToString() + ";";
                            string s2 = range_J.Value2.ToString().Trim() + "," + range_W.Value2.ToString().Trim();

                        labLoop:
                            if (!alldata.Contains(s2))
                            {
                                alldata.Add(s2);
                                ck_r = true;
                            }
                            else
                            {
                                ck_r = false;
                            }

                            if (ck_r)
                            {
                                jwlist.Add(s2);
                            }
                            else
                            {
                                s2 = "S" + s2;
                                goto labLoop;
                                //jwlist.Add("S" + s2);
                            }
                            mclist.Add(range_mc.Value2.ToString());
                            dylist.Add(range_kv.Value2.ToString());
                        }
                    }
                LabReadEnd:
                    if (right == true)
                    {
                        StringBuilder bpts = new StringBuilder();
                        string jwd = "";
                        string points = "";
                        for (int k = 0; k < jwlist.Count; k++)
                        {
                            bool ck_s = true;
                            string str_jwdlist = ((string)jwlist[k]);
                            int int_s = 0;
                            if (str_jwdlist.Contains("S"))
                            {
                                ck_s = false;
                                int_s = str_jwdlist.LastIndexOfAny("S".ToCharArray());
                                if (int_s > -1)
                                {
                                    int_s = int_s + 1;
                                }
                                str_jwdlist = str_jwdlist.Replace("S", "");
                            }

                            jwd = jwd + str_jwdlist + ";";

                            double JD = 0;
                            double WD = 0;
                            if (str_jwdlist.LastIndexOfAny(" ".ToCharArray()) > 3)
                            {
                                string[] str = str_jwdlist.Split(',');
                                string[] JWD1 = str[0].Trim().Split(' ');
                                double J1 = Convert.ToDouble(JWD1[0]);
                                Double W1 = Convert.ToDouble(JWD1[1]);
                                Double D1 = Convert.ToDouble(JWD1[2]);
                                string[] JWD2 = str[1].Trim().Split(' ');
                                Double J2 = Convert.ToDouble(JWD2[0]);
                                Double W2 = Convert.ToDouble(JWD2[1]);
                                Double D2 = Convert.ToDouble(JWD2[2]);

                                JD = J1 + W1 / 60 + D1 / 3600;
                                WD = J2 + W2 / 60 + D2 / 3600;
                            }
                            else
                            {
                                string[] str = str_jwdlist.Split(',');
                                JD = Convert.ToDouble(str[0]);
                                WD = Convert.ToDouble(str[1]);
                            }

                            IntXY xy = mapview.getXY(JD, WD);
                            double _x = xy.X;
                            double _y = xy.Y;
                            if (ck_s)
                            {
                                if (mapview is MapViewGoogle)
                                {
                                    _x = xy.X;
                                    _y = xy.Y;
                                }
                                else
                                {
                                    _x = xy.X / (double)tlVectorControl1.ScaleRatio;
                                    _y = xy.Y / (double)tlVectorControl1.ScaleRatio;
                                }
                            }
                            else
                            {
                                if (mapview is MapViewGoogle)
                                {
                                    _x = xy.X + 5 * int_s;
                                    _y = xy.Y + 5 * int_s;
                                }
                                else
                                {
                                    _x = xy.X / (double)tlVectorControl1.ScaleRatio + 5 * int_s;
                                    _y = xy.Y / (double)tlVectorControl1.ScaleRatio + 5 * int_s;
                                }

                            }

                            string pspid = "";
                            if (create)
                            {
                                PSP_Substation_Info sub = new PSP_Substation_Info();
                                sub.UID = Guid.NewGuid().ToString();
                                sub.Title = mclist[k].ToString();
                                sub.AreaID = MIS.ProgUID;
                                sub.L1 = Convert.ToInt32(dylist[k]);
                                Services.BaseService.Create<Substation_Info>(sub);
                                pspid = sub.UID;
                            }

                            string str_sub = getHCSubName(dylist[k].ToString());
                            //PointF pf = getOff(str_dy);
                            XmlElement e0 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;
                            e0.SetAttribute("x", Convert.ToString(_x));
                            e0.SetAttribute("y", Convert.ToString(_y));
                            e0.SetAttribute("info-name", mclist[k].ToString());
                            e0.SetAttribute("jwd-info", str_jwdlist);
                            e0.SetAttribute("xlink:href", str_sub);
                            e0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                            e0.SetAttribute("layer", SvgDocument.currentLayer);
                            if (pspid != "")
                            {
                                e0.SetAttribute("Deviceid", pspid);
                            }
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(e0);

                        }

                    }
                }
                //fInfo.Hide();
                ex.Quit();
                frmLoad.Close();
            }
            catch
            {
                MessageBox.Show(" 数据格式错误,请检查。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ex.Quit();
                frmLoad.Close();
            }
        }
Пример #32
0
        public void InputFile(string filename, bool create)
        {
            int LineOffSize = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("LineOffSize"));
            Excel.Application ex = new Excel.Application();
            Excel.Workbook workBook = ex.Workbooks.Open(filename, Type.Missing, Type.Missing,
                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            ex.Visible = false;
            FlashWindow frmLoad = new FlashWindow();
            frmLoad.Show();
            try
            {
                ArrayList alldata = new ArrayList();
                bool right = true;

                frmLoad.RefleshStatus("共有" + ex.Worksheets.Count.ToString() + "张工作表。");
                //fInfo.Info = "共有" + ex.Worksheets.Count.ToString()+ "张工作表。";
                //fInfo.Show();
                for (int n = 1; n <= ex.Worksheets.Count; n++)
                {
                    Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[n];
                    int c = xSheet1.Columns.Count;
                    int r = xSheet1.Rows.Count;
                    string line_name = "";
                    ArrayList jwlist = new ArrayList();
                    ArrayList gtlist = new ArrayList();
                    int int_jd = 0;
                    int int_wd = 0;
                    int int_dy = 0;
                    int int_gt = 0;
                    int int_gtxh = 0;
                    string kv = "";
                    string s = "";
                    string gt = "";
                    string s_gtxh = "";
                    for (int j = 1; j < xSheet1.Columns.Count; j++)
                    {
                        if (((Excel.Range)xSheet1.Cells[1, j]).Value2 == null)
                        {
                            break;
                        }
                        Excel.Range range1 = (Excel.Range)xSheet1.Cells[1, j];
                        if (range1.Value2.ToString().Contains("经度"))
                        {
                            int_jd = j;
                        }
                        if (range1.Value2.ToString().Contains("纬度"))
                        {
                            int_wd = j;
                        }
                        if (range1.Value2.ToString().Contains("电压"))
                        {
                            int_dy = j;
                        }
                        if (range1.Value2.ToString().Contains("杆塔号"))
                        {
                            int_gt = j;
                        }
                        if (range1.Value2.ToString().Contains("杆塔型号"))
                        {
                            int_gtxh = j;
                        }
                    }
                    if (int_jd == 0 || int_wd == 0)
                    {
                        MessageBox.Show("第" + n.ToString() + "张工作表中不包含经纬度信息,请核对。");
                        right = false;
                        break;
                    }
                    if (int_dy == 0)
                    {
                        MessageBox.Show("第" + n.ToString() + "张工作表中不包含电压信息,请核对。");
                        right = false;
                        break;
                    }
                    if (int_gt == 0)
                    {
                        MessageBox.Show("第" + n.ToString() + "张工作表中不包含杆塔号信息,请核对。");
                        right = false;
                        break;
                    }
                    frmLoad.RefleshStatus("正在导入第" + n.ToString() + "张工作表......");
                    //   fInfo.Info = "正在导入第" + n.ToString() + "张工作表......";
                    line_name = xSheet1.Name;
                    for (int i = 2; i < xSheet1.Rows.Count; i++)
                    {
                        frmLoad.RefleshStatus("正在导入第" + n.ToString() + "张工作表,第" + i.ToString() + "行记录。");
                        if (((Excel.Range)xSheet1.Cells[i, 1]).Value2 == null)
                        {
                            goto LabReadEnd;
                        }
                        int gtxh = 0;
                        Excel.Range range_J = (Excel.Range)xSheet1.Cells[i, int_jd];
                        Excel.Range range_W = (Excel.Range)xSheet1.Cells[i, int_wd];
                        Excel.Range range_gt = (Excel.Range)xSheet1.Cells[i, int_gt];
                        Excel.Range range_kv = (Excel.Range)xSheet1.Cells[i, int_dy];
                        if (int_gtxh != 0)
                        {
                            Excel.Range range_gtxh = (Excel.Range)xSheet1.Cells[i, int_gtxh];
                            string str_xh = range_gtxh.Value2.ToString();
                            if (str_xh.Contains("T"))
                            {
                                gtxh = 1;
                            }
                        }
                        if (range_J.Value2 == null || range_W.Value2 == null)
                        {
                            MessageBox.Show("第" + n.ToString() + "张工作表中第" + i.ToString() + "行数据格式错误,请核对。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            right = false;
                            break;
                        }

                        else
                        {
                            bool ck_r = true;
                            gt = gt + range_gt.Value2.ToString() + ",";
                            s_gtxh = s_gtxh + gtxh.ToString() + ",";
                            s = s + range_J.Value2.ToString() + "," + range_W.Value2.ToString() + ";";
                            string s2 = range_J.Value2.ToString().Trim() + "," + range_W.Value2.ToString().Trim();

                        labLoop:
                            if (!alldata.Contains(s2))
                            {
                                alldata.Add(s2);
                                ck_r = true;
                            }
                            else
                            {
                                ck_r = false;
                            }

                            if (ck_r)
                            {
                                jwlist.Add(s2);
                            }
                            else
                            {
                                s2 = "S" + s2;
                                goto labLoop;
                                //jwlist.Add("S" + s2);
                            }
                        }
                        //line_name = range_nm.Value2.ToString();
                        if (range_kv.Value2 != null)
                        {
                            kv = range_kv.Value2.ToString();
                        }
                    }
                LabReadEnd:
                    if (right == true)
                    {
                        StringBuilder bpts = new StringBuilder();
                        string jwd = "";
                        string points = "";
                        for (int k = 0; k < jwlist.Count; k++)
                        {
                            bool ck_s = true;
                            string str_jwdlist = ((string)jwlist[k]);
                            int int_s = 0;
                            if (str_jwdlist.Contains("S"))
                            {
                                ck_s = false;
                                int_s = str_jwdlist.LastIndexOfAny("S".ToCharArray());
                                if (int_s > -1)
                                {
                                    int_s = int_s + 1;
                                }
                                str_jwdlist = str_jwdlist.Replace("S", "");
                            }

                            jwd = jwd + str_jwdlist + ";";

                            double JD = 0;
                            double WD = 0;
                            if (str_jwdlist.LastIndexOfAny(" ".ToCharArray()) > 3)
                            {
                                string[] str = str_jwdlist.Split(',');
                                string[] JWD1 = str[0].Trim().Split(' ');
                                double J1 = Convert.ToDouble(JWD1[0]);
                                Double W1 = Convert.ToDouble(JWD1[1]);
                                Double D1 = Convert.ToDouble(JWD1[2]);
                                string[] JWD2 = str[1].Trim().Split(' ');
                                Double J2 = Convert.ToDouble(JWD2[0]);
                                Double W2 = Convert.ToDouble(JWD2[1]);
                                Double D2 = Convert.ToDouble(JWD2[2]);

                                JD = J1 + W1 / 60 + D1 / 3600;
                                WD = J2 + W2 / 60 + D2 / 3600;
                            }
                            else
                            {
                                string[] str = str_jwdlist.Split(',');
                                JD = Convert.ToDouble(str[0]);
                                WD = Convert.ToDouble(str[1]);
                            }

                            IntXY xy = mapview.getXY(JD, WD);
                            if (ck_s)
                            {
                                if (mapview is MapViewGoogle)
                                    bpts.Append(xy.X + " " + xy.Y + ",");
                                else
                                    bpts.Append((-xy.X / (double)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (double)tlVectorControl1.ScaleRatio) + ",");
                            }
                            else
                            {
                                if (mapview is MapViewGoogle)
                                    bpts.Append(xy.X + LineOffSize * int_s + " " + xy.Y + LineOffSize * int_s + ",");
                                else
                                {
                                    bpts.Append((-xy.X / (double)tlVectorControl1.ScaleRatio) + LineOffSize * int_s + " " + (-xy.Y / (double)tlVectorControl1.ScaleRatio) + LineOffSize * int_s + ",");
                                }

                            }
                        }
                        if (bpts.Length > 0)
                            points = bpts.ToString(0, bpts.Length - 1);

                        if (jwd.Length > 1)
                        {
                            jwd = jwd.Substring(0, jwd.Length - 1);
                        }

                        if (gt.Length > 0)
                        {
                            gt = gt.Substring(0, gt.Length - 1);
                        }
                        if (s_gtxh.Length > 0)
                        {
                            s_gtxh = s_gtxh.Substring(0, s_gtxh.Length - 1);
                        }
                        string styleValue = "";
                        LineType lt = new LineType();
                        if (!kv.Contains("kV"))
                        {
                            kv = kv + "kV";
                        }
                        lt.TypeName = kv;
                        lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                        if (lt != null)
                        {
                            styleValue = "stroke-width:" + lt.ObligateField1 + ";";
                            styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(lt.Color)));
                        }
                        string pspid = "";
                        if (create)
                        {
                            PSPDEV psp = new PSPDEV();
                            psp.SUID = Guid.NewGuid().ToString();
                            psp.Name = line_name;
                            psp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                            psp.Type = "05";
                            psp.RateVolt = Convert.ToDouble(kv.Replace("kV", ""));
                            psp.ProjectID = MIS.ProgUID;
                            Services.BaseService.Create<PSPDEV>(psp);
                            pspid = psp.SUID;
                        }

                        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                        n1.SetAttribute("IsLead", "1");
                        n1.SetAttribute("points", points);
                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                        n1.SetAttribute("info-name", line_name);
                        n1.SetAttribute("jwd-info", jwd);
                        n1.SetAttribute("gt-info", gt);
                        n1.SetAttribute("dy-info", kv.Replace("kV", ""));
                        n1.SetAttribute("gtxh-info", s_gtxh);
                        if (pspid != "")
                        {
                            n1.SetAttribute("Deviceid", pspid);
                        }
                        if (styleValue != "")
                        {
                            n1.SetAttribute("style", styleValue);
                        }
                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);

                    }
                }
                //fInfo.Hide();
                ex.Quit();
                frmLoad.Close();
            }
            catch
            {
                MessageBox.Show(" 数据格式错误,请检查。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ex.Quit();
                frmLoad.Close();
            }
        }
Пример #33
0
        private void layerImport()
        {
            frmLayerInPut dlgInPut = new frmLayerInPut();
            string ss2="";
            dlgInPut.InitData(SVGUID);
            string layerOutXml = null;
            if (dlgInPut.ShowDialog(this) == DialogResult.OK) {
                FlashWindow frmLoad = new FlashWindow();
                foreach (LayerFile layer in dlgInPut.InputLayerList) {
                    if (Layer.CkLayerExist(layer.LayerFileName, tlVectorControl1.SVGDocument)) {
                        if (MessageBox.Show("文档中已经存在同名图层,是否覆盖原图层。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) {
                            if (layerOutXml == null)
                            {
                                layerOutXml = layer.LayerOuterXml;
                            }
                            else
                            {
                                layerOutXml = SvgDocument.Union(layerOutXml, layer.LayerOuterXml);
                            }
                            Services.BaseService.Update("DeleteLayerFile", layer);
                            frmlar.DeleteLayer(getlayer(layer.LayerFileName, tlVectorControl1.SVGDocument.getLayerList()));
                        }

                    } else {
                        if (layerOutXml == null) {
                            layerOutXml = layer.LayerOuterXml;
                        } else {
                            layerOutXml = SvgDocument.Union(layerOutXml, layer.LayerOuterXml);
                        }
                        Services.BaseService.Update("DeleteLayerFile", layer);

                        //frmlar.DeleteLayer(getlayer(layer.LayerFileName, tlVectorControl1.SVGDocument.getLayerList()));
                    }

                    //FileStream a = new FileStream("c:\\1.xml",FileMode.OpenOrCreate);
                    //StreamWriter str= new StreamWriter(a);
                    //str.Write(layerOutXml);
                    //str.Close();
                }
                dlgInPut.Close();
                dlgInPut.Dispose();
                //string ss= tlVectorControl1.SVGDocument.CurrentLayer.ID;
                //layerOutXml = layerOutXml.Replace(ss2,ss);
                if (layerOutXml != null) {
                    string svgName = tlVectorControl1.SVGDocument.FileName;
                    string svgUid = tlVectorControl1.SVGDocument.SvgdataUid;
                    ItopVector.SpecialCursors.LoadCursors();
                    frmLoad.Show();
                    frmLoad.RefleshStatus("正在导入图层...");
                    Application.DoEvents();
                    frmLoad.SplashData();
                    frmLoad.Owner = tlVectorControl1.ParentForm;
                    frmLoad.Refresh();

                    //tlVectorControl1.SVGDocument.LoadXml(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, lay.LayerOuterXml));
                    tlVectorControl1.SVGDocument = LoadXMLToCtrl(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, layerOutXml));
                    tlVectorControl1.PropertyGrid = propertyGrid;
                    tlVectorControl1.SVGDocument.SvgdataUid = svg.SUID;
                    //tlVectorControl1.SVGDocument.SvgdataUid = svgUid;
                    tlVectorControl1.SVGDocument.FileName = svgName;
                    tlVectorControl1.IsModified = true;

                    frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                    frmlar.InitData();
                    MessageBox.Show("图层已成功导入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                //if (dlgInPut.InputText != "")
                //{

                //    LayerFile temp = new LayerFile();
                //    temp.LayerFileName = dlgInPut.InputText;
                //    temp.SvgDataUid = tlVectorControl1.SVGDocument.SvgdataUid;
                //    LayerFile lay = (LayerFile)Services.BaseService.GetObject("SelectLayerFileByNameAndSvgDataUid", temp);

                //if (lay != null)
                //{
                //    if (Layer.CkLayerExist(dlgInPut.InputText, tlVectorControl1.SVGDocument))
                //    {
                //        if (MessageBox.Show("文档中已经存在同名图层,是否覆盖原图层。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                //        {
                //            frmlar.DeleteLayer(getlayer(dlgInPut.InputText, tlVectorControl1.SVGDocument.getLayerList()));
                //            string svgName = tlVectorControl1.SVGDocument.FileName;
                //            string svgUid = tlVectorControl1.SVGDocument.SvgdataUid;
                //            ItopVector.SpecialCursors.LoadCursors();
                //            frmLoad.Show();
                //            frmLoad.RefleshStatus("正在导入图层...");
                //            Application.DoEvents();
                //            frmLoad.SplashData();
                //            frmLoad.Owner = tlVectorControl1.ParentForm;
                //            frmLoad.Refresh();

                //            //tlVectorControl1.SVGDocument.LoadXml(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, lay.LayerOuterXml));
                //            tlVectorControl1.SVGDocument = LoadXMLToCtrl(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, lay.LayerOuterXml));
                //            tlVectorControl1.PropertyGrid = propertyGrid;
                //            tlVectorControl1.SVGDocument.SvgdataUid = svg.SUID;
                //            //tlVectorControl1.SVGDocument.SvgdataUid = svgUid;
                //            tlVectorControl1.SVGDocument.FileName = svgName;
                //            tlVectorControl1.IsModified = true;

                //            frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                //            frmlar.InitData();
                //            Services.BaseService.Update("DeleteLayerFile", lay);
                //            MessageBox.Show("图层已成功导入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //        }

                //    }
                //    else
                //    {
                //        string svgName = tlVectorControl1.SVGDocument.FileName;
                //        string svgUid = tlVectorControl1.SVGDocument.SvgdataUid;
                //        ItopVector.SpecialCursors.LoadCursors();

                //        frmLoad.Show();
                //        frmLoad.RefleshStatus("正在导入图层...");
                //        Application.DoEvents();
                //        frmLoad.SplashData();
                //        frmLoad.Owner = tlVectorControl1.ParentForm;
                //        frmLoad.Refresh();

                //        tlVectorControl1.SVGDocument = LoadXMLToCtrl(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, lay.LayerOuterXml));
                //        tlVectorControl1.PropertyGrid = propertyGrid;
                //        tlVectorControl1.SVGDocument.SvgdataUid = svgUid;
                //        tlVectorControl1.SVGDocument.FileName = svgName;
                //        tlVectorControl1.IsModified = true;
                //        frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                //        frmlar.InitData();
                //        Services.BaseService.Update("DeleteLayerFile", lay);
                //        MessageBox.Show("图层已成功导入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    }
                //}
                //}
            }
        }