Esempio n. 1
0
 private static void PostfixProcessLabel(BaseLabel label)
 {
     if (label.gameObject.activeSelf)
     {
         LabelEvent.onLabelProcessed.Fire(label);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            #region Controls
            var defButtonSize = new Size(83, 23);

            menuSubHelpBtn    = new BaseButton(_res, "menuSubHelpBtn", 11, visStyleBackColor: true, point: new Point(502, 172), size: defButtonSize, text: "Help!");
            removeSelectedBtn = new BaseButton(_res, "removeSelectedBtn", 10, visStyleBackColor: true, point: new Point(98, 142), size: new Size(104, 23), text: "Remove Selected");
            stopCurrentBtn    = new BaseButton(_res, "stopCurrentBtn", 9, visStyleBackColor: true, point: new Point(297, 142), size: defButtonSize, text: "Stop Current");
            runCustomBtn      = new BaseButton(_res, "runCustomBtn", 8, visStyleBackColor: true, point: new Point(208, 142), size: defButtonSize, text: "Run Custom");
            createNewBtn      = new BaseButton(_res, "createNewBtn", 7, visStyleBackColor: true, point: new Point(6, 142), size: defButtonSize, text: "Add New");
            saveAsCsvBtn      = new BaseButton(_res, "saveAsCsvBtn", 5, visStyleBackColor: true, point: new Point(187, 41), size: defButtonSize, text: "Save as CSV");
            saveAsXmlBtn      = new BaseButton(_res, "saveAsXmlBtn", 4, visStyleBackColor: true, point: new Point(98, 41), size: defButtonSize, text: "Save as XML");
            resetCrntBtn      = new BaseButton(_res, "resetCrntBtn", 3, visStyleBackColor: true, point: new Point(357, 41), size: defButtonSize, text: "Reset Current");
            openFileBtn       = new BaseButton(_res, "openFileBtn", 2, visStyleBackColor: true, point: new Point(276, 41), size: new Size(75, 23), text: "Open File");
            saveAsTxtBtn      = new BaseButton(_res, "saveAsTxtBtn", visStyleBackColor: true, point: new Point(3, 41), size: new Size(86, 23), text: "Save as Text");
            scriptLbl         = new BaseLabel(_res, "scriptLbl", 6, new Point(3, 101), new Size(107, 17), "Script / Process", autoSize: true);
            procStatusLbl     = new BaseLabel(_res, "procStatusLbl", 3, new Point(336, 270), new Size(37, 23), "Idle", autoSize: true, borderStyle: BorderStyle.Fixed3D);
            reportingLbl      = new BaseLabel(_res, "reportingLbl", 1, new Point(3, 0), new Size(70, 17), "Reporting", autoSize: false);
            currentStatusBar  = new BaseProgressBar(_res, "currentStatusBar", 1, new Point(12, 270), new Size(318, 23));
            infoTextBox       = new BaseRichTextBox(_res, "infoTextBox", 2, Color.Black, Color.LimeGreen, new Point(12, 12), new Size(592, 241));
            #endregion

            #region Panels
            reportingOpersPnl = new BasePanel(_res, "reportingOpersPnl", controls: new Control[] { menuSubHelpBtn, removeSelectedBtn, stopCurrentBtn, runCustomBtn, createNewBtn, scriptLbl, saveAsCsvBtn, saveAsXmlBtn, resetCrntBtn, openFileBtn, reportingLbl, saveAsTxtBtn },
                                              point: new Point(12, 308), size: new Size(592, 202));
            #endregion

            SuspendLayout();
            InitMainMenuSub();
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            #region Controls
            var defBigButtonSize  = new Size(120, 23);
            var defButtonPadding  = new Padding(85, 10, 85, 5);
            var defControlPadding = new Padding(5, 10, 5, 5);

            removeCurrBtn       = new BaseButton(_res, "removeCurrBtn", 2, visStyleBackColor: true, point: new Point(85, 79), margin: defButtonPadding, size: defBigButtonSize, text: "Remove Selected");
            setSelectedBtn      = new BaseButton(_res, "setSelectedBtn", 11, visStyleBackColor: true, point: new Point(85, 117), margin: defButtonPadding, size: defBigButtonSize, text: "Set Selected");
            setAsDefBtn         = new BaseButton(_res, "setAsDefBtn", 6, visStyleBackColor: true, point: new Point(85, 155), margin: defButtonPadding, size: defBigButtonSize, text: "Set as Default");
            setToDefBtn         = new BaseButton(_res, "setToDefBtn", 3, visStyleBackColor: true, point: new Point(85, 193), margin: defButtonPadding, size: defBigButtonSize, text: "Set to Default");
            checkGeoDataBtn     = new BaseButton(_res, "checkGeoData", 5, visStyleBackColor: true, point: new Point(85, 231), margin: defButtonPadding, size: defBigButtonSize, text: "Check Geo-Data");
            addCustomBtn        = new BaseButton(_res, "addCustomBtn", 9, visStyleBackColor: true, point: new Point(85, 337), margin: defButtonPadding, size: defBigButtonSize, text: "Add Custom");
            addNSetCustBtn      = new BaseButton(_res, "addNSetCustBtn", 12, visStyleBackColor: true, point: new Point(85, 375), margin: defButtonPadding, size: defBigButtonSize, text: "Add and Set Custom");
            removeSimilarBtn    = new BaseButton(_res, "removeSimilarBtn", 10, visStyleBackColor: true, point: new Point(85, 413), margin: defButtonPadding, size: defBigButtonSize, text: "Remove Similar");
            currHelpBtn         = new BaseButton(_res, "currHelpBtn", 4, visStyleBackColor: true, point: new Point(190, 461), margin: new Padding(0, 20, 25, 5), size: new Size(75, 23), text: "Help!", dock: DockStyle.Right);
            addNewBtn           = new BaseButton(_res, "addNewBtn", 0, visStyleBackColor: true, point: new Point(84, 15), margin: new Padding(84, 15, 3, 3), size: defBigButtonSize, text: "Add New");
            addnSetNewBtn       = new BaseButton(_res, "addnSetNewBtn", 1, visStyleBackColor: true, point: new Point(84, 56), margin: new Padding(84, 15, 3, 3), size: defBigButtonSize, text: "Add and Set New");
            helpNewBtn          = new BaseButton(_res, "helpNewBtn", 2, visStyleBackColor: true, point: new Point(183, 107), margin: new Padding(183, 25, 15, 3), size: new Size(80, 23), text: "Help!", dock: DockStyle.Right);
            customTagInpBox     = new BaseTextBox(_res, "customTagInpBox", 8, new Point(5, 302), new Size(270, 20), padding: defControlPadding);
            langTagListBox      = new BaseListBox(_res, "langTagListBox", 18, formatting: true, scrollAlwaysVisible: true, backColor: SystemColors.MenuText, foreColor: Color.OliveDrab, point: new Point(317, 12), size: new Size(288, 346), selMode: SelectionMode.MultiSimple);
            customInpLbl        = new BaseLabel(_res, "customInpLbl", 7, new Point(5, 269), new Size(96, 18), "Custom Input", padding: defControlPadding, autoSize: true);
            currentInstLangsLbl = new BaseLabel(_res, "currentInstLangsLbl", 1, new Point(5, 10), new Size(186, 18), "Current Installed Languages:", autoSize: true, padding: defControlPadding);
            currentLangsCmboBox = new BaseComboBox(_res, "currentLangsCmboBox", point: new Point(5, 43), size: new Size(270, 21), padding: defControlPadding);
            #endregion

            #region Panels
            currLangOpPanel = new BaseFlowPanel(_res, "currLangOpPanel", 1, controls: new Control[] { currentInstLangsLbl, currentLangsCmboBox, removeCurrBtn, setSelectedBtn, setAsDefBtn, setToDefBtn, checkGeoDataBtn, customInpLbl, customTagInpBox, addCustomBtn, addNSetCustBtn, removeSimilarBtn, currHelpBtn },
                                                new Point(12, 12), new Size(290, 498), borderStyle: BorderStyle.Fixed3D, flow: FlowDirection.TopDown);
            newLangListPanel = new BaseFlowPanel(_res, "newLangListPanel", 2, controls: new Control[] { addNewBtn, addnSetNewBtn, helpNewBtn }, new Point(317, 364), new Size(288, 146), borderStyle: BorderStyle.Fixed3D, flow: FlowDirection.TopDown);
            #endregion

            SuspendLayout();
            InitSysLanguage();
        }
        void ReleaseDesignerOutlets()
        {
            if (BaseTextView != null)
            {
                BaseTextView.Dispose();
                BaseTextView = null;
            }

            if (CurrentTextView != null)
            {
                CurrentTextView.Dispose();
                CurrentTextView = null;
            }

            if (BaseLabel != null)
            {
                BaseLabel.Dispose();
                BaseLabel = null;
            }

            if (CurrentLabel != null)
            {
                CurrentLabel.Dispose();
                CurrentLabel = null;
            }
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            #region Controls
            var defBtnSizeBig = new Size(100, 23);
            var defBtnSize    = new Size(70, 23);

            constFullLbl     = new BaseLabel(_res, "constFullLbl", 6, new Point(233, 315), new Size(178, 18), "Constructed Full Address:", autoSize: true);
            genAddLbl        = new BaseLabel(_res, "genAddLbl", 3, new Point(3, 315), new Size(131, 18), "Generate Address:", autoSize: true);
            macVendorsLbl    = new BaseLabel(_res, "macVendorsLbl", 1, new Point(3, 40), new Size(100, 18), "Mac Vendors:", autoSize: true);
            savedAddysLbl    = new BaseLabel(_res, "savedAddysLbl", 3, new Point(5, 40), new Size(123, 17), "Saved Addresses:", padding: new Padding(5, 40, 3, 0), autoSize: true);
            generateRndmBtn  = new BaseButton(_res, "generateRndmBtn", 9, point: new Point(236, 237), size: new Size(120, 23), text: "Generate Random", visStyleBackColor: true);
            applyFullAddBtn  = new BaseButton(_res, "applyFullAddBtn", 8, point: new Point(236, 387), size: defBtnSizeBig, text: "Apply Full Address", visStyleBackColor: true);
            saveToFileBtn    = new BaseButton(_res, "saveToFileBtn", 0, point: new Point(236, 433), size: new Size(70, 23), margin: new Padding(20, 20, 3, 3), text: "Save", visStyleBackColor: true);
            generateAddrBtn  = new BaseButton(_res, "generateAddrBtn", 5, point: new Point(6, 387), size: defBtnSizeBig, text: "Generate New", visStyleBackColor: true);
            addVendorBtn     = new BaseButton(_res, "addVendorBtn", 4, point: new Point(6, 237), size: new Size(100, 23), text: "Add Selected", visStyleBackColor: true);
            applySelectBtn   = new BaseButton(_res, "applySelectBtn", 1, point: new Point(35, 151), size: defBtnSize, margin: new Padding(35, 60, 3, 3), text: "Apply", visStyleBackColor: true);
            removeSelectBtn  = new BaseButton(_res, "removeSelectBtn", 2, point: new Point(35, 192), size: defBtnSize, margin: new Padding(35, 15, 3, 3), text: "Remove", visStyleBackColor: true);
            macAddHelpBtn    = new BaseButton(_res, "macAddHelpBtn", 5, point: new Point(80, 233), size: new Size(40, 23), margin: new Padding(80, 15, 3, 3), text: "Help!", visStyleBackColor: true);
            fullMacTxtBox    = new BaseTextBox(_res, "fullMacTxtBox", 7, new Point(236, 349), new Size(160, 20));
            generatedTxtBox  = new BaseTextBox(_res, "generatedTxtBox", 2, new Point(6, 349), new Size(120, 20));
            macVendorsLstBox = new BaseListBox(_res, "macVendorsLstBox", 0, true, point: new Point(6, 67), size: new Size(350, 147));
            savedMacsCmboBox = new BaseComboBox(_res, "savedMacsCmboBox", 3, new Point(5, 67), new Size(121, 21), new Padding(5, 10, 3, 3));

            #endregion

            #region Panels
            macDetailsPnl = new BaseFlowPanel(_res, "macDetailsPnl", 0, new Control[] { generateRndmBtn, applyFullAddBtn, saveToFileBtn, fullMacTxtBox, constFullLbl, generateAddrBtn, addVendorBtn, genAddLbl, generatedTxtBox, macVendorsLbl, macVendorsLstBox },
                                              new Point(12, 12), new Size(434, 491));
            savedAddrsPnl = new BaseFlowPanel(_res, "svedAddrsPnl", 1, new Control[] { savedAddysLbl, savedMacsCmboBox, applySelectBtn, removeSelectBtn, macAddHelpBtn },
                                              new Point(461, 12), new Size(140, 490), borderStyle: BorderStyle.Fixed3D);
            #endregion

            SuspendLayout();
            InitMacAddress();
        }
Esempio n. 6
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            #region Controls
            var defTxtBoxSize = new Size(100, 20);

            adapterIpsListBox           = new BaseListBox(_res, "adaptersIpsListBox", 2, true, backColor: SystemColors.MenuText, foreColor: Color.YellowGreen, point: new Point(13, 358), size: new Size(591, 148), itemHeight: 16);
            selectedAdapterDataRchTxtBx = new BaseRichTextBox(_res, "selectedAdapterDataRchTxtBx", 7, SystemColors.MenuText, Color.YellowGreen, new Point(3, 95), new Size(259, 131));
            gatewayTxtBox     = new BaseTextBox(_res, "gatewayTxtBox", 9, new Point(7, 171), defTxtBoxSize);
            ipAddTxtBox       = new BaseTextBox(_res, "ipAddTxtBox", 8, new Point(7, 95), defTxtBoxSize);
            maskTxtBox        = new BaseTextBox(_res, "maskTxtBox", 7, new Point(158, 95), defTxtBoxSize);
            dnsTxtBox         = new BaseTextBox(_res, "dnsTxtBox", 6, new Point(158, 171), defTxtBoxSize);
            dnsLbl            = new BaseLabel(_res, "dnsLbl", 4, new Point(155, 151), new Size(41, 17), "DNS:", autoSize: true);
            gatewayLbl        = new BaseLabel(_res, "gatewayLbl", 3, new Point(4, 151), new Size(67, 17), "Gateway:", autoSize: true);
            maskLbl           = new BaseLabel(_res, "maskLbl", 2, new Point(155, 75), new Size(4, 17), "Mask", autoSize: true);
            ipaddressLbl      = new BaseLabel(_res, "ipAddressLbl", 1, new Point(4, 75), new Size(80, 17), "IP Address:", autoSize: true);
            staticAddLbl      = new BaseLabel(_res, "staticAddLbl", point: new Point(3, 11), size: new Size(113, 20), text: "Static Address", autoSize: true);
            currNetAdDataLbl  = new BaseLabel(_res, "currNetAdDataLbl", 8, new Point(4, 75), new Size(169, 17), "Current NetAdapter Data:", autoSize: true);
            dynamicAddLbl     = new BaseLabel(_res, "dynamicAddLbl", 1, new Point(3, 11), new Size(133, 20), "Dynamic Address", autoSize: true);
            adaptersListLbl   = new BaseLabel(_res, "adaptersListLbl", 9, point: new Point(12, 329), new Size(112, 17), autoSize: true, text: "Adapters and IPs:");
            ipAddressesHlpBtn = new BaseButton(_res, "ipAddressesHlpBtn", 10, visStyleBackColor: true, point: new Point(564, 329), size: new Size(40, 23), text: "Help!");
            setDynamicIPBtn   = new BaseButton(_res, "setDynamicIPBtn", 6, point: new Point(7, 244), size: new Size(75, 23), visStyleBackColor: true, text: "Do Magic");
            setStaticIPBtn    = new BaseButton(_res, "setStaticIPBtn", 5, point: new Point(7, 244), size: new Size(75, 23), text: "Set Address:", visStyleBackColor: true);
            #endregion

            #region Panels
            staticPnl = new BaseFlowPanel(_res, "staticPnl", controls: new Control[] { gatewayTxtBox, ipAddTxtBox, maskTxtBox, dnsTxtBox, setStaticIPBtn, dnsLbl, gatewayLbl, maskLbl, ipaddressLbl, staticAddLbl },
                                          point: new Point(13, 17), size: new Size(282, 289), borderStyle: BorderStyle.Fixed3D);
            dynamicPnl = new BaseFlowPanel(_res, "dynamicPnl", 1, new Control[] { currNetAdDataLbl, selectedAdapterDataRchTxtBx, setDynamicIPBtn, dynamicAddLbl }, new Point(322, 17), new Size(282, 289), BorderStyle.Fixed3D);
            #endregion


            SuspendLayout();
            InitIPAddress();
        }
Esempio n. 7
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            #region Controls
            var defVisStyleBackCol = true;

            connTxtBox             = new BaseTextBox(_res, "connTxtBox", 1, new Point(30, 52), new Size(120, 20), padding: new Padding(30, 5, 3, 3));
            addressTxtBox          = new BaseTextBox(_res, "addressTxtBox", 3, new Point(30, 112), new Size(120, 20), padding: new Padding(30, 5, 3, 3));
            portTxtBox             = new BaseTextBox(_res, "portTxtBox", 5, new Point(30, 172), new Size(120, 20), padding: new Padding(30, 5, 3, 3));
            gatewayTxtBox          = new BaseTextBox(_res, "gatewayTxtBox", 7, new Point(30, 232), new Size(120, 20), padding: new Padding(30, 5, 3, 3));
            screenWidthTxtBox      = new BaseTextBox(_res, "screenWidthTxtBox", 23, new Point(20, 124), new Size(105, 20), padding: new Padding(20, 5, 3, 3));
            screenHeightTxtBox     = new BaseTextBox(_res, "screenHeightTxtBox", 25, new Point(20, 184), new Size(105, 20), padding: new Padding(20, 5, 3, 3));
            connLbl                = new BaseLabel(_res, "connLbl", 0, new Point(30, 30), new Size(124, 17), "Connection Name:", autoSize: true, padding: new Padding(30, 30, 3, 0));
            addressLbl             = new BaseLabel(_res, "addressLbl", 2, new Point(30, 90), new Size(110, 17), "Server Address:", autoSize: true, padding: new Padding(30, 15, 3, 0));
            portLbl                = new BaseLabel(_res, "portLbl", 4, new Point(30, 150), new Size(84, 17), "Server Port:", autoSize: true, padding: new Padding(30, 15, 3, 0));
            gatewayLbl             = new BaseLabel(_res, "gatewayLbl", 6, new Point(30, 120), new Size(67, 17), "Gateway:", autoSize: true, padding: new Padding(30, 15, 3, 0));
            connStatusLbl          = new BaseLabel(_res, "connStatusLbl", 8, new Point(175, 129), new Size(127, 17), "Connection Status", autoSize: true);
            savedRdpsLbl           = new BaseLabel(_res, "savedRdpsLbl", 1, new Point(31, 28), new Size(97, 18), "Saved RDPs:", autoSize: true);
            screenWidthLbl         = new BaseLabel(_res, "screenWidthLbl", 22, new Point(20, 102), new Size(97, 17), "Screen Width:", autoSize: true, padding: new Padding(20, 15, 3, 0));
            screenHeightLbl        = new BaseLabel(_res, "screenHeightLbl", 24, new Point(20, 162), new Size(102, 17), "Screen Height:", autoSize: true, padding: new Padding(20, 15, 3, 0));
            useGatewayChckBox      = new BaseCheckBox(_res, "useGatewayChckBox", 8, defVisStyleBackCol, "Use Gateway", new Point(30, 285), new Size(98, 19), margin: new Padding(30, 30, 3, 3));
            asAdminChckBox         = new BaseCheckBox(_res, "asAdminChckBox", 9, defVisStyleBackCol, "As Admin", new Point(30, 317), new Size(77, 19), margin: new Padding(30, 10, 3, 3));
            remGuardChckBox        = new BaseCheckBox(_res, "remGuardChckBox", 10, defVisStyleBackCol, "Remote Guard", new Point(30, 349), new Size(107, 19), margin: new Padding(30, 10, 3, 3));
            restrictedAdminChckBox = new BaseCheckBox(_res, "restrictedAdminChckBox", 15, defVisStyleBackCol, "As Restricted Admin", new Point(30, 381), new Size(135, 19), margin: new Padding(30, 10, 3, 3));
            fullScreenChckBox      = new BaseCheckBox(_res, "fullScreenChckBox", 19, defVisStyleBackCol, "Start Fullscreen", new Point(10, 15), new Size(111, 19), margin: new Padding(10, 15, 3, 3));
            multiMonitorChckBox    = new BaseCheckBox(_res, "multiMonitorChckBox", 20, defVisStyleBackCol, "Multi Monitor Mode", new Point(10, 40), new Size(133, 19), margin: new Padding(10, 3, 3, 3));
            spanMonitorsChckBox    = new BaseCheckBox(_res, "spanMonitorsChckBox", 21, defVisStyleBackCol, "Span Monitors Mode", new Point(10, 65), new Size(141, 19), margin: new Padding(10, 3, 3, 3));
            rdpCredsHelpBtn        = new BaseButton(_res, "rdpCredsHelpBtn", 16, visStyleBackColor: defVisStyleBackCol, point: new Point(174, 458), margin: new Padding(174, 55, 3, 3), size: new Size(40, 23));
            recheckConnBtn         = new BaseButton(_res, "recheckConnBtn", 9, visStyleBackColor: defVisStyleBackCol, point: new Point(33, 228), size: new Size(120, 23), text: "Recheck Connection");
            editCrntBtn            = new BaseButton(_res, "editCrntBtn", 6, visStyleBackColor: defVisStyleBackCol, point: new Point(33, 190), size: new Size(75, 23), text: "Edit");
            delCrntBtn             = new BaseButton(_res, "delCrntBtn", 5, visStyleBackColor: defVisStyleBackCol, point: new Point(33, 161), size: new Size(75, 23), text: "Delete");
            connectCrntBtn         = new BaseButton(_res, "connectCrntBtn", 4, visStyleBackColor: defVisStyleBackCol, point: new Point(33, 129), size: new Size(75, 23), text: "Connect To");
            refreshRdpsBtn         = new BaseButton(_res, "refreshRdpBtn", 3, visStyleBackColor: defVisStyleBackCol, point: new Point(237, 57), size: new Size(60, 23), text: "Refresh");
            saveNUpdtBtn           = new BaseButton(_res, "saveNUpdtBtn", visStyleBackColor: defVisStyleBackCol, point: new Point(19, 10), margin: new Padding(19, 10, 3, 3), size: new Size(110, 23), text: "Save / Update");
            saveToRdpFileBtn       = new BaseButton(_res, "saveToRdpFileBtn", 5, visStyleBackColor: defVisStyleBackCol, point: new Point(19, 46), margin: new Padding(19, 10, 3, 3), size: new Size(110, 23), text: "Save as .RDP");
            saveToXmlBtn           = new BaseButton(_res, "saveToXmlBtn", 4, visStyleBackColor: defVisStyleBackCol, point: new Point(19, 82), margin: new Padding(19, 10, 3, 3), size: new Size(110, 23), text: "Save as .XML");
            connGivenBtn           = new BaseButton(_res, "connGivenBtn", 2, visStyleBackColor: defVisStyleBackCol, point: new Point(19, 118), margin: new Padding(19, 10, 3, 3), size: new Size(110, 23), text: "Quick Connect");
            resetBtn               = new BaseButton(_res, "resetBtn", 1, visStyleBackColor: defVisStyleBackCol, point: new Point(19, 154), margin: new Padding(19, 10, 3, 3), size: new Size(110, 23), text: "Reset To Defaults");
            screenSettingsHelpBtn  = new BaseButton(_res, "screenSettingsHelpBtn", 3, visStyleBackColor: defVisStyleBackCol, point: new Point(88, 185), margin: new Padding(88, 5, 3, 3), size: new Size(40, 23), text: "Help!");
            isMstcRunningImgBox    = new BasePicBox(_res, "isMstcRunningImgBox", 7, new Point(191, 161), new Size(106, 90));
            savedRdpsResults       = new BaseComboBox(_res, "savedRdpsResults", 2, new Point(33, 59), new Size(181, 21));
            onlyRdpFilesRdio       = new BaseRadioButton(_res, "onlyRdpFilesRdio", text: "Only .RDP Files", autoSize: true, point: new Point(173, 25), size: new Size(125, 21), tabStop: true, visualStyleCol: true);
            #endregion

            #region Panels
            currentRdpsPnl = new BaseFlowPanel(_res, "currentRdpsPnl", 3, new Control[] { recheckConnBtn, connStatusLbl, isMstcRunningImgBox, editCrntBtn, delCrntBtn, connectCrntBtn, refreshRdpsBtn, savedRdpsResults, savedRdpsLbl, saveToRdpFileBtn, onlyRdpFilesRdio },
                                               new Point(276, 12), new Size(327, 264), borderStyle: BorderStyle.Fixed3D);
            screenSettingsHolderPnl = new BaseFlowPanel(_res, "screenSettingsHolderPnl", 4, new Control[] { rdpButtonsPnl, screenSettingsPnl }, new Point(276, 285), new Size(328, 225), borderStyle: BorderStyle.Fixed3D);
            connectionSettingsPnl   = new BaseFlowPanel(_res, "connectionSettingsPnl", controls: new Control[] { connLbl, connTxtBox, addressLbl, addressTxtBox, portLbl, portTxtBox, gatewayLbl, gatewayTxtBox, useGatewayChckBox, asAdminChckBox, remGuardChckBox, restrictedAdminChckBox, rdpCredsHelpBtn },
                                                        point: new Point(12, 12), size: new Size(244, 498), borderStyle: BorderStyle.Fixed3D, flow: FlowDirection.TopDown);
            rdpButtonsPnl     = new BaseFlowPanel(_res, "rdpButtonsPnl", 1, new Control[] { saveNUpdtBtn, saveToRdpFileBtn, saveToXmlBtn, connGivenBtn, resetBtn, screenSettingsHelpBtn }, new Point(173, 3), new Size(148, 215));
            screenSettingsPnl = new BaseFlowPanel(_res, "screenSettingsPnl", controls: new Control[] { fullScreenChckBox, multiMonitorChckBox, spanMonitorsChckBox, screenWidthLbl, screenWidthTxtBox, screenHeightLbl, screenHeightTxtBox }, point: new Point(3, 3), size: new Size(164, 215));
            #endregion

            ((System.ComponentModel.ISupportInitialize)(isMstcRunningImgBox)).BeginInit();
            SuspendLayout();
            InitRdp();
        }
Esempio n. 8
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>

        private void InitializeComponent()
        {
            #region Controls
            var regularBtnSize       = new Size(80, 23);
            var largeBtnSize         = new Size(120, 23);
            var defaultButtonPadding = new Padding(60, 10, 0, 5);
            var defTxtBoxPoint       = new Point(6, 57);
            var defTxtBoxSize        = new Size(135, 21);
            var defLblPoint          = new Point(3, 29);
            var defComboPoint        = new Point(6, 57);
            var defComboSize         = new Size(135, 21);
            var defPanelSize         = new Size(150, 100);

            selectConnBtn       = new BaseButton(_res, "selectConnBtn", visStyleBackColor: true, point: new Point(60, 20), margin: new Padding(60, 20, 0, 5), size: regularBtnSize, text: "Connect to Selected");
            selectEditBtn       = new BaseButton(_res, "selectEditBtn", visStyleBackColor: true, point: new Point(60, 58), margin: defaultButtonPadding, size: regularBtnSize, text: "Edit");
            selectRmvBtn        = new BaseButton(_res, "selectRmvBtn", visStyleBackColor: true, point: new Point(60, 96), margin: defaultButtonPadding, size: regularBtnSize, text: "Remove");
            vpnHelpBtn          = new BaseButton(_res, "vpnHelpBtn", 3, visStyleBackColor: true, point: new Point(100, 139), margin: new Padding(100, 15, 0, 5), size: regularBtnSize, text: "Help!");
            clearValsBtn        = new BaseButton(_res, "clearValsBtn", 5, visStyleBackColor: true, point: new Point(132, 96), size: new Size(120, 23), text: "Clear Values");
            saveConnBtn         = new BaseButton(_res, "saveConnBtn", 3, visStyleBackColor: true, point: new Point(74, 136), size: largeBtnSize, text: "Save and Connect");
            saveVpnNewBtn       = new BaseButton(_res, "saveVpnNewBtn", visStyleBackColor: true, point: new Point(6, 96), size: largeBtnSize, text: "Save New / Edited");
            vpnsTxtBox          = new BaseTextBox(_res, "vpnsTxtBox", 1, defTxtBoxPoint, defTxtBoxSize);
            vpnNameTxtBox       = new BaseTextBox(_res, "vpnNameTxtBox", 1, defTxtBoxPoint, defTxtBoxSize);
            selectedInfoTxtBox  = new BaseRichTextBox(_res, "selectedInfoTxtBox", 1, SystemColors.MenuText, Color.YellowGreen, new Point(6, 31), new Size(212, 134));
            selectedsLbl        = new BaseLabel(_res, "selectedsLbl", point: new Point(3, 10), size: new Size(108, 18), text: "Selected\'s Info:");
            currentVpnsLbl      = new BaseLabel(_res, "currentVpnsLbl", point: defLblPoint, size: new Size(103, 18), text: "Current VPNs:");
            nameVpnLbl          = new BaseLabel(_res, "nameVpnLbl", point: defLblPoint, size: new Size(52, 18), text: "Name:");
            addressVpnLbl       = new BaseLabel(_res, "addressVpnLbl", point: defLblPoint, size: new Size(66, 18), text: "Address:");
            ttypeVpnLbl         = new BaseLabel(_res, "tTypeVpnLbl", point: defLblPoint, size: new Size(92, 18), text: "Tunnel Type:");
            encryptLvlVpnLbl    = new BaseLabel(_res, "encryptLvlVpnLbl", point: defLblPoint, size: new Size(120, 18), text: "Encryption LEvel:");
            authMetLbl          = new BaseLabel(_res, "authMetLbl", point: defLblPoint, size: new Size(99, 18), text: "Auth. Method:");
            currentVpnsComBox   = new BaseComboBox(_res, "currentVpnsCombox", 2, defComboPoint, defComboSize);
            tTypeSelectCombBox  = new BaseComboBox(_res, "tTypeSelectComBox", 1, defComboPoint, defComboSize);
            encryLvlCombBox     = new BaseComboBox(_res, "encrLvlComBox", 2, defComboPoint, defComboSize);
            authMetCombBox      = new BaseComboBox(_res, "authMetComBox", 2, defComboPoint, defComboSize);
            availForAllCheckBox = new BaseCheckBox(_res, "availForAllCheckBox", visStyleBackColor: true, text: "Available for All Users", point: new Point(5, 67), size: new Size(169, 22));
            splitTunCheckBox    = new BaseCheckBox(_res, "splitTunCheckBox", visStyleBackColor: true, text: "Split Tunnel:", point: new Point(6, 17), size: new Size(103, 22));
            #endregion

            #region Panels
            bottomInfosPnl = new BaseFlowPanel(_res, "bottomInfosPnl", 2, new Control[] { currOpersPnl, currInfoPnl, currPnl }, new Point(12, 335), new Size(590, 175), borderStyle: BorderStyle.Fixed3D);
            currOpersPnl   = new BaseFlowPanel(_res, "currOpersPnl", 6, new Control[] { selectConnBtn, selectEditBtn, selectRmvBtn, vpnHelpBtn }, new Point(383, 3), new Size(200, 170), flow: FlowDirection.TopDown);
            vpnSettingsPnl = new BaseFlowPanel(_res, "vpnSettingsPnl", 3, new Control[] { namePnl, addressPnl, tunnelPnl, encryptionPnl, authPnl, btnsTopPnl }, new Point(12, 12), new Size(590, 306));
            currInfoPnl    = new BasePanel(_res, "currInfoPnl", 5, new Control[] { selectedInfoTxtBox, selectedsLbl }, new Point(150, 3), new Size(231, 170));
            currPnl        = new BasePanel(_res, "currPnl", 4, new Control[] { currentVpnsComBox, currentVpnsLbl }, new Point(3, 3), new Size(150, 170));
            namePnl        = new BasePanel(_res, "namePnl", 2, new Control[] { vpnsTxtBox, nameVpnLbl }, new Point(3, 3), defPanelSize);
            addressPnl     = new BasePanel(_res, "addressPnl", 0, new Control[] { vpnNameTxtBox, addressVpnLbl }, new Point(159, 3), defPanelSize);
            tunnelPnl      = new BasePanel(_res, "tunnelPnl", 2, new Control[] { tTypeSelectCombBox, ttypeVpnLbl }, new Point(315, 3), defPanelSize);
            encryptionPnl  = new BasePanel(_res, "encryptionPnl", 3, new Control[] { encryLvlCombBox, encryptLvlVpnLbl }, new Point(3, 109), defPanelSize);
            authPnl        = new BasePanel(_res, "authPnl", 4, new Control[] { authMetCombBox, authMetLbl }, new Point(159, 109), defPanelSize);
            btnsTopPnl     = new BasePanel(_res, "btnSopPnl", 5, new Control[] { clearValsBtn, saveConnBtn, saveVpnNewBtn, availForAllCheckBox, splitTunCheckBox }, new Point(315, 109), new Size(270, 197));
            #endregion

            SuspendLayout();
            InitVpnElements();
        }
Esempio n. 9
0
 private void loadLblLogin()
 {
     this.lblLogin = new BaseLabel(
         "lblLogin",
         "Login:",
         Brushes.White,
         VerticalAlignment.Bottom,
         HorizontalAlignment.Left,
         false,
         BaseLabel.ButtonFontSize.Medium);
 }
Esempio n. 10
0
 private void loadLblUsuarioId()
 {
     this.lblUsuarioId = new BaseLabel(
         "lblUsuarioId",
         "ID:",
         Brushes.White,
         VerticalAlignment.Bottom,
         HorizontalAlignment.Right,
         false,
         BaseLabel.ButtonFontSize.Medium);
 }
Esempio n. 11
0
 private void loadTxtUsuarioId()
 {
     this.txtUsuarioId = new BaseLabel(
         "txtUsuarioId",
         "000000",
         Brushes.DarkBlue,
         VerticalAlignment.Bottom,
         HorizontalAlignment.Right,
         false,
         BaseLabel.ButtonFontSize.Medium);
 }
Esempio n. 12
0
        public void OnLabelProcessed(BaseLabel label)
        {
            if (label is VesselLabel vesselLabel)
            {
                var vessel = vesselLabel.vessel;
                var owner  = LockSystem.LockQuery.GetControlLockOwner(vessel.id);

                if (!string.IsNullOrEmpty(owner))
                {
                    label.text.text = $"{owner}\n{label.text.text}";
                }
            }
        }
Esempio n. 13
0
        private void loadLblViewName()
        {
            this.lblViewName = new BaseLabel(
                "lblViewName",
                "Cadastro de Usuário",
                Brushes.White,
                VerticalAlignment.Center,
                HorizontalAlignment.Center,
                false,
                BaseLabel.ButtonFontSize.Large);

            this.addChildren(ref this.lblViewName, null, 0);
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            #region Controls
            var anchorForBtn = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                                                                     | System.Windows.Forms.AnchorStyles.Right)));
            var defVisStlye        = true;
            var defButtonPadding   = new Padding(3, 10, 0, 0);
            var defButtonSize      = new Size(120, 30);
            var defTextBoxSize     = new Size(194, 20);
            var defCheckBoxPadding = new Padding(5, 25, 0, 0);

            passwordTxtBox     = new BaseTextBox(_res, "passwordTxtBox", 7, new Point(3, 111), defTextBoxSize);
            usernameTxtBox     = new BaseTextBox(_res, "usernameTxtBox", 5, new Point(3, 90), defTextBoxSize);
            emailAddConfTxtBox = new BaseTextBox(_res, "emailAddConfTxtBox", 12, new Point(3, 113), defTextBoxSize);
            emailAddTxtBox     = new BaseTextBox(_res, "emailAddTxtBox", 10, new Point(6, 33), defTextBoxSize);
            gpgTxtBox          = new BaseTextBox(_res, "gpgTxtBox", 9, new Point(3, 191), new Size(194, 20));
            usernameLbl        = new BaseLabel(_res, "usernameLbl", 4, new Point(3, 10), new Size(81, 18), "Username", autoSize: true);
            gpgLbl             = new BaseLabel(_res, "gpgLbl", 8, new Point(5, 170), new Size(73, 18), "PGP Key:", autoSize: true);
            passwordLbl        = new BaseLabel(_res, "passwordLbl", 6, new Point(3, 90), new Size(79, 18), "Password:"******"emailAddConfLbl", 11, new Point(2, 92), new Size(65, 18), "Confirm:", autoSize: true);
            emailAddLbl        = new BaseLabel(_res, "emailAddLbl", 10, new Point(3, 12), new Size(147, 18), "Your E-Mail Address:", autoSize: true);
            helpBtn            = new BaseButton(_res, "helpBtn", 15, visStyleBackColor: defVisStlye, point: new Point(494, 113), margin: defButtonPadding, size: new Size(70, 30), text: "Help!");
            setEmailBtn        = new BaseButton(_res, "setEmailBtn", 14, visStyleBackColor: defVisStlye, point: new Point(494, 24), margin: defButtonPadding, size: new Size(70, 29), text: "Set Email");
            reloadStngsBtn     = new BaseButton(_res, "reloadStngsBtn", 5, visStyleBackColor: defVisStlye, point: new Point(3, 90), margin: defButtonPadding, size: defButtonSize, text: "Reload Settings");
            saveStngsBtn       = new BaseButton(_res, "saveStngsBtn", 6, visStyleBackColor: defVisStlye, point: new Point(3, 50), margin: defButtonPadding, size: defButtonSize, text: "Save Settings");
            loadStngsBtn       = new BaseButton(_res, "loadStngsBtn", 7, visStyleBackColor: defVisStlye, point: new Point(3, 10), margin: defButtonPadding, size: defButtonSize, text: "Load Settings", anchor: anchorForBtn);
            setUserinfoBtn     = new BaseButton(_res, "setUserinfoBtn", 15, visStyleBackColor: defVisStlye, point: new Point(114, 251), margin: defButtonPadding, size: new Size(83, 29), text: "Set User Info");
            useRecommBtn       = new BaseButton(_res, "useRecommBtn", 8, visStyleBackColor: defVisStlye, point: new Point(3, 130), margin: defButtonPadding, size: defButtonSize, text: "Use Recommended");
            addUserBtn         = new BaseButton(_res, "addUserBtn", 9, visStyleBackColor: defVisStlye, point: new Point(3, 170), margin: defButtonPadding, size: defButtonSize, text: "Add User");
            removeUserBtn      = new BaseButton(_res, "removeUserBtn", 10, visStyleBackColor: defVisStlye, point: new Point(3, 210), margin: defButtonPadding, size: defButtonSize, text: "Remove User");
            wipeAllnRemoveBtn  = new BaseButton(_res, "wipeAllnRemoveBtn", 11, visStyleBackColor: defVisStlye, point: new Point(3, 250), margin: defButtonPadding, size: defButtonSize, text: "Wipe Everything");
            autoLoginCheck     = new BaseCheckBox(_res, "autoLoginCheck", 1, defVisStlye, "Log In Automatically", new Point(5, 25), new Size(135, 19), margin: defCheckBoxPadding);
            doNotSaveCheck     = new BaseCheckBox(_res, "doNotSaveCheck", 2, defVisStlye, "Do Not Save Data", new Point(5, 69), new Size(123, 19), margin: defCheckBoxPadding);
            wipeDataQuitCheck  = new BaseCheckBox(_res, "wipeDataQuitCheck", visStyleBackColor: defVisStlye, text: "Wipe Data on Quit", point: new Point(5, 113), size: new Size(125, 19), margin: defCheckBoxPadding);
            resetSysDefsCheck  = new BaseCheckBox(_res, "resetSysDefsCheck", 3, defVisStlye, "Reset To Sys Defaults on Quit", new Point(5, 157), new Size(187, 19), margin: defCheckBoxPadding);
            alwaysPGPCheck     = new BaseCheckBox(_res, "alwaysPGPCheck", 4, defVisStlye, "Always Use PGP", new Point(5, 201), new Size(116, 19), margin: defCheckBoxPadding);
            sendRepEmailCheck  = new BaseCheckBox(_res, "sendRepEmailCheck", 5, defVisStlye, "Send Reports to Email", new Point(5, 245), new Size(149, 19), margin: defCheckBoxPadding);
            forcePGPEmailCheck = new BaseCheckBox(_res, "forcePGPEmailCheck", 13, defVisStlye, "Force PGP in Email", new Point(277, 72), new Size(133, 19), margin: defCheckBoxPadding);
            #endregion

            #region Panels
            emailPnl          = new BasePanel(_res, "emailPnl", 13, new Control[] { helpBtn, setEmailBtn, forcePGPEmailCheck, emailAddConfTxtBox, emailAddConfLbl, emailAddTxtBox, emailAddLbl }, new Point(12, 342), new Size(573, 168));
            userinfoPnl       = new BasePanel(_res, "userinfoPnl", 1, new Control[] { setUserinfoBtn, gpgTxtBox, gpgLbl, passwordTxtBox, passwordLbl, usernameTxtBox, usernameLbl }, new Point(255, 12), new Size(207, 300));
            settingsBtnsPnl   = new BaseFlowPanel(_res, "settingsBtnsPnl", 6, new Control[] { loadStngsBtn, saveStngsBtn, reloadStngsBtn, useRecommBtn, addUserBtn, removeUserBtn, wipeAllnRemoveBtn }, new Point(453, 12), new Size(132, 300), BorderStyle.Fixed3D, anchor: AnchorStyles.Top);
            checkBoxLayoutPnl = new BaseFlowPanel(_res, "checkBoxLayoutPnl", 12, new Control[] { autoLoginCheck, doNotSaveCheck, wipeDataQuitCheck, resetSysDefsCheck, alwaysPGPCheck, sendRepEmailCheck }, new Point(12, 12), new Size(192, 300), BorderStyle.Fixed3D, anchor: AnchorStyles.Top);
            #endregion

            SuspendLayout();
            InitSettings();
        }
Esempio n. 15
0
        public static BaseLabel getObjectLabel(string labelName)
        {
            BaseLabel label = null;

            switch (labelName.ToUpper())
            {
            case "F4005":

                break;

            default:
                break;
            }
            return(label);
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            #region Controls
            var defButtonSize     = new Size(80, 23);
            var defTextBoxSize    = new Size(140, 20);
            var defTextBoxPadding = new Padding(40, 5, 3, 3);
            var defLabelPadding   = new Padding(40, 20, 3, 0);

            saveProxyBtn         = new BaseButton(_res, "saveProxyBtn", 8, visStyleBackColor: true, point: new Point(50, 336), margin: new Padding(50, 30, 3, 3), size: new Size(120, 23), text: "Save to File");
            saveNConnectProxyBtn = new BaseButton(_res, "saveNConnectProxyBtn", 9, visStyleBackColor: true, point: new Point(50, 382), margin: new Padding(50, 20, 3, 3), size: new Size(120, 23), text: "Save and Connect");
            proxyHelpBtn         = new BaseButton(_res, "proxyHelpBtn", 13, visStyleBackColor: true, point: new Point(140, 458), margin: new Padding(140, 50, 3, 3), size: new Size(60, 23), text: "Help!");
            connectToSavedBtn    = new BaseButton(_res, "connectToSavedBtn", 2, visStyleBackColor: true, point: new Point(70, 320), margin: new Padding(70, 20, 70, 3), size: new Size(80, 23), text: "Connect To");
            editSavedBtn         = new BaseButton(_res, "editSavedBtn", 3, visStyleBackColor: true, point: new Point(70, 361), margin: new Padding(70, 15, 70, 3), size: new Size(80, 23), text: "Edit");
            deleteSavedBtn       = new BaseButton(_res, "deleteSavedBtn", 4, visStyleBackColor: true, point: new Point(70, 402), margin: new Padding(70, 15, 70, 3), size: new Size(80, 23), text: "Delete");
            selectTextFileBtn    = new BaseButton(_res, "selectTextFileBtn", visStyleBackColor: true, point: new Point(20, 78), margin: new Padding(20, 40, 20, 3), size: new Size(100, 23), text: "Select Text File");
            helpImportBtn        = new BaseButton(_res, "helpImportBtn", 2, visStyleBackColor: true, point: new Point(30, 119), margin: new Padding(30, 15, 30, 3), size: new Size(80, 23), text: "Help!");
            ipAddyLbl            = new BaseLabel(_res, "ipAddyLbl", 0, new Point(40, 20), new Size(83, 18), "IP Address:", autoSize: true, padding: defLabelPadding);
            portLbl             = new BaseLabel(_res, "portLbl", 11, new Point(40, 86), new Size(40, 18), "Port:", autoSize: true, padding: defLabelPadding);
            passLbl             = new BaseLabel(_res, "passLbl", 4, new Point(40, 218), new Size(79, 18), "Password:"******"uNameLbl", 2, new Point(40, 152), new Size(81, 18), "Username:"******"proxyInfoLbl", 6, new Point(10, 92), new Size(114, 18), "Info of Selected:", autoSize: true, padding: new Padding(10, 20, 10, 0));
            savedProxiesLbl     = new BaseLabel(_res, "savedProxiesLbl", 5, new Point(10, 20), new Size(107, 18), "Saved Proxies:", autoSize: true, padding: new Padding(10, 20, 3, 0));
            importProxiesLbl    = new BaseLabel(_res, "importProxiesLbl", 1, new Point(18, 20), new Size(104, 18), "Import Proxies", autoSize: true, padding: new Padding(18, 20, 0, 0));
            ipAddyTxtBox        = new BaseTextBox(_res, "ipAddyTxtBox", 1, new Point(40, 43), defTextBoxSize, padding: defTextBoxPadding);
            portTxtBox          = new BaseTextBox(_res, "portTxtBox", 12, new Point(40, 109), defTextBoxSize, padding: defTextBoxPadding);
            uNameTxtBox         = new BaseTextBox(_res, "uNameTxtBox", 3, new Point(40, 175), defTextBoxSize, padding: defTextBoxPadding);
            passTextBox         = new BaseTextBox(_res, "passTextBox", 5, new Point(40, 241), defTextBoxSize, padding: defTextBoxPadding);
            authReqChckBox      = new BaseCheckBox(_res, "authReqChckBox", 10, true, "Authorization Required", new Point(40, 284), new Size(151, 19), margin: new Padding(40, 20, 3, 3));
            savedProxiesCombBox = new BaseComboBox(_res, "savedProxiesCombBox", 1, new Point(10, 48), new Size(180, 21), new Padding(10, 10, 3, 3));
            proxyInfoTxtBox     = new BaseRichTextBox(_res, "proxyInfoTxtBox", 0, SystemColors.MenuText, Color.GreenYellow, new Point(10, 120), new Size(200, 177), margin: new Padding(10, 10, 10, 3));
            #endregion

            #region Panels
            importProxiesPnl = new BaseFlowPanel(_res, "importProxiesPnl", 1, new Control[] { importProxiesLbl, selectTextFileBtn, helpImportBtn }, new Point(12, 12), new Size(140, 498), borderStyle: BorderStyle.Fixed3D, flow: FlowDirection.TopDown);
            savedProxiesPnl  = new BaseFlowPanel(_res, "savedProxiesPnl", 1, new Control[] { savedProxiesLbl, savedProxiesCombBox, proxyInfoLbl, proxyInfoTxtBox, connectToSavedBtn, editSavedBtn, deleteSavedBtn }, new Point(158, 12), new Size(220, 498), borderStyle: BorderStyle.Fixed3D, flow: FlowDirection.TopDown);
            addNewProxyPnl   = new BaseFlowPanel(_res, "addNewProxyPnl", 0, new Control[] { ipAddyLbl, ipAddyTxtBox, portLbl, portTxtBox, uNameLbl, uNameTxtBox, passLbl, passTextBox, authReqChckBox, saveProxyBtn, saveNConnectProxyBtn, proxyHelpBtn },
                                                 new Point(384, 12), new Size(220, 498), borderStyle: BorderStyle.Fixed3D, flow: FlowDirection.TopDown);
            #endregion

            SuspendLayout();
            InitProxy();
        }
Esempio n. 17
0
        public void addChildren(ref BaseLabel lblChildren, int?intX = null, int?intY = null)
        {
            try
            {
                if (!intX.Equals(null))
                {
                    Grid.SetColumn(lblChildren, Convert.ToInt32(intX));
                }
                if (!intY.Equals(null))
                {
                    Grid.SetRow(lblChildren, Convert.ToInt32(intY));
                }

                this.Children.Add(lblChildren);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 18
0
        //private static LineString ReverseLineString(LineString clippedLineString)
        //{
        //    var coords = new Stack<Point>(clippedLineString.Vertices);
        //    return new LineString(coords.ToArray());
        //}

        ///// <summary>
        ///// Function to transform a linestring to a graphics path for further processing
        ///// </summary>
        ///// <param name="multiLineString">The Linestring</param>
        ///// <param name="map">The map</param>
        ///// <param name="useClipping">A value indicating whether clipping should be applied or not</param>
        ///// <returns>A GraphicsPath</returns>
        //public static GraphicsPath MultiLineStringToPath(MultiLineString multiLineString, Map map, bool useClipping)
        //{
        //    var gp = new GraphicsPath(FillMode.Alternate);
        //    foreach (var lineString in multiLineString.LineStrings)
        //        gp.AddPath(LineStringToPath(lineString, map, useClipping), false);

        //    return gp;
        //}

        //private static GraphicsPath LineToGraphicsPath(LineString line, Map map)
        //{
        //    GraphicsPath path = new GraphicsPath();
        //    path.AddLines(line.TransformToImage(map));
        //    return path;
        //}

        private static void CalculateLabelOnLinestring(ILineString line, ref BaseLabel baseLabel, Map map)
        {
            double dx, dy;
            var    label = baseLabel as Label;

            // first find the middle segment of the line
            var vertices = line.Coordinates;
            int midPoint = (vertices.Length - 1) / 2;

            if (vertices.Length > 2)
            {
                dx = vertices[midPoint + 1].X - vertices[midPoint].X;
                dy = vertices[midPoint + 1].Y - vertices[midPoint].Y;
            }
            else
            {
                midPoint = 0;
                dx       = vertices[1].X - vertices[0].X;
                dy       = vertices[1].Y - vertices[0].Y;
            }
            if (dy == 0)
            {
                label.Rotation = 0;
            }
            else if (dx == 0)
            {
                label.Rotation = 90;
            }
            else
            {
                // calculate angle of line
                double angle = -Math.Atan(dy / dx) + Math.PI * 0.5;
                angle         *= (180d / Math.PI);  // convert radians to degrees
                label.Rotation = (float)angle - 90; // -90 text orientation
            }
            var tmpx = vertices[midPoint].X + (dx * 0.5);
            var tmpy = vertices[midPoint].Y + (dy * 0.5);

            label.Location = map.WorldToImage(new Coordinate(tmpx, tmpy));
        }
Esempio n. 19
0
        private List <BaseLabel> CreateLabelDefinitions(Graphics g, MapViewport map, FeatureDataTable features)
        {
            var labels  = new List <BaseLabel>();
            var factory = new GeometryFactory();

            for (int i = 0; i < features.Count; i++)
            {
                var feature = features[i];

                LabelStyle style;
                if (Theme != null) //If thematics is enabled, lets override the style
                {
                    style = Theme.GetStyle(feature) as LabelStyle;
                }
                else
                {
                    style = Style;
                }

                // Do we need to render at all?
                if (!style.Enabled)
                {
                    continue;
                }

                // Rotation
                float rotationStyle  = style != null ? style.Rotation : 0f;
                float rotationColumn = 0f;
                if (!String.IsNullOrEmpty(RotationColumn))
                {
                    Single.TryParse(feature[RotationColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
                                    out rotationColumn);
                }
                float rotation = rotationStyle + rotationColumn;

                // Priority
                int priority = Priority;
                if (_getPriorityMethod != null)
                {
                    priority = _getPriorityMethod(feature);
                }
                else if (!String.IsNullOrEmpty(PriorityColumn))
                {
                    Int32.TryParse(feature[PriorityColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
                                   out priority);
                }

                // Text
                string text;
                if (_getLabelMethod != null)
                {
                    text = _getLabelMethod(feature);
                }
                else
                {
                    text = feature[LabelColumn].ToString();
                }

                if (String.IsNullOrEmpty(text))
                {
                    continue;
                }

                // Geometry
                feature.Geometry = ToTarget(feature.Geometry);

                // for lineal geometries, clip to ensure proper labeling
                if (feature.Geometry is ILineal)
                {
                    feature.Geometry = ClipLinealGeomToViewExtents(map, feature.Geometry);
                }

                if (feature.Geometry is IPolygonal)
                {
                    // TO CONSIDER clip to ViewExtents?
                    // This will ensure that polygons only partly in view will be labelled
                    // but perhaps need complexity threshold (eg Pts < 500) so as not to impact rendering
                    // or new prop bool PartialPolygonalLabel
                }

                if (feature.Geometry is IGeometryCollection geoms)
                {
                    if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.All)
                    {
                        for (int j = 0; j < geoms.Count; j++)
                        {
                            var lbl = CreateLabelDefinition(feature, geoms.GetGeometryN(j), text, rotation,
                                                            priority, style, map, g, _getLocationMethod);
                            if (lbl != null)
                            {
                                labels.Add(lbl);
                            }
                        }
                    }
                    else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.CommonCenter)
                    {
                        if (geoms.NumGeometries > 0)
                        {
                            var    pt           = geoms.Centroid;
                            double closest      = double.MaxValue;
                            int    idxOfClosest = 0;
                            for (int j = 0; j < geoms.NumGeometries; j++)
                            {
                                var    geom = geoms.GetGeometryN(j);
                                double dist = geom.Distance(pt);
                                if (dist < closest)
                                {
                                    closest      = dist;
                                    idxOfClosest = j;
                                }
                            }

                            var lbl = CreateLabelDefinition(feature, geoms.GetGeometryN(idxOfClosest), text,
                                                            rotation, priority, style, map, g, _getLocationMethod);
                            if (lbl != null)
                            {
                                labels.Add(lbl);
                            }
                        }
                    }
                    else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.First)
                    {
                        if (geoms.NumGeometries > 0)
                        {
                            var lbl = CreateLabelDefinition(feature, geoms.GetGeometryN(0), text,
                                                            rotation, priority, style, map, g, _getLocationMethod);
                            if (lbl != null)
                            {
                                labels.Add(lbl);
                            }
                        }
                    }
                    else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.Largest)
                    {
                        if (geoms.NumGeometries > 0)
                        {
                            double largestVal   = 0d;
                            int    idxOfLargest = 0;
                            for (var j = 0; j < geoms.NumGeometries; j++)
                            {
                                var geom = geoms.GetGeometryN(j);
                                if (geom is ILineString lineString && lineString.Length > largestVal)
                                {
                                    largestVal   = lineString.Length;
                                    idxOfLargest = j;
                                }
                                if (geom is IMultiLineString multiLineString && multiLineString.Length > largestVal)
                                {
                                    largestVal   = multiLineString.Length;
                                    idxOfLargest = j;
                                }
                                if (geom is IPolygon polygon && polygon.Area > largestVal)
                                {
                                    largestVal   = polygon.Area;
                                    idxOfLargest = j;
                                }
                                if (geom is IMultiPolygon multiPolygon && multiPolygon.Area > largestVal)
                                {
                                    largestVal   = multiPolygon.Area;
                                    idxOfLargest = j;
                                }
                            }

                            var lbl = CreateLabelDefinition(feature, geoms.GetGeometryN(idxOfLargest), text, rotation, priority, style,
                                                            map, g, _getLocationMethod);
                            if (lbl != null)
                            {
                                labels.Add(lbl);
                            }
                        }
                    }
                }
                else
                {
                    BaseLabel lbl = CreateLabelDefinition(feature, feature.Geometry, text, rotation, priority, style, map, g, _getLocationMethod);
                    if (lbl != null)
                    {
                        labels.Add(lbl);
                    }
                }
            }

            return(labels);
        }
Esempio n. 20
0
        private static void CalculateLabelAroundOnLineString(SharpMap.Geometries.LineString line, ref BaseLabel label, Map map, System.Drawing.Graphics g, System.Drawing.SizeF textSize)
        {
            IList<SharpMap.Geometries.Point> sPoints = line.Vertices;

            // only get point in enverlop of map
            Collection<System.Drawing.PointF> colPoint = new Collection<System.Drawing.PointF>();
            bool bCheckStarted = false;
            for (int j = 0; j < sPoints.Count; j++)
            {
                if (map.Envelope.Grow(map.PixelSize * 10).Contains(sPoints[j]))
                {
                    //points[j] = map.WorldToImage(sPoints[j]);
                    colPoint.Add(map.WorldToImage(sPoints[j]));
                    bCheckStarted = true;
                }
                else if (bCheckStarted == true)
                {
                    // fix bug curved line out of map in center segment of line
                    break;
                }
            }

            if (colPoint.Count > 1)
            {
                label.TextOnPathLabel = new SharpMap.Rendering.TextOnPath();
                switch (label.Style.HorizontalAlignment)
                {
                    case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left:
                        label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Left;
                        break;
                    case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Right:
                        label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Right;
                        break;
                    case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center:
                        label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                        break;
                    default:
                        label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                        break;
                }
                switch (label.Style.VerticalAlignment)
                {
                    case SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom:
                        label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.UnderPath;
                        break;
                    case SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Top:
                        label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.OverPath;
                        break;
                    case SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Middle:
                        label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.CenterPath;
                        break;
                    default:
                        label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.CenterPath;
                        break;
                }
                int idxStartPath = 0;
                int numberPoint = colPoint.Count;
                // start Optimzes Path points                
                int step = 100;
                if (colPoint.Count >= step * 2)
                {
                    numberPoint = step * 2; ;
                    switch (label.Style.HorizontalAlignment)
                    {
                        case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left:
                            //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Left;
                            idxStartPath = 0;
                            break;
                        case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Right:
                            //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Right;
                            idxStartPath = colPoint.Count - step;
                            break;
                        case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center:
                            //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                            idxStartPath = (int)colPoint.Count / 2 - step;
                            break;
                        default:
                            //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                            idxStartPath = (int)colPoint.Count / 2 - step;
                            break;
                    }
                }
                // end optimize path point
                System.Drawing.PointF[] points = new System.Drawing.PointF[numberPoint];
                int count = 0;
                if (colPoint[0].X <= colPoint[colPoint.Count - 1].X)
                {
                    for (int l = idxStartPath; l < numberPoint + idxStartPath; l++)
                    {
                        points[count] = colPoint[l];
                        count++;
                    }
                }
                else
                {
                    //reverse the path                    
                    for (int k = numberPoint - 1 + idxStartPath; k >= idxStartPath; k--)
                    {
                        points[count] = colPoint[k];
                        count++;
                    }
                }
                //get text size in page units ie pixels
                float textheight = label.Style.Font.Size;
                switch (label.Style.Font.Unit)
                {
                    case System.Drawing.GraphicsUnit.Display:
                        textheight = textheight * g.DpiY / 75;
                        break;
                    case System.Drawing.GraphicsUnit.Document:
                        textheight = textheight * g.DpiY / 300;
                        break;
                    case System.Drawing.GraphicsUnit.Inch:
                        textheight = textheight * g.DpiY;
                        break;
                    case System.Drawing.GraphicsUnit.Millimeter:
                        textheight = (float)(textheight / 25.4 * g.DpiY);
                        break;
                    case System.Drawing.GraphicsUnit.Pixel:
                        //do nothing
                        break;
                    case System.Drawing.GraphicsUnit.Point:
                        textheight = textheight * g.DpiY / 72;
                        break;
                }
                System.Drawing.Font topFont = new System.Drawing.Font(label.Style.Font.FontFamily, textheight, label.Style.Font.Style);
                //
                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                path.AddLines(points);

                label.TextOnPathLabel.PathColorTop = System.Drawing.Color.Transparent;
                label.TextOnPathLabel.Text = label.Text;
                label.TextOnPathLabel.LetterSpacePercentage = 90;
                label.TextOnPathLabel.FillColorTop = new System.Drawing.SolidBrush(label.Style.ForeColor);
                label.TextOnPathLabel.Font = topFont;
                label.TextOnPathLabel.PathDataTop = path.PathData;
                label.TextOnPathLabel.Graphics = g;
                //label.TextOnPathLabel.ShowPath=true;
                //label.TextOnPathLabel.PathColorTop = System.Drawing.Color.YellowGreen;
                if (label.Style.Halo != null)
                {
                    label.TextOnPathLabel.ColorHalo = label.Style.Halo;
                }
                else
                {
                    label.TextOnPathLabel.ColorHalo = null;// new System.Drawing.Pen(label.Style.ForeColor, (float)0.5); 
                }
                path.Dispose();

                // MeasureString to get region
                label.TextOnPathLabel.MeasureString = true;
                label.TextOnPathLabel.DrawTextOnPath();
                label.TextOnPathLabel.MeasureString = false;
                // Get Region label for CollissionDetection here.
                System.Drawing.Drawing2D.GraphicsPath pathRegion = new System.Drawing.Drawing2D.GraphicsPath();

                if (label.TextOnPathLabel.RegionList.Count > 0)
                {
                    //int idxCenter = (int)label.TextOnPathLabel.PointsText.Count / 2;
                    //System.Drawing.Drawing2D.Matrix rotationMatrix = g.Transform.Clone();// new Matrix();
                    //rotationMatrix.RotateAt(label.TextOnPathLabel.Angles[idxCenter], label.TextOnPathLabel.PointsText[idxCenter]);
                    //if (label.TextOnPathLabel.PointsTextUp.Count > 0)
                    //{
                    //    for (int up = label.TextOnPathLabel.PointsTextUp.Count - 1; up >= 0; up--)
                    //    {
                    //        label.TextOnPathLabel.PointsText.Add(label.TextOnPathLabel.PointsTextUp[up]);
                    //    }

                    //}                 
                    pathRegion.AddRectangles(label.TextOnPathLabel.RegionList.ToArray());

                    // get box for detect colission here              
                    label.Box = new LabelBox(pathRegion.GetBounds());
                    //g.FillRectangle(System.Drawing.Brushes.YellowGreen, label.Box);
                }
                pathRegion.Dispose();
            }

        }
Esempio n. 21
0
        private static void CalculateLabelAroundOnLineString(ILineString line, ref BaseLabel label, Map map, IGraphics g, SizeF textSize)
        {
            var sPoints = line.Coordinates;

            // only get point in enverlop of map
            var colPoint      = new Collection <PointF>();
            var bCheckStarted = false;

            //var testEnvelope = map.Envelope.Grow(map.PixelSize*10);
            for (var j = 0; j < sPoints.Length; j++)
            {
                if (map.Envelope.Contains(sPoints[j]))
                {
                    //points[j] = map.WorldToImage(sPoints[j]);
                    colPoint.Add(map.WorldToImage(sPoints[j]));
                    bCheckStarted = true;
                }
                else if (bCheckStarted)
                {
                    // fix bug curved line out of map in center segment of line
                    break;
                }
            }

            if (colPoint.Count > 1)
            {
                label.TextOnPathLabel = new TextOnPath();
                switch (label.Style.HorizontalAlignment)
                {
                case LabelStyle.HorizontalAlignmentEnum.Left:
                    label.TextOnPathLabel.TextPathAlignTop = TextPathAlign.Left;
                    break;

                case LabelStyle.HorizontalAlignmentEnum.Right:
                    label.TextOnPathLabel.TextPathAlignTop = TextPathAlign.Right;
                    break;

                case LabelStyle.HorizontalAlignmentEnum.Center:
                    label.TextOnPathLabel.TextPathAlignTop = TextPathAlign.Center;
                    break;

                default:
                    label.TextOnPathLabel.TextPathAlignTop = TextPathAlign.Center;
                    break;
                }
                switch (label.Style.VerticalAlignment)
                {
                case LabelStyle.VerticalAlignmentEnum.Bottom:
                    label.TextOnPathLabel.TextPathPathPosition = TextPathPosition.UnderPath;
                    break;

                case LabelStyle.VerticalAlignmentEnum.Top:
                    label.TextOnPathLabel.TextPathPathPosition = TextPathPosition.OverPath;
                    break;

                case LabelStyle.VerticalAlignmentEnum.Middle:
                    label.TextOnPathLabel.TextPathPathPosition = TextPathPosition.CenterPath;
                    break;

                default:
                    label.TextOnPathLabel.TextPathPathPosition = TextPathPosition.CenterPath;
                    break;
                }

                var idxStartPath = 0;
                var numberPoint  = colPoint.Count;
                // start Optimzes Path points

                var step = 100;
                if (colPoint.Count >= step * 2)
                {
                    numberPoint = step * 2;;
                    switch (label.Style.HorizontalAlignment)
                    {
                    case LabelStyle.HorizontalAlignmentEnum.Left:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Left;
                        idxStartPath = 0;
                        break;

                    case LabelStyle.HorizontalAlignmentEnum.Right:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Right;
                        idxStartPath = colPoint.Count - step;
                        break;

                    case LabelStyle.HorizontalAlignmentEnum.Center:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                        idxStartPath = (int)colPoint.Count / 2 - step;
                        break;

                    default:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                        idxStartPath = (int)colPoint.Count / 2 - step;
                        break;
                    }
                }
                // end optimize path point
                var points = new PointF[numberPoint];
                var count  = 0;
                if (colPoint[0].X <= colPoint[colPoint.Count - 1].X)
                {
                    for (var l = idxStartPath; l < numberPoint + idxStartPath; l++)
                    {
                        points[count] = colPoint[l];
                        count++;
                    }
                }
                else
                {
                    //reverse the path
                    for (var k = numberPoint - 1 + idxStartPath; k >= idxStartPath; k--)
                    {
                        points[count] = colPoint[k];
                        count++;
                    }
                }
                //get text size in page units ie pixels
                float textheight = label.Style.Font.Size;
                switch (label.Style.Font.Unit)
                {
                case GraphicsUnit.Display:
                    textheight = textheight * g.DpiY / 75;
                    break;

                case GraphicsUnit.Document:
                    textheight = textheight * g.DpiY / 300;
                    break;

                case GraphicsUnit.Inch:
                    textheight = textheight * g.DpiY;
                    break;

                case GraphicsUnit.Millimeter:
                    textheight = (float)(textheight / 25.4 * g.DpiY);
                    break;

                case GraphicsUnit.Pixel:
                    //do nothing
                    break;

                case GraphicsUnit.Point:
                    textheight = textheight * g.DpiY / 72;
                    break;
                }
                var topFont = new Font(label.Style.Font.FontFamily, textheight, label.Style.Font.Style);
                //
                var path = new GraphicsPath();
                path.AddLines(points);

                label.TextOnPathLabel.PathColorTop          = System.Drawing.Color.Transparent;
                label.TextOnPathLabel.Text                  = label.Text;
                label.TextOnPathLabel.LetterSpacePercentage = 90;
                label.TextOnPathLabel.FillColorTop          = new System.Drawing.SolidBrush(label.Style.ForeColor);
                label.TextOnPathLabel.Font                  = topFont;
                label.TextOnPathLabel.PathDataTop           = path.PathData;
                label.TextOnPathLabel.Graphics              = g;
                //label.TextOnPathLabel.ShowPath=true;
                //label.TextOnPathLabel.PathColorTop = System.Drawing.Color.YellowGreen;
                if (label.Style.Halo != null)
                {
                    label.TextOnPathLabel.ColorHalo = label.Style.Halo;
                }
                else
                {
                    label.TextOnPathLabel.ColorHalo = null;// new System.Drawing.Pen(label.Style.ForeColor, (float)0.5);
                }
                path.Dispose();

                // MeasureString to get region
                label.TextOnPathLabel.MeasureString = true;
                label.TextOnPathLabel.DrawTextOnPath();
                label.TextOnPathLabel.MeasureString = false;
                // Get Region label for CollissionDetection here.
                var pathRegion = new GraphicsPath();

                if (label.TextOnPathLabel.RegionList.Count > 0)
                {
                    //int idxCenter = (int)label.TextOnPathLabel.PointsText.Count / 2;
                    //System.Drawing.Drawing2D.Matrix rotationMatrix = g.Transform.Clone();// new Matrix();
                    //rotationMatrix.RotateAt(label.TextOnPathLabel.Angles[idxCenter], label.TextOnPathLabel.PointsText[idxCenter]);
                    //if (label.TextOnPathLabel.PointsTextUp.Count > 0)
                    //{
                    //    for (int up = label.TextOnPathLabel.PointsTextUp.Count - 1; up >= 0; up--)
                    //    {
                    //        label.TextOnPathLabel.PointsText.Add(label.TextOnPathLabel.PointsTextUp[up]);
                    //    }

                    //}
                    pathRegion.AddRectangles(label.TextOnPathLabel.RegionList.ToArray());

                    // get box for detect colission here
                    label.Box = new LabelBox(pathRegion.GetBounds());
                    //g.FillRectangle(System.Drawing.Brushes.YellowGreen, label.Box);
                }
                pathRegion.Dispose();
            }
        }
Esempio n. 22
0
        private BaseLabel CreateLabel(IFeature fdr, IGeometry feature, string text, float rotation, int priority, LabelStyle style, Map map, IGraphics g, GetLocationMethod _getLocationMethod)
        {
            if (feature == null)
            {
                return(null);
            }

            BaseLabel lbl = null;

            SizeF size = RendererHelper.SizeOfString(g, text, style.Font);

            if (feature is ILineal)
            {
                var line = feature as ILineString;
                if (line != null)
                {
                    if (style.IsTextOnPath == false)
                    {
                        if (size.Width < 0.95 * line.Length / map.PixelWidth || style.IgnoreLength)
                        {
                            var positiveLineString = PositiveLineString(line, false);
                            var lineStringPath     = LineStringToPath(positiveLineString, map /*, false*/);
                            var rect = lineStringPath.GetBounds();

                            if (style.CollisionDetection && !style.CollisionBuffer.IsEmpty)
                            {
                                var cbx = style.CollisionBuffer.Width;
                                var cby = style.CollisionBuffer.Height;
                                rect.Inflate(2 * cbx, 2 * cby);
                                rect.Offset(-cbx, -cby);
                            }
                            var labelBox = new LabelBox(rect);

                            lbl = new PathLabel(text, lineStringPath, 0, priority, labelBox, style);
                        }
                    }
                    else
                    {
                        //get centriod
                        PointF position2 = map.WorldToImage(feature.EnvelopeInternal.Centre);
                        lbl = new Label(text, position2, rotation, priority, style);
                        if (size.Width < 0.95 * line.Length / map.PixelWidth || !style.IgnoreLength)
                        {
                            CalculateLabelAroundOnLineString(line, ref lbl, map, g, size);
                        }
                    }
                }
                return(lbl);
            }

            var worldPosition = _getLocationMethod == null
                ? feature.EnvelopeInternal.Centre
                : _getLocationMethod(fdr);

            if (worldPosition == null)
            {
                return(null);
            }

            var position = Transform.WorldtoMap(worldPosition, map);

            var location = new PointF(
                position.X - size.Width * (short)style.HorizontalAlignment * 0.5f,
                position.Y - size.Height * (short)(2 - (int)style.VerticalAlignment) * 0.5f);

            if (location.X - size.Width > map.Size.Width || location.X + size.Width < 0 ||
                location.Y - size.Height > map.Size.Height || location.Y + size.Height < 0)
            {
                return(null);
            }

            if (!style.CollisionDetection)
            {
                lbl = new Label(text, location, rotation, priority, null, style)
                {
                    LabelPoint = position
                }
            }
            ;
            else
            {
                //Collision detection is enabled so we need to measure the size of the string
                lbl = new Label(text, location, rotation, priority,
                                new LabelBox(location.X - size.Width * 0.5f - style.CollisionBuffer.Width,
                                             location.Y + size.Height * 0.5f + style.CollisionBuffer.Height,
                                             size.Width + 2f * style.CollisionBuffer.Width,
                                             size.Height + style.CollisionBuffer.Height * 2f), style)
                {
                    LabelPoint = position
                };
            }

            /*
             * if (feature is LineString)
             * {
             *  var line = feature as LineString;
             *
             *  //Only label feature if it is long enough, or it is definately wanted
             *  if (line.Length / map.PixelSize > size.Width || style.IgnoreLength)
             *  {
             *      CalculateLabelOnLinestring(line, ref lbl, map);
             *  }
             *  else
             *      return null;
             * }
             */
            return(lbl);
        }
Esempio n. 23
0
        /// <summary>
        /// Renders the layer
        /// </summary>
        /// <param name="g">Graphics object reference</param>
        /// <param name="map">Map which is rendered</param>
        public override void Render(IGraphics g, Map map)
        {
            if (Style.Enabled && Style.MaxVisible >= map.Zoom && Style.MinVisible < map.Zoom)
            {
                if (DataSource == null)
                {
                    throw (new ApplicationException("DataSource property not set on layer '" + LayerName + "'"));
                }
                g.TextRenderingHint = TextRenderingHint;
                g.SmoothingMode     = SmoothingMode;

                var envelope     = map.Envelope; //View to render
                var lineClipping = new CohenSutherlandLineClipping(envelope.MinX, envelope.MinY,
                                                                   envelope.MaxX, envelope.MaxY);

                if (CoordinateTransformation != null)
                {
#if !DotSpatialProjections
                    if (ReverseCoordinateTransformation != null)
                    {
                        envelope = GeometryTransform.TransformBox(envelope, ReverseCoordinateTransformation.MathTransform);
                    }
                    else
                    {
                        CoordinateTransformation.MathTransform.Invert();
                        envelope = GeometryTransform.TransformBox(envelope, CoordinateTransformation.MathTransform);
                        CoordinateTransformation.MathTransform.Invert();
                    }
#else
                    envelope = GeometryTransform.TransformBox(envelope, CoordinateTransformation.Target, CoordinateTransformation.Source);
#endif
                }
                var ds = new FeatureCollectionSet();
                DataSource.Open();
                DataSource.ExecuteIntersectionQuery(envelope, ds);
                DataSource.Close();
                if (ds.Count == 0)
                {
                    base.Render(g, map);
                    return;
                }

                var features = ds[0];


                //Initialize label collection
                List <BaseLabel> labels = new List <BaseLabel>();

                //List<System.Drawing.Rectangle> LabelBoxes; //Used for collision detection
                //Render labels
                foreach (var feature in features)
                {
                    var featureGeometry = (IGeometry)feature.Geometry.Clone();
                    if (CoordinateTransformation != null)
#if !DotSpatialProjections
                    { featureGeometry = GeometryTransform.TransformGeometry(
                          featureGeometry, CoordinateTransformation.MathTransform,
                          GeometryServiceProvider.Instance.CreateGeometryFactory((int)CoordinateTransformation.TargetCS.AuthorityCode)
                          ); }
#else
                    { featuresGeometry = GeometryTransform.TransformGeometry(features[i].Geometry,
                                                                             CoordinateTransformation.Source,
                                                                             CoordinateTransformation.Target,
                                                                             CoordinateTransformation.TargetFactory); }
#endif
                    LabelStyle style;
                    if (Theme != null) //If thematics is enabled, lets override the style
                    {
                        style = Theme.GetStyle(feature) as LabelStyle;
                    }
                    else
                    {
                        style = Style;
                    }

                    float rotationStyle  = style != null ? style.Rotation : 0f;
                    float rotationColumn = 0f;
                    if (!String.IsNullOrEmpty(RotationColumn))
                    {
                        Single.TryParse(feature.Attributes[RotationColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
                                        out rotationColumn);
                    }
                    float rotation = rotationStyle + rotationColumn;

                    int priority = Priority;
                    if (_getPriorityMethod != null)
                    {
                        priority = _getPriorityMethod(feature);
                    }
                    else if (!String.IsNullOrEmpty(PriorityColumn))
                    {
                        Int32.TryParse(feature.Attributes[PriorityColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
                                       out priority);
                    }

                    string text;
                    if (_getLabelMethod != null)
                    {
                        text = _getLabelMethod(feature);
                    }
                    else
                    {
                        text = feature.Attributes[LabelColumn].ToString();
                    }

                    if (!String.IsNullOrEmpty(text))
                    {
                        // for lineal geometries, try clipping to ensure proper labeling
                        if (featureGeometry is ILineal)
                        {
                            if (featureGeometry is ILineString)
                            {
                                featureGeometry = lineClipping.ClipLineString(featureGeometry as ILineString);
                            }
                            else if (featureGeometry is IMultiLineString)
                            {
                                featureGeometry = lineClipping.ClipLineString(featureGeometry as IMultiLineString);
                            }
                        }

                        if (featureGeometry is IGeometryCollection)
                        {
                            if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.All)
                            {
                                foreach (var geom in (featureGeometry as IGeometryCollection))
                                {
                                    BaseLabel lbl = CreateLabel(feature, geom, text, rotation, priority, style, map, g, _getLocationMethod);
                                    if (lbl != null)
                                    {
                                        labels.Add(lbl);
                                    }
                                }
                            }
                            else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.CommonCenter)
                            {
                                BaseLabel lbl = CreateLabel(feature, featureGeometry, text, rotation, priority, style, map, g, _getLocationMethod);
                                if (lbl != null)
                                {
                                    labels.Add(lbl);
                                }
                            }
                            else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.First)
                            {
                                if ((featureGeometry as IGeometryCollection).NumGeometries > 0)
                                {
                                    BaseLabel lbl = CreateLabel(feature, (featureGeometry as IGeometryCollection).GetGeometryN(0), text,
                                                                rotation, style, map, g);
                                    if (lbl != null)
                                    {
                                        labels.Add(lbl);
                                    }
                                }
                            }
                            else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.Largest)
                            {
                                var coll = (featureGeometry as IGeometryCollection);
                                if (coll.NumGeometries > 0)
                                {
                                    var largestVal   = 0d;
                                    var idxOfLargest = 0;
                                    for (var j = 0; j < coll.NumGeometries; j++)
                                    {
                                        var geom = coll.GetGeometryN(j);
                                        if (geom is ILineString && ((ILineString)geom).Length > largestVal)
                                        {
                                            largestVal   = ((ILineString)geom).Length;
                                            idxOfLargest = j;
                                        }
                                        if (geom is IMultiLineString && ((IMultiLineString)geom).Length > largestVal)
                                        {
                                            largestVal   = ((IMultiLineString)geom).Length;
                                            idxOfLargest = j;
                                        }
                                        if (geom is IPolygon && ((IPolygon)geom).Area > largestVal)
                                        {
                                            largestVal   = ((IPolygon)geom).Area;
                                            idxOfLargest = j;
                                        }
                                        if (geom is IMultiPolygon && ((IMultiPolygon)geom).Area > largestVal)
                                        {
                                            largestVal   = ((IMultiPolygon)geom).Area;
                                            idxOfLargest = j;
                                        }
                                    }

                                    BaseLabel lbl = CreateLabel(feature, coll.GetGeometryN(idxOfLargest), text, rotation, priority, style,
                                                                map, g, _getLocationMethod);
                                    if (lbl != null)
                                    {
                                        labels.Add(lbl);
                                    }
                                }
                            }
                        }
                        else
                        {
                            BaseLabel lbl = CreateLabel(feature, featureGeometry, text, rotation, priority, style, map, g, _getLocationMethod);
                            if (lbl != null)
                            {
                                labels.Add(lbl);
                            }
                        }
                    }
                }
                if (labels.Count > 0) //We have labels to render...
                {
                    if (Style.CollisionDetection && _labelFilter != null)
                    {
                        _labelFilter(labels);
                    }

                    for (int i = 0; i < labels.Count; i++)
                    {
                        // Don't show the label if not necessary
                        if (!labels[i].Show)
                        {
                            continue;
                        }

                        if (labels[i] is Label)
                        {
                            var label = labels[i] as Label;
                            if (label.Style.IsTextOnPath == false || label.TextOnPathLabel == null)
                            {
                                Renderer.Draw(map, g, label);
                            }
                            else
                            {
                                if (label.Style.BackColor != null && label.Style.BackColor != System.Drawing.Brushes.Transparent)
                                {
                                    //draw background
                                    if (label.TextOnPathLabel.RegionList.Count > 0)
                                    {
                                        g.FillRectangles(labels[i].Style.BackColor, labels[i].TextOnPathLabel.RegionList.ToArray());
                                        //g.FillPolygon(labels[i].Style.BackColor, labels[i].TextOnPathLabel.PointsText.ToArray());
                                    }
                                }
                                label.TextOnPathLabel.DrawTextOnPath();
                            }
                        }
                        else if (labels[i] is PathLabel)
                        {
                            var plbl     = labels[i] as PathLabel;
                            var lblStyle = plbl.Style;
                            g.DrawString(lblStyle.Halo, new SolidBrush(lblStyle.ForeColor), plbl.Text,
                                         lblStyle.Font.FontFamily, (int)lblStyle.Font.Style, lblStyle.Font.Size,
                                         lblStyle.GetStringFormat(), lblStyle.IgnoreLength, plbl.Location);
                        }
                    }
                }
            }
            base.Render(g, map);
        }
Esempio n. 24
0
        /// <summary>
        /// Renders the layer
        /// </summary>
        /// <param name="g">Graphics object reference</param>
        /// <param name="map">Map which is rendered</param>
        public override void Render(Graphics g, MapViewport map)
        {
            if (DataSource == null)
            {
                throw (new ApplicationException("DataSource property not set on layer '" + LayerName + "'"));
            }
            g.TextRenderingHint = TextRenderingHint;
            g.SmoothingMode     = SmoothingMode;

            var mapEnvelope   = map.Envelope;
            var layerEnvelope = ToSource(mapEnvelope); //View to render
            var lineClipping  = new CohenSutherlandLineClipping(mapEnvelope.MinX, mapEnvelope.MinY,
                                                                mapEnvelope.MaxX, mapEnvelope.MaxY);

            var ds = new FeatureDataSet();

            DataSource.Open();
            DataSource.ExecuteIntersectionQuery(layerEnvelope, ds);
            DataSource.Close();
            if (ds.Tables.Count == 0)
            {
                base.Render(g, map);
                return;
            }

            var features = ds.Tables[0];

            //Initialize label collection
            var labels = new List <BaseLabel>();

            //List<System.Drawing.Rectangle> LabelBoxes; //Used for collision detection
            //Render labels

            for (int i = 0; i < features.Count; i++)
            {
                var feature = features[i];
                feature.Geometry = ToTarget(feature.Geometry);

                LabelStyle style;
                if (Theme != null) //If thematics is enabled, lets override the style
                {
                    style = Theme.GetStyle(feature) as LabelStyle;
                }
                else
                {
                    style = Style;
                }

                // Do we need to render at all?
                if (!style.Enabled)
                {
                    continue;
                }

                // Rotation
                float rotationStyle  = style != null ? style.Rotation : 0f;
                float rotationColumn = 0f;
                if (!String.IsNullOrEmpty(RotationColumn))
                {
                    Single.TryParse(feature[RotationColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
                                    out rotationColumn);
                }
                float rotation = rotationStyle + rotationColumn;

                // Priority
                int priority = Priority;
                if (_getPriorityMethod != null)
                {
                    priority = _getPriorityMethod(feature);
                }
                else if (!String.IsNullOrEmpty(PriorityColumn))
                {
                    Int32.TryParse(feature[PriorityColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
                                   out priority);
                }

                // Text
                string text;
                if (_getLabelMethod != null)
                {
                    text = _getLabelMethod(feature);
                }
                else
                {
                    text = feature[LabelColumn].ToString();
                }

                if (!String.IsNullOrEmpty(text))
                {
                    // for lineal geometries, try clipping to ensure proper labeling
                    if (feature.Geometry is ILineal)
                    {
                        if (feature.Geometry is ILineString)
                        {
                            feature.Geometry = lineClipping.ClipLineString(feature.Geometry as ILineString);
                        }
                        else if (feature.Geometry is IMultiLineString)
                        {
                            feature.Geometry = lineClipping.ClipLineString(feature.Geometry as IMultiLineString);
                        }
                    }

                    if (feature.Geometry is IGeometryCollection)
                    {
                        if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.All)
                        {
                            foreach (var geom in (feature.Geometry as IGeometryCollection))
                            {
                                BaseLabel lbl = CreateLabel(feature, geom, text, rotation, priority, style, map, g, _getLocationMethod);
                                if (lbl != null)
                                {
                                    labels.Add(lbl);
                                }
                            }
                        }
                        else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.CommonCenter)
                        {
                            BaseLabel lbl = CreateLabel(feature, feature.Geometry, text, rotation, priority, style, map, g, _getLocationMethod);
                            if (lbl != null)
                            {
                                labels.Add(lbl);
                            }
                        }
                        else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.First)
                        {
                            if ((feature.Geometry as IGeometryCollection).NumGeometries > 0)
                            {
                                BaseLabel lbl = CreateLabel(feature, (feature.Geometry as IGeometryCollection).GetGeometryN(0), text,
                                                            rotation, style, map, g);
                                if (lbl != null)
                                {
                                    labels.Add(lbl);
                                }
                            }
                        }
                        else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.Largest)
                        {
                            var coll = (feature.Geometry as IGeometryCollection);
                            if (coll.NumGeometries > 0)
                            {
                                var largestVal   = 0d;
                                var idxOfLargest = 0;
                                for (var j = 0; j < coll.NumGeometries; j++)
                                {
                                    var geom = coll.GetGeometryN(j);
                                    if (geom is ILineString && ((ILineString)geom).Length > largestVal)
                                    {
                                        largestVal   = ((ILineString)geom).Length;
                                        idxOfLargest = j;
                                    }
                                    if (geom is IMultiLineString && ((IMultiLineString)geom).Length > largestVal)
                                    {
                                        largestVal   = ((IMultiLineString)geom).Length;
                                        idxOfLargest = j;
                                    }
                                    if (geom is IPolygon && ((IPolygon)geom).Area > largestVal)
                                    {
                                        largestVal   = ((IPolygon)geom).Area;
                                        idxOfLargest = j;
                                    }
                                    if (geom is IMultiPolygon && ((IMultiPolygon)geom).Area > largestVal)
                                    {
                                        largestVal   = ((IMultiPolygon)geom).Area;
                                        idxOfLargest = j;
                                    }
                                }

                                BaseLabel lbl = CreateLabel(feature, coll.GetGeometryN(idxOfLargest), text, rotation, priority, style,
                                                            map, g, _getLocationMethod);
                                if (lbl != null)
                                {
                                    labels.Add(lbl);
                                }
                            }
                        }
                    }
                    else
                    {
                        BaseLabel lbl = CreateLabel(feature, feature.Geometry, text, rotation, priority, style, map, g, _getLocationMethod);
                        if (lbl != null)
                        {
                            labels.Add(lbl);
                        }
                    }
                }
            }
            if (labels.Count > 0) //We have labels to render...
            {
                if (Style.CollisionDetection && _labelFilter != null)
                {
                    _labelFilter(labels);
                }

                for (int i = 0; i < labels.Count; i++)
                {
                    // Don't show the label if not necessary
                    if (!labels[i].Show)
                    {
                        continue;
                    }

                    if (labels[i] is Label)
                    {
                        var label = labels[i] as Label;
                        if (label.Style.IsTextOnPath == false || label.TextOnPathLabel == null)
                        {
                            VectorRenderer.DrawLabel(g, label.Location, label.Style.Offset,
                                                     label.Style.GetFontForGraphics(g), label.Style.ForeColor,
                                                     label.Style.BackColor, label.Style.Halo, label.Rotation,
                                                     label.Text, map, label.Style.HorizontalAlignment,
                                                     label.LabelPoint);
                        }
                        else
                        {
                            if (label.Style.BackColor != null && label.Style.BackColor != System.Drawing.Brushes.Transparent)
                            {
                                //draw background
                                if (label.TextOnPathLabel.RegionList.Count > 0)
                                {
                                    g.FillRectangles(labels[i].Style.BackColor, labels[i].TextOnPathLabel.RegionList.ToArray());
                                    //g.FillPolygon(labels[i].Style.BackColor, labels[i].TextOnPathLabel.PointsText.ToArray());
                                }
                            }
                            label.TextOnPathLabel.DrawTextOnPath();
                        }
                    }
                    else if (labels[i] is PathLabel)
                    {
                        var plbl     = labels[i] as PathLabel;
                        var lblStyle = plbl.Style;
                        g.DrawString(lblStyle.Halo, new SolidBrush(lblStyle.ForeColor), plbl.Text,
                                     lblStyle.Font.FontFamily, (int)lblStyle.Font.Style, lblStyle.Font.Size,
                                     lblStyle.GetStringFormat(), lblStyle.IgnoreLength, plbl.Location);
                    }
                }
            }
            base.Render(g, map);
        }
Esempio n. 25
0
        //private static LineString ReverseLineString(LineString clippedLineString)
        //{
        //    var coords = new Stack<Point>(clippedLineString.Vertices);
        //    return new LineString(coords.ToArray());
        //}

        ///// <summary>
        ///// Function to transform a linestring to a graphics path for further processing
        ///// </summary>
        ///// <param name="multiLineString">The Linestring</param>
        ///// <param name="map">The map</param>
        ///// <param name="useClipping">A value indicating whether clipping should be applied or not</param>
        ///// <returns>A GraphicsPath</returns>
        //public static GraphicsPath MultiLineStringToPath(MultiLineString multiLineString, Map map, bool useClipping)
        //{
        //    var gp = new GraphicsPath(FillMode.Alternate);
        //    foreach (var lineString in multiLineString.LineStrings)
        //        gp.AddPath(LineStringToPath(lineString, map, useClipping), false);

        //    return gp;
        //}

        //private static GraphicsPath LineToGraphicsPath(LineString line, Map map)
        //{
        //    GraphicsPath path = new GraphicsPath();
        //    path.AddLines(line.TransformToImage(map));
        //    return path;
        //}

        private static void CalculateLabelOnLinestring(LineString line, ref BaseLabel baseLabel, Map map)
        {
            double dx, dy;
            var label = baseLabel as Label;

            // first find the middle segment of the line
            int midPoint = (line.Vertices.Count - 1)/2;
            if (line.Vertices.Count > 2)
            {
                dx = line.Vertices[midPoint + 1].X - line.Vertices[midPoint].X;
                dy = line.Vertices[midPoint + 1].Y - line.Vertices[midPoint].Y;
            }
            else
            {
                midPoint = 0;
                dx = line.Vertices[1].X - line.Vertices[0].X;
                dy = line.Vertices[1].Y - line.Vertices[0].Y;
            }
            if (dy == 0)
                label.Rotation = 0;
            else if (dx == 0)
                label.Rotation = 90;
            else
            {
                // calculate angle of line					
                double angle = -Math.Atan(dy/dx) + Math.PI*0.5;
                angle *= (180d/Math.PI); // convert radians to degrees
                label.Rotation = (float) angle - 90; // -90 text orientation
            }
            double tmpx = line.Vertices[midPoint].X + (dx*0.5);
            double tmpy = line.Vertices[midPoint].Y + (dy*0.5);
            label.LabelPoint = map.WorldToImage(new Point(tmpx, tmpy));
        }
Esempio n. 26
0
        private static BaseLabel CreateLabel(Geometry feature, string text, float rotation, int priority, LabelStyle style, Map map,
                                             Graphics g)
        {
            BaseLabel lbl = null;

            SizeF size = VectorRenderer.SizeOfString(g, text, style.Font);

            if (feature is ILineal)
            {
                var line = feature as LineString;
                if (line != null)
                {
                    if (size.Width < 0.95 * line.Length / map.PixelWidth || !style.IgnoreLength)
                    {
                        var positiveLineString = PositiveLineString(line, false);
                        var lineStringPath     = LineStringToPath(positiveLineString, map /*, false*/);
                        var rect = lineStringPath.GetBounds();

                        if (style.CollisionDetection && !style.CollisionBuffer.IsEmpty)
                        {
                            var cbx = style.CollisionBuffer.Width;
                            var cby = style.CollisionBuffer.Height;
                            rect.Inflate(2 * cbx, 2 * cby);
                            rect.Offset(-cbx, -cby);
                        }
                        var labelBox = new LabelBox(rect);

                        lbl = new PathLabel(text, lineStringPath, 0, priority, labelBox, style);
                    }
                }
                return(lbl);
            }

            PointF position = Transform.WorldtoMap(feature.GetBoundingBox().GetCentroid(), map);

            position.X = position.X - size.Width * (short)style.HorizontalAlignment * 0.5f;
            position.Y = position.Y - size.Height * (short)(2 - (int)style.VerticalAlignment) * 0.5f;
            if (position.X - size.Width > map.Size.Width || position.X + size.Width < 0 ||
                position.Y - size.Height > map.Size.Height || position.Y + size.Height < 0)
            {
                return(null);
            }

            if (!style.CollisionDetection)
            {
                lbl = new Label(text, position, rotation, priority, null, style);
            }
            else
            {
                //Collision detection is enabled so we need to measure the size of the string
                lbl = new Label(text, position, rotation, priority,
                                new LabelBox(position.X - size.Width * 0.5f - style.CollisionBuffer.Width,
                                             position.Y + size.Height * 0.5f + style.CollisionBuffer.Height,
                                             size.Width + 2f * style.CollisionBuffer.Width,
                                             size.Height + style.CollisionBuffer.Height * 2f), style);
            }

            /*
             * if (feature is LineString)
             * {
             *  var line = feature as LineString;
             *
             *  //Only label feature if it is long enough, or it is definately wanted
             *  if (line.Length / map.PixelSize > size.Width || style.IgnoreLength)
             *  {
             *      CalculateLabelOnLinestring(line, ref lbl, map);
             *  }
             *  else
             *      return null;
             * }
             */
            return(lbl);
        }
Esempio n. 27
0
        /// <summary>
        /// Renders the layer
        /// </summary>
        /// <param name="g">Graphics object reference</param>
        /// <param name="map">Map which is rendered</param>
        public override void Render(Graphics g, Map map)
        {
            if (Style.Enabled && Style.MaxVisible >= map.Zoom && Style.MinVisible < map.Zoom)
            {
                if (DataSource == null)
                {
                    throw (new ApplicationException("DataSource property not set on layer '" + LayerName + "'"));
                }
                g.TextRenderingHint = TextRenderingHint;
                g.SmoothingMode     = SmoothingMode;

                BoundingBox envelope     = map.Envelope; //View to render
                var         lineClipping = new CohenSutherlandLineClipping(envelope.Min.X, envelope.Min.Y,
                                                                           envelope.Max.X, envelope.Max.Y);

                if (CoordinateTransformation != null)
                {
#if !DotSpatialProjections
                    CoordinateTransformation.MathTransform.Invert();
                    envelope = GeometryTransform.TransformBox(envelope, CoordinateTransformation.MathTransform);
                    CoordinateTransformation.MathTransform.Invert();
#else
                    envelope = GeometryTransform.TransformBox(envelope, CoordinateTransformation.Target, CoordinateTransformation.Source);
#endif
                }
                FeatureDataSet ds = new FeatureDataSet();
                DataSource.Open();
                DataSource.ExecuteIntersectionQuery(envelope, ds);
                DataSource.Close();
                if (ds.Tables.Count == 0)
                {
                    base.Render(g, map);
                    return;
                }

                FeatureDataTable features = ds.Tables[0];


                //Initialize label collection
                List <BaseLabel> labels = new List <BaseLabel>();

                //List<System.Drawing.Rectangle> LabelBoxes; //Used for collision detection
                //Render labels
                for (int i = 0; i < features.Count; i++)
                {
                    FeatureDataRow feature = features[i];
                    if (CoordinateTransformation != null)
#if !DotSpatialProjections
                    { features[i].Geometry = GeometryTransform.TransformGeometry(features[i].Geometry,
                                                                                 CoordinateTransformation.
                                                                                 MathTransform); }
#else
                    { features[i].Geometry = GeometryTransform.TransformGeometry(features[i].Geometry,
                                                                                 CoordinateTransformation.Source,
                                                                                 CoordinateTransformation.Target); }
#endif
                    LabelStyle style;
                    if (Theme != null) //If thematics is enabled, lets override the style
                    {
                        style = Theme.GetStyle(feature) as LabelStyle;
                    }
                    else
                    {
                        style = Style;
                    }

                    float rotationStyle  = style != null ? style.Rotation : 0f;
                    float rotationColumn = 0f;
                    if (!String.IsNullOrEmpty(RotationColumn))
                    {
                        Single.TryParse(feature[RotationColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
                                        out rotationColumn);
                    }
                    float rotation = rotationStyle + rotationColumn;

                    int priority = Priority;
                    if (_getPriorityMethod != null)
                    {
                        priority = _getPriorityMethod(feature);
                    }
                    else if (!String.IsNullOrEmpty(PriorityColumn))
                    {
                        Int32.TryParse(feature[PriorityColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
                                       out priority);
                    }

                    string text;
                    if (_getLabelMethod != null)
                    {
                        text = _getLabelMethod(feature);
                    }
                    else
                    {
                        text = feature[LabelColumn].ToString();
                    }

                    if (!String.IsNullOrEmpty(text))
                    {
                        // for lineal geometries, try clipping to ensure proper labeling
                        if (feature.Geometry is ILineal)
                        {
                            if (feature.Geometry is LineString)
                            {
                                feature.Geometry = lineClipping.ClipLineString(feature.Geometry as LineString);
                            }
                            else if (feature.Geometry is MultiLineString)
                            {
                                feature.Geometry = lineClipping.ClipLineString(feature.Geometry as MultiLineString);
                            }
                        }

                        if (feature.Geometry is GeometryCollection)
                        {
                            if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.All)
                            {
                                foreach (Geometry geom in (feature.Geometry as GeometryCollection))
                                {
                                    BaseLabel lbl = CreateLabel(geom, text, rotation, priority, style, map, g);
                                    if (lbl != null)
                                    {
                                        labels.Add(lbl);
                                    }
                                }
                            }
                            else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.CommonCenter)
                            {
                                BaseLabel lbl = CreateLabel(feature.Geometry, text, rotation, priority, style, map, g);
                                if (lbl != null)
                                {
                                    labels.Add(lbl);
                                }
                            }
                            else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.First)
                            {
                                if ((feature.Geometry as GeometryCollection).Collection.Count > 0)
                                {
                                    BaseLabel lbl = CreateLabel((feature.Geometry as GeometryCollection).Collection[0], text,
                                                                rotation, style, map, g);
                                    if (lbl != null)
                                    {
                                        labels.Add(lbl);
                                    }
                                }
                            }
                            else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.Largest)
                            {
                                GeometryCollection coll = (feature.Geometry as GeometryCollection);
                                if (coll.NumGeometries > 0)
                                {
                                    double largestVal   = 0;
                                    int    idxOfLargest = 0;
                                    for (int j = 0; j < coll.NumGeometries; j++)
                                    {
                                        Geometry geom = coll.Geometry(j);
                                        if (geom is LineString && ((LineString)geom).Length > largestVal)
                                        {
                                            largestVal   = ((LineString)geom).Length;
                                            idxOfLargest = j;
                                        }
                                        if (geom is MultiLineString && ((MultiLineString)geom).Length > largestVal)
                                        {
                                            largestVal   = ((MultiLineString)geom).Length;
                                            idxOfLargest = j;
                                        }
                                        if (geom is Polygon && ((Polygon)geom).Area > largestVal)
                                        {
                                            largestVal   = ((Polygon)geom).Area;
                                            idxOfLargest = j;
                                        }
                                        if (geom is MultiPolygon && ((MultiPolygon)geom).Area > largestVal)
                                        {
                                            largestVal   = ((MultiPolygon)geom).Area;
                                            idxOfLargest = j;
                                        }
                                    }

                                    BaseLabel lbl = CreateLabel(coll.Geometry(idxOfLargest), text, rotation, priority, style,
                                                                map, g);
                                    if (lbl != null)
                                    {
                                        labels.Add(lbl);
                                    }
                                }
                            }
                        }
                        else
                        {
                            BaseLabel lbl = CreateLabel(feature.Geometry, text, rotation, priority, style, map, g);
                            if (lbl != null)
                            {
                                labels.Add(lbl);
                            }
                        }
                    }
                }
                if (labels.Count > 0) //We have labels to render...
                {
                    if (Style.CollisionDetection && _labelFilter != null)
                    {
                        _labelFilter(labels);
                    }

                    for (int i = 0; i < labels.Count; i++)
                    {
                        // Don't show the label if not necessary
                        if (!labels[i].Show)
                        {
                            continue;
                        }

                        if (labels[i] is Label)
                        {
                            var label = labels[i] as Label;
                            VectorRenderer.DrawLabel(g, label.Location, label.Style.Offset,
                                                     label.Style.Font, label.Style.ForeColor,
                                                     label.Style.BackColor, Style.Halo, label.Rotation,
                                                     label.Text, map);
                        }
                        else if (labels[i] is PathLabel)
                        {
                            var plbl     = labels[i] as PathLabel;
                            var lblStyle = plbl.Style;
                            g.DrawString(lblStyle.Halo, new SolidBrush(lblStyle.ForeColor), plbl.Text,
                                         lblStyle.Font.FontFamily, (int)lblStyle.Font.Style, lblStyle.Font.Size,
                                         lblStyle.GetStringFormat(), lblStyle.IgnoreLength, plbl.Location);
                        }
                    }
                }
            }
            base.Render(g, map);
        }
Esempio n. 28
0
 F4005Impl()
 {
     baseLabel = LabelFactory.getObjectLabel("F4005");
 }
Esempio n. 29
0
        public static void GetAsset(BaseLabel icon, SoftObjectProperty s)
        {
            PakPackage p = Utils.GetPropertyPakPackage(s.Value.AssetPathName.String);

            if (p.HasExport() && !p.Equals(default))