예제 #1
0
        private void OnUpdatePreset(object sender, EventArgs e)
        {
            //get current coordinates
            System.Collections.ObjectModel.Collection <object> objResult = EnvironmentManager.Instance.SendMessage(
                new VideoOS.Platform.Messaging.Message(MessageId.Control.PTZGetAbsoluteRequest), _camera.FQID);

            PTZGetAbsoluteRequestData datRequestData = (PTZGetAbsoluteRequestData)objResult[0];
            double pan  = datRequestData.Pan;
            double tilt = datRequestData.Tilt;
            double zoom = datRequestData.Zoom;

            objResult.Clear();

            Item   currentlySelectedPresetItem = comboBoxPresets.SelectedItem as Item;
            string currentlySelectedPresetName = currentlySelectedPresetItem.Name;

            try
            {
                Camera          camera    = new Camera(_camera.FQID);
                PtzPresetFolder folder    = camera.PtzPresetFolder;
                PtzPreset       ptzPreset = folder.PtzPresets.Where(x => x.Name == currentlySelectedPresetName).FirstOrDefault();
                if (ptzPreset != null)
                {
                    ptzPreset.Pan  = pan;
                    ptzPreset.Tilt = tilt;
                    ptzPreset.Zoom = zoom;
                    ptzPreset.Save();
                }
            }
            catch (Exception ex)
            {
                EnvironmentManager.Instance.Log(true, "Update Preset", ex.Message);
                MessageBox.Show(ex.Message, "Exception in Update preset", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void buttonCreatePreset_Click(object sender, EventArgs e)
        {
            //get current coordinates
            System.Collections.ObjectModel.Collection <object> objResult = EnvironmentManager.Instance.SendMessage(
                new VideoOS.Platform.Messaging.Message(MessageId.Control.PTZGetAbsoluteRequest), _camera.FQID);

            PTZGetAbsoluteRequestData datRequestData = (PTZGetAbsoluteRequestData)objResult[0];
            double pan  = datRequestData.Pan;
            double tilt = datRequestData.Tilt;
            double zoom = datRequestData.Zoom;

            objResult.Clear();
            try
            {
                Camera          camera = new Camera(_camera.FQID);
                PtzPresetFolder folder = camera.PtzPresetFolder;
                folder.AddPtzPreset(textBoxPresetName.Text, "", pan, tilt, zoom);
            }
            catch (Exception ex)
            {
                EnvironmentManager.Instance.Log(true, "Create Preset", ex.Message);
                MessageBox.Show(ex.Message, "Exception in Create preset", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            refreshList();
            textBoxPresetName.Text = "new preset name";
        }
예제 #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            Bitmap bmp = this._imageViewerControl.GetCurrentDisplayedImageAsBitmap();

            if (bmp == null)
            {
                return;
            }

            PTZCenterCommandData datPTZCenterCommandData = new PTZCenterCommandData();

            datPTZCenterCommandData.CenterX   = Convert.ToDouble(bmp.Width / 2 + 10);
            datPTZCenterCommandData.CenterY   = Convert.ToDouble(bmp.Height / 2 + 10);
            datPTZCenterCommandData.RefWidth  = Convert.ToDouble(bmp.Width);
            datPTZCenterCommandData.RefHeight = Convert.ToDouble(bmp.Height);

            System.Collections.ObjectModel.Collection <object> objResult = EnvironmentManager.Instance.SendMessage(
                new VideoOS.Platform.Messaging.Message(MessageId.Control.PTZGetAbsoluteRequest), _camera.FQID);

            PTZGetAbsoluteRequestData datRequestData = (PTZGetAbsoluteRequestData)objResult[0];

            datPTZCenterCommandData.Zoom = -1.0;// datRequestData.Zoom;
            objResult.Clear();

            EnvironmentManager.Instance.SendMessage(
                new VideoOS.Platform.Messaging.Message(MessageId.Control.PTZCenterCommand, datPTZCenterCommandData), _camera.FQID);
        }
        private void printerNameComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            _printMgr.PrinterName = printerNameComboBox.SelectedItem as string;

            // Verify the relative controls is enable or not, according to the printer changed.
            _printMgr.VerifyPrintToFile(printToFileCheckBox);

            System.Collections.ObjectModel.Collection <System.Windows.Forms.Control> controlsToEnableOrNot =
                new System.Collections.ObjectModel.Collection <System.Windows.Forms.Control>();
            controlsToEnableOrNot.Add(copiesNumericUpDown);
            controlsToEnableOrNot.Add(numberofcoyiesLabel);
            _printMgr.VerifyCopies(controlsToEnableOrNot);

            controlsToEnableOrNot.Clear();
            controlsToEnableOrNot.Add(printToFileNameLabel);
            controlsToEnableOrNot.Add(printToFileNameTextBox);
            controlsToEnableOrNot.Add(browseButton);

            if (!string.IsNullOrEmpty(printToFileNameTextBox.Text))
            {
                printToFileNameTextBox.Text = printToFileNameTextBox.Text.Remove(
                    printToFileNameTextBox.Text.LastIndexOf(".")) + _printMgr.PostFix;
            }
            this.printToFileNameTextBox.Text = _printMgr.PrintToFileName;
            _printMgr.VerifyPrintToFileName(controlsToEnableOrNot);

            _printMgr.VerifyPrintToSingleFile(singleFileRadioButton);
            _printMgr.VerifyPrintToSeparateFile(separateFileRadioButton);
        }
예제 #5
0
        //public void LoadClientExclusions

        public void LoadAbsence()
        {
            sqlConnection1 = new OleDbConnection();

            sqlConnection1.ConnectionString = ConfigurationManager.ConnectionStrings["TransManager"].ToString();

            using (sqlConnection1)
            {
                Absences.Clear();

                sqlConnection1.Open();

                OleDbCommand    cmd = new OleDbCommand();
                OleDbDataReader dr;

                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = "SELECT * FROM DriverAbsence WHERE DriverID = @var1 ORDER BY DateFrom ASC";

                cmd.Parameters.Add(new OleDbParameter("@var1", _id));

                cmd.Connection = sqlConnection1;
                Log.WriteCommand(cmd);
                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    Absence abs = new Absence(dr.GetInt32(dr.GetOrdinal("DriverAbsenceID")), dr.GetDateTime(dr.GetOrdinal("DateFrom")), dr.GetDateTime(dr.GetOrdinal("DateTo")), dr.GetValue(dr.GetOrdinal("AbsenceReason")).ToString());

                    Absences.Add(abs);
                }

                sqlConnection1.Close();
            }
        }
예제 #6
0
 /// <summary>
 /// Remove all of the "garbage" ParticleSystem objects from this collection.
 /// </summary>
 public void Collect()
 {
     for (int i = 0; i < garbage.Count; i++)
     {
         Remove(garbage[i]);
     }
     garbage.Clear();
 }
예제 #7
0
        void lyap_LayerCompleted(object src, LyapunovGenerator.LayerCompletedEventArgs e)
        {
            LyapunovGenerator sender = (LyapunovGenerator)src;

            try
            {
                if (!System.IO.Directory.Exists(sender.Conf._path + "\\" + sender.Conf._z))
                {
                    System.IO.Directory.CreateDirectory(sender.Conf._path + "\\" + sender.Conf._z);
                }
                if (e.Z != -1)
                {
                    //System.IO.File.Delete(sender.Conf._path + "\\" + sender.Conf._z + "\\" + sender.Conf._x + "_" + sender.Conf._y + ".png");
                    e.Layer.Save(sender.Conf._path + "\\" + sender.Conf._z + "\\" + sender.Conf._x + "_" + sender.Conf._y + ".png", System.Drawing.Imaging.ImageFormat.Png);
                }
            }
            catch
            {
                Confs.Clear();
                //MessageBox.Show("Problem with: " + sender.Conf._z + "x (" + sender.Conf._x + ", " + sender.Conf._y + ") please sort out!!!");

                //MessageBox.Show("File Error");
                if (fileError < 5)
                {
                    fileError++;
                    Confs.Add(sender.Conf);
                }
                else
                {
                    //Confs.Clear();
                    foreach (LyapunovGenerator lyap in Lyaps)
                    {
                        lyap.Stop();
                    }
                    if (fileError == 5)
                    {
                        MessageBox.Show("Could not save");
                    }
                    fileError      = 0;
                    btn_start.Text = "Start";
                }
            }
        }
예제 #8
0
        private static void DownloadProgram(DF1Comm.DF1Comm df1, string filename, string serialPort)
        {
            df1.ComPort = serialPort;
            System.Collections.ObjectModel.Collection <DF1Comm.DF1Comm.PLCFileDetails> PLCFiles = new System.Collections.ObjectModel.Collection <DF1Comm.DF1Comm.PLCFileDetails>();
            DF1Comm.DF1Comm.PLCFileDetails PLCFile = default(DF1Comm.DF1Comm.PLCFileDetails);
            try
            {
                System.IO.StreamReader FileReader = new System.IO.StreamReader(filename);

                string line = null;
                System.Collections.ObjectModel.Collection <byte> data = new System.Collections.ObjectModel.Collection <byte>();

                int linesCount = 0;
                while (!(FileReader.EndOfStream))
                {
                    line               = FileReader.ReadLine();
                    PLCFile.FileType   = Convert.ToByte(line, 16);
                    line               = FileReader.ReadLine();
                    PLCFile.FileNumber = Convert.ToByte(line, 16);

                    line = FileReader.ReadLine();
                    data.Clear();
                    for (int i = 0; i <= line.Length / 2 - 1; i++)
                    {
                        data.Add(Convert.ToByte(line.Substring(i * 2, 2), 16));
                    }
                    byte[] dataC = new byte[data.Count];
                    data.CopyTo(dataC, 0);
                    PLCFile.data = dataC;

                    PLCFiles.Add(PLCFile);
                    linesCount += 1;
                }

                try
                {
                    df1.DownloadProgramData(PLCFiles);
                    df1.SetRunMode();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return;
                }

                Console.WriteLine("Successful Download");
                return;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }
        }
예제 #9
0
 /// <summary>
 /// Inits an new <see cref="LogItem"/> instance which
 /// is initialized with default values.
 /// </summary>
 public LogItem(int priority)
 {
     Categories        = new System.Collections.ObjectModel.Collection <string>();
     LogItemProperties = new List <LogItemProperty>();
     Title             = String.Empty;
     Message           = String.Empty;
     LogLevel          = LogLevel.Info;
     LoggerName        = String.Empty;
     Priority          = priority;
     Categories.Clear();
     Timestamp = DateTimeOffset.Now;
 }
예제 #10
0
        private void buttonGetAbs_Click(object sender, EventArgs e)
        {
            System.Collections.ObjectModel.Collection <object> objResult = EnvironmentManager.Instance.SendMessage(
                new VideoOS.Platform.Messaging.Message(MessageId.Control.PTZGetAbsoluteRequest), _camera.FQID);

            PTZGetAbsoluteRequestData datRequestData = (PTZGetAbsoluteRequestData)objResult[0];

            textBoxGetAbsPan.Text  = datRequestData.Pan.ToString(System.Globalization.CultureInfo.InvariantCulture);
            textBoxGetAbsTilt.Text = datRequestData.Tilt.ToString(System.Globalization.CultureInfo.InvariantCulture);
            textBoxGetAbsZoom.Text = datRequestData.Zoom.ToString(System.Globalization.CultureInfo.InvariantCulture);
            objResult.Clear();
        }
예제 #11
0
        internal override void PopulateWithIShellItems(System.Collections.ObjectModel.Collection <IShellItem> items)
        {
            IShellItem item;

            saveDialogCoClass.GetResult(out item);

            if (item == null)
            {
                throw new InvalidOperationException(LocalizedMessages.SaveFileNullItem);
            }
            items.Clear();
            items.Add(item);
        }
예제 #12
0
        internal override void PopulateWithFileNames(
            System.Collections.ObjectModel.Collection <string> names)
        {
            IShellItem item;

            saveDialogCoClass.GetResult(out item);

            if (item == null)
            {
                throw new InvalidOperationException(LocalizedMessages.SaveFileNullItem);
            }
            names.Clear();
            names.Add(GetFileNameFromShellItem(item));
        }
예제 #13
0
        internal override void PopulateWithIShellItems(
            System.Collections.ObjectModel.Collection <IShellItem> items)
        {
            IShellItem item;

            saveDialogCoClass.GetResult(out item);

            if (item == null)
            {
                throw new InvalidOperationException(
                          "Retrieved a null shell item from dialog");
            }
            items.Clear();
            items.Add(item);
        }
예제 #14
0
        public void LoadDriverAttributes()
        {
            Attributes.Clear();

            sqlConnection1 = new OleDbConnection(ConfigurationManager.ConnectionStrings["TransManager"].ToString());

            using (sqlConnection1)
            {
                sqlConnection1.Open();

                OleDbCommand cmd = new OleDbCommand();

                OleDbDataReader dr;

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "vwDriverAttributes";
                cmd.Parameters.Add(new OleDbParameter("[DriverID]", _id));

                cmd.Connection = sqlConnection1;
                Log.WriteCommand(cmd);
                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    Attribute attribute = new Attribute();
                    attribute.AttributeID     = dr.GetInt32(dr.GetOrdinal("AttributeID"));
                    attribute.Checked         = dr.GetInt32(dr.GetOrdinal("Checked")) == 1 ? true : false;
                    attribute.Description     = dr.GetValue(dr.GetOrdinal("Description")).ToString();
                    attribute.LinkAttributeID = dr.GetInt32(dr.GetOrdinal("DriverAttrID"));
                    attribute.AccessLevel     = dr.GetInt32(dr.GetOrdinal("AccessLevel"));
                    attribute.LinkID          = _id;
                    Attributes.Add(attribute);
                    if (attribute.Description.ToLower() == "wheelchair enabled")
                    {
                        _wheelchairenabled = attribute.Checked;
                    }
                    if (attribute.Description.ToLower() == "walker enabled")
                    {
                        _walkerenabled = attribute.Checked;
                    }
                    if (attribute.Description.ToLower() == "Local drives")
                    {
                        _localdrives = attribute.Checked;
                    }
                }
            }
        }
예제 #15
0
        void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                appimages.Clear();
                apps.Clear();
                string   data = e.Result;
                string[] s    = data.Split(new string[] { "<a:entry>" }, StringSplitOptions.None);
                string[] s2;
                bool     isfirst = true;
                foreach (string app in s)
                {
                    if (isfirst)
                    {
                        isfirst = false;
                    }
                    else
                    {
                        appentry appentry = new appentry();
                        s2 = app.Split(new string[] { "<a:title" }, StringSplitOptions.None);
                        s2 = s2[1].Split(">".ToCharArray());
                        s2 = s2[1].Split("<".ToCharArray());
                        listBox1.Items.Add(s2[0]);
                        appentry.name = s2[0];

                        s2            = app.Split(new string[] { "<a:id>urn:uuid:" }, StringSplitOptions.None);
                        s2            = s2[1].Split("<".ToCharArray());
                        appentry.guid = s2[0];

                        s2 = app.Split(new string[] { "<id>urn:uuid:" }, StringSplitOptions.None);
                        s2 = s2[1].Split("<".ToCharArray());

                        appimages.Add(s2[0]);
                        apps.Add(appentry);
                    }
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("That didn't work ):\r\n" + ee.Message);
            }
            updateListbox();
        }
예제 #16
0
        public void DoUpdate(object sender, System.EventArgs e)
        {
            for (int i = 0; i <= BytesToRead - 1; i += 1)
            {
                ReceivedDataPacket.Add(BytesRead[i]);
            }

            if (ReceivedDataPacket.Count >= 14)
            {
                byte[] ACKSequence = { 16, 6 };
                serialPort1.Write(ACKSequence, 0, 2);
                richTextBox1.Clear();
                for (int i = 0; i <= ReceivedDataPacket.Count - 1; i += 1)
                {
                    richTextBox1.Text = richTextBox1.Text + "\n Index" + i + " = " + ReceivedDataPacket[i];
                }
                ReceivedDataPacket.Clear();
            }
        }
        private void printToFileCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            _printMgr.IsPrintToFile = printToFileCheckBox.Checked;

            // Verify the relative controls is enable or not, according to the print to file
            // check box is checked or not.
            System.Collections.ObjectModel.Collection <System.Windows.Forms.Control> controlsToEnableOrNot =
                new System.Collections.ObjectModel.Collection <System.Windows.Forms.Control>();
            controlsToEnableOrNot.Add(copiesNumericUpDown);
            controlsToEnableOrNot.Add(numberofcoyiesLabel);
            _printMgr.VerifyCopies(controlsToEnableOrNot);

            controlsToEnableOrNot.Clear();
            controlsToEnableOrNot.Add(printToFileNameLabel);
            controlsToEnableOrNot.Add(printToFileNameTextBox);
            controlsToEnableOrNot.Add(browseButton);
            _printMgr.VerifyPrintToFileName(controlsToEnableOrNot);

            _printMgr.VerifyPrintToSingleFile(singleFileRadioButton);
        }
        private void RefreshMapElements()
        {
            // Clears map elements.
            System.Collections.ObjectModel.Collection <MapElement> elements = MapControl.MapElements;
            elements.Clear();

            // Refresh player accuracy polygon.
            GeoCoordinateCollection playerAccuracyArea = ViewModel.PlayerAccuracyArea;

            if (playerAccuracyArea != null)
            {
                elements.Add(new MapPolygon()
                {
                    Path            = playerAccuracyArea,
                    StrokeThickness = 2,
                    FillColor       = _playerAccuracyFillColor,
                    StrokeColor     = _playerAccuracyStrokeColor
                });
            }

            // Refreshes zones.
            IEnumerable <GameMapViewModel.ZoneData> zones = ViewModel.Zones;

            if (zones != null)
            {
                foreach (GameMapViewModel.ZoneData zone in zones)
                {
                    elements.Add(new MapPolygon()
                    {
                        Path            = zone.Points,
                        FillColor       = _polygonFillColor,
                        StrokeColor     = _polygonStrokeColor,
                        StrokeThickness = 2
                    });
                }
            }
        }
예제 #19
0
파일: PrintMgrForm.cs 프로젝트: AMEE/revit
        private void printToFileCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            m_printMgr.IsPrintToFile = printToFileCheckBox.Checked;

            // Verify the relative controls is enable or not, according to the print to file
            // check box is checked or not.
            System.Collections.ObjectModel.Collection<System.Windows.Forms.Control> controlsToEnableOrNot =
                new System.Collections.ObjectModel.Collection<System.Windows.Forms.Control>();
            controlsToEnableOrNot.Add(copiesNumericUpDown);
            controlsToEnableOrNot.Add(numberofcoyiesLabel);
            m_printMgr.VerifyCopies(controlsToEnableOrNot);

            controlsToEnableOrNot.Clear();
            controlsToEnableOrNot.Add(printToFileNameLabel);
            controlsToEnableOrNot.Add(printToFileNameTextBox);
            controlsToEnableOrNot.Add(browseButton);
            m_printMgr.VerifyPrintToFileName(controlsToEnableOrNot);

            m_printMgr.VerifyPrintToSingleFile(singleFileRadioButton);
        }
        /// <summary>
        /// Initialize the UI data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PrintMgrForm_Load(object sender, EventArgs e)
        {
            printerNameComboBox.DataSource = _printMgr.InstalledPrinterNames;
            pd = new System.Drawing.Printing.PrintDocument();
            // set copy number

            // the selectedValueChange event have to add event handler after
            // data source be set, or else the delegate method will be invoked meaningless.
            this.printerNameComboBox.SelectedValueChanged += new System.EventHandler(this.printerNameComboBox_SelectedValueChanged);
            printerNameComboBox.SelectedItem = _printMgr.PrinterName;
            if (_printMgr.CopyNumber > 0)
            {
                copiesNumericUpDown.Value = _printMgr.CopyNumber;
            }
            if (_printMgr.VerifyPrintToFile(printToFileCheckBox))
            {
                printToFileCheckBox.Checked = _printMgr.IsPrintToFile;
            }

            System.Collections.ObjectModel.Collection <System.Windows.Forms.Control> controlsToEnableOrNot =
                new System.Collections.ObjectModel.Collection <System.Windows.Forms.Control>();
            controlsToEnableOrNot.Add(copiesNumericUpDown);
            controlsToEnableOrNot.Add(numberofcoyiesLabel);
            _printMgr.VerifyCopies(controlsToEnableOrNot);

            controlsToEnableOrNot.Clear();
            controlsToEnableOrNot.Add(printToFileNameLabel);
            controlsToEnableOrNot.Add(printToFileNameTextBox);
            controlsToEnableOrNot.Add(browseButton);
            _printMgr.VerifyPrintToFileName(controlsToEnableOrNot);

            _printMgr.VerifyPrintToSingleFile(singleFileRadioButton);

            if (_printMgr.VerifyPrintToSingleFile(singleFileRadioButton))
            {
                singleFileRadioButton.Checked   = _printMgr.IsCombinedFile;
                separateFileRadioButton.Checked = !_printMgr.IsCombinedFile;
            }

            if (!_printMgr.VerifyPrintToSingleFile(singleFileRadioButton) &&
                _printMgr.VerifyPrintToSeparateFile(separateFileRadioButton))
            {
                separateFileRadioButton.Checked = true;
            }
            this.singleFileRadioButton.CheckedChanged += new System.EventHandler(this.combineRadioButton_CheckedChanged);

            switch (_printMgr.PrintRange)
            {
            case PrintRange.Current:
                currentWindowRadioButton.Checked = true;
                break;

            case PrintRange.Select:
                selectedViewsRadioButton.Checked = true;
                break;

            case PrintRange.Visible:
                visiblePortionRadioButton.Checked = true;
                break;

            default:
                break;
            }
            this.currentWindowRadioButton.CheckedChanged  += new System.EventHandler(this.currentWindowRadioButton_CheckedChanged);
            this.visiblePortionRadioButton.CheckedChanged += new System.EventHandler(this.visiblePortionRadioButton_CheckedChanged);
            this.selectedViewsRadioButton.CheckedChanged  += new System.EventHandler(this.selectedViewsRadioButton_CheckedChanged);

            //this.printToFileNameTextBox.Text = Environment.GetFolderPath(
            //    Environment.SpecialFolder.MyDocuments) + "\\" + _printMgr.DocumentTitle;
            this.printToFileNameTextBox.Text = _printMgr.PrintToFileName;
            controlsToEnableOrNot.Clear();
            controlsToEnableOrNot.Add(selectedViewSheetSetLabel);
            controlsToEnableOrNot.Add(selectedViewSheetSetButton);
            if (_printMgr.VerifySelectViewSheetSet(controlsToEnableOrNot))
            {
                this.selectedViewSheetSetLabel.Text = _printMgr.SelectedViewSheetSetName;
            }

            orderCheckBox.Checked              = _printMgr.PrintOrderReverse;
            this.orderCheckBox.CheckedChanged += new System.EventHandler(this.orderCheckBox_CheckedChanged);

            if (_printMgr.VerifyCollate(collateCheckBox))
            {
                collateCheckBox.Checked = _printMgr.Collate;
                if (collateCheckBox.Checked)
                {
                    pictureBoxCollate.Image = global::SelectionPrint.Properties.Resources.Collate2;
                }
                else
                {
                    pictureBoxCollate.Image = global::SelectionPrint.Properties.Resources.Collate1;
                }
            }
            this.collateCheckBox.CheckedChanged += new System.EventHandler(this.collateCheckBox_CheckedChanged);

            printSetupNameLabel.Text = _printMgr.PrintSetupName;
        }
예제 #21
0
파일: MainForm.cs 프로젝트: developer88/umk
 private void add_umk_files_Click(object sender, EventArgs e)
 {
     win_add_umk window_umk = new win_add_umk();
        System.Collections.ObjectModel.Collection<string> return_lst = new System.Collections.ObjectModel.Collection<string>();
        System.Collections.ObjectModel.Collection<string> return_lst1 = new System.Collections.ObjectModel.Collection<string>();
        System.Collections.ObjectModel.Collection<string> return_lst2 = new System.Collections.ObjectModel.Collection<string>();
        cls_main main_func = new cls_main();
        window_umk.change_vars(umk_folder);
        window_umk.ShowDialog();
        if (window_umk.selected_path != "")
        {
        /*if (window_umk.selected_level == 3)
        {
            string[] row1 = { window_umk.selected_obj, "файл", window_umk.selected_path + "\\" };
            dg_prj_files.Rows.Add(row1);
        }*/
        if (window_umk.selected_level == 2)
        {
            string[] row1 = { window_umk.selected_obj, "папка", window_umk.selected_path + "\\" };
            //dg_prj_files.Rows.Add(row1);
        }
        else
        {
            if (window_umk.selected_level == 0)
            {
                return_lst.Clear();
                return_lst1.Clear();
                return_lst = main_func.get_dir(window_umk.selected_path + "\\" + window_umk.selected_obj);
                if (return_lst.Count > 0)
                {
                    for (int i = 0; i < return_lst.Count; i++)
                    {
                        return_lst1 = main_func.get_dir(window_umk.selected_path + "\\" + window_umk.selected_obj + "\\" + return_lst[i]);
                        if (return_lst1.Count > 0)
                        {
                            for (int j = 0; j < return_lst1.Count; j++)
                            {
                                string[] row1 = { return_lst1[j], "папка", window_umk.selected_path + "\\" + window_umk.selected_obj + "\\" + return_lst[i] + "\\"};
                                //dg_prj_files.Rows.Add(row1);
                            }
                        }
                    }
                }
            }
            else
            {
                return_lst.Clear();
                return_lst = main_func.get_dir(window_umk.selected_path + "\\" + window_umk.selected_obj);
                if (return_lst.Count > 0)
                {
                    for (int i = 0; i < return_lst.Count; i++)
                    {
                        string[] row1 = { return_lst[i], "папка", window_umk.selected_path + "\\" + window_umk.selected_obj + "\\" };
                        //dg_prj_files.Rows.Add(row1);
                    }
                }
            }
        }
        }
 }
예제 #22
0
파일: MainForm.cs 프로젝트: developer88/umk
        private void backgroundStructurWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
               {
               //start_create_structure();
               m_isStructurising = true;
               string temp_str = "";
               developers_components_lib.cls_filesystem filesys_func = new developers_components_lib.cls_filesystem();
               developers_components_lib.cls_converter convert_func = new developers_components_lib.cls_converter();
               cls_prj prj_func = new cls_prj();
               cls_main main_func = new cls_main();
               System.Collections.ObjectModel.Collection<string> db_files = new System.Collections.ObjectModel.Collection<string>();
               System.Collections.ObjectModel.Collection<string> db_temp_list = new System.Collections.ObjectModel.Collection<string>();
               System.Collections.ObjectModel.Collection<string> lst_files = new System.Collections.ObjectModel.Collection<string>();
               System.Collections.ObjectModel.Collection<string> lst_plan = new System.Collections.ObjectModel.Collection<string>();
               System.Collections.ObjectModel.Collection<string> lst_eplan_rows = new System.Collections.ObjectModel.Collection<string>();
               lst_plan = open_plan(s_plan_name);
               db_files.Clear();
               prj_func.create_prj_dir("distr", prj_open_name, true);
               string control_template = main_func.read_all_file(appdir + "Styles\\disk_styles\\" + disk_style + "\\control\\index.htm");
               string control_row_template = main_func.read_all_file(appdir + "Styles\\disk_styles\\" + disk_style + "\\control\\row_template.htm");
               string control_rows_str = "";
               string umk_row_year_template = main_func.read_all_file(appdir + "Styles\\disk_styles\\" + disk_style + "\\umk\\row_year.htm");
               string umk_row_year_temp_str = "";
               string umk_rows_str = "";
               string umk_final_rows_str = "";
               string sub_umk_rows_str = "";
               string sub_umk_template_temp = "";
               string subumk_template = main_func.read_all_file(appdir + "Styles\\disk_styles\\" + disk_style + "\\umk\\sub_umk.htm");
               string subumk_row_template = main_func.read_all_file(appdir + "Styles\\disk_styles\\" + disk_style + "\\umk\\subumk_row_template.htm");
               string umk_template = main_func.read_all_file(appdir + "Styles\\disk_styles\\" + disk_style + "\\umk\\index.htm");
               string umk_row_template = main_func.read_all_file(appdir + "Styles\\disk_styles\\" + disk_style + "\\umk\\row_template.htm");
               //
               //copying system files
               //
               backgroundStructurWorker.ReportProgress(10);
               if (chk_service_enabled.Enabled == true & chk_service_enabled.Checked == true) { main_func.DirectoryCopy(appdir + "system\\service", appdir + "Projects\\" + prj_open_name + "\\distr\\SERVICE", true); }
               main_func.DirectoryCopy(appdir + "system\\umk", appdir + "Projects\\" + prj_open_name + "\\distr\\", true);
               //
               //copying UMK FILES
               //
               backgroundStructurWorker.ReportProgress(20);
               if (lst_plan.Count > 0)
               {
                   //create test
                   if ( s_control_type == "page")
                   {
                       main_func.DirectoryCopy(appdir + "Styles\\disk_styles\\" + disk_style + "\\control\\files", appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\control\\", true);
                       control_template = control_template.Replace("{CAPTION}", txt_menu_control.Text);
                   }
                   //create education
                   if (s_edu_type == "page")
                   {
                       main_func.DirectoryCopy(appdir + "Styles\\disk_styles\\" + disk_style + "\\umk\\files", appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\", true);
                       umk_template = umk_template.Replace("{SPECIALIZATION}", txt_specialization.Text);
                       umk_template = umk_template.Replace("{all_years}", txt_total_year.Text);
                       //umk_template = umk_template.Replace("{SPECIALIZATION}", txt_specialization.Text);
                       //umk_template = umk_template.Replace("{SPECIALIZATION}", txt_specialization.Text);
                   }
                   main_func.clear_lst_to_file();
                   main_func.add_to_lst_to_file("version=" + shell_search_db_version);
                   string type = "";
                   int n = 0;
                   int Col = 0;
                   string umk_name = "";
                   backgroundStructurWorker.ReportProgress(30);
                   for (int h = 0; h < 7; h++)
                   {
                       Col = 0;
                       for (int i = 0; i < lst_plan.Count; i++)
                       {
                           string ss = lst_plan[i];
                           string[] plan_data = ss.Split(Convert.ToChar(";"));
                           if (plan_data[3] == h.ToString())
                           {
                               lst_files.Clear();
                               lst_files = main_func.get_files_indir(umk_folder + "\\" + plan_data[2]);
                               if (lst_files.Count > 0)
                               {
                                   if (Directory.Exists(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name))
                                   {
                                       umk_name = main_func.get_filename(plan_data[2]) + "_" + h.ToString() + i.ToString();
                                   }
                                   else
                                   {
                                       umk_name = main_func.get_filename(plan_data[2]);
                                   }
                                   Directory.CreateDirectory(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name);
                                   if (s_control_type == "page") { Directory.CreateDirectory(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\test"); }
                                   Directory.CreateDirectory(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html");
                                   temp_str = umk_row_template;
                                   n++;
                                   int nt = i + 1;
                                   string cur_umk = umk_folder + "\\" + plan_data[2] + "\\info.dat";
                                   temp_str = temp_str.Replace("{n}", nt.ToString());
                                   temp_str = temp_str.Replace("{name}", plan_data[0]);
                                   temp_str = temp_str.Replace("{HOURS}", main_func.get_value_from_infofile(cur_umk, "hours"));
                                   temp_str = temp_str.Replace("{LINK}", umk_name + "/html/index.htm");
                                   temp_str = temp_str.Replace("{CODE}", plan_data[1]);
                                   sub_umk_template_temp = subumk_template;
                                   sub_umk_template_temp = sub_umk_template_temp.Replace("{CAPTION}", plan_data[0]);
                                   sub_umk_rows_str = "";
                                   if (main_func.get_value_from_infofile(cur_umk, "exam") == "1")
                                   {
                                       temp_str = temp_str.Replace("{EXAM}", "+");
                                   }
                                   else
                                   {
                                       temp_str = temp_str.Replace("{EXAM}", "-");
                                   }
                                   if (main_func.get_value_from_infofile(cur_umk, "test") == "1")
                                   {
                                       temp_str = temp_str.Replace("{TEST}", "+");
                                   }
                                   else
                                   {
                                       temp_str = temp_str.Replace("{TEST}", "-");
                                   }
                                   if (main_func.get_value_from_infofile(cur_umk, "examination") == "1")
                                   {
                                       temp_str = temp_str.Replace("{EXAMINATION}", "+");
                                   }
                                   else
                                   {
                                       temp_str = temp_str.Replace("{EXAMINATION}", "-");
                                   }
                                   if (main_func.get_value_from_infofile(cur_umk, "prj") == "1")
                                   {
                                       temp_str = temp_str.Replace("{PRJ}", "+");
                                   }
                                   else
                                   {
                                       temp_str = temp_str.Replace("{PRJ}", "-");
                                   }
                                   umk_rows_str = umk_rows_str + temp_str;
                                   main_func.DirectoryCopy(appdir + "Styles\\disk_styles\\" + disk_style + "\\umk\\subfiles", appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\", true);

                                   for (int j = 0; j < lst_files.Count; j++)
                                   {
                                       if (main_func.get_extention(lst_files[j]) != "info")
                                       {
                                           if (File.Exists(umk_folder + "\\" + plan_data[2] + "\\" + lst_files[j] + ".info"))
                                           {
                                               string file_name = umk_folder + "\\" + plan_data[2] + "\\" + lst_files[j];
                                               string tags = main_func.get_value_from_infofile(file_name + ".info", "tags");
                                               if (tags != "" & Microsoft.VisualBasic.Strings.Left(tags, 1) != ",") { tags = "," + tags; }
                                               type = main_func.get_value_from_infofile(file_name + ".info", "file_type");

                                               string for_course = main_func.get_value_from_infofile(file_name + ".info", "course");
                                               bool file_is_good = false;
                                               if (for_course != "")
                                               {
                                                   if (for_course==Convert.ToString(Convert.ToInt32( plan_data[3])+1))
                                                   {
                                                      file_is_good=true;
                                                   }
                                                   else
                                                   {
                                                       string[] ss1 = for_course.Split(Convert.ToChar(","));
                                                       if (ss1.GetUpperBound(0) > 0)
                                                       {
                                                           for (int a = 0; a < ss1.GetUpperBound(0); a++)
                                                           {
                                                               if (ss1[a] == Convert.ToString(Convert.ToInt32(plan_data[3]) + 1)) { file_is_good = true; };
                                                           }
                                                       }
                                                   }
                                               }
                                               else
                                               {
                                                   file_is_good = true;
                                               }
                                                   switch (type)
                                                   {
                                                       case "Тесты (AIST)":
                                                           temp_str = control_row_template;
                                                           if (chk_zip_tests_enabled.Checked == true)
                                                           {
                                                               File.Copy(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\test\\test.zip", true);
                                                               temp_str = temp_str.Replace("{LINK}", "ztest://" + "umk/" + umk_name + "/test/test.zip");
                                                               if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\test\\test.zip;test,аист,aist,тестирование" + tags); }
                                                           }
                                                           else
                                                           {
                                                               filesys_func.extract_all_to_fldr(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\test\\");
                                                               if (File.Exists(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\test\\Aist-3w.exe"))
                                                               {
                                                                   temp_str = temp_str.Replace("{LINK}", "app://" + "umk/" + umk_name + "/test/Aist-3w.exe");
                                                               }
                                                               else
                                                               {
                                                                   temp_str = temp_str.Replace("{LINK}", "app://" + "umk/" + umk_name + "/test/app_test.exe");
                                                               }
                                                               if (chk_search_enabled.Checked == true)
                                                               {
                                                                   db_temp_list.Clear();
                                                                   db_temp_list = main_func.get_files_indir(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\test\\");
                                                                   if (db_temp_list.Count > 0)
                                                                   {
                                                                       for (int t = 0; t < db_temp_list.Count; t++)
                                                                       {
                                                                           db_files.Add("Content\\umk\\" + umk_name + "\\test\\" + db_temp_list[t] + ";test,тест,тестирование" + tags);
                                                                       }
                                                                   }
                                                               }
                                                           }
                                                           temp_str = temp_str.Replace("{NAME}", plan_data[0]);
                                                           control_rows_str = control_rows_str + temp_str;
                                                           break;
                                                       case "Тесты":
                                                           temp_str = control_row_template;
                                                           if (main_func.get_extention(file_name) == "htm" | main_func.get_extention(file_name) == "html")
                                                           {
                                                               File.Copy(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\test\\" + main_func.get_filename(file_name));
                                                               temp_str = temp_str.Replace("{LINK}", "../umk/" + umk_name + "/test/" + main_func.get_filename(file_name));
                                                               if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\test\\" + main_func.get_filename(file_name) + ";test,тест,тестирование,документ,файл,предмет,автор" + tags); }
                                                           }
                                                           else
                                                           {
                                                               if (s_convert_to_type == "PDF (*.pdf)")
                                                               {
                                                                   temp_str = temp_str.Replace("{LINK}", "other://umk/" + umk_name + "/test/test.pdf");
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\test\\test.pdf", "pdf");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\test\\test.pdf;test,тест,тестирование,документ,файл,предмет,автор" + tags); }
                                                               }
                                                               else
                                                               {
                                                                   temp_str = temp_str.Replace("{LINK}", "../umk/" + umk_name + "/test/test.htm");
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\test\\test.htm", "html");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\test\\test.htm;test,тест,тестирование,страница,предмет,автор" + tags); }
                                                               }
                                                           }
                                                           /*
                                                           if (chk_zip_tests_enabled.Checked == true)
                                                           {
                                                               File.Copy(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + dg_prj_files.Rows[i].Cells[0].Value.ToString() + "\\test\\test.zip", true);
                                                               temp_str = temp_str.Replace("{LINK}", "ztest://" + "umk/" + dg_prj_files.Rows[i].Cells[0].Value.ToString() + "/test/test.zip");
                                                               if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + dg_prj_files.Rows[i].Cells[0].Value.ToString() + "\\test\\test.zip;test,тестирование" + tags); }
                                                           }
                                                           else
                                                           {
                                                               filesys_func.extract_all_to_fldr(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + dg_prj_files.Rows[i].Cells[0].Value.ToString() + "\\test\\");
                                                               temp_str = temp_str.Replace("{LINK}", "app://" + "umk/" + dg_prj_files.Rows[i].Cells[0].Value.ToString() + "/test/app_test.exe");
                                                               if (chk_search_enabled.Checked == true)
                                                               {
                                                                   db_temp_list.Clear();
                                                                   db_temp_list = main_func.get_files_indir(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + dg_prj_files.Rows[i].Cells[0].Value.ToString() + "\\test\\");
                                                                   if (db_temp_list.Count > 0)
                                                                   {
                                                                       for (int t = 0; t < db_temp_list.Count; t++)
                                                                       {
                                                                           db_files.Add("Content\\umk\\" + dg_prj_files.Rows[i].Cells[0].Value.ToString() + "\\test\\" + db_temp_list[t] + ";test,тест,тестирование" + tags);
                                                                       }
                                                                   }
                                                               }
                                                           }*/
                                                           temp_str = temp_str.Replace("{NAME}", plan_data[0]);
                                                           control_rows_str = control_rows_str + temp_str;
                                                           break;
                                                       case "Метод. указания":
                                                           if (file_is_good)
                                                           {
                                                               temp_str = subumk_row_template;
                                                               if (s_convert_to_type == "PDF (*.pdf)")
                                                               {
                                                                   temp_str = temp_str.Replace("{LINK}", "other://umk/" + umk_name + "/html/met.pdf");
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\met.pdf", "pdf");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\html\\met.pdf;методичка,методические,указания,документ,файл,предмет,автор" + tags); }
                                                               }
                                                               else
                                                               {
                                                                   temp_str = temp_str.Replace("{LINK}", "met.htm");
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\met.htm", "html");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\html\\met.htm;методичка,методические,указания,страница,предмет,автор" + tags); }
                                                               }
                                                               temp_str = temp_str.Replace("{NAME}", "Методические указания");
                                                               sub_umk_rows_str = sub_umk_rows_str + temp_str;
                                                           }
                                                           break;
                                                       case "Лекции":
                                                           if (file_is_good)
                                                           {
                                                               temp_str = subumk_row_template;
                                                               if (s_convert_to_type == "PDF (*.pdf)")
                                                               {
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\lectures.pdf", "pdf");
                                                                   temp_str = temp_str.Replace("{LINK}", "other://umk/" + umk_name + "/html/lectures.pdf");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\html\\lectures.pdf;лекции,материал,лекционный,файл,документ,предмет,автор" + tags); }
                                                               }
                                                               else
                                                               {
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\lectures.htm", "html");
                                                                   temp_str = temp_str.Replace("{LINK}", "lectures.htm");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\html\\lectures.htm;лекции,материал,лекционный,страница,предмет,автор" + tags); }
                                                               }
                                                               temp_str = temp_str.Replace("{NAME}", "Лекции");
                                                               sub_umk_rows_str = sub_umk_rows_str + temp_str;
                                                           }
                                                           break;
                                                       case "Билеты":
                                                           if (file_is_good)
                                                           {
                                                               temp_str = subumk_row_template;
                                                               if (s_convert_to_type == "PDF (*.pdf)")
                                                               {
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\notes.pdf", "pdf");
                                                                   temp_str = temp_str.Replace("{LINK}", "other://umk/" + umk_name + "/html/notes.pdf");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\html\\notes.pdf;билеты,задания,файл,документ,предмет,автор" + tags); }
                                                               }
                                                               else
                                                               {
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\notes.htm", "html");
                                                                   temp_str = temp_str.Replace("{LINK}", "notes.htm");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\html\\notes.htm;билеты,задаения,страница,предмет,автор" + tags); }
                                                               }
                                                               temp_str = temp_str.Replace("{NAME}", "Билеты");
                                                               sub_umk_rows_str = sub_umk_rows_str + temp_str;
                                                           }
                                                           break;
                                                       case "Раб.программа":
                                                           if (file_is_good)
                                                           {
                                                               temp_str = subumk_row_template;
                                                               if (s_convert_to_type == "PDF (*.pdf)")
                                                               {
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\programme.pdf", "pdf");
                                                                   temp_str = temp_str.Replace("{LINK}", "other://umk/" + umk_name + "/html/programme.pdf");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\html\\programme.pdf;программа,рабочая,курс,лекции,экзамен,тест,зачёт,зачет,билеты,проект,курсовой,курсовая,курсовик,итог,тестирование,файл,документ,предмет,автор" + tags); }
                                                               }
                                                               else
                                                               {
                                                                   convert_func.convert(file_name, appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\programme.htm", "html");
                                                                   temp_str = temp_str.Replace("{LINK}", "programme.htm");
                                                                   if (chk_search_enabled.Checked == true) { db_files.Add("Content\\umk\\" + umk_name + "\\html\\programme.htm;программа,рабочая,курс,лекции,экзамен,тест,зачёт,зачет,билеты,проект,курсовой,курсовая,курсовик,итог,тестирование,страница,предмет,автор" + tags); }
                                                               }
                                                               temp_str = temp_str.Replace("{NAME}", "Рабочая учебная программа");
                                                               sub_umk_rows_str = sub_umk_rows_str + temp_str;
                                                           }
                                                           break;
                                               }
                                           }
                                       }
                                       Col++;
                                   }
                                   sub_umk_template_temp = sub_umk_template_temp.Replace("{ROWS}", sub_umk_rows_str);
                                   main_func.write_all_text_to_file(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\" + umk_name + "\\html\\index.htm", sub_umk_template_temp);
                               }
                           }
                       }
                       if (Col > 0)
                       {
                           umk_row_year_temp_str = umk_row_year_template;
                           int ts = h + 1;
                           umk_row_year_temp_str = umk_row_year_temp_str.Replace("{YEAR}", ts.ToString());
                           umk_final_rows_str = umk_final_rows_str + umk_row_year_temp_str + umk_rows_str;
                           umk_rows_str = "";
                       }
                   }

                   if (s_control_type == "page")
                   {
                       control_template = control_template.Replace("{ROWS}", control_rows_str);
                       main_func.write_all_text_to_file(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\control\\index.htm", control_template);
                   }
                   if (s_edu_type == "page")
                   {
                       umk_template = umk_template.Replace("{ROWS}", umk_final_rows_str);
                       main_func.write_all_text_to_file(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\umk\\index.htm", umk_template);
                   }
               }
               else
               {
                   MessageBox.Show("В выбранном учебном плане нет файлов!", "Отсутствуют файлы", MessageBoxButtons.OK, MessageBoxIcon.Warning);
               }
               //
               //create files.db
               //
               backgroundStructurWorker.ReportProgress(50);
               if (chk_search_enabled.Checked == true)
               {
                   main_func.clear_lst_to_file();
                   if (db_files.Count > 0)
                   {
                       for (int i = 0; i < db_files.Count; i++)
                       {
                           main_func.add_to_lst_to_file(db_files[i]);
                       }
                       main_func.write_to_info_file(prj_folder + prj_open_name + "\\distr\\files.db");
                   }
               }
               backgroundStructurWorker.ReportProgress(60);
               //
               //create autorun.inf
               //
               if (chk_create_autorun_inf.Checked == true)
               {
                   main_func.clear_lst_to_file();
                   main_func.add_to_lst_to_file("[autorun]");
                   main_func.add_to_lst_to_file("open=umk_shell.exe");
                   if (File.Exists(appdir + "Projects\\" + prj_open_name + "\\temp\\autorun\\disk_icon.ico"))
                   {
                       File.Copy(appdir + "Projects\\" + prj_open_name + "\\temp\\autorun\\disk_icon.ico", prj_folder + prj_open_name + "\\distr\\autorun.ico", true);
                       main_func.add_to_lst_to_file("icon=autorun.ico");
                   }
                   main_func.write_to_info_file(prj_folder + prj_open_name + "\\distr\\autorun.inf");
               }
               //
               //create strings.inf
               //
               backgroundStructurWorker.ReportProgress(70);
               main_func.clear_lst_to_file();
               main_func.add_to_lst_to_file("version=" + shell_config_version);
               main_func.add_to_lst_to_file("[MAIN_SETTINGS]");
               main_func.add_to_lst_to_file("search_enabled=" + chk_search_enabled.Checked.ToString());
               main_func.add_to_lst_to_file("glass_enabled=" + chk_glass_enabled.Checked.ToString());
               if (s_licence_enabled == true)
               {
                   if (s_licence_type == "url")
                   {
                       main_func.add_to_lst_to_file("licence_path=" + txt_licence_path.Text);
                   }
                   else
                   {
                       main_func.add_to_lst_to_file("licence_path=" + "licence/licence.htm");
                   }
                   main_func.add_to_lst_to_file("licence_type=" + s_licence_type);
               }
               main_func.add_to_lst_to_file("[CAPTIONS]");
               main_func.add_to_lst_to_file("caption=" + txt_disk_name.Text);
               main_func.add_to_lst_to_file("author=" + txt_menu_about.Text);
               main_func.add_to_lst_to_file("learn_caption=" + txt_menu_edu.Text);
               main_func.add_to_lst_to_file("control_caption=" + txt_menu_control.Text);
               main_func.add_to_lst_to_file("[BUTTONS]");
               main_func.add_to_lst_to_file("splash_type=" + s_splash_type);
               if (s_splash_type == "url")
               {
                   main_func.add_to_lst_to_file("splash_path=" + txt_splash_path.Text);
               }
               else
               {
                   main_func.add_to_lst_to_file("splash_path=splash\\" + txt_splash_path.Text);
               }
               main_func.add_to_lst_to_file("splash_enabled=" + chk_splash_enabled.Checked.ToString());
               main_func.add_to_lst_to_file("help_type=page");
               //+ s_help_type  chk_help_enabled.Checked.ToString()
               main_func.add_to_lst_to_file("help_enabled=True" );
               main_func.add_to_lst_to_file("help_path=help\\index.htm");
               main_func.add_to_lst_to_file("umk_type=" + s_edu_type);
               main_func.add_to_lst_to_file("umk_enabled=" + chk_edu_enabled.Checked.ToString());
               if (s_edu_type == "url")
               {
                   main_func.add_to_lst_to_file("umk_path=" + txt_menu_edu_path.Text);
               }
               else
               {
                   main_func.add_to_lst_to_file("umk_path=umk\\index.htm");
               }
               main_func.add_to_lst_to_file("test_type=" + s_control_type);
               main_func.add_to_lst_to_file("test_enabled=" + chk_control_enabled.Checked.ToString());
               if (s_control_type == "url")
               {
                   main_func.add_to_lst_to_file("test_path=" + txt_menu_control_path.Text);
               }
               else
               {
                   main_func.add_to_lst_to_file("test_path=control\\index.htm");
               }
               main_func.add_to_lst_to_file("about_type=" + s_about_type);
               main_func.add_to_lst_to_file("about_enabled=" + chk_about_enabled.Checked.ToString());
               if (s_about_type == "url")
               {
                   main_func.add_to_lst_to_file("about_path=" + txt_menu_about_path.Text);
               }
               else
               {
                   main_func.add_to_lst_to_file("about_path=about\\" + txt_menu_about_path.Text);
               }
               main_func.write_to_info_file(prj_folder + prj_open_name + "\\distr\\strings.inf");
               //
               //copy files from temp
               //
               backgroundStructurWorker.ReportProgress(80);
               if (s_splash_type != "url")
               {
                   //copy splash
                   if (Directory.Exists(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\splash") == false) { Directory.CreateDirectory(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\splash"); }
                   main_func.DirectoryCopy(appdir + "Projects\\" + prj_open_name + "\\temp\\splash", appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\splash", true);
               }
               if (s_help_type == "page")
               {
                   //copy help
                   if (Directory.Exists(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\help") == false) { Directory.CreateDirectory(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\help"); }
                   main_func.DirectoryCopy(appdir + "Projects\\" + prj_open_name + "\\temp\\help", appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\help", true);
               }
               if (s_about_type == "page")
               {
                   //copy about
                   if (Directory.Exists(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\about") == false) { Directory.CreateDirectory(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\about"); }
                   main_func.DirectoryCopy(appdir + "Projects\\" + prj_open_name + "\\temp\\about", appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\about", true);
               }
               //copy service files
               //main_func.DirectoryCopy(appdir + "system\\service", appdir + "Projects\\" + prj_open_name + "\\distr\\SERVICE", true);
               //
               //SET CHANGES
               //
               backgroundStructurWorker.ReportProgress(90);
               prj_IS_built = true;
               prj_build_date = DateTime.Now.Date.Day.ToString() + "." + DateTime.Now.Date.Month.ToString() + "." + DateTime.Now.Date.Year.ToString();
               //create help
                   main_func.DirectoryCopy(appdir + "Styles\\disk_styles\\" + disk_style + "\\help\\files", appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\help\\", true);
                   string help_template = main_func.read_all_file(appdir + "Styles\\disk_styles\\" + disk_style + "\\help\\index.htm");
                   if (txt_menu_help_path.Text != "" & chk_help_enabled.Checked.ToString()=="True")
                   {
                       help_template = help_template.Replace("{HELP_LINK}", txt_menu_help_path.Text);
                       help_template = help_template.Replace("{HELP_LINK_ENABLED}", "block");
                   }
                   else
                   {
                       help_template = help_template.Replace("{HELP_LINK}", "#");
                       help_template = help_template.Replace("{HELP_LINK_ENABLED}", "none");
                   }
                   main_func.write_all_text_to_file(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\help\\index.htm", help_template);
               if (s_licence_type == "page")
               {
                   //copy licence
                   if (Directory.Exists(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\licence") == false) { Directory.CreateDirectory(appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\licence"); }
                   main_func.DirectoryCopy(appdir + "Projects\\" + prj_open_name + "\\temp\\licence", appdir + "Projects\\" + prj_open_name + "\\distr\\Content\\licence", true);
               }
               //
               //Add files_folders to listBoxFiles
               //
               add_prj_to_listboxfiles();
               backgroundStructurWorker.ReportProgress(100);
               e.Result = 0;
               }
               catch ( Exception ex)
               {
               MessageBox.Show(ex.Message);
               e.Result = 1;
               }
        }
예제 #23
0
        public void LoadExchangeDAG()
        {
            if (ExchangeServerTextBox.Text.ToLower().Contains("http://") == false && ExchangeServerTextBox.Text.ToLower().Contains("https://") == false)
            {
                errorDiv.InnerHtml   = "Not a Valid Exchange Server Address!. Server Address shoud be in the form of 'https://myexchange.com'";
                errorDiv.Style.Value = "display: block";
                return;
            }

            DataTable dt       = new DataTable();
            string    strError = "";
            string    UserName = "";
            string    Password = "";

            if (CredentialsComboBox.Text != "")
            {
                ArrayList Cred = getCredentials();
                if (Cred.Count > 1)
                {
                    UserName = Cred[0].ToString();
                    Password = Cred[1].ToString();

                    if (UserName == "" || Password == "")
                    {
                        errorDiv.InnerHtml   = "User Id or Password not set for the selected Credentials";
                        errorDiv.Style.Value = "display: block";
                        return;
                    }
                }
            }
            else
            {
                UserName = UserIdtextBox.Text;                // "jnittech\\administrator";
                Password = PasswordTextbox.Text;              // "Pa$$w0rd";
                if (UserName == "" || Password == "")
                {
                    errorDiv.InnerHtml   = "Please Enter the User Id and Password.";
                    errorDiv.Style.Value = "display: block";
                    return;
                }
            }
            Uid = UserName;
            Pwd = Password;


            string IPAddress = ExchangeServerTextBox.Text;            // "https://jnittech-exchg1.jnittech.com";
            //ViewState["Pwd"] = Password;
            //ViewState.Add("Pwd", Password);
            bool updatedsrv = VSWebBL.SettingBL.SettingsBL.Ins.UpdateSvalue("Primary Exchange Server", ExchangeServerTextBox.Text, VSWeb.Constants.Constants.SysString);

            System.Uri uri = new Uri(IPAddress + "/powershell?serializationLevel=Full");
            System.Security.SecureString securePassword = String2SecureString(Password);
            PSCredential creds      = new PSCredential(UserName, securePassword);
            Runspace     runspace   = RunspaceFactory.CreateRunspace();
            PowerShell   powershell = PowerShell.Create();

            PSCommand command = new PSCommand();

            command.AddCommand("New-PSSession");
            command.AddParameter("ConfigurationName", "Microsoft.Exchange");
            command.AddParameter("ConnectionUri", uri);
            command.AddParameter("Credential", creds);
            command.AddParameter("Authentication", "Default");
            System.Collections.ObjectModel.Collection <PSObject> results = new System.Collections.ObjectModel.Collection <PSObject>();

            PSSessionOption sessionOption = new PSSessionOption();

            sessionOption.SkipCACheck         = true;
            sessionOption.SkipCNCheck         = true;
            sessionOption.SkipRevocationCheck = true;

            command.AddParameter("SessionOption", sessionOption);
            powershell.AddScript(@"set-executionpolicy unrestricted");
            powershell.Commands = command;

            try
            {
                using (runspace)
                {
                    runspace.Open();
                    powershell.Runspace = runspace;
                    System.Collections.ObjectModel.Collection <PSSession> result = powershell.Invoke <PSSession>();

                    //foreach (ErrorRecord current in powershell.Streams.Error)
                    //{
                    //    strError += "Exception Importing Servers: " + current.Exception.ToString() + ",\r\nInner Exception: " + current.Exception.InnerException;
                    //    errorDiv.InnerHtml = strError;
                    //    errorDiv.Style.Value = "display: block";
                    //    return;
                    //}

                    if (result.Count == 0)
                    {
                        //errorDiv.InnerHtml = "Unexpected number of Remote Runspace connections returned.";
                        //errorDiv.Style.Value = "display: block";
                        //return;
                        foreach (ErrorRecord current in powershell.Streams.Error)
                        {
                            strError            += "Exception Importing Servers: " + current.Exception.ToString() + ",\r\nInner Exception: " + current.Exception.InnerException;
                            errorDiv.InnerHtml   = strError;
                            errorDiv.Style.Value = "display: block";
                            return;
                        }
                    }
                    PSSession pssession = (PSSession)result[0];
                    command = new PSCommand();
                    command.AddCommand("Set-Variable");
                    command.AddParameter("Name", "ra");
                    command.AddParameter("Value", result[0]);
                    powershell.Commands = command;;
                    powershell.Invoke();


                    command = new PSCommand();
                    command.AddScript("Import-PSSession -Session $ra -CommandName Get-DatabaseAvailabilityGroup, Test-ReplicationHealth, Get-MailboxDatabase, Get-MailboxDatabaseCopyStatus");
                    powershell.Commands = command;
                    powershell.Invoke();

                    powershell.Streams.Error.Clear();

                    String str = "Get-DatabaseAvailabilityGroup | Select-Object -Property Name,WitnessServer";
                    powershell.AddScript(str);

                    results = powershell.Invoke();

                    dt.Columns.Add("DAGName", typeof(string));
                    dt.Columns.Add("WitnessServer", typeof(string));
                    if (results.Count > 0)
                    {
                        foreach (PSObject ps in results)
                        {
                            string Fqdn = ps.Properties["Name"].Value.ToString();
                            string name = ps.Properties["Name"].Value.ToString();
                            //load exchange servers
                            errorDiv.Style.Value     = "display: none;";
                            errorinfoDiv.Style.Value = "display: none";
                            DataTable LocationsDataTable = new DataTable();
                            LocationsDataTable = VSWebBL.SecurityBL.LocationsBL.Ins.GetAllData();
                            if (LocationsDataTable.Rows.Count > 0)
                            {
                                LocComboBox.DataSource = LocationsDataTable;
                                LocComboBox.TextField  = "Location";
                                LocComboBox.ValueField = "Location";
                                LocComboBox.DataBind();
                                LocIDComboBox.DataSource = LocationsDataTable;
                                LocIDComboBox.TextField  = "ID";
                                LocIDComboBox.ValueField = "ID";
                                LocIDComboBox.DataBind();

                                try
                                {
                                    DataRow[] foundRows;

                                    DataTable importedDT;
                                    importedDT = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetServer();
                                    foundRows  = importedDT.Select("ServerName = '" + name + "'");
                                    if (foundRows.Length == 0)
                                    {
                                        DataRow dr = dt.NewRow();
                                        dr["DAGName"]       = name;
                                        dr["WitnessServer"] = name;
                                        dt.Rows.Add(dr);
                                        dr = dt.NewRow();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    errorDiv.InnerHtml       = "The following error has occurred: " + ex.Message;
                                    errorDiv.Style.Value     = "display: block";
                                    errorinfoDiv.Style.Value = "display: block";
                                    Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                                    return;
                                }
                            }
                            else
                            {
                                errorDiv.InnerHtml   = "All imported servers must be assigned to a location. There were no locations found. Please create at least one location entry using the 'Setup & Security - Maintain Server Locations' menu option.";
                                errorDiv.Style.Value = "display: block";
                                return;
                            }
                        }
                        results.Clear();
                        result.Clear();
                        if (dt.Rows.Count > 0)
                        {
                            infoDiv.Style.Value        = "display: block";
                            SrvCheckBoxList.DataSource = dt;
                            SrvCheckBoxList.TextField  = "DAGName";
                            SrvCheckBoxList.ValueField = "DAGName";
                            SrvCheckBoxList.DataBind();
                            IPCheckBoxList.DataSource = dt;
                            IPCheckBoxList.TextField  = "DAGName";
                            IPCheckBoxList.ValueField = "DAGName";
                            IPCheckBoxList.DataBind();
                            ASPxRoundPanel1.Visible = true;
                        }
                        else
                        {
                            errorDiv.InnerHtml   = "There are no new servers in the address book that have not already been imported into VitalSigns.";
                            errorDiv.Style.Value = "display: block";
                            return;
                        }
                        if (pssession != null)
                        {
                            Command cmd = new Command("remove-pssession");
                            cmd.Parameters.Add("id", pssession.Id);
                            powershell.Commands.Clear();
                            powershell.Commands.AddCommand(cmd);
                            powershell.Invoke();
                        }
                        if (runspace != null)
                        {
                            if (runspace.RunspaceStateInfo.State == RunspaceState.Opened)
                            {
                                runspace.Close();
                                runspace.Dispose();
                                powershell.Dispose();
                            }
                        }
                    }
                    else
                    {
                        errorDiv.InnerHtml   = "No Servers Found!.";
                        errorDiv.Style.Value = "display: block";
                        return;
                    }
                }
                GC.Collect();
            }
            catch (Exception ex)
            {
                errorDiv.InnerHtml   = ex.Message.ToString();
                errorDiv.Style.Value = "display: block";
                return;
            }
        }
예제 #24
0
        void doUpdate()
        {
            Process pro = new Process();

            pro.StartInfo.FileName  = bin;
            pro.StartInfo.Arguments = "/iu test";

            //try
            //{

            pro.StartInfo.RedirectStandardOutput = true;
            pro.StartInfo.UseShellExecute        = false;
            pro.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            pro.StartInfo.CreateNoWindow         = true;
            pro.Start();

            pro.WaitForExit();

            string output = pro.StandardOutput.ReadToEnd();

            System.Diagnostics.Debug.WriteLine(output);
            if (output.Contains("Zune is currently running"))
            {
                MessageBox.Show("Zune is running. Close it and try again.");
                return;
            }
            if (output.Contains("COM"))
            {
                if (MessageBox.Show("You don't have the Windows Phone Support Tools installed. Press OK to download them.", "", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                {
                    Process bro = new Process();
                    bro.StartInfo.FileName = "http://forum.xda-developers.com/attachment.php?attachmentid=751891&d=1318801790";
                    bro.Start();
                }
                return;
            }
            if (!output.Contains("Applying update"))
            {
                MessageBox.Show("An unknown error occured:\n" + output);
                return;
            }
            System.Diagnostics.Debug.Write(output);



            //Get phone OS version
            currentversion = getVersionFromOutput(output);


            if (availablePackages.selectedLanguages.Count == 0)
            {
                languagelist frm = new languagelist();
                frm.ShowDialog();

                for (int i = 0; i < frm.checkedListBox1.Items.Count; i++)
                {
                    if (frm.checkedListBox1.CheckedItems.Contains(frm.checkedListBox1.Items[i]))
                    {
                        availablePackages.selectedLanguages.Add(i);
                    }
                }
            }

            button1.Enabled = false;

            progressBar1.Style   = ProgressBarStyle.Marquee;
            progressBar1.Enabled = true;
            progressBar1.MarqueeAnimationSpeed = 40;

            if (currentversion.Contains("7720"))
            {
                lblStatus.Text = "Downloading 7740...";

                packages.Clear();

                packages.Add(availablePackages.ver7740);

                System.Threading.Thread th = new System.Threading.Thread(() =>
                {
                    installPackages();
                });
                th.Start();
            }

            if (currentversion.Contains("7740"))
            {
                lblStatus.Text = "Downloading 8107...";
                packages.Clear();

                packages.Add(availablePackages.ver8107);
                for (int i = 0; i < availablePackages.selectedLanguages.Count; i++)
                {
                    packages.Add(availablePackages.ver8107langs[availablePackages.selectedLanguages[i]]);
                }

                System.Threading.Thread th = new System.Threading.Thread(() =>
                {
                    installPackages();
                });
                th.Start();
            }

            if (currentversion.Contains("8107"))
            {
                lblStatus.Text = "Tango time, 1 of 2...";
                packages.Clear();

                packages.Add(availablePackages.ver8112_1);
                packages.Add(availablePackages.ver8112_2);

                for (int i = 0; i < availablePackages.selectedLanguages.Count; i++)
                {
                    packages.Add(availablePackages.ver8112langs[availablePackages.selectedLanguages[i]]);
                }

                System.Threading.Thread th = new System.Threading.Thread(() =>
                {
                    installPackages();
                });
                th.Start();
            }

            if (currentversion.Contains("8112"))
            {
                lblStatus.Text = "Tango time, 2 of 2...";
                packages.Clear();

                packages.Add(availablePackages.ver8773_1);
                packages.Add(availablePackages.ver8773_2);

                for (int i = 0; i < availablePackages.selectedLanguages.Count; i++)
                {
                    packages.Add(availablePackages.ver8773langs[availablePackages.selectedLanguages[i]]);
                }

                System.Threading.Thread th = new System.Threading.Thread(() =>
                {
                    installPackages();
                });
                th.Start();
            }

            if (currentversion.Contains("8773"))
            {
                lblStatus.Text = "Downloading 8779 (pre-7.8, 1 of 3)...";

                packages.Clear();

                packages.Add(availablePackages.ver8779);
                for (int i = 0; i < availablePackages.selectedLanguages.Count; i++)
                {
                    packages.Add(availablePackages.ver8779langs[availablePackages.selectedLanguages[i]]);
                }

                System.Threading.Thread th = new System.Threading.Thread(() =>
                {
                    installPackages();
                });
                th.Start();
            }

            if (currentversion.Contains("8779"))
            {
                lblStatus.Text = "Downloading 8783 (pre-7.8, 2 of 3)...";

                packages.Clear();

                packages.Add(availablePackages.ver8783);

                System.Threading.Thread th = new System.Threading.Thread(() =>
                {
                    installPackages();
                });
                th.Start();
            }

            if (currentversion.Contains("8783"))
            {
                lblStatus.Text = "Downloading WP7.8 (3 of 3)...";


                packages.Clear();

                packages.Add(availablePackages.ver8858_1);
                packages.Add(availablePackages.ver8858_2);
                for (int i = 0; i < availablePackages.selectedLanguages.Count; i++)
                {
                    packages.Add(availablePackages.ver8858langs[availablePackages.selectedLanguages[i]]);
                }


                System.Threading.Thread th = new System.Threading.Thread(() =>
                {
                    installPackages();
                });
                th.Start();
            }
            if (currentversion.Contains("8858"))
            {
                lblStatus.Text = "Downloading WP7.8 fix...";

                packages.Clear();

                packages.Add(availablePackages.ver8860);

                System.Threading.Thread th = new System.Threading.Thread(() =>
                {
                    installPackages();
                });
                th.Start();
            }
            if (currentversion.Contains("8860"))
            {
                lblStatus.Text = "Downloading WP7.8 fix #2...";

                packages.Clear();

                packages.Add(availablePackages.ver8862);

                System.Threading.Thread th = new System.Threading.Thread(() =>
                {
                    installPackages();
                });
                th.Start();
            }
            if (currentversion.Contains("8862"))
            {
                progressBar1.Enabled = false;

                MessageBox.Show("Congratulations! You're done!");
            }
        }
예제 #25
0
 void update_level_files(int old_level)
 {
     System.Collections.ObjectModel.Collection<string> lst_to_delete= new System.Collections.ObjectModel.Collection<string>();
     //delete old values
     if (lst_all_umk.Count > 0)
     {
         lst_to_delete.Clear();
         foreach (string s_item in lst_all_umk)
         {
             string s_temp = Microsoft.VisualBasic.Strings.Right(s_item, 1);
             if (s_temp == old_level.ToString()) { lst_to_delete.Add(s_item); }
         }
         for (int i = 0; i < lst_to_delete.Count; i++)
         {
             lst_all_umk.Remove(lst_to_delete[i]);
         }
     }
     //add new values
     for (int i = 0; i < dg_prj_files.Rows.Count; i++)
     {
         string new_value = dg_prj_files.Rows[i].Cells[0].Value.ToString() + ";" + dg_prj_files.Rows[i].Cells[1].Value.ToString() + ";" + dg_prj_files.Rows[i].Cells[2].Value.ToString() + ";" + old_level.ToString();
         lst_all_umk.Add(new_value);
     }
 }
예제 #26
0
파일: PrintMgrForm.cs 프로젝트: AMEE/revit
        private void printerNameComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            m_printMgr.PrinterName = printerNameComboBox.SelectedItem as string;

            // Verify the relative controls is enable or not, according to the printer changed.
            m_printMgr.VerifyPrintToFile(printToFileCheckBox);

            System.Collections.ObjectModel.Collection<System.Windows.Forms.Control> controlsToEnableOrNot =
                new System.Collections.ObjectModel.Collection<System.Windows.Forms.Control>();
            controlsToEnableOrNot.Add(copiesNumericUpDown);
            controlsToEnableOrNot.Add(numberofcoyiesLabel);
            m_printMgr.VerifyCopies(controlsToEnableOrNot);

            controlsToEnableOrNot.Clear();
            controlsToEnableOrNot.Add(printToFileNameLabel);
            controlsToEnableOrNot.Add(printToFileNameTextBox);
            controlsToEnableOrNot.Add(browseButton);

            if (!string.IsNullOrEmpty(printToFileNameTextBox.Text))
            {
                printToFileNameTextBox.Text = printToFileNameTextBox.Text.Remove(
                    printToFileNameTextBox.Text.LastIndexOf(".")) + m_printMgr.PostFix;
            }

            m_printMgr.VerifyPrintToFileName(controlsToEnableOrNot);

            m_printMgr.VerifyPrintToSingleFile(singleFileRadioButton);
            m_printMgr.VerifyPrintToSeparateFile(separateFileRadioButton);
        }
예제 #27
0
파일: PrintMgrForm.cs 프로젝트: AMEE/revit
        /// <summary>
        /// Initialize the UI data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PrintMgrForm_Load(object sender, EventArgs e)
        {
            printerNameComboBox.DataSource = m_printMgr.InstalledPrinterNames;
            // the selectedValueChange event have to add event handler after
            // data source be set, or else the delegate method will be invoked meaningless.
            this.printerNameComboBox.SelectedValueChanged += new System.EventHandler(this.printerNameComboBox_SelectedValueChanged);
            printerNameComboBox.SelectedItem = m_printMgr.PrinterName;
            if (m_printMgr.VerifyPrintToFile(printToFileCheckBox))
            {
                printToFileCheckBox.Checked = m_printMgr.IsPrintToFile;
            }

            System.Collections.ObjectModel.Collection<System.Windows.Forms.Control> controlsToEnableOrNot =
                new System.Collections.ObjectModel.Collection<System.Windows.Forms.Control>();
            controlsToEnableOrNot.Add(copiesNumericUpDown);
            controlsToEnableOrNot.Add(numberofcoyiesLabel);
            m_printMgr.VerifyCopies(controlsToEnableOrNot);

            controlsToEnableOrNot.Clear();
            controlsToEnableOrNot.Add(printToFileNameLabel);
            controlsToEnableOrNot.Add(printToFileNameTextBox);
            controlsToEnableOrNot.Add(browseButton);
            m_printMgr.VerifyPrintToFileName(controlsToEnableOrNot);

            m_printMgr.VerifyPrintToSingleFile(singleFileRadioButton);

            if (m_printMgr.VerifyPrintToSingleFile(singleFileRadioButton))
            {
                singleFileRadioButton.Checked = m_printMgr.IsCombinedFile;
                separateFileRadioButton.Checked = !m_printMgr.IsCombinedFile;
            }

            if (!m_printMgr.VerifyPrintToSingleFile(singleFileRadioButton)
                && m_printMgr.VerifyPrintToSeparateFile(separateFileRadioButton))
            {
                separateFileRadioButton.Checked = true;
            }
            this.singleFileRadioButton.CheckedChanged += new System.EventHandler(this.combineRadioButton_CheckedChanged);

            switch (m_printMgr.PrintRange)
            {
                case PrintRange.Current:
                    currentWindowRadioButton.Checked = true;
                    break;
                case PrintRange.Select:
                    selectedViewsRadioButton.Checked = true;
                    break;
                case PrintRange.Visible:
                    visiblePortionRadioButton.Checked = true;
                    break;
                default:
                    break;
            }
            this.currentWindowRadioButton.CheckedChanged += new System.EventHandler(this.currentWindowRadioButton_CheckedChanged);
            this.visiblePortionRadioButton.CheckedChanged += new System.EventHandler(this.visiblePortionRadioButton_CheckedChanged);
            this.selectedViewsRadioButton.CheckedChanged += new System.EventHandler(this.selectedViewsRadioButton_CheckedChanged);

            this.printToFileNameTextBox.Text = Environment.GetFolderPath(
                Environment.SpecialFolder.MyDocuments) + "\\" + m_printMgr.DocumentTitle;
            controlsToEnableOrNot.Clear();
            controlsToEnableOrNot.Add(selectedViewSheetSetLabel);
            controlsToEnableOrNot.Add(selectedViewSheetSetButton);
            if (m_printMgr.VerifySelectViewSheetSet(controlsToEnableOrNot))
            {
                this.selectedViewSheetSetLabel.Text = m_printMgr.SelectedViewSheetSetName;
            }

            orderCheckBox.Checked = m_printMgr.PrintOrderReverse;
            this.orderCheckBox.CheckedChanged += new System.EventHandler(this.orderCheckBox_CheckedChanged);

            if (m_printMgr.VerifyCollate(collateCheckBox))
            {
                collateCheckBox.Checked = m_printMgr.Collate;
            }
            this.collateCheckBox.CheckedChanged += new System.EventHandler(this.collateCheckBox_CheckedChanged);

            printSetupNameLabel.Text = m_printMgr.PrintSetupName;
        }
예제 #28
0
 private void add_umk_Click(object sender, EventArgs e)
 {
     win_add_umk window_umk = new win_add_umk();
     System.Collections.ObjectModel.Collection<string> return_lst = new System.Collections.ObjectModel.Collection<string>();
     System.Collections.ObjectModel.Collection<string> return_lst1 = new System.Collections.ObjectModel.Collection<string>();
     System.Collections.ObjectModel.Collection<string> return_lst2 = new System.Collections.ObjectModel.Collection<string>();
     cls_main main_func = new cls_main();
      window_umk.change_vars(umk_folder);
     window_umk.ShowDialog();
     //if (window_umk.selected_path != "")
     //{
         if (window_umk.selected_level == 2)
         {
             //if (if_cell_ISexists(2, window_umk.selected_path + "\\" + window_umk.selected_obj) != true)
             //{
                 string[] row1 = { window_umk.selected_obj, main_func.get_value_from_infofile(umk_folder + "\\" + window_umk.selected_path + "\\" + window_umk.selected_obj + "\\info.dat", "code"), window_umk.selected_path + "\\" + window_umk.selected_obj };
                 dg_prj_files.Rows.Add(row1);
             //}
         }
         else
         {
             if (window_umk.selected_level == 0)
             {
                 return_lst.Clear();
                 return_lst1.Clear();
                 return_lst = main_func.get_dir(umk_folder +  window_umk.selected_path + "\\" + window_umk.selected_obj);
                 if (return_lst.Count > 0)
                 {
                     for (int i = 0; i < return_lst.Count; i++)
                     {
                         return_lst1 = main_func.get_dir(umk_folder +  window_umk.selected_path + "\\" + window_umk.selected_obj + "\\" + return_lst[i]);
                         if (return_lst1.Count > 0)
                         {
                             for (int j = 0; j < return_lst1.Count; j++)
                             {
                                 //if (if_cell_ISexists(2,  window_umk.selected_obj + "\\" + return_lst[i] + "\\" + return_lst1[j]) != true)
                                 //{
                                     string[] row1 = { return_lst1[j], main_func.get_value_from_infofile(umk_folder + window_umk.selected_path + "\\" + window_umk.selected_obj + "\\" + return_lst[i] + "\\" + return_lst1[j] + "\\info.dat", "code"),  window_umk.selected_obj + "\\" + return_lst[i] + "\\" + return_lst1[j] };
                                     dg_prj_files.Rows.Add(row1);
                                 //}
                             }
                         }
                     }
                 }
             }
             else
             {
                 return_lst.Clear();
                 return_lst = main_func.get_dir(umk_folder + "\\" + window_umk.selected_path + "\\" + window_umk.selected_obj);
                 if (return_lst.Count > 0)
                 {
                     for (int i = 0; i < return_lst.Count; i++)
                     {
                         //if (if_cell_ISexists(2,  window_umk.selected_path + "\\" + window_umk.selected_obj + "\\" + return_lst[i]) != true)
                         //{
                             string[] row1 = { return_lst[i], main_func.get_value_from_infofile(umk_folder + "\\" + window_umk.selected_path + "\\" + window_umk.selected_obj + "\\" + return_lst[i] + "\\info.dat", "code"), window_umk.selected_path + "\\" + window_umk.selected_obj + "\\" + return_lst[i] };
                             dg_prj_files.Rows.Add(row1);
                         //}
                     }
                 }
             }
         }
     //}
     update_level_files(selected_level);
 }
예제 #29
0
        //Downloads program to PLC using specified file name and serial port
        private static void DownloadProgram(DF1Comm.DF1Comm df1, IGpioConnectionDriver driver, GpioConnection gpioConnection, ProcessorPin redLED, OutputPinConfiguration greenLED, string filename, string serialPort)
        {
            startIdleTimer();
            //turn on red LED while update is in progress
            driver.Write(redLED, true);

            //set serial port on DF1 class to serial port specified, e.g. "/dev/ttyUSB0"
            df1.ComPort = serialPort;

            //detectBaudRate(df1);

            //Create new PLCFileDetails object
            System.Collections.ObjectModel.Collection <DF1Comm.DF1Comm.PLCFileDetails> PLCFiles = new System.Collections.ObjectModel.Collection <DF1Comm.DF1Comm.PLCFileDetails>();

            //Create new PLCFile with the defaults
            DF1Comm.DF1Comm.PLCFileDetails PLCFile = default(DF1Comm.DF1Comm.PLCFileDetails);


            //try reading the program file using the filename specified
            try
            {
                //create fileReader to read from file
                fileReader = new System.IO.StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename));

                //initialize string to hold contents of each line
                string line = null;

                //byte collection to hold raw data to send to PLC
                System.Collections.ObjectModel.Collection <byte> data = new System.Collections.ObjectModel.Collection <byte>();

                //loop until the end of the file is reached
                //data is read in chunks of 3 lines
                //the first line is the FileType
                //the second line is the FileNumber
                //and the third line is the data
                //these are converted into a PLCFile and added to the PLCFiles collection
                while (!(fileReader.EndOfStream))
                {
                    //get the contents of the first line
                    line = fileReader.ReadLine();

                    //convert hex ascii to byte for FileType
                    PLCFile.FileType = Convert.ToByte(line, 16);

                    //get the contents of the second line
                    line = fileReader.ReadLine();

                    //convert hex ascii to byte for FileNumber
                    PLCFile.FileNumber = Convert.ToByte(line, 16);

                    //get the contents of the third line
                    line = fileReader.ReadLine();

                    //clear the data collection
                    data.Clear();

                    //loop through the entire line two characters at a time
                    for (int i = 0; i <= line.Length / 2 - 1; i++)
                    {
                        //convert each two character ascii hex byte into a byte and add to data collection
                        data.Add(Convert.ToByte(line.Substring(i * 2, 2), 16));
                    }

                    //create byte array the same length as data collection
                    byte[] dataC = new byte[data.Count];

                    //copy data collection to byte array
                    data.CopyTo(dataC, 0);

                    //assign byte array to PLCFile data property
                    PLCFile.data = dataC;

                    //add the PLCFile to the PLCFiles collection
                    PLCFiles.Add(PLCFile);
                }

                //try to download the PLCfiles to the PLC
                try
                {
                    df1.DownloadProgramData(PLCFiles);
                    //set the PLC back to Run mode when download is complete
                    df1.SetRunMode();
                }

                //write the error to the console if an error occurs downloading the program
                catch (Exception ex)
                {
                    Console.WriteLine("Error Downloading Program. " + ex.Message + " " + ex.StackTrace);
                    rapidBlink(driver, redLED);
                    startIdleTimer();
                    return;
                }

                //turn off red LED when update is complete
                driver.Write(redLED, false);

                //write a success message to the console if completed without errors
                Console.WriteLine("Successful Download");

                //turn on green LED for 5 seconds when update is complete
                gpioConnection.Blink(greenLED, TimeSpan.FromSeconds(5));

                //reset the idle shutdown timer
                startIdleTimer();
                fileReader.Close();
                return;
            }

            //catch errors reading the program file
            catch (Exception ex)
            {
                //write the error to the console if an error occurs reading the program file
                Console.WriteLine("Error Reading Program File for Download. " + ex.Message + " " + ex.StackTrace);

                //blink red LED to indicate problem with upload
                rapidBlink(driver, redLED);

                //reset the idle shutdown timer
                startIdleTimer();
                if (fileReader != null)
                {
                    fileReader.Close();
                }
                return;
            }
        }