Example #1
0
        private void DrawEntry(ChartMode mode, int val, StringBuilder sb)
        {
            // Format is: Dec Hex Chr
            int modVal = (mode == ChartMode.High) ? val | 0x80 : val;

            sb.AppendFormat("{0,3:D} {1,3:X2} ", modVal, modVal);
            if (val < 0x20)
            {
                sb.Append('^');
                sb.Append((char)(val + 0x40));
                sb.Append(' ');
            }
            else if (val == 0x20)
            {
                sb.Append("' '");
            }
            else if (val < 0x7f)
            {
                sb.Append(' ');
                sb.Append((char)val);
                sb.Append(' ');
            }
            else
            {
                sb.Append("DEL");
            }
        }
Example #2
0
 public Bitmap GetChart(ChartMode mode, Func <T, double> valueAxisY, Func <T, object> valueAxisX)
 {
     return(mode switch
     {
         ChartMode.LineMode => GetLineChart(valueAxisY, valueAxisX),
         ChartMode.RectangleMode => GetRectangleChart(valueAxisY, valueAxisX),
         _ => null
     });
Example #3
0
        internal Dictionary<string, string> GetSeries(Fields fields, string xlsFileNameWPath, ChartMode chartMode, int columnCount)
        {
            Dictionary<string, string> RetVal = new Dictionary<string, string>();
            try
            {
                Dictionary<string, IRange> PyramidSeries = new Dictionary<string, IRange>();

                if (chartMode == ChartMode.Insert || chartMode == ChartMode.Edit)
                {
                    this.TableSheetIndex = 1;
                }

                this.ExcelFile = new DIExcel(xlsFileNameWPath, System.Threading.Thread.CurrentThread.CurrentCulture);

                //-- Insert column and its value.
                this.InserDataValueColumn(fields, columnCount);

                //-- Generate the series for pyramid chart
                PyramidSeries = this.GetPyramidSeries(fields, chartMode);

                //-- Save the file
                this.ExcelFile.Save();

                //-- Insert / Edit the chart
                switch (chartMode)
                {
                    case ChartMode.Insert:
                        this.InsertChart(PyramidSeries, xlsFileNameWPath);
                        break;

                    case ChartMode.Edit:
                        this.CreatePyramidChartAndSetDataRange(xlsFileNameWPath, PyramidSeries);
                        break;

                    case ChartMode.ExcelInsert:
                    case ChartMode.ExcelEdit:
                        RetVal = this.ConvertRangeIntoString(PyramidSeries);
                        break;
                    default:
                        break;
                }

                this.ExcelFile.Close();
            }
            catch (Exception)
            {
            }
            return RetVal;
        }
Example #4
0
        /// <summary>
        /// Set the mode of the chart recorder to the specified mode.
        /// </summary>
        /// <param name="chartMode">The requested chart recorder mode.</param>
        private void SetChartMode(ChartMode chartMode)
        {
            ICommunicationWatch communicationInterface;

            if (MainWindow.CommunicationInterface.CommunicationSetting.Protocol == Protocol.SIMULATOR)
            {
                communicationInterface = new CommunicationWatchOffline(MainWindow.CommunicationInterface);
            }
            else
            {
                communicationInterface = new CommunicationWatch(MainWindow.CommunicationInterface);
            }

            PauseCommunication <ICommunicationWatch>(communicationInterface, true);
            communicationInterface.SetChartMode(chartMode);
            PauseCommunication <ICommunicationWatch>(communicationInterface, false);
            return;
        }
Example #5
0
        public void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Restore chart mode setting.
            ChartMode mode = (ChartMode)AppSettings.Global.GetEnum(
                AppSettings.A2SC_MODE, typeof(ChartMode), (int)ChartMode.HiRes1_L);
            int index = 0;

            for (int i = 0; i < ChartModeItems.Length; i++)
            {
                if (ChartModeItems[i].Mode == mode)
                {
                    index = i;
                    break;
                }
            }
            chartModeComboBox.SelectedIndex = index;
            // should call UpdateControls via SelectionChanged
        }
Example #6
0
        /// <summary>
        /// 获取逻辑管理器实例
        /// </summary>
        /// <param name="chartMode">当前编辑模式</param>
        /// <returns>逻辑管理器实例</returns>
        public LogicBaseManager GetLogicManager(ChartMode chartMode)
        {
            LogicBaseManager logicManager = null;

            switch (chartMode)
            {
            case ChartMode.FlowChart:     // 编辑流程图模式
            {
                logicManager = FlowChartLogicManager;
                break;
            }

            case ChartMode.AIChart:     // 编辑AI图模式
            {
                logicManager = AIChartLogicManager;
                break;
            }
            }

            return(logicManager);
        }
Example #7
0
 public ChartModeItem(string name, ChartMode mode)
 {
     Name = name;
     Mode = mode;
 }
Example #8
0
        /// <summary>
        /// 获取逻辑管理器实例
        /// </summary>
        /// <param name="chartMode">当前编辑模式</param>
        /// <returns>逻辑管理器实例</returns>
        public LogicBaseManager GetLogicManager(ChartMode chartMode)
        {
            LogicBaseManager logicManager = null;

            switch(chartMode)
            {
                case ChartMode.FlowChart: // 编辑流程图模式
                    {
                        logicManager = FlowChartLogicManager;
                        break;
                    }

                case ChartMode.AIChart: // 编辑AI图模式
                    {
                        logicManager = AIChartLogicManager;
                        break;
                    }
            }

            return logicManager;
        }
        /// <summary>
        /// Set the mode of the chart recorder.
        /// </summary>
        /// <param name="chartMode">The required mode of the chart recorder.</param>
        /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.SetChartMode() method is
        /// not CommunicationError.Success.</exception>
        public void SetChartMode(ChartMode chartMode)
        {
            // Check that the function delegate has been initialized.
            Debug.Assert(m_MutexCommuncationInterface != null, "CommunicationParent.SetChartMode() - [m_MutexCommuncationInterface != null]");

            short chartModeAsShort = (short)chartMode;
            CommunicationError errorCode = CommunicationError.UnknownError;
            try
            {
                m_MutexCommuncationInterface.WaitOne(DefaultMutexWaitDurationMs, false);
                errorCode = m_WatchClockMarshal.SetChartMode(chartModeAsShort);
            }
            catch (Exception)
            {
                errorCode = CommunicationError.SystemException;
                throw new CommunicationException(Resources.EMChartModeSetFailed, errorCode);
            }
            finally
            {
                m_MutexCommuncationInterface.ReleaseMutex();
            }

            if (DebugMode.Enabled == true)
            {
                DebugMode.SetChartMode_t setChartMode = new DebugMode.SetChartMode_t((ChartMode)chartModeAsShort, errorCode);
                DebugMode.Write(setChartMode.ToXML());
            }

            if (errorCode != CommunicationError.Success)
            {
                throw new CommunicationException(Resources.EMChartModeSetFailed, errorCode);
            }
        }
 /// <summary>
 /// Set the mode of the chart recorder.
 /// </summary>
 /// <param name="chartMode">The required mode of the chart recorder.</param>
 /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.SetChartMode() method is not
 /// CommunicationError.Success.</exception>
 public void SetChartMode(ChartMode chartMode)
 {
     m_ChartMode = chartMode;
 }
        public Dictionary<string, string> GetPyramidSeries(string presentationFileNameWPath, ChartMode chartMode)
        {
            Dictionary<string, string> RetVal = new Dictionary<string, string>();
            try
            {
                //-- Set the show excel to true so thatcolumn will not merged into the column for pyramid chart.
                bool ShowExcel = this._TablePresentation.ShowExcel;
                this._TablePresentation.ShowExcel = true;

                //-- Generate the table, data, source and keyword worksheet
                this._TablePresentation.GeneratePresentation(Path.GetDirectoryName(presentationFileNameWPath), Path.GetFileName(presentationFileNameWPath));
                RetVal = this.PyramidChart.GetSeries(this.TablePresentation.Fields, presentationFileNameWPath, chartMode, this._TablePresentation.ColumnArrangementTable.Rows.Count);

                //-- Reset the showExcel status
                this._TablePresentation.ShowExcel = ShowExcel;
                this._GraphPresentationFileNameWPath = presentationFileNameWPath;

                if (!this._TablePresentation.ShowExcel)
                {
                    this.ApplyTemplate(presentationFileNameWPath);
                }
            }
            catch (Exception)
            {
            }
            return RetVal;
        }
Example #12
0
        /// <summary>
        /// Generate the pyramid series
        /// </summary>
        /// <returns></returns>
        private Dictionary<string, IRange> GetPyramidSeries(Fields fields, ChartMode chartMode)
        {
            Dictionary<string, IRange> RetVal = new Dictionary<string, IRange>();
            try
            {
                int Index=0;
                int StartRowIndex = 1;
                int FormulaRange = -1;
                IRange Range = null;
                string ColumnHeader = string.Empty;
                string TempAreaName = string.Empty;
                string AreaName = string.Empty;
                int RowCount = this.ExcelFile.GetUsedRange(TableSheetIndex).Rows.Count;
                int ColumnCount = this.ExcelFile.GetUsedRange(TableSheetIndex).Columns.Count;
                int NewColumnIndex = this.InsertColumnIndex;

                if (fields.Rows.Count > 1)
                {
                    if (this.ExcelFile.GetUsedRange(TableSheetIndex).Columns.Count > 2)
                    {
                        FormulaRange = fields.Rows.Count;
                    }
                    else
                    {
                        FormulaRange = this.InsertColumnIndex - 2;
                    }

                    AreaName = this.ExcelFile.GetCellValue(TableSheetIndex, 1, AreaColumnIndex, 1, AreaColumnIndex);

                    for (int ColumnIndex = FormulaRange; ColumnIndex < this.InsertColumnIndex; ColumnIndex += 2)
                    {
                        for (int RowIndex = 2; RowIndex < RowCount; RowIndex++)
                        {
                            TempAreaName = this.ExcelFile.GetCellValue(TableSheetIndex, RowIndex, AreaColumnIndex, RowIndex, AreaColumnIndex);
                            if (AreaName.ToLower() != TempAreaName.ToLower())
                            {
                                ColumnHeader = this.ExcelFile.GetCellValue(TableSheetIndex, 0, ColumnIndex, 0, ColumnIndex).Replace("\n", "-");
                                if (Index == 0)
                                {
                                    //this._DataSourceDimensions = StartRowIndex.ToString() + "," + DimensionIndex.ToString() + "," + (RowIndex - 1) + "," + (this.InsertColumnIndex - 2);
                                    Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, StartRowIndex, DimensionIndex, RowIndex - 1, FormulaRange);
                                    RetVal.Add(AreaName + " - " + ColumnHeader, Range);
                                }
                                else
                                {
                                    Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, RowIndex, ColumnIndex, RowIndex, ColumnIndex);
                                    RetVal.Add(AreaName + " - " + ColumnHeader, Range);
                                }

                                ColumnHeader = this.ExcelFile.GetCellValue(TableSheetIndex, 0, NewColumnIndex, 0, NewColumnIndex).Replace("\n", "-");
                                Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, RowIndex, NewColumnIndex, RowIndex, NewColumnIndex);
                                RetVal.Add(AreaName + " - " + ColumnHeader, Range);

                                AreaName = TempAreaName;
                                StartRowIndex = RowIndex;
                            }
                        }
                        Index += 1;
                        StartRowIndex = 2;
                        NewColumnIndex += 1;
                    }
                }
                else
                {
                    for (int ColumnIndex = 1; ColumnIndex < this.InsertColumnIndex; ColumnIndex += 2)
                    {
                        if (Index == 0)
                        {
                            if (chartMode == ChartMode.Insert)
                            {
                                Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, StartRowIndex, 1, RowCount - 1, 1);
                                ColumnHeader = this.ExcelFile.GetCellValue(TableSheetIndex, 0, 1, 0, 1).Replace("\n", "-");
                                RetVal.Add(ColumnHeader, Range);

                                Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, StartRowIndex, 0, RowCount - 1, 0);
                                ColumnHeader = "1";
                                RetVal.Add(ColumnHeader, Range);
                            }
                            else if (chartMode == ChartMode.ExcelInsert)
                            {
                                Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, StartRowIndex, 0, RowCount - 1, 1);
                                ColumnHeader = this.ExcelFile.GetCellValue(TableSheetIndex, 0, 1, 0, 1).Replace("\n", "-");
                                RetVal.Add(ColumnHeader, Range);
                            }
                            else if (chartMode == ChartMode.Edit || chartMode == ChartMode.ExcelEdit)
                            {
                                Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, StartRowIndex, 0, RowCount - 1, fields.Columns.Count - 1);
                                ColumnHeader = "";
                                RetVal.Add(ColumnHeader, Range);

                                Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, StartRowIndex, 1, RowCount - 1, 1);
                                ColumnHeader = this.ExcelFile.GetCellValue(TableSheetIndex, 0, 1, 0, 1).Replace("\n", "-");
                                RetVal.Add(ColumnHeader, Range);
                            }
                        }
                        else
                        {
                            Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, StartRowIndex, ColumnIndex, RowCount - 1, ColumnIndex);
                            ColumnHeader = this.ExcelFile.GetCellValue(TableSheetIndex, 0, ColumnIndex, 0, ColumnIndex).Replace("\n", "-");
                            if (!string.IsNullOrEmpty(ColumnHeader.Trim()))
                            {
                                RetVal.Add(ColumnHeader, Range);
                            }
                        }

                        Range = this.ExcelFile.GetSelectedRange(TableSheetIndex, StartRowIndex, NewColumnIndex, RowCount - 1, NewColumnIndex);
                        ColumnHeader = this.ExcelFile.GetCellValue(TableSheetIndex, 0, NewColumnIndex, 0, NewColumnIndex).Replace("\n", "-");
                        if (!string.IsNullOrEmpty(ColumnHeader.Trim()))
                        {
                            RetVal.Add(ColumnHeader, Range);
                        }

                        Index += 1;
                        NewColumnIndex += 1;
                    }
                }
            }
            catch (Exception)
            {
            }
            return RetVal;
        }
        /// <summary>
        /// Set the mode of the chart recorder to the specified mode.
        /// </summary>
        /// <param name="chartMode">The requested chart recorder mode.</param>
        private void SetChartMode(ChartMode chartMode)
        {
            ICommunicationWatch communicationInterface;
            if (MainWindow.CommunicationInterface.CommunicationSetting.Protocol == Protocol.SIMULATOR)
            {
                communicationInterface = new CommunicationWatchOffline(MainWindow.CommunicationInterface);
            }
            else
            {
                communicationInterface = new CommunicationWatch(MainWindow.CommunicationInterface);
            }

            PauseCommunication<ICommunicationWatch>(communicationInterface, true);
            communicationInterface.SetChartMode(chartMode);
            PauseCommunication<ICommunicationWatch>(communicationInterface, false);
            return;
        }
Example #14
0
 /// <summary>
 /// Set the mode of the chart recorder.
 /// </summary>
 /// <param name="chartMode">The required mode of the chart recorder.</param>
 /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.SetChartMode() method is not
 /// CommunicationError.Success.</exception>
 public void SetChartMode(ChartMode chartMode)
 {
     m_ChartMode = chartMode;
 }