コード例 #1
0
 /// <summary>
 ///		Lanza el evento de abrir archivo
 /// </summary>
 public void RaiseEventOpenFile(string fileName)
 {
     if (!string.IsNullOrEmpty(fileName) && !System.IO.Directory.Exists(fileName))
     {
         OpenFile?.Invoke(this, new EventArguments.FileEventArgs(fileName));
     }
 }
コード例 #2
0
 private void btnOpenFile_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         OpenFileName = openFileDialog.FileName;
         OpenFile?.Invoke(this, e);
     }
 }
コード例 #3
0
        private void openMenu_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "Текстовые файлы (*.txt)|*.txt|Все файлы (*.*)|*.*";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                FilePath = dialog.FileName;
                OpenFile?.Invoke(this, EventArgs.Empty);
                approximation = new Approximation(ConvertToPoints(), a, b);
            }
        }
コード例 #4
0
        private void listViewFolder1_ItemActivate(object sender, EventArgs e)
        {
            int leng = listViewFolder1.SelectedItems.Count;


            for (int i = 0; i < leng; i++)
            {
                Select_Elements.Add(Full_Path_Note + "\\" + listViewFolder1.SelectedItems[i].Text);
            }
            OpenFile?.Invoke(this, EventArgs.Empty);
            Select_Elements.Clear();
        }
コード例 #5
0
        private TreeViewItem GetNode(IncludeGraphNode node)
        {
            TreeViewItem item = new TreeViewItem()
            {
                Header = node.Name
            };

            var treeViewItemMenu = new ContextMenu();
            var expandItem       = new MenuItem()
            {
                Header = "Expand subtree",
                Tag    = item
            };

            expandItem.Click += ExpandItem_Click;
            treeViewItemMenu.Items.Add(expandItem);

            var unexpandItem = new MenuItem()
            {
                Header = "Unexpand subtree",
                Tag    = item
            };

            unexpandItem.Click += UnexpandItem_Click;
            treeViewItemMenu.Items.Add(unexpandItem);

            var openFile = new MenuItem()
            {
                Header = "Open file",
                Tag    = item
            };

            openFile.Click += (sender, e) => {
                TreeViewItem tmp = (sender as MenuItem)?.Tag as TreeViewItem;

                if (tmp != null)
                {
                    string filename = tmp.Header as string;
                    OpenFile?.Invoke(sender, filename, e);
                }
            };
            treeViewItemMenu.Items.Add(openFile);

            item.ContextMenu = treeViewItemMenu;

            foreach (var childNode in node.Includes)
            {
                item.Items.Add(GetNode(childNode));
            }

            return(item);
        }
コード例 #6
0
 /// <summary>
 /// Called when double clicking an item
 /// </summary>
 void Open(string name, string extension, string filePath)
 {
     //It's a directory -> open filepath
     if (extension == string.Empty)
     {
         _inputfield.text = filePath;
         PressedGo();
     }
     //It's a file
     else
     {
         //send event further out and let them deal with it
         OpenFile?.Invoke(name, extension, filePath);
     }
 }
コード例 #7
0
 private void fireOpen()
 {
     if (allowOpen && fileDataGrid.hasItemSelected())
     {
         allowOpen             = false;
         loadingWidget.Visible = true;
         OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget.update();
         currentFile = (PatientDataFile)fileDataGrid.getItemDataAt(fileDataGrid.getIndexSelected());
         if (OpenFile != null)
         {
             OpenFile.Invoke(this, EventArgs.Empty);
         }
         this.hide();
     }
 }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 protected virtual bool OnLoad(DataFileEventArgs e)
 {
     try
     {
         OpenFile?.Invoke(this, e);
         FileName   = e.FileName;
         IsModified = false;
         FileChanged?.Invoke(this, e);
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Error loading '{FileName}' : {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return(false);
     }
 }
コード例 #9
0
 public EditorViewModel()
 {
     IncreaseText = new DelegateCommand(_ =>
     {
         ++FontSize;
         OnPropertyChanged();
     });
     DecreaseText = new DelegateCommand(_ =>
     {
         if (FontSize > 1)
         {
             --FontSize;
             OnPropertyChanged();
         }
     });
     New = new DelegateCommand(_ => {
         if (IsDirty)
         {
             string messageBoxText = "You have unsaved changes. Do you want to save?";
             string caption        = "Unsaved changes";
             System.Windows.MessageBoxButton button = System.Windows.MessageBoxButton.YesNoCancel;
             System.Windows.MessageBoxImage icon    = System.Windows.MessageBoxImage.Warning;
             System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show(messageBoxText, caption, button, icon);
             if (result == System.Windows.MessageBoxResult.Yes)
             {
                 SaveFile?.Invoke(this, new FileOperationEventArgs(null, CurrentText, IsDirty));
                 IsDirty     = false;
                 CurrentText = "";
                 LineNumbers = "";
             }
             else if (result == System.Windows.MessageBoxResult.No)
             {
                 NewFile?.Invoke(this, null);
             }
         }
     });
     Save = new DelegateCommand(_ => {
         if (IsDirty)
         {
             SaveFile?.Invoke(this, new FileOperationEventArgs(null, CurrentText, IsDirty));
             IsDirty = false;
         }
     });
     Open = new DelegateCommand(_ => {
         OpenFile?.Invoke(this, new FileOperationEventArgs(null, null, IsDirty));
     });
 }
コード例 #10
0
ファイル: StartScreen.cs プロジェクト: Dabzi/HarmonyExporter
        protected void OpenClicked(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Open existing export settings file.", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
            fc.SetCurrentFolder(System.IO.Directory.GetCurrentDirectory());
            FileFilter ff = new FileFilter();

            ff.AddPattern("*.tbp");
            fc.Filter = ff;

            if (fc.Run() == (int)ResponseType.Accept)
            {
                openFileHandler.Invoke(new Uri(fc.Filename));
                fc.Destroy();
                Destroy();
            }
            else
            {
                fc.Destroy();
            }
        }
コード例 #11
0
        /// <summary>
        /// Raises the <see cref="OpenFile"/> event to implement opening a file.
        /// </summary>
        /// <param name="path">Full path name of file to load.</param>
        /// <returns>True if successful, false otherwise.</returns>
        protected virtual bool OnLoad(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            try
            {
                DataFileEventArgs e = new(path);
                OpenFile?.Invoke(this, e);
                FileName   = e.FileName;
                IsModified = false;
                FileChanged?.Invoke(this, e);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error loading '{FileName}' : {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
        }
コード例 #12
0
ファイル: FileControls.cs プロジェクト: zwirek2201/CRMTool
 private void _openItem_Click(object sender, RoutedEventArgs e)
 {
     OpenFile?.Invoke(this, EventArgs.Empty);
 }
コード例 #13
0
 protected virtual void OnOpenFile(OpenFileEventArgs oea)
 {
     OpenFile?.Invoke(this, oea);
 }
コード例 #14
0
 public static void OnOpenFile(string path)
 {
     OpenFile?.Invoke(path);
 }
コード例 #15
0
ファイル: MenuPanel.xaml.cs プロジェクト: itdimk/AMAGE
 private void OpenFile_Click(object sender, RoutedEventArgs e)
 => OpenFile?.Invoke(this, e);
コード例 #16
0
 /// <summary>
 /// Called when user presses button for select -> used to open selected file or !directory!
 /// </summary>
 public void Select()
 {
     OpenFile?.Invoke(_selectedName, _selectedExtension, _selectedFilePath);
 }
コード例 #17
0
        public bool OnFileNew(ref string fileName)
        {
            // INTEX data are in cms
            UnitsManager.CurrentUnitSystem = UnitsManager.UnitSystem.UNIT_METRIC2;

            string dbPath = Properties.Settings.Default.DatabasePathINTEX;

            if (string.IsNullOrWhiteSpace(dbPath) || !File.Exists(dbPath))
            {
                var fd = new OpenFileDialog
                {
                    DefaultExt       = "xls",
                    AddExtension     = false,
                    Filter           = "Microsoft Excel File (*.xls)|*.xls|All files (*.*)|*.*",
                    FilterIndex      = 0,
                    RestoreDirectory = true,
                    CheckFileExists  = true
                };
                if (DialogResult.OK != fd.ShowDialog())
                {
                    return(false);
                }

                dbPath = fd.FileName;
                Properties.Settings.Default.DatabasePathINTEX = dbPath;
                Properties.Settings.Default.Save();
            }
            // load INTEX excel file
            List <DataItemINTEX>   listItems   = null;
            List <DataPalletINTEX> listPallets = null;
            List <DataCaseINTEX>   listCases   = null;

            try
            {
                // Set cursor as hourglass
                Cursor.Current = Cursors.WaitCursor;
                // load excel file
                if (!ExcelDataReader.ExcelDataReader.LoadIntexFile(dbPath, ref listItems, ref listPallets, ref listCases))
                {
                    Cursor.Current = Cursors.Default;
                    string message = string.Empty;
                    if (null == listItems || listItems.Count < 1)
                    {
                        message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "article", "Articles");
                    }
                    else if (null == listPallets || listPallets.Count < 1)
                    {
                        message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "palette", "Palettes");
                    }
                    else
                    {
                        message = string.Format(Properties.Resources.ID_ERROR_INVALIDFILE, dbPath);
                    }
                    if (!string.IsNullOrEmpty(message))
                    {
                        MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    ex.Message
                    , Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                _log.Error(ex.Message);
            }
            finally
            { Cursor.Current = Cursors.Default; }
            // do we have a valid list
            if (null == listItems || 0 == listItems.Count)
            {
                return(false);
            }
            // proceed : buid project file
            try
            {
                FormNewINTEX form = new FormNewINTEX()
                {
                    ListItems   = listItems,
                    ListPallets = listPallets,
                    ListCases   = listCases
                };
                if (DialogResult.OK != form.ShowDialog())
                {
                    return(false);
                }
                // create document
                DataItemINTEX item     = form._currentItem;
                Document      document = new Document(item._ref, item._description, "INTEX", DateTime.Now, null);
                // create box properties
                Color[] colorsCase = new Color[6];
                for (int i = 0; i < 6; ++i)
                {
                    colorsCase[i] = Color.Chocolate;
                }
                BoxProperties itemProperties = null;
                if (!form.UseIntermediatePacking)
                {
                    itemProperties = document.CreateNewCase(
                        item._ref
                        , $"{item._description};EAN14 : {item._gencode};UPC : {item._UPC};PCB : {item._PCB}"
                        , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , colorsCase);
                }
                else
                {
                    itemProperties = document.CreateNewBox(
                        item._ref
                        , string.Format("{0};EAN14 : {1};UPC : {2};PCB : {3}", item._description, item._gencode, item._UPC, item._PCB)
                        , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , colorsCase);
                }
                itemProperties.TapeColor = Color.Beige;
                itemProperties.TapeWidth = new OptDouble(true, 5.0);
                InsertPictogram(ref itemProperties);

                BoxProperties currentCase = null;
                if (form.UseIntermediatePacking)
                {
                    // create cases
                    foreach (DataCaseINTEX dataCase in listCases)
                    {
                        double lengthInt = dataCase._lengthInt > 0 ? dataCase._lengthInt : dataCase._lengthExt - 2 * form.DefaultCaseThickness;
                        double widthInt  = dataCase._widthInt > 0 ? dataCase._widthInt : dataCase._widthExt - 2 * form.DefaultCaseThickness;
                        double heightInt = dataCase._heightInt > 0 ? dataCase._heightInt : dataCase._heightExt - 2 * form.DefaultCaseThickness;

                        BoxProperties intercaseProperties = document.CreateNewCase(
                            dataCase._ref
                            , string.Format("{0:0.0}*{1:0.0}*{2:0.0}", dataCase._lengthExt, dataCase._widthExt, dataCase._heightExt)
                            , UnitsManager.ConvertLengthFrom(dataCase._lengthExt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(dataCase._widthExt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(dataCase._heightExt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(lengthInt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(widthInt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(heightInt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , false
                            , UnitsManager.ConvertMassFrom(dataCase._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , colorsCase);
                        intercaseProperties.TapeColor = Color.Beige;
                        intercaseProperties.TapeWidth = new OptDouble(true, 5.0);

                        if (string.Equals(form._currentCase._ref, intercaseProperties.Name))
                        {
                            currentCase = intercaseProperties;
                        }
                    }
                }

                // initialize Layer solver
                SolutionLayered.SetSolver(new LayerSolver());

                if (form.UseIntermediatePacking)
                {
                    // Case constraint set
                    ConstraintSetBoxCase constraintSetBoxCase = new ConstraintSetBoxCase(currentCase);
                    constraintSetBoxCase.AllowedOrientationsString = "1,1,1";
                    if (constraintSetBoxCase.Valid)
                    {
                        SolverBoxCase   solver          = new SolverBoxCase(itemProperties, currentCase, constraintSetBoxCase);
                        Layer2DBrickImp layer           = solver.BuildBestLayer();
                        var             listLayerEncaps = new List <LayerEncap>();
                        if (null != layer)
                        {
                            listLayerEncaps.Add(new LayerEncap(layer.LayerDescriptor));
                        }
                        // create case analysis
                        AnalysisLayered analysis = document.CreateNewAnalysisBoxCase(
                            string.Format(Properties.Resources.ID_PACKING, item._ref)
                            , item._description
                            , itemProperties
                            , currentCase
                            , null
                            , constraintSetBoxCase
                            , listLayerEncaps) as AnalysisLayered;
                    }
                }

                // create pallets
                PalletProperties currentPallet = null;
                foreach (DataPalletINTEX pallet in listPallets)
                {
                    PalletProperties palletProperties = document.CreateNewPallet(
                        pallet._type, pallet._type, "EUR"
                        , UnitsManager.ConvertLengthFrom(pallet._length, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(pallet._width, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(pallet._height, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertMassFrom(pallet._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , Color.Gold);
                    if (string.Equals(form._currentPallet._type, pallet._type))
                    {
                        currentPallet = palletProperties;
                    }
                }

                // *** pallet analysis ***
                // constraint set
                ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();
                constraintSet.SetMaxHeight(new OptDouble(true, UnitsManager.ConvertLengthFrom(form.PalletHeight, UnitsManager.UnitSystem.UNIT_METRIC2)));
                constraintSet.SetAllowedOrientations(new bool[] { false, false, true });
                if (constraintSet.Valid)
                {
                    SolverCasePallet solver = new SolverCasePallet(form.UseIntermediatePacking ? currentCase : itemProperties, currentPallet, constraintSet);
                    Layer2DBrickImp  layer  = solver.BuildBestLayer();
                    var listLayerEncaps     = new List <LayerEncap>();
                    if (null != layer)
                    {
                        listLayerEncaps.Add(new LayerEncap(layer.LayerDescriptor));
                    }

                    // create analysis
                    AnalysisLayered palletAnalysis = document.CreateNewAnalysisCasePallet(
                        item._ref, item.ToString()
                        , form.UseIntermediatePacking ? currentCase : itemProperties
                        , currentPallet,
                        null, null,
                        null, null,
                        constraintSet,
                        listLayerEncaps) as AnalysisLayered;
                }
                // save document
                fileName = form.FilePath;
                document.Write(form.FilePath);

                OpenFile?.Invoke(fileName);
                // return true to let application open
                return(File.Exists(fileName));
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
                return(false);
            }
        }
コード例 #18
0
ファイル: FileControls.cs プロジェクト: zwirek2201/CRMTool
 private void Item_OpenFile(object sender, EventArgs e)
 {
     OpenFile?.Invoke(sender, e);
 }
コード例 #19
0
        private void TreeViewItem_File_DoubleClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            FileInfo item = (sender as RadTreeViewItem).Tag as FileInfo;

            OpenFile?.Invoke(item);
        }