示例#1
0
 private void SearchBtn_Click(object sender, EventArgs e)
 {
     try
     {
         List <int> weights = ListConvert.GetList(ListInput.Text);
         if (weights.Count > 10)
         {
             throw new Exception();
         }
         int                sumWeight = int.Parse(IntInput.Text);
         ToolsList          toolsList = new ToolsList();
         List <List <int> > result    = toolsList.SelectionCount(weights, sumWeight);
         if (result.Count > 0)
         {
             Output.Text = ListConvert.GetString(result);
         }
         else
         {
             Output.Text = "комбинаций не найдено";
         }
     }
     catch (Exception)
     {
         MessageBox.Show("ошибка ввода", "ошибка");
     }
 }
示例#2
0
 /// <summary>
 /// Initialise tools list with the last used list.
 /// </summary>
 void InitialseToolsList()
 {
     //var tools = ToolsFc18.GetData(Properties.Settings.Default.Tools);
     //settings.ToolsPath = @"data\Library\tools1.fctl";
     tools = ToolsList.GetData(settings.ToolsPath);
     Tools = new ReadOnlyDictionary <string, Bit>(tools.Bits);
 }
示例#3
0
        /// <summary>
        /// фабрика инструментов
        /// </summary>
        /// <param name="_tools">список инструментов</param>
        /// <param name="_absPathToTools">абсолютный путь до инструментов</param>
        public ToolsFactory(ToolsList _tools, string _absPathToTools)
        {
            if (_tools == null || string.IsNullOrEmpty(_absPathToTools))
                throw new ArgumentNullException("Переда нулевой список инструментов в конструктор ToolsFactory");

            tools = _tools;
            absPathToTools = _absPathToTools;
        }
示例#4
0
        /// <summary>
        /// фабрика инструментов
        /// </summary>
        /// <param name="_tools">список инструментов</param>
        /// <param name="_absPathToTools">абсолютный путь до инструментов</param>
        public ToolsFactory(ToolsList _tools, string _absPathToTools)
        {
            if (_tools == null || string.IsNullOrEmpty(_absPathToTools))
            {
                throw new ArgumentNullException("Переда нулевой список инструментов в конструктор ToolsFactory");
            }

            tools          = _tools;
            absPathToTools = _absPathToTools;
        }
示例#5
0
 private void CalcBtn_Click(object sender, EventArgs e)
 {
     try
     {
         List <int> list      = ConvertList.StrToList(ListInput.Text);
         ToolsList  toolsList = new ToolsList(list);
         List <int> listNew   = (List <int>)toolsList.Process((int)InputN.Value);
         Output.Text = ConvertList.ListToStr(listNew, ", ");
     }
     catch (Exception)
     {
         MessageBox.Show("ошибка ввода", "ошибка");
     }
 }
示例#6
0
 private void CalcBtn_Click(object sender, EventArgs e)
 {
     try
     {
         List <int> list      = ConvertList.StrToList(ListInput.Text);
         ToolsList  toolsList = new ToolsList(list);
         List <int> listNew   = toolsList.Process(out bool success);
         Output.Text = ConvertList.ListToStr(listNew) + "\n" + (success ? "успешно" : "не успешно");
     }
     catch (Exception)
     {
         MessageBox.Show("ошибка ввода", "ошибка");
     }
 }
示例#7
0
 /// <summary>
 /// Load new tools list
 /// </summary>
 /// <param name="path">Path to the new tools list</param>
 public void LoadTools(string path)
 {
     try
     {
         var t = ToolsList.GetData(path);
         if (t != null)
         {
             tools = t;
             Tools = new ReadOnlyDictionary <string, Bit>(tools.Bits);
             settings.ToolsPath = path;
             OnToolsChanged?.Invoke(this, EventArgs.Empty);
         }
     }
     catch { }
 }
示例#8
0
        public VModel()
        {
            vm          = this;
            vm.DrawRect = new Rect()
            {
                Width = 800, Height = 800
            };
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            act();

            if (Data["ColorList"] is string[] cs)
            {
                foreach (var item in cs)
                {
                    ColorList.Add(new SolidColorBrush(Color.FromData(item)));
                }
            }
            if (ColorList.Count < 1)
            {
                foreach (var i in App1.Vendor.ColorList.List())
                {
                    ColorList.Add(new SolidColorBrush {
                        Color = Color.FromData(i)
                    });
                }
            }
            if ((Data["MainColor"] is string a) && (Data["BackColor"] is string b))
            {
                MainBrush.Color = Color.FromData(a);
                BackBrush.Color = Color.FromData(b);
            }

            if (Data["ToolsList"] is string[] ts)
            {
                foreach (var s in ts)
                {
                    var t = ToolsModel.Create(s);
                    if (t != null)
                    {
                        ToolsList.Add(t);
                    }
                }
            }
            if (ToolsList.Count < 2)
            {
                ToolsList.Add(new Model.Tools.Pen9Model()
                {
                    Name = "pen1",
                });
                ToolsList.Add(new Model.Tools.EraserModel()
                {
                    Name = "eras",
                });
            }
            if (ToolsList.Count > 0)
            {
                CurrentTools = ToolsList[1];
                CurrentTools = ToolsList[0];
            }
            if (Data["Error"] is string ee)
            {
                Data.Remove("Error");
                var em = new EmailMessage();
                em.Subject = "Prpaint Crash Report";
                em.Body    = ee;
                em.To.Add(new EmailRecipient("*****@*****.**"));
                EmailManager.ShowComposeNewEmailAsync(em).ToString();
            }

            Window.Current.VisibilityChanged += (s, e) => {
                if (e.Visible)
                {
                    return;
                }
                Window.Current.Activate();
                backup();
                var c = ColorList.Select(x => {
                    return(Color.ToData(x.Color));
                });
                if (c.Count() > 1)
                {
                    Data["ColorList"] = c.ToArray();
                }
                var t = ToolsList.Select(x => {
                    return(x.ToData());
                });
                if (t.Count() > 1)
                {
                    Data["ToolsList"] = t.ToArray();
                }

                Data["MainColor"] = Color.ToData(MainBrush.Color);
                Data["BackColor"] = Color.ToData(BackBrush.Color);
            };

            App.Current.UnhandledException += (sender, e) => {
                Data["Error"] = e.Exception.ToString();
                vm.backup();
            };
        }